MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / __init__

Method __init__

monai/transforms/compose.py:458–479  ·  view source on GitHub ↗
(
        self,
        transforms: Sequence[Callable] | Callable | None = None,
        weights: Sequence[float] | float | None = None,
        map_items: bool | int = True,
        unpack_items: bool = False,
        log_stats: bool | str = False,
        lazy: bool | None = False,
        overrides: dict | None = None,
    )

Source from the content-addressed store, hash-verified

456 """
457
458 def __init__(
459 self,
460 transforms: Sequence[Callable] | Callable | None = None,
461 weights: Sequence[float] | float | None = None,
462 map_items: bool | int = True,
463 unpack_items: bool = False,
464 log_stats: bool | str = False,
465 lazy: bool | None = False,
466 overrides: dict | None = None,
467 ) -> None:
468 super().__init__(transforms, map_items, unpack_items, log_stats, lazy, overrides)
469 if len(self.transforms) == 0:
470 weights = []
471 elif weights is None or isinstance(weights, float):
472 weights = [1.0 / len(self.transforms)] * len(self.transforms)
473 if len(weights) != len(self.transforms):
474 raise ValueError(
475 "transforms and weights should be same size if both specified as sequences, "
476 f"got {len(weights)} and {len(self.transforms)}."
477 )
478 self.weights = ensure_tuple(self._normalize_probabilities(weights))
479 self.log_stats = log_stats
480
481 def _normalize_probabilities(self, weights):
482 if len(weights) == 0:

Callers 3

__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45

Calls 2

ensure_tupleFunction · 0.90

Tested by

no test coverage detected