Skip to content

Commit

Permalink
Merge branch 'python3' of https://github.com/pradyunsg/enable into fe…
Browse files Browse the repository at this point in the history
…ature/python3

Conflicts:
	.travis.yml
	enable/__init__.py
	integrationtests/kiva/agg/test_draw_dash.py
	kiva/fonttools/font.py
	kiva/fonttools/sstruct.py
	setup.py
  • Loading branch information
corranwebster committed Sep 11, 2015
2 parents e47a3df + a3801cf commit 84f22ef
Show file tree
Hide file tree
Showing 57 changed files with 208 additions and 173 deletions.
9 changes: 7 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ sudo: false
python:
- '2.7_with_system_site_packages'
- 2.6
- 3.4
addons:
apt:
packages:
Expand All @@ -29,6 +30,8 @@ matrix:
env: ETS_TOOLKIT=qt4
- python: 2.6
env: ETS_TOOLKIT=wx
- python: 3.4
env: ETS_TOOLKIT=wx
cache:
directories:
- $HOME/.cache
Expand All @@ -44,12 +47,14 @@ install:
# numpy is already installed
- pip install -r travis-ci-requirements
- pip install coveralls
- python setup.py develop

before_script:
- export NOSE_WITH_COVERAGE=True
script:
- coverage run -m nose.core -v enable/tests
- coverage run -a -m nose.core -v enable/savage/svg/tests
- coverage run -a -m unittest2 discover -v -p *test_* kiva/tests
- coverage run -a -m nose.core -v kiva/agg/tests
after_success:
- pip install codecov
- codecov
- codecov
5 changes: 2 additions & 3 deletions enable/enable_traits.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

# Major library imports
from numpy import arange, array
from types import ListType, TupleType

# Enthought library imports
from kiva.trait_defs.kiva_font_trait import KivaFont
Expand All @@ -30,10 +29,10 @@
ArrayType = type( arange( 1.0 ) )

# Basic sequence types:
basic_sequence_types = ( ListType, TupleType )
basic_sequence_types = ( list, tuple )

# Sequence types:
sequence_types = [ ArrayType, ListType, TupleType ]
sequence_types = [ ArrayType, list, tuple ]

