Skip to content

Commit

Permalink
First changes so datarray imports on Python 3. Tests don't pass yet.
Browse files Browse the repository at this point in the history
  • Loading branch information
fperez committed Sep 20, 2015
1 parent cc6495f commit 3157308
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion datarray/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
try:
from .testing.testlib import test
except ImportError:
print "No datarray unit testing available."
print("No datarray unit testing available.")

from .version import __version__
from .datarray import DataArray
2 changes: 1 addition & 1 deletion datarray/datarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,7 @@ def __getitem__(self, key):
# Pop the axes off in descending order to prevent index renumbering
# headaches
reductions = reversed(sorted(zip(key, new_axes), None,
key=lambda (k,ax): ax.index))
key=lambda k,ax: ax.index))
arr = self
for k,ax in reductions:
arr = arr.axes[ax.index][k]
Expand Down
2 changes: 1 addition & 1 deletion datarray/testing/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@

from utils import *
from .utils import *
20 changes: 10 additions & 10 deletions datarray/testing/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,23 +101,23 @@ def heading(text):
# Both x and y are scalars
try:
assert_equal(x, y)
except AssertionError, err:
except (AssertionError, err):
fail.append(heading('SCALARS') + str(err))

elif (type(x) is np.ndarray) and (type(y) is np.ndarray):

# Both x and y are scalars
try:
assert_array_equal(x, y)
except AssertionError, err:
except (AssertionError, err):
fail.append(heading('ARRAYS') + str(err))

elif (type(x) == DataArray) + (type(y) == DataArray) == 1:

# Only one of x and y are datarrays; test failed
try:
assert_equal(type(x), type(y))
except AssertionError, err:
except (AssertionError, err):
fail.append(heading('TYPE') + str(err))

else:
Expand All @@ -127,35 +127,35 @@ def heading(text):
# shape
try:
assert_equal(x.shape, y.shape)
except AssertionError, err:
except (AssertionError, err):
fail.append(heading('SHAPE') + str(err))

# axis names
try:
assert_equal(x.names, y.names)
except AssertionError, err:
except (AssertionError, err):
fail.append(heading('AXIS NAMES') + str(err))

# labels
for ax in range(x.ndim):
try:
try:
assert_equal(x.axes[ax].labels, y.axes[ax].labels)
except AssertionError, err:
except (AssertionError, err):
fail.append(heading('LABELS ALONG AXIS = %d' % ax) + str(err))

# axes
for ax in range(x.ndim):
try:
assert_(x.axes[ax], y.axes[ax])
except AssertionError, err:
except (AssertionError, err):
fail.append(heading('AXIS OBJECT ALONG AXIS = %d' % ax) + str(err))
fail.append('x: ' + str(x.axes[ax]))
fail.append('y: ' + str(y.axes[ax]))

# data
try:
assert_array_equal(x.base, y.base)
except AssertionError, err:
except (AssertionError, err):
fail.append(heading('ARRAY') + str(err))

# Did the test pass?
Expand All @@ -168,7 +168,7 @@ def heading(text):
err_msg = heading("TEST: " + err_msg) + err_msgs
else:
err_msg = err_msgs
raise AssertionError, err_msg
raise (AssertionError, err_msg)
else:
raise AssertionError

0 comments on commit 3157308

Please sign in to comment.