Skip to content
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

Python 3 compatibility fixes #369

Merged
merged 16 commits into from
Aug 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions chaco/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@

__requires__ = [
'enable',
'six'
]
2 changes: 1 addition & 1 deletion chaco/abstract_colormap.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"""
from traits.api import Enum, Event, HasTraits, Instance

from data_range_1d import DataRange1D
from .data_range_1d import DataRange1D

class AbstractColormap(HasTraits):
"""
Expand Down
2 changes: 1 addition & 1 deletion chaco/abstract_data_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from traits.api import Event, Float, HasTraits, Instance, List, Trait

# Local relative imports
from abstract_data_source import AbstractDataSource
from .abstract_data_source import AbstractDataSource


class AbstractDataRange(HasTraits):
Expand Down
4 changes: 2 additions & 2 deletions chaco/abstract_data_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from traits.api import Bool, Dict, Event, HasTraits

# Local relative imports
from base import DimensionTrait
from .base import DimensionTrait

class AbstractDataSource(HasTraits):
""" This abstract interface must be implemented by any class supplying data
Expand Down Expand Up @@ -124,7 +124,7 @@ def __getstate__(self):

# everything but 'metadata'
for key in ['value_dimension', 'index_dimension', 'persist_data']:
if state.has_key(key):
if key in state:
del state[key]

return state
Expand Down
2 changes: 1 addition & 1 deletion chaco/abstract_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def map_data_array(self, screen_vals):
def __getstate__(self):
state = super(AbstractMapper,self).__getstate__()
for key in ['_cache_valid']:
if state.has_key(key):
if key in state:
del state[key]

return state
Expand Down
2 changes: 1 addition & 1 deletion chaco/abstract_overlay.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from enable.api import Component
from traits.api import Instance

from plot_component import PlotComponent
from .plot_component import PlotComponent


class AbstractOverlay(PlotComponent):
Expand Down
2 changes: 1 addition & 1 deletion chaco/abstract_plot_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from traits.api import Enum

# Local relative imports
from plot_component import PlotComponent
from .plot_component import PlotComponent

class AbstractPlotRenderer(PlotComponent):
""" This is the minimal interface that all plot renderers must support.
Expand Down
152 changes: 76 additions & 76 deletions chaco/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,113 +3,113 @@
# This just imports the key datamodel classes into the top-level package
# namespace for convenience.

from base import NumericalSequenceTrait, PointTrait, ImageTrait, DimensionTrait, \
from .base import NumericalSequenceTrait, PointTrait, ImageTrait, DimensionTrait, \
SortOrderTrait, bin_search, reverse_map_1d, right_shift, \
left_shift, sort_points, find_runs, arg_find_runs, \
point_line_distance

# Data model
from abstract_data_source import AbstractDataSource
from array_data_source import ArrayDataSource
from grid_data_source import GridDataSource
from image_data import ImageData
from multi_array_data_source import MultiArrayDataSource
from point_data_source import PointDataSource
from abstract_data_range import AbstractDataRange
from base_data_range import BaseDataRange
from data_range_1d import DataRange1D
from data_range_2d import DataRange2D
from .abstract_data_source import AbstractDataSource
from .array_data_source import ArrayDataSource
from .grid_data_source import GridDataSource
from .image_data import ImageData
from .multi_array_data_source import MultiArrayDataSource
from .point_data_source import PointDataSource
from .abstract_data_range import AbstractDataRange
from .base_data_range import BaseDataRange
from .data_range_1d import DataRange1D
from .data_range_2d import DataRange2D

# Mappers
from abstract_mapper import AbstractMapper
from base_1d_mapper import Base1DMapper
from grid_mapper import GridMapper
from log_mapper import LogMapper
from linear_mapper import LinearMapper
from color_mapper import ColorMapper, ColorMapTemplate
from discrete_color_mapper import DiscreteColorMapper
from transform_color_mapper import TransformColorMapper
from .abstract_mapper import AbstractMapper
from .base_1d_mapper import Base1DMapper
from .grid_mapper import GridMapper
from .log_mapper import LogMapper
from .linear_mapper import LinearMapper
from .color_mapper import ColorMapper, ColorMapTemplate
from .discrete_color_mapper import DiscreteColorMapper
from .transform_color_mapper import TransformColorMapper

# Colormaps and color palettes
from default_colormaps import *
from default_colors import *
from .default_colormaps import *
from .default_colors import *

# Visual components
from abstract_plot_renderer import AbstractPlotRenderer
from abstract_overlay import AbstractOverlay
from base_plot_container import BasePlotContainer
from base_plot_frame import BasePlotFrame
from cross_plot_frame import CrossPlotFrame
from data_view import DataView
from simple_plot_frame import SimplePlotFrame
from plot_component import PlotComponent
from plot_graphics_context import PlotGraphicsContext, PlotGraphicsContextMixin
from selectable_overlay_container import SelectableOverlayPlotContainer
from plot_containers import OverlayPlotContainer, HPlotContainer, VPlotContainer, \
from .abstract_plot_renderer import AbstractPlotRenderer
from .abstract_overlay import AbstractOverlay
from .base_plot_container import BasePlotContainer
from .base_plot_frame import BasePlotFrame
from .cross_plot_frame import CrossPlotFrame
from .data_view import DataView
from .simple_plot_frame import SimplePlotFrame
from .plot_component import PlotComponent
from .plot_graphics_context import PlotGraphicsContext, PlotGraphicsContextMixin
from .selectable_overlay_container import SelectableOverlayPlotContainer
from .plot_containers import OverlayPlotContainer, HPlotContainer, VPlotContainer, \
GridPlotContainer
GridContainer = GridPlotContainer

from label import Label
from plot_label import PlotLabel
from legend import Legend
from tooltip import ToolTip
from data_label import DataLabel
from lasso_overlay import LassoOverlay
from color_bar import ColorBar
from text_box_overlay import TextBoxOverlay
from scatter_inspector_overlay import ScatterInspectorOverlay
from .label import Label
from .plot_label import PlotLabel
from .legend import Legend
from .tooltip import ToolTip
from .data_label import DataLabel
from .lasso_overlay import LassoOverlay
from .color_bar import ColorBar
from .text_box_overlay import TextBoxOverlay
from .scatter_inspector_overlay import ScatterInspectorOverlay

# Renderers
from barplot import BarPlot
from base_1d_plot import Base1DPlot
from base_2d_plot import Base2DPlot
from base_xy_plot import BaseXYPlot
from scatterplot import ScatterPlot, render_markers
from image_plot import ImagePlot
from cmap_image_plot import CMapImagePlot
from contour_line_plot import ContourLinePlot
from contour_poly_plot import ContourPolyPlot
from lineplot import LinePlot
from colormapped_scatterplot import ColormappedScatterPlot
from colormapped_selection_overlay import ColormappedSelectionOverlay
from polygon_plot import PolygonPlot
from errorbar_plot import ErrorBarPlot
from filled_line_plot import FilledLinePlot
from quiverplot import QuiverPlot
from candle_plot import CandlePlot
from multi_line_plot import MultiLinePlot
from jitterplot import JitterPlot
from variable_size_scatterplot import VariableSizeScatterPlot
from horizon_plot import BandedMapper, HorizonPlot
from scatterplot_1d import ScatterPlot1D
from line_scatterplot_1d import LineScatterPlot1D
from text_plot_1d import TextPlot1D
from .barplot import BarPlot
from .base_1d_plot import Base1DPlot
from .base_2d_plot import Base2DPlot
from .base_xy_plot import BaseXYPlot
from .scatterplot import ScatterPlot, render_markers
from .image_plot import ImagePlot
from .cmap_image_plot import CMapImagePlot
from .contour_line_plot import ContourLinePlot
from .contour_poly_plot import ContourPolyPlot
from .lineplot import LinePlot
from .colormapped_scatterplot import ColormappedScatterPlot
from .colormapped_selection_overlay import ColormappedSelectionOverlay
from .polygon_plot import PolygonPlot
from .errorbar_plot import ErrorBarPlot
from .filled_line_plot import FilledLinePlot
from .quiverplot import QuiverPlot
from .candle_plot import CandlePlot
from .multi_line_plot import MultiLinePlot
from .jitterplot import JitterPlot
from .variable_size_scatterplot import VariableSizeScatterPlot
from .horizon_plot import BandedMapper, HorizonPlot
from .scatterplot_1d import ScatterPlot1D
from .line_scatterplot_1d import LineScatterPlot1D
from .text_plot_1d import TextPlot1D

# Plot factories
from plot_factory import create_bar_plot, create_line_plot, create_scatter_plot, \
from .plot_factory import create_bar_plot, create_line_plot, create_scatter_plot, \
create_polar_plot, add_default_axes, add_default_grids

from abstract_plot_data import AbstractPlotData
from array_plot_data import ArrayPlotData
from data_frame_plot_data import DataFramePlotData
from plot import Plot
from toolbar_plot import ToolbarPlot
from .abstract_plot_data import AbstractPlotData
from .array_plot_data import ArrayPlotData
from .data_frame_plot_data import DataFramePlotData
from .plot import Plot
from .toolbar_plot import ToolbarPlot

# Axis
from axis import PlotAxis, MinorPlotAxis
from label_axis import LabelAxis
from ticks import AbstractTickGenerator, DefaultTickGenerator, auto_ticks, auto_interval, \
from .axis import PlotAxis, MinorPlotAxis
from .label_axis import LabelAxis
from .ticks import AbstractTickGenerator, DefaultTickGenerator, auto_ticks, auto_interval, \
tick_intervals, log_auto_ticks, auto_bounds, calc_bound

# Grid
from grid import PlotGrid
from .grid import PlotGrid

# Style stuff
#from stylable import Stylable
#from stylesheets import Style, StyleSheet

