-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug loading MPL style from the configuration #11750
Conversation
One or more of the the following people are requested to review this:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks right thanks, but can we add a regression test so it doesn't happen again?
Pull Request Test Coverage Report for Build 7916495351Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
that's a pretty questionable decision by GitHub to allow a commit in an entirely separate organisation (let alone repo) to close this PR. |
Added in dddca99 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this Luciano. The spirit of the test looks good, though I had a minor comment. Let me know if you've not got time to respond and I can just do it if you prefer.
with patch( | ||
"qiskit.user_config.get_config", | ||
return_value={ | ||
"circuit_drawer": "mpl", | ||
"circuit_mpl_style": "quantum-light", | ||
"circuit_mpl_style_path": ["~/.qiskit"], | ||
}, | ||
): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This particular form causes the test to generate a warning (we don't forbid UserWarning
in CI) unless mthree
is installed, which drops the quantum-light.json
file into ~/.qiskit
.
We maybe want to make the test resilient against that - perhaps use a temporary directory as the style_path
that includes a valid style file we can use?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
true. Done in ae5f93c I ended up with a kinda complicated solution. Any ideas how to improve it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think what you had was fine in principle - the interface of the circuit drawer is kind of missing a couple of things that would have made it a bit easier to do, so I think everything was always going to look a little messy. I tweaked it over to use TemporaryDirectory
instead and to add a test of a failed lookup in 05eb769, but mostly just to expand the coverage more than anything else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this Luciano.
I think your test before was generally ok, but I've tweaked the test here to avoid using another internal function (load_style
) and needing to do a direct JSON dump, in favour of copying over a known-valid style into a temporary directory and using that. I also expanded the test to test the behaviour if we're searching for a file that doesn't exist.
It's perhaps a bit cleaner to use a TemporaryDirectory
directly instead of of a NamedTemporaryFile
because it's technically a directory that we actually want to test, and NamedTemporaryFile
has a few complications between POSIX and Windows around the rules for re-opening it, and stuff like that.
* config path fixing * reno * add test * temp file creation * Avoid using more internal details in style test --------- Co-authored-by: Jake Lishman <[email protected]> (cherry picked from commit 19c15b7)
* config path fixing * reno * add test * temp file creation * Avoid using more internal details in style test --------- Co-authored-by: Jake Lishman <[email protected]> (cherry picked from commit 19c15b7) Co-authored-by: Luciano Bello <[email protected]>
@Mergifyio backport stable/0.46 |
✅ Backports have been created
|
* config path fixing * reno * add test * temp file creation * Avoid using more internal details in style test --------- Co-authored-by: Jake Lishman <[email protected]> (cherry picked from commit 19c15b7) # Conflicts: # qiskit/visualization/circuit/qcstyle.py # test/python/visualization/test_circuit_drawer.py
While testing mthree with
rc1
, I detected a small typo inqiskit.visualization.circuit.qcstyle.load_style
introduced in #11536:https://github.com/Qiskit-Extensions/mthree/actions/runs/7828157591/job/21357435372?pr=196
locally also is reproducible: