Skip to content

Commit 786aa82

Browse files
gegnewzbjornson
authored andcommitted
docs(): Satisfy mkdocs warnings
1 parent d9f221e commit 786aa82

File tree

6 files changed

+23
-43
lines changed

6 files changed

+23
-43
lines changed

cellengine/resources/attachment.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def from_dict(cls, data: dict):
6262
def to_dict(self):
6363
return converter.unstructure(self)
6464

65-
def download(self, to_file: str = None):
65+
def download(self, to_file: Optional[str] = None) -> Optional[bytes]:
6666
"""Download the attachment.
6767
6868
Defaults to returning the file as a blob. If ``to_file`` is specified,

cellengine/resources/compensation.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from __future__ import annotations
2-
from typing import List, Optional, TYPE_CHECKING, Tuple, cast
2+
from typing import List, Optional, TYPE_CHECKING, Tuple, Union, cast
33

44
from attr import define, field
55
from numpy import array, linalg
@@ -146,14 +146,16 @@ def dataframe_as_html(self):
146146
"""Return the compensation matrix dataframe as HTML."""
147147
return self.dataframe._repr_html_()
148148

149-
def apply(self, file: FcsFile, inplace: bool = True, **kwargs):
149+
def apply(
150+
self, file: FcsFile, inplace: bool = True, **kwargs
151+
) -> Union[DataFrame, None]:
150152
"""Compensate an FcsFile's data.
151153
152154
Args:
153155
file (FcsFile): The FcsFile to compensate.
154156
inplace (bool): If True, modify the `FcsFile.events` with the result.
155157
If False, return the compensated events.
156-
kwargs (Dict):
158+
**kwargs (Dict):
157159
All arguments accepted by `FcsFile.get_events` are accepted here.
158160
If the file's events have already been retrieved with the same
159161
kwargs provided here, those stored events will be used.

cellengine/resources/experiment.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from datetime import datetime
33

44
from marshmallow import fields
5+
from pandas.core.frame import DataFrame
56

67
from cellengine.utils.dataclass_mixin import DataClassMixin, ReadOnly
78
from dataclasses import dataclass, field
@@ -180,7 +181,7 @@ def update(self):
180181
res = ce.APIClient().update_experiment(self._id, self.to_dict())
181182
self.__dict__.update(Experiment.from_dict(res).__dict__)
182183

