From 84c9d0f6a3c111924984f0aa88a20494e4b492c5 Mon Sep 17 00:00:00 2001 From: Felix Jung Date: Fri, 16 Aug 2024 17:20:11 +0200 Subject: [PATCH] removed __cinit__ from CyGraph --- setup.py | 1 + src/ridepy/util/spaces_cython/spaces.pyx | 35 ++++++++++++------------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/setup.py b/setup.py index 826e6577..1aa92f5a 100644 --- a/setup.py +++ b/setup.py @@ -21,6 +21,7 @@ def build_extensions(self): setup( + package_dir={"": "src"}, # Necessary for `python setup.py develop` to work ext_modules=cythonize( [ Extension( diff --git a/src/ridepy/util/spaces_cython/spaces.pyx b/src/ridepy/util/spaces_cython/spaces.pyx index 9508c62c..416daf20 100644 --- a/src/ridepy/util/spaces_cython/spaces.pyx +++ b/src/ridepy/util/spaces_cython/spaces.pyx @@ -471,8 +471,23 @@ cdef class Graph(TransportSpace): """ Weighted directed graph with integer node labels. """ - def __cinit__(self, vertices, edges, weights=None, double velocity=1): - self.loc_type = LocType.INT + + def __init__(self, vertices, edges, weights=None, double velocity=1): + """ + Parameters + ---------- + vertices : Sequence[int] + sequence of vertices + edges : Sequence[Tuple[int, int]] + sequence of edge tuples + weights : Union[None, float, Sequence[float]] + Edge weights. + - if None is supplied, the resulting graph is unweighted (unit edge length) + - if a single float is supplied, every edge length will be equal to this number + - if a sequence is supplied, this will be mapped onto the edge sequence + velocity + constant velocity to compute travel time, optional. default: 1 + """ if weights is None: self.derived_ptr = self.u_space.space_int_ptr = new CGraphSpace[ulonglong]( @@ -491,22 +506,6 @@ cdef class Graph(TransportSpace): weights ) - def __init__(self, *args, **kwargs): # remember both __cinit__ and __init__ gets the same arguments passed - """ - Parameters - ---------- - vertices : Sequence[int] - sequence of vertices - edges : Sequence[Tuple[int, int]] - sequence of edge tuples - weights : Union[None, float, Sequence[float]] - Edge weights. - - if None is supplied, the resulting graph is unweighted (unit edge length) - - if a single float is supplied, every edge length will be equal to this number - - if a sequence is supplied, this will be mapped onto the edge sequence - velocity - constant velocity to compute travel time, optional. default: 1 - """ TransportSpace.__init__(self, loc_type=LocType.INT) def __dealloc__(self):