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

Generate AfidSet for testing #24

Merged
merged 1 commit into from
Aug 29, 2023
Merged

Generate AfidSet for testing #24

merged 1 commit into from
Aug 29, 2023

Conversation

kaitj
Copy link
Contributor

@kaitj kaitj commented Aug 28, 2023

Proposed changes
This PR updates and renames the afid_coord strategy to afid_set, generating a near complete AfidSet object (sans desc). This allows for future testing of methods requiring a (in)valid AfidSet, while still being able to use a list of AfidPositions by invoking AfidSet.afids.

Additionally, this adds in an additional AfidSet.load to the valid_save_fcsv test, to ensure that the generated AfidSet that is saved can also be loaded.

Types of changes
What types of changes does your code introduce? Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Other (if none of the other choices apply)

Checklist
Put an x in the boxes that apply. You can also fill these out after creating the PR. If you are unsure about any of the choices, don't hesitate to ask!

  • Changes have been tested to ensure that fix is effective or that a feature works.
  • Changes pass the unit tests
  • Code has been run through the poe quality task
  • I have included necessary documentation or comments (as necessary)
  • Any dependent changes have been merged and published

Notes
All PRs will undergo the unit testing before being reviewed. You may be requested to explain or make additional changes before the PR is accepted.

- Add a strategy that updates afids_coords to generating a near-complete
  AfidSet. `desc` was left out as it would not be read upon saving and
this field may be dropped in future updates.
- Additionally adds a round-trip AfidSet.load, asserting that the file
  loaded is of the correct class in `save_fcsv`
@kaitj kaitj added the maintenance Updates or improvements that do not change functionality of the code label Aug 28, 2023
@github-actions github-actions bot requested a review from tkkuehn August 28, 2023 18:31
@codecov
Copy link

codecov bot commented Aug 28, 2023

Codecov Report

Merging #24 (0a47aa0) into main (ba3147d) will not change coverage.
The diff coverage is 100.00%.

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #24   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            8         8           
  Lines          348       353    +5     
=========================================
+ Hits           348       353    +5     
Components Coverage Δ
afids_utils/afids.py ∅ <ø> (∅)
afids_utils/ext 100.00% <ø> (ø)
afids_utils/transforms.py 100.00% <ø> (ø)

Copy link
Contributor

@tkkuehn tkkuehn left a comment

Choose a reason for hiding this comment

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

A couple of minor comments but this largely looks good

afids_utils/tests/strategies.py Show resolved Hide resolved
@@ -19,7 +19,7 @@ class AfidPosition:
x: float = attrs.field()
y: float = attrs.field()
z: float = attrs.field()
desc: str = attrs.field()
desc: str = attrs.field(default="")
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd rather not have a default value that's invalid here (even if you want to leave the invalid descs in the test for now)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair enough, I think alternatively I can load in the valid descs and any invalid ones set to "Unknown".

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds reasonable to me, or you can just leave it without a default until we implement the validation

afids_utils/tests/test_ext.py Show resolved Hide resolved
def test_invalid_num_afids(self, afids_coords: list[AfidPosition]) -> None:
# Check to see if file can be loaded with afids-utils
test_load = AfidSet.load(out_fcsv_file.name)
assert isinstance(test_load, AfidSet)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we could even assert test_load == afids_set

Copy link
Contributor Author

@kaitj kaitj Aug 29, 2023

Choose a reason for hiding this comment

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

Ahh yeah, this test can be simplified quite a bit with the new afid_sets strategy (and slight modification since it also randomly generates the slicer version by default)

@kaitj kaitj merged commit 0a47aa0 into afids:main Aug 29, 2023
7 checks passed
@kaitj
Copy link
Contributor Author

kaitj commented Aug 29, 2023

Ahh oops, this one was accidental, will see if I can roll back, otherwise will throw a patch in.

Oh nvm, I see. it is because #25 got merged in and that was based off of this one. Oops. Will make a new patch PR to address the comments

@kaitj kaitj mentioned this pull request Aug 29, 2023
9 tasks
@kaitj kaitj deleted the test/afid_set branch August 29, 2023 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Updates or improvements that do not change functionality of the code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants