Skip to content

Commit

Permalink
Merge pull request #1 from RobinKa/robin/egglog-0.6.0
Browse files Browse the repository at this point in the history
Upgrade to egglog 0.7.0
  • Loading branch information
RobinKa authored Oct 4, 2023
2 parents c6b203e + 7e7e59c commit 88bc0cc
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 46 deletions.
12 changes: 6 additions & 6 deletions egga/geometric_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from typing import Dict, Optional, Tuple, Type

from egglog import (
BaseExpr,
EGraph,
Expr,
String,
StringLike,
egraph,
Expand Down Expand Up @@ -77,7 +77,7 @@ def __init__(
egraph = EGraph()

@egraph.class_
class MathExpr(BaseExpr):
class MathExpr(Expr):
@egraph.method(cost=costs.get("equal"))
def equal(self, other: MathExpr) -> MathExpr:
...
Expand Down Expand Up @@ -676,10 +676,10 @@ def register_equality():
birewrite(x_1.equal(x_2)).to(x_2.equal(x_1)),
birewrite(x_1.not_equal(x_2)).to(x_2.not_equal(x_1)),
# Eq / Ne
rewrite(x_1.equal(x_1)).to(boolean(True)),
rewrite(x_1.not_equal(x_1)).to(boolean(False)),
rewrite(x_1.equal(x_2)).to(boolean(False), x_1 != x_2),
rewrite(x_1.not_equal(x_2)).to(boolean(True), x_1 != x_2),
rewrite(x_1.equal(x_1)).to(boolean(1)),
rewrite(x_1.not_equal(x_1)).to(boolean(0)),
rewrite(x_1.equal(x_2)).to(boolean(0), x_1 != x_2),
rewrite(x_1.not_equal(x_2)).to(boolean(1), x_1 != x_2),
)

def register_trigonometry():
Expand Down
14 changes: 7 additions & 7 deletions egga/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ def run_ruleset(ga: GeometricAlgebra, options: RunRulesetOptions = RunRulesetOpt
else:
ruleset = options.ruleset

return ga.egraph.run(
run(
ruleset,
options.limit,
*([options.until] if options.until is not None else []),
).saturate()
)
for _ in range(options.limit):
ga.egraph.run(
run(
ruleset,
*([options.until] if options.until is not None else []),
).saturate()
)


@dataclass
Expand Down
50 changes: 25 additions & 25 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "egga"
version = "0.1.7"
version = "0.1.8"
description = "Symbolic Geometric Algebra with E-Graphs "
authors = ["Robin Kahlow <tora@warlock.ai>"]
readme = "README.md"
Expand Down Expand Up @@ -45,7 +45,7 @@ classifiers = [

[tool.poetry.dependencies]
python = "^3.8"
egglog = "^0.5.1"
egglog = "^0.7.0"

[tool.poetry.group.dev.dependencies]
pytest = "^7.4.0"
Expand Down
12 changes: 6 additions & 6 deletions tests/test_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@
(e_1 * ~(e_12 + e_23 + e_31), -e_2 - e_123 + e_3),
(e_23 ** E.scalar_literal(1.0), e_23),
(e_23 * e_23, E.scalar_literal(-1.0)),
(e_1.equal(E.scalar_literal(1.0) * e_1), E.boolean(True)),
(e_1.not_equal(E.scalar_literal(1.0) * e_1), E.boolean(False)),
(e_1.equal(-E.scalar_literal(1.0) * e_1), E.boolean(False)),
(e_1.not_equal(-E.scalar_literal(1.0) * e_1), E.boolean(True)),
(e_1.equal(E.scalar_literal(1.0) * e_1), E.boolean(1)),
(e_1.not_equal(E.scalar_literal(1.0) * e_1), E.boolean(0)),
(e_1.equal(-E.scalar_literal(1.0) * e_1), E.boolean(0)),
(e_1.not_equal(-E.scalar_literal(1.0) * e_1), E.boolean(1)),
(E.inverse(e_1), e_1),
(E.inverse(e_12), -e_12),
(E.scalar_literal(1.0) / e_12, -e_12),
Expand Down Expand Up @@ -359,7 +359,7 @@ def test_equalities(equation):
ga.egraph.pop()

if caught is not None:
raise caught
raise caught from caught


@pytest.mark.skip
Expand Down Expand Up @@ -393,4 +393,4 @@ def test_contradiction(equations):
ga.egraph.pop()

if caught is not None:
raise caught
raise caught from caught

0 comments on commit 88bc0cc

Please sign in to comment.