gana.sets.index#

A set of index elements (X)

Functions

display(*objs[, include, exclude, metadata, ...])

Display a Python object in all frontends.

is_(a, b, /)

Same as a is b.

Classes

I(*members[, size, start, mutable, tag, ...])

Set of index elements (X).

ICase(*values)

index cases

Math([data, url, filename, metadata])

class I(*members: str | int, size: int = None, start: int = 0, mutable: bool = False, tag: str = None, ltx: str = None, dummy: bool = False)[source]#

Bases: object

Set of index elements (X).

Parameters:
  • members (str | int, optional) – Members of the Index set.

  • size (int, optional) – Size of the Index set, creates an ordered set if given.

  • mutable (bool, optional) – If the Index set is mutable. Defaults to False.

  • tag (str, optional) – Tag/details. Defaults to None.

  • dummy (bool, optional) – If the Index set is a dummy set, elements are created immediately. Defaults to False.

Variables:
  • _ (list[X]) – Elements of the index set

  • tag (str) – Tag/details

  • ordered (bool) – Ordered set, True if size is given

  • name (str) – Name, set by the program

  • n (int) – Number id, set by the program

  • ltx (str) – LaTeX representation

Raises:
  • ValueError – If both members and size are given

  • ValueError – If indices of elements (P, V) are not compatible

  • ValueError – If index set is not ordered and step is given

Example

p = Program()
p.s1 = I('a', 'b', 'c')
p.s2 = I('a', 'd', 'e', 'f')

# Intersection
p.s1 & p.s2
# I('a')

# Union
p.s1 | p.s2
# I('a', 'b', 'c', 'd', 'e', 'f')

# Symmetric difference
p.s1 ^ p.s2
# I('b', 'c', 'd', 'e', 'f')

# Difference
p.s1 - p.s2
# I('b', 'c')
birth_elements()[source]#

Create elements for the index set

step(n: int) list[Self][source]#

Step up or down the index set

Parameters:

n (int) – Step size

Returns:

New index set stepped up or down

Return type:

I

property ltx: str#

LaTeX representation

latex(descriptive: bool = True, int_not: bool = False, dots_limit: int = 5) str[source]#

LaTeX representation

Parameters:
  • descriptive (bool, optional) – print members of the index set

  • int_not (bool, optional) – Whether to display the set in integer notation.

  • ddot_limit (int, optional) – Maximum size over which … is used to represent members.

Returns:

LaTeX representation of the index set

Return type:

str

show(descriptive: bool = True, int_not: bool = False, dots_limit: int = 5)[source]#

Display the set

Parameters:

descriptive (bool, optional) – Print members of the index set

mps(pos: int) str[source]#

MPS representation

Parameters:

pos (int) – Position of the member in the set

Returns:

MPS representation of the member at position pos

Return type:

str

lp(pos: int) str[source]#

LP representation

Parameters:

pos (int) – Position of the member in the set

birth_index(name: str, members: list[Self]) Self[source]#

Updates the parent, sets new positions and mutable/ordered attributes

Parameters:
  • name (str) – Name of the new index set

  • members (list[I]) – Members of the new index set

Returns:

New index set

Return type:

I