Skip to content

Commit 7c61319

Browse files
authored
Merge pull request #369 from jdeschenes/python-3
Python 3 compatibility fixes
2 parents d7e9b5a + 3655a79 commit 7c61319

File tree

153 files changed

+870
-694
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

153 files changed

+870
-694
lines changed

chaco/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@
77

88
__requires__ = [
99
'enable',
10+
'six'
1011
]

chaco/abstract_colormap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"""
33
from traits.api import Enum, Event, HasTraits, Instance
44

5-
from data_range_1d import DataRange1D
5+
from .data_range_1d import DataRange1D
66

77
class AbstractColormap(HasTraits):
88
"""

chaco/abstract_data_range.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from traits.api import Event, Float, HasTraits, Instance, List, Trait
77

88
# Local relative imports
9-
from abstract_data_source import AbstractDataSource
9+
from .abstract_data_source import AbstractDataSource
1010

1111

1212
class AbstractDataRange(HasTraits):

chaco/abstract_data_source.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from traits.api import Bool, Dict, Event, HasTraits
66

77
# Local relative imports
8-
from base import DimensionTrait
8+
from .base import DimensionTrait
99

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

125125
# everything but 'metadata'
126126
for key in ['value_dimension', 'index_dimension', 'persist_data']:
127-
if state.has_key(key):
127+
if key in state:
128128
del state[key]
129129

130130
return state

chaco/abstract_mapper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def map_data_array(self, screen_vals):
5555
def __getstate__(self):
5656
state = super(AbstractMapper,self).__getstate__()
5757
for key in ['_cache_valid']:
58-
if state.has_key(key):
58+
if key in state:
5959
del state[key]
6060

6161
return state

chaco/abstract_overlay.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from enable.api import Component
88
from traits.api import Instance
99

10-
from plot_component import PlotComponent
10+
from .plot_component import PlotComponent
1111

1212

1313
class AbstractOverlay(PlotComponent):

chaco/abstract_plot_renderer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from traits.api import Enum
55

66
# Local relative imports
7-
from plot_component import PlotComponent
7+
from .plot_component import PlotComponent
88