# Tools
from abstract_controller import AbstractController
from .abstract_controller import AbstractController

# Importing various symbols into the Chaco namespace for backwards
# compatibility. New code should directly import from Enable.
Expand Down
4 changes: 2 additions & 2 deletions chaco/array_data_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
from traits.api import Any, Constant, Int, Tuple

# Chaco imports
from base import NumericalSequenceTrait, reverse_map_1d, SortOrderTrait
from abstract_data_source import AbstractDataSource
from .base import NumericalSequenceTrait, reverse_map_1d, SortOrderTrait
from .abstract_data_source import AbstractDataSource


def bounded_nanargmin(arr):
Expand Down
9 changes: 5 additions & 4 deletions chaco/array_plot_data.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
""" Defines ArrayPlotData.
"""

import six
import six.moves as sm
from numpy import array, ndarray

# Enthought library imports
Expand Down Expand Up @@ -62,7 +63,7 @@ def __init__(self, *data, **kw):
"""
super(AbstractPlotData, self).__init__()
self._update_data(kw)
data = dict(zip(self._generate_names(len(data)), data))
data = dict(sm.zip(self._generate_names(len(data)), data))
self._update_data(data)


Expand All @@ -73,7 +74,7 @@ def __init__(self, *data, **kw):
def list_data(self):
""" Returns a list of the names of the arrays managed by this instance.
"""
return self.arrays.keys()
return list(self.arrays.keys())


def get_data(self, name):
Expand Down Expand Up @@ -189,7 +190,7 @@ def _update_data(self, data):
"""
# note that this call modifies data, but that's OK since the callers
# all create the dictionary that they pass in
for name, value in data.items():
for name, value in list(data.items()):
if not isinstance(value, (ndarray, AbstractDataSource)):
data[name] = array(value)
else:
Expand Down
18 changes: 9 additions & 9 deletions chaco/axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
Bool, Event, List, Array, Instance, Enum, Callable, ArrayOrNone

# Local relative imports
from ticks import AbstractTickGenerator, DefaultTickGenerator, MinorTickGenerator
from abstract_mapper import AbstractMapper
from abstract_overlay import AbstractOverlay
from label import Label
from log_mapper import LogMapper
from .ticks import AbstractTickGenerator, DefaultTickGenerator, MinorTickGenerator
from .abstract_mapper import AbstractMapper
from .abstract_overlay import AbstractOverlay
from .label import Label
from .log_mapper import LogMapper


def DEFAULT_TICK_FORMATTER(val):
Expand Down Expand Up @@ -196,7 +196,7 @@ def traits_view(self):
called automatically be the Traits framework when .edit_traits() is
invoked.
"""
from axis_view import AxisView
from .axis_view import AxisView
return AxisView


Expand Down Expand Up @@ -463,7 +463,7 @@ def _compute_tick_positions(self, gc, overlay_component=None):
return

if datalow > datahigh:
raise RuntimeError, "DataRange low is greater than high; unable to compute axis ticks."
raise RuntimeError("DataRange low is greater than high; unable to compute axis ticks.")

if not self.tick_generator:
return
Expand Down Expand Up @@ -793,7 +793,7 @@ def __getstate__(self):

state = super(PlotAxis,self).__getstate__()
for key in dont_pickle:
if state.has_key(key):
if key in state:
del state[key]

return state
Expand All @@ -811,7 +811,7 @@ class MinorPlotAxis(PlotAxis):
The MinorPlotAxis is a PlotAxis which draws ticks with a smaller interval,
smaller tick sizes, and no tick labels.
"""

def __init__(self, *args, **kwargs):
super(MinorPlotAxis, self).__init__(*args, **kwargs)

Expand Down
6 changes: 4 additions & 2 deletions chaco/axis_view.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
""" Defines the Traits UI view for a PlotAxis """

import six

from traits.api import TraitError
from traitsui.api import View, HGroup, Group, VGroup, Item, TextEditor

Expand All @@ -12,9 +14,9 @@ def float_or_auto(val):
try:
return float(val)
except:
if isinstance(val, basestring) and val == "auto":
if isinstance(val, six.string_types) and val == "auto":
return val
raise TraitError, "Tick interval must be a number or 'auto'."
raise TraitError("Tick interval must be a number or 'auto'.")

# Traits UI for a PlotAxis.
AxisView = View(VGroup(
Expand Down
8 changes: 4 additions & 4 deletions chaco/barplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
from kiva.constants import FILL_STROKE

# Local relative imports
from chaco.abstract_plot_renderer import AbstractPlotRenderer
from abstract_mapper import AbstractMapper
from array_data_source import ArrayDataSource
from base import reverse_map_1d
from .abstract_plot_renderer import AbstractPlotRenderer
from .abstract_mapper import AbstractMapper
from .array_data_source import ArrayDataSource
from .base import reverse_map_1d


logger = logging.getLogger(__name__)
Expand Down
Loading