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

Commit47b5116

Browse files
committed
Let MultiNorm inherit from Norm ABC
1 parentbd8e726 commit47b5116

File tree

2 files changed

+29
-9
lines changed

2 files changed

+29
-9
lines changed

‎lib/matplotlib/colors.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2337,6 +2337,12 @@ def _changed(self):
23372337
"""
23382338
self.callbacks.process('changed')
23392339

2340+
@property
2341+
@abstractmethod
2342+
defn_variables(self):
2343+
# Returns the number of variables supported by this normalization
2344+
pass
2345+
23402346

23412347
classNormalize(Norm):
23422348
"""
@@ -2394,11 +2400,6 @@ def __init__(self, vmin=None, vmax=None, clip=False):
23942400
self._clip=clip
23952401
self._scale=None
23962402

2397-
@property
2398-
defn_variables(self):
2399-
# To be overridden by subclasses with multiple inputs
2400-
return1
2401-
24022403
@property
24032404
defvmin(self):
24042405
# docstring inherited
@@ -2552,6 +2553,11 @@ def scaled(self):
25522553
# docstring inherited
25532554
returnself.vminisnotNoneandself.vmaxisnotNone
25542555

2556+
@property
2557+
defn_variables(self):
2558+
# docstring inherited
2559+
return1
2560+
25552561

25562562
classTwoSlopeNorm(Normalize):
25572563
def__init__(self,vcenter,vmin=None,vmax=None):
@@ -3277,7 +3283,7 @@ def inverse(self, value):
32773283
returnvalue
32783284

32793285

3280-
classMultiNorm(Normalize):
3286+
classMultiNorm(Norm):
32813287
"""
32823288
A class which contains multiple scalar norms
32833289
"""
@@ -3442,6 +3448,12 @@ def autoscale(self, A):
34423448
"""
34433449
For each constituent norm, Set *vmin*, *vmax* to min, max of the corresponding
34443450
variate in *A*.
3451+
3452+
Parameters
3453+
----------
3454+
A
3455+
Data, must be of length `n_variables` or be a structured array or scalar
3456+
with `n_variables` fields.
34453457
"""
34463458
withself.callbacks.blocked():
34473459
# Pause callbacks while we are updating so we only get

‎lib/matplotlib/colors.pyi

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,9 @@ class Norm(ABC):
270270
defautoscale_None(self,A:ArrayLike)->None: ...
271271
@abstractmethod
272272
defscaled(self)->bool: ...
273+
@abstractmethod
274+
@property
275+
defn_variables(self)->int: ...
273276

274277

275278
classNormalize(Norm):
@@ -285,8 +288,6 @@ class Normalize(Norm):
285288
@vmax.setter
286289
defvmax(self,value:float|None)->None: ...
287290
@property
288-
defn_variables(self)->int: ...
289-
@property
290291
defclip(self)->bool: ...
291292
@clip.setter
292293
defclip(self,value:bool)->None: ...
@@ -307,6 +308,8 @@ class Normalize(Norm):
307308
defautoscale(self,A:ArrayLike)->None: ...
308309
defautoscale_None(self,A:ArrayLike)->None: ...
309310
defscaled(self)->bool: ...
311+
@property
312+
defn_variables(self)->Literal[1]: ...
310313

311314
classTwoSlopeNorm(Normalize):
312315
def__init__(
@@ -411,7 +414,7 @@ class BoundaryNorm(Normalize):
411414

412415
classNoNorm(Normalize): ...
413416

414-
classMultiNorm(Normalize):
417+
classMultiNorm(Norm):
415418
# Here "type: ignore[override]" is used for functions with a return type
416419
# that differs from the function in the base class.
417420
# i.e. where `MultiNorm` returns a tuple and Normalize returns a `float` etc.
@@ -438,6 +441,11 @@ class MultiNorm(Normalize):
438441
defclip(self,value:ArrayLike|bool)->None: ...
439442
def__call__(self,value:ArrayLike,clip:ArrayLike|bool|None= ...)->list: ...# type: ignore[override]
440443
definverse(self,value:ArrayLike)->list: ...# type: ignore[override]
444+
defautoscale(self,A:ArrayLike)->None: ...
445+
defautoscale_None(self,A:ArrayLike)->None: ...
446+
defscaled(self)->bool: ...
447+
@property
448+
defn_variables(self)->int: ...
441449

442450
defrgb_to_hsv(arr:ArrayLike)->np.ndarray: ...
443451
defhsv_to_rgb(hsv:ArrayLike)->np.ndarray: ...

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp