diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index 3fd774df2..fe6790d2d 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -13,7 +13,7 @@ jobs: - uses: actions/checkout@v4 - uses: mamba-org/setup-micromamba@v2.0.4 with: - environment-file: ./environment-dev.yml + environment-file: ./environment.yml - name: "Build docs" shell: bash -el {0} run: | diff --git a/.github/workflows/build-ultraplot.yml b/.github/workflows/build-ultraplot.yml index 56dccfcac..e082dd60c 100644 --- a/.github/workflows/build-ultraplot.yml +++ b/.github/workflows/build-ultraplot.yml @@ -15,7 +15,7 @@ jobs: - uses: actions/checkout@v4 - uses: mamba-org/setup-micromamba@v2.0.4 with: - environment-file: ./environment-dev.yml + environment-file: ./environment.yml init-shell: bash create-args: >- --verbose diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml deleted file mode 100644 index 5ba74fadc..000000000 --- a/.github/workflows/linter.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Linter check -on: - push: - branches: [main] - pull_request: - branches: [main] - -jobs: - linter: - runs-on: ubuntu-latest - timeout-minutes: 15 - steps: - - uses: actions/checkout@v4 - - uses: mamba-org/setup-micromamba@v2.0.4 - with: - environment-file: ./environment-dev.yml - init-shell: bash - create-args: --verbose - cache-environment: true - cache-downloads: false - - - name: "Apply linter" - shell: bash -el {0} - run: | - micromamba activate ultraplot-dev - pip install . - pip install black - black --check --diff ultraplot diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8a0eb377f..36dba903a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,39 +1,16 @@ -# See: https://pre-commit.com/hooks.html -# Must put flake8 in separate group so 'black' is executed first -# WARNING: Make sure to keep flags in sync with ci/run-linter.sh -repos: - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.1.0 - hooks: - - id: double-quote-string-fixer - - id: check-docstring-first - - id: check-merge-conflict - - id: end-of-file-fixer - - id: trailing-whitespace +ci: + autofix_commit_msg: | + [pre-commit.ci] auto fixes from pre-commit.com hooks - - repo: https://github.com/pre-commit/mirrors-isort - rev: v5.10.1 - hooks: - - id: isort - args: ['--line-width=88', '--multi-line=3', '--force-grid-wrap=0', '--trailing-comma'] - exclude: '(^docs|__init__)' + for more information, see https://pre-commit.ci + autofix_prs: false + autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate' + autoupdate_schedule: monthly + skip: [] + submodules: false - - repo: https://github.com/PyCQA/flake8 - rev: 4.0.1 +repos: + - repo: https://github.com/psf/black-pre-commit-mirror + rev: 24.8.0 hooks: - - id: flake8 - args: ['--max-line-length=88', '--ignore=W503,E402,E731,E741'] - - # apply once this handles long tables better - # - repo: https://github.com/PyCQA/doc8 - # rev: 0.10.1 - # hooks: - # - id: doc8 - # args: ['--max-line-length', '88', '--allow-long-titles'] - - # apply after function keyword args can be ignored - # - repo: https://github.com/ambv/black - # rev: 22.1.0 - # hooks: - # - id: black - # args: ['--line-length', '88', '--skip-string-normalization'] + - id: black diff --git a/.readthedocs.yml b/.readthedocs.yml index 385709145..9aec82860 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -18,7 +18,7 @@ build: conda: - environment: ./environment-dev.yml + environment: ./environment.yml sphinx: configuration: ./docs/conf.py diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 1a9f3475b..000000000 --- a/.travis.yml +++ /dev/null @@ -1,42 +0,0 @@ -# Travis Continuos Integration -# Currently only tests notebook files -# Based on https://conda.pydata.org/docs/travis.html -sudo: false # use container based build -language: python -dist: focal -notifications: - email: false - -python: - - "3.7" - -before_install: - - | - MODIFIED_FILES=$(git diff --name-only "$TRAVIS_COMMIT_RANGE" 2>/dev/null) - if [ $? -eq 0 ] && ! echo "$MODIFIED_FILES" | grep -qvE '(.md)|(.rst)|(.html)|(.png)|(.ico)' - then - echo "Only doc files were updated, not running the CI." - exit - fi - - wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh - - bash miniconda.sh -b -p $HOME/miniconda - - export PATH="$HOME/miniconda/bin:$PATH" - - hash -r - - conda config --set always_yes yes --set changeps1 no --set show_channel_urls true - - conda update -q conda - - conda info -a - -install: - - conda env create --file ci/environment.yml - - source activate ultra-dev - - conda list - - which conda - - which python - - python setup.py sdist bdist_wheel - - pip install --user ./dist/*.whl - -script: - - ci/run-linter.sh - - pushd docs - - make html - - popd diff --git a/README.rst b/README.rst index dc6b79c7e..4d6612ea2 100644 --- a/README.rst +++ b/README.rst @@ -1,7 +1,7 @@ .. image:: UltraPlotLogo.svg :width: 100% -|build-status| |docs| |pypi| |code-style| |pr-welcome| |license| +|build-status| |docs| |pypi| |code-style| |pre-commit| |pr-welcome| |license| A succinct `matplotlib `__ wrapper for making beautiful, publication-quality graphics. It builds upon ProPlot_ and transports it into the modern age (supporting mpl 3.9.0+). @@ -63,3 +63,7 @@ inside the ``ultraplot`` folder. .. |license| image:: https://img.shields.io/github/license/ultraplot/ultraplot.svg :alt: license :target: LICENSE.txt + +.. |pre-commit| image:: https://results.pre-commit.ci/badge/github/Ultraplot/ultraplot/main.svg + :target: https://results.pre-commit.ci/latest/github/Ultraplot/ultraplot/main + :alt: pre-commit.ci status diff --git a/environment-dev.yml b/environment-dev.yml deleted file mode 100644 index 336ba4aa0..000000000 --- a/environment-dev.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: ultraplot-dev -channels: - - conda-forge -dependencies: - - python>=3.10,<3.13 - - numpy - - matplotlib>=3.9 - - cartopy - - xarray - - seaborn - - pandas - - pytest - - pytest-mpl - - jupyter - - pip - - pint - - sphinx - - nbsphinx - - jupytext - - sphinx-copybutton - - sphinx-autoapi - - sphinx-automodapi - - sphinx-rtd-theme - - basemap >=1.4.1 - - pip: - - git+https://github.com/ultraplot/UltraTheme.git diff --git a/environment.yml b/environment.yml index 6485e16a1..3fe4a8c28 100644 --- a/environment.yml +++ b/environment.yml @@ -1,11 +1,27 @@ -name: ultraplot +name: ultraplot-dev channels: - conda-forge - - nodefaults dependencies: - - python>=3.9,<3.13 + - python>=3.10,<3.13 + - numpy + - matplotlib>=3.9 + - cartopy + - xarray + - seaborn + - pandas - pytest - pytest-mpl - - numpy>=1.20.0 - - matplotlib>=3.9 + - jupyter - pip + - pint + - sphinx + - nbsphinx + - jupytext + - sphinx-copybutton + - sphinx-autoapi + - sphinx-automodapi + - sphinx-rtd-theme + - basemap >=1.4.1 + - pre-commit + - pip: + - git+https://github.com/ultraplot/UltraTheme.git diff --git a/ci/PermanentMarker-Regular.ttf b/logo/PermanentMarker-Regular.ttf similarity index 100% rename from ci/PermanentMarker-Regular.ttf rename to logo/PermanentMarker-Regular.ttf diff --git a/ci/environment.yml b/logo/environment-logo.yml similarity index 100% rename from ci/environment.yml rename to logo/environment-logo.yml diff --git a/ci/logo.py b/logo/logo.py similarity index 55% rename from ci/logo.py rename to logo/logo.py index e9f791b19..019d4074f 100644 --- a/ci/logo.py +++ b/logo/logo.py @@ -2,39 +2,47 @@ import ultraplot as plt, numpy as np from matplotlib.font_manager import FontProperties -from matplotlib import patheffects as pe +from matplotlib import patheffects as pe from matplotlib.patches import Rectangle from scipy.ndimage import gaussian_filter -font = FontProperties(fname='./PermanentMarker-Regular.ttf') +font = FontProperties(fname="./PermanentMarker-Regular.ttf") fs = 38 left = 0.575 sw = 3 -fig, ax = plt.subplots(figsize = (3, 1.25)) -ax.text(left, 0.5, "Ultra", - fontsize = fs, - fontproperties = font, - va = "center", - ha = "right", - color = "steelblue", - path_effects = [ - pe.Stroke(linewidth = sw, foreground = "white"), +fig, ax = plt.subplots(figsize=(3, 1.25)) +ax.text( + left, + 0.5, + "Ultra", + fontsize=fs, + fontproperties=font, + va="center", + ha="right", + color="steelblue", + path_effects=[ + pe.Stroke(linewidth=sw, foreground="white"), pe.Normal(), ], - transform = ax.transAxes) -ax.text(left, 0.5, "Plot", - fontsize = fs, + transform=ax.transAxes, +) +ax.text( + left, + 0.5, + "Plot", + fontsize=fs, # fontproperties = font, - va = "center", - ha = "left", - color = "white", - path_effects = [ - pe.Stroke(linewidth = sw, foreground = "steelblue"), - pe.Normal(), + va="center", + ha="left", + color="white", + path_effects=[ + pe.Stroke(linewidth=sw, foreground="steelblue"), + pe.Normal(), ], - transform = ax.transAxes) + transform=ax.transAxes, +) shift = 0.033 import colorengine as ce @@ -44,9 +52,7 @@ colors = ce.vivid(colors) for idx, color in enumerate(colors): s = idx * shift - ax.axhline(0.275 - 2.3 * s, 0.59 + s, 0.9 - s, color = color, - ls = '-', - lw = 3) + ax.axhline(0.275 - 2.3 * s, 0.59 + s, 0.9 - s, color=color, ls="-", lw=3) ax.axis(False) # fig.set_facecolor("lightgray") @@ -60,15 +66,16 @@ square_size_y = 0.1 # Base square size in y direction square_size_x = square_size_y / fig_aspect # Adjust x size to maintain square shape -n_squares_x = int(1.0 / square_size_x) + 1 # Calculate number of squares needed in x direction +n_squares_x = ( + int(1.0 / square_size_x) + 1 +) # Calculate number of squares needed in x direction # Create alpha mask with Gaussian fade -x = np.linspace(-2, 2, n_squares_x -) +x = np.linspace(-2, 2, n_squares_x) y = np.linspace(-2, 2, n_squares_y) X, Y = np.meshgrid(x, y) R = np.sqrt(X**2 + Y**2) -alpha = np.exp(-R**2/0.75) # Adjust the 1.0 to control fade rate +alpha = np.exp(-(R**2) / 0.75) # Adjust the 1.0 to control fade rate alpha = gaussian_filter(alpha, sigma=0.5) # Adjust sigma for smoothness # Create colormap gradient @@ -77,29 +84,29 @@ for i in range(n_squares_x): for j in range(n_squares_y): if (i + j) % 2 == 0: # Checkerboard pattern - color = cmap(i/n_squares_x) # Color varies along x-axis + color = cmap(i / n_squares_x) # Color varies along x-axis rect = Rectangle( - (i*square_size_x - 0.3, j*square_size_y + 0.075), - square_size_x, square_size_y, + (i * square_size_x - 0.3, j * square_size_y + 0.075), + square_size_x, + square_size_y, facecolor=color, alpha=alpha[j, i], - transform=ax.transAxes + transform=ax.transAxes, ) ax.add_patch(rect) - fig.savefig( "UltraPlotLogo.svg", - transparent = True, - bbox_inches = "tight", - ) + transparent=True, + bbox_inches="tight", +) fig.savefig( "UltraPlotLogo.png", - transparent = True, - bbox_inches = "tight", - ) + transparent=True, + bbox_inches="tight", +) fig.show() @@ -107,39 +114,47 @@ import ultraplot as plt, numpy as np from matplotlib.font_manager import FontProperties -from matplotlib import patheffects as pe +from matplotlib import patheffects as pe from matplotlib.patches import Rectangle from scipy.ndimage import gaussian_filter -font = FontProperties(fname='./PermanentMarker-Regular.ttf') +font = FontProperties(fname="./PermanentMarker-Regular.ttf") fs = 38 left = 0.5 sw = 3 -fig, ax = plt.subplots(figsize = (2, 2)) -ax.text(left, 0.52, "Ultra", - fontsize = fs, - fontproperties = font, - va = "bottom", - ha = "center", - color = "steelblue", - path_effects = [ - pe.Stroke(linewidth = sw, foreground = "white"), +fig, ax = plt.subplots(figsize=(2, 2)) +ax.text( + left, + 0.52, + "Ultra", + fontsize=fs, + fontproperties=font, + va="bottom", + ha="center", + color="steelblue", + path_effects=[ + pe.Stroke(linewidth=sw, foreground="white"), pe.Normal(), ], - transform = ax.transAxes) -ax.text(left, 0.48, "Plot", - fontsize = fs, + transform=ax.transAxes, +) +ax.text( + left, + 0.48, + "Plot", + fontsize=fs, # fontproperties = font, - va = "top", - ha = "center", - color = "white", - path_effects = [ - pe.Stroke(linewidth = sw, foreground = "steelblue"), - pe.Normal(), + va="top", + ha="center", + color="white", + path_effects=[ + pe.Stroke(linewidth=sw, foreground="steelblue"), + pe.Normal(), ], - transform = ax.transAxes) + transform=ax.transAxes, +) shift = 0.033 import colorengine as ce @@ -160,15 +175,16 @@ square_size_y = 0.1 # Base square size in y direction square_size_x = square_size_y / fig_aspect # Adjust x size to maintain square shape -n_squares_x = int(1.0 / square_size_x) + 1 # Calculate number of squares needed in x direction +n_squares_x = ( + int(1.0 / square_size_x) + 1 +) # Calculate number of squares needed in x direction # Create alpha mask with Gaussian fade -x = np.linspace(-2, 2, n_squares_x -) +x = np.linspace(-2, 2, n_squares_x) y = np.linspace(-2, 2, n_squares_y) X, Y = np.meshgrid(x, y) R = np.sqrt(X**2 + Y**2) -alpha = np.exp(-R**2/0.75) # Adjust the 1.0 to control fade rate +alpha = np.exp(-(R**2) / 0.75) # Adjust the 1.0 to control fade rate alpha = gaussian_filter(alpha, sigma=0.5) # Adjust sigma for smoothness # Create colormap gradient @@ -177,21 +193,21 @@ for i in range(n_squares_x): for j in range(n_squares_y): if (i + j) % 2 == 0: # Checkerboard pattern - color = cmap(i/n_squares_x) # Color varies along x-axis + color = cmap(i / n_squares_x) # Color varies along x-axis rect = Rectangle( - (i*square_size_x, j*square_size_y + 0.075), - square_size_x, square_size_y, + (i * square_size_x, j * square_size_y + 0.075), + square_size_x, + square_size_y, facecolor=color, alpha=alpha[j, i], - transform=ax.transAxes + transform=ax.transAxes, ) ax.add_patch(rect) - fig.savefig( "UltraPlotLogoSquare.png", - transparent = True, - bbox_inches = "tight", - ) + transparent=True, + bbox_inches="tight", +) fig.show() diff --git a/ci/run-linter.sh b/logo/run-linter.sh similarity index 100% rename from ci/run-linter.sh rename to logo/run-linter.sh diff --git a/ci/whyUltraPlot.svg b/logo/whyUltraPlot.svg similarity index 100% rename from ci/whyUltraPlot.svg rename to logo/whyUltraPlot.svg diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index b20c5e8c7..000000000 --- a/requirements.txt +++ /dev/null @@ -1,4 +0,0 @@ -pytest -pytest-mpl -numpy -matplotlib>=3.9.3