Skip to content

Commit

Permalink
Made it work and test on 3.5 again
Browse files Browse the repository at this point in the history
  • Loading branch information
flying-sheep committed May 25, 2018
1 parent a489245 commit 555c15c
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: python
python:
#- "3.5" # loompy needs python 3.6
- "3.5"
- "3.6"
install:
- "pip install -r requires.txt"
Expand Down
8 changes: 4 additions & 4 deletions anndata/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def __repr__(self):
if self._filename is None:
return 'Backing file manager: no file is set.'
else:
return f'Backing file manager of file {self._filename}.'
return 'Backing file manager of file {}.'.format(self._filename)

def __getitem__(self, key):
return self._file[key]
Expand Down Expand Up @@ -523,9 +523,9 @@ def __init__(self, n_dims):


class AnnData(IndexMixin, metaclass=utils.DeprecationMixinMeta):
__doc__ = dedent(f"""An annotated data matrix.
__doc__ = dedent("""An annotated data matrix.
{indent(_MAIN_NARRATIVE, 4*' ')}
{}
Parameters
----------
Expand Down Expand Up @@ -583,7 +583,7 @@ class AnnData(IndexMixin, metaclass=utils.DeprecationMixinMeta):
.. _statsmodels: http://www.statsmodels.org/stable/index.html
.. _scikit-learn: http://scikit-learn.org/
""")
""").format(indent(_MAIN_NARRATIVE, 4*' '))

_BACKED_ATTRS = ['X', 'raw.X']

Expand Down
2 changes: 1 addition & 1 deletion anndata/h5py/h5sparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def __init__(
libver: Optional[str] = None,
userblock_size: Optional[int] = None,
swmr: bool = False,
**kwds,
**kwds # Python 3.5 can’t handle trailing commas here
):
self.h5f = h5py.File(
name,
Expand Down
4 changes: 2 additions & 2 deletions anndata/readwrite/write.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def write_csvs(dirname: Union[Path, str], adata: AnnData, skip_data: bool = True
filename = dirname
if key not in {'X', 'var', 'obs', 'obsm', 'varm'}:
filename = dir_uns
filename /= f'{key}.csv'
filename /= '{}.csv'.format(key)
df = value
if not isinstance(value, pd.DataFrame):
value = np.array(value)
Expand All @@ -54,7 +54,7 @@ def write_csvs(dirname: Union[Path, str], adata: AnnData, skip_data: bool = True
try:
df = pd.DataFrame(value)
except Exception as e:
warnings.warn(f'Omitting to write {key!r}.', type(e))
warnings.warn('Omitting to write {!r}.'.format(key), type(e))
continue
df.to_csv(
filename, sep=sep,
Expand Down
4 changes: 4 additions & 0 deletions anndata/tests/readwrite.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
from importlib.util import find_spec
from pathlib import Path

import numpy as np
import pandas as pd
import pytest
from scipy.sparse import csr_matrix
import anndata as ad


HERE = Path(__file__).parent


# -------------------------------------------------------------------------------
# Some test data
# -------------------------------------------------------------------------------
Expand Down Expand Up @@ -61,6 +64,7 @@ def test_readwrite_dynamic():
assert adata.obs['oanno1'].cat.categories.tolist() == ['cat1', 'cat2']


@pytest.mark.skipif(not find_spec('loompy'), reason='Loompy is not installed (expected on Python 3.5)')
def test_readwrite_loom():
for i, typ in enumerate([np.array, csr_matrix]):
X = typ(X_list)
Expand Down
4 changes: 2 additions & 2 deletions anndata/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ def decorator(func):
def new_func(*args, **kwargs):
warnings.simplefilter('always', DeprecationWarning) # turn off filter
warnings.warn(
f'Use {new_name} instead of {func.__name__}, '
f'{func.__name__} will be removed in the future.',
'Use {0} instead of {1}, {1} will be removed in the future.'
.format(new_name, func.__name__),
category=DeprecationWarning,
stacklevel=2,
)
Expand Down
2 changes: 1 addition & 1 deletion requires_tests.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
loompy>=2.0
loompy>=2.0; python_version>='3.6'

0 comments on commit 555c15c

Please sign in to comment.