# Valid pointer shape names:
pointer_shapes = [
Expand Down
4 changes: 1 addition & 3 deletions enable/qt4/scrollbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
the standard Qt one.
"""

from types import ListType, TupleType

from pyface.qt import QtCore, QtGui
from traits.api import Any, Bool, Enum, Float, Int, Property, Trait, TraitError

Expand All @@ -15,7 +13,7 @@ def valid_range(object, name, value):
""" Verify that a set of range values for a scrollbar is valid.
"""
try:
if (type(value) in (TupleType, ListType)) and (len(value) == 4):
if (type(value) in (tuple, list)) and (len(value) == 4):
low, high, page_size, line_size = value
if high < low:
low, high = high, low
Expand Down
4 changes: 2 additions & 2 deletions enable/savage/svg/document.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
SVGDocument
"""
from cStringIO import StringIO
from io import BytesIO
import warnings
import math
from functools import wraps
Expand Down Expand Up @@ -183,7 +183,7 @@ def resolve(self, path):
# Plain URI. Pass it back.
# Read the data and stuff it in a StringIO in order to satisfy
# functions that need a functioning seek() and stuff.
return path, lambda uri: StringIO(urllib.urlopen(uri).read())
return path, lambda uri: BytesIO(urllib.urlopen(uri).read())
path = os.path.abspath(os.path.join(self.dirname, path_part))
return path, lambda fn: open(fn, 'rb')

Expand Down
3 changes: 1 addition & 2 deletions enable/scrollbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
# PZW: Define a scrollbar that uses the system/wx-native scrollbar instead
# of drawing our own.

from types import TupleType
from traits.api import Event, Property, Trait, TraitError
from traitsui.api import Group, View

Expand Down Expand Up @@ -58,7 +57,7 @@
def valid_range ( object, name, value ):
"Verify that a set of range values for a scrollbar is valid"
try:
if (type( value ) is TupleType) and (len( value ) == 4):
if (type( value ) is tuple) and (len( value ) == 4):
low, high, page_size, line_size = value
if high < low:
low, high = high, low
Expand Down
2 changes: 1 addition & 1 deletion enable/toolkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def _init_toolkit():
backend = 'enable.%s.%s' % (ETSConfig.toolkit, ETSConfig.kiva_backend)
try:
__import__(backend)
except ImportError, SystemExit:
except (ImportError, SystemExit):
t, v, _tb = sys.exc_info()
raise ImportError, "Unable to import the %s backend for the %s " \
"toolkit (reason: %s)." % (ETSConfig.kiva_backend, ETSConfig.toolkit,
Expand Down
3 changes: 1 addition & 2 deletions enable/wx/scrollbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

# Major library imports
import wx
from types import ListType, TupleType

# Enthought Imports
from traits.api import Property, Trait, TraitError, \
Expand All @@ -17,7 +16,7 @@
def valid_range(object, name, value):
"Verify that a set of range values for a scrollbar is valid"
try:
if (type(value) in (TupleType, ListType)) and (len(value) == 4):
if (type(value) in (tuple, list)) and (len(value) == 4):
low, high, page_size, line_size = value
if high < low:
low, high = high, low
Expand Down
2 changes: 1 addition & 1 deletion examples/enable/basic_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def _draw_mainlayer(self, gc, view_bounds=None, mode="default"):
return

def normal_key_pressed(self, event):
print "Key:", event.character
print("Key:", event.character)

def normal_left_down(self, event):
self.event_state = "moving"
Expand Down
2 changes: 1 addition & 1 deletion examples/enable/compass_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def _create_window(self):
return Window(self, component=container)

def _arrow_printer(self):
print "Clicked:", self.compass.clicked
print("Clicked:", self.compass.clicked)


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion examples/enable/component_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def draw(self, gc, **kwargs):
return

def normal_key_pressed(self, event):
print "key pressed: ", event.character
print("key pressed: ", event.character)


class Demo(HasTraits):
Expand Down
2 changes: 1 addition & 1 deletion examples/enable/container_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __init__(self, color=None, **kw):
super(Region, self).__init__(**kw)
if color:
self.color = color
if not kw.has_key("bounds"):
if "bounds" not in kw:
self.bounds = [100, 100]

def _draw_plot(self, gc, view_bounds=None, mode="normal"):
Expand Down
6 changes: 3 additions & 3 deletions examples/enable/latency_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ class Box(Component):

def _draw_mainlayer(self, gc, view=None, mode="default"):
if self.event_state == "clicked":
print "waiting %0.4f seconds... " % self.delay,
print("waiting %0.4f seconds... " % self.delay, end=' ')
time.sleep(self.delay)
print "done."
print("done.")

with gc:
gc.set_fill_color(self.color_)
Expand Down Expand Up @@ -83,7 +83,7 @@ def _create_window(self):
0.10: (240,50,100,100)}

container = MyContainer(auto_size = False)
for delay, bounds in times_and_bounds.items():
for delay, bounds in list(times_and_bounds.items()):
box = Box()
container.add(box)
box.position = list(bounds[:2])
Expand Down
2 changes: 1 addition & 1 deletion examples/enable/slider_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def _create_window(self):
return Window(self, component=container)

def val_changed(self):
print self.slider.value
print(self.slider.value)


if __name__ == "__main__":
Expand Down
4 changes: 2 additions & 2 deletions examples/enable/view_bounds_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def _draw_container_mainlayer(self, gc, view_bounds, mode="default"):
tmp = intersect_bounds(component.position + component.bounds,
new_bounds)
if tmp == empty_rectangle:
print "skipping component:", component.__class__.__name__,
print "\tbounds:", component.position, component.bounds
print("skipping component:", component.__class__.__name__, end=' ')
print("\tbounds:", component.position, component.bounds)
continue

with gc:
Expand Down
28 changes: 14 additions & 14 deletions examples/kiva/agg/benchmark.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
Benchmarks Agg rendering times.
"""
from __future__ import with_statement


import time

Expand All @@ -15,7 +15,7 @@ def benchmark_real_time(cycles=10,n_pts=1000,sz=(1000,1000)):
""" Render a sin wave to the screen repeatedly. Clears
the screen between each rendering.
"""
print 'realtime:',
print('realtime:', end=' ')
width,height = sz
pts = zeros((n_pts,2),Float)
x = pts[:,0]
Expand All @@ -32,7 +32,7 @@ def benchmark_real_time(cycles=10,n_pts=1000,sz=(1000,1000)):
#agg.write_bmp_rgb24("sin%d.bmp" % i,gc.bitmap)
t2 = time.clock()
tot_time = t2 - t1
print 'tot,per cycle:', tot_time, tot_time/cycles
print('tot,per cycle:', tot_time, tot_time/cycles)
return


Expand Down Expand Up @@ -61,12 +61,12 @@ def benchmark_compiled_path(cycles=10,n_pts=1000,sz=(1000,1000)):
t2 = time.clock()

tot_time = t2 - t1
print 'tot,per cycle:', tot_time, tot_time/cycles
print('tot,per cycle:', tot_time, tot_time/cycles)
return


def benchmark_draw_path_flags(cycles=10,n_pts=1000,sz=(1000,1000)):
print 'realtime:',
print('realtime:', end=' ')
width,height = sz
pts = zeros((n_pts,2),Float)
x = pts[:,0]
Expand All @@ -88,7 +88,7 @@ def benchmark_draw_path_flags(cycles=10,n_pts=1000,sz=(1000,1000)):
t2 = time.clock()
agg.write_bmp_rgb24("draw_path%d.bmp" % flag,gc.bitmap)
tot_time = t2 - t1
print 'tot,per cycle:', tot_time, tot_time/cycles
print('tot,per cycle:', tot_time, tot_time/cycles)
return


Expand Down Expand Up @@ -127,8 +127,8 @@ def benchmark_individual_symbols(n_pts=1000,sz=(1000,1000)):
"Draws some stars"
width,height = sz
pts = stats.norm.rvs(size=(n_pts,2)) * array(sz)/8.0 + array(sz)/2.0
print pts[5,:]
print shape(pts)
print(pts[5,:])
print(shape(pts))
star_path = star_path_gen()

gc = agg.GraphicsContextArray(sz)
Expand All @@ -143,16 +143,16 @@ def benchmark_individual_symbols(n_pts=1000,sz=(1000,1000)):
t2 = time.clock()
gc.save("benchmark_symbols1.bmp")
tot_time = t2 - t1
print 'star count, tot,per shape:', n_pts, tot_time, tot_time / n_pts
print('star count, tot,per shape:', n_pts, tot_time, tot_time / n_pts)
return


def benchmark_rect(n_pts=1000,sz=(1000,1000)):
"Draws a number of randomly-placed renctangles."
width,height = sz
pts = stats.norm.rvs(size=(n_pts,2)) * array(sz)/8. + array(sz)/2.
print pts[5,:]
print shape(pts)
print(pts[5,:])
print(shape(pts))

gc = agg.GraphicsContextArray(sz)
gc.set_fill_color((1.0,0.0,0.0,0.1))
Expand All @@ -166,7 +166,7 @@ def benchmark_rect(n_pts=1000,sz=(1000,1000)):
t2 = time.clock()
gc.save("benchmark_rect.bmp")
tot_time = t2 - t1
print 'rect count, tot,per shape:', n_pts, tot_time, tot_time / n_pts
print('rect count, tot,per shape:', n_pts, tot_time, tot_time / n_pts)
return


Expand Down Expand Up @@ -198,8 +198,8 @@ def benchmark_symbols_all_at_once(n_pts=1000,sz=(1000,1000)):
build_path_time = t2 - t1
render_path_time = t3 - t2
tot_time = t3 - t1
print 'star count, tot,building path, rendering path:', n_pts, \
tot_time, build_path_time,render_path_time
print('star count, tot,building path, rendering path:', n_pts, \
tot_time, build_path_time,render_path_time)
return


Expand Down
2 changes: 1 addition & 1 deletion examples/kiva/agg/dash.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def dash(sz=(1000,1000)):
t2 = time.clock()
gc.save("dash.bmp")
tot_time = t2 - t1
print 'time:', tot_time
print('time:', tot_time)

if __name__ == "__main__":
dash()
4 changes: 2 additions & 2 deletions examples/kiva/agg/lion.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def main():
t1 = now()
path_and_color, size, center = get_lion()
t2 = now()
print t2 - t1
print(t2 - t1)

gc = agg.GraphicsContextArray(sz)
t1 = now()
Expand All @@ -33,7 +33,7 @@ def main():
gc.fill_path()
gc.rotate_ctm(1)
t2 = now()
print 'total time, sec/image, img/sec:', t2 - t1, (t2-t1)/Nimages, Nimages/(t2-t1)
print('total time, sec/image, img/sec:', t2 - t1, (t2-t1)/Nimages, Nimages/(t2-t1))
gc.save('lion.bmp')

if __name__ == "__main__":
Expand Down
6 changes: 3 additions & 3 deletions examples/kiva/agg/lion_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,11 @@ def build_paths(lion_string):
else:
fields = array(fields,'O')
cmd = fields[::2]
pts = map(lambda x: array(eval(x), dtype=float), fields[1::2])
pts = [array(eval(x), dtype=float) for x in fields[1::2]]
mins.append(amin(pts,axis=0))
maxs.append(amax(pts,axis=0))

path_def = zip (cmd,pts)
path_def = list(zip (cmd,pts))
for cmd, pt in path_def:
pt[0] -= 119
pt[1] -= 190.5
Expand All @@ -194,7 +194,7 @@ def build_paths(lion_string):

sz = max_pt - min_pt
center = min_pt + sz/2.0
return zip(paths, colors), sz, center
return list(zip(paths, colors)), sz, center

def get_lion():
"""get_lion() -> path_and_color, size, center
Expand Down
Loading

0 comments on commit 84f22ef

Please sign in to comment.