From d4a7894412367b7d731760c9ba946f8806135f02 Mon Sep 17 00:00:00 2001 From: Alexandre Chabot-Leclerc Date: Sun, 14 Jul 2019 10:09:17 -0500 Subject: [PATCH 1/7] FIX: Circular import in toolbar_plot --- chaco/toolbar_plot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chaco/toolbar_plot.py b/chaco/toolbar_plot.py index bb26b2ad1..19d72dea5 100644 --- a/chaco/toolbar_plot.py +++ b/chaco/toolbar_plot.py @@ -1,4 +1,4 @@ -from chaco.api import Plot +from chaco.plot import Plot from chaco.tools.toolbars.plot_toolbar import PlotToolbar from traits.api import Type, DelegatesTo, Instance, Enum, \ on_trait_change From fe38e1eeb2dc6674a3b65596668a70d1a9919cee Mon Sep 17 00:00:00 2001 From: Alexandre Chabot-Leclerc Date: Sat, 13 Jul 2019 17:52:24 -0500 Subject: [PATCH 2/7] FIX: Fix circular import in transform_color_mapper The fix is to import ColorMapper directly from chaco.color_mapper --- chaco/transform_color_mapper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chaco/transform_color_mapper.py b/chaco/transform_color_mapper.py index 52acadff7..d547ed64e 100644 --- a/chaco/transform_color_mapper.py +++ b/chaco/transform_color_mapper.py @@ -1,6 +1,6 @@ from numpy import clip, isinf, ones_like, empty -from chaco.api import ColorMapper +from chaco.color_mapper import ColorMapper from traits.api import Trait, Callable, Tuple, Float, on_trait_change from .speedups import map_colors, map_colors_uint8 From b47a7dadc3742d43065d1164bfe4b90e9f6b9a09 Mon Sep 17 00:00:00 2001 From: Alexandre Chabot-Leclerc Date: Tue, 16 Jul 2019 09:55:12 -0500 Subject: [PATCH 3/7] Use explicit imports and remove unused in coommand --- chaco/shell/commands.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/chaco/shell/commands.py b/chaco/shell/commands.py index ccfeee66a..f6ae5271b 100644 --- a/chaco/shell/commands.py +++ b/chaco/shell/commands.py @@ -11,8 +11,7 @@ except ImportError: GetApp = lambda: None -from chaco.api import Plot, color_map_name_dict -from chaco.scales.api import ScaleSystem +from chaco.plot import Plot from chaco.tools.api import PanTool, ZoomTool # Note: these are imported to be exposed in the namespace. @@ -797,7 +796,7 @@ def save(filename="chacoplot.png", dpi=72, pagesize="letter", dest_box=None, uni print("Saved to", filename) elif ext in [".bmp", ".png", ".jpg"]: - from chaco.api import PlotGraphicsContext + from chaco.plot_graphics_context import PlotGraphicsContext gc = PlotGraphicsContext(tuple(p.outer_bounds), dpi=dpi) # temporarily turn off the backbuffer for offscreen rendering From 60c4345dd93c149fd4304fbf175de7c1944c76f0 Mon Sep 17 00:00:00 2001 From: Alexandre Chabot-Leclerc Date: Tue, 16 Jul 2019 09:57:51 -0500 Subject: [PATCH 4/7] Use direct imports everywhere --- chaco/function_image_data.py | 3 ++- chaco/layers/status_layer.py | 2 +- chaco/layers/svg_range_selection_overlay.py | 2 +- chaco/overlays/container_overlay.py | 2 +- chaco/overlays/coordinate_line_overlay.py | 2 +- chaco/overlays/databox.py | 2 +- chaco/shell/plot_maker.py | 5 +++-- chaco/shell/scaly_plot.py | 10 +++++++--- chaco/tools/dataprinter.py | 2 +- chaco/tools/draw_points_tool.py | 2 +- chaco/tools/highlight_tool.py | 2 +- chaco/tools/image_inspector_tool.py | 4 +++- chaco/tools/lasso_selection.py | 6 ++++-- chaco/tools/legend_highlighter.py | 2 +- chaco/tools/line_inspector.py | 3 ++- chaco/tools/line_segment_tool.py | 2 +- chaco/tools/range_selection.py | 2 +- chaco/tools/range_selection_overlay.py | 5 ++++- chaco/tools/regression_lasso.py | 5 +++-- chaco/tools/save_tool.py | 2 +- chaco/tools/tracking_pan_tool.py | 2 +- chaco/tools/traits_tool.py | 3 ++- chaco/ui/popupable_plot.py | 2 +- 23 files changed, 44 insertions(+), 28 deletions(-) diff --git a/chaco/function_image_data.py b/chaco/function_image_data.py index b4947b7fd..de239cac5 100644 --- a/chaco/function_image_data.py +++ b/chaco/function_image_data.py @@ -1,6 +1,7 @@ from numpy import array from traits.api import Instance, Callable, on_trait_change -from chaco.api import DataRange2D, ImageData +from .data_range_2d import DataRange2D +from .image_data import ImageData # Adapted (ie. copied and modified) from function_data_source. diff --git a/chaco/layers/status_layer.py b/chaco/layers/status_layer.py index 16e885206..f254ff751 100644 --- a/chaco/layers/status_layer.py +++ b/chaco/layers/status_layer.py @@ -4,7 +4,7 @@ import os.path import xml.etree.cElementTree as etree -from chaco.api import AbstractOverlay +from chaco.abstract_overlay import AbstractOverlay from pyface.timer.timer import Timer from traits.api import Instance, Str, Enum, Float, Int from enable.savage.svg.document import SVGDocument diff --git a/chaco/layers/svg_range_selection_overlay.py b/chaco/layers/svg_range_selection_overlay.py index b484ba629..277845c78 100644 --- a/chaco/layers/svg_range_selection_overlay.py +++ b/chaco/layers/svg_range_selection_overlay.py @@ -4,7 +4,7 @@ import os import numpy -from chaco.api import GridMapper +from chaco.grid_mapper import GridMapper from traits.api import Property, Enum, Str, cached_property from .status_layer import StatusLayer diff --git a/chaco/overlays/container_overlay.py b/chaco/overlays/container_overlay.py index d89baabb0..a097a11c6 100644 --- a/chaco/overlays/container_overlay.py +++ b/chaco/overlays/container_overlay.py @@ -7,7 +7,7 @@ from traits.api import Instance from enable.api import Container, Component -from chaco.api import PlotComponent +from chaco.plot_component import PlotComponent class ContainerOverlay(Container, PlotComponent): diff --git a/chaco/overlays/coordinate_line_overlay.py b/chaco/overlays/coordinate_line_overlay.py index 7478df6a1..7139004f0 100644 --- a/chaco/overlays/coordinate_line_overlay.py +++ b/chaco/overlays/coordinate_line_overlay.py @@ -8,7 +8,7 @@ from traits.api import Instance, Float, Array from enable.api import black_color_trait, LineStyle, Component -from chaco.api import AbstractOverlay +from chaco.abstract_overlay import AbstractOverlay class CoordinateLineOverlay(AbstractOverlay): diff --git a/chaco/overlays/databox.py b/chaco/overlays/databox.py index 98333cf09..58d6f0946 100644 --- a/chaco/overlays/databox.py +++ b/chaco/overlays/databox.py @@ -4,7 +4,7 @@ from traits.api import (Bool, Enum, Float, Int, CList, Property, Trait, on_trait_change) from enable.api import ColorTrait -from chaco.api import AbstractOverlay +from chaco.abstract_overlay import AbstractOverlay class DataBox(AbstractOverlay): diff --git a/chaco/shell/plot_maker.py b/chaco/shell/plot_maker.py index ba8e63cff..d23e8a0de 100644 --- a/chaco/shell/plot_maker.py +++ b/chaco/shell/plot_maker.py @@ -13,8 +13,9 @@ from numpy import all, array, arange, asarray, reshape, shape, transpose # Chaco imports -from chaco.api import (create_line_plot, create_scatter_plot, - ArrayDataSource, ImageData) +from chaco.plot_factory import (create_line_plot, create_scatter_plot) +from chaco.array_data_source import ArrayDataSource +from chaco.image_data import ImageData from chaco.tools.api import HighlightTool diff --git a/chaco/shell/scaly_plot.py b/chaco/shell/scaly_plot.py index 6f27b0fa4..2f7bcb096 100644 --- a/chaco/shell/scaly_plot.py +++ b/chaco/shell/scaly_plot.py @@ -3,10 +3,14 @@ from traits.api import Any -from chaco.api import (DataRange2D, LinearMapper, LogMapper, - PlotGrid, Plot, PlotAxis) -from chaco.scales_tick_generator import ScalesTickGenerator +from chaco.axis import PlotAxis +from chaco.data_range_2d import DataRange2D +from chaco.grid import PlotGrid +from chaco.linear_mapper import LinearMapper +from chaco.log_mapper import LogMapper +from chaco.plot import Plot from chaco.scales.api import DefaultScale, LogScale, ScaleSystem +from chaco.scales_tick_generator import ScalesTickGenerator def add_default_axes(plot, orientation="normal", vtitle="", htitle=""): diff --git a/chaco/tools/dataprinter.py b/chaco/tools/dataprinter.py index ad4c01b3f..6a76ef629 100644 --- a/chaco/tools/dataprinter.py +++ b/chaco/tools/dataprinter.py @@ -8,7 +8,7 @@ from enable.api import BaseTool # Chaco imports -from chaco.api import BaseXYPlot +from chaco.base_xy_plot import BaseXYPlot class DataPrinter(BaseTool): diff --git a/chaco/tools/draw_points_tool.py b/chaco/tools/draw_points_tool.py index 00ecbdf61..cff84b797 100644 --- a/chaco/tools/draw_points_tool.py +++ b/chaco/tools/draw_points_tool.py @@ -8,7 +8,7 @@ from enable.api import BaseTool # Chaco import -from chaco.api import ArrayDataSource +from chaco.array_data_source import ArrayDataSource class DrawPointsTool(BaseTool): diff --git a/chaco/tools/highlight_tool.py b/chaco/tools/highlight_tool.py index e6cba592a..aa4204231 100644 --- a/chaco/tools/highlight_tool.py +++ b/chaco/tools/highlight_tool.py @@ -8,7 +8,7 @@ from enable.api import BaseTool # Chaco imports -from chaco.api import BasePlotContainer +from chaco.base_plot_container import BasePlotContainer class HighlightTool(BaseTool): diff --git a/chaco/tools/image_inspector_tool.py b/chaco/tools/image_inspector_tool.py index 6cae66da2..46573e348 100644 --- a/chaco/tools/image_inspector_tool.py +++ b/chaco/tools/image_inspector_tool.py @@ -6,7 +6,9 @@ from traits.api import Any, Bool, Enum, Event, Tuple # Chaco imports -from chaco.api import AbstractOverlay, ImagePlot, TextBoxOverlay +from chaco.abstract_overlay import AbstractOverlay +from chaco.image_plot import ImagePlot +from chaco.text_box_overlay import TextBoxOverlay class ImageInspectorTool(BaseTool): diff --git a/chaco/tools/lasso_selection.py b/chaco/tools/lasso_selection.py index a69ec5122..07bd6c4f7 100644 --- a/chaco/tools/lasso_selection.py +++ b/chaco/tools/lasso_selection.py @@ -10,8 +10,10 @@ from kiva.api import points_in_polygon # Chaco imports -from chaco.api import AbstractController, AbstractDataSource, \ - BaseXYPlot, Base2DPlot +from chaco.abstract_controller import AbstractController +from chaco.abstract_data_source import AbstractDataSource +from chaco.base_xy_plot import BaseXYPlot +from chaco.base_2d_plot import Base2DPlot class LassoSelection(AbstractController): diff --git a/chaco/tools/legend_highlighter.py b/chaco/tools/legend_highlighter.py index 5ad9c3579..8d1277858 100644 --- a/chaco/tools/legend_highlighter.py +++ b/chaco/tools/legend_highlighter.py @@ -1,7 +1,7 @@ from itertools import chain # ETS imports -from chaco.tools.api import LegendTool +from .legend_tool import LegendTool from traits.api import List, Float concat = chain.from_iterable diff --git a/chaco/tools/line_inspector.py b/chaco/tools/line_inspector.py index 2ae7c9be7..c1a09129e 100644 --- a/chaco/tools/line_inspector.py +++ b/chaco/tools/line_inspector.py @@ -7,7 +7,8 @@ from traits.api import Any, Bool, Enum, Float, Str, Trait # Chaco imports -from chaco.api import BaseXYPlot, Base2DPlot +from chaco.base_xy_plot import BaseXYPlot +from chaco.base_2d_plot import Base2DPlot class LineInspector(BaseTool): diff --git a/chaco/tools/line_segment_tool.py b/chaco/tools/line_segment_tool.py index 34913dd89..81ecfaeff 100644 --- a/chaco/tools/line_segment_tool.py +++ b/chaco/tools/line_segment_tool.py @@ -10,7 +10,7 @@ from traits.api import Any, Bool, Enum, Instance, Int, List, Trait, Tuple # Chaco imports -from chaco.api import AbstractOverlay +from chaco.abstract_overlay import AbstractOverlay diff --git a/chaco/tools/range_selection.py b/chaco/tools/range_selection.py index 3ec5c984a..b5b2f314a 100644 --- a/chaco/tools/range_selection.py +++ b/chaco/tools/range_selection.py @@ -9,7 +9,7 @@ from enable.api import KeySpec # Chaco imports -from chaco.api import AbstractController +from chaco.abstract_controller import AbstractController class RangeSelection(AbstractController): diff --git a/chaco/tools/range_selection_overlay.py b/chaco/tools/range_selection_overlay.py index 6eb1877a6..9d2ae8bb3 100644 --- a/chaco/tools/range_selection_overlay.py +++ b/chaco/tools/range_selection_overlay.py @@ -9,7 +9,10 @@ from enable.api import ColorTrait, LineStyle from traits.api import Enum, Float, Property, Str, Instance, \ cached_property -from chaco.api import AbstractOverlay, arg_find_runs, GridMapper, AbstractMapper +from chaco.abstract_overlay import AbstractOverlay +from chaco.base import arg_find_runs +from chaco.grid_mapper import GridMapper +from chaco.abstract_mapper import AbstractMapper class RangeSelectionOverlay(AbstractOverlay): diff --git a/chaco/tools/regression_lasso.py b/chaco/tools/regression_lasso.py index 12f59aff0..ed44d7bf2 100644 --- a/chaco/tools/regression_lasso.py +++ b/chaco/tools/regression_lasso.py @@ -11,8 +11,9 @@ from traits.api import Any, Float, Instance # Chaco imports -from chaco.api import LassoOverlay, Label -from chaco.tools.api import LassoSelection +from chaco.lasso_overlay import LassoOverlay +from chaco.label import Label +from .lasso_selection import LassoSelection class RegressionLasso(LassoSelection): diff --git a/chaco/tools/save_tool.py b/chaco/tools/save_tool.py index 2ec8a99b0..ad8abd7b6 100755 --- a/chaco/tools/save_tool.py +++ b/chaco/tools/save_tool.py @@ -56,7 +56,7 @@ def normal_key_pressed(self, event): def _save_raster(self): """ Saves an image of the component. """ - from chaco.api import PlotGraphicsContext + from chaco.plot_graphics_context import PlotGraphicsContext gc = PlotGraphicsContext((int(self.component.outer_width), int(self.component.outer_height))) self.component.draw(gc, mode="normal") gc.save(self.filename) diff --git a/chaco/tools/tracking_pan_tool.py b/chaco/tools/tracking_pan_tool.py index 3b888d965..55f279275 100644 --- a/chaco/tools/tracking_pan_tool.py +++ b/chaco/tools/tracking_pan_tool.py @@ -1,7 +1,7 @@ """ Defines the TrackingPanTool class. """ # Chaco imports -from chaco.tools.api import PanTool +from .pan_tool import PanTool class TrackingPanTool(PanTool): """ Allows the user to pan around a plot. diff --git a/chaco/tools/traits_tool.py b/chaco/tools/traits_tool.py index 8d84d70d1..4cfeb956a 100755 --- a/chaco/tools/traits_tool.py +++ b/chaco/tools/traits_tool.py @@ -6,7 +6,8 @@ from traits.api import List, Dict, Str # Chaco imports -from chaco.api import PlotAxis, ColorBar +from chaco.axis import PlotAxis +from chaco.color_bar import ColorBar class Fifo(object): diff --git a/chaco/ui/popupable_plot.py b/chaco/ui/popupable_plot.py index a2b8d0ad6..1ee944aa6 100644 --- a/chaco/ui/popupable_plot.py +++ b/chaco/ui/popupable_plot.py @@ -1,7 +1,7 @@ # Enthought library imports from traits.api import List -from chaco.api import VPlotContainer from chaco.plot import Plot +from chaco.plot_containers import VPlotContainer from chaco.tools.api import PanTool, ZoomTool from chaco.ui.plot_window import PlotWindow From be1a5d0a29fe9daba59f4107515b135ad39901e3 Mon Sep 17 00:00:00 2001 From: Alexandre Chabot-Leclerc Date: Tue, 16 Jul 2019 10:05:19 -0500 Subject: [PATCH 5/7] Explict imports for tools and scales --- chaco/selectable_legend.py | 2 +- chaco/shell/commands.py | 5 +++-- chaco/shell/plot_maker.py | 2 +- chaco/shell/scaly_plot.py | 2 +- chaco/ui/popupable_plot.py | 3 ++- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/chaco/selectable_legend.py b/chaco/selectable_legend.py index fb8b08769..0b7b946e7 100644 --- a/chaco/selectable_legend.py +++ b/chaco/selectable_legend.py @@ -1,5 +1,5 @@ -from chaco.tools.api import SelectTool +from chaco.tools.select_tool import SelectTool from traits.api import List from .legend import Legend diff --git a/chaco/shell/commands.py b/chaco/shell/commands.py index f6ae5271b..98eb0d7f4 100644 --- a/chaco/shell/commands.py +++ b/chaco/shell/commands.py @@ -12,10 +12,11 @@ GetApp = lambda: None from chaco.plot import Plot -from chaco.tools.api import PanTool, ZoomTool +from chaco.tools.pan_tool import PanTool +from chaco.tools.zoom_tool import ZoomTool # Note: these are imported to be exposed in the namespace. -from chaco.scales.api import (FixedScale, Pow10Scale, LogScale, +from chaco.scales.scales import (FixedScale, Pow10Scale, LogScale, CalendarScaleSystem) from chaco.default_colormaps import * diff --git a/chaco/shell/plot_maker.py b/chaco/shell/plot_maker.py index d23e8a0de..24d963bca 100644 --- a/chaco/shell/plot_maker.py +++ b/chaco/shell/plot_maker.py @@ -17,7 +17,7 @@ from chaco.array_data_source import ArrayDataSource from chaco.image_data import ImageData -from chaco.tools.api import HighlightTool +from chaco.tools.highlight_tool import HighlightTool diff --git a/chaco/shell/scaly_plot.py b/chaco/shell/scaly_plot.py index 2f7bcb096..43457c06f 100644 --- a/chaco/shell/scaly_plot.py +++ b/chaco/shell/scaly_plot.py @@ -9,7 +9,7 @@ from chaco.linear_mapper import LinearMapper from chaco.log_mapper import LogMapper from chaco.plot import Plot -from chaco.scales.api import DefaultScale, LogScale, ScaleSystem +from chaco.scales.scales import DefaultScale, LogScale, ScaleSystem from chaco.scales_tick_generator import ScalesTickGenerator diff --git a/chaco/ui/popupable_plot.py b/chaco/ui/popupable_plot.py index 1ee944aa6..0504d6289 100644 --- a/chaco/ui/popupable_plot.py +++ b/chaco/ui/popupable_plot.py @@ -2,7 +2,8 @@ from traits.api import List from chaco.plot import Plot from chaco.plot_containers import VPlotContainer -from chaco.tools.api import PanTool, ZoomTool +from chaco.tools.pan_tool import PanTool +from chaco.tools.zoom_tool import ZoomTool from chaco.ui.plot_window import PlotWindow from traitsui.wx.constants import WindowColor From 22aa61a056af34645290dbf862ce87135e4c9e9f Mon Sep 17 00:00:00 2001 From: Alexandre Chabot-Leclerc Date: Wed, 17 Jul 2019 14:00:45 -0500 Subject: [PATCH 6/7] FIX: Import of CalendarScaleSystem from time_scales --- chaco/shell/commands.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chaco/shell/commands.py b/chaco/shell/commands.py index 98eb0d7f4..16291637d 100644 --- a/chaco/shell/commands.py +++ b/chaco/shell/commands.py @@ -16,8 +16,8 @@ from chaco.tools.zoom_tool import ZoomTool # Note: these are imported to be exposed in the namespace. -from chaco.scales.scales import (FixedScale, Pow10Scale, LogScale, - CalendarScaleSystem) +from chaco.scales.scales import (FixedScale, Pow10Scale, LogScale) +from chaco.scales.time_scale import CalendarScaleSystem from chaco.default_colormaps import * from . import plot_maker From 0318d2d335d47ace9fa7064cd7b4e00305dd102f Mon Sep 17 00:00:00 2001 From: Alexandre Chabot-Leclerc Date: Wed, 17 Jul 2019 14:01:06 -0500 Subject: [PATCH 7/7] FIX: No relative imports from chaco in tests --- chaco/tests/test_default_colormaps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chaco/tests/test_default_colormaps.py b/chaco/tests/test_default_colormaps.py index d10dd14ab..210cc0a83 100644 --- a/chaco/tests/test_default_colormaps.py +++ b/chaco/tests/test_default_colormaps.py @@ -15,7 +15,7 @@ from numpy.testing import assert_array_equal, assert_array_almost_equal from chaco.api import DataRange1D -from .. import default_colormaps +from chaco import default_colormaps class DefaultColormapsTestCase(unittest.TestCase):