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

Skip to content

Mask hardness is not well defined #19331

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

Closed
QuLogic opened this issue Jun 24, 2021 · 6 comments · Fixed by #20810
Closed

Mask hardness is not well defined #19331

QuLogic opened this issue Jun 24, 2021 · 6 comments · Fixed by #20810
Labels
04 - Documentation component: numpy.ma masked arrays sprintable Issue fits the time-frame and setting of a sprint

Comments

@QuLogic
Copy link
Contributor

QuLogic commented Jun 24, 2021

Documentation

In the MaskedArray documentation, handling the mask section, there is harden_mask and soften_mask, with a summary that says "Force the mask to hard|soft":
image
So I click on one of those, and it says:
image
So I click on the hardmask property and it says:
image

This is all circular and I still have no idea what mask hardness means. There is also the Masked Array tutorial which explicitly states that it does not cover hard vs soft mask and links to the above functions, which of course make no explanation.

@melissawm
Copy link
Member

There is also a note here but I would agree this is probably not sufficient...

@ForgottenProgramme
Copy link

@melissawm , that note you linked is actually quite helpful. :)
I'd like to open a PR to solve this issue.

@melissawm
Copy link
Member

Feel free @ForgottenProgramme - let us know if you have questions about the process.

@WarrenWeckesser WarrenWeckesser added the component: numpy.ma masked arrays label Nov 18, 2021
@InessaPawson InessaPawson added the sprintable Issue fits the time-frame and setting of a sprint label Jan 6, 2022
@hmeine
Copy link
Contributor

hmeine commented Jan 6, 2022

I stumbled over the same problem (see SO post) and was also about to open a PR. In fact, I found that https://github.com/numpy/numpy/pull/13002/files replaced the attribute documentation with an :autoattribute: that is much less helpful, though.

I would suggest a documentation based on what was there in the past, maybe extended a little such as

Returns whether the mask is hard (True) or soft (False). When the mask is hard, masked entries cannot be unmasked by element assignment.

and including a link to the note referenced above.

@hmeine
Copy link
Contributor

hmeine commented Jan 7, 2022

Just to clarify, since I wrote "I was about to open a PR": It is not clear to me what would be a good way to reintroduce the documentation. The author of PR #13002 (@mattip) will have had good reasons to switch to :autoattribute:, and my hunch is that the documentation should be re-introduced elsewhere, probably as a kind of docstring. I will leave it up to people more knowledgeable w.r.t. numpy docs to tackle this.

@Mukulikaa
Copy link
Contributor

Hi @hmeine, if you want to improve the docstrings for the hardmask attribute, you can do it here:

numpy/numpy/ma/core.py

Lines 3576 to 3579 in f4a3e07

def hardmask(self):
""" Hardness of the mask """
return self._hardmask

The other methods and attributes of numpy.ma are also defined in the same file (numpy/ma/core.py) AFAIK. If you think they need improvements too, feel free to do so!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
04 - Documentation component: numpy.ma masked arrays sprintable Issue fits the time-frame and setting of a sprint
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants