Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
(De-Duplication) linking validate hatch from hatch module#28076
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Conversation
I think validate_hatch=_validate_hatch_pattern Any fixes for this error? |
rcparams is imported very early in import process so this change adds a circular import (matplotlib/init.py -> rcparams.py -> hatch.py -> matplotlib/init.py). If we want to do this merging, then the cannonical location needs to be in rcparams (as funny as that seems). |
story645 commentedApr 15, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
What about going the other direction and doing the validation at run time, which I think is kind of what@anntzer is suggesting in#24797 (comment) b/c it allows for setting third-party hatches in rcParams. |
story645 commentedApr 18, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Ok, so I'm just gonna summarize my understanding of three options:
|
@ShivamPathak99 we discussed this on the call and decision was either do 2. or 3. |
lib/matplotlib/hatch.py Outdated
@@ -182,6 +182,8 @@ def __init__(self, hatch, density): | |||
def _validate_hatch_pattern(hatch): | |||
valid_hatch_patterns = set(r'-+|/\xXoO.*') | |||
if hatch is not None: | |||
if not isinstance(hatch, str): |
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 is an subtle API change that needs to be document as currently
b.set_hatch(('x','x'))
works. The docstring onPatch.set_hatch
is not clear about the type on the input should be.
We do run the hatches through an lrucache so only hashable things work (and it looks like we used as a key in a dictionary before that).
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.
Working on it,
I'm a bit lost on -
We do run the hatches through anlrucache so only hashable things work (and it looks like we used as a key in a dictionary before that).
Could you break it down for me
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.
matplotlib/lib/matplotlib/path.py
Lines 1025 to 1035 in199c31f
@staticmethod | |
@lru_cache(8) | |
defhatch(hatchpattern,density=6): | |
""" | |
Given a hatch specifier, *hatchpattern*, generates a `Path` that | |
can be used in a repeated hatching pattern. *density* is the | |
number of lines per unit square. | |
""" | |
frommatplotlib.hatchimportget_path | |
return (get_path(hatchpattern,density) | |
ifhatchpatternisnotNoneelseNone) |
Is part of the code path betweenPatch.set_hatch
and rendering a hatched patch. Thelru_cache
means we will avoid re-computing the hatch path. Thelru_cache
is backed by a dictionary (eventually) with the function parameters as the key so only inputs that are hashable can be used.
Sorry for delay, figuring outoption 2.
|
hatchModule will call out rcparams for hatch validation
FIXED: ModuleNotFoundError: No module named 'rcsetup'
Have I done it right, some tests are still failing. |
@ShivamPathak99 some of the tests are a bit flakey. I’ve re-run the failed one so let’s see how it goes this time. 🤞 |
Uh oh!
There was an error while loading.Please reload this page.
Why |
PR summary
issue#24797
Applying the discussed changes in
rcsetup
PR checklist