-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix CursorTool issue with LogMapper #803
Merged
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8a87e84
add regression test
aaronayres35 2334b8d
update cursor_tool.py so test passes
aaronayres35 5edf21f
add a now failing test showing use with LinearMapper
aaronayres35 7f3d1d1
remove commented out lines
aaronayres35 81abe50
make new test pass by having LinearMapper match behavior of LogMapper
aaronayres35 fa10055
fix failing test
aaronayres35 442c68a
add copyright header
aaronayres35 8ec5e61
Merge branch 'master' into fix/289-CursorTool-with-LogMapper
aaronayres35 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
# (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 | ||
aaronayres35 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
import numpy as np | ||
|
||
from enable.api import ComponentEditor | ||
from enable.testing import EnableTestAssistant | ||
from traits.api import HasTraits, Instance | ||
from traits.etsconfig.api import ETSConfig | ||
from traitsui.api import Item, View | ||
from traitsui.testing.api import UITester | ||
|
||
from chaco.api import ArrayPlotData, Plot | ||
from chaco.tools.cursor_tool import CursorTool | ||
|
||
|
||
class TestCursorTool(unittest.TestCase, EnableTestAssistant): | ||
|
||
# regression test for enthought/chaco#289 | ||
@unittest.skipIf(ETSConfig.toolkit == "null", "Skip on 'null' toolkit") | ||
def test_use_with_log_mappers(self): | ||
class TestCursor(HasTraits): | ||
plot = Instance(Plot) | ||
|
||
traits_view = View( | ||
Item('plot', editor=ComponentEditor(), show_label=False), | ||
width=500, | ||
height=500, | ||
resizable=True | ||
) | ||
|
||
def _plot_default(self): | ||
arr = np.logspace(0, 10, num=10) | ||
data = ArrayPlotData(x=arr, y=arr) | ||
plot = Plot(data) | ||
renderer = plot.plot( | ||
("x", "y"), | ||
index_scale="log", | ||
value_scale="log" | ||
)[0] | ||
|
||
cursor = CursorTool(renderer) | ||
|
||
renderer.overlays.append(cursor) | ||
|
||
return plot | ||
|
||
tester = UITester() | ||
test_cursor = TestCursor() | ||
with tester.create_ui(test_cursor): | ||
# should not fail | ||
self.mouse_move( | ||
test_cursor.plot, 10, 10 | ||
) | ||
|
||
@unittest.skipIf(ETSConfig.toolkit == "null", "Skip on 'null' toolkit") | ||
def test_use_with_linear_mappers(self): | ||
class TestCursor(HasTraits): | ||
plot = Instance(Plot) | ||
|
||
traits_view = View( | ||
Item('plot', editor=ComponentEditor(), show_label=False), | ||
width=500, | ||
height=500, | ||
resizable=True | ||
) | ||
|
||
def _plot_default(self): | ||
arr = np.logspace(0, 10, num=10) | ||
data = ArrayPlotData(x=arr, y=arr) | ||
plot = Plot(data) | ||
renderer = plot.plot( | ||
("x", "y"), | ||
)[0] | ||
|
||
cursor = CursorTool(renderer) | ||
|
||
renderer.overlays.append(cursor) | ||
|
||
return plot | ||
|
||
tester = UITester() | ||
test_cursor = TestCursor() | ||
with tester.create_ui(test_cursor): | ||
# should not fail | ||
self.mouse_move( | ||
test_cursor.plot, 10, 10 | ||
) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note this change is also made in #802
Both the changes to
BaseXYPlot1.map_screen
done there andLinearMapper.map_screen
here can cause the return type to be an an array of shape (N,2).