-
Notifications
You must be signed in to change notification settings - Fork 47
A small functionality added to annotation_utils.py together with a new test for it. #596
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool!
Tiny suggestions to improve code clarity but functionality changes are good.
Consider writing a test for these functions, in a separate PR - (if you have time around your thesis)?
return name, acronym | ||
|
||
|
||
def read_itk_labels(path: Path) -> dict: | ||
def read_itk_labels(path: Path, acryonym_letter=1) -> dict: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename argument as suggested above.
@@ -3,7 +3,7 @@ | |||
from pathlib import Path | |||
|
|||
|
|||
def split_label_text(name: str) -> str: | |||
def split_label_text(name: str, acryonym_letter=1) -> str: | |||
"""Split label text into name + acronym. | |||
|
|||
If the label text ends with ')', extract the acronym inside parentheses. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This docstring needs updating to explain the new function argument:
The "Otherwise, use the first letter as the acronym" part is now wrong!
Co-authored-by: Alessandro Felder <[email protected]>
Co-authored-by: Alessandro Felder <[email protected]>
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice to be thinking about catching errors.
I've made some suggestions around improving the tests - I think they could be a lot simpler.
@@ -12,27 +13,67 @@ | |||
|
|||
|
|||
@pytest.mark.parametrize( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest to split this test into three smaller tests, for clarity.
- One test for default (
acronym_length=1
) - One test for non-default (
acronym_length=3
or similar) - One for error case (
acronym_length = len(atlas_name)+1
)
instead of using pytest.param
?
"BGA-N", | ||
np.random.randint(1), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am confused why you are using randint
here?
I would keep it simple and use 1, 2, len+1 for the three tests.
Before submitting a pull request (PR), please read the contributing guide.
Please fill out as much of this template as you can, but if you have any problems or questions, just leave a comment and we will help out :)
Description
What is this PR
Why is this PR needed?
Currently the read_itk_labels function only supports 1-letter acryonym
What does this PR do?
Now it allows the user to choose the number of first letters the user want to use as structure acryonym.
How has this PR been tested?
Locally
Is this a breaking change?
no
Does this PR require an update to the documentation?
no
Checklist: