Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

simplify validation function #113

Merged
merged 3 commits into from
Jan 29, 2024
Merged

simplify validation function #113

merged 3 commits into from
Jan 29, 2024

Conversation

alessandrofelder
Copy link
Member

@alessandrofelder alessandrofelder commented Jan 25, 2024

Description

What is this PR

  • Bug fix
  • Addition of a new feature
  • Other

Why is this PR needed?
New validation functions currently require a change in two places of the main validation script validate_atlases.py.

What does this PR do?
This PR makes all validation functions just take a single argument, which has to be atlas object - this is a requirement from now on. This means we don't need to build and maintain an ordered parameters list for each validation function in validate_atlases.py. Another advantage of this is that it simplifies mocking of atlas functions in the tests

This PR also simplify output list to be dicts of lists mapping the atlas name to values, so a possible output of a successful validations of atlas "allen_mouse_100um" would look like:

{"allen_mouse_100um": [validation_function_1, validation_function_2]}

instead of

[("allen_mouse_100um", validation_function_1), ("allen_mouse_100um", validation_function_2)]

reducing repetition.

References

Closes #112

How has this PR been tested?

Existing tests have been adapted to fit new validation function signature.
Two new test fixtures have been added to reduce code length and increase flexibility.

Is this a breaking change?

Yes, the signature of the validation functions has changed.

Does this PR require an update to the documentation?

To be tackled in brainglobe/brainglobe-atlasapi#209

Checklist:

  • The code has been tested locally
  • Tests have been added to cover all new functionality (unit & integration)
  • The documentation has been updated to reflect any changes
  • The code has been formatted with pre-commit

alessandrofelder and others added 2 commits January 25, 2024 17:17
- all validation functions just take an atlas object
- means we don't need a parameters list
- also simplify output list to be dicts of lists mapping the atlas name to values

- another advantage of this is that it simplifies mocking of atlas functions in the tests
Copy link

codecov bot commented Jan 25, 2024

Codecov Report

Attention: 15 lines in your changes are missing coverage. Please review.

Comparison is base (a4acdb4) 0.00% compared to head (99d8b7b) 0.00%.

Files Patch % Lines
bg_atlasgen/validate_atlases.py 0.00% 15 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##            main    brainglobe/bg-atlasgen#113   +/-   ##
=====================================
  Coverage   0.00%   0.00%           
=====================================
  Files         24      24           
  Lines       1943    1943           
=====================================
  Misses      1943    1943           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@alessandrofelder alessandrofelder marked this pull request as ready for review January 25, 2024 17:25
@alessandrofelder alessandrofelder self-assigned this Jan 25, 2024
try:
validation_function(*validation_function_parameters[i])
successful_validations.append((atlas_name, validation_function))
validation_function(atlas_name)
Copy link
Collaborator

@viktorpm viktorpm Jan 26, 2024

Choose a reason for hiding this comment

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

I tried running the individual functions locally on "allen_mouse_100um". They all worked. When I tried validate_atlases it gave me an error. I think line 161 should be: validation_function(BrainGlobeAtlas(atlas_name)) instead of validation_function(atlas_name). It works when I change it.

Copy link
Collaborator

@viktorpm viktorpm left a comment

Choose a reason for hiding this comment

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

I really like this solution. Just one tiny comment in validate_atlases.py, line 161

Copy link
Collaborator

@viktorpm viktorpm left a comment

Choose a reason for hiding this comment

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

Tested on HPC. It ran with the expected output.

@viktorpm viktorpm merged commit 9259796 into main Jan 29, 2024
8 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Make it easier to add validation functions
2 participants