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

Commiteb37db8

Browse files
committed
Updates based on feedback from@QuLogic
1 parent23fb63c commiteb37db8

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

‎lib/matplotlib/colorizer.py‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
importnumpyasnp
2525
fromnumpyimportma
2626

27-
frommatplotlibimport_api,colors,cbook,artist,cm,scale
27+
frommatplotlibimport_api,colors,cbook,artist,scale
2828
importmatplotlibasmpl
2929

3030
mpl._docstring.interpd.register(
@@ -222,9 +222,9 @@ def _set_cmap(self, cmap):
222222
in_init=self._cmapisNone
223223
cmap_obj=_ensure_cmap(cmap,accept_multivariate=True)
224224
ifnotin_initandself.norm.n_components!=cmap_obj.n_variates:
225-
raiseValueError(f"The colormap{cmap} does not support "
226-
f"{self.norm.n_components} variates as required by "
227-
f"the{type(self.norm)} on this Colorizer")
225+
raiseValueError(f"The colormap{cmap} does not support "
226+
f"{self.norm.n_components} variates as required by "
227+
f"the{type(self.norm)} on this Colorizer")
228228
self._cmap=cmap_obj
229229
ifnotin_init:
230230
self.changed()# Things are not set up properly yet.
@@ -814,7 +814,8 @@ def _ensure_cmap(cmap, accept_multivariate=False):
814814
ifisinstance(cmap,types):
815815
returncmap
816816

817-
cmap_name=cmapifcmapisnotNoneelsempl.rcParams["image.cmap"]
817+
cmap_name=mpl._val_or_rc(cmap,"image.cmap")
818+
818819
formappinginmappings:
819820
ifcmap_nameinmapping:
820821
returnmapping[cmap_name]
@@ -829,8 +830,6 @@ def _ensure_cmap(cmap, accept_multivariate=False):
829830
" `matplotlib.multivar_colormaps()` for"
830831
" bivariate and multivariate colormaps")
831832

832-
returncm.colormaps[cmap_name]
833-
834833

835834
def_ensure_multivariate_data(data,n_components):
836835
"""
@@ -870,7 +869,8 @@ def _ensure_multivariate_data(data, n_components):
870869
dt=np.dtype('float64, float64')
871870
else:
872871
dt=np.dtype('float32, float32')
873-
reconstructed=np.ma.frombuffer(data.data,dtype=dt).reshape(data.shape)
872+
873+
reconstructed=np.ma.array(np.asarray(data).view(dt))
874874
ifnp.ma.is_masked(data):
875875
fordescriptorindt.descr:
876876
reconstructed[descriptor[0]][data.mask]=np.ma.masked

‎lib/matplotlib/tests/test_colors.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2105,16 +2105,16 @@ def test_ensure_multivariate_data():
21052105
assertmdata.dtype.fields['f1'][0]==np.int64
21062106

21072107
# test input of floats, ints as tuple of lists
2108-
data= ([0.0,0], [1,1])
2108+
data= ([0.0,0.0], [1,1])
21092109
mdata=mcolorizer._ensure_multivariate_data(data,2)
21102110
assertmdata.shape== (2,)
21112111
assertmdata.dtype.fields['f0'][0]==np.float64
21122112
assertmdata.dtype.fields['f1'][0]==np.int64
21132113

21142114
# test input of array of floats
2115-
data=np.array([[0.0,0], [1,1]])
2115+
data=np.array([[0.0,0,0], [1,1,1]])
21162116
mdata=mcolorizer._ensure_multivariate_data(data,2)
2117-
assertmdata.shape== (2,)
2117+
assertmdata.shape== (3,)
21182118
assertmdata.dtype.fields['f0'][0]==np.float64
21192119
assertmdata.dtype.fields['f1'][0]==np.float64
21202120

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp