8000 BUG: np.ma.array changes subdtype fill_value · Issue #9303 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG: np.ma.array changes subdtype fill_value #9303

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
eric-wieser opened this issue Jun 26, 2017 · 1 comment
Open

BUG: np.ma.array changes subdtype fill_value #9303

eric-wieser opened this issue Jun 26, 2017 · 1 comment

Comments

@eric-wieser
Copy link
Member
eric-wieser commented Jun 26, 2017

Repro:

>>> dt = np.dtype([('value', int, 3)])
>>> m = np.ma.array(([1, 2, 3],), dtype=dt, fill_value=([10, 20, 30],))
masked_array(data = ([1, 2, 3],),
             mask = ([False, False, False],),
       fill_value = ([10, 10, 10],),           # wrong!
            dtype = [('value', '<i4', (3,))])

Or perhaps more alarmingly:

>>> m = np.ma.array(([1, 2, 3],), dtype=dt)
>>> m.fill_value['value'][1] = 20
masked_array(data = ([1, 2, 3],),
             mask = ([False, False, False],),
       fill_value = ([10, 20, 10],),           # OK!
            dtype = [('value', '<i4', (3,))])
>>> np.ma.array(m)
masked_array(data = ([1, 2, 3],),
             mask = ([False, False, False],),
       fill_value = (10,),                     # Wait, what?
            dtype = [('value', '<i4', (3,))])

Is any of this by design? Surely m.dtype == m.fill_value.dtype is an invariant?

@eric-wieser
Copy link
Member Author
eric-wieser commented Jun 26, 2017

e2df0c7 by @pierregm introduced this peculiar line that breaks this invariant, without any obvious rationale.

It's possible that this was trying to preempt #6723

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant
0