Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5f68f64

Browse files
committed
Change num lines to int in hatch.
Fixes numpy issues warnings
1 parent 0287479 commit 5f68f64

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

lib/matplotlib/hatch.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class HatchPatternBase:
2121

2222
class HorizontalHatch(HatchPatternBase):
2323
def __init__(self, hatch, density):
24-
self.num_lines = (hatch.count('-') + hatch.count('+')) * density
24+
self.num_lines = int((hatch.count('-') + hatch.count('+')) * density)
2525
self.num_vertices = self.num_lines * 2
2626

2727
def set_vertices_and_codes(self, vertices, codes):
@@ -38,7 +38,7 @@ def set_vertices_and_codes(self, vertices, codes):
3838

3939
class VerticalHatch(HatchPatternBase):
4040
def __init__(self, hatch, density):
41-
self.num_lines = (hatch.count('|') + hatch.count('+')) * density
41+
self.num_lines = int((hatch.count('|') + hatch.count('+')) * density)
4242
self.num_vertices = self.num_lines * 2
4343

4444
def set_vertices_and_codes(self, vertices, codes):
@@ -55,8 +55,8 @@ def set_vertices_and_codes(self, vertices, codes):
5555

5656
class NorthEastHatch(HatchPatternBase):
5757
def __init__(self, hatch, density):
58-
self.num_lines = (hatch.count('/') + hatch.count('x') +
59-
hatch.count('X')) * density
58+
self.num_lines = int((hatch.count('/') + hatch.count('x') +
59+
hatch.count('X')) * density)
6060
if self.num_lines:
6161
self.num_vertices = (self.num_lines + 1) * 2
6262
else:
@@ -74,8 +74,8 @@ def set_vertices_and_codes(self, vertices, codes):
7474

7575
class SouthEastHatch(HatchPatternBase):
7676
def __init__(self, hatch, density):
77-
self.num_lines = (hatch.count('\\') + hatch.count('x') +
78-
hatch.count('X')) * density
77+
self.num_lines = int((hatch.count('\\') + hatch.count('x') +
78+
hatch.count('X')) * density)
7979
self.num_vertices = (self.num_lines + 1) * 2
8080
if self.num_lines:
8181
self.num_vertices = (self.num_lines + 1) * 2
@@ -100,8 +100,8 @@ def __init__(self, hatch, density):
100100
self.num_shapes = 0
101101
self.num_vertices = 0
102102
else:
103-
self.num_shapes = ((self.num_rows / 2 + 1) * (self.num_rows + 1) +
104-
(self.num_rows / 2) * (self.num_rows))
103+
self.num_shapes = ((self.num_rows // 2 + 1) * (self.num_rows + 1) +
104+
(self.num_rows // 2) * (self.num_rows))
105105
self.num_vertices = (self.num_shapes *
106106
len(self.shape_vertices) *
107107
(self.filled and 1 or 2))
@@ -212,6 +212,7 @@ def get_path(hatchpattern, density=6):
212212
cursor = 0
213213
for pattern in patterns:
214214
if pattern.num_vertices != 0:
215+
num_vertices
215216
vertices_chunk = vertices[cursor:cursor + pattern.num_vertices]
216217
codes_chunk = codes[cursor:cursor + pattern.num_vertices]
217218
pattern.set_vertices_and_codes(vertices_chunk, codes_chunk)

0 commit comments

Comments
 (0)