From 9dbd19f0f720c6813ede4c42864dbb89884d454b Mon Sep 17 00:00:00 2001 From: Graham Inggs Date: Sun, 14 Jul 2019 17:56:10 +0200 Subject: [PATCH 1/2] Fix tests on big-endian systems --- xarray/tests/test_dataarray.py | 3 ++- xarray/tests/test_dataset.py | 3 ++- xarray/tests/test_formatting.py | 15 +++++++++------ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/xarray/tests/test_dataarray.py b/xarray/tests/test_dataarray.py index 30385779e5f..5f5c4ee5b60 100644 --- a/xarray/tests/test_dataarray.py +++ b/xarray/tests/test_dataarray.py @@ -3125,7 +3125,8 @@ def test_to_and_from_dict(self): expected_no_data = expected.copy() del expected_no_data['data'] del expected_no_data['coords']['x']['data'] - expected_no_data['coords']['x'].update({'dtype': 'U1' + expected_no_data['coords']['x'].update({'dtype': endiantype, 'shape': (2,)}) expected_no_data.update({'dtype': 'float64', 'shape': (2, 3)}) actual_no_data = array.to_dict(data=False) assert expected_no_data == actual_no_data diff --git a/xarray/tests/test_dataset.py b/xarray/tests/test_dataset.py index c4925352bbc..781b00ec5b1 100644 --- a/xarray/tests/test_dataset.py +++ b/xarray/tests/test_dataset.py @@ -3445,7 +3445,8 @@ def test_to_and_from_dict(self): del expected_no_data['coords']['t']['data'] del expected_no_data['data_vars']['a']['data'] del expected_no_data['data_vars']['b']['data'] - expected_no_data['coords']['t'].update({'dtype': 'U1' + expected_no_data['coords']['t'].update({'dtype': endiantype, 'shape': (10,)}) expected_no_data['data_vars']['a'].update({'dtype': 'float64', 'shape': (10,)}) diff --git a/xarray/tests/test_formatting.py b/xarray/tests/test_formatting.py index 8a3c95a4962..be3e368e02b 100644 --- a/xarray/tests/test_formatting.py +++ b/xarray/tests/test_formatting.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- from textwrap import dedent +import sys import numpy as np import pandas as pd @@ -204,6 +205,7 @@ def test_diff_array_repr(self): 'label': ('x', np.array([1, 2], dtype='int64'))}, attrs={'units': 'kg'}) + byteorder = '<' if sys.byteorder == 'little' else '>' expected = dedent("""\ Left and right DataArray objects are not identical Differing dimensions: @@ -215,8 +217,8 @@ def test_diff_array_repr(self): R array([1, 2], dtype=int64) Differing coordinates: - L * x (x) ' expected = dedent("""\ Left and right Dataset objects are not identical Differing dimensions: (x: 2, y: 3) != (x: 2) Differing coordinates: - L * x (x) Date: Sun, 14 Jul 2019 18:08:31 +0200 Subject: [PATCH 2/2] PEP 8 --- xarray/tests/test_dataarray.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xarray/tests/test_dataarray.py b/xarray/tests/test_dataarray.py index 5f5c4ee5b60..091eee7ebd8 100644 --- a/xarray/tests/test_dataarray.py +++ b/xarray/tests/test_dataarray.py @@ -3126,7 +3126,8 @@ def test_to_and_from_dict(self): del expected_no_data['data'] del expected_no_data['coords']['x']['data'] endiantype = 'U1' - expected_no_data['coords']['x'].update({'dtype': endiantype, 'shape': (2,)}) + expected_no_data['coords']['x'].update({'dtype': endiantype, + 'shape': (2,)}) expected_no_data.update({'dtype': 'float64', 'shape': (2, 3)}) actual_no_data = array.to_dict(data=False) assert expected_no_data == actual_no_data