Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 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.run_report()` 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 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.run_report()` to get overall statistics about the EGraph.

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

## 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 run_report(self) -> 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().run_report()