Skip to content

Update numerical file comparisons in tests #231

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

Merged
merged 4 commits into from
Jul 9, 2025

Conversation

Sparks29032
Copy link
Collaborator

Create a shared function for numerical file comparisons.

Copy link

codecov bot commented Jul 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.08%. Comparing base (b4763e1) to head (8364a94).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #231   +/-   ##
=======================================
  Coverage   99.07%   99.08%           
=======================================
  Files          21       21           
  Lines        1084     1087    +3     
=======================================
+ Hits         1074     1077    +3     
  Misses         10       10           
Files with missing lines Coverage Δ
tests/test_morphio.py 100.00% <100.00%> (ø)
tests/test_morphpy.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@sbillinge sbillinge 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. Couple of small comments

@@ -50,6 +50,20 @@ def isfloat(s):
return False


def compare_numeric(file1, file2):
Copy link
Contributor

Choose a reason for hiding this comment

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

this should probably have a name like are_same(file1, file2) since it returns True if they are the same and False if they are not. Something like that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed to are_files_same

@@ -149,7 +163,7 @@ def test_morph_outputs(self, setup, tmp_path):
with open(test_saving_verbose.joinpath(file)) as tf:
generated = filter(ignore_path, gf)
target = filter(ignore_path, tf)
assert all(x == y for x, y in zip(generated, target))
compare_numeric(generated, target)
Copy link
Contributor

Choose a reason for hiding this comment

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

can we call the options expected and actual to make the test more intelligible

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Resolved

@sbillinge sbillinge merged commit 5d9fd64 into diffpy:main Jul 9, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants