Skip to content

Commit

Permalink
Merge pull request mattloper#28 from metabolize/python3-2
Browse files Browse the repository at this point in the history
Python 3 support (mattloper#7)
  • Loading branch information
Matthew Loper authored Mar 14, 2019
2 parents ef0c192 + b3a5953 commit a3cfdb1
Show file tree
Hide file tree
Showing 20 changed files with 208 additions and 194 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ tidy:

test: clean qtest
qtest: all
python -m unittest discover -s chumpy
# For some reason the import changes for Python 3 caused the Python 2 test
# loader to give up without loading any tests. So we discover them ourselves.
# python -m unittest
find chumpy -name 'test_*.py' | sed -e 's/\.py$$//' -e 's/\//./' | xargs python -m unittest

coverage: clean qcov
qcov: all
Expand Down
24 changes: 12 additions & 12 deletions chumpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from ch import *
from logic import *
from .ch import *
from .logic import *

from optimization import minimize
import extras
import testing
from version import version as __version__
from .optimization import minimize
from . import extras
from . import testing
from .version import version as __version__

from version import version as __version__
from .version import version as __version__

from numpy import bool, int, float, complex, object, unicode, str, nan, inf

Expand Down Expand Up @@ -107,12 +107,12 @@ def compute_dr_wrt(self, wrt):

def demo(which=None):
if which not in demos:
print 'Please indicate which demo you want, as follows:'
print('Please indicate which demo you want, as follows:')
for key in demos:
print "\tdemo('%s')" % (key,)
print("\tdemo('%s')" % (key,))
return

print '- - - - - - - - - - - <CODE> - - - - - - - - - - - -'
print demos[which]
print '- - - - - - - - - - - </CODE> - - - - - - - - - - - -\n'
print('- - - - - - - - - - - <CODE> - - - - - - - - - - - -')
print(demos[which])
print('- - - - - - - - - - - </CODE> - - - - - - - - - - - -\n')
exec('global np\n' + demos[which], globals(), locals())
14 changes: 7 additions & 7 deletions chumpy/api_compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
"""


import ch
from . import ch
import numpy as np
from os.path import join, split
from StringIO import StringIO
from six import StringIO
import numpy
import chumpy
import cPickle as pickle
from six.moves import cPickle as pickle

src = ''
num_passed = 0
Expand Down Expand Up @@ -71,7 +71,7 @@ def r(fn_name, args_req, args_opt, nplib=numpy, chlib=chumpy):

try:
if isinstance(args_req, dict):
fn(**dict(args_req.items() + args_opt.items()))
fn(**dict(list(args_req.items()) + list(args_opt.items())))
else:
fn(*args_req, **args_opt)
if lib is chlib:
Expand Down Expand Up @@ -108,7 +108,7 @@ def append(a, b, c):
b_color = lookup[b] if b in lookup else 'white'
c_color = lookup[c] if c in lookup else 'white'

print '%s: %s, %s' % (a,b,c)
print('%s: %s, %s' % (a,b,c))
make_row(a, b, c, b_color, c_color)

def m(s):
Expand Down Expand Up @@ -524,11 +524,11 @@ def main():
src = '<html><body><table border=1>' + src + '</table></body></html>'
open(join(split(__file__)[0], 'api_compatibility.html'), 'w').write(src)

print 'passed %d, not passed %d' % (num_passed, num_not_passed)
print('passed %d, not passed %d' % (num_passed, num_not_passed))



if __name__ == '__main__':
global which_passed
main()
print ' '.join(which_passed)
print(' '.join(which_passed))
Loading

0 comments on commit a3cfdb1

Please sign in to comment.