diff options
author | Vincent Rouvreau <vincent.rouvreau@inria.fr> | 2022-02-14 12:31:30 +0100 |
---|---|---|
committer | Vincent Rouvreau <vincent.rouvreau@inria.fr> | 2022-02-14 12:31:30 +0100 |
commit | d5ac245a6dc4ab2d6e30689fc5d95503c40b6187 (patch) | |
tree | b850ae8bbd72bb9e1cd89fe390963a1450822a55 /src/python/gudhi/simplex_tree.pyx | |
parent | 1a0551c033e55024cd0f00302cd9df1f356bab44 (diff) |
code review: ctor shall raise a TypeError when constructed from something else than a SimplexTree
Diffstat (limited to 'src/python/gudhi/simplex_tree.pyx')
-rw-r--r-- | src/python/gudhi/simplex_tree.pyx | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/python/gudhi/simplex_tree.pyx b/src/python/gudhi/simplex_tree.pyx index 8f760422..e1685ded 100644 --- a/src/python/gudhi/simplex_tree.pyx +++ b/src/python/gudhi/simplex_tree.pyx @@ -47,6 +47,7 @@ cdef class SimplexTree: :returns: An empty or a copy simplex tree. :rtype: SimplexTree + :raises TypeError: In case `other` is neither `None`, nor a `SimplexTree`. :note: If the `SimplexTree` is a copy, it requires :func:`compute_persistence` to be launched again as the persistence result is not copied. """ @@ -54,9 +55,12 @@ cdef class SimplexTree: # The real cython constructor def __cinit__(self, other = None): cdef SimplexTree ostr - if other and type(other) is SimplexTree: - ostr = <SimplexTree> other - self.thisptr = <intptr_t>(new Simplex_tree_interface_full_featured(dereference(ostr.get_ptr()))) + if other: + if type(other) is SimplexTree: + ostr = <SimplexTree> other + self.thisptr = <intptr_t>(new Simplex_tree_interface_full_featured(dereference(ostr.get_ptr()))) + else: + raise TypeError("`other` argument requires to be of type `SimplexTree`, or `None`.") else: self.thisptr = <intptr_t>(new Simplex_tree_interface_full_featured()) |