Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Labels
Description
Summary
In#17926 code to validate hatches got added to the hatch module:
matplotlib/lib/matplotlib/hatch.py
Lines 182 to 196 in5100378
def_validate_hatch_pattern(hatch): | |
valid_hatch_patterns=set(r'-+|/\xXoO.*') | |
ifhatchisnotNone: | |
invalids=set(hatch).difference(valid_hatch_patterns) | |
ifinvalids: | |
valid=''.join(sorted(valid_hatch_patterns)) | |
invalids=''.join(sorted(invalids)) | |
_api.warn_deprecated( | |
'3.4', | |
removal='3.8',# one release after custom hatches (#20690) | |
message=f'hatch must consist of a string of "{valid}" or ' | |
'None, but found the following invalid values ' | |
f'"{invalids}". Passing invalid values is deprecated ' | |
'since %(since)s and will become an error %(removal)s.' | |
) |
and there's near identical code in rc validation that went in in#4686:
matplotlib/lib/matplotlib/rcsetup.py
Lines 580 to 592 in5093150
defvalidate_hatch(s): | |
r""" | |
Validate a hatch pattern. | |
A hatch pattern string can have any sequence of the following | |
characters: ``\ / | - + * . x o O``. | |
""" | |
ifnotisinstance(s,str): | |
raiseValueError("Hatch pattern must be a string") | |
_api.check_isinstance(str,hatch_pattern=s) | |
unknown=set(s)- {'\\','/','|','-','+','*','.','x','o','O'} | |
ifunknown: | |
raiseValueError("Unknown hatch symbol(s): %s"%list(unknown)) | |
returns |
They diverge slightly in that the hatch version has a deprecation warning but I think it should also apply to the rc version?
Proposed fix
Make the validation function in hatch.py the canonical validator and either deprecate the rcsetup validation function or turn it into a thin shim over the one in hatch.