Skip to content

Commit 6b43923

Browse files
committed
Add default_callable for some random network generics
1 parent 963eb78 commit 6b43923

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

src/reticula/__init__.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,14 @@
1616
pair = _generic_attribute(
1717
attr_prefix="pair",
1818
arg_names=("vertex_type", "vertex_type"),
19-
options={(i, j)
20-
for i in _simple_vertex_types for j in _simple_vertex_types},
19+
options={(i, i) for i in _simple_vertex_types},
2120
function_module=_reticula_ext,
2221
api_module_name=__name__)
2322

23+
_pair_vertex_types = set([
24+
getattr(_reticula_ext, f"pair_{i.__name__}_{i.__name__}")
25+
for i in _simple_vertex_types])
26+
2427
_static_edge_prefixes = [
2528
"directed_edge", "undirected_edge",
2629
"directed_hyperedge", "undirected_hyperedge"]
@@ -92,13 +95,14 @@
9295

9396
_time_types = set(_reticula_ext.types.time_types)
9497

98+
_temporal_edge_verts = _simple_vertex_types | _pair_vertex_types
9599
for _e in _temporal_edge_prefixes:
96100
setattr(_sys.modules[__name__],
97101
_e, _generic_attribute(
98102
attr_prefix=_e,
99103
arg_names=("vertex_type", "time_type"),
100104
options={(v, t)
101-
for v in _all_vertex_types for t in _time_types},
105+
for v in _temporal_edge_verts for t in _time_types},
102106
function_module=_reticula_ext,
103107
api_module_name=__name__))
104108
_n = _e[:-4] + "network"
@@ -107,7 +111,7 @@
107111
attr_prefix=_n,
108112
arg_names=("vertex_type", "time_type"),
109113
options={(v, t)
110-
for v in _all_vertex_types for t in _time_types},
114+
for v in _temporal_edge_verts for t in _time_types},
111115
function_module=_reticula_ext,
112116
api_module_name=__name__))
113117

@@ -202,7 +206,8 @@
202206
arg_names=("integer_vertex_type",),
203207
options={(t,) for t in _integer_vertex_types},
204208
function_module=_reticula_ext,
205-
api_module_name=__name__))
209+
api_module_name=__name__,
210+
default_callable=getattr(_reticula_ext, _a+"_int64")))
206211

207212
_integer_vertex_generic_generators = [
208213
"square_grid_graph", "path_graph", "cycle_graph",
@@ -215,7 +220,8 @@
215220
arg_names=("integer_vertex_type",),
216221
options={(t,) for t in _integer_vertex_types},
217222
function_module=_reticula_ext,
218-
api_module_name=__name__))
223+
api_module_name=__name__,
224+
default_callable=getattr(_reticula_ext, _a+"_int64")))
219225

220226
from ._reticula_ext import (
221227
random_link_activation_temporal_network,

0 commit comments

Comments
 (0)