Skip to content

Commit

Permalink
Merge pull request #118 from KrishnaswamyLab/dev
Browse files Browse the repository at this point in the history
v1.0.12.post1
  • Loading branch information
scottgigante committed Feb 10, 2021
2 parents c0a4845 + 085fc2f commit 1a4f5e2
Show file tree
Hide file tree
Showing 11 changed files with 61 additions and 51 deletions.
22 changes: 12 additions & 10 deletions .github/workflows/run_tests.yml
Expand Up @@ -34,12 +34,14 @@ jobs:

- name: Install tools
run: |
python -m pip install --upgrade "pip<=21.0"
pip install --use-deprecated=legacy-resolver -U wheel setuptools
pip install --use-deprecated=legacy-resolver -U black flake8
python -m pip install --upgrade pip
pip install -U wheel setuptools
pip install -U black flake8
- name: Lint with Black
run: |
black . --check --diff
- name: Lint with flake8
run: |
flake8 scprep
Expand Down Expand Up @@ -101,6 +103,13 @@ jobs:
restore-keys: |
${{ runner.os }}-renv-${{ steps.setup-r.outputs.installed-r-version }}-
- name: Install package & dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade wheel setuptools
pip install --upgrade .[test]
python -c "import scprep"
- name: Install R packages
run: |
if (!requireNamespace("renv", quietly = TRUE)) install.packages("renv")
Expand All @@ -109,13 +118,6 @@ jobs:
renv::install("bioc::slingshot")
shell: Rscript {0}

- name: Install package & dependencies
run: |
python -m pip install --upgrade "pip<=21.0"
pip install --use-deprecated=legacy-resolver -U wheel setuptools
pip install --use-deprecated=legacy-resolver -U .[test,r]
python -c "import scprep"
- name: Run tests
run: nose2 -vvv

Expand Down
16 changes: 2 additions & 14 deletions scprep/__init__.py
Expand Up @@ -15,18 +15,6 @@
import scprep.reduce
import scprep.run

import pandas as _pd
import packaging.version as _packaging_version
from . import _patch

if _packaging_version.parse(_pd.__version__) < _packaging_version.parse("2.0"):

def _fill_value(self):
# Used in reindex_indexer
try:
return self.values.dtype.fill_value
except AttributeError:
return self.values.dtype.na_value

from pandas.core.internals.blocks import ExtensionBlock as _ExtensionBlock

setattr(_ExtensionBlock, "fill_value", property(_fill_value))
_patch.patch_fill_value()
17 changes: 17 additions & 0 deletions scprep/_patch.py
@@ -0,0 +1,17 @@
import packaging.version
import pandas as pd


def patch_fill_value():
if packaging.version.parse(pd.__version__) < packaging.version.parse("2.0"):

def _fill_value(self):
# Used in reindex_indexer
try:
return self.values.dtype.fill_value
except AttributeError:
return self.values.dtype.na_value

from pandas.core.internals.blocks import ExtensionBlock

setattr(ExtensionBlock, "fill_value", property(_fill_value))
10 changes: 5 additions & 5 deletions scprep/plot/jitter.py
Expand Up @@ -195,12 +195,12 @@ def jitter(

# Plotting means
if plot_means:
plot_x_means = [
i for i in range(len(params.x_labels)) if np.any(params.x_coords == i)
]
ax.scatter(
np.arange(len(params.x_labels)),
[
np.nanmean(params.y[params.x_coords == i])
for i in range(len(params.x_labels))
],
plot_x_means,
[np.nanmean(params.y[params.x_coords == i]) for i in plot_x_means],
c=means_c,
edgecolors="black",
lw=1.5,
Expand Down
5 changes: 4 additions & 1 deletion scprep/plot/utils.py
Expand Up @@ -14,7 +14,10 @@ def _with_default(param, default):


def _mpl_is_gui_backend():
backend = mpl.get_backend()
try:
backend = mpl.get_backend()
except Exception:
return False
if backend in ["module://ipykernel.pylab.backend_inline", "agg"]:
return False
else:
Expand Down
2 changes: 1 addition & 1 deletion scprep/version.py
@@ -1,4 +1,4 @@
# author: Scott Gigante <scott.gigante@yale.edu>
# (C) 2018 Krishnaswamy Lab GPLv2

__version__ = "1.0.12"
__version__ = "1.0.13"
3 changes: 2 additions & 1 deletion setup.py
Expand Up @@ -8,6 +8,7 @@
"scikit-learn>=0.19.1",
"decorator>=4.3.0",
"pandas>=0.25",
"packaging",
]

optional_requires = [
Expand Down Expand Up @@ -41,7 +42,7 @@
doc_requires += ["autodocsumm!=0.2.0"]
else:
test_requires += ["matplotlib>=3.0", "rpy2>=3.0", "black"]
optional_requires += ["anndata2ri"]
optional_requires += ["anndata2ri>=1.0.6"]
doc_requires += ["autodocsumm"]

version_py = os.path.join(os.path.dirname(__file__), "scprep", "version.py")
Expand Down
Binary file removed test.png
Binary file not shown.
8 changes: 4 additions & 4 deletions test/_test_lazyload.py
Expand Up @@ -14,11 +14,11 @@ def test_lazyload():
for module in scprep._lazyload._importspec.keys():
if module == "anndata2ri" and sys.version_info[:2] < (3, 6):
continue
if module in preloaded_modules:
assert getattr(scprep._lazyload, module).__class__ is type(scprep)
assert module not in scprep_loaded, module
if module in postloaded_modules:
assert getattr(scprep._lazyload, module).__class__ is type(scprep), module
else:
assert (
getattr(scprep._lazyload, module).__class__
is scprep._lazyload.AliasModule
)
assert module not in scprep_loaded, module
), module
2 changes: 1 addition & 1 deletion test/test_hdf5.py
Expand Up @@ -68,7 +68,7 @@ def test_get_node_invalid():
def test_get_values_invalid():
utils.assert_raises_message(
TypeError,
"Expected h5py.Dataset or tables.CArray. " "Got <class 'str'>",
"Expected h5py.Dataset or tables.CArray. Got <class 'str'>",
scprep.io.hdf5.get_values,
"invalid",
)
27 changes: 13 additions & 14 deletions test/test_lazyload.py
@@ -1,4 +1,5 @@
import subprocess
import mock
import os
import scprep
import sys
Expand All @@ -23,18 +24,16 @@ def test_lazyload():


def test_builtins():
for module in scprep._lazyload._importspec.keys():
if module == "anndata2ri" and sys.version_info[:2] < (3, 6):
for module_name in scprep._lazyload._importspec.keys():
if module_name == "anndata2ri" and sys.version_info[:2] < (3, 6):
continue
try:
del sys.modules[module]
except KeyError:
pass
assert (
getattr(scprep._lazyload, module).__class__ is scprep._lazyload.AliasModule
)
try:
getattr(scprep._lazyload, module).__version__
except AttributeError:
pass
assert getattr(scprep._lazyload, module).__class__ is type(scprep)
with mock.patch.dict(sys.modules):
if module_name in sys.modules:
del sys.modules[module_name]
module = getattr(scprep._lazyload, module_name)
assert module.__class__ is scprep._lazyload.AliasModule, (
module_name,
module,
)
module.__package__
assert module.__class__ is type(scprep), (module_name, module)

0 comments on commit 1a4f5e2

Please sign in to comment.