Skip to content

ndarray printing is inconsistent across the platforms #13468

@soupault

Description

@soupault

Hi,

I've discovered that numpy array printing is slightly different for different platforms (might be related to platform-dependent types somehow - https://www.ibm.com/support/knowledgecenter/en/SSFKSJ_9.0.0/com.ibm.mq.ref.dev.doc/q104610_.htm).
This inconsistency makes the testing of docstring examples challenging (scikit-image/scikit-image#3873) across the operating systems.

Reproducing code example:

Notice the dtype part:

import numpy as np

### Windows 32bit

np.set_printoptions(legacy='1.13')
np.argmin([[0,2,-1,3], [1,2,3,4]], axis=1)
# array([2, 0], dtype=int32)

np.set_printoptions(legacy=False)
np.argmin([[0,2,-1,3], [1,2,3,4]], axis=1)
# array([2, 0], dtype=int32)

### Windows 64bit

np.set_printoptions(legacy='1.13')
np.argmin([[0,2,-1,3], [1,2,3,4]], axis=1)
# array([2, 0], dtype=int64)

np.set_printoptions(legacy=False)
np.argmin([[0,2,-1,3], [1,2,3,4]], axis=1)
# array([2, 0], dtype=int32)

### Linux / MacOS 64bit

np.set_printoptions(legacy='1.13')
np.argmin([[0,2,-1,3], [1,2,3,4]], axis=1)
# array([2, 0])

np.set_printoptions(legacy=False)
np.argmin([[0,2,-1,3], [1,2,3,4]], axis=1)
# array([2, 0])

Numpy/Python version information:

(for Windows VM)
1.16.3, wide range of Python 3 versions

(for MacOS PC)
1.16.2 3.6.8 |Anaconda, Inc.| (default, Dec 29 2018, 19:04:46)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions