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

Commit01e6a47

Browse files
committed
Don't reshape offsets into the correct shape.
(Instead let invalid entries error.)
1 parenta4bd3ce commit01e6a47

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

‎lib/matplotlib/collections.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def __init__(self,
145145
self._uniform_offsets=None
146146
self._offsets=np.array([[0,0]],float)
147147
ifoffsetsisnotNone:
148-
offsets=np.asanyarray(offsets).reshape((-1,2))
148+
offsets=np.asanyarray(offsets,float)
149149
iftransOffsetisnotNone:
150150
self._offsets=offsets
151151
self._transOffset=transOffset
@@ -210,7 +210,6 @@ def get_datalim(self, transData):
210210
offsets=transOffset.transform_non_affine(offsets)
211211
transOffset=transOffset.get_affine()
212212

213-
offsets=np.asanyarray(offsets,float).reshape((-1,2))
214213
ifisinstance(offsets,np.ma.MaskedArray):
215214
offsets=offsets.filled(np.nan)
216215
# get_path_collection_extents handles nan but not masked arrays
@@ -244,14 +243,12 @@ def _prepare_points(self):
244243
xs,ys=vertices[:,0],vertices[:,1]
245244
xs=self.convert_xunits(xs)
246245
ys=self.convert_yunits(ys)
247-
paths.append(mpath.Path(list(zip(xs,ys)),path.codes))
246+
paths.append(mpath.Path(np.column_stack([xs,ys]),path.codes))
248247

249248
ifoffsets.size>0:
250249
xs=self.convert_xunits(offsets[:,0])
251250
ys=self.convert_yunits(offsets[:,1])
252-
offsets=list(zip(xs,ys))
253-
254-
offsets=np.asanyarray(offsets,float).reshape((-1,2))
251+
offsets=np.column_stack([xs,ys])
255252

256253
ifnottransform.is_affine:
257254
paths= [transform.transform_path_non_affine(path)
@@ -431,7 +428,7 @@ def set_offsets(self, offsets):
431428
432429
ACCEPTS: float or sequence of floats
433430
"""
434-
offsets=np.asanyarray(offsets,float).reshape((-1,2))
431+
offsets=np.asanyarray(offsets,float)
435432
#This decision is based on how they are initialized above
436433
ifself._uniform_offsetsisNone:
437434
self._offsets=offsets
@@ -1881,17 +1878,12 @@ def draw(self, renderer):
18811878
iflen(self._offsets):
18821879
xs=self.convert_xunits(self._offsets[:,0])
18831880
ys=self.convert_yunits(self._offsets[:,1])
1884-
offsets=list(zip(xs,ys))
1885-
1886-
offsets=np.asarray(offsets,float).reshape((-1,2))
1881+
offsets=np.column_stack([xs,ys])
18871882

18881883
self.update_scalarmappable()
18891884

18901885
ifnottransform.is_affine:
1891-
coordinates=self._coordinates.reshape(
1892-
(self._coordinates.shape[0]*
1893-
self._coordinates.shape[1],
1894-
2))
1886+
coordinates=self._coordinates.reshape((-1,2))
18951887
coordinates=transform.transform(coordinates)
18961888
coordinates=coordinates.reshape(self._coordinates.shape)
18971889
transform=transforms.IdentityTransform()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp