Skip to content

Commit e911635

Browse files
committed
feat: added type definitions for most enums
1 parent 601cbf0 commit e911635

File tree

4 files changed

+536
-37
lines changed

4 files changed

+536
-37
lines changed

src/codegen/run.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,21 @@ def generate_enums(template: Path, output: Path, headers: Iterable[Path]):
4848
ENUM_NAME_REMAPPING = {
4949
"Adjacency": "AdjacencyMode",
5050
"BlissSh": "BLISSSplittingHeuristics",
51+
"Degseq": "DegreeSequenceMode",
5152
"EdgeorderType": "EdgeOrder",
5253
"EitType": "EdgeIteratorType",
5354
"EsType": "EdgeSequenceType",
54-
"FasAlgorithm": "FASAlgorithm",
55+
"FasAlgorithm": "FeedbackArcSetAlgorithm",
5556
"FileformatType": "FileFormat",
5657
"LayoutDrlDefault": "DRLLayoutPreset",
5758
"Loops": None,
5859
"Neimode": "NeighborMode",
60+
"Optimal": "Optimality",
5961
"PagerankAlgo": "PagerankAlgorithm",
62+
"RandomTree": "RandomTreeMethod",
6063
"SparsematType": "SparseMatrixType",
6164
"SparsematSolve": "SparseMatrixSolver",
65+
"SpincommUpdate": "SpinglassUpdateMode",
6266
"VitType": "VertexIteratorType",
6367
"VsType": "VertexSequenceType",
6468
}

src/codegen/types.yaml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ REAL:
1717
INCONV:
1818
OUT: "%C% = igraph_real_t()"
1919

20+
INT:
21+
PY_TYPE: int
22+
INCONV:
23+
OUT: "%C% = c_int()"
24+
25+
DOUBLE:
26+
PY_TYPE: float
27+
INCONV:
28+
OUT: "%C% = c_double()"
29+
2030
CSTRING:
2131
PY_TYPE: str
2232

@@ -170,6 +180,46 @@ ADJACENCY_MODE:
170180
INCONV:
171181
IN: "%C% = c_int(%I%)"
172182

183+
BARABASI_ALGORITHM:
184+
PY_TYPE: BarabasiAlgorithm
185+
INCONV:
186+
IN: "%C% = c_int(%I%)"
187+
188+
COMMCMP:
189+
PY_TYPE: CommunityComparison
190+
INCONV:
191+
IN: "%C% = c_int(%I%)"
192+
193+
CONNECTEDNESS:
194+
PY_TYPE: Connectedness
195+
INCONV:
196+
IN: "%C% = c_int(%I%)"
197+
198+
DEGSEQ_MODE:
199+
PY_TYPE: DegreeSequenceMode
200+
INCONV:
201+
IN: "%C% = c_int(%I%)"
202+
203+
EIGENALGO:
204+
PY_TYPE: EigenAlgorithm
205+
INCONV:
206+
IN: "%C% = c_int(%I%)"
207+
208+
FAS_ALGORITHM:
209+
PY_TYPE: FeedbackArcSetAlgorithm
210+
INCONV:
211+
IN: "%C% = c_int(%I%)"
212+
213+
FWALGORITHM:
214+
PY_TYPE: FloydWarshallAlgorithm
215+
INCONV:
216+
IN: "%C% = c_int(%I%)"
217+
218+
IMITATE_ALGORITHM:
219+
PY_TYPE: ImitateAlgorithm
220+
INCONV:
221+
IN: "%C% = c_int(%I%)"
222+
173223
LOOPS:
174224
PY_TYPE: Loops
175225
INCONV:
@@ -180,11 +230,61 @@ NEIMODE:
180230
INCONV:
181231
IN: "%C% = c_int(%I%)"
182232

233+
OPTIMALITY:
234+
PY_TYPE: Optimality
235+
INCONV:
236+
IN: "%C% = c_int(%I%)"
237+
238+
PAGERANKALGO:
239+
PY_TYPE: PagerankAlgorithm
240+
INCONV:
241+
IN: "%C% = c_int(%I%)"
242+
243+
RANDOM_TREE_METHOD:
244+
PY_TYPE: RandomTreeMethod
245+
INCONV:
246+
IN: "%C% = c_int(%I%)"
247+
248+
RECIP:
249+
PY_TYPE: Reciprocity
250+
INCONV:
251+
IN: "%C% = c_int(%I%)"
252+
253+
REWIRING_MODE:
254+
PY_TYPE: Rewiring
255+
INCONV:
256+
IN: "%C% = c_int(%I%)"
257+
258+
ROOTCHOICE:
259+
PY_TYPE: RootChoice
260+
INCONV:
261+
IN: "%C% = c_int(%I%)"
262+
263+
RWSTUCK:
264+
PY_TYPE: RandomWalkStuck
265+
INCONV:
266+
IN: "%C% = c_int(%I%)"
267+
268+
SPINCOMMUPDATE:
269+
PY_TYPE: SpinglassUpdateMode
270+
INCONV:
271+
IN: "%C% = c_int(%I%)"
272+
273+
SPINGLASS_IMPLEMENTATION:
274+
PY_TYPE: SpinglassImplementation
275+
INCONV:
276+
IN: "%C% = c_int(%I%)"
277+
183278
STAR_MODE:
184279
PY_TYPE: StarMode
185280
INCONV:
186281
IN: "%C% = c_int(%I%)"
187282

