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
10 changes: 5 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ jobs:
- "3.11"
- "3.10"
- "3.9"
- "3.8"
pyqt-dependency:
- "PyQt5"
# - "PyQt6"
- "PyQt6"
- "PySide6"

steps:
- uses: "actions/checkout@v3"
Expand All @@ -37,8 +36,9 @@ jobs:
# pytest-qt CI dependencies: https://pytest-qt.readthedocs.io/en/latest/troubleshooting.html#github-actions
sudo apt update
sudo apt install -y \
xvfb \
libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xfixes0 x11-utils
xvfb libegl1 \
libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xfixes0 x11-utils \
libxcb-cursor0
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without libxcb-cursor0, tests failed with Aborted (core dumped) under both PySide6 and PyQt6.


- name: "Run tests"
run: "make test"
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.PHONY: test
test:
python -m pytest --version
python -m pytest -v test/
python -m pytest -sv test/


.PHONY: lint
Expand Down
57 changes: 37 additions & 20 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,6 @@ viscm

This is a little tool for analyzing colormaps and creating new colormaps.

Try::

$ pip install viscm
$ python -m viscm view jet
$ python -m viscm edit

There is some information available about how to interpret the
resulting visualizations and use the editor tool `on this website
<https://bids.github.io/colormap/>`_.

Downloads:
* https://pypi.python.org/pypi/viscm/
* https://anaconda.org/conda-forge/viscm/
Expand All @@ -24,23 +14,50 @@ Contact:
Nathaniel J. Smith <njs@pobox.com> and Stéfan van der Walt <stefanv@berkeley.edu>

Dependencies:
* Python 3.8+
* `colorspacious <https://pypi.python.org/pypi/colorspacious>`_
* Matplotlib
* NumPy
* Python 3.9+
* `colorspacious <https://pypi.python.org/pypi/colorspacious>`_ 1.1+
* Matplotlib 3.5+
* NumPy 1.22+
* SciPy 1.8+
* one of PyQt6, PySide6

License:
MIT, see `LICENSE <LICENSE>`__ for details.


Installation
------------

This is a GUI application, and requires Qt Python bindings.
They can be provided by PyQt (GPL) or PySide (LGPL)::

$ pip install viscm[PySide]

...or::

$ pip install viscm[PyQt]


Usage
-----

::

$ viscm view jet
$ viscm edit

There is some information available about how to interpret the
resulting visualizations and use the editor tool `on this website
<https://bids.github.io/colormap/>`_.


Reproducing viridis
-------------------
^^^^^^^^^^^^^^^^^^^

Load [viridis AKA option_d.py](https://github.com/BIDS/colormap/) using:
Load `viridis AKA option_d.py <https://github.com/BIDS/colormap/>`__ using::

```
python -m viscm --uniform-space buggy-CAM02-UCS -m Bezier edit /tmp/option_d.py
```
viscm --uniform-space buggy-CAM02-UCS -m Bezier edit /tmp/option_d.py

Note that there was a small bug in the assumed sRGB viewing conditions
while designing viridis. It does not affect the outcome by much. Also
see `python -m viscm --help`.
see :code:`viscm --help`.
2 changes: 2 additions & 0 deletions doc/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ python -m build
pip install dist/*.whl # or `dist/*.tar.gz`
```

To automatically install a Qt dependency, try `pip install dist/<wheel_filename>[PyQt]`.


## Tests

Expand Down
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ dependencies:
- "matplotlib ~=3.7"
- "colorspacious ~=1.1"
- "scipy ~=1.10"
- "PySide6"

# Development
- "mypy ~=1.3.0"
Expand Down
21 changes: 13 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,19 @@ classifiers = [
"Programming Language :: Python :: 3",
]

requires-python = "~=3.8"
requires-python = "~=3.9"
dependencies = [
"numpy",
"matplotlib",
"colorspacious",
"scipy",
"numpy ~=1.22",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this also place an upper pin on NumPy?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's equivalent to >=1.22, 1.*, so numpy could not be upgraded to 2.x or higher.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, the setuptools docs are a bit confusing: wanted to make sure this didn't pin to 22

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's some good info "compatible release" specification: https://peps.python.org/pep-0440/#compatible-release

"matplotlib ~=3.5",
"colorspacious ~=1.1",
"scipy ~=1.8",
]

[project.optional-dependencies]
# Qt6 was released 2020.08.12
PySide = ["PySide6"]
PyQt = ["PyQt6"]

[project.urls]
repository = "https://github.com/matplotlib/viscm"
# documentation = "https://viscm.readthedocs.io"
Expand All @@ -46,7 +51,7 @@ package-data = {viscm = ["examples/*"]}


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

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


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

[tool.ruff]
target-version = "py38"
target-version = "py39"
select = [
"F",
"E",
Expand Down
10 changes: 7 additions & 3 deletions viscm/bezierbuilder/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
from viscm.bezierbuilder.curve import curve_method
from viscm.minimvc import Trigger

Qt = QtCore.Qt


class ControlPointModel:
def __init__(self, xp, yp, fixed=None):
Expand Down Expand Up @@ -104,12 +106,14 @@ def on_button_press(self, event):
if event.inaxes != self.ax:
return
res, ind = self.control_polygon.contains(event)
if res and modkey == QtCore.Qt.NoModifier:
if res and modkey == Qt.KeyboardModifier.NoModifier:
self._index = ind["ind"][0]
if res and (modkey == QtCore.Qt.ControlModifier or self.mode == "remove"):
if res and (
modkey == Qt.KeyboardModifier.ControlModifier or self.mode == "remove"
):
# Control-click deletes
self.control_point_model.remove_point(ind["ind"][0])
if modkey == QtCore.Qt.ShiftModifier or self.mode == "add":
if modkey == Qt.KeyboardModifier.ShiftModifier or self.mode == "add":
# Adding a new point. Find the two closest points and insert it in
# between them.
total_squared_dists = []
Expand Down
7 changes: 4 additions & 3 deletions viscm/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def cli():

signal.signal(signal.SIGINT, signal.SIG_DFL)

app.exec_()
app.exec()


def _make_window(
Expand Down Expand Up @@ -145,7 +145,7 @@ def _make_window(
v.figure.savefig(str(save))
elif action == "edit":
if not cm.can_edit:
sys.exit("Sorry, I don't know how to edit the specified colormap")
raise RuntimeError("Sorry, I don't know how to edit the specified colormap")

v = gui.viscm_editor(
figure=fig,
Expand All @@ -164,7 +164,8 @@ def _make_window(
sys.exit()

figure_canvas.setSizePolicy(
gui.QtWidgets.QSizePolicy.Expanding, gui.QtWidgets.QSizePolicy.Expanding
gui.QtWidgets.QSizePolicy.Policy.Expanding,
gui.QtWidgets.QSizePolicy.Policy.Expanding,
)
figure_canvas.updateGeometry()

Expand Down
Loading