egglog 6.1.0__cp310-none-win_amd64.whl → 7.0.0__cp310-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/thunk.py ADDED
@@ -0,0 +1,72 @@
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 ParamSpec, TypeVarTuple, Unpack
7
+
8
+ if TYPE_CHECKING:
9
+ from collections.abc import Callable
10
+
11
+
12
+ __all__ = ["Thunk"]
13
+
14
+ T = TypeVar("T")
15
+ P = ParamSpec("P")
16
+ TS = TypeVarTuple("TS")
17
+
18
+
19
+ @dataclass
20
+ class Thunk(Generic[T, Unpack[TS]]):
21
+ """
22
+ Cached delayed function call.
23
+ """
24
+
25
+ state: Resolved[T] | Unresolved[T, Unpack[TS]] | Resolving[T]
26
+
27
+ @classmethod
28
+ def fn(
29
+ cls, fn: Callable[[Unpack[TS]], T], *args: Unpack[TS], fallback: Callable[[], T] | None = None
30
+ ) -> Thunk[T, Unpack[TS]]:
31
+ """
32
+ Create a thunk based on some functions and some partial args.
33
+
34
+ If the function is called while it is being resolved recursively, will instead return the fallback, if provided.
35
+ """
36
+ return cls(Unresolved(fn, args, fallback))
37
+
38
+ @classmethod
39
+ def value(cls, value: T) -> Thunk[T]:
40
+ return Thunk(Resolved(value))
41
+
42
+ def __call__(self) -> T:
43
+ match self.state:
44
+ case Resolved(value):
45
+ return value
46
+ case Unresolved(fn, args, fallback):
47
+ self.state = Resolving(fallback)
48
+ res = fn(*args)
49
+ self.state = Resolved(res)
50
+ return res
51
+ case Resolving(fallback):
52
+ if fallback is None:
53
+ msg = "Recursively resolving thunk without fallback"
54
+ raise ValueError(msg)
55
+ return fallback()
56
+
57
+
58
+ @dataclass
59
+ class Resolved(Generic[T]):
60
+ value: T
61
+
62
+
63
+ @dataclass
64
+ class Unresolved(Generic[T, Unpack[TS]]):
65
+ fn: Callable[[Unpack[TS]], T]
66
+ args: tuple[Unpack[TS]]
67
+ fallback: Callable[[], T] | None
68
+
69
+
70
+ @dataclass
71
+ class Resolving(Generic[T]):
72
+ fallback: Callable[[], T] | None
@@ -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
- cls_typevars = self._decls.get_class_decl(ref.name).type_vars
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[ref.name]
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: 6.1.0
3
+ Version: 7.0.0
4
4
  Classifier: Environment :: MacOS X
5
5
  Classifier: Environment :: Win32 (MS Windows)
6
6
  Classifier: Intended Audience :: Developers
@@ -19,22 +19,6 @@ Classifier: Typing :: Typed
19
19
  Requires-Dist: typing-extensions
20
20
  Requires-Dist: black
21
21
  Requires-Dist: graphviz
22
- Requires-Dist: pre-commit; extra == 'dev'
23
- Requires-Dist: ruff; extra == 'dev'
24
- Requires-Dist: mypy; extra == 'dev'
25
- Requires-Dist: anywidget[dev]; extra == 'dev'
26
- 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
- Requires-Dist: pytest; extra == 'test'
32
- Requires-Dist: mypy; extra == 'test'
33
- Requires-Dist: syrupy; extra == 'test'
34
- Requires-Dist: egglog[array]; extra == 'test'
35
- Requires-Dist: pytest-codspeed; extra == 'test'
36
- Requires-Dist: pytest-benchmark; extra == 'test'
37
- Requires-Dist: pytest-xdist; extra == 'test'
38
22
  Requires-Dist: pydata-sphinx-theme; extra == 'docs'
39
23
  Requires-Dist: myst-nb; extra == 'docs'
40
24
  Requires-Dist: sphinx-autodoc-typehints; extra == 'docs'
@@ -47,10 +31,26 @@ Requires-Dist: egglog[array]; extra == 'docs'
47
31
  Requires-Dist: line-profiler; extra == 'docs'
48
32
  Requires-Dist: sphinxcontrib-mermaid; extra == 'docs'
49
33
  Requires-Dist: ablog; extra == 'docs'
34
+ Requires-Dist: pre-commit; extra == 'dev'
35
+ Requires-Dist: ruff; extra == 'dev'
36
+ Requires-Dist: mypy; extra == 'dev'
37
+ Requires-Dist: anywidget[dev]; extra == 'dev'
38
+ Requires-Dist: egglog[docs,test]; extra == 'dev'
39
+ Requires-Dist: pytest; extra == 'test'
40
+ Requires-Dist: mypy; extra == 'test'
41
+ Requires-Dist: syrupy; extra == 'test'
42
+ Requires-Dist: egglog[array]; extra == 'test'
43
+ Requires-Dist: pytest-codspeed; extra == 'test'
44
+ Requires-Dist: pytest-benchmark; extra == 'test'
45
+ Requires-Dist: pytest-xdist; extra == 'test'
46
+ Requires-Dist: scikit-learn; extra == 'array'
47
+ Requires-Dist: array_api_compat; extra == 'array'
48
+ Requires-Dist: numba==0.59.0rc1; extra == 'array'
49
+ Requires-Dist: llvmlite==0.42.0rc1; extra == 'array'
50
+ Provides-Extra: docs
50
51
  Provides-Extra: dev
51
- Provides-Extra: array
52
52
  Provides-Extra: test
53
- Provides-Extra: docs
53
+ Provides-Extra: array
54
54
  License-File: LICENSE
55
55
  Summary: e-graphs in Python built around the the egglog rust library
56
56
  License: MIT
@@ -1,11 +1,13 @@
1
- egglog-6.1.0.dist-info/METADATA,sha256=1MhEh2rFwsmv5yqI6TZ2hoHfGwxUBSzFk1Z_slTV0HU,3838
2
- egglog-6.1.0.dist-info/WHEEL,sha256=keLBtIOE7ZgLyd8Cijw37iqv72a2jhfxMdDu8Unr7zo,96
3
- egglog-6.1.0.dist-info/license_files/LICENSE,sha256=TfaboMVZ81Q6OUaKjU7z6uVjSlcGKclLYcOpgDbm9_s,1091
4
- egglog/bindings.pyi,sha256=YPGerQlOpSO6kHyIYTUh1hnOopy4cyAKMPtljr3a1rg,11514
5
- egglog/builtins.py,sha256=lc7jWEjf5hUXzPRvo8pJrkGFIUBC0oLXV4U6WYXDrEw,11959
1
+ egglog-7.0.0.dist-info/METADATA,sha256=Z_hOJtco7EDSXWxJH_L2Sod2Za3dYICl6SaSN-UKVD0,3838
2
+ egglog-7.0.0.dist-info/WHEEL,sha256=keLBtIOE7ZgLyd8Cijw37iqv72a2jhfxMdDu8Unr7zo,96
3
+ egglog-7.0.0.dist-info/license_files/LICENSE,sha256=TfaboMVZ81Q6OUaKjU7z6uVjSlcGKclLYcOpgDbm9_s,1091
4
+ egglog/bindings.pyi,sha256=q9gyhu_kTcAPXtyu2IzHhytzjhua4sDEjM1h3XrEw60,11588
5
+ egglog/builtins.py,sha256=lI-WAQGsXYYNvPXBnR6SpRpoTLFQ8u6GaVkrJ8nb-GY,11962
6
6
  egglog/config.py,sha256=mALVaxh7zmGrbuyzaVKVmYKcu1lF703QsKJw8AF7gSM,176
7
- egglog/declarations.py,sha256=JMivLe8Cwna3BsLgls9X_LU-ZQuFapyD-KkZpkf4Eq0,39062
8
- egglog/egraph.py,sha256=y-vPuD0U1h8ajNrjy3V5q-r61j6yDtQbeOyDFaZy9eE,69677
7
+ egglog/conversion.py,sha256=9unbL5LYkYQ-Jc9gsWCd1VwdrI_w3mwudAcm-5PDPcc,6143
8
+ egglog/declarations.py,sha256=zTm0TQd7YB3DfxCldONDMg-AH0leCoU4EyQ-pzfUs7A,15454
9
+ egglog/egraph.py,sha256=HwK4vfI5eSndaK4tVinV5bWJ_K4O5Pzq8zA2un2nAcs,63151
10
+ egglog/egraph_state.py,sha256=2UuZ2XOmTXm-D_Ytfw5LjicsjpM52vLevbOF3ucJtyc,17691
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=ozOPzHzWBT6-5TFX4Flc9Em4I_WBywZZsekmadi06wg,40901
21
+ egglog/exp/array_api.py,sha256=ClS1kbPq1xY4LwmllCo3wHstmZ7dbSKQP8xZcaah6fQ,41310
20
22
  egglog/exp/array_api_jit.py,sha256=HIZzd0G17u-u_F4vfRdhoYvRo-ETx5HFO3RBcOfLcco,1287
21
- egglog/exp/array_api_numba.py,sha256=b7pA3Mk0s0H5s0N5ZWofcWUXb4EVmnUZMEJk0EXyukw,2881
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=PORBaI1jlPSgySipX8foIS5hBZPlY-W5bv2clD-J1Ps,17051
27
31
  egglog/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
28
- egglog/runtime.py,sha256=0Vje8UZTbrHba5d1wjKocbHiio4MDPWraAOrLQXDj9Q,27484
29
- egglog/type_constraint_solver.py,sha256=u-b2SZxptCxjYNcht_TQSAebIVEcf3P_-2-TJk8uaqs,5671
32
+ egglog/runtime.py,sha256=U6fsbTU81hWZdW8chCbnuA3OoOSZ8JnWTDE-M5WF3OM,18722
33
+ egglog/thunk.py,sha256=jsj5lp6qU87GTseYip_shE7ZTYbF9E1GDcB8R1ubQh8,1925
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=AGM-7H_Vx1Xb0Z-tc0C9Y8JbQxpa6hdYfhSU_dnT3Mw,244
33
- egglog/bindings.cp310-win_amd64.pyd,sha256=M6YHB0Ef-G-xSpFHmIFtPa-sL8yQ2t_C_DfDoPjCJ0s,4991488
34
- egglog-6.1.0.dist-info/RECORD,,
37
+ egglog/__init__.py,sha256=iUrVe5fb0XFyMCS3CwTjwhKEtU8KpIkdTpJpnUhm8o0,247
38
+ egglog/bindings.cp310-win_amd64.pyd,sha256=KSpjek2AtlZiqgmNTtDMuFrAn4O9FQzOXjCOuvvbH88,5108224
39
+ egglog-7.0.0.dist-info/RECORD,,
File without changes