Skip to content
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

Allow integer or boolean mask to be passed to Masker #1532

Merged
merged 17 commits into from
Feb 27, 2024

Conversation

lauramurgatroyd
Copy link
Member

@lauramurgatroyd lauramurgatroyd commented Oct 12, 2023

Describe your changes

Allows Masker to accept an integer array, in which case it is converted to boolean

Describe any testing you have performed

Please add any demo scripts to CIL-Demos/misc/
Added unit test to make sure error is thrown if mask is integer.

Link relevant issues

Closes #1531

Checklist when you are ready to request a review

  • I have performed a self-review of my code
  • I have added docstrings in line with the guidance in the developer guide
  • I have implemented unit tests that cover any new or modified functionality
  • CHANGELOG.md has been updated with any functionality change
  • Request review from all relevant developers
  • Change pull request label to 'Waiting for review'

Contribution Notes

Please read and adhere to the developer guide and local patterns and conventions.

  • The content of this Pull Request (the Contribution) is intentionally submitted for inclusion in CIL (the Work) under the terms and conditions of the Apache-2.0 License.
  • I confirm that the contribution does not violate any intellectual property rights of third parties

@lauramurgatroyd lauramurgatroyd marked this pull request as draft October 12, 2023 13:33
Copy link
Member

@MargaretDuff MargaretDuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

Copy link
Member

@gfardell gfardell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we may want accept any array and convert it to bool.

mask_boolean = as_array(mask_input, dtype=bool)

This will convert 0s to False and any other value to True, which could catch people out but I think as long as it's documented that:

"masks will be interpreted as boolean with non-zero values set as True"

If the input mask is already boolean then mask_boolean will just be a reference to mask_input

lauramurgatroyd and others added 3 commits December 11, 2023 17:27
Signed-off-by: Laura Murgatroyd <60604372+lauramurgatroyd@users.noreply.github.com>
Copy link
Contributor

@paskino paskino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per comments.

Wrappers/Python/cil/processors/Masker.py Outdated Show resolved Hide resolved
Wrappers/Python/cil/processors/Masker.py Outdated Show resolved Hide resolved
Wrappers/Python/cil/processors/Masker.py Outdated Show resolved Hide resolved
Wrappers/Python/cil/processors/Masker.py Show resolved Hide resolved
Copy link
Member

@gfardell gfardell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add Return to the doc strings, otherwise I'm happy.

@lauramurgatroyd lauramurgatroyd changed the title Fix check for whether Masker's input mask is bool Allow integer or boolean mask to be passed to Masker Jan 4, 2024
@lauramurgatroyd
Copy link
Member Author

I have added docstrings on the Returns and a unit test to check that the user's mask is not modified

Copy link
Contributor

@paskino paskino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm suggesting some minor changes to the docstrings

Wrappers/Python/cil/processors/Masker.py Outdated Show resolved Hide resolved
Wrappers/Python/cil/processors/Masker.py Outdated Show resolved Hide resolved
Wrappers/Python/cil/processors/Masker.py Outdated Show resolved Hide resolved
Wrappers/Python/cil/processors/Masker.py Outdated Show resolved Hide resolved
Wrappers/Python/cil/processors/Masker.py Outdated Show resolved Hide resolved
Wrappers/Python/cil/processors/Masker.py Show resolved Hide resolved
Co-authored-by: Edoardo Pasca <14138589+paskino@users.noreply.github.com>
Signed-off-by: Laura Murgatroyd <60604372+lauramurgatroyd@users.noreply.github.com>
@gfardell gfardell requested a review from paskino January 23, 2024 09:32
lauramurgatroyd and others added 3 commits January 31, 2024 17:09
Signed-off-by: Laura Murgatroyd <60604372+lauramurgatroyd@users.noreply.github.com>
Co-authored-by: Edoardo Pasca <14138589+paskino@users.noreply.github.com>
Signed-off-by: Laura Murgatroyd <60604372+lauramurgatroyd@users.noreply.github.com>
Signed-off-by: Laura Murgatroyd <60604372+lauramurgatroyd@users.noreply.github.com>
@lauramurgatroyd lauramurgatroyd merged commit 451c1d6 into master Feb 27, 2024
3 checks passed
@lauramurgatroyd lauramurgatroyd deleted the masker_bool_type branch February 27, 2024 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

If Masker is passed a non-boolean mask, it will run still but may give an incorrect result
4 participants