Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Changed hatch density typing to float. Added FutureWarning for cases …#27032

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

Open
borgesaugusto wants to merge1 commit intomatplotlib:main
base:main
Choose a base branch
Loading
fromborgesaugusto:iss_26645
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletionslib/matplotlib/hatch.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -133,15 +133,15 @@ class SmallCircles(Circles):
size=0.2

def__init__(self,hatch,density):
self.num_rows=(hatch.count('o'))*density
self.num_rows=int((hatch.count('o'))*density)
super().__init__(hatch,density)


classLargeCircles(Circles):
size=0.35

def__init__(self,hatch,density):
self.num_rows=(hatch.count('O'))*density
self.num_rows=int((hatch.count('O'))*density)
super().__init__(hatch,density)


Expand All@@ -150,7 +150,7 @@ class SmallFilledCircles(Circles):
filled=True

def__init__(self,hatch,density):
self.num_rows=(hatch.count('.'))*density
self.num_rows=int((hatch.count('.'))*density)
super().__init__(hatch,density)


Expand All@@ -159,7 +159,7 @@ class Stars(Shapes):
filled=True

def__init__(self,hatch,density):
self.num_rows=(hatch.count('*'))*density
self.num_rows=int((hatch.count('*'))*density)
path=Path.unit_regular_star(5)
self.shape_vertices=path.vertices
self.shape_codes=np.full(len(self.shape_vertices),Path.LINETO,
Expand DownExpand Up@@ -196,13 +196,18 @@ def _validate_hatch_pattern(hatch):
)


defget_path(hatchpattern,density=6):
defget_path(hatchpattern,density=6.0):
"""
Given a hatch specifier, *hatchpattern*, generates Path to render
the hatch in a unit square. *density* is the number of lines per
unit square.
"""
density=int(density)
ifint(density)!=density:
_api.warn_external("Passing a floating point density will result in "
"a behavior change due to float to int conversion."
f"Value density ({density}) will be used "
f"instead of{int(density)} to calculate lines",
category=FutureWarning)

patterns= [hatch_type(hatchpattern,density)
forhatch_typein_hatch_types]
Expand Down
22 changes: 11 additions & 11 deletionslib/matplotlib/hatch.pyi
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,61 +8,61 @@ class HatchPatternBase: ...
classHorizontalHatch(HatchPatternBase):
num_lines:int
num_vertices:int
def__init__(self,hatch:str,density:int)->None: ...
def__init__(self,hatch:str,density:float)->None: ...
defset_vertices_and_codes(self,vertices:ArrayLike,codes:ArrayLike)->None: ...

classVerticalHatch(HatchPatternBase):
num_lines:int
num_vertices:int
def__init__(self,hatch:str,density:int)->None: ...
def__init__(self,hatch:str,density:float)->None: ...
defset_vertices_and_codes(self,vertices:ArrayLike,codes:ArrayLike)->None: ...

classNorthEastHatch(HatchPatternBase):
num_lines:int
num_vertices:int
def__init__(self,hatch:str,density:int)->None: ...
def__init__(self,hatch:str,density:float)->None: ...
defset_vertices_and_codes(self,vertices:ArrayLike,codes:ArrayLike)->None: ...

classSouthEastHatch(HatchPatternBase):
num_lines:int
num_vertices:int
def__init__(self,hatch:str,density:int)->None: ...
def__init__(self,hatch:str,density:float)->None: ...
defset_vertices_and_codes(self,vertices:ArrayLike,codes:ArrayLike)->None: ...

classShapes(HatchPatternBase):
filled:bool
num_shapes:int
num_vertices:int
def__init__(self,hatch:str,density:int)->None: ...
def__init__(self,hatch:str,density:float)->None: ...
defset_vertices_and_codes(self,vertices:ArrayLike,codes:ArrayLike)->None: ...

classCircles(Shapes):
shape_vertices:np.ndarray
shape_codes:np.ndarray
def__init__(self,hatch:str,density:int)->None: ...
def__init__(self,hatch:str,density:float)->None: ...

classSmallCircles(Circles):
size:float
num_rows:int
def__init__(self,hatch:str,density:int)->None: ...
def__init__(self,hatch:str,density:float)->None: ...

classLargeCircles(Circles):
size:float
num_rows:int
def__init__(self,hatch:str,density:int)->None: ...
def__init__(self,hatch:str,density:float)->None: ...

classSmallFilledCircles(Circles):
size:float
filled:bool
num_rows:int
def__init__(self,hatch:str,density:int)->None: ...
def__init__(self,hatch:str,density:float)->None: ...

classStars(Shapes):
size:float
filled:bool
num_rows:int
shape_vertices:np.ndarray
shape_codes:np.ndarray
def__init__(self,hatch:str,density:int)->None: ...
def__init__(self,hatch:str,density:float)->None: ...

defget_path(hatchpattern:str,density:int= ...)->Path: ...
defget_path(hatchpattern:str,density:float= ...)->Path: ...
2 changes: 1 addition & 1 deletionlib/matplotlib/path.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1024,7 +1024,7 @@ def wedge(cls, theta1, theta2, n=None):

@staticmethod
@lru_cache(8)
defhatch(hatchpattern,density=6):
defhatch(hatchpattern,density=6.0):
"""
Given a hatch specifier, *hatchpattern*, generates a `Path` that
can be used in a repeated hatching pattern. *density* is the
Expand Down
10 changes: 10 additions & 0 deletionslib/matplotlib/tests/test_path.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -539,3 +539,13 @@ def test_cleanup_closepoly():
cleaned=p.cleaned(remove_nans=True)
assertlen(cleaned)==1
assertcleaned.codes[0]==Path.STOP


deftest_hatch_density_integer_to_float():
withpytest.warns(FutureWarning,
match="behavior change due to float to int conversion."):
Path.hatch("x",6.6)


deftest_hatch_density_integer():
Path.hatch("x",2.0)

[8]ページ先頭

©2009-2025 Movatter.jp