Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add matplotlib as a requirement #80

Merged
merged 1 commit into from
Sep 2, 2024
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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ $ conda install -c conda-forge inequality
#### Requirements

- libpysal
- matplotlib
- numpy
- scipy

Expand Down
7 changes: 4 additions & 3 deletions ci/310-oldest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 4 additions & 3 deletions ci/311-latest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 5 additions & 2 deletions ci/312-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions ci/312-latest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 7 additions & 13 deletions inequality/pen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"):
Expand All @@ -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
Expand All @@ -43,22 +45,14 @@ 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:
msg = f"{caller} requires pandas. "
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(
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 1 addition & 4 deletions inequality/tests/test_pengram.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ classifiers = [
requires-python = ">=3.10"
dependencies = [
"libpysal>=4.5",
"matplotlib>=3.6",
"numpy>=1.23",
"scipy>=1.8",
]
Expand Down