Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: "ubuntu-latest"
strategy:
matrix:
python-version: ["3.11"]
python-version: ["3.14"]

steps:
- uses: "actions/checkout@v3"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: "Set up Python"
uses: "actions/setup-python@v4"
with:
python-version: "3.9"
python-version: "3.12"

- name: "Install build tool"
run: "pip install --user build"
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ jobs:
strategy:
matrix:
python-version:
- "3.11"
- "3.10"
- "3.9"
- "3.14"
- "3.13"
- "3.12"
pyqt-dependency:
- "PyQt6"
- "PySide6"
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ repos:
- id: "end-of-file-fixer"

- repo: "https://github.com/charliermarsh/ruff-pre-commit"
rev: "v0.0.269"
rev: "v0.15.14"
hooks:
- id: "ruff"
- id: "ruff-check"
# NOTE: "--exit-non-zero-on-fix" is important for CI to function
# correctly!
args: ["--fix", "--exit-non-zero-on-fix"]

- repo: "https://github.com/psf/black"
rev: "23.3.0"
rev: "26.5.1"
hooks:
- id: "black"
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Contact:
Nathaniel J. Smith <njs@pobox.com> and Stéfan van der Walt <stefanv@berkeley.edu>

Dependencies:
* Python 3.9+
* Python 3.12+
* `colorspacious <https://pypi.python.org/pypi/colorspacious>`_ 1.1+
* Matplotlib 3.5+
* NumPy 1.22+
Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ channels:
- "nodefaults"
dependencies:
# Runtime
- "python ~=3.11"
- "python ~=3.12"
- "numpy ~=1.24"
- "matplotlib ~=3.7"
- "colorspacious ~=1.1"
Expand Down
29 changes: 16 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ classifiers = [
"Programming Language :: Python :: 3",
]

requires-python = "~=3.9"
requires-python = ">=3.12"
dependencies = [
"numpy ~=1.22",
"matplotlib ~=3.5",
"colorspacious ~=1.1",
"scipy ~=1.8",
"numpy >=1.22",
"matplotlib >=3.5",
"colorspacious >=1.1",
"scipy >=1.8",
]

[project.optional-dependencies]
Expand Down Expand Up @@ -60,7 +60,7 @@ package-data = {viscm = ["examples/*"]}


[tool.mypy]
python_version = "3.9"
python_version = "3.12"

# These libraries don't have type stubs. Mypy will see them as `Any` and not
# throw an [import] error.
Expand All @@ -73,11 +73,7 @@ module = [
ignore_missing_imports = true


[tool.black]
target-version = ["py39", "py310", "py311"]

[tool.ruff]
target-version = "py39"
[tool.ruff.lint]
select = [
"F",
"E",
Expand All @@ -93,9 +89,16 @@ select = [
"T10",
"RUF",
]
ignore = [
"B905",
"UP031",
"RUF005",
"RUF046",
"RUF059",
]

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"viscm/gui.py" = ["N8"]

[tool.ruff.mccabe]
[tool.ruff.lint.mccabe]
max-complexity = 11
1 change: 1 addition & 0 deletions test/data/option_d.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
You should have received a copy of the CC0 legalcode along with this
work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
"""

from matplotlib.colors import LinearSegmentedColormap

# Used to reconstruct the colormap in viscm
Expand Down
9 changes: 4 additions & 5 deletions viscm/cli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import sys
from pathlib import Path
from typing import Union

import matplotlib.pyplot as plt

Expand Down Expand Up @@ -117,13 +116,13 @@ def cli():
def _make_window(
*,
action: str,
cmap: Union[str, None],
cmap: str | None,
cmap_type: str,
cmap_spline_method: str,
cmap_uniform_space: str,
save: Union[Path, None],
save: Path | None,
quit_immediately: bool,
) -> Union[gui.ViewerWindow, gui.EditorWindow]:
) -> gui.ViewerWindow | gui.EditorWindow:
# Hold a reference so it doesn't get GC'ed
fig = plt.figure()
figure_canvas = gui.FigureCanvas(fig)
Expand All @@ -132,7 +131,7 @@ def _make_window(
if cmap:
cm.load(cmap)

v: Union[gui.viscm, gui.viscm_editor]
v: gui.viscm | gui.viscm_editor
# Easter egg! I keep typing 'show' instead of 'view' so accept both
if action in ("view", "show"):
if cm is None:
Expand Down
20 changes: 8 additions & 12 deletions viscm/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,9 @@ def delta_ymax(values):
title(ax, "Perceptual derivative")
label(
ax,
"Length: {:0.1f}\nRMS deviation from flat: {:0.1f} ({:0.1f}%)".format(
arclength, rmse, 100 * rmse / arclength
),
f"Length: {arclength:0.1f}"
f"\nRMS deviation from flat: {rmse:0.1f}"
f" ({100 * rmse / arclength:0.1f}%)",
)
ax.set_ylim(-delta_ymax(-local_derivs), delta_ymax(local_derivs))
ax.get_xaxis().set_visible(False)
Expand All @@ -308,11 +308,9 @@ def delta_ymax(values):
lightness_rmse = np.std(lightness_derivs)
label(
ax,
"Length: {:0.1f}\nRMS deviation from flat: {:0.1f} ({:0.1f}%)".format(
lightness_arclength,
lightness_rmse,
100 * lightness_rmse / lightness_arclength,
),
f"Length: {lightness_arclength:0.1f}"
f"\nRMS deviation from flat: {lightness_rmse:0.1f}"
f" ({100 * lightness_rmse / lightness_arclength:0.1f}%)",
)

ax.set_ylim(-delta_ymax(-lightness_derivs), delta_ymax(lightness_derivs))
Expand Down Expand Up @@ -707,16 +705,14 @@ def save_colormap(self, filepath):
def export_py(self, filepath):
import textwrap

template = textwrap.dedent(
"""
template = textwrap.dedent("""
from matplotlib.colors import ListedColormap

cm_type = "{type}"

cm_data = {array_list}
test_cm = ListedColormap(cm_data, name="{name}")
"""
)
""")
rgb, _ = self.cmap_model.get_sRGB(num=256)
array_list = np.array2string(
rgb, max_line_width=78, prefix="cm_data = ", separator=","
Expand Down
Loading