Skip to content
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

Fix version parsing issue in bloch.py. #12928

Merged
merged 1 commit into from
Aug 12, 2024

Conversation

kevinhartman
Copy link
Contributor

Summary

Adds more robust version parsing in bloch.py, which we use to check the version of matplotlib. The latest version of matplotlib is matplotlib 3.9.1.post1 and causes the old code to fail.

Details and comments

This version regex stuff is taken from our qpy module.

@kevinhartman kevinhartman requested review from nonhermitian and a team as code owners August 8, 2024 17:49
@qiskit-bot
Copy link
Collaborator

One or more of the following people are relevant to this code:

Comment on lines +64 to +102
# This version pattern is taken from the pypa packaging project:
# https://github.com/pypa/packaging/blob/21.3/packaging/version.py#L223-L254
# which is dual licensed Apache 2.0 and BSD see the source for the original
# authors and other details
VERSION_PATTERN = (
"^"
+ r"""
v?
(?:
(?:(?P<epoch>[0-9]+)!)? # epoch
(?P<release>[0-9]+(?:\.[0-9]+)*) # release segment
(?P<pre> # pre-release
[-_\.]?
(?P<pre_l>(a|b|c|rc|alpha|beta|pre|preview))
[-_\.]?
(?P<pre_n>[0-9]+)?
)?
(?P<post> # post release
(?:-(?P<post_n1>[0-9]+))
|
(?:
[-_\.]?
(?P<post_l>post|rev|r)
[-_\.]?
(?P<post_n2>[0-9]+)?
)
)?
(?P<dev> # dev release
[-_\.]?
(?P<dev_l>dev)
[-_\.]?
(?P<dev_n>[0-9]+)?
)?
)
(?:\+(?P<local>[a-z0-9]+(?:[-_\.][a-z0-9]+)*))? # local version
"""
+ "$"
)
VERSION_PATTERN_REGEX = re.compile(VERSION_PATTERN, re.VERBOSE | re.IGNORECASE)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just import this from qpy it seems a bit weird to duplicate this a 4th time in the code: https://github.com/search?q=repo%3AQiskit%2Fqiskit%20VERSION_PATTERN&type=code

but at the end of the day I guess it doesn't matter too much.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally, I would rather just duplicate it unless we move it to a common location. I think importing from qpy would be weirder in terms of module dependencies. It really shouldn't change anyway since it's not our code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should look at consolidating these down to one shared copy somewhere, but we can save that for a separate PR. I'm fine to add another copy of this here in the medium term to get this fix into 1.2.0.

@mtreinish mtreinish added stable backport potential The bug might be minimal and/or import enough to be port to stable mod: visualization qiskit.visualization labels Aug 8, 2024
@mtreinish mtreinish added this to the 1.2.0 milestone Aug 8, 2024
@mtreinish mtreinish added the Changelog: None Do not include in changelog label Aug 8, 2024
@coveralls
Copy link

Pull Request Test Coverage Report for Build 10306985942

Details

  • 3 of 5 (60.0%) changed or added relevant lines in 1 file are covered.
  • 2 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.03%) to 89.765%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit/visualization/bloch.py 3 5 60.0%
Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/lex.rs 1 92.98%
qiskit/visualization/bloch.py 1 50.17%
Totals Coverage Status
Change from base Build 10302737074: 0.03%
Covered Lines: 67348
Relevant Lines: 75027

💛 - Coveralls

@mtreinish mtreinish added this pull request to the merge queue Aug 12, 2024
Merged via the queue into Qiskit:main with commit 61adcf9 Aug 12, 2024
15 checks passed
mergify bot pushed a commit that referenced this pull request Aug 12, 2024
github-merge-queue bot pushed a commit that referenced this pull request Aug 12, 2024
(cherry picked from commit 61adcf9)

Co-authored-by: Kevin Hartman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: None Do not include in changelog mod: visualization qiskit.visualization stable backport potential The bug might be minimal and/or import enough to be port to stable
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants