Get the unmasked regions using the coordinates and array
(self)
| 2635 | self._set_unmasked_verts() |
| 2636 | |
| 2637 | def _get_unmasked_polys(self): |
| 2638 | """Get the unmasked regions using the coordinates and array""" |
| 2639 | # mask(X) | mask(Y) |
| 2640 | mask = np.any(np.ma.getmaskarray(self._coordinates), axis=-1) |
| 2641 | |
| 2642 | # We want the shape of the polygon, which is the corner of each X/Y array |
| 2643 | mask = (mask[0:-1, 0:-1] | mask[1:, 1:] | mask[0:-1, 1:] | mask[1:, 0:-1]) |
| 2644 | arr = self.get_array() |
| 2645 | if arr is not None: |
| 2646 | arr = np.ma.getmaskarray(arr) |
| 2647 | if arr.ndim == 3: |
| 2648 | # RGB(A) case |
| 2649 | mask |= np.any(arr, axis=-1) |
| 2650 | elif arr.ndim == 2: |
| 2651 | mask |= arr |
| 2652 | else: |
| 2653 | mask |= arr.reshape(self._coordinates[:-1, :-1, :].shape[:2]) |
| 2654 | return ~mask |
| 2655 | |
| 2656 | def _set_unmasked_verts(self): |
| 2657 | X = self._coordinates[..., 0] |
no test coverage detected