Skip to content

Conversation

bobleesj
Copy link
Contributor

Closes #298 -

if not isinstance(other, (DiffractionObject, int, float)):
raise TypeError(invalid_add_type_emsg)
if isinstance(other, DiffractionObject):
if self.all_arrays.shape != other.all_arrays.shape:
Copy link
Contributor Author

@bobleesj bobleesj Dec 30, 2024

Choose a reason for hiding this comment

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

We need to first check the shape. Without this condition, the error message is ValueError: operands could not be broadcast together with shapes (0,3) (2,3) error message instead of getting the expected error message in x_values_not_equal_emsg

Copy link

codecov bot commented Dec 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (88d8d73) to head (98c65dd).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #299   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            8         8           
  Lines          500       511   +11     
=========================================
+ Hits           500       511   +11     
Files with missing lines Coverage Δ
tests/conftest.py 100.00% <100.00%> (ø)
tests/test_diffraction_objects.py 100.00% <100.00%> (ø)

"add",
np.array([[2.0, 0.51763809, 30.0, 12.13818192], [4.0, 1.0, 60.0, 6.28318531]]),
np.array([[2.0, 6.28318531, 100.70777771, 1], [4.0, 3.14159265, 45.28748053, 2.0]]),
np.array([[2.0, 0.51763809, 30.0, 12.13818192], [4.0, 1.0, 60.0, 6.28318531]]),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

add two DOs with identical xarrays, expect valid without error.

):
# Add two DO objects with different xarray values but equal in shape, expect ValueError
do_1 = do_minimal_tth
do_2 = do_minimal_d
Copy link
Contributor Author

Choose a reason for hiding this comment

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

do1 and do2 have differnet xarray values, expect invalid.

Copy link
Contributor Author

@bobleesj bobleesj left a comment

Choose a reason for hiding this comment

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

@sbillinge ready for review

cc' @yucongalicechen

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.

nicely done there.

@sbillinge sbillinge merged commit 65088f9 into diffpy:main Dec 31, 2024
5 checks passed
@bobleesj bobleesj deleted the operation-test-warnings branch December 31, 2024 01:53
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.

fix: revisit tests for DO operations

2 participants