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

Appearance settings

Commit 9ac2739

Browse filesBrowse files
trygvradksunden
authored andcommitted
updates to colorizer pipeline based on feedback from @QuLogic
1 parent dbe8cc3 commit 9ac2739
Copy full SHA for 9ac2739

File tree

Expand file treeCollapse file tree

9 files changed

+22
-38
lines changed
Filter options
Expand file treeCollapse file tree

9 files changed

+22
-38
lines changed

‎lib/matplotlib/axes/_axes.pyi

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_axes.pyi
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,8 +439,8 @@ class Axes(_AxesBase):
439439
reduce_C_function: Callable[[np.ndarray | list[float]], float] = ...,
440440
mincnt: int | None = ...,
441441
marginals: bool = ...,
442-
data=...,
443442
colorizer: Colorizer | None = ...,
443+
data=...,
444444
**kwargs
445445
) -> PolyCollection: ...
446446
def arrow(

‎lib/matplotlib/collections.pyi

Copy file name to clipboardExpand all lines: lib/matplotlib/collections.pyi
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ from numpy.typing import ArrayLike, NDArray
77
from . import colorizer, transforms
88
from .backend_bases import MouseEvent
99
from .artist import Artist
10-
from .colorizer import Colorizer
1110
from .colors import Normalize, Colormap
1211
from .lines import Line2D
1312
from .path import Path
@@ -31,7 +30,7 @@ class Collection(colorizer.ColorizingArtist):
3130
offset_transform: transforms.Transform | None = ...,
3231
norm: Normalize | None = ...,
3332
cmap: Colormap | None = ...,
34-
colorizer: Colorizer | None = ...,
33+
colorizer: colorizer.Colorizer | None = ...,
3534
pickradius: float = ...,
3635
hatch: str | None = ...,
3736
urls: Sequence[str] | None = ...,

‎lib/matplotlib/colorbar.py

Copy file name to clipboardExpand all lines: lib/matplotlib/colorbar.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ def update_normal(self, mappable=None):
498498
# [ColorizingArtist.changed() emits self.callbacks.process('changed')]
499499
# Also, there is no test where self.mappable == mappable is not True
500500
# and possibly no use case.
501-
# Therefore, the mappable keyword can be depreciated if cm.ScalarMappable
501+
# Therefore, the mappable keyword can be deprecated if cm.ScalarMappable
502502
# is removed.
503503
self.mappable = mappable
504504
_log.debug('colorbar update normal %r %r', self.mappable.norm, self.norm)

‎lib/matplotlib/colorizer.py

Copy file name to clipboardExpand all lines: lib/matplotlib/colorizer.py
-15Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -192,21 +192,6 @@ def _pass_image_data(x, alpha=None, bytes=False, norm=True):
192192
xx[np.any(np.ma.getmaskarray(x), axis=2), 3] = 0
193193
return xx
194194

195-
def normalize(self, x):
196-
"""
197-
Normalize the data in x.
198-
199-
Parameters
200-
----------
201-
x : np.array
202-
203-
Returns
204-
-------
205-
np.array
206-
207-
"""
208-
return self.norm(x)
209-
210195
def autoscale(self, A):
211196
"""
212197
Autoscale the scalar limits on the norm instance using the

‎lib/matplotlib/colorizer.pyi

Copy file name to clipboardExpand all lines: lib/matplotlib/colorizer.pyi
+7-10Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import numpy as np
55
from numpy.typing import ArrayLike
66

77

8-
class Colorizer():
8+
class Colorizer:
99
colorbar: colorbar.Colorbar | None
1010
callbacks: cbook.CallbackRegistry
1111
def __init__(
1212
self,
13-
norm: colors.Normalize | str | None = ...,
1413
cmap: str | colors.Colormap | None = ...,
14+
norm: str | colors.Normalize | None = ...,
1515
) -> None: ...
1616
@property
1717
def norm(self) -> colors.Normalize: ...
@@ -24,12 +24,6 @@ class Colorizer():
2424
bytes: bool = ...,
2525
norm: bool = ...,
2626
) -> np.ndarray: ...
27-
@overload
28-
def normalize(self, value: float, clip: bool | None = ...) -> float: ...
29-
@overload
30-
def normalize(self, value: np.ndarray, clip: bool | None = ...) -> np.ma.MaskedArray: ...
31-
@overload
32-
def normalize(self, value: ArrayLike, clip: bool | None = ...) -> ArrayLike: ...
3327
def autoscale(self, A: ArrayLike) -> None: ...
3428
def autoscale_None(self, A: ArrayLike) -> None: ...
3529
@property
@@ -83,6 +77,9 @@ class _ScalarMappable(_ColorizerInterface):
8377
self,
8478
norm: colors.Normalize | None = ...,
8579
cmap: str | colors.Colormap | None = ...,
80+
*,
81+
colorizer: Colorizer | None = ...,
82+
**kwargs
8683
) -> None: ...
8784
def set_array(self, A: ArrayLike | None) -> None: ...
8885
def get_array(self) -> np.ndarray | None: ...
@@ -93,8 +90,8 @@ class ColorizingArtist(_ScalarMappable, artist.Artist):
9390
callbacks: cbook.CallbackRegistry
9491
def __init__(
9592
self,
96-
norm: colors.Normalize | None = ...,
97-
cmap: str | colors.Colormap | None = ...,
93+
colorizer: Colorizer,
94+
**kwargs
9895
) -> None: ...
9996
def set_array(self, A: ArrayLike | None) -> None: ...
10097
def get_array(self) -> np.ndarray | None: ...

‎lib/matplotlib/figure.py

Copy file name to clipboardExpand all lines: lib/matplotlib/figure.py
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2972,8 +2972,8 @@ def set_canvas(self, canvas):
29722972

29732973
@_docstring.interpd
29742974
def figimage(self, X, xo=0, yo=0, alpha=None, norm=None, cmap=None,
2975-
vmin=None, vmax=None, colorizer=None, origin=None, resize=False,
2976-
**kwargs):
2975+
vmin=None, vmax=None, origin=None, resize=False, *,
2976+
colorizer=None, **kwargs):
29772977
"""
29782978
Add a non-resampled image to the figure.
29792979
@@ -3009,17 +3009,17 @@ def figimage(self, X, xo=0, yo=0, alpha=None, norm=None, cmap=None,
30093009
30103010
This parameter is ignored if *X* is RGB(A).
30113011
3012-
%(colorizer_doc)s
3013-
3014-
This parameter is ignored if *X* is RGB(A).
3015-
30163012
origin : {'upper', 'lower'}, default: :rc:`image.origin`
30173013
Indicates where the [0, 0] index of the array is in the upper left
30183014
or lower left corner of the Axes.
30193015
30203016
resize : bool
30213017
If *True*, resize the figure to match the given image size.
30223018
3019+
%(colorizer_doc)s
3020+
3021+
This parameter is ignored if *X* is RGB(A).
3022+
30233023
Returns
30243024
-------
30253025
`matplotlib.image.FigureImage`

‎lib/matplotlib/figure.pyi

Copy file name to clipboardExpand all lines: lib/matplotlib/figure.pyi
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,9 +368,10 @@ class Figure(FigureBase):
368368
cmap: str | Colormap | None = ...,
369369
vmin: float | None = ...,
370370
vmax: float | None = ...,
371-
colorizer: Colorizer | None = ...,
372371
origin: Literal["upper", "lower"] | None = ...,
373372
resize: bool = ...,
373+
*,
374+
colorizer: Colorizer | None = ...,
374375
**kwargs
375376
) -> FigureImage: ...
376377
def set_size_inches(

‎lib/matplotlib/meson.build

Copy file name to clipboardExpand all lines: lib/matplotlib/meson.build
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ typing_sources = [
103103
'cm.pyi',
104104
'collections.pyi',
105105
'colorbar.pyi',
106+
'colorizer.pyi',
106107
'colors.pyi',
107108
'container.pyi',
108109
'contour.pyi',

‎lib/matplotlib/pyplot.py

Copy file name to clipboardExpand all lines: lib/matplotlib/pyplot.py
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2723,9 +2723,10 @@ def figimage(
27232723
cmap: str | Colormap | None = None,
27242724
vmin: float | None = None,
27252725
vmax: float | None = None,
2726-
colorizer: Colorizer | None = None,
27272726
origin: Literal["upper", "lower"] | None = None,
27282727
resize: bool = False,
2728+
*,
2729+
colorizer: Colorizer | None = None,
27292730
**kwargs,
27302731
) -> FigureImage:
27312732
return gcf().figimage(
@@ -2737,9 +2738,9 @@ def figimage(
27372738
cmap=cmap,
27382739
vmin=vmin,
27392740
vmax=vmax,
2740-
colorizer=colorizer,
27412741
origin=origin,
27422742
resize=resize,
2743+
colorizer=colorizer,
27432744
**kwargs,
27442745
)
27452746

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.