From 6324eeeecbf872f39af1c2c8aa672a9a2f7a13e2 Mon Sep 17 00:00:00 2001 From: Victor Shnayder Date: Sat, 27 Oct 2012 20:00:18 -0400 Subject: [PATCH] add note about mysterious -15 in the code --- common/lib/capa/capa/inputtypes.py | 3 ++- common/lib/capa/capa/tests/test_inputtypes.py | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/common/lib/capa/capa/inputtypes.py b/common/lib/capa/capa/inputtypes.py index 33e9048131..0bbf54d153 100644 --- a/common/lib/capa/capa/inputtypes.py +++ b/common/lib/capa/capa/inputtypes.py @@ -510,7 +510,8 @@ class ImageInput(InputTypeBase): # if value is of the form [x,y] then parse it and send along coordinates of previous answer m = re.match('\[([0-9]+),([0-9]+)]', self.value.strip().replace(' ', '')) if m: - # TODO (vshnayder): why is there a "-15" here?? + # Note: we subtract 15 to compensate for the size of the dot on the screen. + # (which supposedly has size 30). (self.gx, self.gy) = [int(x) - 15 for x in m.groups()] else: (self.gx, self.gy) = (0, 0) diff --git a/common/lib/capa/capa/tests/test_inputtypes.py b/common/lib/capa/capa/tests/test_inputtypes.py index 992af14bf9..ba20f84cb1 100644 --- a/common/lib/capa/capa/tests/test_inputtypes.py +++ b/common/lib/capa/capa/tests/test_inputtypes.py @@ -400,6 +400,7 @@ class ImageInputTest(unittest.TestCase): self.assertEqual(context, expected) def test_with_value(self): + # Check that compensating for the dot size works properly. self.check('[50,40]', 35, 25) def test_without_value(self):