(self, weights)
| 746 | |
| 747 | # Modified from OneOf |
| 748 | def _normalize_probabilities(self, weights): |
| 749 | if weights is None or len(self.transforms) == 0: |
| 750 | return None |
| 751 | |
| 752 | weights = np.array(weights) |
| 753 | |
| 754 | n_weights = len(weights) |
| 755 | if n_weights != len(self.transforms): |
| 756 | raise ValueError(f"Expected len(weights)={len(self.transforms)}, got: {n_weights}.") |
| 757 | |
| 758 | if np.any(weights < 0): |
| 759 | raise ValueError(f"Probabilities must be greater than or equal to zero, got {weights}.") |
| 760 | |
| 761 | if np.all(weights == 0): |
| 762 | raise ValueError(f"At least one probability must be greater than zero, got {weights}.") |
| 763 | |
| 764 | weights = weights / weights.sum() |
| 765 | |
| 766 | return ensure_tuple(list(weights)) |
| 767 | |
| 768 | def __call__(self, data, start=0, end=None, threading=False, lazy: bool | None = None): |
| 769 | if start != 0: |
no test coverage detected