Skip to content

Commit

Permalink
Removing redundant test summaries, cleanup de tests (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
euxhenh authored Aug 11, 2023
1 parent d65459e commit c95cbcc
Show file tree
Hide file tree
Showing 9 changed files with 191 additions and 453 deletions.
12 changes: 0 additions & 12 deletions src/grinch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@
from .aliases import ADK, OBS, OBSM, OBSP, UNS, VAR, VARM, VARP, AnnDataKeys
from .cond_filter import Filter, StackedFilter
from .conf import BaseConfigurable
from .de_test_summary import (
BimodalTestSummary,
DETestSummary,
KSTestSummary,
PvalTestSummary,
TestSummary,
)
from .filters import FilterCells, FilterGenes, VarianceFilter
from .main import instantiate_config
from .normalizers import Combat, Log1P, NormalizeTotal, Scale
Expand All @@ -42,17 +35,12 @@
'UNS',
'AnnDataKeys',
'BaseConfigurable',
'BimodalTestSummary',
'GRPipeline',
'FilterCells',
'FilterGenes',
'VarianceFilter',
'Report',
'Reporter',
'DETestSummary',
'TestSummary',
'PvalTestSummary',
'KSTestSummary',
'Filter',
'StackedFilter',
'Combat',
Expand Down
2 changes: 0 additions & 2 deletions src/grinch/aliases.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,4 @@ class VARP:
VARP = AnnDataKeys.VARP
UNS = AnnDataKeys.UNS

ALLOWED_KEYS = ['obs', 'obsm', 'uns', 'var', 'varm', 'layers', 'obsp', 'varp']

GROUP_SEP = '.'
42 changes: 3 additions & 39 deletions src/grinch/custom_types.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import inspect
from operator import attrgetter
from typing import Annotated, Any, Dict, List, Tuple, TypeAlias

import numpy as np
import numpy.typing as npt
import scipy.sparse as sp
from pydantic import Field

REP_KEY: TypeAlias = str | List[str] | Dict[str, str] | None
Expand All @@ -22,41 +21,6 @@
NP_int = npt.NDArray[np.int_]
NP_float = npt.NDArray[np.float_]

PercentFraction = Annotated[float, Field(ge=0, le=1)]


def optional_staticmethod(klas: str, special_args: Dict[str, str]):
"""Marks a method as optionally static. If the method is called from an
instance of the class, will assume it is not static and will parse any
self.keys specified in args. Otherwise will set each to None, and call
the method as a staticmethod. This is useful when static behavior is
desired if these optional arguments are not always needed.
NP_SP = np.ndarray | sp.spmatrix

This mainly exists because of group_label for group processing where
optionally we may need to pass group labels. Instead of modifying the
set_repr function call for evey derived class, we check if the method
was called from an instance of a class and pass group_label through
this decorator. This is nice because the derived classes can remain
ignorant of any group processing details.
Parameters
__________
klas: str
This should point to the class name of the object.
args: dict
Maps a key (member of klas) to a function parameter. These can have
multiple dots in the representation. E.g., 'foo.bar.eggs.spam' will
try to access self.foo.bar.eggs.spam
"""
def _decorator(f):
def _wrapper(*args, **kwargs):
bases = inspect.getmro(args[0].__class__)
base_qualnames = [base.__qualname__ for base in bases]
if len(args) > 0 and klas in base_qualnames:
# Assume that this was called from a class instance.
for k, v in special_args.items():
kwargs[v] = attrgetter(k)(args[0])
args = args[1:]
return f(*args, **kwargs)
return _wrapper
return _decorator
PercentFraction = Annotated[float, Field(ge=0, le=1)]
182 changes: 0 additions & 182 deletions src/grinch/de_test_summary.py

This file was deleted.

Loading

0 comments on commit c95cbcc

Please sign in to comment.