@@ -705,7 +705,7 @@ def test_copy_object(do_minimal):
705
705
706
706
707
707
@pytest .mark .parametrize (
708
- "starting_all_arrays, scalar_value , expected_all_arrays" ,
708
+ "starting_all_arrays, scalar_to_add , expected_all_arrays" ,
709
709
[
710
710
# Test scalar addition to xarray values (q, tth, d) and expect no change to yarray values
711
711
( # C1: Add integer of 5, expect xarray to increase by by 5
@@ -720,11 +720,13 @@ def test_copy_object(do_minimal):
720
720
),
721
721
],
722
722
)
723
- def test_addition_operator_by_scalar (starting_all_arrays , scalar_value , expected_all_arrays , do_minimal_tth ):
723
+ def test_addition_operator_by_scalar (starting_all_arrays , scalar_to_add , expected_all_arrays , do_minimal_tth ):
724
724
do = do_minimal_tth
725
725
assert np .allclose (do .all_arrays , starting_all_arrays )
726
- do_sum = do + scalar_value
727
- assert np .allclose (do_sum .all_arrays , expected_all_arrays )
726
+ do_sum_RHS = do + scalar_to_add
727
+ do_sum_LHS = scalar_to_add + do
728
+ assert np .allclose (do_sum_RHS .all_arrays , expected_all_arrays )
729
+ assert np .allclose (do_sum_LHS .all_arrays , expected_all_arrays )
728
730
729
731
730
732
@pytest .mark .parametrize (
@@ -750,10 +752,12 @@ def test_addition_operator_by_another_do(LHS_all_arrays, RHS_all_arrays, expecte
750
752
751
753
def test_addition_operator_invalid_type (do_minimal_tth , invalid_add_type_error_msg ):
752
754
# Add a string to a DO object, expect TypeError, only scalar (int, float) allowed for addition
753
- do_LHS = do_minimal_tth
755
+ do = do_minimal_tth
754
756
with pytest .raises (TypeError , match = re .escape (invalid_add_type_error_msg )):
755
- do_LHS + "string_value"
756
-
757
+ do + "string_value"
758
+ with pytest .raises (TypeError , match = re .escape (invalid_add_type_error_msg )):
759
+ "string_value" + do
760
+
757
761
758
762
def test_addition_operator_invalid_xarray_length (do_minimal , do_minimal_tth , x_grid_size_mismatch_error_msg ):
759
763
# Combine two DO objects, one with empty xarrays (do_minimal) and the other with non-empty xarrays
0 commit comments