numbox 0.2.8__py3-none-any.whl → 0.2.9__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- numbox/__init__.py +1 -1
- numbox/core/work/builder.py +19 -10
- {numbox-0.2.8.dist-info → numbox-0.2.9.dist-info}/METADATA +1 -1
- {numbox-0.2.8.dist-info → numbox-0.2.9.dist-info}/RECORD +7 -7
- {numbox-0.2.8.dist-info → numbox-0.2.9.dist-info}/LICENSE +0 -0
- {numbox-0.2.8.dist-info → numbox-0.2.9.dist-info}/WHEEL +0 -0
- {numbox-0.2.8.dist-info → numbox-0.2.9.dist-info}/top_level.txt +0 -0
numbox/__init__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = '0.2.
|
|
1
|
+
__version__ = '0.2.9'
|
numbox/core/work/builder.py
CHANGED
|
@@ -22,16 +22,18 @@ _specs_registry = dict()
|
|
|
22
22
|
class _End(NamedTuple):
|
|
23
23
|
name: str
|
|
24
24
|
init_value: Any
|
|
25
|
+
registry: dict = None
|
|
25
26
|
ty: Optional[type | Type] = None
|
|
26
27
|
|
|
27
28
|
|
|
28
29
|
def _new(cls, super_proxy, *args, **kwargs):
|
|
29
30
|
name = kwargs.get("name")
|
|
30
31
|
assert name, "`name` key-word argument has not been provided"
|
|
31
|
-
|
|
32
|
+
registry = kwargs.get("registry", _specs_registry)
|
|
33
|
+
if name in registry:
|
|
32
34
|
raise ValueError(f"Node '{name}' has already been defined on this graph. Pick a different name.")
|
|
33
35
|
spec_ = super_proxy.__new__(cls, *args, **kwargs)
|
|
34
|
-
|
|
36
|
+
registry[name] = spec_
|
|
35
37
|
return spec_
|
|
36
38
|
|
|
37
39
|
|
|
@@ -47,6 +49,7 @@ class _Derived(NamedTuple):
|
|
|
47
49
|
init_value: Any
|
|
48
50
|
derive: Callable
|
|
49
51
|
sources: Sequence[Union['Derived', End]]
|
|
52
|
+
registry: dict = None
|
|
50
53
|
ty: Optional[type | Type] = None
|
|
51
54
|
|
|
52
55
|
|
|
@@ -118,29 +121,35 @@ def code_block_hash(code_txt: str):
|
|
|
118
121
|
return sha256(code_txt.encode("utf-8")).hexdigest()
|
|
119
122
|
|
|
120
123
|
|
|
121
|
-
def _infer_end_and_derived_nodes(spec: SpecTy, all_inputs_: Dict[str, Type], all_derived_: Dict[str, Type]):
|
|
124
|
+
def _infer_end_and_derived_nodes(spec: SpecTy, all_inputs_: Dict[str, Type], all_derived_: Dict[str, Type], registry):
|
|
122
125
|
if spec.name in all_inputs_ or spec.name in all_derived_:
|
|
123
126
|
return
|
|
124
127
|
if isinstance(spec, End):
|
|
125
128
|
all_inputs_[spec.name] = get_ty(spec)
|
|
126
129
|
return
|
|
127
130
|
for source in spec.sources:
|
|
128
|
-
_infer_end_and_derived_nodes(source, all_inputs_, all_derived_)
|
|
131
|
+
_infer_end_and_derived_nodes(source, all_inputs_, all_derived_, registry)
|
|
129
132
|
all_derived_[spec.name] = get_ty(spec)
|
|
130
133
|
|
|
131
134
|
|
|
132
|
-
def infer_end_and_derived_nodes(access_nodes: SpecTy | Sequence[SpecTy]):
|
|
135
|
+
def infer_end_and_derived_nodes(access_nodes: SpecTy | Sequence[SpecTy], registry):
|
|
133
136
|
all_inputs_ = dict()
|
|
134
137
|
all_derived_ = dict()
|
|
135
138
|
for access_node in access_nodes:
|
|
136
|
-
_infer_end_and_derived_nodes(access_node, all_inputs_, all_derived_)
|
|
137
|
-
all_inputs_lst = [
|
|
138
|
-
all_derived_lst = [
|
|
139
|
+
_infer_end_and_derived_nodes(access_node, all_inputs_, all_derived_, registry)
|
|
140
|
+
all_inputs_lst = [registry[name] for name in all_inputs_.keys()]
|
|
141
|
+
all_derived_lst = [registry[name] for name in all_derived_.keys()]
|
|
139
142
|
return all_inputs_lst, all_derived_lst
|
|
140
143
|
|
|
141
144
|
|
|
142
|
-
def make_graph(
|
|
143
|
-
|
|
145
|
+
def make_graph(
|
|
146
|
+
*access_nodes: SpecTy | Sequence[SpecTy],
|
|
147
|
+
registry: Optional[dict] = None,
|
|
148
|
+
jit_options: Optional[dict] = None
|
|
149
|
+
):
|
|
150
|
+
if registry is None:
|
|
151
|
+
registry = _specs_registry
|
|
152
|
+
all_inputs_, all_derived_ = infer_end_and_derived_nodes(access_nodes, registry)
|
|
144
153
|
if jit_options is None:
|
|
145
154
|
jit_options = {}
|
|
146
155
|
jit_options = {**default_jit_options, **jit_options}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
numbox/__init__.py,sha256=
|
|
1
|
+
numbox/__init__.py,sha256=bd8hlxKMc0Fh_2w5GWfqBtuwa8uTepTMjT8w7F-EKvY,22
|
|
2
2
|
numbox/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
3
|
numbox/core/configurations.py,sha256=0bCmxXL-QMwtvyIDhpXLeT-1KJMf_QpH0wLuEvYLGxQ,68
|
|
4
4
|
numbox/core/any/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -15,7 +15,7 @@ numbox/core/bindings/utils.py,sha256=aRtN8oUYBk9vgoUGaUJosGx0Za-vvCNwwbZg_g_-LRs
|
|
|
15
15
|
numbox/core/proxy/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
16
16
|
numbox/core/proxy/proxy.py,sha256=Wt7yzswDmeQXt0yjcTcnLi2coneowSHWXy_IFpZZJMU,3612
|
|
17
17
|
numbox/core/work/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
18
|
-
numbox/core/work/builder.py,sha256=
|
|
18
|
+
numbox/core/work/builder.py,sha256=jH9lIxpJcU-eJ8SMQe7TzV8xci7FQgK8ZOhFma0n5DI,6308
|
|
19
19
|
numbox/core/work/combine_utils.py,sha256=qTVGke_ydzaTQ7o29DFjZWZzKjRNKb0L3yJMaR3TLII,2430
|
|
20
20
|
numbox/core/work/explain.py,sha256=ESwvsTgfe0w7UnM13yyVpVDtfJyAK2A1sNdF3RNb-jU,1200
|
|
21
21
|
numbox/core/work/loader_utils.py,sha256=g83mDWidZJ8oLWP3I3rK8aGISYOO2S-w6HDgtosCyck,1572
|
|
@@ -32,8 +32,8 @@ numbox/utils/meminfo.py,sha256=ykFi8Vt0WcHI3ztgMwvpn6NqaflDSQGL8tjI01jrzm0,1759
|
|
|
32
32
|
numbox/utils/standard.py,sha256=2fPrMlSXe2TG3CIfjJOT8LQkHEH86oOOj1AvwQkYCfA,450
|
|
33
33
|
numbox/utils/timer.py,sha256=5_d690Fb3L2axJBRxtoB0qe23exBosNR4qu6cno4QfY,641
|
|
34
34
|
numbox/utils/void_type.py,sha256=IkZsjNeAIShYJtvWbvERdHnl_mbF1rCRWiM3gp6II8U,404
|
|
35
|
-
numbox-0.2.
|
|
36
|
-
numbox-0.2.
|
|
37
|
-
numbox-0.2.
|
|
38
|
-
numbox-0.2.
|
|
39
|
-
numbox-0.2.
|
|
35
|
+
numbox-0.2.9.dist-info/LICENSE,sha256=YYgNvjH_p6-1NsdrIqGJnr1GUbZzA_8DxsP6vVfM6nY,1446
|
|
36
|
+
numbox-0.2.9.dist-info/METADATA,sha256=s-0iSTOHKbHEyDL5u8DgOPcbgHSs1897HV9T3963x9E,2935
|
|
37
|
+
numbox-0.2.9.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
|
|
38
|
+
numbox-0.2.9.dist-info/top_level.txt,sha256=A67jOkfqidCSYYm6ifjN_WZyIiR1B27fjxv6nNbPvjc,7
|
|
39
|
+
numbox-0.2.9.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|