Thanks to visit codestin.com
Credit goes to github.com

Skip to content

BUG: The output of np.vectorize for int32 inputs is promoted to int64 #29189

Closed
@asi1024

Description

@asi1024

Describe the issue:

It seems that the dtype of np.vectorize results differs between NumPy 2.2 and earlier versions and NumPy 2.3. Is this an intended change?

Reproduce the code example:

>>> np.vectorize(lambda x: x + x)(np.array([1, 2, 3, 4], dtype=np.int32)).dtype
dtype('int64')  # dtype('int32') if numpy<=2.2

Python and NumPy Versions:

Python: 3.13.1
NumPy: 2.3.0

Runtime Environment:

>>> np.show_runtime()
[{'numpy_version': '2.3.0',
  'python': '3.13.1 (main, Jan  7 2025, 10:32:19) [GCC 9.4.0]',
  'uname': uname_result(system='Linux', node='pg00', release='5.15.0-135-generic', version='#146-Ubuntu SMP Sat Feb 15 17:06:22 UTC 2025', machine='x86_64')},
 {'simd_extensions': {'baseline': ['SSE', 'SSE2', 'SSE3'],
                      'found': ['SSSE3',
                                'SSE41',
                                'POPCNT',
                                'SSE42',
                                'AVX',
                                'F16C',
                                'FMA3',
                                'AVX2',
                                'AVX512F',
                                'AVX512CD',
                                'AVX512_SKX'],
                      'not_found': ['AVX512_KNL',
                                    'AVX512_KNM',
                                    'AVX512_CLX',
                                    'AVX512_CNL',
                                    'AVX512_ICL',
                                    'AVX512_SPR']}},
 {'architecture': 'SkylakeX',
  'filepath': '/home/imanishi/.pyenv/versions/3.13.1/lib/python3.13/site-packages/numpy.libs/libscipy_openblas64_-56d6093b.so',
  'internal_api': 'openblas',
  'num_threads': 64,
  'prefix': 'libscipy_openblas',
  'threading_layer': 'pthreads',
  'user_api': 'blas',
  'version': '0.3.29'}]

Context for the issue:

If this behavior is intentional, we will update new CuPy versions to conform to ensure compatibility with this NumPy specification.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions