egglog 6.1.0__cp311-none-win_amd64.whl → 7.1.0__cp311-none-win_amd64.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.
Potentially problematic release.
This version of egglog might be problematic. Click here for more details.
- egglog/__init__.py +1 -1
- egglog/bindings.cp311-win_amd64.pyd +0 -0
- egglog/bindings.pyi +9 -0
- egglog/builtins.py +42 -2
- egglog/conversion.py +177 -0
- egglog/declarations.py +354 -734
- egglog/egraph.py +602 -800
- egglog/egraph_state.py +456 -0
- egglog/exp/array_api.py +100 -88
- egglog/exp/array_api_numba.py +6 -1
- egglog/exp/siu_examples.py +35 -0
- egglog/pretty.py +464 -0
- egglog/runtime.py +279 -431
- egglog/thunk.py +71 -0
- egglog/type_constraint_solver.py +5 -2
- {egglog-6.1.0.dist-info → egglog-7.1.0.dist-info}/METADATA +7 -7
- {egglog-6.1.0.dist-info → egglog-7.1.0.dist-info}/RECORD +19 -14
- {egglog-6.1.0.dist-info → egglog-7.1.0.dist-info}/WHEEL +0 -0
- {egglog-6.1.0.dist-info → egglog-7.1.0.dist-info}/license_files/LICENSE +0 -0
egglog/thunk.py
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
from typing import TYPE_CHECKING, Generic, TypeVar
|
|
5
|
+
|
|
6
|
+
from typing_extensions import TypeVarTuple, Unpack
|
|
7
|
+
|
|
8
|
+
if TYPE_CHECKING:
|
|
9
|
+
from collections.abc import Callable
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
__all__ = ["Thunk"]
|
|
13
|
+
|
|
14
|
+
T = TypeVar("T")
|
|
15
|
+
TS = TypeVarTuple("TS")
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@dataclass
|
|
19
|
+
class Thunk(Generic[T, Unpack[TS]]):
|
|
20
|
+
"""
|
|
21
|
+
Cached delayed function call.
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
state: Resolved[T] | Unresolved[T, Unpack[TS]] | Resolving[T]
|
|
25
|
+
|
|
26
|
+
@classmethod
|
|
27
|
+
def fn(
|
|
28
|
+
cls, fn: Callable[[Unpack[TS]], T], *args: Unpack[TS], fallback: Callable[[], T] | None = None
|
|
29
|
+
) -> Thunk[T, Unpack[TS]]:
|
|
30
|
+
"""
|
|
31
|
+
Create a thunk based on some functions and some partial args.
|
|
32
|
+
|
|
33
|
+
If the function is called while it is being resolved recursively, will instead return the fallback, if provided.
|
|
34
|
+
"""
|
|
35
|
+
return cls(Unresolved(fn, args, fallback))
|
|
36
|
+
|
|
37
|
+
@classmethod
|
|
38
|
+
def value(cls, value: T) -> Thunk[T]:
|
|
39
|
+
return Thunk(Resolved(value))
|
|
40
|
+
|
|
41
|
+
def __call__(self) -> T:
|
|
42
|
+
match self.state:
|
|
43
|
+
case Resolved(value):
|
|
44
|
+
return value
|
|
45
|
+
case Unresolved(fn, args, fallback):
|
|
46
|
+
self.state = Resolving(fallback)
|
|
47
|
+
res = fn(*args)
|
|
48
|
+
self.state = Resolved(res)
|
|
49
|
+
return res
|
|
50
|
+
case Resolving(fallback):
|
|
51
|
+
if fallback is None:
|
|
52
|
+
msg = "Recursively resolving thunk without fallback"
|
|
53
|
+
raise ValueError(msg)
|
|
54
|
+
return fallback()
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
@dataclass
|
|
58
|
+
class Resolved(Generic[T]):
|
|
59
|
+
value: T
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
@dataclass
|
|
63
|
+
class Unresolved(Generic[T, Unpack[TS]]):
|
|
64
|
+
fn: Callable[[Unpack[TS]], T]
|
|
65
|
+
args: tuple[Unpack[TS]]
|
|
66
|
+
fallback: Callable[[], T] | None
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
@dataclass
|
|
70
|
+
class Resolving(Generic[T]):
|
|
71
|
+
fallback: Callable[[], T] | None
|
egglog/type_constraint_solver.py
CHANGED
|
@@ -14,6 +14,7 @@ from .declarations import *
|
|
|
14
14
|
if TYPE_CHECKING:
|
|
15
15
|
from collections.abc import Collection, Iterable
|
|
16
16
|
|
|
17
|
+
|
|
17
18
|
__all__ = ["TypeConstraintSolver", "TypeConstraintError"]
|
|
18
19
|
|
|
19
20
|
|
|
@@ -38,10 +39,11 @@ class TypeConstraintSolver:
|
|
|
38
39
|
Bind the typevars of a class to the given types.
|
|
39
40
|
Used for a situation like Map[int, str].create().
|
|
40
41
|
"""
|
|
41
|
-
|
|
42
|
+
name = ref.name
|
|
43
|
+
cls_typevars = self._decls.get_class_decl(name).type_vars
|
|
42
44
|
if len(cls_typevars) != len(ref.args):
|
|
43
45
|
raise TypeConstraintError(f"Mismatch of typevars {cls_typevars} and {ref}")
|
|
44
|
-
bound_typevars = self._cls_typevar_index_to_type[
|
|
46
|
+
bound_typevars = self._cls_typevar_index_to_type[name]
|
|
45
47
|
for i, arg in enumerate(ref.args):
|
|
46
48
|
bound_typevars[cls_typevars[i]] = arg
|
|
47
49
|
|
|
@@ -117,6 +119,7 @@ class TypeConstraintSolver:
|
|
|
117
119
|
if cls_name is None:
|
|
118
120
|
msg = "Cannot infer typevar without class name"
|
|
119
121
|
raise RuntimeError(msg)
|
|
122
|
+
|
|
120
123
|
class_typevars = self._cls_typevar_index_to_type[cls_name]
|
|
121
124
|
if typevar in class_typevars:
|
|
122
125
|
if class_typevars[typevar] != arg:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: egglog
|
|
3
|
-
Version:
|
|
3
|
+
Version: 7.1.0
|
|
4
4
|
Classifier: Environment :: MacOS X
|
|
5
5
|
Classifier: Environment :: Win32 (MS Windows)
|
|
6
6
|
Classifier: Intended Audience :: Developers
|
|
@@ -19,15 +19,15 @@ Classifier: Typing :: Typed
|
|
|
19
19
|
Requires-Dist: typing-extensions
|
|
20
20
|
Requires-Dist: black
|
|
21
21
|
Requires-Dist: graphviz
|
|
22
|
+
Requires-Dist: scikit-learn; extra == 'array'
|
|
23
|
+
Requires-Dist: array_api_compat; extra == 'array'
|
|
24
|
+
Requires-Dist: numba==0.59.1; extra == 'array'
|
|
25
|
+
Requires-Dist: llvmlite==0.42.0; extra == 'array'
|
|
22
26
|
Requires-Dist: pre-commit; extra == 'dev'
|
|
23
27
|
Requires-Dist: ruff; extra == 'dev'
|
|
24
28
|
Requires-Dist: mypy; extra == 'dev'
|
|
25
29
|
Requires-Dist: anywidget[dev]; extra == 'dev'
|
|
26
30
|
Requires-Dist: egglog[docs,test]; extra == 'dev'
|
|
27
|
-
Requires-Dist: scikit-learn; extra == 'array'
|
|
28
|
-
Requires-Dist: array_api_compat; extra == 'array'
|
|
29
|
-
Requires-Dist: numba==0.59.0rc1; extra == 'array'
|
|
30
|
-
Requires-Dist: llvmlite==0.42.0rc1; extra == 'array'
|
|
31
31
|
Requires-Dist: pytest; extra == 'test'
|
|
32
32
|
Requires-Dist: mypy; extra == 'test'
|
|
33
33
|
Requires-Dist: syrupy; extra == 'test'
|
|
@@ -47,8 +47,8 @@ Requires-Dist: egglog[array]; extra == 'docs'
|
|
|
47
47
|
Requires-Dist: line-profiler; extra == 'docs'
|
|
48
48
|
Requires-Dist: sphinxcontrib-mermaid; extra == 'docs'
|
|
49
49
|
Requires-Dist: ablog; extra == 'docs'
|
|
50
|
-
Provides-Extra: dev
|
|
51
50
|
Provides-Extra: array
|
|
51
|
+
Provides-Extra: dev
|
|
52
52
|
Provides-Extra: test
|
|
53
53
|
Provides-Extra: docs
|
|
54
54
|
License-File: LICENSE
|
|
@@ -59,7 +59,7 @@ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
|
59
59
|
|
|
60
60
|
# `egglog` Python wrapper
|
|
61
61
|
|
|
62
|
-
[](https://egglog-python.readthedocs.io/
|
|
62
|
+
[](https://egglog-python.readthedocs.io/latest/?badge=latest) [](https://github.com/egraphs-good/egglog-python/actions/workflows/CI.yml) [](https://pypi.org/project/egglog/) [](https://pypi.org/project/egglog/) [](https://pypi.org/project/egglog/) [](https://github.com/pre-commit/pre-commit) [](https://codspeed.io/egraphs-good/egglog-python)
|
|
63
63
|
|
|
64
64
|
`egglog` is a Python package that provides bindings to the Rust library [`egglog`](https://github.com/egraphs-good/egglog/),
|
|
65
65
|
allowing you to use e-graphs in Python for optimization, symbolic computation, and analysis.
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
egglog-
|
|
2
|
-
egglog-
|
|
3
|
-
egglog-
|
|
4
|
-
egglog/bindings.pyi,sha256=
|
|
5
|
-
egglog/builtins.py,sha256=
|
|
1
|
+
egglog-7.1.0.dist-info/METADATA,sha256=t8YGDTCeCIpcJMDrAiicXrJAARElS-vM1R6-GY4wNzE,3829
|
|
2
|
+
egglog-7.1.0.dist-info/WHEEL,sha256=PI_yinHuPssCo943lUdZTaSBEwIUzDPKgEICR1imaRE,96
|
|
3
|
+
egglog-7.1.0.dist-info/license_files/LICENSE,sha256=TfaboMVZ81Q6OUaKjU7z6uVjSlcGKclLYcOpgDbm9_s,1091
|
|
4
|
+
egglog/bindings.pyi,sha256=iFdtYHqPjuVt46qh1IE81cOI-lbGgPISKQB-3ERNzhI,11770
|
|
5
|
+
egglog/builtins.py,sha256=p5oZLDleCgQC8G2Zp2EvmqsfVnpgmARqUHqosKSSKnQ,13120
|
|
6
6
|
egglog/config.py,sha256=mALVaxh7zmGrbuyzaVKVmYKcu1lF703QsKJw8AF7gSM,176
|
|
7
|
-
egglog/
|
|
8
|
-
egglog/
|
|
7
|
+
egglog/conversion.py,sha256=4JhocGd1_nwmFMVNCzDDwj6aWfhBFTX2hm_7Xc_DiUM,6328
|
|
8
|
+
egglog/declarations.py,sha256=LFClid1ojrQFF7ezJSanwZA89j01fjJ-NkvH0VUH0Wk,16199
|
|
9
|
+
egglog/egraph.py,sha256=WRu_omk-5i53wokpkSTw9wA2EqW_WI2-ZX8340_w3q8,66198
|
|
10
|
+
egglog/egraph_state.py,sha256=ic6MEL41-DjozBCe-GSKqHM2vkabuC865odeg_zT964,20074
|
|
9
11
|
egglog/examples/bool.py,sha256=pWZTjfXR1cFy3KcihLBU5AF5rn83ImORlhUUJ1YiAXc,733
|
|
10
12
|
egglog/examples/eqsat_basic.py,sha256=ORXFYYEDsEZK2IPhHtoFsd-LdjMiQi1nn7kix4Nam0s,1011
|
|
11
13
|
egglog/examples/fib.py,sha256=wAn-PjazxgHDkXAU4o2xTk_GtM_iGL0biV66vWM1st4,520
|
|
@@ -16,19 +18,22 @@ egglog/examples/README.rst,sha256=QrbfmivODBvUvmY3-dHarcbC6bEvwoqAfTDhiI-aJxU,23
|
|
|
16
18
|
egglog/examples/resolution.py,sha256=sKkbRI_v9XkQM0DriacKLINqKKDqYGFhvMCAS9tZbTA,2203
|
|
17
19
|
egglog/examples/schedule_demo.py,sha256=iJtIbcLaZ7zK8UalY0z7KAKMqYjQx0MKTsNF24lKtik,652
|
|
18
20
|
egglog/examples/__init__.py,sha256=KuhaJFOyz_rpUvEqZubsgLnv6rhQNE_AVFXA6bUnpdY,34
|
|
19
|
-
egglog/exp/array_api.py,sha256=
|
|
21
|
+
egglog/exp/array_api.py,sha256=diQNK-Uxxt6Qr58zJuQDM_BF6eKgwa-D5eYB5VJoT70,41412
|
|
20
22
|
egglog/exp/array_api_jit.py,sha256=HIZzd0G17u-u_F4vfRdhoYvRo-ETx5HFO3RBcOfLcco,1287
|
|
21
|
-
egglog/exp/array_api_numba.py,sha256=
|
|
23
|
+
egglog/exp/array_api_numba.py,sha256=OjONBLdFRukx4vKiNK_rBxjMzsxbWpMEdD7JcGHJjmY,2924
|
|
22
24
|
egglog/exp/array_api_program_gen.py,sha256=crgUYXXNhQdfTq31FSIpWLIfzNsgQD8ngg3OosCtIgg,19680
|
|
23
25
|
egglog/exp/program_gen.py,sha256=2qlfc-dVSNbPFQVl0eIzUzf-yw28AeaARa4PUC1xtRA,12257
|
|
26
|
+
egglog/exp/siu_examples.py,sha256=KZmpkSCgbL4uqHhx2Jh9Adz1_cDbkIlyXPa1Kh_0O_8,784
|
|
24
27
|
egglog/exp/__init__.py,sha256=G9zeKUcPBgIhgUg1meC86OfZVFETYIugyHWseTcCe_0,52
|
|
25
28
|
egglog/graphviz_widget.py,sha256=YtI7LCFWHihDQ1qLvdj2SVYEcuZLSooFUYheunOTxdc,1339
|
|
26
29
|
egglog/ipython_magic.py,sha256=VA19xAb6Sz7-IxlJBbnZW_gVFDqaYNnvdMB9QitndjE,1254
|
|
30
|
+
egglog/pretty.py,sha256=4YzItMaXSQw2xzId9pnjUikOojwE6G7Hg0_M4sOGJ84,19071
|
|
27
31
|
egglog/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
28
|
-
egglog/runtime.py,sha256=
|
|
29
|
-
egglog/
|
|
32
|
+
egglog/runtime.py,sha256=P5wKThFglf2l5AynxgVAryyNjvLtFMbou7JCSSsORno,23013
|
|
33
|
+
egglog/thunk.py,sha256=jYMb4owraT-3zGQEYkqMK76hk39Qdpc6bfEa7CVkjcg,1894
|
|
34
|
+
egglog/type_constraint_solver.py,sha256=0c8oy-sLCVN0XndfAyRxO1AvIgfQuszw0NaRJ9ILysE,5692
|
|
30
35
|
egglog/widget.css,sha256=WJS2M1wQdujhSTCakMa_ZXuoTPre1Uy1lPcvBE1LZQU,102
|
|
31
36
|
egglog/widget.js,sha256=UNOER3sYZ-bS7Qhw9S6qtpR81FuHa5DzXQaWWtQq334,2021
|
|
32
|
-
egglog/__init__.py,sha256=
|
|
33
|
-
egglog/bindings.cp311-win_amd64.pyd,sha256
|
|
34
|
-
egglog-
|
|
37
|
+
egglog/__init__.py,sha256=iUrVe5fb0XFyMCS3CwTjwhKEtU8KpIkdTpJpnUhm8o0,247
|
|
38
|
+
egglog/bindings.cp311-win_amd64.pyd,sha256=HtRJQhBePNNPAlvsmJqmdaQQwL-gCnTi2hXPcOKIXqw,4591104
|
|
39
|
+
egglog-7.1.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|