cf.CfList

class cf.CfList(sequence=())

Bases: _abcoll.MutableSequence

A list-like object (a ‘cf list’) suitable for CF structures.

When requesting a non-private attribute that the cf list does not have, and the _elements_atts attribute is True, instead of raising an AttributeError a cf list is returned containing the values of the attribute from each of the elements, with a value of None if an element does not have the attribute. The setting of an attribute is as usual, i.e. it is set on the object itself rather that the object’s elements.

Parameters:sequence (iterable) – Optional. Initialize new list from sequence’s items.

Overloaded operators

The in (set membership), == and != operators are overloaded to use numerically tolerant equality.

The +, *, += and *= operators behave as for a built-in list. Note in particular that in-place changes to an element of the result of one of these operations will affect the equivalent element on the right hand side, and possibly other equivalent elements in the result itself.

Attribute (type) Description
_atol (NoneType or float) Optional. Absolute tolerance for numeric equality. Unset is equivalent to None, which implies a default value. Refer to cf.
_elements_atts (bool) If True then do not raise an exception when requesting a non-existent attribute, but broadcast the request to each element of the list.
_rtol (NoneType or float) Optional. Relative tolerance for numeric equality. Unset is equivalent to None, which implies a default value. Refer to cf.
Method Description
append() As for a built-in list.
copy() Create a deep copy.
count() As for a built-in list but using numerically tolerant equality.
equals() Determine whether two lists are congruent element-wise.
extend() As for a built-in list.
index() As for a built-in list but using numerically tolerant equality.
insert() As for a built-in list.
pop() As for a built-in list.
properties() Return a set of writable, public attributes.
remove() As for a built-in list.
reverse() As for a built-in list.
sort() As for a built-in list.
copy()

Create a deep copy of the list. Equivalent to calling copy.deepcopy on the list.

Returns:A deep copy of the list.
count(value)
Returns:The number of occurrences of value using numerically tolerant equality.
equals(other, rtol=None, atol=None, override=True)

Return True if two instances are congruent in that each pair of their elements are equal.

Equality of numbers is to within a tolerance. Refer to cf for details.

Parameters:
  • other (object) – The variable to compare against for equality.
  • atol (None or float) – Optional. If None then use the default method for setting the absolute tolerance for equality of real numbers (refer to cf for details). If a float then set the absolute tolerance to this value for all comparisons (refer to the override parameter).
  • override (bool) – Optional. If False then only use a float value of the rtol or atol parameters if it can not be set from attributes of the objects being compared.
  • rtol (None or float) – Optional. If None then use the default method for setting the relative tolerance for equality of real numbers (refer to cf for details). If a float then set the relative tolerance to this value for all comparisons (refer to the override parameter).
Returns:

True if the two objects are congruent, False otherwise.

index(value, start=0, stop=None)
Returns:The first index of value using numerically tolerant equality. Restrict the search to the slice start:stop. If stop is None then the slice is :obj:`start:`cf.
insert(index, object)

L.insert(index, object) – insert object before index

properties(nc=False)

Return a set of writable, public attribute names, excluding methods.

An attribute created by assigning directly to the __dict__ dictionary (as opposed to using setattr()) will not appear in this set.

Parameters:nc (bool) – If False then exclude attributes whose names begin “nc”.
Returns:A set of attribute names.

Previous topic

cf.CfDict

Next topic

cf.Comparison

This Page