Repository navigation
Commit 1a4d943
committed
BUG Ensure masked object arrays can always return single items.
For a masked array holding objects that themselves are arrays, when selecting a
single item, it is treated as if it were a slice of the array and an attempt is
made to set its mask. This was always a bug, but it become visible with a
recent change to `MaskedArray.__getitem__` (gh-4586) where it is attempted to
change the shape of the mask. With this PR, this case gets special treatment
in that the object is made into a Masked Array with a full set mask.
(A previous attempt to do the perhaps more logical think and just return
`masked` caused quite a few errors in astropy.io.votable; it seemed it was
not worth breaking backwards compatibility that much).
Test case that now works but used to fail:
```
mx1 = MaskedArray([1.], mask=[True])
mx2 = MaskedArray([1., 2.])
mx = MaskedArray([mx1, mx2], mask=[False, True])
mx[0]
```1 parent a580d6f commit 1a4d943
3 files changed
Lines changed: 23 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
102 | 107 | | |
103 | 108 | | |
104 | 109 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3046 | 3046 | | |
3047 | 3047 | | |
3048 | 3048 | | |
| 3049 | + | |
3049 | 3050 | | |
3050 | 3051 | | |
3051 | 3052 | | |
| |||
3057 | 3058 | | |
3058 | 3059 | | |
3059 | 3060 | | |
| 3061 | + | |
| 3062 | + | |
| 3063 | + | |
| 3064 | + | |
| 3065 | + | |
3060 | 3066 | | |
3061 | 3067 | | |
3062 | 3068 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
685 | 685 | | |
686 | 686 | | |
687 | 687 | | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
688 | 700 | | |
689 | 701 | | |
690 | 702 | | |
| |||
0 commit comments