8000 update following change to MultiNorm · matplotlib/matplotlib@a276d89 · GitHub
[go: up one dir, main page]

Skip to content

Commit a276d89

Browse files
committed
update following change to MultiNorm
1 parent adb4ee3 commit a276d89

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

lib/matplotlib/colorizer.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,9 @@ def _set_cmap(self, cmap):
223223
in_init = self._cmap is None
224224
cmap_obj = _ensure_cmap(cmap, accept_multivariate=True)
225225
if not in_init:
226-
if self.norm.n_output != cmap_obj.n_variates:
226+
if self.norm.n_variables != cmap_obj.n_variates:
227227
raise ValueError(f"The colormap {cmap} does not support "
228-
f"{self.norm.n_output} variates as required by "
228+
f"{self.norm.n_variables} variates as required by "
229229
f"the {type(self.norm)} on this Colorizer")
230230
self._cmap = cmap_obj
231231
if not in_init:
@@ -253,7 +253,7 @@ def set_clim(self, vmin=None, vmax=None):
253253
254254
.. ACCEPTS: (vmin: float, vmax: float)
255255
"""
256-
if self.norm.n_input == 1:
256+
if self.norm.n_variables == 1:
257257
if vmax is None:
258258
try:
259259
vmin, vmax = vmin
@@ -580,7 +580,7 @@ def set_array(self, A):
580580
self._A = None
581581
return
582582

583-
A = _ensure_multivariate_data(A, self.norm.n_input)
583+
A = _ensure_multivariate_data(A, self.norm.n_variables)
584584

585585
A = cbook.safe_masked_invalid(A, copy=True)
586586
if not np.can_cast(A.dtype, float, "same_kind"):
@@ -784,7 +784,7 @@ def _ensure_norm(norm, n_variates=1):
784784
norm = colors.MultiNorm([norm]*n_variates)
785785
else: # multiple string or objects
786786
norm = colors.MultiNorm(norm)
787-
if isinstance(norm, colors.Normalize) and norm.n_output == n_variates:
787+
if isinstance(norm, colors.Normalize) and norm.n_variables == n_variates:
788788
return norm
789789
raise ValueError(
790790
"Invalid norm for multivariate colormap with "
@@ -857,20 +857,20 @@ def _ensure_cmap(cmap, accept_multivariate=False):
857857
return cm.colormaps[cmap_name]
858858

859859

860-
def _ensure_multivariate_data(data, n_input):
860+
def _ensure_multivariate_data(data, n_variables):
861861
"""
862-
Ensure that the data has dtype with n_input.
863-
Input data of shape (n_input, n, m) is converted to an array of shape
864-
(n, m) with data type np.dtype(f'{data.dtype}, ' * n_input)
862+
Ensure that the data has dtype with n_variables.
863+
Input data of shape (n_variables, n, m) is converted to an array of shape
864+
(n, m) with data type np.dtype(f'{data.dtype}, ' * n_variables)
865865
Complex data is returned as a view with dtype np.dtype('float64, float64')
866866
or np.dtype('float32, float32')
867-
If n_input is 1 and data is not of type np.ndarray (i.e. PIL.Image),
867+
If n_variables is 1 and data is not of type np.ndarray (i.e. PIL.Image),
868868
the data is returned unchanged.
869869
If data is None, the function returns None
870870
871871
Parameters
872872
----------
873-
n_input : int
873+
n_variables : int
874874
- number of variates in the data
875875
data : np.ndarray, PIL.Image or None
876876
@@ -880,7 +880,7 @@ def _ensure_multivariate_data(data, n_input):
880880
"""
881881

882882
if isinstance(data, np.ndarray):
883-
if len(data.dtype.descr) == n_input:
883+
if len(data.dtype.descr) == n_variables:
884884
# pass scalar data
885885
# and already formatted data
886886
return data
@@ -896,8 +896,8 @@ def _ensure_multivariate_data(data, n_input):
896896
reconstructed[descriptor[0]][data.mask] = np.ma.masked
897897
return reconstructed
898898

899-
if n_input > 1 and len(data) == n_input:
900-
# convert data from shape (n_input, n, m)
899+
if n_variables > 1 and len(data) == n_variables:
900+
# convert data from shape (n_variables, n, m)
901901
# to (n,m) with a new dtype
902902
data = [np.ma.array(part, copy=False) for part in data]
903903
dt = np.dtype(', '.join([f'{part.dtype}' for part in data]))
@@ -915,15 +915,15 @@ def _ensure_multivariate_data(data, n_input):
915915
if data is None:
916916
return data
917917

918-
if n_input == 1:
918+
if n_variables == 1:
919919
# PIL.Image also gets passed here
920920
return data
921921

922-
elif n_input == 2:
922+
elif n_variables == 2:
923923
raise ValueError("Invalid data entry for multivariate data. The data"
924924
" must contain complex numbers, or have a first dimension 2,"
925925
" or be of a dtype with 2 fields")
926926
else:
927927
raise ValueError("Invalid data entry for multivariate data. The shape"
928-
f" of the data must have a first dimension {n_input}"
929-
f" or be of a dtype with {n_input} fields")
928+
f" of the data must have a first dimension {n_variables}"
929+
f" or be of a dtype with {n_variables} fields")

0 commit comments

Comments
 (0)
0