-
-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Open
Labels
Description
Summary
The typing makes it clear that both are used.
density of Path.hatch is typed as float. This is then passed to hatch.get_path, where it is typed as int and then does:
matplotlib/lib/matplotlib/hatch.py
Lines 205 to 208 in 8d56b9c
| density = int(density) | |
| patterns = [hatch_type(hatchpattern, density) | |
| for hatch_type in _hatch_types] |
hatch_type is one of the hatch methods and typically has a line like:
matplotlib/lib/matplotlib/hatch.py
Line 16 in 8d56b9c
| self.num_lines = int((hatch.count('-') + hatch.count('+')) * density) |
As seen it is possible to pass a float until here.
Proposed fix
I see two solutions:
- Type
densityofPath.hatchasint. This makes it consistent and there are no consequences. - Type
densityelsewhere asfloatand remove theint(density)inget_path. This will work properly from a typing pespective, but change the appearance. For example, usingPath.hatch("/xX/xX", 1.9)will changenum_linesofNorthEastHatchfrom6*int(1.9) = 6toint(6*1.9) = 11. However, it will also allow a more detailed control of the density in a more natural way.