Skip to content

BUG: Architecture-inconsistent behaviour casting negative integers to unsigned integers (MacOS ARM) #22951

@cmutel

Description

@cmutel

Describe the issue:

Converting a negative integer with dtype float, float32, or float64 to uint32 or uint64 gives zero on MacOS ARM machines.

  • Tested on Numpy 1.23 and 1.24.
  • Tested on multiple MacOS ARM machines.
  • Expected behaviour is to wrap around the maximum unsigned integer, which is what is done on x64 machines
  • Wrap around also works when converting to uint8 and unint16

This exact operation is discussed in the 1.24 release notes, and the provided example does work. However, it fails when the input has dtype float, and conversion is to 32- or 64-bit unsigned integers.

Reproduce the code example:

import numpy as np
np.array(-1).astype(np.uint32)
>>> array(4294967295, dtype=uint32)
np.array(-1, dtype=float).astype(np.uint32)
>>> array(0, dtype=uint32)

Error message:

No response

Runtime information:

1.23.2
3.10.5 | packaged by conda-forge | (main, Jun 14 2022, 07:07:06) [Clang 13.0.1 ]

-and-

1.24.1
3.9.13 | packaged by conda-forge | (main, May 27 2022, 17:00:33)
[Clang 13.0.1 ]
[{'simd_extensions': {'baseline': ['NEON', 'NEON_FP16', 'NEON_VFPV4', 'ASIMD'],
'found': ['ASIMDHP', 'ASIMDDP'],
'not_found': ['ASIMDFHM']}}]

Context for the issue:

This breaks correct matrix building for the Brightway life cycle assessment framework.

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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy