Skip to content

Fix #556: unify default output format#563

Open
thierry-martinez wants to merge 3 commits into
TeamGraphix:masterfrom
thierry-martinez:fix/556-output-format
Open

Fix #556: unify default output format#563
thierry-martinez wants to merge 3 commits into
TeamGraphix:masterfrom
thierry-martinez:fix/556-output-format

Conversation

@thierry-martinez

Copy link
Copy Markdown
Collaborator

This commit unifies the default behavior of display routines by introducing the context variable default_output_format, which is set to OutputFormat.ASCII by default.

The __str__ methods of PauliFlow, XZCorrections, Pattern, and StateVec now directly call the corresponding *_to_str functions using the default value for the output parameter. This default is resolved by ensure_output_format, which retrieves the value of default_output_format. Previously, StateVec produced output without relying on the pretty-printing functions, while StateVec.draw uses OutputFormat.Unicode by default and the other classes called to_ascii directly.

In docs/source/conf.py, the following entry has been added to intersphinx_mapping:

    "python": ("https://docs.python.org/3", None),

This enables links to the Python documentation for ContextVar.

The documentation of the pretty_print module has been changed to:

.. automodule:: graphix.pretty_print
    :members:

so that all public members are included in the documentation.

This commit unifies the default behavior of display routines by
introducing the context variable `default_output_format`, which is
set to `OutputFormat.ASCII` by default.

The `__str__` methods of `PauliFlow`, `XZCorrections`, `Pattern`, and
`StateVec` now directly call the corresponding `*_to_str` functions
using the default value for the `output` parameter. This default is
resolved by `ensure_output_format`, which retrieves the value of
`default_output_format`. Previously, `StateVec` produced output
without relying on the pretty-printing functions, while
`StateVec.draw` uses `OutputFormat.Unicode` by default and the other
classes called `to_ascii` directly.

In `docs/source/conf.py`, the following entry has been added to
`intersphinx_mapping`:

```python
    "python": ("https://docs.python.org/3", None),
```

This enables links to the Python documentation for `ContextVar`.

The documentation of the `pretty_print` module has been changed to:

```
.. automodule:: graphix.pretty_print
    :members:
```

so that all public members are included in the documentation.
@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.62%. Comparing base (2351197) to head (43957b8).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #563      +/-   ##
==========================================
+ Coverage   90.58%   90.62%   +0.03%     
==========================================
  Files          49       49              
  Lines        7481     7499      +18     
==========================================
+ Hits         6777     6796      +19     
+ Misses        704      703       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant