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

Commit5c17100

Browse files
committed
MNT: changes required for greglucas/pcolor-2dmesh
1 parentae87d58 commit5c17100

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

‎lib/cartopy/mpl/geoaxes.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
importmatplotlib.transformsasmtransforms
3333
importnumpyasnp
3434
importnumpy.maasma
35+
importpackaging
3536
importshapely.geometryassgeom
3637

3738
fromcartopyimportconfig
@@ -44,7 +45,9 @@
4445
fromcartopy.mpl.slippy_image_artistimportSlippyImageArtist
4546

4647

47-
assertmpl.__version__>='3.1', \
48+
_MPL_VERSION=packaging.version.parse(mpl.__version__)
49+
50+
assert_MPL_VERSION.release>= (3,1), \
4851
'Cartopy is only supported with Matplotlib 3.1 or greater.'
4952

5053
# A nested mapping from path, source CRS, and target projection to the
@@ -1960,9 +1963,13 @@ def _wrap_quadmesh(self, collection, **kwargs):
19601963
# Now add back in the masked data if there was any
19611964
full_mask=~maskifC_maskisNoneelse~mask|C_mask
19621965
pcolor_data=np.ma.array(C,mask=full_mask)
1963-
# The pcolor_col is now possibly shorter than the
1964-
# actual collection, so grab the masked cells
1965-
pcolor_col.set_array(pcolor_data[mask].ravel())
1966+
1967+
if_MPL_VERSION.release[:2]< (3,8):
1968+
# The pcolor_col is now possibly shorter than the
1969+
# actual collection, so grab the masked cells
1970+
pcolor_col.set_array(pcolor_data[mask].ravel())
1971+
else:
1972+
pcolor_col.set_array(pcolor_data)
19661973

19671974
pcolor_col.set_cmap(cmap)
19681975
pcolor_col.set_norm(norm)

‎lib/cartopy/mpl/geocollection.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@
33
# This file is part of Cartopy and is released under the LGPL license.
44
# See COPYING and COPYING.LESSER in the root of the repository for full
55
# licensing details.
6+
importmatplotlibasmpl
67
frommatplotlib.collectionsimportQuadMesh
78
importnumpyasnp
9+
importpackaging
10+
11+
12+
_MPL_VERSION=packaging.version.parse(mpl.__version__)
813

914

1015
classGeoQuadMesh(QuadMesh):
@@ -21,7 +26,8 @@ def get_array(self):
2126
A=super().get_array().copy()
2227
# If the input array has a mask, retrieve the associated data
2328
ifhasattr(self,'_wrapped_mask'):
24-
A[self._wrapped_mask]=self._wrapped_collection_fix.get_array()
29+
A[self._wrapped_mask]=np.ma.compressed(
30+
self._wrapped_collection_fix.get_array())
2531
returnA
2632

2733
defset_array(self,A):
@@ -34,7 +40,10 @@ def set_array(self, A):
3440
# Only use the mask attribute if it is there.
3541
ifhasattr(self,'_wrapped_mask'):
3642
# Update the pcolor data with the wrapped masked data
37-
self._wrapped_collection_fix.set_array(A[self._wrapped_mask])
43+
if_MPL_VERSION.release< (3,8):
44+
self._wrapped_collection_fix.set_array(A[self._wrapped_mask])
45+
else:
46+
self._wrapped_collection_fix.set_array(A)
3847
# If the input array was a masked array, keep that data masked
3948
ifhasattr(A,'mask'):
4049
A=np.ma.array(A,mask=self._wrapped_mask|A.mask)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp