Fix numpy tests for big endian architectures

Fixes some numpy tests failures on ppc64 in big-endian mode due to
little-endian assumptions.

Fixes #694.
This commit is contained in:
Jason Rhinelander
2017-02-25 16:43:01 -05:00
committed by Wenzel Jakob
parent 2a75784420
commit 0861be05da
2 changed files with 18 additions and 9 deletions

View File

@@ -8,7 +8,7 @@ with pytest.suppress(ImportError):
@pytest.fixture(scope='function')
def arr():
return np.array([[1, 2, 3], [4, 5, 6]], '<u2')
return np.array([[1, 2, 3], [4, 5, 6]], '=u2')
def test_array_attributes():
@@ -80,9 +80,10 @@ def test_dim_check_fail(arr):
([1, 2], [6])])
def test_data(arr, args, ret):
from pybind11_tests.array import data, data_t
from sys import byteorder
assert all(data_t(arr, *args) == ret)
assert all(data(arr, *args)[::2] == ret)
assert all(data(arr, *args)[1::2] == 0)
assert all(data(arr, *args)[(0 if byteorder == 'little' else 1)::2] == ret)
assert all(data(arr, *args)[(1 if byteorder == 'little' else 0)::2] == 0)
def test_mutate_readonly(arr):