Skip to content

Instantly share code, notes, and snippets.

@lindemann09
Created March 26, 2019 16:38
Show Gist options
  • Save lindemann09/6874b5d251c6dcf919932a3328ed84b6 to your computer and use it in GitHub Desktop.
Save lindemann09/6874b5d251c6dcf919932a3328ed84b6 to your computer and use it in GitHub Desktop.
Testscript Florian
import expyriment as xpy
def shape_test_case(size, line_width):
"""Compare manual rectangle with result from Shape class."""
from expyriment import stimuli
print("TEST CASE: size={0}, line_width={1}".format(size, line_width))
# Manual Rectangle
m = stimuli.Rectangle(size, line_width=line_width)
m2 = stimuli.Canvas(size)
# Rectangle based on Shape class
s = stimuli.Shape(line_width=line_width)
#s.add_vertices([[size[0],0], [0, size[1]], [-size[0],0]])
s.add_vertices([[size[0]-1,0], [0, size[1]-1], [-size[0]+1,0]])
m_surface = m.surface_size
s_surface = s.surface_size
if not m_surface == s_surface:
print("surface size: FAILED ({0},{1})".format(
s_surface[0] - m_surface[0], s_surface[1] - m_surface[1]))
else:
print("surface size: OK".format(m.surface_size))
overlap_self = m.overlapping_with_stimulus(m)
overlap_self2 = s.overlapping_with_stimulus(s)
overlap_other = m.overlapping_with_stimulus(s)
if not overlap_self[1] == overlap_self2[1]:
print("visable size: FAILED ({0})".format(
overlap_self2[1] - overlap_self[1]))
else:
print("visable size: OK")
if not (m.inside_stimulus(s) and s.inside_stimulus(m)):
print("visable overlap: FAILED ({0})".format(
max(overlap_self[1], overlap_self2[1]) - overlap_other[1]))
else:
print("visual overlap: OK")
print("")
return s
xpy.control.set_develop_mode()
exp = xpy.control.initialize()
s = shape_test_case([20, 20], 0)
s.present()
exp.keyboard.wait()
shape_test_case([21, 21], 0)
shape_test_case([20, 20], 1)
shape_test_case([21, 21], 1)
shape_test_case([20, 20], 2)
shape_test_case([21, 21], 2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment