Skip to content

Commit

Permalink
Merge pull request GUDHI#871 from VincentRouvreau/stree_magic_methods…
Browse files Browse the repository at this point in the history
…_documentation

Document SimplexTree __eq__, __getstate__ and __setstate__
  • Loading branch information
VincentRouvreau authored May 9, 2023
2 parents 7df641b + d7d2049 commit 8adafa5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/python/doc/simplex_tree_ref.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ Simplex tree reference manual

.. autoclass:: gudhi.SimplexTree
:members:
:special-members: __eq__, __getstate__, __setstate__
:show-inheritance:
11 changes: 5 additions & 6 deletions src/python/gudhi/simplex_tree.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -811,16 +811,13 @@ cdef class SimplexTree:
del ptr

def __eq__(self, other:SimplexTree):
"""Test for structural equality
:returns: True if the 2 simplex trees are equal, False otherwise.
""":returns: True if the 2 complexes have the same simplices with the same filtration values, False otherwise.
:rtype: bool
"""
return dereference(self.get_ptr()) == dereference(other.get_ptr())

def __getstate__(self):
"""Pickle the SimplexTree data structure as a Python Byte Array
:raises MemoryError: In the case the serialization allocates a too large block of memory.
:returns: Serialized SimplexTree data structure
""":returns: Serialized (or flattened) SimplexTree data structure in order to pickle SimplexTree.
:rtype: numpy.array of shape (n,)
"""
cdef size_t buffer_size = self.get_ptr().get_serialization_size()
Expand All @@ -834,7 +831,9 @@ cdef class SimplexTree:
return np_buffer

def __setstate__(self, state):
"""Construct the SimplexTree data structure from a Python Byte Array
"""Construct the SimplexTree data structure from a Numpy Array (cf. :func:`~gudhi.SimplexTree.__getstate__`)
in order to unpickle a SimplexTree.
:param state: Serialized SimplexTree data structure
:type state: numpy.array of shape (n,)
"""
Expand Down

0 comments on commit 8adafa5

Please sign in to comment.