@@ -2566,9 +2566,8 @@ def n_components(self):
2566
2566
This is number of elements of the parameter to ``__call__`` and of
2567
2567
*vmin*, *vmax*.
2568
2568
2569
- This class support only a single compoenent , as opposed to `MultiNorm`
2569
+ This class support only a single component , as opposed to `MultiNorm`
2570
2570
which supports multiple components.
2571
-
2572
2571
"""
2573
2572
return 1
2574
2573
@@ -3318,28 +3317,22 @@ def __init__(self, norms, vmin=None, vmax=None, clip=False):
3318
3317
``[vmin, vmax]`` for the constituent norms.
3319
3318
If a list, each value is assigned to each of the constituent
3320
3319
norms. Single values are repeated to form a list of appropriate size.
3321
-
3322
3320
"""
3323
-
3324
3321
if cbook .is_scalar_or_string (norms ):
3325
3322
raise ValueError ("A MultiNorm must be assigned multiple norms" )
3326
3323
3327
- norms = [* norms ]
3328
- for i , n in enumerate (norms ):
3329
- if n is None :
3330
- norms [i ] = Normalize ()
3331
- elif isinstance (n , str ):
3332
- scale_cls = _get_scale_cls_from_str (n )
3324
+ def resolve (norm ):
3325
+ if isinstance (norm , str ):
3326
+ scale_cls = _get_scale_cls_from_str (n )
3333
3327
norms [i ] = mpl .colorizer ._auto_norm_from_scale (scale_cls )()
3334
- elif not isinstance (n , Normalize ):
3328
+ elif isinstance (norm , Normalize ):
3329
+ return norm
3330
+ else :
3335
3331
raise ValueError (
3336
3332
"MultiNorm must be assigned multiple norms, where each norm "
3337
- f"is of type `None` ` str`, or `Normalize`, not { type (n )} " )
3333
+ f"is of type `str`, or `Normalize`, not { type (n )} " )
3338
3334
3339
- # Convert the list of norms to a tuple to make it immutable.
3340
- # If there is a use case for swapping a single norm, we can add support for
3341
- # that later
3342
- self ._norms = tuple (norms )
3335
+ self ._norms = tuple (resolve (norm ) for norm in norms )
3343
3336
3344
3337
self .callbacks = cbook .CallbackRegistry (signals = ["changed" ])
3345
3338
0 commit comments