Skip to content

BUG: numpy.isin does not function correctly with two arrays with different integer type #22877

@TonyXiang8787

Description

@TonyXiang8787

Describe the issue:

The function numpy.isin sometimes returns the wrong answer, if the integer type of the two arrays (to be compared) are not the same.

The example below shows a int8 array with one zero and a int64 array with two values. It should return one True. However, it returns False.

Reproduce the code example:

>>> import numpy as np
>>> np.isin(np.zeros(1, dtype=np.int8), np.array([-128, 0], dtype=np.int64), kind='table')
array([False])

Error message:

No response

Runtime information:

Numpy version

>>> print(numpy.__version__)
1.24.0

Sys version

>>> print(sys.version)
3.11.1 (main, Dec  7 2022, 01:11:34) [GCC 11.3.0]

Numpy runtime

[{'simd_extensions': {'baseline': ['SSE', 'SSE2', 'SSE3'],
                      'found': ['SSSE3',
                                'SSE41',
                                'POPCNT',
                                'SSE42',
                                'AVX',
                                'F16C',
                                'FMA3',
                                'AVX2'],
                      'not_found': ['AVX512F',
                                    'AVX512CD',
                                    'AVX512_KNL',
                                    'AVX512_KNM',
                                    'AVX512_SKX',
                                    'AVX512_CLX',
                                    'AVX512_CNL',
                                    'AVX512_ICL']}},
 {'architecture': 'Haswell',
  'filepath': 'PATH_DELETED_DUE_TO_PRIVACY/.venv/lib/python3.11/site-packages/numpy.libs/libopenblas64_p-r0-15028c96.3.21.so',
  'internal_api': 'openblas',
  'num_threads': 20,
  'prefix': 'libopenblas',
  'threading_layer': 'pthreads',
  'user_api': 'blas',
  'version': '0.3.21'}]

Context for the issue:

The problem seems to only occur in version 1.24.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions