Skip to content

Commit 590d77e

Browse files
feat: update for crameri v8 (#83)
* ci(pre-commit.ci): autoupdate updates: - [github.com/astral-sh/ruff-pre-commit: v0.7.2 → v0.8.6](astral-sh/ruff-pre-commit@v0.7.2...v0.8.6) - [github.com/pre-commit/mirrors-mypy: v1.13.0 → v1.14.1](pre-commit/mirrors-mypy@v1.13.0...v1.14.1) * style(pre-commit.ci): auto fixes [...] * update crameri * update validate-pyproject * block pydantic-extra-types 2.10.1 * add author and remove mpl aliases * style(pre-commit.ci): auto fixes [...] --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 49bb688 commit 590d77e

File tree

13 files changed

+1359
-30
lines changed

13 files changed

+1359
-30
lines changed

.pre-commit-config.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,21 @@ repos:
1616
args: [--autofix]
1717

1818
- repo: https://github.com/astral-sh/ruff-pre-commit
19-
rev: v0.7.2
19+
rev: v0.9.1
2020
hooks:
2121
- id: ruff
2222
args: [--fix, --unsafe-fixes]
2323
- id: ruff-format
2424

2525
# commented out until PEP 639 is supported\
2626
# https://github.com/abravalheri/validate-pyproject/issues/70
27-
# - repo: https://github.com/abravalheri/validate-pyproject
28-
# rev: v0.10.1
29-
# hooks:
30-
# - id: validate-pyproject
27+
- repo: https://github.com/abravalheri/validate-pyproject
28+
rev: v0.23
29+
hooks:
30+
- id: validate-pyproject
3131

3232
- repo: https://github.com/pre-commit/mirrors-mypy
33-
rev: v1.13.0
33+
rev: v1.14.1
3434
hooks:
3535
- id: mypy
3636
files: "^src/"

pyproject.toml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ name = "cmap"
99
description = "Scientific colormaps for python, without dependencies"
1010
readme = "README.md"
1111
requires-python = ">=3.8"
12-
license = { text = "BSD 3-Clause License" }
12+
license = "BSD-3-Clause"
13+
license-files = ["LICENSE/*"]
1314
authors = [{ email = "[email protected]", name = "Talley Lambert" }]
1415
classifiers = [
1516
"Development Status :: 4 - Beta",
@@ -25,9 +26,6 @@ classifiers = [
2526
dynamic = ["version"]
2627
dependencies = ["numpy"]
2728

28-
[project.license-files]
29-
globs = ["LICENSE/*"]
30-
3129
# extras
3230
# https://peps.python.org/pep-0621/#dependencies-optional-dependencies
3331
[project.optional-dependencies]
@@ -52,9 +50,9 @@ test_thirdparty = [
5250
"colour",
5351
"matplotlib",
5452
"napari>=0.4.19; python_version<'3.13'",
55-
"numba; python_version<'3.13'",
53+
"numba; python_version<'3.13' and platform_machine != 'arm64'",
5654
"plotly",
57-
"pydantic-extra-types>=2",
55+
"pydantic-extra-types>=2,!=2.10.1",
5856
"pydantic",
5957
"pygfx",
6058
"pyqtgraph",
@@ -73,6 +71,7 @@ dev = [
7371
"pytest",
7472
"rich",
7573
"ruff",
74+
"pyqt6",
7675
]
7776

7877
[project.urls]

src/cmap/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ def resolve(self, name: str) -> str:
6262
from ._catalog import Catalog, CatalogItem
6363

6464
__all__ = [
65-
"Catalog",
66-
"CatalogItem",
67-
"Color",
68-
"Colormap",
69-
"ColorStops",
7065
"HSLA",
7166
"HSVA",
7267
"RGBA",
7368
"RGBA8",
69+
"Catalog",
70+
"CatalogItem",
71+
"Color",
72+
"ColorStops",
73+
"Colormap",
7474
]

src/cmap/_catalog.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def _build_catalog(records: Iterable[FileDescriptorOrPath]) -> CatalogDict:
177177
# here we add any global keys to the colormap that are not already there.
178178
for k in ("license", "namespace", "source", "authors", "category"):
179179
if k in data:
180-
v.setdefault(k, data[k]) # type: ignore [misc,literal-required]
180+
v.setdefault(k, data[k]) # type: ignore [misc]
181181

182182
# add the fully namespaced colormap to the catalog
183183
ctlg[namespaced] = v

src/cmap/_color.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def to_float(self) -> RGBA:
141141
def to_hex(self) -> str:
142142
"""Convert to hex color."""
143143
out = f"#{self.r:02X}{self.g:02X}{self.b:02X}"
144-
return f"{out}{round(self.a*255):02X}" if self.a != 1 else out
144+
return f"{out}{round(self.a * 255):02X}" if self.a != 1 else out
145145

146146
def to_hsv(self) -> HSVA:
147147
"""Convert to Hue, Saturation, Value."""
@@ -466,7 +466,7 @@ class Color:
466466
The color to represent. Can be any "ColorLike".
467467
"""
468468

469-
__slots__ = ("_rgba", "_name", "__weakref__")
469+
__slots__ = ("__weakref__", "_name", "_rgba")
470470
_rgba: RGBA
471471
_name: str | None
472472

src/cmap/_colormap.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ class Colormap:
121121
"""
122122

123123
__slots__ = (
124+
"__weakref__",
125+
"_initialized",
126+
"_lut_cache",
124127
"bad_color",
125128
"category",
126129
"color_stops",
@@ -130,9 +133,6 @@ class Colormap:
130133
"name",
131134
"over_color",
132135
"under_color",
133-
"_initialized",
134-
"_lut_cache",
135-
"__weakref__",
136136
)
137137

138138
color_stops: ColorStops
@@ -920,7 +920,7 @@ def _from_colorarray_like(cls, colors: ArrayLike) -> ColorStops:
920920
return cls(np.concatenate([stops[:, None], ary], axis=1))
921921

922922
@property
923-
def stops(self) -> tuple[float, ...]:
923+
def stops(self) -> tuple[np.floating, ...]:
924924
"""Return tuple of color stop positions."""
925925
return tuple(self._stops[:, 0])
926926

@@ -1061,14 +1061,14 @@ def to_css(
10611061
midpoints = np.linspace(0, 1, len(colors) + 1)[1:-1]
10621062
_midstops = []
10631063
for m, (c1, c2) in zip(midpoints, zip(colors[:-1], colors[1:])):
1064-
s1 = f"{c1.hex if as_hex else c1.rgba_string} {m*100:g}%"
1065-
s2 = f"{c2.hex if as_hex else c2.rgba_string} {m*100:g}%"
1064+
s1 = f"{c1.hex if as_hex else c1.rgba_string} {m * 100:g}%"
1065+
s2 = f"{c2.hex if as_hex else c2.rgba_string} {m * 100:g}%"
10661066
_midstops.extend([s1, s2])
10671067
_stops = ", ".join(_midstops)
10681068
else:
10691069
_stops = ", ".join(
10701070
[
1071-
f"{c.hex if as_hex else c.rgba_string} {s*100:g}%"
1071+
f"{c.hex if as_hex else c.rgba_string} {s * 100:g}%"
10721072
for c, s in zip(colors, stops)
10731073
]
10741074
)

src/cmap/_util.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ def plot_color_gradients(
3434
nrows = len(cmap_list) * (2 if compare else 1)
3535
figh = 0.35 + 0.15 + (nrows + (nrows - 1) * 0.1) * 0.22
3636
fig, axs = plt.subplots(nrows=nrows + 1, figsize=(6.4, figh))
37-
fig.subplots_adjust(top=1 - 0.35 / figh, bottom=0.15 / figh, left=0.2, right=0.99)
37+
bottom = 0.15 / figh
38+
top = 1 - 0.35 / figh
39+
if bottom >= top: # pragma: no cover
40+
bottom, top = top, bottom
41+
fig.subplots_adjust(top=top, bottom=bottom, left=0.2, right=0.99)
3842

3943
for i, (ax, name) in enumerate(zip(axs[:: 2 if compare else 1], cmap_list)):
4044
cm = _ensure_cmap(name).to_mpl()
@@ -137,7 +141,7 @@ def plot_lightness(
137141
x = np.linspace(0.0, 1.0, 101) if x is None else np.asarray(x)
138142
cmap = _ensure_cmap(cmap)
139143
lab = calc_lightness(cmap, x, colorspace)
140-
lslice = np.s_[::-1] if reverse else np.s_[:]
144+
lslice = np.s_[::-1] if reverse else slice(None)
141145
y_ = lab[lslice]
142146
c_ = x[lslice]
143147

0 commit comments

Comments
 (0)