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

Skip to content

BUG: filled MaskedArray becomes object dtype if given a fill_value of None #27269

@bear24rw

Description

@bear24rw

Describe the issue:

Passing fill_value=None results in the MaskedArray dtype changing to object. Is this behavior intended? I didn't see mention of this in any changelog.

>>> np.__version__
'1.25.2'
>>> np.ma.MaskedArray([1,1,1], [True, False, True], dtype='uint64').filled()
array([999999,      1, 999999], dtype=uint64)
>>> np.__version__
'2.1.0'
>>> np.ma.MaskedArray([1,1,1], [True, False, True], dtype='uint64').filled()
array([np.int64(999999), 1, np.int64(999999)], dtype=object)

Reproduce the code example:

import numpy as np
assert np.ma.MaskedArray([1,1,1], [True, False, True], dtype='uint64').filled().dtype == np.dtype("uint64")

Error message:

No response

Python and NumPy Versions:

2.1.0
3.12.4 (main, Jun  6 2024, 18:26:44) [Clang 15.0.0 (clang-1500.3.9.4)]

Runtime Environment:

[{'numpy_version': '2.1.0',
  'python': '3.12.4 (main, Jun  6 2024, 18:26:44) [Clang 15.0.0 '
            '(clang-1500.3.9.4)]',
  'uname': uname_result(system='Darwin', node='<redacted>', release='23.2.0', version='<redacted>', machine='arm64')},
 {'simd_extensions': {'baseline': ['NEON', 'NEON_FP16', 'NEON_VFPV4', 'ASIMD'],
                      'found': ['ASIMDHP'],
                      'not_found': ['ASIMDFHM']}}]

Context for the issue:

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions