Skip to content

Commit

Permalink
removed __cinit__ from CyGraph
Browse files Browse the repository at this point in the history
  • Loading branch information
fxjung committed Aug 16, 2024
1 parent 0963a8e commit 84c9d0f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def build_extensions(self):


setup(
package_dir={"": "src"}, # Necessary for `python setup.py develop` to work
ext_modules=cythonize(
[
Extension(
Expand Down
35 changes: 17 additions & 18 deletions src/ridepy/util/spaces_cython/spaces.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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](
Expand All @@ -491,22 +506,6 @@ cdef class Graph(TransportSpace):
<vector[double]>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):
Expand Down

0 comments on commit 84c9d0f

Please sign in to comment.