Set

class odl.set.sets.Set[source]

Bases: object

An abstract set.

Abstract Methods

Each subclass of Set must implement two methods: one to check if an object is contained in the set and one to test if two sets are equal.

Membership test: __contains__(self, other)

Test if other is a member of this set. This function provides the operator overload for in.

Parameters:
other :

Object to be tested for membership

Returns:
containsbool

True if other is a member of this set, False otherwise.

Equality test: __eq__(self, other)

Test if other is the same set as this set, i.e. both sets are of the same type and contain the same elements. This function provides the operator overload for ==.

Parameters:
other :

Object to be tested for equality.

Returns:
equalsbool

True if both sets are of the same type and contain the same elements, False otherwise.

A default implementation of the operator overload for != via __ne__(self, other) is provided as not self.__eq__(other).

Element creation (optional): element(self, inp=None)

Create an element of this set, either from scratch or from an input parameter.

Parameters:
inpoptional

Object from which to create the new element

Returns:
elementmember of this set

If inp is None, return an arbitrary element. Otherwise, return the element created from inp.

Attributes
examples

Generator creating name-value pairs of set elements.

Methods

contains_all(self, other)

Test if all elements in other are contained in this set.

contains_set(self, other)

Test if other is a subset of this set.

element(self[, inp])

Return an element from inp or from scratch.

__init__(self, /, \*args, \*\*kwargs)

Initialize self. See help(type(self)) for accurate signature.