(arr)
| 3782 | |
| 3783 | |
| 3784 | def _vector_magnitude(arr): |
| 3785 | # things that don't work here: |
| 3786 | # * np.linalg.norm: drops mask from ma.array |
| 3787 | # * np.sum: drops mask from ma.array unless entire vector is masked |
| 3788 | sum_sq = 0 |
| 3789 | for i in range(arr.shape[-1]): |
| 3790 | sum_sq += arr[..., i, np.newaxis] ** 2 |
| 3791 | return np.sqrt(sum_sq) |
| 3792 | |
| 3793 | |
| 3794 | class LightSource: |