From fa78d16ac8455a140f5ca06d3a7a7457ab643357 Mon Sep 17 00:00:00 2001 From: Joris Vincent Date: Sun, 4 Jul 2021 13:05:35 +0200 Subject: [PATCH] Clean-up tests Rename scripts that just plot (and don't assert anything) to `demo_`, to avoid being run automatically by pytest. Include an empty __init__.py in tests to help with pytest discovering tests in `tests/papers/domijna2015/` --- tests/__init__.py | 0 ...usions.py => demo_brightness_illusions.py} | 0 ...ions2.py => demo_brightness_illusions2.py} | 0 tests/demo_lightness.py | 48 ++++++++++++++++++ tests/papers/domijan2015/test_stimuli.py | 33 ++++++++----- tests/test_lightness.py | 49 ------------------- 6 files changed, 69 insertions(+), 61 deletions(-) create mode 100644 tests/__init__.py rename tests/{test_brightness_illusions.py => demo_brightness_illusions.py} (100%) rename tests/{test_brightness_illusions2.py => demo_brightness_illusions2.py} (100%) create mode 100644 tests/demo_lightness.py delete mode 100644 tests/test_lightness.py diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/test_brightness_illusions.py b/tests/demo_brightness_illusions.py similarity index 100% rename from tests/test_brightness_illusions.py rename to tests/demo_brightness_illusions.py diff --git a/tests/test_brightness_illusions2.py b/tests/demo_brightness_illusions2.py similarity index 100% rename from tests/test_brightness_illusions2.py rename to tests/demo_brightness_illusions2.py diff --git a/tests/demo_lightness.py b/tests/demo_lightness.py new file mode 100644 index 00000000..f9fef93b --- /dev/null +++ b/tests/demo_lightness.py @@ -0,0 +1,48 @@ +import matplotlib.pyplot as plt +from stimuli import lightness + +# %% Cornsweet / Todorovic +a = lightness.cornsweet((10, 10), 10, 0.5) +b = lightness.todorovic(a, 2, 2) + +plt.figure() +plt.imshow(a, vmin=0, vmax=1, cmap="gray") +plt.show() +plt.figure() +plt.imshow(b, vmin=0, vmax=1, cmap="gray") +plt.show() + +# %% Square Wave +c = lightness.square_wave((10, 10), 10, 0.5, 2) + +plt.figure() +plt.imshow(c, vmin=0, vmax=1, cmap="gray") +plt.show() + +# %% White's Illusion BMCC +d = lightness.whites_illusion_bmcc((10, 10), 10, 0.5, 2) +e1, e2 = lightness.contours_white_bmmc((10, 10), 10, 0.5, 2, contour_width=3) + +plt.figure() +plt.imshow(d, vmin=0, vmax=1, cmap="gray") +plt.show() +plt.figure() +plt.imshow(e1, vmin=0, vmax=1, cmap="gray") +plt.show() +plt.figure() +plt.imshow(e2, vmin=0, vmax=1, cmap="gray") +plt.show() + +# %% White's Illusion Gil +f = lightness.whites_illusion_gil((10, 10), 10, 0.5, 2) + +plt.figure() +plt.imshow(f, vmin=0, vmax=1, cmap="gray") +plt.show() + +# %% Disc and Ring +g = lightness.disc_and_ring((10, 10), [4, 2], [0.5, 1.0]) + +plt.figure() +plt.imshow(g, vmin=0, vmax=1, cmap="gray") +plt.show() diff --git a/tests/papers/domijan2015/test_stimuli.py b/tests/papers/domijan2015/test_stimuli.py index b158f3c0..2d8f2b2c 100644 --- a/tests/papers/domijan2015/test_stimuli.py +++ b/tests/papers/domijan2015/test_stimuli.py @@ -11,54 +11,63 @@ def test_dungeon(): original = ground_truth.get_dungeon() test = stimuli.papers.domijan2015.dungeon().img assert np.array_equal(original, test) - - + + def test_cube(): original = ground_truth.get_cube() test = stimuli.papers.domijan2015.cube().img assert np.array_equal(original, test) - + + def test_grating(): original = ground_truth.get_grating() test = stimuli.papers.domijan2015.grating().img assert np.array_equal(original, test) - + + def test_ring(): original = ground_truth.get_ring() test = stimuli.papers.domijan2015.rings().img assert np.array_equal(original, test) - + + def test_bullseye(): original = ground_truth.get_bullseye() test = stimuli.papers.domijan2015.bullseye().img assert np.array_equal(original, test) - + + def test_sbc(): original = ground_truth.get_sbc() test = stimuli.papers.domijan2015.simultaneous_brightness_contrast().img assert np.array_equal(original, test) - + + def test_white(): original = ground_truth.get_white() test = stimuli.papers.domijan2015.white().img assert np.array_equal(original, test) - + + def test_benary(): original = ground_truth.get_benary() test = stimuli.papers.domijan2015.benary().img assert np.array_equal(original, test) - + + def test_todorovic(): original = ground_truth.get_todorovic() test = stimuli.papers.domijan2015.todorovic().img assert np.array_equal(original, test) - + + def test_checkerboard(): original = ground_truth.get_checkerboard() test = stimuli.papers.domijan2015.checkerboard().img assert np.array_equal(original, test) - + + def test_checkerboard_extended(): original = ground_truth.get_checkerboard_extended() test = stimuli.papers.domijan2015.checkerboard_extended().img - assert np.array_equal(original, test) \ No newline at end of file + assert np.array_equal(original, test) diff --git a/tests/test_lightness.py b/tests/test_lightness.py deleted file mode 100644 index 7a554dd6..00000000 --- a/tests/test_lightness.py +++ /dev/null @@ -1,49 +0,0 @@ -import matplotlib.pyplot as plt -from stimuli import lightness - -# %% Cornsweet / Todorovic -a = lightness.cornsweet((10, 10), 10, .5) -b = lightness.todorovic(a, 2, 2) - -plt.figure() -plt.imshow(a, vmin=0, vmax=1, cmap='gray') -plt.show() -plt.figure() -plt.imshow(b, vmin=0, vmax=1, cmap='gray') -plt.show() - -# %% Square Wave -c = lightness.square_wave((10, 10), 10, .5, 2) - -plt.figure() -plt.imshow(c, vmin=0, vmax=1, cmap='gray') -plt.show() - -# %% White's Illusion BMCC -d = lightness.whites_illusion_bmcc((10, 10), 10, .5, 2) -e1, e2 = lightness.contours_white_bmmc((10, 10), 10, .5, 2, contour_width=3) - -plt.figure() -plt.imshow(d, vmin=0, vmax=1, cmap='gray') -plt.show() -plt.figure() -plt.imshow(e1, vmin=0, vmax=1, cmap='gray') -plt.show() -plt.figure() -plt.imshow(e2, vmin=0, vmax=1, cmap='gray') -plt.show() - -# %% White's Illusion Gil -f = lightness.whites_illusion_gil((10, 10), 10, .5, 2) - -plt.figure() -plt.imshow(f, vmin=0, vmax=1, cmap='gray') -plt.show() - -# %% Disc and Ring -g = lightness.disc_and_ring((10, 10), [4, 2], [0.5, 1.]) - -plt.figure() -plt.imshow(g, vmin=0, vmax=1, cmap='gray') -plt.show() -