Skip to content

Commit

Permalink
(chore): add more doc fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jdeschamps committed May 29, 2024
1 parent a04961f commit 10af1b4
Show file tree
Hide file tree
Showing 37 changed files with 191 additions and 121 deletions.
5 changes: 5 additions & 0 deletions src/careamics/config/architectures/architecture_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ def model_dump(self, **kwargs: Any) -> Dict[str, Any]:
"""
Dump the model as a dictionary, ignoring the architecture keyword.
Parameters
----------
**kwargs : Any
Additional keyword arguments from Pydantic BaseModel model_dump method.
Returns
-------
dict[str, Any]
Expand Down
9 changes: 8 additions & 1 deletion src/careamics/config/architectures/custom_model.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Custom architecture Pydantic model."""

from __future__ import annotations

from pprint import pformat
Expand Down Expand Up @@ -84,6 +86,11 @@ def custom_model_is_known(cls, value: str) -> str:
value : str
Name of the custom model as registered using the `@register_model`
decorator.
Returns
-------
str
The custom model name.
"""
# delegate error to get_custom_model
model = get_custom_model(value)
Expand Down Expand Up @@ -134,7 +141,7 @@ def model_dump(self, **kwargs: Any) -> Dict[str, Any]:
Parameters
----------
kwargs : Any
**kwargs : Any
Additional keyword arguments from Pydantic BaseModel model_dump method.
Returns
Expand Down
4 changes: 3 additions & 1 deletion src/careamics/config/architectures/register_model.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Custom model registration utilities."""

from typing import Callable

from torch.nn import Module
Expand Down Expand Up @@ -53,7 +55,7 @@ def add_custom_model(model: Module) -> Module:
Parameters
----------
model : Module
Module class to register
Module class to register.
Returns
-------
Expand Down
2 changes: 2 additions & 0 deletions src/careamics/config/architectures/unet_model.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""UNet Pydantic model."""

from __future__ import annotations

from typing import Literal
Expand Down
2 changes: 2 additions & 0 deletions src/careamics/config/architectures/vae_model.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""VAE Pydantic model."""

from typing import Literal