99
class AbstractPlotRenderer(PlotComponent):
1010
""" This is the minimal interface that all plot renderers must support.

chaco/api.py

Lines changed: 76 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -3,113 +3,113 @@
33
# This just imports the key datamodel classes into the top-level package
44
# namespace for convenience.
55

6-
from base import NumericalSequenceTrait, PointTrait, ImageTrait, DimensionTrait, \
6+
from .base import NumericalSequenceTrait, PointTrait, ImageTrait, DimensionTrait, \
77
SortOrderTrait, bin_search, reverse_map_1d, right_shift, \
88
left_shift, sort_points, find_runs, arg_find_runs, \
99
point_line_distance
1010

1111
# Data model
12-
from abstract_data_source import AbstractDataSource
13-
from array_data_source import ArrayDataSource
14-
from grid_data_source import GridDataSource
15-
from image_data import ImageData
16-
from multi_array_data_source import MultiArrayDataSource
17-
from point_data_source import PointDataSource
18-
from abstract_data_range import AbstractDataRange
19-
from base_data_range import BaseDataRange
20-
from data_range_1d import DataRange1D
21-
from data_range_2d import DataRange2D
12+
from .abstract_data_source import AbstractDataSource
13+
from .array_data_source import ArrayDataSource
14+
from .grid_data_source import GridDataSource
15+
from .image_data import ImageData
16+
from .multi_array_data_source import MultiArrayDataSource
17+
from .point_data_source import PointDataSource
18+
from .abstract_data_range import AbstractDataRange
19+
from .base_data_range import BaseDataRange
20+
from .data_range_1d import DataRange1D
21+
from .data_range_2d import DataRange2D
2222

2323
# Mappers
24-
from abstract_mapper import AbstractMapper
25-
from base_1d_mapper import Base1DMapper
26-
from grid_mapper import GridMapper
27-
from log_mapper import LogMapper
28-
from linear_mapper import LinearMapper
29-
from color_mapper import ColorMapper, ColorMapTemplate
30-
from discrete_color_mapper import DiscreteColorMapper
31-
from transform_color_mapper import TransformColorMapper
24+
from .abstract_mapper import AbstractMapper
25+
from .base_1d_mapper import Base1DMapper
26+
from .grid_mapper import GridMapper
27+
from .log_mapper import LogMapper
28+
from .linear_mapper import LinearMapper
29+
from .color_mapper import ColorMapper, ColorMapTemplate
30+
from .discrete_color_mapper import DiscreteColorMapper
31+
from .transform_color_mapper import TransformColorMapper
3232

3333
# Colormaps and color palettes
34-
from default_colormaps import *
35-
from default_colors import *
34+
from .default_colormaps import *
35+
from .default_colors import *
3636

3737
# Visual components
38-
from abstract_plot_renderer import AbstractPlotRenderer
39-
from abstract_overlay import AbstractOverlay
40-
from base_plot_container import BasePlotContainer
41-
from base_plot_frame import BasePlotFrame
42-
from cross_plot_frame import CrossPlotFrame
43-
from data_view import DataView
44-
from simple_plot_frame import SimplePlotFrame
45-
from plot_component import PlotComponent
46-
from plot_graphics_context import PlotGraphicsContext, PlotGraphicsContextMixin
47-
from selectable_overlay_container import SelectableOverlayPlotContainer
48-
from plot_containers import OverlayPlotContainer, HPlotContainer, VPlotContainer, \
38+
from .abstract_plot_renderer import AbstractPlotRenderer
39+
from .abstract_overlay import AbstractOverlay
40+
from .base_plot_container import BasePlotContainer
41+
from .base_plot_frame import BasePlotFrame
42+
from .cross_plot_frame import CrossPlotFrame
43+
from .data_view import DataView
44+
from .simple_plot_frame import SimplePlotFrame
45+
from .plot_component import PlotComponent
46+
from .plot_graphics_context import PlotGraphicsContext, PlotGraphicsContextMixin
47+
from .selectable_overlay_container import SelectableOverlayPlotContainer
48+
from .plot_containers import OverlayPlotContainer, HPlotContainer, VPlotContainer, \
4949
GridPlotContainer
5050
GridContainer = GridPlotContainer
5151

52-
from label import Label
53-
from plot_label import PlotLabel
54-
from legend import Legend
55-
from tooltip import ToolTip
56-
from data_label import DataLabel
57-
from lasso_overlay import LassoOverlay
58-
from color_bar import ColorBar
59-
from text_box_overlay import TextBoxOverlay
60-
from scatter_inspector_overlay import ScatterInspectorOverlay
52+
from .label import Label
53+
from .plot_label import PlotLabel
54+
from .legend import Legend
55+
from .tooltip import ToolTip
56+
from .data_label import DataLabel
57+
from .lasso_overlay import LassoOverlay
58+
from .color_bar import ColorBar
59+
from .text_box_overlay import TextBoxOverlay
60+
from .scatter_inspector_overlay import ScatterInspectorOverlay
6161

6262
# Renderers
63-
from barplot import BarPlot
64-
from base_1d_plot import Base1DPlot
65-
from base_2d_plot import Base2DPlot
66-
from base_xy_plot import BaseXYPlot
67-
from scatterplot import ScatterPlot, render_markers
68-
from image_plot import ImagePlot
69-
from cmap_image_plot import CMapImagePlot
70-
from contour_line_plot import ContourLinePlot
71-
from contour_poly_plot import ContourPolyPlot
72-
from lineplot import LinePlot
73-
from colormapped_scatterplot import ColormappedScatterPlot
74-
from colormapped_selection_overlay import ColormappedSelectionOverlay
75-
from polygon_plot import PolygonPlot
76-
from errorbar_plot import ErrorBarPlot
77-
from filled_line_plot import FilledLinePlot
78-
from quiverplot import QuiverPlot
79-
from candle_plot import CandlePlot
80-
from multi_line_plot import MultiLinePlot
81-
from jitterplot import JitterPlot
82-
from variable_size_scatterplot import VariableSizeScatterPlot
83-
from horizon_plot import BandedMapper, HorizonPlot
84-
from scatterplot_1d import ScatterPlot1D
85-
from line_scatterplot_1d import LineScatterPlot1D
86-
from text_plot_1d import TextPlot1D
63+
from .barplot import BarPlot
64+
from .base_1d_plot import Base1DPlot
65+
from .base_2d_plot import Base2DPlot
66+
from .base_xy_plot import BaseXYPlot
67+
from .scatterplot import ScatterPlot, render_markers
68+
from .image_plot import ImagePlot
69+
from .cmap_image_plot import CMapImagePlot
70+
from .contour_line_plot import ContourLinePlot
71+
from .contour_poly_plot import ContourPolyPlot
72+
from .lineplot import LinePlot
73+
from .colormapped_scatterplot import ColormappedScatterPlot
74+
from .colormapped_selection_overlay import ColormappedSelectionOverlay
75+
from .polygon_plot import PolygonPlot
76+
from .errorbar_plot import ErrorBarPlot
77+
from .filled_line_plot import FilledLinePlot
78+
from .quiverplot import QuiverPlot
79+
from .candle_plot import CandlePlot
80+
from .multi_line_plot import MultiLinePlot
81+
from .jitterplot import JitterPlot
82+
from .variable_size_scatterplot import VariableSizeScatterPlot
83+
from .horizon_plot import BandedMapper, HorizonPlot
84+
from .scatterplot_1d import ScatterPlot1D
85+
from .line_scatterplot_1d import LineScatterPlot1D
86+
from .text_plot_1d import TextPlot1D
8787

8888
# Plot factories
89-
from plot_factory import create_bar_plot, create_line_plot, create_scatter_plot, \
89+
from .plot_factory import create_bar_plot, create_line_plot, create_scatter_plot, \
9090
create_polar_plot, add_default_axes, add_default_grids
9191

92-
from abstract_plot_data import AbstractPlotData
93-
from array_plot_data import ArrayPlotData
94-
from data_frame_plot_data import DataFramePlotData
95-
from plot import Plot
96-
from toolbar_plot import ToolbarPlot
92+
from .abstract_plot_data import AbstractPlotData
93+
from .array_plot_data import ArrayPlotData
94+
from .data_frame_plot_data import DataFramePlotData
95+
from .plot import Plot
96+
from .toolbar_plot import ToolbarPlot
9797

9898
# Axis
99-
from axis import PlotAxis, MinorPlotAxis
100-
from label_axis import LabelAxis
101-
from ticks import AbstractTickGenerator, DefaultTickGenerator, auto_ticks, auto_interval, \
99+
from .axis import PlotAxis, MinorPlotAxis
100+
from .label_axis import LabelAxis
101+
from .ticks import AbstractTickGenerator, DefaultTickGenerator, auto_ticks, auto_interval, \
102102
tick_intervals, log_auto_ticks, auto_bounds, calc_bound
103103

104104
# Grid
105-
from grid import PlotGrid
105+
from .grid import PlotGrid
106106

107107
# Style stuff
108108
#from stylable import Stylable
109109
#from stylesheets import Style, StyleSheet
110110

111111
# Tools
112-
from abstract_controller import AbstractController
112+
from .abstract_controller import AbstractController
113113

114114
# Importing various symbols into the Chaco namespace for backwards
115115
# compatibility. New code should directly import from Enable.

chaco/array_data_source.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
from traits.api import Any, Constant, Int, Tuple
99

1010
# Chaco imports
11-
from base import NumericalSequenceTrait, reverse_map_1d, SortOrderTrait
12-
from abstract_data_source import AbstractDataSource
11+
from .base import NumericalSequenceTrait, reverse_map_1d, SortOrderTrait
12+
from .abstract_data_source import AbstractDataSource
1313

1414

1515
def bounded_nanargmin(arr):

chaco/array_plot_data.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
""" Defines ArrayPlotData.
22
"""
3-
3+
import six
4+
import six.moves as sm
45
from numpy import array, ndarray
56

67
# Enthought library imports
@@ -62,7 +63,7 @@ def __init__(self, *data, **kw):
6263
"""
6364
super(AbstractPlotData, self).__init__()
6465
self._update_data(kw)
65-
data = dict(zip(self._generate_names(len(data)), data))
66+
data = dict(sm.zip(self._generate_names(len(data)), data))
6667
self._update_data(data)
6768

6869

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

7879

7980
def get_data(self, name):
@@ -189,7 +190,7 @@ def _update_data(self, data):
189190
"""
190191
# note that this call modifies data, but that's OK since the callers
191192
# all create the dictionary that they pass in
192-
for name, value in data.items():
193+
for name, value in list(data.items()):
193194
if not isinstance(value, (ndarray, AbstractDataSource)):
194195
data[name] = array(value)
195196
else:

0 commit comments

Comments
 (0)