Skip to content

Commit

Permalink
docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
bkmartinjr committed Aug 27, 2024
1 parent 39f2f4a commit 7484315
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions other_packages/python/tiledbsoma_ml/src/tiledbsoma_ml/pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,11 +491,6 @@ def shape(self) -> Tuple[int, int]:
return self._exp_iter.shape


def _collate_noop(datum: _T) -> _T:
"""Disable collation in dataloader instance."""
return datum


def experiment_dataloader(
ds: torchdata.datapipes.iter.IterDataPipe | torch.utils.data.IterableDataset,
# num_workers: int = 0,
Expand Down Expand Up @@ -558,13 +553,22 @@ def experiment_dataloader(
)


def _collate_noop(datum: _T) -> _T:
"""Noop collation for use with a dataloader instance.
Private.
"""
return datum


def _splits(total_length: int, sections: int) -> npt.NDArray[np.intp]:
"""For `total_length` points, compute start/stop offsets that split the length into roughly equal sizes.
A total_length of L, split into N sections, will return L%N sections of size L//N+1,
and the remainder as size L//N.
and the remainder as size L//N. This results in the same split as numpy.array_split,
for an array of length L and sections N.
This results in is the same split as numpy.array_split, for an array of length L.
Private.
Examples
--------
Expand Down Expand Up @@ -635,6 +639,7 @@ def _init_multiprocessing() -> None:
Also, CUDA does not support forked child processes:
https://pytorch.org/docs/stable/notes/multiprocessing.html#cuda-in-multiprocessing
Private.
"""
orig_start_method = torch.multiprocessing.get_start_method()
if orig_start_method != "spawn":
Expand All @@ -660,6 +665,8 @@ def _csr_to_dense(sp: sparse.csr_array | sparse.csr_matrix) -> NDArrayNumber:
"""Fast, parallel, variant of scipy.sparse.csr_array.todense.
Typically 4-8X faster, dending on host and size of array/matrix.
Private.
"""
assert isinstance(sp, (sparse.csr_array, sparse.csr_matrix))
return cast(
Expand Down

0 comments on commit 7484315

Please sign in to comment.