from pydantic import (
Expand Down
18 changes: 3 additions & 15 deletions src/careamics/config/callback_model.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Checkpoint saving configuration."""
"""Callback Pydantic models."""

from __future__ import annotations

Expand All @@ -13,13 +13,7 @@


class CheckpointModel(BaseModel):
"""_summary_.
Parameters
----------
BaseModel : _type_
_description_
"""
"""Checkpoint saving callback Pydantic model."""

model_config = ConfigDict(
validate_assignment=True,
Expand All @@ -46,13 +40,7 @@ class CheckpointModel(BaseModel):


class EarlyStoppingModel(BaseModel):
"""_summary_.
Parameters
----------
BaseModel : _type_
_description_
"""
"""Early stopping callback Pydantic model."""

model_config = ConfigDict(
validate_assignment=True,
Expand Down
4 changes: 3 additions & 1 deletion src/careamics/config/configuration_example.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Example of configurations."""

from .algorithm_model import AlgorithmConfig
from .architectures import UNetModel
from .configuration_model import Configuration
Expand All @@ -19,7 +21,7 @@


def full_configuration_example() -> Configuration:
"""Returns a dictionnary representing a full configuration example.
"""Return a dictionnary representing a full configuration example.
Returns
-------
Expand Down
8 changes: 4 additions & 4 deletions src/careamics/config/optimizer_models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Optimizers and schedulers Pydantic models."""

from __future__ import annotations

from typing import Dict, Literal
Expand All @@ -19,8 +21,7 @@


class OptimizerModel(BaseModel):
"""
Torch optimizer.
"""Torch optimizer Pydantic model.
Only parameters supported by the corresponding torch optimizer will be taken
into account. For more details, check:
Expand Down Expand Up @@ -115,8 +116,7 @@ def sgd_lr_parameter(self) -> Self:


class LrSchedulerModel(BaseModel):
"""
Torch learning rate scheduler.
"""Torch learning rate scheduler Pydantic model.
Only parameters supported by the corresponding torch lr scheduler will be taken
into account. For more details, check:
Expand Down
2 changes: 0 additions & 2 deletions src/careamics/config/support/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"SupportedPixelManipulation",
"SupportedTransform",
"SupportedData",
"SupportedExtractionStrategy",
"SupportedStructAxis",
"SupportedLogger",
]
Expand All @@ -24,7 +23,6 @@
from .supported_algorithms import SupportedAlgorithm
from .supported_architectures import SupportedArchitecture
from .supported_data import SupportedData
from .supported_extraction_strategies import SupportedExtractionStrategy
from .supported_loggers import SupportedLogger
from .supported_losses import SupportedLoss
from .supported_optimizers import SupportedOptimizer, SupportedScheduler
Expand Down
2 changes: 2 additions & 0 deletions src/careamics/config/support/supported_activations.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Activations supported by CAREamics."""

from careamics.utils import BaseEnum


Expand Down
4 changes: 3 additions & 1 deletion src/careamics/config/support/supported_algorithms.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Algorithms supported by CAREamics."""

from __future__ import annotations

from careamics.utils import BaseEnum
Expand All @@ -10,9 +12,9 @@ class SupportedAlgorithm(str, BaseEnum):
"""

N2V = "n2v"
CUSTOM = "custom"
CARE = "care"
N2N = "n2n"
CUSTOM = "custom"
# PN2V = "pn2v"
# HDN = "hdn"
# SEG = "segmentation"
2 changes: 2 additions & 0 deletions src/careamics/config/support/supported_architectures.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Architectures supported by CAREamics."""

from careamics.utils import BaseEnum


Expand Down
2 changes: 2 additions & 0 deletions src/careamics/config/support/supported_data.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Data supported by CAREamics."""

from __future__ import annotations

from typing import Union
Expand Down
25 changes: 0 additions & 25 deletions src/careamics/config/support/supported_extraction_strategies.py

This file was deleted.

2 changes: 2 additions & 0 deletions src/careamics/config/support/supported_loggers.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Logger supported by CAREamics."""

from careamics.utils import BaseEnum


Expand Down
2 changes: 2 additions & 0 deletions src/careamics/config/support/supported_losses.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Losses supported by CAREamics."""

from careamics.utils import BaseEnum


Expand Down
2 changes: 2 additions & 0 deletions src/careamics/config/support/supported_optimizers.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Optimizers and schedulers supported by CAREamics."""

from careamics.utils import BaseEnum


Expand Down
6 changes: 3 additions & 3 deletions src/careamics/config/support/supported_pixel_manipulations.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
"""Pixel manipulation methods supported by CAREamics."""

from careamics.utils import BaseEnum


class SupportedPixelManipulation(str, BaseEnum):
"""_summary_.
"""Supported Noise2Void pixel manipulations.
- Uniform: Replace masked pixel value by a (uniformly) randomly selected neighbor
pixel value.
- Median: Replace masked pixel value by the mean of the neighborhood.
"""

# TODO docs

UNIFORM = "uniform"
MEDIAN = "median"
2 changes: 2 additions & 0 deletions src/careamics/config/support/supported_struct_axis.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""StructN2V axes supported by CAREamics."""

from careamics.utils import BaseEnum


Expand Down
17 changes: 3 additions & 14 deletions src/careamics/config/support/supported_transforms.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,12 @@
"""Transforms supported by CAREamics."""

from careamics.utils import BaseEnum


class SupportedTransform(str, BaseEnum):
"""Transforms officially supported by CAREamics.
- Flip: from Albumentations, randomly flip the input horizontally, vertically or
both, parameter `p` can be used to set the probability to apply the transform.
- XYRandomRotate90: #TODO
- Normalize # TODO add details, in particular about the parameters
- ManipulateN2V # TODO add details, in particular about the parameters
- XYFlip
Note that while any Albumentations (see https://albumentations.ai/) transform can be
used in CAREamics, no check are implemented to verify the compatibility of any other
transforms than the ones officially supported.
"""
"""Transforms officially supported by CAREamics."""

XY_FLIP = "XYFlip"
XY_RANDOM_ROTATE90 = "XYRandomRotate90"
NORMALIZE = "Normalize"
N2V_MANIPULATE = "N2VManipulate"
# CUSTOM = "Custom"
2 changes: 2 additions & 0 deletions src/careamics/config/tile_information.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Pydantic model representing the metadata of a prediction tile."""

from __future__ import annotations

from typing import Optional, Tuple
Expand Down
8 changes: 4 additions & 4 deletions src/careamics/dataset/dataset_utils/dataset_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Convenience methods for datasets."""
"""Dataset utilities."""

from typing import List, Tuple

Expand All @@ -17,12 +17,12 @@ def _get_shape_order(
Parameters
----------
shape_in : Tuple
shape_in : Tuple[int, ...]
Input shape.
ref_axes : str
Reference axes.
axes_in : str
Input axes.
ref_axes : str
Reference axes.
Returns
-------
Expand Down
7 changes: 4 additions & 3 deletions src/careamics/dataset/dataset_utils/file_utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""File utilities."""

from fnmatch import fnmatch
from pathlib import Path
from typing import List, Union
Expand All @@ -11,8 +13,7 @@


def get_files_size(files: List[Path]) -> float:
"""
Get files size in MB.
"""Get files size in MB.
Parameters
----------
Expand All @@ -32,7 +33,7 @@ def list_files(
data_type: Union[str, SupportedData],
extension_filter: str = "",
) -> List[Path]:
"""Creates a recursive list of files in `data_path`.
"""Create a recursive list of files in `data_path`.
If `data_path` is a file, its name is validated against the `data_type` using
`fnmatch`, and the method returns `data_path` itself.
Expand Down
4 changes: 2 additions & 2 deletions src/careamics/dataset/dataset_utils/read_tiff.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Funtions to read tiff images."""

import logging
from fnmatch import fnmatch
from pathlib import Path
Expand All @@ -19,8 +21,6 @@ def read_tiff(file_path: Path, *args: list, **kwargs: dict) -> np.ndarray:
----------
file_path : Path
Path to a file.
axes : str
Description of axes in format STCZYX.
Returns
-------
Expand Down
2 changes: 2 additions & 0 deletions src/careamics/dataset/dataset_utils/read_utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Read function utilities."""

from typing import Callable, Union

from careamics.config.support import SupportedData
Expand Down
Loading

0 comments on commit 10af1b4

Please sign in to comment.