Skip to content

Commit 23960ce

Browse files
Merge pull request #83 from theislab/dev
Dev v0.6.5
2 parents 6252825 + 72d73fc commit 23960ce

File tree

12 files changed

+20
-27
lines changed

12 files changed

+20
-27
lines changed

batchglm/api/data.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
from batchglm.data import design_matrix
2-
from batchglm.data import constraint_matrix_from_dict, constraint_matrix_from_string, string_constraints_from_dict
2+
from batchglm.data import constraint_matrix_from_dict, constraint_matrix_from_string, string_constraints_from_dict, \
3+
constraint_system_from_star
34
from batchglm.data import view_coef_names, preview_coef_names

batchglm/api/typing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
from batchglm.models.base.estimator import EstimatorBaseTyping
2-
from batchglm.models.base.input import InputDataBaseTyping
2+
from batchglm.models.base.input import InputDataBase

batchglm/data.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
import dask
2-
import dask.array
31
import logging
42
import patsy
53
import pandas as pd
64
import numpy as np
7-
import scipy.sparse
8-
from typing import Union, Dict, Tuple, List
5+
from typing import Union, Tuple, List
96

107
try:
118
import anndata
@@ -23,7 +20,7 @@ def design_matrix(
2320
formula: Union[str, None] = None,
2421
as_categorical: Union[bool, list] = True,
2522
dmat: Union[pd.DataFrame, None] = None,
26-
return_type: str = "xarray",
23+
return_type: str = "patsy",
2724
) -> Union[patsy.design_info.DesignMatrix, pd.DataFrame]:
2825
"""
2926
Create a design matrix from some sample description.
@@ -142,7 +139,7 @@ def constraint_system_from_star(
142139
formula: Union[None, str] = None,
143140
as_categorical: Union[bool, list] = True,
144141
constraints: Union[None, List[str], Tuple[str], dict, np.ndarray] = None,
145-
return_type: str = "xarray",
142+
return_type: str = "patsy",
146143
) -> Tuple:
147144
"""
148145
Wrap different constraint matrix building formats with building of design matrix.

batchglm/models/base/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from .input import _InputDataBase, InputDataBaseTyping
1+
from .input import InputDataBase, InputDataBase
22
from .estimator import _EstimatorBase, EstimatorBaseTyping
33
from .model import _ModelBase
44
from .simulator import _SimulatorBase

batchglm/models/base/estimator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
except ImportError:
1010
anndata = None
1111

12-
from .input import _InputDataBase
12+
from .input import InputDataBase
1313
from .model import _ModelBase
1414

1515
logger = logging.getLogger(__name__)
@@ -29,7 +29,7 @@ class TrainingStrategy(Enum):
2929
def __init__(
3030
self,
3131
model: _ModelBase,
32-
input_data: _InputDataBase
32+
input_data: InputDataBase
3333
):
3434
self.model = model
3535
self.input_data = input_data

batchglm/models/base/input.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
logger = logging.getLogger(__name__)
1212

1313

14-
class _InputDataBase:
14+
class InputDataBase:
1515
"""
1616
Base class for all input data types.
1717
"""
@@ -45,7 +45,7 @@ def __init__(
4545
self.x = data
4646
elif isinstance(data, anndata.AnnData) or isinstance(data, anndata.Raw):
4747
self.x = data.X
48-
elif isinstance(data, _InputDataBase):
48+
elif isinstance(data, InputDataBase):
4949
self.x = data.x
5050
else:
5151
raise ValueError("type of data %s not recognized" % type(data))
@@ -90,8 +90,3 @@ def fetch_x_sparse(self, idx):
9090
data_idx = np.squeeze(data_idx, axis=0)
9191

9292
return data_idx, data_val, data_shape
93-
94-
class InputDataBaseTyping:
95-
"""
96-
Input data base class used for typing in other packages.
97-
"""

batchglm/models/base/simulator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
except ImportError:
99
anndata = None
1010

11-
from .input import _InputDataBase
11+
from .input import InputDataBase
1212
from .model import _ModelBase
1313

1414
logger = logging.getLogger(__name__)
@@ -26,7 +26,7 @@ class _SimulatorBase(metaclass=abc.ABCMeta):
2626
nobs: int
2727
nfeatures: int
2828

29-
input_data: _InputDataBase
29+
input_data: InputDataBase
3030
model: _ModelBase
3131

3232
def __init__(

batchglm/models/base_glm/external.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from batchglm.models.base import _EstimatorBase
2-
from batchglm.models.base import _InputDataBase
2+
from batchglm.models.base import InputDataBase
33
from batchglm.models.base import _ModelBase
44
from batchglm.models.base import _SimulatorBase
55

batchglm/models/base_glm/input.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
from typing import Union
1111

1212
from .utils import parse_constraints, parse_design
13-
from .external import _InputDataBase
13+
from .external import InputDataBase
1414

1515

16-
class InputDataGLM(_InputDataBase):
16+
class InputDataGLM(InputDataBase):
1717
"""
1818
Input data for Generalized Linear Models (GLMs).
1919
"""
@@ -76,7 +76,7 @@ def __init__(
7676
If this option is set, all provided data will be casted to this data type.
7777
:return: InputData object
7878
"""
79-
_InputDataBase.__init__(
79+
InputDataBase.__init__(
8080
self=self,
8181
data=data,
8282
observation_names=observation_names,

batchglm/train/tf/glm_beta/estimator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Estimator(TFEstimatorGLM, ProcessModel):
2020
def __init__(
2121
self,
2222
input_data: InputDataGLM,
23-
batch_size: int = 500,
23+
batch_size: int = 512,
2424
graph: tf.Graph = None,
2525
init_model: Model = None,
2626
init_a: Union[np.ndarray, str] = "AUTO",

0 commit comments

Comments
 (0)