Uh oh!
There was an error while loading. Please reload this page.
fix: compare values and shape of xarray values before applying operations between 2 DiffractionObjects - #299
Conversation
| @@ -255,7 +256,9 @@ def _check_operation_compatibility(self, other): | |||
| raise TypeError(invalid_add_type_emsg) | |||
| if isinstance(other, DiffractionObject): | |||
| if self.all_arrays.shape != other.all_arrays.shape: | |||
There was a problem hiding this comment.
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
Codecov ReportAll modified and coverable lines are covered by tests ✅
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
|
| "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]]), |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
do1 and do2 have differnet xarray values, expect invalid.
bobleesj
left a comment
There was a problem hiding this comment.
@sbillinge ready for review
cc' @yucongalicechen
Closes#298 -