From 4f282c755b95361e1aba66427980a513cd6b6eb3 Mon Sep 17 00:00:00 2001 From: pwwang <1188067+pwwang@users.noreply.github.com> Date: Sat, 14 May 2022 15:43:47 -0700 Subject: [PATCH] 0.8.4 (#120) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ➖ Add optional deps to extras so they aren't installed by default * 🔖 0.8.4 * 👷 Update CI * 🎨 Giva better message when optional packages not installed --- .github/workflows/build.yml | 10 ++-------- datar/__init__.py | 2 +- datar/base/bessel.py | 3 ++- datar/base/funs.py | 9 ++++++++- datar/base/string.py | 8 +++++++- docs/CHANGELOG.md | 5 +++++ poetry.lock | 5 ++++- pyproject.toml | 5 ++++- 8 files changed, 33 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5c0734ee..e6c44e7b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -38,10 +38,7 @@ jobs: python -m pip install flake8 python -m pip install poetry poetry config virtualenvs.create false - poetry install -E pdtypes -v - pip install wcwidth - pip install scipy - pip install python-slugify + poetry install -E pdtypes -E scipy -E wcwidth -E slugify -v # reinstall pandas to specific version pip install -U $PANDAS env: @@ -94,10 +91,7 @@ jobs: python -m pip install flake8 python -m pip install poetry poetry config virtualenvs.create false - poetry install -E modin -E pdtypes -v - pip install wcwidth - pip install scipy - pip install python-slugify + poetry install -E modin -E pdtypes -E scipy -E wcwidth -E slugify -v # reinstall modin to specific version pip install -U $MODIN env: diff --git a/datar/__init__.py b/datar/__init__.py index 7bcc3afe..1af5bceb 100644 --- a/datar/__init__.py +++ b/datar/__init__.py @@ -13,7 +13,7 @@ ) __all__ = ("f", "get_versions") -__version__ = "0.8.3" +__version__ = "0.8.4" apply_init_callbacks() diff --git a/datar/base/bessel.py b/datar/base/bessel.py index c6964ce3..c4f5dd69 100644 --- a/datar/base/bessel.py +++ b/datar/base/bessel.py @@ -11,7 +11,8 @@ def _get_special_func_from_scipy(name): from scipy import special except ImportError as imperr: # pragma: no cover raise ValueError( - "Bessel functions require scipy to be installed." + "`bessel` family requires `scipy` package.\n" + "Try: pip install -U datar[scipy]" ) from imperr return getattr(special, name) diff --git a/datar/base/funs.py b/datar/base/funs.py index 602760ae..8291e27e 100644 --- a/datar/base/funs.py +++ b/datar/base/funs.py @@ -184,7 +184,14 @@ def make_names(names, unique=False): Returns: Converted names """ - from slugify import slugify + try: + from slugify import slugify + except ImportError as imerr: # pragma: no cover + raise ValueError( + "`make_names()` requires `python-slugify` package.\n" + "Try: pip install -U datar[slugify]" + ) from imerr + from . import as_character if is_scalar(names): diff --git a/datar/base/string.py b/datar/base/string.py index e19ff85d..1a493f11 100644 --- a/datar/base/string.py +++ b/datar/base/string.py @@ -354,7 +354,13 @@ def _nchar_scalar(x, retn, allow_na, keep_na, na_len): return np.nan if keep_na else na_len if retn == "width": - from wcwidth import wcswidth + try: + from wcwidth import wcswidth + except ImportError as imperr: # pragma: no cover + raise ValueError( + "`nchar(x, type='width')` requires `wcwidth` package.\n" + "Try: pip install -U datar[wcwidth]" + ) from imperr return wcswidth(x) if retn == "chars": diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 995b5c96..4f24d4e7 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.8.4 + +- ➖ Add optional deps to extras so they aren't installed by default +- 🎨 Giva better message when optional packages not installed + ## 0.8.3 - ⬆️ Upgrade pipda to v0.6 diff --git a/poetry.lock b/poetry.lock index ebc24c99..37df5afb 100644 --- a/poetry.lock +++ b/poetry.lock @@ -449,11 +449,14 @@ testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest- [extras] modin = ["modin"] pdtypes = ["pdtypes"] +scipy = ["scipy"] +slugify = ["python-slugify"] +wcwidth = ["wcwidth"] [metadata] lock-version = "1.1" python-versions = "^3.7.1" # required by modin 0.10.2 -content-hash = "305f1512d9a146cddce5682fcb28ad08e36d2b3bc68ea975ab7f1c6291639b06" +content-hash = "4a4b33843b8e67403da9264321b0abcc4c6fcee163f4f8a3f30703865849b9fc" [metadata.files] asttokens = [ diff --git a/pyproject.toml b/pyproject.toml index 51347f2a..0aa09938 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "datar" -version = "0.8.3" +version = "0.8.4" description = "Port of dplyr and other related R packages in python, using pipda." authors = ["pwwang "] readme = "README.md" @@ -28,6 +28,9 @@ modin = {version = "^0.10", optional = true} [tool.poetry.extras] pdtypes = ["pdtypes"] modin = ["modin"] +scipy = ["scipy"] +wcwidth = ["wcwidth"] +slugify = ["python-slugify"] [tool.poetry.dev-dependencies] pytest = "^7"