Skip to content

Commit

Permalink
REL: release 1.7.0 (#95)
Browse files Browse the repository at this point in the history
* MNT: migrate setup.py -> setup.cfg
* MNT: migrate setup.cfg -> pyproject.toml
* MNT: drop setup.py
* MNT: add dev comment
* MNT: drop support for EOL Python versions 3.6 and 3.7
* MNT: fixup codespell check
* MNT: enable dependabot
* MNT: migrate linting and formatting to pre-commit + ruff
* STY: autofixes (ruff)
* MNT: add .git-blame-ignore-revs
* MNT: upgrade GHA
* MNT: temporarily deactivate cross-plateform CI
* MNT: exclude new dev-only files in MANIFEST.in
* TST: add color to pytest output in CI
* TST: fix utility tests
* STY: manually fix remaining ruff violations
* STY: fix EOF
* STY: apply ruff-format
* STY: fix trailing whitespaces
* MNT: fix bandit pre-commit hook
* MNT: prettify yaml files
* MNT: fixup codespell pre-commit hook
* MNT: temporarily disable safety check
* DEP: bump minimal requirements on matplotlib 3.5 and numpy 1.17.3
* API: remove deprecated colormap alias (heat -> torch)
* DEP: drop dependency on e13tools (broken on Python 3.12)
* MNT: fix deprecation warnings from matplotlib
* DEP: test against matplotlib/viscm instead of fork
* BUG: fix a future warning from numpy (avoid iterating over scalar array)
* TST: treat warnings as errors
* MNT: drop support for Python 3.8
* STY: upgrade to Python 3.9 syntax
* TST: add explicit support for Python 3.10 to 3.12
* TST: drop support for Windows x86 (32 bits arch)
* TST: re-enable tests on Windows and MacOS
* MNT: cleanup unused requirement
* MNT: bump minimal requirement for numpy
* BUG: fix compatibility with matplotlib 3.5
* ENH: delay expensive imports
* TST: filter a deprecation warning that we do not control
* TST: test against minimal env
* MNT: stop linting with flake8 (ruff is already doing the job)
* TST: simplify pytest runs
* TST: separate publication-related tasks from normal tests
* REL: prepare release 1.7.0
  • Loading branch information
neutrinoceros authored Dec 17, 2023
1 parent 1e76ef9 commit c19cfde
Show file tree
Hide file tree
Showing 180 changed files with 21,911 additions and 21,399 deletions.
26 changes: 13 additions & 13 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
codecov:
notify:
require_ci_to_pass: yes
notify:
require_ci_to_pass: yes

coverage:
round: nearest
precision: 2
status:
project:
default:
target: 99%
patch:
default:
target: 95%
changes: yes
round: nearest
precision: 2
status:
project:
default:
target: 99%
patch:
default:
target: 95%
changes: yes

comment:
require_changes: yes
require_changes: yes
14 changes: 14 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# ruff auto fixing lints
a010823543c72d4a92ed9994d690366ca5e02018

# ruff-format
1a885e2c1cc0c7808c0fc589a49465a61f31f2f0

# EOF autofix
a71a91b1c588d84bf1ab4cb3003a987b3c253f05

# trailing whitespace autofix
bd2ceff52a3a310e7bb31faaa85f75b24ef60a36

# prettify yaml files
9cbafca68712562e3e03b4023b11942cb6858050
16 changes: 16 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: pip
directory: /
target-branch: develop
schedule:
interval: monthly

- package-ecosystem: github-actions
directory: /.github/workflows
target-branch: develop
schedule:
interval: monthly
23 changes: 8 additions & 15 deletions .github/workflows/lint_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,11 @@ jobs:
lint_python:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- run: pip install bandit black codespell flake8 isort mypy pytest pyupgrade safety
- run: bandit --recursive --skip B101 . # B101 is assert statements
- run: black --check . || true
- run: codespell --ignore-words-list="mutch"
- run: flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
- run: flake8 . --count --exit-zero --max-complexity=10 --max-line-length=88 --show-source --statistics
- run: isort --check-only --profile black . || true
- run: pip install -r requirements.txt || true
- run: mypy --ignore-missing-imports . || true
- run: pytest . || true
- run: pytest --doctest-modules . || true
- run: shopt -s globstar && pyupgrade --py36-plus **/*.py || true
- run: safety check
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- run: pipx run pre-commit run --all-files
- run: pip install mypy pytest safety
- run: pip install -r requirements.txt || true
- run: mypy --ignore-missing-imports . || true
- run: shopt -s globstar
#- run: safety check
88 changes: 66 additions & 22 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,46 +7,90 @@ on: [push, pull_request]

jobs:
build:
name: ${{ matrix.os }} ${{ matrix.architecture }}, Python ${{ matrix.python-version }}
name: ${{ matrix.os }}, Python ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
architecture: [x86, x64]
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.6, 3.7, 3.8, 3.9]
exclude:
- os: ubuntu-latest
architecture: x86
- os: macos-latest
architecture: x86
os:
- ubuntu-latest
- macos-latest
- windows-latest
python-version:
- '3.9'
- '3.10'
- '3.11'
- '3.12'
include:
- os: ubuntu-20.04
python-version: '3.9'
fail-fast: false

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }} ${{ matrix.architecture }}
uses: actions/setup-python@v2
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.architecture }}
- name: Install dependencies
- if: ${{ matrix.os == 'ubuntu-20.04' }}
name: Install minimal env
run: |
python -m pip install --upgrade pip
python -m pip install tomli tomli_w
python scripts/pin_requirements.py
python -m pip uninstall --yes tomli tomli_w
python -m pip install -e . --only-binary ':all:'
python -m pip install pytest pytest-mpl pytest-cov
- if: ${{ matrix.os != 'ubuntu-20.04' }}
name: Install full test env
run: |
python -m pip install --upgrade pip setuptools wheel
pip install -r requirements_dev.txt
- name: Test deployment
run: |
check-manifest
python setup.py sdist bdist_wheel
twine check dist/*
- run: python -m pip freeze
- name: Test package
run: |
pytest
pytest --color=yes --mpl --cov --cov-config=pyproject.toml --cov-report=term-missing
- name: Upload coverage
run: |
curl -s https://codecov.io/bash | bash
check-manifest:
name: Check MANIFEST.in
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.x
- run: pipx run check-manifest

check-twine:
name: Test deployment
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.x
- run: |
pipx run build --sdist
pipx run twine check dist/*
publish:
name: Publish to PyPI
runs-on: ubuntu-latest
needs:
- build
- check-manifest
- check-twine
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Deploy package
if: ${{ success() && matrix.os == 'ubuntu-latest' && github.event_name == 'push' && github.ref == 'refs/heads/master' }}
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
twine upload --skip-existing dist/*
pipx twine upload
40 changes: 40 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
ci:
autofix_prs: false
autoupdate_schedule: quarterly

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: no-commit-to-branch
- id: debug-statements
- id: check-merge-conflict
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-toml

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.3
hooks:
- id: ruff-format
- id: ruff
args: [--fix]

- repo: https://github.com/codespell-project/codespell
rev: v2.2.4
hooks:
- id: codespell
args: [--ignore-words-list, 'mutch, ore']

- repo: https://github.com/PyCQA/bandit
rev: 1.7.6
hooks:
- id: bandit
# B101 is assert statements
args: [--recursive, --skip, B101, .]

- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.11.0
hooks:
- id: pretty-format-yaml
args: [--autofix, --indent, '2']
2 changes: 1 addition & 1 deletion CITATION
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ archivePrefix = {arXiv},
primaryClass = {eess.IV},
adsurl = {https://ui.adsabs.harvard.edu/abs/2020JOSS....5.2004V},
adsnote = {Provided by the SAO/NASA Astrophysics Data System}
}
}
5 changes: 3 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ recursive-include cmasher data/*
recursive-exclude cmasher/colormaps *
recursive-include cmasher/colormaps cm_*

exclude docs joss_paper .github
exclude docs joss_paper .git* scripts/*
recursive-exclude docs *
recursive-exclude joss_paper *
recursive-exclude .github *
exclude *.yml
exclude *.yml *.yaml

recursive-exclude * __pycache__
recursive-exclude * *.py[co]
5 changes: 3 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Let's get rid of all bad colormaps in the world together!
.. _issue: https://github.com/1313e/CMasher/issues
.. _online documentation: https://cmasher.readthedocs.io
.. _matplotlib: https://github.com/matplotlib/matplotlib
.. _viscm: https://github.com/1313e/viscm
.. _viscm: https://github.com/matplotlib/viscm

Colormap overview
-----------------
Expand Down Expand Up @@ -73,12 +73,13 @@ So, for example, if one were to use the *rainforest* colormap, this could be don
import cmasher as cmr
# Import packages for plotting
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
# Access rainforest colormap through CMasher or MPL
cmap = cmr.rainforest # CMasher
cmap = plt.get_cmap('cmr.rainforest') # MPL
cmap = mpl.colormaps['cmr.rainforest'] # MPL
# Generate some data to plot
x = np.random.rand(100)
Expand Down
10 changes: 3 additions & 7 deletions cmasher/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

"""
CMasher
=======
Expand All @@ -10,15 +8,13 @@

# %% IMPORTS AND DECLARATIONS
# CMasher imports
from . import app_usage, cm, utils
from .__version__ import __version__
from . import utils
from .utils import *
from . import cm
from .cm import *
from . import app_usage
from .utils import *

# All declaration
__all__ = ['app_usage', 'cm', 'utils']
__all__ = ["app_usage", "cm", "utils"]
__all__.extend(cm.__all__)
__all__.extend(utils.__all__)

Expand Down
4 changes: 1 addition & 3 deletions cmasher/__version__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

"""
CMasher Version
===============
Expand All @@ -10,4 +8,4 @@

# %% VERSIONS
# Default/Latest/Current version
__version__ = '1.6.3'
__version__ = "1.7.0" # keep in sync with pyproject.toml
28 changes: 28 additions & 0 deletions cmasher/_handlercolorpolycollection.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import numpy as np
from matplotlib.legend_handler import HandlerBase


# Define legend handler class for artists that use colormaps
class _HandlerColorPolyCollection(HandlerBase):
# Override create_artists to create an AxesImage resembling a colormap
def create_artists(
self, legend, artist, xdescent, ydescent, width, height, fontsize, trans
):
from matplotlib.image import AxesImage

# Obtain the Axes object of this legend
ax = legend.axes

# Obtain the colormap of the artist
cmap = artist.cmap

# Create an AxesImage to contain the colormap with proper dimensions
image = AxesImage(
ax, cmap=cmap, transform=trans, extent=[xdescent, width, ydescent, height]
)

# Set the data of the image
image.set_data(np.arange(cmap.N)[np.newaxis, ...])

# Return the AxesImage object
return [image]
Loading

0 comments on commit c19cfde

Please sign in to comment.