Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ _This project uses semantic versioning_

## UNRELEASED

- Add `egraph.stats()` method to print overall stats [#339](https://github.com/egraphs-good/egglog-python/pull/339)
- Add `all_function_sizes` and `function_size` EGraph methods [#338](https://github.com/egraphs-good/egglog-python/pull/338)
- Fix execution of docs [#337](https://github.com/egraphs-good/egglog-python/pull/337)
- Emit warnings when functions omitted when visualizing [#336](https://github.com/egraphs-good/egglog-python/pull/336)
Expand All @@ -14,6 +15,7 @@ _This project uses semantic versioning_
- Allow changing number of threads with env variable [#330](https://github.com/egraphs-good/egglog-python/pull/330)

## 11.0.0 (2025-08-08)

- Change conversion between binary operators to consider converting both types [#320](https://github.com/egraphs-good/egglog-python/pull/320)
- Add ability to parse egglog expressions into Python values [#319](https://github.com/egraphs-good/egglog-python/pull/319)
- Deprecates `.eval()` method on primitives in favor of `.value` which can be used with pattern matching.
Expand Down
9 changes: 9 additions & 0 deletions docs/reference/egglog-translation.md
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,15 @@ egraph.function_size(Math)
egraph.all_function_sizes()
```

## Overall Statistics

The `(print-stats)` command is translated into `egraph.stats()` to get overall statistics about the EGraph.

```{code-cell} python
# (print-stats)
egraph.stats()
```

## Include

The `(include <path>)` command is used to add modularity, by allowing you to pull in the source from another egglog file into the current file.
Expand Down
8 changes: 8 additions & 0 deletions python/egglog/egraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,14 @@ def _run_schedule(self, schedule: Schedule) -> bindings.RunReport:
assert isinstance(command_output, bindings.RunScheduleOutput)
return command_output.report

def stats(self) -> bindings.RunReport:
"""
Returns the overall run report for the egraph.
"""
(output,) = self._egraph.run_program(bindings.PrintOverallStatistics())
assert isinstance(output, bindings.OverallStatistics)
return output.report

def check_bool(self, *facts: FactLike) -> bool:
"""
Returns true if the facts are true in the egraph.
Expand Down
4 changes: 4 additions & 0 deletions python/tests/test_high_level.py
Original file line number Diff line number Diff line change
Expand Up @@ -1048,3 +1048,7 @@ def test_all_function_size():
(C, 1),
(E.cm, 1),
}


def test_overall_run_report():
assert EGraph().stats()
Loading