|
3 | 3 | See docstring of :mod:`nibabel.arraywriters` for API.
|
4 | 4 | """
|
5 | 5 |
|
6 |
| -import sys |
7 | 6 | from platform import python_compiler, machine
|
8 |
| -from distutils.version import LooseVersion |
9 | 7 | import itertools
|
10 | 8 | import numpy as np
|
11 | 9 |
|
|
33 | 31 | IUINT_TYPES = INT_TYPES + UINT_TYPES
|
34 | 32 | NUMERIC_TYPES = CFLOAT_TYPES + IUINT_TYPES
|
35 | 33 |
|
36 |
| -NP_VERSION = LooseVersion(np.__version__) |
37 |
| - |
38 | 34 |
|
39 | 35 | def round_trip(writer, order='F', apply_scale=True):
|
40 | 36 | sio = BytesIO()
|
@@ -65,29 +61,14 @@ def test_arraywriters():
|
65 | 61 | assert_array_equal(arr, round_trip(aw))
|
66 | 62 | # Byteswapped should be OK
|
67 | 63 | bs_arr = arr.byteswap().newbyteorder('S')
|
68 |
| - # Except on some numpies for complex256, where the array does not |
69 |
| - # equal itself |
70 |
| - if not np.all(bs_arr == arr): |
71 |
| - assert_true(NP_VERSION <= LooseVersion('1.7.0')) |
72 |
| - assert_true(on_powerpc()) |
73 |
| - assert_true(type == np.complex256) |
74 |
| - else: |
75 |
| - bs_aw = klass(bs_arr) |
76 |
| - bs_aw_rt = round_trip(bs_aw) |
77 |
| - # On Ubuntu 13.04 with python 3.3 __eq__ comparison on |
78 |
| - # arrays with complex numbers fails here for some |
79 |
| - # reason -- not our fault, and to test correct operation we |
80 |
| - # will just compare element by element |
81 |
| - if NP_VERSION == '1.7.1' and sys.version_info[:2] == (3, 3): |
82 |
| - assert_array_equal_ = lambda x, y: np.all([x_ == y_ for x_, y_ in zip(x, y)]) |
83 |
| - else: |
84 |
| - assert_array_equal_ = assert_array_equal |
85 |
| - # assert against original array because POWER7 was running into |
86 |
| - # trouble using the byteswapped array (bs_arr) |
87 |
| - assert_array_equal_(arr, bs_aw_rt) |
88 |
| - bs_aw2 = klass(bs_arr, arr.dtype) |
89 |
| - bs_aw2_rt = round_trip(bs_aw2) |
90 |
| - assert_array_equal(arr, bs_aw2_rt) |
| 64 | + bs_aw = klass(bs_arr) |
| 65 | + bs_aw_rt = round_trip(bs_aw) |
| 66 | + # assert against original array because POWER7 was running into |
| 67 | + # trouble using the byteswapped array (bs_arr) |
| 68 | + assert_array_equal(arr, bs_aw_rt) |
| 69 | + bs_aw2 = klass(bs_arr, arr.dtype) |
| 70 | + bs_aw2_rt = round_trip(bs_aw2) |
| 71 | + assert_array_equal(arr, bs_aw2_rt) |
91 | 72 | # 2D array
|
92 | 73 | arr2 = np.reshape(arr, (2, 5))
|
93 | 74 | a2w = klass(arr2)
|
|
0 commit comments