-
Notifications
You must be signed in to change notification settings - Fork 21
Remove unused test util functions for comparing two dicts, use __eq__
to compare DiffractionObjects
#214
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
Conversation
Warning! No news item is found for this PR. If this is a user-facing change/feature/fix, |
# setattr(diffraction_object1, attribute, inputs1[i]) | ||
# setattr(diffraction_object2, attribute, inputs2[i]) | ||
print(dicts_equal(diffraction_object1.__dict__, diffraction_object2.__dict__), expected) | ||
assert dicts_equal(diffraction_object1.__dict__, diffraction_object2.__dict__) == expected |
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.
Since we will be introducing an unique uuid
via _id
, this test will fail. But rather we use __eq__
method to compare two objects.
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.
@bobleesj yes, this is much cleaner. A sure sign that our code and API is improving, don't you think?
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.
absolutely
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #214 +/- ##
==========================================
+ Coverage 96.54% 99.68% +3.14%
==========================================
Files 8 8
Lines 347 316 -31
==========================================
- Hits 335 315 -20
+ Misses 12 1 -11
|
@@ -8,43 +8,6 @@ | |||
|
|||
from diffpy.utils.diffraction_objects import XQUANTITIES, DiffractionObject | |||
|
|||
|
|||
def compare_dicts(dict1, dict2): |
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.
These functions are no longer used in our test code - We. may use the DeepDiff
library instead to compare two dicts as implemented in our previous PR:
@pytest.mark.parametrize("inputs, expected", tc_params)
def test_constructor(inputs, expected):
actual_do = DiffractionObject(**inputs)
diff = DeepDiff(actual_do.__dict__, expected, ignore_order=True, significant_digits=13)
assert diff == {}
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.
While I was waiting for other PRs to be merged, I was reading the code and found these potential areas of improvement. Please let me know! @sbillinge
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.
yes, thanks for this @bobleesj
# setattr(diffraction_object1, attribute, inputs1[i]) | ||
# setattr(diffraction_object2, attribute, inputs2[i]) | ||
print(dicts_equal(diffraction_object1.__dict__, diffraction_object2.__dict__), expected) | ||
assert dicts_equal(diffraction_object1.__dict__, diffraction_object2.__dict__) == expected |
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.
@bobleesj yes, this is much cleaner. A sure sign that our code and API is improving, don't you think?
No description provided.