183-
def clone(self, props: Optional[Dict[str, Any]] = None):
184+
def clone(self, props: Optional[Dict[str, Any]] = None) -> Experiment:
184185
"""
185186
Saves a deep copy of the experiment and all of its resources, including
186187
attachments, FCS files, gates and populations.
@@ -331,7 +332,7 @@ def get_statistics(
331332
layout: str = None,
332333
percent_of: Union[str, List[str]] = None,
333334
population_ids: List[str] = None,
334-
):
335+
) -> Union[Dict, str, DataFrame]:
335336
"""
336337
Request Statistics from CellEngine.
337338
@@ -369,6 +370,7 @@ def get_statistics(
369370
those populations.
370371
population_ids: List[str]: List of population IDs.
371372
Defaults to ungated.
373+
372374
Returns:
373375
statistics: Dict, String, or pandas.Dataframe
374376
"""

cellengine/resources/fcs_file.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,12 +283,13 @@ def spill_string(self):
283283
return self._spill_string
284284

285285
def get_events(
286-
self, inplace: bool = False, destination=None, **kwargs
286+
self, inplace: bool = False, destination=None, **kwargs: Any
287287
) -> Union[DataFrame, None]:
288288
"""
289289
Fetch a DataFrame containing this file's data.
290290
291291
Args:
292+
inplace: bool
292293
**kwargs:
293294
- compensatedQ (bool): If true, applies the compensation
294295
specified in compensationId to the exported events.

cellengine/resources/gate.py

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -64,37 +64,6 @@ def bulk_create(cls, experiment_id, gates: List) -> List[Gate]:
6464

6565
@classmethod
6666
def factory(cls, gates: Dict) -> List["Gate"]:
67-
"""Build a Gate object from a dict of properties.
68-
69-
Args:
70-
experiment_id (str): The ID of the experiment to which to add the gate. Use
71-
when calling this as a static method; not needed when calling from an
72-
Experiment object.
73-
name (str): The name of the gate
74-
x_channel (str): The name of the x channel to which the gate applies.
75-
y_channel (str): The name of the y channel to which the gate applies.
76-
gid (str): Group ID of the gate, used for tailoring. If this is not
77-
specified, then a new Group ID will be created. If you wish you create
78-
a tailored gate, you must specify the gid of the global tailored gate.
79-
parent_population_id (str): ID of the parent population. Use ``None`` for
80-
the 'ungated' population. If specified, do not specify
81-
``parent_population``.
82-
parent_population (str): Name of the parent population. An attempt will
83-
be made to find the population by name. If zero or more than
84-
one population exists with the name, an error will be thrown.
85-
If specified, do not specify ``parent_population_id``.
86-
tailored_per_file (bool): Whether or not this gate is tailored per FCS file.
87-
fcs_file_id (str): ID of FCS file, if tailored per file. Use ``None`` for
88-
the global gate in a tailored gate group. If specified, do not
89-
specify ``fcs_file``.
90-
fcs_file (str): Name of FCS file, if tailored per file. An attempt will
91-
be made to find the file by name. If zero or more than one file exists
92-
with the name, an error will be thrown. Looking up files by name is
93-
slower than using the ID, as this requires additional requests
94-
to the server. If specified, do not specify ``fcs_file_id``.
95-
locked (bool): Prevents modification of the gate via the web interface.
96-
create_population (bool): Automatically create corresponding population.
97-
"""
9867
if type(gates) is list:
9968
return [cls._build_gate(gate) for gate in gates]
10069
else:
@@ -152,7 +121,7 @@ def delete_gates(
152121
ce.APIClient().delete_gate(experiment_id, _id, gid, exclude)
153122

154123
@staticmethod
155-
def update_gate_family(experiment_id, gid: str, body: Dict):
124+
def update_gate_family(experiment_id: str, gid: str, body: Dict) -> None:
156125
"""Update a given field for a gate family.
157126
158127
Warning: This method does not modify local versions of gates; use the

cellengine/utils/api_client/APIClient.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from typing import Any, Dict, List, Optional, Tuple, TypeVar, Union, overload
77

88
import pandas
9+
from pandas.core.frame import DataFrame
910
from requests_toolbelt.multipart.encoder import MultipartEncoder
1011

1112
from cellengine.utils import converter
@@ -76,7 +77,9 @@ def __repr__(self):
7677
else:
7778
return "Client(TOKEN)"
7879

79-
def _authenticate(self, username, password, token):
80+
def _authenticate(
81+
self, username: Optional[str], password: Optional[str], token: Optional[str]
82+
):
8083
"""Authenticate with the CellEngine API.
8184
8285
There are two ways of authenticating:
@@ -386,14 +389,14 @@ def create_fcs_file(self, experiment_id, body):
386389
return FcsFile.from_dict(self._post(url, json=body))
387390

388391
def download_fcs_file(
389-
self, experiment_id: str, fcs_file_id: str, **kwargs
392+
self, experiment_id: str, fcs_file_id: str, **kwargs: Any
390393
) -> bytes:
391394
"""Download events for a specific FcsFile
392395
393396
Parameters:
394397
experiment_id (str): ID of the experiment
395398
fcs_file_id (str): ID of the FcsFile
396-
kwargs:
399+
**kwargs:
397400
- compensatedQ (bool): If true, applies the compensation
398401
specified in compensationId to the exported events. For
399402
TSV format, the numerical values will be the compensated
@@ -624,7 +627,7 @@ def get_statistics(
624627
layout: Optional[str] = None,
625628
percent_of: Optional[Union[str, List[str]]] = "PARENT",
626629
population_ids: Optional[List[str]] = None,
627-
):
630+
) -> Union[Dict, str, DataFrame]:
628631
"""
629632
Request Statistics from CellEngine.
630633
@@ -663,6 +666,7 @@ def get_statistics(
663666
those populations.
664667
population_ids: List[str]: List of population IDs.
665668
Defaults to ungated.
669+
666670
Returns:
667671
statistics: Dict, String, or pandas.Dataframe
668672
"""
@@ -710,3 +714,5 @@ def determine_format(f):
710714
return pandas.DataFrame.from_dict(json.loads(raw_stats))
711715
except Exception as e:
712716
raise ValueError("Invalid data format {} for pandas".format(format), e)
717+
else:
718+
raise ValueError("Invalid data format selected.")

0 commit comments

Comments
 (0)