toponetx.Simplex#

class toponetx.Simplex(elements: Collection, **kwargs)[source]#

Bases: Atom, Generic

A class representing a simplex in a simplicial complex.

This class represents a simplex in a simplicial complex, which is a set of nodes with a specific dimension. The simplex is immutable, and the nodes in the simplex must be hashable and unique.

Parameters:
elementsCollection[Hashable]

The nodes in the simplex.

**kwargskeyword arguments, optional

Additional attributes to be associated with the simplex.

Methods

clone()

Return a copy of the simplex.

sign(face)

Calculate the sign of the simplex with respect to a given face.

update(attributes)

Update the attributes of the atom.

validate_attributes(attributes)

Validate the attributes of the simplex.

Examples

>>> # Create a 0-dimensional simplex (point)
>>> s = tnx.Simplex((1,))
>>> # Create a 1-dimensional simplex (line segment)
>>> s = tnx.Simplex((1, 2))
>>> # Create a 2-dimensional simplex (triangle)
>>> simplex1 = tnx.Simplex((1, 2, 3))
>>> simplex2 = tnx.Simplex(("a", "b", "c"))
>>> # Create a 3-dimensional simplex (tetrahedron)
>>> simplex3 = tnx.Simplex((1, 2, 4, 5), weight=1)
__init__(elements: Collection, **kwargs) None[source]#

Methods

__init__(elements, **kwargs)

clone()

Return a copy of the simplex.

sign(face)

Calculate the sign of the simplex with respect to a given face.

update(attributes)

Update the attributes of the atom.

validate_attributes(attributes)

Validate the attributes of the simplex.

Attributes

elements

name

clone() Self[source]#

Return a copy of the simplex.

The clone method by default returns an independent shallow copy of the simplex and attributes. That is, if an attribute is a container, that container is shared by the original and the copy. Use Python’s copy.deepcopy for new containers.

Returns:
Simplex

A copy of this simplex.

sign(face: Simplex[ElementType]) int[source]#

Calculate the sign of the simplex with respect to a given face.

Parameters:
faceSimplex

A face of the simplex.

update(attributes: dict) None#

Update the attributes of the atom.

Parameters:
attributesdict

The attributes to be updated.

static validate_attributes(attributes: dict) None[source]#

Validate the attributes of the simplex.

Parameters:
attributesdict

The attributes to be validated.

Raises:
ValueError

If the attributes contain the reserved keys is_maximal or membership.