question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Suggested Alternative Mask handling by NDData

See original GitHub issue

Here is a suggested alternative for handling the mask information as in NDData arithmetic operations that I would like to get feedback on from the NDData folks. The motivation is the future extension of arithmetic operations to NDCube.

This concept applies when both operands are NDData instances/subclasses. The idea is that if the array element has the same mask value in both operands, the operation is executed as normal. But if an array element is masked in one operand and unmasked in the other, then the operation is not performed and the value from the unmasked operand is into the result. Are there reasons why the NDData team thinks this is a bad option to offer? Or any other thoughts or feedback?

Below is a little more detail on implementation.

Mask

The following mask values in the operands leads to the following result on an element-by-element basis. Both False -> False Both True -> True One False, one True -> False

Data & Uncertainty

Let + signify any arithmetic operator. And let a suffix of 1 or 2 signify the value from operand 1 or 2. This is carried out on an array element-by-element basis. Both False -> data1 + data2 & uncertainty1 + uncertainty2 Both True -> data1 + data2 & uncertainty1 + uncertainty2 (But result will be masked.) Mask1 = False & mask2 = True -> data1 & uncertainty1 Mask1 = True & mask2 = False -> data2 & uncertainty2

This algorithm is not intended to replace the functionality currently available. Instead I wonder whether there is interest in it being implemented as an option in NDData so users don’t have to code it up themselves, but rather set a kwarg.

Edges Cases

  • mask = None is equivalent to all pixels unmasked
  • operand1.mask is True or all elements of the mask are True -> result is operand2 and vice versa.
  • Both operands’ masks are True or all elements of both operands’ masks are True -> result is None or error is raised or an empty NDData (if allowed) is returned.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
hamogucommented, Jan 4, 2021

Hi @hamogu. Thanks so much for you feedback. Just so I know the community members better, are you an nddata maintainer? Or more of an interested community member/user?

I’m an interested user.

0reactions
DanRyanIrishcommented, Jan 27, 2021

Hi @mwcraig, thanks for you comments. I’m glad you think this is useful. I think the first thing to understand is what the API should be. Should the nddata arithmetic methods have a library of different paradigms that can be chosen by a kwarg, e.g. handle_mask='ignore masked'. If so, where should the different implementations live?

(Note that this paradigm is different to the current handle_mask options in that it impacts the values in data and uncertainty whereas current handle_mask options only impact the mask.)

Or should each paradigm be its own mixin and the kwargs dispensed with in the user facing API? This might be simpler, but probably makes the code base bigger. The downside for users is that once they instantiate an object, they can only use the one paradigm on their data.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Types of Masks and Respirators - CDC
CDC recommends universal indoor masking for all teachers, staff, students, and visitors to K-12 schools, regardless of vaccination status.
Read more >
What alternatives to face coverings or masks (eg, face shields ...
When used, face shields would need to be considered as potentially contaminated and should be handled, cared for and cleaned appropriately.
Read more >
N95 Respirators, Surgical Masks, Face Masks, and Barrier ...
To safely discard your N95 respirator, place it in a plastic bag and put it in the trash. Wash your hands after handling...
Read more >
The ADA and Face Mask Policies
It is recommended that you wear a high-quality mask through day 10 ... Guidance on Clear Mask Alternatives for People with Disabilities.
Read more >
Reusable Face Masks as Alternative for Disposable Medical ...
Therefore, this paper focuses on evaluating the comfort of reusable masks and suggesting the influential parameters that might affect their ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found