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

Commitdfe72ed

Browse files
Vectorize bounding box limits updates
1 parent042d068 commitdfe72ed

File tree

1 file changed

+29
-5
lines changed

1 file changed

+29
-5
lines changed

‎lib/matplotlib/transforms.py

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@
4646
fromnumpy.linalgimportinv
4747

4848
frommatplotlibimport_api
49-
frommatplotlib._pathimport (
50-
affine_transform,count_bboxes_overlapping_bbox,update_path_extents)
49+
frommatplotlib._pathimportaffine_transform,count_bboxes_overlapping_bbox
5150
from .pathimportPath
5251

5352
DEBUG=False
@@ -868,10 +867,35 @@ def update_from_path(self, path, ignore=None, updatex=True, updatey=True):
868867
ifpath.vertices.size==0:
869868
return
870869

871-
points,minpos,changed=update_path_extents(
872-
path,None,self._points,self._minpos,ignore)
870+
ifignore:
871+
points=np.array([[np.inf,np.inf], [-np.inf,-np.inf]])
872+
minpos=np.array([np.inf,np.inf])
873+
else:
874+
points=self._points.copy()
875+
minpos=self._minpos.copy()
876+
877+
ifupdatexandupdatey:
878+
where= (np.isfinite(path.vertices[...,0])
879+
&np.isfinite(path.vertices[...,1]))
880+
elifupdatex:
881+
where=np.isfinite(path.vertices[...,0])
882+
elifupdatey:
883+
where=np.isfinite(path.vertices[...,1])
884+
else:
885+
return
873886

874-
ifchanged:
887+
ifupdatex:
888+
x=path.vertices[...,0][where]
889+
points[0,0]=min(points[0,0],np.min(x,initial=np.inf))
890+
points[1,0]=max(points[1,0],np.max(x,initial=-np.inf))
891+
minpos[0]=min(minpos[0],np.min(x[x>0],initial=np.inf))
892+
ifupdatey:
893+
y=path.vertices[...,1][where]
894+
points[0,1]=min(points[0,1],np.min(y,initial=np.inf))
895+
points[1,1]=max(points[1,1],np.max(y,initial=-np.inf))
896+
minpos[1]=min(minpos[1],np.min(y[y>0],initial=np.inf))
897+
898+
ifnp.any(points!=self._points)ornp.any(minpos!=self._minpos):
875899
self.invalidate()
876900
ifupdatex:
877901
self._points[:,0]=points[:,0]

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp