MCPcopy Create free account
hub / github.com/vispy/vispy / test_image_complex

Function test_image_complex

vispy/visuals/tests/test_image_complex.py:17–36  ·  view source on GitHub ↗

Test rendering of complex-valued image data.

(input_dtype, complex_mode)

Source from the content-addressed store, hash-verified

15@pytest.mark.parametrize("input_dtype", [np.complex64, np.complex128, np.float32])
16@pytest.mark.parametrize("complex_mode", ["magnitude", "real", "imaginary", "phase"])
17def 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)

Callers

nothing calls this directly

Calls 4

TestingCanvasFunction · 0.90
downsampleFunction · 0.90
compare_renderFunction · 0.90
renderMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…