Skip to content

Commit

Permalink
add pooch not as optional dep
Browse files Browse the repository at this point in the history
  • Loading branch information
SarthakJariwala committed Oct 25, 2020
1 parent 095574c commit eaf0ee3
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 29 deletions.
2 changes: 0 additions & 2 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,4 @@ python:
version: 3.7
install:
- requirements: docs/requirements.txt
- method: pip
- path: .
- extra_requirements: docs
1 change: 0 additions & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ def tests(session):
"""Run the test suite."""
args = session.posargs or ["--cov", "-m", "not e2e"]
session.run("poetry", "install", external=True)
session.install("pooch")
install_with_constraints(session, "coverage[toml]", "pytest", "pytest-cov")
session.run("pytest", *args)

Expand Down
4 changes: 2 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ matplotlib-scalebar = "^0.6.2"
palettable = "^3.3.0"
scipy = "^1.5.1"
importlib_metadata = {version = "^1.7.0", python = "<3.8"}
pooch = {version = "^1.2.0", optional = true}

[tool.poetry.extras]
pooch = ["pooch"]
pooch = "^1.2.0"

[tool.poetry.dev-dependencies]
pytest = "^6.1.1"
Expand Down
26 changes: 6 additions & 20 deletions src/seaborn_image/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,10 @@

import matplotlib.pyplot as plt
import numpy as np
import pooch
from matplotlib import ticker
from skimage import io

try:
import pooch

HAS_POOCH = True
except ImportError: # pragma: no cover
HAS_POOCH = False

__all__ = ["scientific_ticks", "despine", "load_image"]


Expand Down Expand Up @@ -246,19 +240,11 @@ def load_image(name):
img = np.loadtxt(path)

elif name == "cells":
if HAS_POOCH:
fname = pooch.retrieve(
url="https://github.com/scikit-image/skimage-tutorials/raw/master/images/cells.tif",
known_hash="2120cfe08e0396324793a10a905c9bbcb64b117215eb63b2c24b643e1600c8c9",
)
img = io.imread(fname).T

elif HAS_POOCH is False: # pragma: no cover
raise ModuleNotFoundError(
"The requested file is part of the scikit-image distribution, "
"but requires the installation of an optional dependency, pooch. "
"Run - `pip install pooch`"
)
fname = pooch.retrieve(
url="https://github.com/scikit-image/skimage-tutorials/raw/master/images/cells.tif",
known_hash="2120cfe08e0396324793a10a905c9bbcb64b117215eb63b2c24b643e1600c8c9",
)
img = io.imread(fname).T

else:
raise ValueError(f"No '{name}' image dataset")
Expand Down

0 comments on commit eaf0ee3

Please sign in to comment.