Skip to content

Commit

Permalink
Clean-up tests
Browse files Browse the repository at this point in the history
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/`
  • Loading branch information
JorisVincent committed Jul 4, 2021
1 parent 24a47c2 commit fa78d16
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 61 deletions.
Empty file added tests/__init__.py
Empty file.
File renamed without changes.
File renamed without changes.
48 changes: 48 additions & 0 deletions 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()
33 changes: 21 additions & 12 deletions tests/papers/domijan2015/test_stimuli.py
Expand Up @@ -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)
assert np.array_equal(original, test)
49 changes: 0 additions & 49 deletions tests/test_lightness.py

This file was deleted.

0 comments on commit fa78d16

Please sign in to comment.