effectful 0.2.0__py3-none-any.whl → 0.2.1__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.
- effectful/internals/unification.py +4 -3
- effectful/ops/semantics.py +8 -0
- effectful/ops/syntax.py +14 -5
- {effectful-0.2.0.dist-info → effectful-0.2.1.dist-info}/METADATA +1 -1
- {effectful-0.2.0.dist-info → effectful-0.2.1.dist-info}/RECORD +8 -8
- {effectful-0.2.0.dist-info → effectful-0.2.1.dist-info}/WHEEL +0 -0
- {effectful-0.2.0.dist-info → effectful-0.2.1.dist-info}/licenses/LICENSE.md +0 -0
- {effectful-0.2.0.dist-info → effectful-0.2.1.dist-info}/top_level.txt +0 -0
@@ -440,9 +440,10 @@ def _(typ: type | abc.ABCMeta):
|
|
440
440
|
return typ
|
441
441
|
elif types.get_original_bases(typ):
|
442
442
|
for base in types.get_original_bases(typ):
|
443
|
-
|
444
|
-
|
445
|
-
|
443
|
+
if typing.get_origin(base) is not typing.Generic:
|
444
|
+
cbase = canonicalize(base)
|
445
|
+
if cbase != object:
|
446
|
+
return cbase
|
446
447
|
return typ
|
447
448
|
else:
|
448
449
|
raise TypeError(f"Cannot canonicalize type {typ}.")
|
effectful/ops/semantics.py
CHANGED
@@ -250,6 +250,14 @@ def evaluate[T](expr: Expr[T], *, intp: Interpretation | None = None) -> Expr[T]
|
|
250
250
|
elif isinstance(expr, collections.abc.Sequence):
|
251
251
|
if isinstance(expr, str | bytes):
|
252
252
|
return typing.cast(T, expr) # mypy doesnt like ignore here, so we use cast
|
253
|
+
elif (
|
254
|
+
isinstance(expr, tuple)
|
255
|
+
and hasattr(expr, "_fields")
|
256
|
+
and all(hasattr(expr, field) for field in getattr(expr, "_fields"))
|
257
|
+
): # namedtuple
|
258
|
+
return type(expr)(
|
259
|
+
**{field: evaluate(getattr(expr, field)) for field in expr._fields}
|
260
|
+
)
|
253
261
|
else:
|
254
262
|
return type(expr)(evaluate(item) for item in expr) # type: ignore
|
255
263
|
elif isinstance(expr, collections.abc.Set):
|
effectful/ops/syntax.py
CHANGED
@@ -1161,11 +1161,20 @@ def _(x: collections.abc.Mapping, other) -> bool:
|
|
1161
1161
|
|
1162
1162
|
@syntactic_eq.register
|
1163
1163
|
def _(x: collections.abc.Sequence, other) -> bool:
|
1164
|
-
|
1165
|
-
isinstance(
|
1166
|
-
and
|
1167
|
-
and all(
|
1168
|
-
)
|
1164
|
+
if (
|
1165
|
+
isinstance(x, tuple)
|
1166
|
+
and hasattr(x, "_fields")
|
1167
|
+
and all(hasattr(x, f) for f in x._fields)
|
1168
|
+
):
|
1169
|
+
return type(other) == type(x) and all(
|
1170
|
+
syntactic_eq(getattr(x, f), getattr(other, f)) for f in x._fields
|
1171
|
+
)
|
1172
|
+
else:
|
1173
|
+
return (
|
1174
|
+
isinstance(other, collections.abc.Sequence)
|
1175
|
+
and len(x) == len(other)
|
1176
|
+
and all(syntactic_eq(a, b) for a, b in zip(x, other))
|
1177
|
+
)
|
1169
1178
|
|
1170
1179
|
|
1171
1180
|
@syntactic_eq.register(object)
|
@@ -14,13 +14,13 @@ effectful/handlers/jax/scipy/special.py,sha256=yTIECFtQVPgraonrPlyenjvcnEYchZwIZ
|
|
14
14
|
effectful/internals/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
15
15
|
effectful/internals/runtime.py,sha256=aLWol7sR1yHekn7zNz1evHKHARjiT1tnkmByLHPHBGc,1811
|
16
16
|
effectful/internals/tensor_utils.py,sha256=3QCSUqdxCXod3dsY3oRMcg36Rqr8pVX-ktEyCEkeODo,1173
|
17
|
-
effectful/internals/unification.py,sha256=
|
17
|
+
effectful/internals/unification.py,sha256=MD0beZ29by9hbJaowafBLIZuKPF5MxHXezuGpSG_wCA,30254
|
18
18
|
effectful/ops/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
19
|
-
effectful/ops/semantics.py,sha256=
|
20
|
-
effectful/ops/syntax.py,sha256=
|
19
|
+
effectful/ops/semantics.py,sha256=u6i7RTpiv5fCnOdh_pOL-5CSsO4QtW-SjfGEQiizeWk,11922
|
20
|
+
effectful/ops/syntax.py,sha256=PE9iuLIzwqFkkk99bBZWk93X4sqSUhtRPePiTQRnAdk,55825
|
21
21
|
effectful/ops/types.py,sha256=W1gZJaBnX7_nFpWrG3vfCBQPSun3Gc9PqT61ls8B3EA,6599
|
22
|
-
effectful-0.2.
|
23
|
-
effectful-0.2.
|
24
|
-
effectful-0.2.
|
25
|
-
effectful-0.2.
|
26
|
-
effectful-0.2.
|
22
|
+
effectful-0.2.1.dist-info/licenses/LICENSE.md,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
23
|
+
effectful-0.2.1.dist-info/METADATA,sha256=AgFY63eWiiFpOlvxgWa-3GOV9eSy__N0gF6ZIs5ljdc,5300
|
24
|
+
effectful-0.2.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
25
|
+
effectful-0.2.1.dist-info/top_level.txt,sha256=gtuJfrE2nXil_lZLCnqWF2KAbOnJs9ILNvK8WnkRzbs,10
|
26
|
+
effectful-0.2.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|