Masked array dimensions added when apply mask value?
Open
Nobody has claimed this yet.
00 - Bug
01 - Enhancement
component: numpy.ma
- Dominant language
- Python
- Stars
- 32.8k
- Forks
- 12.8k
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 197
Description
When i apply mask generated by ma.zeros on the zeros matrix, i have an behaviour which i don't understand.
Reproducing code example:
import numpy as np
a = np.ma.zeros(5)
# add a dimensions
print(a[~a.mask])
# Seem work correctly
print(a[a.mask])
# But when we check dimensions??:
print(a[a.mask].shape)
Result
print(a[~a.mask])
[[0. 0. 0. 0. 0.]]
print(a[a.mask])
[]
print(a[a.mask].shape)
(0, 5)
Numpy/Python version information:
1.16.5 3.7.4 (default, Aug 13 2019, 20:35:49)
[GCC 7.3.0]
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Run the provided Python reproduction with NumPy masked arrays and inspect the shapes and values produced by each indexing expression. Trace the masked-array indexing behavior, then establish whether the reported shape is expected; done means the behavior is corrected or clearly explained with appropriate coverage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- numpy, python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100