From 52db923e7056ac68dabd469a5ebe86012b258115 Mon Sep 17 00:00:00 2001 From: James Gaboardi Date: Mon, 2 Sep 2024 12:53:55 -0400 Subject: [PATCH] add matplotlib as a requirement --- .pre-commit-config.yaml | 2 +- README.md | 1 + ci/310-oldest.yaml | 7 ++++--- ci/311-latest.yaml | 7 ++++--- ci/312-dev.yaml | 7 +++++-- ci/312-latest.yaml | 5 +++-- inequality/pen.py | 20 +++++++------------- inequality/tests/test_pengram.py | 5 +---- pyproject.toml | 1 + 9 files changed, 27 insertions(+), 28 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d16e920..2b53a9e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ files: "inequality\/" repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.6.1" + rev: "v0.6.3" hooks: - id: ruff - id: ruff-format diff --git a/README.md b/README.md index 995f5a0..e099d00 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ $ conda install -c conda-forge inequality #### Requirements - libpysal +- matplotlib - numpy - scipy diff --git a/ci/310-oldest.yaml b/ci/310-oldest.yaml index 5640784..5b9326c 100644 --- a/ci/310-oldest.yaml +++ b/ci/310-oldest.yaml @@ -5,13 +5,14 @@ dependencies: - python=3.10 # required - libpysal=4.5 + - matplotlib>=3.6 - numpy=1.23 - scipy=1.8 # testing - - seaborn - - mapclassify + - codecov - geopandas + - mapclassify - pytest - pytest-cov - pytest-xdist - - codecov + - seaborn diff --git a/ci/311-latest.yaml b/ci/311-latest.yaml index 2d1e14a..2fa397f 100644 --- a/ci/311-latest.yaml +++ b/ci/311-latest.yaml @@ -5,12 +5,13 @@ dependencies: - python=3.11 # required - libpysal + - matplotlib>=3.6 - numpy - scipy - - seaborn - - mapclassify # testing + - codecov + - mapclassify - pytest - pytest-cov - pytest-xdist - - codecov + - seaborn diff --git a/ci/312-dev.yaml b/ci/312-dev.yaml index c10f2b8..e909bc2 100644 --- a/ci/312-dev.yaml +++ b/ci/312-dev.yaml @@ -4,14 +4,17 @@ channels: dependencies: - python=3.12 # testing + - codecov - pytest - pytest-cov - pytest-xdist - - codecov - seaborn - pip: # dev versions of packages - - --pre --index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple --extra-index-url https://pypi.org/simple + - --pre \ + --index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple \ + --extra-index-url https://pypi.org/simple + - matplotlib - numpy - scipy - git+https://github.com/pysal/libpysal.git@main diff --git a/ci/312-latest.yaml b/ci/312-latest.yaml index 318f8e7..67f6cf5 100644 --- a/ci/312-latest.yaml +++ b/ci/312-latest.yaml @@ -5,15 +5,16 @@ dependencies: - python=3.12 # required - libpysal + - matplotlib - numpy - scipy # testing + - codecov + - mapclassify - pytest - pytest-cov - pytest-xdist - - codecov - seaborn - - mapclassify # docs - nbsphinx - numpydoc diff --git a/inequality/pen.py b/inequality/pen.py index 9c30f13..5ab5011 100644 --- a/inequality/pen.py +++ b/inequality/pen.py @@ -16,7 +16,10 @@ import math +import matplotlib.patches as patches +import matplotlib.pyplot as plt import numpy as np +from mpl_toolkits.axes_grid1.inset_locator import inset_axes def _check_deps(caller="pen"): @@ -26,8 +29,7 @@ def _check_deps(caller="pen"): Returns ------- tuple - A tuple containing the imported modules (Seaborn, mapclassify, - Matplotlib pyplot, Matplotlib patches). + A tuple containing the imported modules (Seaborn, mapclassify, pandas). """ try: import seaborn as sns @@ -43,14 +45,6 @@ def _check_deps(caller="pen"): msg = f"{msg} Install it using `conda install -c conda-forge mapclassify`" raise ImportError(msg) from e - try: - import matplotlib.patches as patches - import matplotlib.pyplot as plt - from mpl_toolkits.axes_grid1.inset_locator import inset_axes - except ImportError as e: - msg = f"{caller} requires matplotlib. " - msg = f"{msg} Install it using `conda install -c conda-forge matplotlib`" - raise ImportError(msg) from e try: import pandas as pd except ImportError as e: @@ -58,7 +52,7 @@ def _check_deps(caller="pen"): msg = f"{msg} Install it using `conda install -c conda-forge pandas`" raise ImportError(msg) from e - return sns, mc, plt, patches, inset_axes, pd + return sns, mc, pd def pen( @@ -111,7 +105,7 @@ def pen( """ - sns, mc, plt, patches, inset_axes, pd = _check_deps() + sns, mc, pd = _check_deps() if ax is None: fig, ax = plt.subplots(1, 1, figsize=figsize) @@ -260,7 +254,7 @@ def pengram( matplotlib.axes.Axes Matplotlib Axes objects for the combined choropleth and Pen's parade. """ - sns, mc, plt, patches, inset_axes, pd = _check_deps() + sns, mc, pd = _check_deps() if ax is None: fig, ax = plt.subplots(figsize=figsize) diff --git a/inequality/tests/test_pengram.py b/inequality/tests/test_pengram.py index db91332..0175d1f 100644 --- a/inequality/tests/test_pengram.py +++ b/inequality/tests/test_pengram.py @@ -43,12 +43,9 @@ def sample_gdf(): def test_check_deps(): """Test that _check_deps function imports all necessary dependencies.""" - sns, mc, plt, patches, inset_axes, pd = _check_deps() + sns, mc, pd = _check_deps() assert sns is not None assert mc is not None - assert plt is not None - assert patches is not None - assert inset_axes is not None assert pd is not None diff --git a/pyproject.toml b/pyproject.toml index 4a4aff7..64608cb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,6 +27,7 @@ classifiers = [ requires-python = ">=3.10" dependencies = [ "libpysal>=4.5", + "matplotlib>=3.6", "numpy>=1.23", "scipy>=1.8", ]