Skip to content

Commit e1608b0

Browse files
author
Arina Danilina
committed
some mypy fixes
1 parent e2b9c5b commit e1608b0

File tree

5 files changed

+27
-16
lines changed

5 files changed

+27
-16
lines changed

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ ignore = [
122122
"D107",
123123
# Missing docstring in magic method
124124
"D105",
125+
# Use `X | Y` for type annotations
126+
"UP007",
125127
]
126128
line-length = 120
127129
select = [

src/moscot/base/problems/_mixins.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def _annotation_mapping(
122122
forward: bool,
123123
source: K,
124124
target: K,
125-
key: str,
125+
key: str | None = None,
126126
other_adata: Optional[str] = None,
127127
scale_by_marginals: bool = True,
128128
cell_transition_kwargs: Mapping[str, Any] = types.MappingProxyType({}),
@@ -342,10 +342,10 @@ def _annotation_mapping(
342342
filter_key=key,
343343
filter_value=source,
344344
)
345-
out_len = self[(source, target)].solution.shape[1]
345+
out_len = self.solutions[(source, target)].shape[1]
346346
batch_size = batch_size if batch_size is not None else out_len
347347
for batch in range(0, out_len, batch_size):
348-
tm_batch = self.push(
348+
tm_batch : ArrayLike = self.push( # type: ignore[attr-defined]
349349
source=source,
350350
target=target,
351351
data=None,
@@ -366,10 +366,10 @@ def _annotation_mapping(
366366
filter_key=key,
367367
filter_value=target,
368368
)
369-
out_len = self[(source, target)].solution.shape[0]
369+
out_len = self.solutions[(source, target)].shape[0]
370370
batch_size = batch_size if batch_size is not None else out_len
371371
for batch in range(0, out_len, batch_size):
372-
tm_batch = self.pull(
372+
tm_batch : ArrayLike = self.pull( # type: ignore[attr-defined]
373373
source=source,
374374
target=target,
375375
data=None,

src/moscot/problems/cross_modality/_mixins.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ class CrossModalityTranslationMixinProtocol(AnalysisMixinProtocol[K, B]):
2525
def _cell_transition(self: AnalysisMixinProtocol[K, B], *args: Any, **kwargs: Any) -> pd.DataFrame:
2626
...
2727

28+
def _annotation_mapping(self: AnalysisMixinProtocol[K, B], *args: Any, **kwargs: Any) -> pd.DataFrame:
29+
...
2830

2931
class CrossModalityTranslationMixin(AnalysisMixin[K, B]):
3032
"""Cross modality translation analysis mixin class."""
@@ -184,13 +186,13 @@ def cell_transition( # type: ignore[misc]
184186
key_added=key_added,
185187
)
186188

187-
def annotation_mapping(
189+
def annotation_mapping( # type: ignore[misc]
188190
self: CrossModalityTranslationMixinProtocol[K, B],
189191
mapping_mode: Literal["sum", "max"],
190192
annotation_label: str,
191193
forward: bool,
192-
source: K = "src",
193-
target: K = "tgt",
194+
source: str = "src",
195+
target: str = "tgt",
194196
scale_by_marginals: bool = True,
195197
other_adata: Optional[str] = None,
196198
cell_transition_kwargs: Mapping[str, Any] = types.MappingProxyType({}),
@@ -202,7 +204,7 @@ def annotation_mapping(
202204
target=target,
203205
key=self.batch_key,
204206
forward=forward,
205-
other_adata=self.adata_tgt,
207+
other_adata=self.adata_tgt if other_adata is None else other_adata,
206208
scale_by_marginals=scale_by_marginals,
207209
cell_transition_kwargs=cell_transition_kwargs,
208210
)

src/moscot/problems/space/_mixins.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,8 @@ def cell_transition( # type: ignore[misc]
284284
key_added=key_added,
285285
)
286286

287-
def annotation_mapping(
288-
self: AnalysisMixinProtocol[K, B],
287+
def annotation_mapping( # type: ignore[misc]
288+
self: SpatialAlignmentMixinProtocol[K, B],
289289
mapping_mode: Literal["sum", "max"],
290290
annotation_label: str,
291291
forward: bool,
@@ -299,7 +299,7 @@ def annotation_mapping(
299299
annotation_label=annotation_label,
300300
source=source,
301301
target=target,
302-
key=self._batch_key,
302+
key=self.batch_key,
303303
forward=forward,
304304
scale_by_marginals=scale_by_marginals,
305305
cell_transition_kwargs=cell_transition_kwargs,
@@ -594,12 +594,12 @@ def cell_transition( # type: ignore[misc]
594594
key_added=key_added,
595595
)
596596

597-
def annotation_mapping(
598-
self: AnalysisMixinProtocol[K, B],
597+
def annotation_mapping( # type: ignore[misc]
598+
self: SpatialMappingMixinProtocol[K, B],
599599
mapping_mode: Literal["sum", "max"],
600600
annotation_label: str,
601-
source: str,
602-
target: str = "tgt",
601+
source: K,
602+
target: K | str = "tgt",
603603
forward: bool = False,
604604
scale_by_marginals: bool = True,
605605
cell_transition_kwargs: Mapping[str, Any] = types.MappingProxyType({}),

src/moscot/problems/time/_mixins.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ def _cell_transition(
6969
) -> pd.DataFrame:
7070
...
7171

72+
def _annotation_mapping(
73+
self: AnalysisMixinProtocol[K, B],
74+
*args: Any,
75+
**kwargs: Any,
76+
) -> pd.DataFrame:
77+
...
78+
7279
def _sample_from_tmap(
7380
self: TemporalMixinProtocol[K, B],
7481
source: K,

0 commit comments

Comments
 (0)