diff --git a/chaco/__init__.py b/chaco/__init__.py index 45df0b907..9f7fbac9e 100644 --- a/chaco/__init__.py +++ b/chaco/__init__.py @@ -9,3 +9,7 @@ __version__ = "not-built" __requires__ = ["traits", "traitsui", "pyface", "numpy", "enable"] + +__extras_require__ = { + 'examples': ['encore', 'scipy', 'pandas'] +} diff --git a/examples/demo/basic/__init__.py b/chaco/examples/__init__.py similarity index 100% rename from examples/demo/basic/__init__.py rename to chaco/examples/__init__.py diff --git a/chaco/examples/_etsdemo_info.py b/chaco/examples/_etsdemo_info.py new file mode 100644 index 000000000..e084da826 --- /dev/null +++ b/chaco/examples/_etsdemo_info.py @@ -0,0 +1,34 @@ +# (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! + +""" This module provides functions to be advertised in the distribution +entry points. +""" + +import pkg_resources + + +def info(request): + """ Return a configuration for contributing examples to the + Demo application. + Parameters + ---------- + request : dict + Information provided by the demo application. + Currently this is a placeholder. + Returns + ------- + response : dict + """ + return { + "version": 1, + "name": "Chaco Examples", + "root": pkg_resources.resource_filename("chaco.examples", "demo"), + } diff --git a/examples/demo/financial/__init__.py b/chaco/examples/demo/__init__.py similarity index 100% rename from examples/demo/financial/__init__.py rename to chaco/examples/demo/__init__.py diff --git a/chaco/examples/demo/advanced/__init__.py b/chaco/examples/demo/advanced/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/examples/demo/advanced/asynchronous_updates.py b/chaco/examples/demo/advanced/asynchronous_updates.py similarity index 100% rename from examples/demo/advanced/asynchronous_updates.py rename to chaco/examples/demo/advanced/asynchronous_updates.py diff --git a/examples/demo/advanced/cmap_variable_sized_scatter.py b/chaco/examples/demo/advanced/cmap_variable_sized_scatter.py similarity index 100% rename from examples/demo/advanced/cmap_variable_sized_scatter.py rename to chaco/examples/demo/advanced/cmap_variable_sized_scatter.py diff --git a/examples/demo/advanced/data_cube.py b/chaco/examples/demo/advanced/data_cube.py similarity index 96% rename from examples/demo/advanced/data_cube.py rename to chaco/examples/demo/advanced/data_cube.py index 396e7af04..5d27ccb7a 100644 --- a/examples/demo/advanced/data_cube.py +++ b/chaco/examples/demo/advanced/data_cube.py @@ -6,13 +6,6 @@ import warnings -# Outstanding TODOs: -# - need to add line inspectors to side and bottom plots, and synchronize -# with center plot -# - need to set the various image plots to use the same colormap instance, -# and that colormap's range needs to be set to min/max of the entire cube -# - refactor create_window() so there is less code duplication -# - try to eliminate the use of model.xs, ys, zs in favor of bounds tuples from numpy import amin, amax, zeros, fromfile, transpose, uint8 # Standard library imports @@ -192,7 +185,7 @@ def normal_mouse_wheel(self, event): self.wheel_cb(self, event.mouse_wheel) -class PlotFrame(DemoFrame): +class Demo(DemoFrame): # These are the indices into the cube that each of the image plot views # will show; the default values are non-zero just to make it a little @@ -466,6 +459,6 @@ def cleanup_data(): if __name__ == "__main__": # Save demo so that it doesn't get garbage collected when run within # existing event loop (i.e. from ipython). - demo = demo_main(PlotFrame, size=(800, 700), title="Cube analyzer") + demo = demo_main(Demo, size=(800, 700), title="Cube analyzer") if run_cleanup: cleanup_data() diff --git a/examples/demo/advanced/data_stream.py b/chaco/examples/demo/advanced/data_stream.py similarity index 100% rename from examples/demo/advanced/data_stream.py rename to chaco/examples/demo/advanced/data_stream.py diff --git a/examples/demo/advanced/scalar_image_function_inspector.py b/chaco/examples/demo/advanced/scalar_image_function_inspector.py similarity index 97% rename from examples/demo/advanced/scalar_image_function_inspector.py rename to chaco/examples/demo/advanced/scalar_image_function_inspector.py index 246ef44fd..772626424 100644 --- a/examples/demo/advanced/scalar_image_function_inspector.py +++ b/chaco/examples/demo/advanced/scalar_image_function_inspector.py @@ -454,8 +454,8 @@ class TimerController(HasTraits): # The plot view which will be affected by timed animation view = Instance(PlotUI) - # The ModelView instance that contains the animation options: - model_view = Instance("ModelView") + # The DemoModelView instance that contains the animation options: + model_view = Instance("DemoModelView") # Whether the view is animated: animated = DelegatesTo("model_view") @@ -556,7 +556,7 @@ def randomize(new_direction=1, color_change=False): metadata["selections"] = x, y -class ModelView(HasTraits): +class DemoModelView(HasTraits): model = Instance(Model) view = Instance(PlotUI) @@ -614,19 +614,15 @@ def _start_timer(self): def edit_traits(self, *args, **kws): self._start_timer() - return super(ModelView, self).edit_traits(*args, **kws) + return super(DemoModelView, self).edit_traits(*args, **kws) def configure_traits(self, *args, **kws): self._start_timer() - return super(ModelView, self).configure_traits(*args, **kws) + return super(DemoModelView, self).configure_traits(*args, **kws) -def show_plot(**kwargs): - model = Model(**kwargs) - view = PlotUI(**kwargs) - modelview = ModelView(model=model, view=view) - modelview.configure_traits() +demo = DemoModelView(model=Model(), view=PlotUI()) if __name__ == "__main__": - show_plot() + demo.configure_traits() diff --git a/chaco/examples/demo/basic/__init__.py b/chaco/examples/demo/basic/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/examples/demo/basic/bar_plot_configurable.py b/chaco/examples/demo/basic/bar_plot_configurable.py similarity index 100% rename from examples/demo/basic/bar_plot_configurable.py rename to chaco/examples/demo/basic/bar_plot_configurable.py diff --git a/examples/demo/basic/bar_plot_stacked.py b/chaco/examples/demo/basic/bar_plot_stacked.py similarity index 100% rename from examples/demo/basic/bar_plot_stacked.py rename to chaco/examples/demo/basic/bar_plot_stacked.py diff --git a/examples/demo/basic/bounded_grids.py b/chaco/examples/demo/basic/bounded_grids.py similarity index 100% rename from examples/demo/basic/bounded_grids.py rename to chaco/examples/demo/basic/bounded_grids.py diff --git a/examples/demo/basic/candle.py b/chaco/examples/demo/basic/candle.py similarity index 100% rename from examples/demo/basic/candle.py rename to chaco/examples/demo/basic/candle.py diff --git a/examples/demo/basic/capitol.jpg b/chaco/examples/demo/basic/capitol.jpg similarity index 100% rename from examples/demo/basic/capitol.jpg rename to chaco/examples/demo/basic/capitol.jpg diff --git a/examples/demo/basic/cat.jpg b/chaco/examples/demo/basic/cat.jpg similarity index 100% rename from examples/demo/basic/cat.jpg rename to chaco/examples/demo/basic/cat.jpg diff --git a/examples/demo/basic/cmap_image_aspect_ratio.py b/chaco/examples/demo/basic/cmap_image_aspect_ratio.py similarity index 100% rename from examples/demo/basic/cmap_image_aspect_ratio.py rename to chaco/examples/demo/basic/cmap_image_aspect_ratio.py diff --git a/examples/demo/basic/cmap_image_plot.py b/chaco/examples/demo/basic/cmap_image_plot.py similarity index 100% rename from examples/demo/basic/cmap_image_plot.py rename to chaco/examples/demo/basic/cmap_image_plot.py diff --git a/examples/demo/basic/cmap_image_select.py b/chaco/examples/demo/basic/cmap_image_select.py similarity index 100% rename from examples/demo/basic/cmap_image_select.py rename to chaco/examples/demo/basic/cmap_image_select.py diff --git a/examples/demo/basic/cmap_scatter.py b/chaco/examples/demo/basic/cmap_scatter.py similarity index 100% rename from examples/demo/basic/cmap_scatter.py rename to chaco/examples/demo/basic/cmap_scatter.py diff --git a/examples/demo/basic/cmap_segment_plot.py b/chaco/examples/demo/basic/cmap_segment_plot.py similarity index 100% rename from examples/demo/basic/cmap_segment_plot.py rename to chaco/examples/demo/basic/cmap_segment_plot.py diff --git a/examples/demo/basic/contour_cmap_plot.py b/chaco/examples/demo/basic/contour_cmap_plot.py similarity index 100% rename from examples/demo/basic/contour_cmap_plot.py rename to chaco/examples/demo/basic/contour_cmap_plot.py diff --git a/examples/demo/basic/contour_plot.py b/chaco/examples/demo/basic/contour_plot.py similarity index 100% rename from examples/demo/basic/contour_plot.py rename to chaco/examples/demo/basic/contour_plot.py diff --git a/examples/demo/basic/discrete_cmap_image_plot.py b/chaco/examples/demo/basic/discrete_cmap_image_plot.py similarity index 100% rename from examples/demo/basic/discrete_cmap_image_plot.py rename to chaco/examples/demo/basic/discrete_cmap_image_plot.py diff --git a/examples/demo/basic/discrete_cmap_scatter.py b/chaco/examples/demo/basic/discrete_cmap_scatter.py similarity index 100% rename from examples/demo/basic/discrete_cmap_scatter.py rename to chaco/examples/demo/basic/discrete_cmap_scatter.py diff --git a/examples/demo/basic/draw_layers.py b/chaco/examples/demo/basic/draw_layers.py similarity index 100% rename from examples/demo/basic/draw_layers.py rename to chaco/examples/demo/basic/draw_layers.py diff --git a/examples/demo/basic/grid_container.py b/chaco/examples/demo/basic/grid_container.py similarity index 100% rename from examples/demo/basic/grid_container.py rename to chaco/examples/demo/basic/grid_container.py diff --git a/examples/demo/basic/grid_container_aspect_ratio.py b/chaco/examples/demo/basic/grid_container_aspect_ratio.py similarity index 100% rename from examples/demo/basic/grid_container_aspect_ratio.py rename to chaco/examples/demo/basic/grid_container_aspect_ratio.py diff --git a/examples/demo/basic/hittest_tool.py b/chaco/examples/demo/basic/hittest_tool.py similarity index 100% rename from examples/demo/basic/hittest_tool.py rename to chaco/examples/demo/basic/hittest_tool.py diff --git a/examples/demo/basic/horizon_plot.py b/chaco/examples/demo/basic/horizon_plot.py similarity index 97% rename from examples/demo/basic/horizon_plot.py rename to chaco/examples/demo/basic/horizon_plot.py index 8c9f890c7..9f199536b 100644 --- a/examples/demo/basic/horizon_plot.py +++ b/chaco/examples/demo/basic/horizon_plot.py @@ -186,11 +186,9 @@ class Demo(HasTraits): ) -demo = Demo() +filled, horizon = _create_plot_components() +demo = Demo(horizon=horizon, filled=filled) -if __name__ == "__main__": - filled, horizon = _create_plot_components() - demo.horizon = horizon - demo.filled = filled +if __name__ == "__main__": demo.configure_traits() diff --git a/examples/demo/basic/image_LICENSE.txt b/chaco/examples/demo/basic/image_LICENSE.txt similarity index 100% rename from examples/demo/basic/image_LICENSE.txt rename to chaco/examples/demo/basic/image_LICENSE.txt diff --git a/examples/demo/basic/image_from_file.py b/chaco/examples/demo/basic/image_from_file.py similarity index 100% rename from examples/demo/basic/image_from_file.py rename to chaco/examples/demo/basic/image_from_file.py diff --git a/examples/demo/basic/image_inspector.py b/chaco/examples/demo/basic/image_inspector.py similarity index 100% rename from examples/demo/basic/image_inspector.py rename to chaco/examples/demo/basic/image_inspector.py diff --git a/examples/demo/basic/image_lasso.py b/chaco/examples/demo/basic/image_lasso.py similarity index 100% rename from examples/demo/basic/image_lasso.py rename to chaco/examples/demo/basic/image_lasso.py diff --git a/examples/demo/basic/image_plot.py b/chaco/examples/demo/basic/image_plot.py similarity index 100% rename from examples/demo/basic/image_plot.py rename to chaco/examples/demo/basic/image_plot.py diff --git a/examples/demo/basic/inset_plot.py b/chaco/examples/demo/basic/inset_plot.py similarity index 100% rename from examples/demo/basic/inset_plot.py rename to chaco/examples/demo/basic/inset_plot.py diff --git a/examples/demo/basic/line_drawing.py b/chaco/examples/demo/basic/line_drawing.py similarity index 100% rename from examples/demo/basic/line_drawing.py rename to chaco/examples/demo/basic/line_drawing.py diff --git a/examples/demo/basic/line_plot1.py b/chaco/examples/demo/basic/line_plot1.py similarity index 100% rename from examples/demo/basic/line_plot1.py rename to chaco/examples/demo/basic/line_plot1.py diff --git a/examples/demo/basic/line_plot_hold.py b/chaco/examples/demo/basic/line_plot_hold.py similarity index 100% rename from examples/demo/basic/line_plot_hold.py rename to chaco/examples/demo/basic/line_plot_hold.py diff --git a/examples/demo/basic/log_plot.py b/chaco/examples/demo/basic/log_plot.py similarity index 100% rename from examples/demo/basic/log_plot.py rename to chaco/examples/demo/basic/log_plot.py diff --git a/examples/demo/basic/minard_napoleon.py b/chaco/examples/demo/basic/minard_napoleon.py similarity index 100% rename from examples/demo/basic/minard_napoleon.py rename to chaco/examples/demo/basic/minard_napoleon.py diff --git a/examples/demo/basic/minor_ticks_axis.py b/chaco/examples/demo/basic/minor_ticks_axis.py similarity index 98% rename from examples/demo/basic/minor_ticks_axis.py rename to chaco/examples/demo/basic/minor_ticks_axis.py index 06dc046df..8189a70a4 100644 --- a/examples/demo/basic/minor_ticks_axis.py +++ b/chaco/examples/demo/basic/minor_ticks_axis.py @@ -57,6 +57,8 @@ def _plot_default(self): return plot +demo = MinorTickDemo() + + if __name__ == "__main__": - demo = MinorTickDemo() demo.configure_traits() diff --git a/examples/demo/basic/nans_plot.py b/chaco/examples/demo/basic/nans_plot.py similarity index 100% rename from examples/demo/basic/nans_plot.py rename to chaco/examples/demo/basic/nans_plot.py diff --git a/examples/demo/basic/pandas_data.py b/chaco/examples/demo/basic/pandas_data.py similarity index 100% rename from examples/demo/basic/pandas_data.py rename to chaco/examples/demo/basic/pandas_data.py diff --git a/examples/demo/basic/polygon_move.py b/chaco/examples/demo/basic/polygon_move.py similarity index 100% rename from examples/demo/basic/polygon_move.py rename to chaco/examples/demo/basic/polygon_move.py diff --git a/examples/demo/basic/polygon_plot_demo.py b/chaco/examples/demo/basic/polygon_plot_demo.py similarity index 100% rename from examples/demo/basic/polygon_plot_demo.py rename to chaco/examples/demo/basic/polygon_plot_demo.py diff --git a/examples/demo/basic/regression.py b/chaco/examples/demo/basic/regression.py similarity index 100% rename from examples/demo/basic/regression.py rename to chaco/examples/demo/basic/regression.py diff --git a/examples/demo/basic/scatter.py b/chaco/examples/demo/basic/scatter.py similarity index 100% rename from examples/demo/basic/scatter.py rename to chaco/examples/demo/basic/scatter.py diff --git a/examples/demo/basic/scatter_1d.py b/chaco/examples/demo/basic/scatter_1d.py similarity index 100% rename from examples/demo/basic/scatter_1d.py rename to chaco/examples/demo/basic/scatter_1d.py diff --git a/examples/demo/basic/scatter_alpha.py b/chaco/examples/demo/basic/scatter_alpha.py similarity index 100% rename from examples/demo/basic/scatter_alpha.py rename to chaco/examples/demo/basic/scatter_alpha.py diff --git a/examples/demo/basic/scatter_custom_marker.py b/chaco/examples/demo/basic/scatter_custom_marker.py similarity index 100% rename from examples/demo/basic/scatter_custom_marker.py rename to chaco/examples/demo/basic/scatter_custom_marker.py diff --git a/examples/demo/basic/scatter_inspector.py b/chaco/examples/demo/basic/scatter_inspector.py similarity index 100% rename from examples/demo/basic/scatter_inspector.py rename to chaco/examples/demo/basic/scatter_inspector.py diff --git a/examples/demo/basic/scatter_inspector2.py b/chaco/examples/demo/basic/scatter_inspector2.py similarity index 62% rename from examples/demo/basic/scatter_inspector2.py rename to chaco/examples/demo/basic/scatter_inspector2.py index a1f2a6ef8..6703e64b7 100644 --- a/examples/demo/basic/scatter_inspector2.py +++ b/chaco/examples/demo/basic/scatter_inspector2.py @@ -54,42 +54,40 @@ def show_data(data_idx): return show_data -if __name__ == "__main__": +def _create_plot_component(): + # Create a fake dataset from which 2 dimensions will be displayed in a + # scatter plot: + x = np.random.uniform(0.0, 10.0, 50) + y = np.random.uniform(0.0, 5.0, 50) + data = pd.DataFrame( + {"x": x, "y": y, "dataset": np.random.choice(list("abcdefg"), 50)} + ) + plot_data = ArrayPlotData(x=x, y=y) + plot = Plot(plot_data) + scatter = plot.plot(("x", "y"), type="scatter")[0] + + # Attach the inspector and its overlays + inspector = DataframeScatterInspector(component=scatter, data=data) + scatter.tools.append(inspector) + + text_overlay = DataframeScatterOverlay( + component=plot, + inspector=inspector, + bgcolor="black", + alpha=0.6, + text_color="white", + border_color="none", + ) + plot.overlays.append(text_overlay) - def _create_plot_component(): - # Create a fake dataset from which 2 dimensions will be displayed in a - # scatter plot: - x = np.random.uniform(0.0, 10.0, 50) - y = np.random.uniform(0.0, 5.0, 50) - data = pd.DataFrame( - {"x": x, "y": y, "dataset": np.random.choice(list("abcdefg"), 50)} - ) - plot_data = ArrayPlotData(x=x, y=y) - plot = Plot(plot_data) - scatter = plot.plot(("x", "y"), type="scatter")[0] - - # Attach the inspector and its overlays - inspector = DataframeScatterInspector(component=scatter, data=data) - scatter.tools.append(inspector) - - text_overlay = DataframeScatterOverlay( - component=plot, - inspector=inspector, - bgcolor="black", - alpha=0.6, - text_color="white", - border_color="none", - ) - plot.overlays.append(text_overlay) - - # Optional: add an overlay on the point to confirm what is hovered over - # Note that this overlay magically knows about hovered points by - # listening to renderer events rather than inspector events: - point_overlay = ScatterInspectorOverlay( - component=scatter, hover_color="red", hover_marker_size=6 - ) - scatter.overlays.append(point_overlay) - return plot + # Optional: add an overlay on the point to confirm what is hovered over + # Note that this overlay magically knows about hovered points by + # listening to renderer events rather than inspector events: + point_overlay = ScatterInspectorOverlay( + component=scatter, hover_color="red", hover_marker_size=6 + ) + scatter.overlays.append(point_overlay) + return plot # ============================================================================= diff --git a/examples/demo/basic/scatter_rect_select.py b/chaco/examples/demo/basic/scatter_rect_select.py similarity index 100% rename from examples/demo/basic/scatter_rect_select.py rename to chaco/examples/demo/basic/scatter_rect_select.py diff --git a/examples/demo/basic/scatter_select.py b/chaco/examples/demo/basic/scatter_select.py similarity index 100% rename from examples/demo/basic/scatter_select.py rename to chaco/examples/demo/basic/scatter_select.py diff --git a/examples/demo/basic/scatter_toggle.py b/chaco/examples/demo/basic/scatter_toggle.py similarity index 100% rename from examples/demo/basic/scatter_toggle.py rename to chaco/examples/demo/basic/scatter_toggle.py diff --git a/examples/demo/basic/scatter_variable_size.py b/chaco/examples/demo/basic/scatter_variable_size.py similarity index 100% rename from examples/demo/basic/scatter_variable_size.py rename to chaco/examples/demo/basic/scatter_variable_size.py diff --git a/examples/demo/basic/scrollbar.py b/chaco/examples/demo/basic/scrollbar.py similarity index 100% rename from examples/demo/basic/scrollbar.py rename to chaco/examples/demo/basic/scrollbar.py diff --git a/examples/demo/basic/segment_plot.py b/chaco/examples/demo/basic/segment_plot.py similarity index 100% rename from examples/demo/basic/segment_plot.py rename to chaco/examples/demo/basic/segment_plot.py diff --git a/examples/demo/basic/tabbed_plots.py b/chaco/examples/demo/basic/tabbed_plots.py similarity index 100% rename from examples/demo/basic/tabbed_plots.py rename to chaco/examples/demo/basic/tabbed_plots.py diff --git a/examples/demo/basic/zoomable_colorbar.py b/chaco/examples/demo/basic/zoomable_colorbar.py similarity index 100% rename from examples/demo/basic/zoomable_colorbar.py rename to chaco/examples/demo/basic/zoomable_colorbar.py diff --git a/examples/demo/bigdata.py b/chaco/examples/demo/bigdata.py similarity index 100% rename from examples/demo/bigdata.py rename to chaco/examples/demo/bigdata.py diff --git a/examples/demo/chaco_trait_editor.py b/chaco/examples/demo/chaco_trait_editor.py similarity index 95% rename from examples/demo/chaco_trait_editor.py rename to chaco/examples/demo/chaco_trait_editor.py index d25365525..413a95d95 100644 --- a/examples/demo/chaco_trait_editor.py +++ b/chaco/examples/demo/chaco_trait_editor.py @@ -3,7 +3,7 @@ interval. """ - +from traits.api import HasTraits from traits.etsconfig.api import ETSConfig if ETSConfig.toolkit == "wx": @@ -11,7 +11,7 @@ else: from traitsui.qt4.editor import Editor -from traitsui.api import EditorFactory +from traitsui.api import EditorFactory, Item, View from enable.api import ColorTrait, Window @@ -173,18 +173,15 @@ def update_editor(self): IntervalEditor = IntervalEditorFactory -# --- Demonstration --- - -if __name__ == "__main__": - from traits.api import HasTraits - from traitsui.api import View, Item - - class IntervalTest(HasTraits): +class IntervalTest(HasTraits): interval = Interval(low=0, high=1) traits_view = View( Item("interval", editor=IntervalEditor()), resizable=True ) - it = IntervalTest() - it.configure_traits() + +demo = IntervalTest() + +if __name__ == "__main__": + demo.configure_traits() diff --git a/examples/demo/coordinate_line_overlay_demo.py b/chaco/examples/demo/coordinate_line_overlay_demo.py similarity index 100% rename from examples/demo/coordinate_line_overlay_demo.py rename to chaco/examples/demo/coordinate_line_overlay_demo.py diff --git a/examples/demo/cursor_tool_demo.py b/chaco/examples/demo/cursor_tool_demo.py similarity index 100% rename from examples/demo/cursor_tool_demo.py rename to chaco/examples/demo/cursor_tool_demo.py diff --git a/examples/demo/data_labels.py b/chaco/examples/demo/data_labels.py similarity index 100% rename from examples/demo/data_labels.py rename to chaco/examples/demo/data_labels.py diff --git a/examples/demo/data_view.py b/chaco/examples/demo/data_view.py similarity index 100% rename from examples/demo/data_view.py rename to chaco/examples/demo/data_view.py diff --git a/examples/demo/edit_line.py b/chaco/examples/demo/edit_line.py similarity index 100% rename from examples/demo/edit_line.py rename to chaco/examples/demo/edit_line.py diff --git a/chaco/examples/demo/financial/__init__.py b/chaco/examples/demo/financial/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/examples/demo/financial/correlations.py b/chaco/examples/demo/financial/correlations.py similarity index 100% rename from examples/demo/financial/correlations.py rename to chaco/examples/demo/financial/correlations.py diff --git a/examples/demo/financial/stock_prices.py b/chaco/examples/demo/financial/stock_prices.py similarity index 98% rename from examples/demo/financial/stock_prices.py rename to chaco/examples/demo/financial/stock_prices.py index 16f91dec0..cc9a7ebc7 100644 --- a/examples/demo/financial/stock_prices.py +++ b/chaco/examples/demo/financial/stock_prices.py @@ -60,7 +60,7 @@ def create_dates(numpoints, units="days"): return dates -class PlotFrame(DemoFrame): +class Demo(DemoFrame): def _create_price_plots(self, times, prices, mini_height=75): """Creates the two plots of prices and returns them. One of the plots can be zoomed and panned, and the other plot (smaller) always @@ -221,5 +221,5 @@ def _create_component(self): # Save demo so that it doesn't get garbage collected when run within # existing event loop (i.e. from ipython). demo = demo_main( - PlotFrame, size=(800, 600), title="Stock price and volume" + Demo, size=(800, 600), title="Stock price and volume" ) diff --git a/examples/demo/functionplotter.py b/chaco/examples/demo/functionplotter.py similarity index 100% rename from examples/demo/functionplotter.py rename to chaco/examples/demo/functionplotter.py diff --git a/examples/demo/hyetograph.py b/chaco/examples/demo/hyetograph.py similarity index 93% rename from examples/demo/hyetograph.py rename to chaco/examples/demo/hyetograph.py index 8ca85f282..047ac7180 100644 --- a/examples/demo/hyetograph.py +++ b/chaco/examples/demo/hyetograph.py @@ -1,6 +1,7 @@ from chaco.api import ArrayPlotData, Plot from enable.api import ComponentEditor from traits.api import ( + Bool, HasTraits, Instance, Int, @@ -43,6 +44,12 @@ class Hyetograph(HasTraits): nrcs_plot = Instance(Plot) + initialized = Bool(False) + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.initialized = True + def _intensity_plot_default(self): intensity_plot = Plot(ArrayPlotData(x=self.timeline, y=self.intensity)) intensity_plot.x_axis.title = "Time (hr)" @@ -104,7 +111,7 @@ def calculate_runoff(self): vr[i] = 0 self.nrcs = vr - @observe('duration, year_storm, county, curve_number') + @observe('duration, year_storm, county, curve_number, initialized') def _perform_calculations(self, event=None): self.calculate_intensity() self.calculate_runoff() @@ -126,10 +133,6 @@ def _update_polt_type(self, event): self.intensity_plot.invalidate_and_redraw() self.nrcs_plot.invalidate_and_redraw() - def start(self): - self._perform_calculations() - self.configure_traits() - traits_view = View( Item('plot_type'), Item("intensity_plot", editor=ComponentEditor()), @@ -144,6 +147,8 @@ def start(self): ) +popup = Hyetograph() + + if __name__ == "__main__": - hyetograph = Hyetograph() - hyetograph.start() + popup.configure_traits() diff --git a/examples/demo/image_plot_origin_and_orientation.py b/chaco/examples/demo/image_plot_origin_and_orientation.py similarity index 92% rename from examples/demo/image_plot_origin_and_orientation.py rename to chaco/examples/demo/image_plot_origin_and_orientation.py index 7802c3e28..5aed02c20 100644 --- a/examples/demo/image_plot_origin_and_orientation.py +++ b/chaco/examples/demo/image_plot_origin_and_orientation.py @@ -3,10 +3,11 @@ The origin parameter sets a plot's default origin to the specified corner of the plot window. These positions has the following behavior: - * 'left' : index increases left to right - * 'right' : index increases right to left - * 'top' : index increases top to bottom - * 'bottom' : index increases bottom to top + +* 'left' : index increases left to right +* 'right' : index increases right to left +* 'top' : index increases top to bottom +* 'bottom' : index increases bottom to top The orientation parameter switches the x- and y-axes. Alternatively, you can think of this as a transpose about the origin. diff --git a/examples/demo/multi_line_plot_demo.py b/chaco/examples/demo/multi_line_plot_demo.py similarity index 88% rename from examples/demo/multi_line_plot_demo.py rename to chaco/examples/demo/multi_line_plot_demo.py index e52946cdb..183341db0 100644 --- a/examples/demo/multi_line_plot_demo.py +++ b/chaco/examples/demo/multi_line_plot_demo.py @@ -138,23 +138,25 @@ def _offset_changed(self, off): self.multi_line_plot_renderer._amplitude_changed() +# Sample rate. +fs = 500 +# Total time. +T = 5.0 +num_samples = fs * T +t = np.arange(num_samples) / fs + +channels = np.arange(12) +# Frequencies of the sine functions in each channel. +freqs = 3 * (channels[:, None] + 1) +y = np.sin(freqs * t) + +# Create an instance of DataModel. This is the data to +# be plotted with a MultiLinePlot. +data = DataModel(x_index=t, y_index=channels, data=y) + +# Create the demo class, and show it. +demo = MultiLinePlotDemo(model=data) + + if __name__ == "__main__": - # Sample rate. - fs = 500 - # Total time. - T = 5.0 - num_samples = fs * T - t = np.arange(num_samples) / fs - - channels = np.arange(12) - # Frequencies of the sine functions in each channel. - freqs = 3 * (channels[:, None] + 1) - y = np.sin(freqs * t) - - # Create an instance of DataModel. This is the data to - # be plotted with a MultiLinePlot. - data = DataModel(x_index=t, y_index=channels, data=y) - - # Create the demo class, and show it. - demo = MultiLinePlotDemo(model=data) demo.configure_traits() diff --git a/examples/demo/nonlinear_color_mapping.py b/chaco/examples/demo/nonlinear_color_mapping.py similarity index 97% rename from examples/demo/nonlinear_color_mapping.py rename to chaco/examples/demo/nonlinear_color_mapping.py index b0849e0e3..492bec86c 100644 --- a/examples/demo/nonlinear_color_mapping.py +++ b/chaco/examples/demo/nonlinear_color_mapping.py @@ -272,11 +272,13 @@ def _colorbar_scale_changed(self): self.colorbar.index_mapper = new_mapper +grid = DataGrid( + func=lambda x, y: 3.0 ** (x ** 2 + 2 * (cos(2 * pi * y) - 1)), + domain_bounds=(0.0, 0.0, 2.0, 2.0), + grid_size=(200, 200), +) +demo = DataGridView(model=grid) + + if __name__ == "__main__": - grid = DataGrid( - func=lambda x, y: 3.0 ** (x ** 2 + 2 * (cos(2 * pi * y) - 1)), - domain_bounds=(0.0, 0.0, 2.0, 2.0), - grid_size=(200, 200), - ) - demo = DataGridView(model=grid) demo.configure_traits() diff --git a/examples/demo/qt_example.py b/chaco/examples/demo/qt_example.py similarity index 95% rename from examples/demo/qt_example.py rename to chaco/examples/demo/qt_example.py index d4b6ea8c0..26cf8c4d7 100644 --- a/examples/demo/qt_example.py +++ b/chaco/examples/demo/qt_example.py @@ -2,6 +2,9 @@ Example of how to directly embed Chaco into Qt widgets. The actual plot being created is drawn from the basic/line_plot1.py code. + +This demo is intended to be run standalone and will not work within the etsdemo +application. """ from traits.etsconfig.etsconfig import ETSConfig diff --git a/examples/demo/quiver.py b/chaco/examples/demo/quiver.py similarity index 100% rename from examples/demo/quiver.py rename to chaco/examples/demo/quiver.py diff --git a/examples/demo/range_selection_demo.py b/chaco/examples/demo/range_selection_demo.py similarity index 100% rename from examples/demo/range_selection_demo.py rename to chaco/examples/demo/range_selection_demo.py diff --git a/examples/demo/scales_test.py b/chaco/examples/demo/scales_test.py similarity index 100% rename from examples/demo/scales_test.py rename to chaco/examples/demo/scales_test.py diff --git a/examples/demo/simple_line.py b/chaco/examples/demo/simple_line.py similarity index 100% rename from examples/demo/simple_line.py rename to chaco/examples/demo/simple_line.py diff --git a/examples/demo/simple_polar.py b/chaco/examples/demo/simple_polar.py similarity index 100% rename from examples/demo/simple_polar.py rename to chaco/examples/demo/simple_polar.py diff --git a/examples/demo/stacked_axis.py b/chaco/examples/demo/stacked_axis.py similarity index 100% rename from examples/demo/stacked_axis.py rename to chaco/examples/demo/stacked_axis.py diff --git a/examples/demo/status_overlay.py b/chaco/examples/demo/status_overlay.py similarity index 96% rename from examples/demo/status_overlay.py rename to chaco/examples/demo/status_overlay.py index b5cb4b465..893ce5536 100644 --- a/examples/demo/status_overlay.py +++ b/chaco/examples/demo/status_overlay.py @@ -82,5 +82,8 @@ def clear_status(self): ) -my_plot = MyPlot() -my_plot.configure_traits() +demo = MyPlot() + + +if __name__ == '__main__': + demo.configure_traits() diff --git a/examples/demo/toolbar_plot.py b/chaco/examples/demo/toolbar_plot.py similarity index 100% rename from examples/demo/toolbar_plot.py rename to chaco/examples/demo/toolbar_plot.py diff --git a/examples/demo/tornado.py b/chaco/examples/demo/tornado.py similarity index 100% rename from examples/demo/tornado.py rename to chaco/examples/demo/tornado.py diff --git a/examples/demo/two_plots.py b/chaco/examples/demo/two_plots.py similarity index 100% rename from examples/demo/two_plots.py rename to chaco/examples/demo/two_plots.py diff --git a/examples/demo/vanderwaals.py b/chaco/examples/demo/vanderwaals.py similarity index 98% rename from examples/demo/vanderwaals.py rename to chaco/examples/demo/vanderwaals.py index 1ca4d8f59..af600fe21 100644 --- a/examples/demo/vanderwaals.py +++ b/chaco/examples/demo/vanderwaals.py @@ -97,6 +97,8 @@ def _update_plot_type(self, event): ) +popup = Data() + + if __name__ == '__main__': - viewer = Data() - viewer.configure_traits() + popup.configure_traits() diff --git a/examples/demo/vertical_plot.py b/chaco/examples/demo/vertical_plot.py similarity index 100% rename from examples/demo/vertical_plot.py rename to chaco/examples/demo/vertical_plot.py diff --git a/examples/demo/xray_plot.py b/chaco/examples/demo/xray_plot.py similarity index 98% rename from examples/demo/xray_plot.py rename to chaco/examples/demo/xray_plot.py index f606614c0..679bce4c2 100644 --- a/examples/demo/xray_plot.py +++ b/chaco/examples/demo/xray_plot.py @@ -172,5 +172,7 @@ def _plot_default(self): ) -example = PlotExample() -example.configure_traits() +demo = PlotExample() + +if __name__ == '__main__': + demo.configure_traits() diff --git a/chaco/examples/tests/__init__.py b/chaco/examples/tests/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/chaco/examples/tests/test_etsdemo_info.py b/chaco/examples/tests/test_etsdemo_info.py new file mode 100644 index 000000000..323fdf529 --- /dev/null +++ b/chaco/examples/tests/test_etsdemo_info.py @@ -0,0 +1,21 @@ +# (C) Copyright 2005-2020 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 os +import unittest + +from chaco.examples._etsdemo_info import info + + +class TestChacoETSDemoInfo(unittest.TestCase): + + def test_info(self): + # input to info is currently just a placeholder + response = info({}) + self.assertTrue(os.path.exists(response['root'])) diff --git a/examples/demo/demo.py b/examples/demo/demo.py deleted file mode 100644 index 2ecf5b7c4..000000000 --- a/examples/demo/demo.py +++ /dev/null @@ -1,23 +0,0 @@ -# ------------------------------------------------------------------------------- -# -# Copyright (c) 2009-2010, Enthought, Inc. -# All rights reserved. -# -# This software is provided without warranty under the terms of the BSD -# license included in enthought/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! -# -# Author: Vibha Srinivasan -# Date: 02/03/2009 -# -# ------------------------------------------------------------------------------- - -""" Run the Chaco demo. -""" - -from traitsui.extras.demo import demo - -demo(use_files=True, title="Chaco Demos") diff --git a/setup.py b/setup.py index 0e54adbac..d103c9824 100644 --- a/setup.py +++ b/setup.py @@ -280,6 +280,7 @@ def resolve_version(): __version__, _ = resolve_version() data = read_module('__init__') __requires__ = data['__requires__'] + __extras_require__ = data['__extras_require__'] numpy_include_dir = get_include() @@ -331,18 +332,25 @@ def resolve_version(): Topic :: Software Development Topic :: Software Development :: Libraries """.splitlines() if len(c.strip()) > 0], + entry_points={ + "etsdemo_data": [ + "chaco_examples = chaco.examples._etsdemo_info:info", + ] + }, package_data={ 'chaco': [ 'overlays/layers/data/*.svg', 'tests/data/PngSuite/*.png', 'tools/toolbars/images/*.png', - ] + ], + "chaco.examples": ["demo/*", "demo/*/*"], }, description='interactive 2-dimensional plotting', long_description=open('README.rst').read(), ext_modules=extensions, include_package_data=True, install_requires=__requires__, + extras_require=__extras_require__, license='BSD', packages=find_packages(), platforms=["Windows", "Linux", "Mac OS-X", "Unix", "Solaris"], diff --git a/tox.ini b/tox.ini index 6d99e8afb..6f43a21d5 100644 --- a/tox.ini +++ b/tox.ini @@ -114,77 +114,77 @@ exclude = chaco/scales/tests/test_scales.py chaco/scales/tests/test_formatters.py examples/demo/financial_plot.py - examples/demo/quiver.py - examples/demo/scales_test.py - examples/demo/qt_example.py - examples/demo/chaco_trait_editor.py + chaco/examples/demo/quiver.py + chaco/examples/demo/scales_test.py + chaco/examples/demo/qt_example.py + chaco/examples/demo/chaco_trait_editor.py examples/demo/multiaxis_using_Plot.py - examples/demo/vertical_plot.py - examples/demo/stacked_axis.py - examples/demo/simple_line.py - examples/demo/edit_line.py - examples/demo/bigdata.py - examples/demo/simple_polar.py - examples/demo/range_selection_demo.py + chaco/examples/demo/vertical_plot.py + chaco/examples/demo/stacked_axis.py + chaco/examples/demo/simple_line.py + chaco/examples/demo/edit_line.py + chaco/examples/demo/bigdata.py + chaco/examples/demo/simple_polar.py + chaco/examples/demo/range_selection_demo.py examples/demo/depth.py - examples/demo/multi_line_plot_demo.py - examples/demo/coordinate_line_overlay_demo.py - examples/demo/cursor_tool_demo.py - examples/demo/toolbar_plot.py + chaco/examples/demo/multi_line_plot_demo.py + chaco/examples/demo/coordinate_line_overlay_demo.py + chaco/examples/demo/cursor_tool_demo.py + chaco/examples/demo/toolbar_plot.py examples/demo/world_map.py examples/demo/financial_plot_dates.py - examples/demo/advanced/asynchronous_updates.py + chaco/examples/demo/advanced/asynchronous_updates.py examples/demo/advanced/spec_waterfall.py - examples/demo/advanced/data_cube.py - examples/demo/advanced/scalar_image_function_inspector.py + chaco/examples/demo/advanced/data_cube.py + chaco/examples/demo/advanced/scalar_image_function_inspector.py examples/demo/advanced/javascript_hover_tools.py - examples/demo/advanced/cmap_variable_sized_scatter.py + chaco/examples/demo/advanced/cmap_variable_sized_scatter.py examples/demo/zoomed_plot/wav_to_numeric.py examples/demo/zoomed_plot/zoom_overlay.py examples/demo/zoomed_plot/zoom_plot.py - examples/demo/financial/correlations.py - examples/demo/financial/stock_prices.py - examples/demo/basic/image_inspector.py - examples/demo/basic/draw_layers.py - examples/demo/basic/regression.py - examples/demo/basic/scatter_variable_size.py - examples/demo/basic/log_plot.py - examples/demo/basic/scatter_toggle.py - examples/demo/basic/scatter_1d.py - examples/demo/basic/cmap_image_plot.py - examples/demo/basic/scatter_alpha.py - examples/demo/basic/candle.py - examples/demo/basic/inset_plot.py - examples/demo/basic/nans_plot.py - examples/demo/basic/grid_container_aspect_ratio.py - examples/demo/basic/contour_plot.py - examples/demo/basic/image_lasso.py - examples/demo/basic/scatter_inspector.py - examples/demo/basic/discrete_cmap_scatter.py - examples/demo/basic/cmap_image_aspect_ratio.py - examples/demo/basic/bounded_grids.py - examples/demo/basic/segment_plot.py - examples/demo/basic/image_from_file.py - examples/demo/basic/scatter.py - examples/demo/basic/contour_cmap_plot.py - examples/demo/basic/line_plot_hold.py - examples/demo/basic/scatter_custom_marker.py - examples/demo/basic/cmap_segment_plot.py - examples/demo/basic/hittest_tool.py - examples/demo/basic/horizon_plot.py - examples/demo/basic/discrete_cmap_image_plot.py - examples/demo/basic/tabbed_plots.py - examples/demo/basic/cmap_image_select.py - examples/demo/basic/zoomable_colorbar.py - examples/demo/basic/polygon_move.py - examples/demo/basic/image_plot.py - examples/demo/basic/grid_container.py - examples/demo/basic/cmap_scatter.py - examples/demo/basic/scatter_inspector2.py - examples/demo/basic/line_plot1.py - examples/demo/basic/scatter_select.py - examples/demo/basic/line_drawing.py - examples/demo/basic/scrollbar.py + chaco/examples/demo/financial/correlations.py + chaco/examples/demo/financial/stock_prices.py + chaco/examples/demo/basic/image_inspector.py + chaco/examples/demo/basic/draw_layers.py + chaco/examples/demo/basic/regression.py + chaco/examples/demo/basic/scatter_variable_size.py + chaco/examples/demo/basic/log_plot.py + chaco/examples/demo/basic/scatter_toggle.py + chaco/examples/demo/basic/scatter_1d.py + chaco/examples/demo/basic/cmap_image_plot.py + chaco/examples/demo/basic/scatter_alpha.py + chaco/examples/demo/basic/candle.py + chaco/examples/demo/basic/inset_plot.py + chaco/examples/demo/basic/nans_plot.py + chaco/examples/demo/basic/grid_container_aspect_ratio.py + chaco/examples/demo/basic/contour_plot.py + chaco/examples/demo/basic/image_lasso.py + chaco/examples/demo/basic/scatter_inspector.py + chaco/examples/demo/basic/discrete_cmap_scatter.py + chaco/examples/demo/basic/cmap_image_aspect_ratio.py + chaco/examples/demo/basic/bounded_grids.py + chaco/examples/demo/basic/segment_plot.py + chaco/examples/demo/basic/image_from_file.py + chaco/examples/demo/basic/scatter.py + chaco/examples/demo/basic/contour_cmap_plot.py + chaco/examples/demo/basic/line_plot_hold.py + chaco/examples/demo/basic/scatter_custom_marker.py + chaco/examples/demo/basic/cmap_segment_plot.py + chaco/examples/demo/basic/hittest_tool.py + chaco/examples/demo/basic/horizon_plot.py + chaco/examples/demo/basic/discrete_cmap_image_plot.py + chaco/examples/demo/basic/tabbed_plots.py + chaco/examples/demo/basic/cmap_image_select.py + chaco/examples/demo/basic/zoomable_colorbar.py + chaco/examples/demo/basic/polygon_move.py + chaco/examples/demo/basic/image_plot.py + chaco/examples/demo/basic/grid_container.py + chaco/examples/demo/basic/cmap_scatter.py + chaco/examples/demo/basic/scatter_inspector2.py + chaco/examples/demo/basic/line_plot1.py + chaco/examples/demo/basic/scatter_select.py + chaco/examples/demo/basic/line_drawing.py + chaco/examples/demo/basic/scrollbar.py examples/demo/canvas/cliptest.py examples/demo/canvas/transient_plot_overlay.py examples/demo/canvas/axis_tool.py