Limit the value into a period for periodic function. Args: val (np.ndarray or Tensor): The value to be converted. offset (float): Offset to set the value range. Defaults to 0.5. period (float): Period of the value. Defaults to np.pi. Returns: np.ndarray or T
(val: Union[np.ndarray, Tensor],
offset: float = 0.5,
period: float = np.pi)
| 12 | |
| 13 | @array_converter(apply_to=('val', )) |
| 14 | def limit_period(val: Union[np.ndarray, Tensor], |
| 15 | offset: float = 0.5, |
| 16 | period: float = np.pi) -> Union[np.ndarray, Tensor]: |
| 17 | """Limit the value into a period for periodic function. |
| 18 | |
| 19 | Args: |
| 20 | val (np.ndarray or Tensor): The value to be converted. |
| 21 | offset (float): Offset to set the value range. Defaults to 0.5. |
| 22 | period (float): Period of the value. Defaults to np.pi. |
| 23 | |
| 24 | Returns: |
| 25 | np.ndarray or Tensor: Value in the range of |
| 26 | [-offset * period, (1-offset) * period]. |
| 27 | """ |
| 28 | limited_val = val - torch.floor(val / period + offset) * period |
| 29 | return limited_val |
| 30 | |
| 31 | |
| 32 | @array_converter(apply_to=('points', 'angles')) |
no outgoing calls
no test coverage detected