Test rendering of complex-valued image data.
(input_dtype, complex_mode)
| 15 | @pytest.mark.parametrize("input_dtype", [np.complex64, np.complex128, np.float32]) |
| 16 | @pytest.mark.parametrize("complex_mode", ["magnitude", "real", "imaginary", "phase"]) |
| 17 | def test_image_complex(input_dtype, complex_mode): |
| 18 | """Test rendering of complex-valued image data.""" |
| 19 | shape = (40, 40) |
| 20 | np.random.seed(0) |
| 21 | data = np.random.random(shape).astype(input_dtype) |
| 22 | if np.iscomplexobj(data): |
| 23 | data.imag = np.random.random(shape) |
| 24 | |
| 25 | with TestingCanvas(size=shape, bgcolor="w") as c: |
| 26 | ComplexImage(data, cmap="grays", complex_mode=complex_mode, parent=c.scene) |
| 27 | # render to canvas |
| 28 | rendered = c.render() |
| 29 | shape_ratio = rendered.shape[0] // data.shape[0] |
| 30 | rendered = downsample(rendered, shape_ratio, axis=(0, 1)) |
| 31 | |
| 32 | # perform (auto-clim) rendering on cpu |
| 33 | exp = CPU_COMPLEX_TRANSFORMS[complex_mode](data) if np.iscomplexobj(data) else data |
| 34 | exp -= exp.min() |
| 35 | exp /= exp.max() |
| 36 | compare_render(exp, rendered) |
nothing calls this directly
no test coverage detected
searching dependent graphs…