(De-Duplication) linking validate hatch from hatch module#28076
(De-Duplication) linking validate hatch from hatch module#28076ShivamPathak99 wants to merge 9 commits intomatplotlib:mainfrom
Conversation
|
I think validate_hatch = _validate_hatch_patternAny 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). |
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. |
|
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
| 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.
This is an subtle API change that needs to be document as currently
b.set_hatch(('x','x'))works. The docstring on Patch.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.
Working on it,
I'm a bit lost on -
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).
Could you break it down for me
There was a problem hiding this comment.
matplotlib/lib/matplotlib/path.py
Lines 1025 to 1035 in 199c31f
Is part of the code path between Patch.set_hatch and rendering a hatched patch. The lru_cache means we will avoid re-computing the hatch path. The lru_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 out option 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. 🤞 |
|
Why |
PR summary
issue #24797
Applying the discussed changes in
rcsetupPR checklist