283+
SUBGRAPH_IMPL:
284+
PY_TYPE: SubgraphImplementation
285+
INCONV:
286+
IN: "%C% = c_int(%I%)"
287+
188288
TRANSITIVITY_MODE:
189289
PY_TYPE: TransitivityMode
190290
INCONV:
@@ -195,6 +295,11 @@ TREE_MODE:
195295
INCONV:
196296
IN: "%C% = c_int(%I%)"
197297

298+
VORONOI_TIEBREAKER:
299+
PY_TYPE: VoronoiTiebreaker
300+
INCONV:
301+
IN: "%C% = c_int(%I%)"
302+
198303
WHEEL_MODE:
199304
PY_TYPE: WheelMode
200305
INCONV:

src/igraph_ctypes/_internal/enums.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class Order(IntEnum):
131131
DESCENDING = 1
132132

133133

134-
class Optimal(IntEnum):
134+
class Optimality(IntEnum):
135135
"""Python counterpart of an ``igraph_optimal_t`` enum."""
136136

137137
MINIMUM = 0
@@ -213,7 +213,7 @@ class GetAdjacency(IntEnum):
213213
BOTH = 2
214214

215215

216-
class Degseq(IntEnum):
216+
class DegreeSequenceMode(IntEnum):
217217
"""Python counterpart of an ``igraph_degseq_t`` enum."""
218218

219219
CONFIGURATION = 0
@@ -231,7 +231,7 @@ class RealizeDegseq(IntEnum):
231231
INDEX = 2
232232

233233

234-
class RandomTree(IntEnum):
234+
class RandomTreeMethod(IntEnum):
235235
"""Python counterpart of an ``igraph_random_tree_t`` enum."""
236236

237237
PRUFER = 0
@@ -289,7 +289,7 @@ class VconnNei(IntEnum):
289289
NEGATIVE = 3
290290

291291

292-
class SpincommUpdate(IntEnum):
292+
class SpinglassUpdateMode(IntEnum):
293293
"""Python counterpart of an ``igraph_spincomm_update_t`` enum."""
294294

295295
SIMPLE = 0
@@ -343,7 +343,7 @@ class BarabasiAlgorithm(IntEnum):
343343
PSUMTREE_MULTIPLE = 2
344344

345345

346-
class FASAlgorithm(IntEnum):
346+
class FeedbackArcSetAlgorithm(IntEnum):
347347
"""Python counterpart of an ``igraph_fas_algorithm_t`` enum."""
348348

349349
EXACT_IP = 0
@@ -533,14 +533,14 @@ class LeadingEigenvectorCommunityHistory(IntEnum):
533533
'CommunityComparison',
534534
'Connectedness',
535535
'DRLLayoutPreset',
536-
'Degseq',
536+
'DegreeSequenceMode',
537537
'EdgeIteratorType',
538538
'EdgeOrder',
539539
'EdgeSequenceType',
540540
'EigenAlgorithm',
541541
'ErdosRenyi',
542542
'ErrorType',
543-
'FASAlgorithm',
543+
'FeedbackArcSetAlgorithm',
544544
'FileFormat',
545545
'FloydWarshallAlgorithm',
546546
'GetAdjacency',
@@ -554,19 +554,19 @@ class LeadingEigenvectorCommunityHistory(IntEnum):
554554
'MatrixStorage',
555555
'Multiple',
556556
'NeighborMode',
557-
'Optimal',
557+
'Optimality',
558558
'Order',
559559
'PagerankAlgorithm',
560-
'RandomTree',
560+
'RandomTreeMethod',
561561
'RandomWalkStuck',
562562
'RealizeDegseq',
563563
'Reciprocity',
564564
'Rewiring',
565565
'RootChoice',
566566
'SparseMatrixSolver',
567567
'SparseMatrixType',
568-
'SpincommUpdate',
569568
'SpinglassImplementation',
569+
'SpinglassUpdateMode',
570570
'StarMode',
571571
'SubgraphImplementation',
572572
'ToDirected',

0 commit comments

Comments
 (0)