| 325 | self._norm_spread[self._norm_spread == 0] = 1 |
| 326 | |
| 327 | def normalize(self, val): |
| 328 | un_low, un_high = self._unnormalized.low, self._unnormalized.high |
| 329 | |
| 330 | self._shape_check(val, 'normalize') |
| 331 | val = self._bounds_check(val, un_low, un_high) |
| 332 | |
| 333 | normalized = self._normalized.low + (self._norm_spread / self._unnorm_spread) * (val - un_low) |
| 334 | |
| 335 | try: |
| 336 | if not isinstance(val, np.ndarray): |
| 337 | return normalized.item() |
| 338 | return normalized |
| 339 | except (AttributeError, ValueError): |
| 340 | return normalized |
| 341 | |
| 342 | def denormalize(self, val): |
| 343 | norm_low, norm_high = self._normalized.low, self._normalized.high |