Skip to content

Commit

Permalink
fix #540
Browse files Browse the repository at this point in the history
Signed-off-by: zethson <lukas.heumos@posteo.net>
  • Loading branch information
Zethson committed Apr 7, 2021
1 parent 14e096e commit 93129d8
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ ignore = # module imported but unused -> required for Scanpys API
E731,
# allow I, O, l as variable names -> I is the identity matrix, i, j, k, l is reasonable indexing notation
E741
per-file-ignores =
per-file-ignores =
# F811 Redefinition of unused name from line, does not play nice with pytest fixtures
tests/test*.py: F811
anndata/tests/test*.py: F811
# F821 Undefined name, can't import AnnData or it'd be a circular import
anndata/compat/_overloaded_dict.py: F821
# E721 comparing types, but we specifically are checking that we aren't getting subtypes (views)
Expand Down
3 changes: 2 additions & 1 deletion anndata/_core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from pandas.api.types import is_bool_dtype
from scipy import sparse

import anndata
from .access import ElementRef
from ..logging import anndata_logger as logger
from ..compat import ZappyArray
Expand Down Expand Up @@ -44,7 +45,7 @@ class _ViewMixin(_SetItemMixin):
def __init__(
self,
*args,
view_args: Tuple["anndata.AnnData", str, Tuple[str, ...]] = None,
view_args: Tuple[anndata.AnnData, str, Tuple[str, ...]] = None,
**kwargs,
):
if view_args is not None:
Expand Down
2 changes: 1 addition & 1 deletion anndata/_io/read.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
except ImportError as e: # noqa: F841

def read_zarr(*_, **__):
raise e
raise e # noqa: F821 TODO: There might be a better way to go about this


def read_csv(
Expand Down
2 changes: 1 addition & 1 deletion anndata/_io/write.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
except ImportError as e: # noqa: F841 # TODO: Is there a better way?

def write_zarr(*_, **__):
raise e
raise e # noqa: F821 # TODO: Fix together with import Error handling


logger = get_logger(__name__)
Expand Down
4 changes: 2 additions & 2 deletions anndata/compat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import pandas as pd

from ._overloaded_dict import _overloaded_uns, OverloadedDict
from .._core.index import _subset
from .._core.index import _subset, Index1D

# try importing zarr, dask, and zappy
from packaging import version
Expand Down Expand Up @@ -194,7 +194,7 @@ def _find_sparse_matrices(d: Mapping, n: int, keys: tuple, paths: list):
return paths


def _slice_uns_sparse_matrices(uns: MutableMapping, oidx: "Index1d", orig_n_obs: int):
def _slice_uns_sparse_matrices(uns: MutableMapping, oidx: Index1D, orig_n_obs: int):
"""slice sparse spatrices of n_obs × n_obs in self.uns"""
if isinstance(oidx, slice) and len(range(*oidx.indices(orig_n_obs))) == orig_n_obs:
return uns # slice of entire dimension is a no-op
Expand Down
8 changes: 4 additions & 4 deletions anndata/tests/helpers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from functools import singledispatch, wraps
from string import ascii_letters
from typing import Tuple
from typing import Tuple, Collection, Type
from collections.abc import Mapping
import warnings

Expand Down Expand Up @@ -68,9 +68,9 @@ def gen_adata(
X_dtype=np.float32,
# obs_dtypes,
# var_dtypes,
obsm_types: "Collection[Type]" = (sparse.csr_matrix, np.ndarray, pd.DataFrame),
varm_types: "Collection[Type]" = (sparse.csr_matrix, np.ndarray, pd.DataFrame),
layers_types: "Collection[Type]" = (sparse.csr_matrix, np.ndarray, pd.DataFrame),
obsm_types: Collection[Type] = (sparse.csr_matrix, np.ndarray, pd.DataFrame),
varm_types: Collection[Type] = (sparse.csr_matrix, np.ndarray, pd.DataFrame),
layers_types: Collection[Type] = (sparse.csr_matrix, np.ndarray, pd.DataFrame),
) -> AnnData:
"""\
Helper function to generate a random AnnData for testing purposes.
Expand Down
3 changes: 2 additions & 1 deletion anndata/tests/test_concatenate.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from itertools import chain, product
from functools import partial
import warnings
from typing import List, Callable, Any

import numpy as np
from numpy import ma
Expand Down Expand Up @@ -796,7 +797,7 @@ def map_values(mapping, path, key, old_parent, new_parent, new_items):
return ret


def permute_nested_values(dicts: "List[dict]", gen_val: "Callable[[int], Any]"):
def permute_nested_values(dicts: List[dict], gen_val: Callable[[int], Any]):
"""
This function permutes the values of a nested mapping, for testing that out merge
method work regardless of the values types.
Expand Down

0 comments on commit 93129d8

Please sign in to comment.