Ob#

class discopy.cat.Ob(name='')[source]#

Bases: object

An object with a string as name.

Parameters:

name (str) – The name of the object.

Example

>>> x, x_, y = Ob('x'), Ob('x'), Ob('y')
>>> assert x == x_ and x != y
to_tree()[source]#

Serialise a DisCoPy object, see dumps().

Example

>>> Ob('x').to_tree()
{'factory': 'cat.Ob', 'name': 'x'}
Return type:

dict

classmethod from_tree(tree)[source]#

Decode a serialised DisCoPy object, see loads().

Parameters:

tree (dict) – DisCoPy serialisation.

Return type:

Ob

Example

>>> x = Ob('x')
>>> assert Ob.from_tree(x.to_tree()) == x