Skip to content
Open
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
10 changes: 3 additions & 7 deletions colornamer/colornamer.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
from typing import List, Dict
from functools import lru_cache

try:
import importlib.resources as pkg_resources
except ImportError:
# Try backported to PY<37 `importlib_resources`.
import importlib_resources as pkg_resources
from importlib.resources import files
import numpy as np, json
from skimage.color import rgb2lab, deltaE_ciede2000

Expand All @@ -15,7 +11,7 @@

@lru_cache(maxsize=1)
def _get_color_data():
hierarchy_txt = pkg_resources.read_text("static", HIERARCHY_JSON_FILE)
hierarchy_txt = files("static").joinpath(HIERARCHY_JSON_FILE).read_text()
color_json = json.loads(hierarchy_txt)
rgb_values = np.array(
[
Expand Down Expand Up @@ -87,7 +83,7 @@ def get_color_json() -> Dict:
""" Just return the whole json from color_hierarchy.json; you can then use
it however you like. For example, pd.DataFrame(color_json) if a pandas
DataFrame is useful to you."""
hierarchy_txt = pkg_resources.read_text("static", HIERARCHY_JSON_FILE)
hierarchy_txt = files("static").joinpath(HIERARCHY_JSON_FILE).read_text()
color_json = json.loads(hierarchy_txt)
return color_json

4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
url="https://github.com/stitchfix/colornamer",
packages=find_packages(),
package_data={"static": ["color_hierarchy.json", "color_hierarchy.csv"],},
install_requires=["importlib_resources", "numpy", "scikit-image==0.19.1",],
python_requires=">=3.7",
install_requires=["numpy", "scikit-image>=0.22.0",],
python_requires=">=3.9",
author="Dan Tasse",
author_email="dan.tasse@stitchfix.com"
)