Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 78b173e

Browse files
committed
change MultiNorm.n_intput to n_variables
1 parent 73713e7 commit 78b173e

File tree

2 files changed

+26
-37
lines changed

2 files changed

+26
-37
lines changed

lib/matplotlib/colors.py

Lines changed: 25 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2321,15 +2321,10 @@ def __init__(self, vmin=None, vmax=None, clip=False):
23212321
self.callbacks = cbook.CallbackRegistry(signals=["changed"])
23222322

23232323
@property
2324-
def n_input(self):
2324+
def n_variables(self):
23252325
# To be overridden by subclasses with multiple inputs
23262326
return 1
23272327

2328-
@property
2329-
def n_output(self):
2330-
# To be overridden by subclasses with multiple outputs
2331-
return 1
2332-
23332328
@property
23342329
def vmin(self):
23352330
return self._vmin
@@ -3283,11 +3278,7 @@ def __init__(self, norms, vmin=None, vmax=None, clip=False):
32833278
n.callbacks.connect('changed', self._changed)
32843279

32853280
@property
3286-
def n_input(self):
3287-
return len(self._norms)
3288-
3289-
@property
3290-
def n_output(self):
3281+
def n_variables(self):
32913282
return len(self._norms)
32923283

32933284
@property
@@ -3300,7 +3291,7 @@ def vmin(self):
33003291

33013292
@vmin.setter
33023293
def vmin(self, value):
3303-
value = np.broadcast_to(value, self.n_input)
3294+
value = np.broadcast_to(value, self.n_variables)
33043295
with self.callbacks.blocked():
33053296
for i, v in enumerate(value):
33063297
if v is not None:
@@ -3313,7 +3304,7 @@ def vmax(self):
33133304

33143305
@vmax.setter
33153306
def vmax(self, value):
3316-
value = np.broadcast_to(value, self.n_input)
3307+
value = np.broadcast_to(value, self.n_variables)
33173308
with self.callbacks.blocked():
33183309
for i, v in enumerate(value):
33193310
if v is not None:
@@ -3326,7 +3317,7 @@ def clip(self):
33263317

33273318
@clip.setter
33283319
def clip(self, value):
3329-
value = np.broadcast_to(value, self.n_input)
3320+
value = np.broadcast_to(value, self.n_variables)
33303321
with self.callbacks.blocked():
33313322
for i, v in enumerate(value):
33323323
if v is not None:
@@ -3349,8 +3340,8 @@ def __call__(self, value, clip=None):
33493340
Parameters
33503341
----------
33513342
value
3352-
Data to normalize. Must be of length `n_input` or have a data type with
3353-
`n_input` fields.
3343+
Data to normalize. Must be of length `n_variables` or have a data type with
3344+
`n_variables` fields.
33543345
clip : list of bools or bool, optional
33553346
See the description of the parameter *clip* in Normalize.
33563347
If ``None``, defaults to ``self.clip`` (which defaults to
@@ -3359,7 +3350,7 @@ def __call__(self, value, clip=None):
33593350
Returns
33603351
-------
33613352
Data
3362-
Normalized input values as a list of length `n_input`
3353+
Normalized input values as a list of length `n_variables`
33633354
33643355
Notes
33653356
-----
@@ -3369,9 +3360,9 @@ def __call__(self, value, clip=None):
33693360
if clip is None:
33703361
clip = self.clip
33713362
elif not np.iterable(clip):
3372-
clip = [clip]*self.n_input
3363+
clip = [clip]*self.n_variables
33733364

3374-
value = self._iterable_variates_in_data(value, self.n_input)
3365+
value = self._iterable_variates_in_data(value, self.n_variables)
33753366
result = [n(v, clip=c) for n, v, c in zip(self.norms, value, clip)]
33763367
return result
33773368

@@ -3382,10 +3373,10 @@ def inverse(self, value):
33823373
Parameters
33833374
----------
33843375
value
3385-
Normalized value. Must be of length `n_input` or have a data type with
3386-
`n_input` fields.
3376+
Normalized value. Must be of length `n_variables` or have a data type with
3377+
`n_variables` fields.
33873378
"""
3388-
value = self._iterable_variates_in_data(value, self.n_input)
3379+
value = self._iterable_variates_in_data(value, self.n_variables)
33893380
result = [n.inverse(v) for n, v in zip(self.norms, value)]
33903381
return result
33913382

@@ -3397,7 +3388,7 @@ def autoscale(self, A):
33973388
with self.callbacks.blocked():
33983389
# Pause callbacks while we are updating so we only get
33993390
# a single update signal at the end
3400-
A = self._iterable_variates_in_data(A, self.n_input)
3391+
A = self._iterable_variates_in_data(A, self.n_variables)
34013392
for n, a in zip(self.norms, A):
34023393
n.autoscale(a)
34033394
self._changed()
@@ -3410,11 +3401,11 @@ def autoscale_None(self, A):
34103401
Parameters
34113402
----------
34123403
A
3413-
Data, must be of length `n_input` or be an np.ndarray type with
3414-
`n_input` fields.
3404+
Data, must be of length `n_variables` or be an np.ndarray type with
3405+
`n_variables` fields.
34153406
"""
34163407
with self.callbacks.blocked():
3417-
A = self._iterable_variates_in_data(A, self.n_input)
3408+
A = self._iterable_variates_in_data(A, self.n_variables)
34183409
for n, a in zip(self.norms, A):
34193410
n.autoscale_None(a)
34203411
self._changed()
@@ -3424,18 +3415,18 @@ def scaled(self):
34243415
return all([(n.vmin is not None and n.vmax is not None) for n in self.norms])
34253416

34263417
@staticmethod
3427-
def _iterable_variates_in_data(data, n_input):
3418+
def _iterable_variates_in_data(data, n_variables):
34283419
"""
34293420
Provides an iterable over the variates contained in the data.
34303421
3431-
An input array with n_input fields is returned as a list of length n referencing
3432-
slices of the original array.
3422+
An input array with `n_variables` fields is returned as a list of length n
3423+
referencing slices of the original array.
34333424
34343425
Parameters
34353426
----------
34363427
data : np.ndarray, tuple or list
3437-
The input array. It must either be an array with n_input fields or have
3438-
a length (n_input)
3428+
The input array. It must either be an array with n_variables fields or have
3429+
a length (n_variables)
34393430
34403431
Returns
34413432
-------
@@ -3444,10 +3435,10 @@ def _iterable_variates_in_data(data, n_input):
34443435
"""
34453436
if isinstance(data, np.ndarray) and data.dtype.fields is not None:
34463437
data = [data[descriptor[0]] for descriptor in data.dtype.descr]
3447-
if len(data) != n_input:
3438+
if len(data) != n_variables:
34483439
raise ValueError("The input to this `MultiNorm` must be of shape "
3449-
f"({n_input}, ...), or have a data type with {n_input} "
3450-
"fields.")
3440+
f"({n_variables}, ...), or have a data type with "
3441+
f"{n_variables} fields.")
34513442
return data
34523443

34533444

lib/matplotlib/colors.pyi

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,7 @@ class Normalize:
263263
@vmax.setter
264264
def vmax(self, value: float | None) -> None: ...
265265
@property
266-
def n_input(self) -> int: ...
267-
@property
268-
def n_output(self) -> int: ...
266+
def n_variables(self) -> int: ...
269267
@property
270268
def clip(self) -> bool: ...
271269
@clip.setter

0 commit comments

Comments
 (0)