pydata / xarray

N-D labeled arrays and datasets in Python
https://xarray.dev
Apache License 2.0
3.57k stars 1.07k forks source link

adjust repr tests to account for different platforms (#9127) #9128

Closed mgorny closed 3 months ago

mgorny commented 3 months ago

Adjust the expectations in repr tests to account for different object sizes and numpy type representations across platforms, particularly fixing the tests on 32-bit platforms.

Firstly, this involves getting the object type size from NumPy and using it to adjust the expectations in DataArray and Dataset tests. The tests were already using int64 type consistently, so only the sizes used for Python objects needed to be adjusted.

Secondly, this involves fixing test_array_repr_dtypes_unix. The test specifically focuses on testing a 32-bit, 64-bit and "native" data type, which affect both size and actual representation (NumPy skips the dtype attribute for the native data type). Get the expected size from NumPy for the native int type, and reuse repr() from NumPy for all array types.

mgorny commented 3 months ago

Thanks!