From 28c378424b4172052d0d4d6563495d7cdadbf853 Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Fri, 16 Apr 2021 08:26:10 -0700 Subject: [PATCH 1/4] scale_ctm expects floats --- enable/markers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/enable/markers.py b/enable/markers.py index a47f4279d..f5c82fe9b 100644 --- a/enable/markers.py +++ b/enable/markers.py @@ -421,7 +421,7 @@ class CustomMarker(AbstractMarker): def _add_to_path(self, path, size): if self.scale_path: path.save_ctm() - path.scale_ctm(size, size) + path.scale_ctm(float(size), float(size)) path.add_path(path) if self.scale_path: path.restore_ctm() @@ -435,7 +435,7 @@ def get_compiled_path(self, size): """ if self.scale_path: newpath = CompiledPath() - newpath.scale_ctm(size, size) + newpath.scale_ctm(float(size), float(size)) newpath.add_path(self.path) return newpath else: From ac6362eb7caa85ce85ea57bf26ff1e069c4c3db3 Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Mon, 19 Apr 2021 15:32:30 -0700 Subject: [PATCH 2/4] add regression tests --- enable/tests/test_markers.py | 48 ++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 enable/tests/test_markers.py diff --git a/enable/tests/test_markers.py b/enable/tests/test_markers.py new file mode 100644 index 000000000..99f519d86 --- /dev/null +++ b/enable/tests/test_markers.py @@ -0,0 +1,48 @@ +# (C) Copyright 2005-2021 Enthought, Inc., Austin, TX +# All rights reserved. +# +# This software is provided without warranty under the terms of the BSD +# license included in LICENSE.txt and may be redistributed only under +# the conditions described in the aforementioned license. The license +# is also available online at http://www.enthought.com/licenses/BSD.txt +# +# Thanks for using Enthought open source! +import unittest + +import numpy as np + +from enable.compiled_path import CompiledPath +from enable.kiva_graphics_context import GraphicsContext +from enable.markers import CustomMarker + + +class TestCustomMarker(unittest.TestCase): + + def test_add_to_path(self): + path = CompiledPath() + path.begin_path() + path.move_to(-5, -5) + path.line_to(-5, 5) + path.line_to(5, 5) + path.line_to(5, -5) + path.line_to(-5, -5) + + marker = CustomMarker(path=path) + + gc = GraphicsContext((50, 50)) + # should not fail + marker.add_to_path(gc.get_empty_path(), np.int64(0)) + + def test_get_compiled_path(self): + path = CompiledPath() + path.begin_path() + path.move_to(-5, -5) + path.line_to(-5, 5) + path.line_to(5, 5) + path.line_to(5, -5) + path.line_to(-5, -5) + + marker = CustomMarker(path=path) + + # should not fail + marker.get_compiled_path(np.int64(0)) From 0a993134cd797881c8828f2d364021d40eedc6c7 Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Mon, 19 Apr 2021 15:36:11 -0700 Subject: [PATCH 3/4] add comment refering to original motivating issue in chaco --- enable/tests/test_markers.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/enable/tests/test_markers.py b/enable/tests/test_markers.py index 99f519d86..907f141bd 100644 --- a/enable/tests/test_markers.py +++ b/enable/tests/test_markers.py @@ -18,6 +18,7 @@ class TestCustomMarker(unittest.TestCase): + # regression test for enthought/chaco#232 def test_add_to_path(self): path = CompiledPath() path.begin_path() @@ -33,6 +34,7 @@ def test_add_to_path(self): # should not fail marker.add_to_path(gc.get_empty_path(), np.int64(0)) + # regression test for enthought/chaco#232 def test_get_compiled_path(self): path = CompiledPath() path.begin_path() From 9af929d82205e7b90662be338945a600412eca17 Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Wed, 21 Apr 2021 10:28:32 -0700 Subject: [PATCH 4/4] skip tests if not on qt --- enable/tests/test_markers.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/enable/tests/test_markers.py b/enable/tests/test_markers.py index 907f141bd..f3b9f6e9e 100644 --- a/enable/tests/test_markers.py +++ b/enable/tests/test_markers.py @@ -14,8 +14,10 @@ from enable.compiled_path import CompiledPath from enable.kiva_graphics_context import GraphicsContext from enable.markers import CustomMarker +from enable.tests._testing import skip_if_not_qt +@skip_if_not_qt class TestCustomMarker(unittest.TestCase): # regression test for enthought/chaco#232