(self, value, clip=None)
| 2526 | return result, is_scalar |
| 2527 | |
| 2528 | def __call__(self, value, clip=None): |
| 2529 | # docstring inherited |
| 2530 | if clip is None: |
| 2531 | clip = self.clip |
| 2532 | |
| 2533 | result, is_scalar = self.process_value(value) |
| 2534 | |
| 2535 | if self.vmin is None or self.vmax is None: |
| 2536 | self.autoscale_None(result) |
| 2537 | # Convert at least to float, without losing precision. |
| 2538 | (vmin,), _ = self.process_value(self.vmin) |
| 2539 | (vmax,), _ = self.process_value(self.vmax) |
| 2540 | if vmin == vmax: |
| 2541 | result.fill(0) # Or should it be all masked? Or 0.5? |
| 2542 | elif vmin > vmax: |
| 2543 | raise ValueError("minvalue must be less than or equal to maxvalue") |
| 2544 | else: |
| 2545 | if clip: |
| 2546 | mask = np.ma.getmask(result) |
| 2547 | result = np.ma.array(np.clip(result.filled(vmax), vmin, vmax), |
| 2548 | mask=mask) |
| 2549 | # ma division is very slow; we can take a shortcut |
| 2550 | resdat = result.data |
| 2551 | resdat -= vmin |
| 2552 | resdat /= (vmax - vmin) |
| 2553 | result = np.ma.array(resdat, mask=result.mask, copy=False) |
| 2554 | if is_scalar: |
| 2555 | result = result[0] |
| 2556 | return result |
| 2557 | |
| 2558 | def inverse(self, value): |
| 2559 | """ |
nothing calls this directly
no test coverage detected