Skip to content
Open
Show file tree
Hide file tree
Changes from 4 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
52 changes: 0 additions & 52 deletions .circleci/config.yml

This file was deleted.

30 changes: 30 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: CI

on:
push:
branches: [master]
pull_request:

jobs:
test:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
Comment thread
coderabbitai[bot] marked this conversation as resolved.
with:
persist-credentials: false

- uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Install dependencies
run: |
pip install -e .[test]

- name: Run tests
run: pytest

- name: Smoke test
run: python complex_colormap/cplot.py
Comment thread
coderabbitai[bot] marked this conversation as resolved.
20 changes: 11 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
VERSION=$(shell python3 -c "import complex_colormap; print(complex_colormap.__version__)")

.PHONY: default tag upload publish clean test

default:
@echo "\"make publish\"?"

README.rst: README.md
cat README.md | sed -e 's_<img src="\([^"]*\)" width="\([^"]*\)">_![](\1){width="\2"}_g' -e 's_<p[^>]*>__g' -e 's_</p>__g' > /tmp/README.md
pandoc /tmp/README.md -o README.rst
python3 setup.py check -r -s || exit 1

tag:
# Make sure we're on the master branch
@if [ "$(shell git rev-parse --abbrev-ref HEAD)" != "master" ]; then exit 1; fi
@echo "Tagging v$(VERSION)..."
git tag v$(VERSION)
git push --tags

upload: setup.py README.rst
upload: tag
@if [ "$(shell git rev-parse --abbrev-ref HEAD)" != "master" ]; then exit 1; fi
rm -f dist/*
python3 setup.py bdist_wheel --universal
python3 -m pip install build
rm -rf dist
python3 -m build
Comment thread
coderabbitai[bot] marked this conversation as resolved.
gpg --detach-sign -a dist/*
twine upload dist/*

publish: tag upload

test:
python3 -m pip install -e .[test]
pytest

clean:
rm -f README.rst
rm -rf dist build *.egg-info
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Binary file added complex_colormap/C_lut.npy
Binary file not shown.
3 changes: 0 additions & 3 deletions complex_colormap/__about__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# -*- coding: utf-8 -*-
#
__version__ = '0.0.1'
__author_email__ = 'endolith@gmail.com'
__website__ = 'https://github.com/endolith/complex_colormap'
__license__ = 'License :: OSI Approved :: MIT License'
__status__ = 'Development Status :: 2 - Pre-Alpha'
46 changes: 46 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "complex_colormap"
dynamic = ["version"]
description = "Color maps for complex-valued functions"
readme = "README.md"
requires-python = ">=3.9"
license = "MIT"
authors = [
{ name = "endolith", email = "endolith@gmail.com" },
]
keywords = ["colormap", "matplotlib", "complex", "plotting"]
classifiers = [
"Development Status :: 2 - Pre-Alpha",
"Intended Audience :: Science/Research",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Mathematics",
"Topic :: Scientific/Engineering :: Physics",
]
dependencies = [
"colorspacious",
"matplotlib",
"numpy",
"scipy",
]

[project.optional-dependencies]
test = [
"pytest",
]

[project.urls]
Homepage = "https://github.com/endolith/complex_colormap"
Download = "https://github.com/endolith/complex_colormap/releases"

[tool.hatch.version]
path = "complex_colormap/__about__.py"

[tool.hatch.build.targets.wheel]
packages = ["complex_colormap"]
artifacts = ["complex_colormap/C_lut.npy"]
4 changes: 0 additions & 4 deletions requirements.txt

This file was deleted.

57 changes: 0 additions & 57 deletions setup.py

This file was deleted.

32 changes: 32 additions & 0 deletions tests/test_cplot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import numpy as np
import pytest

from complex_colormap.cplot import const_chroma_colormap, max_chroma_colormap


@pytest.mark.parametrize("func,expected", [
(const_chroma_colormap,
[[1.0, 1.0, 1.0],
[0.0, 0.0, 0.0],
[0.824, 0.706, 0.314],
[0.502, 0.502, 0.502]]),
(max_chroma_colormap,
[[1.0, 1.0, 1.0],
[0.051, 0.0, 0.001],
[0.863, 0.694, 0.0],
[0.502, 0.502, 0.502]]),
])
def test_colormap_docstring_examples(func, expected):
z = np.array([[np.inf, 0, 10j, np.nan]])
result = func(z)
np.testing.assert_allclose(result[0], expected, atol=1e-3)


@pytest.mark.parametrize("func", [const_chroma_colormap, max_chroma_colormap])
def test_colormap_shape_and_bounds(func):
z = np.random.randn(10, 12) + 1j * np.random.randn(10, 12)
result = func(z)
assert result.shape == (10, 12, 3)
assert result.min() >= 0.0
assert result.max() <= 1.0

Loading