@@ -715,6 +715,7 @@ def test_copy_object(do_minimal):
715715@pytest .mark .parametrize (
716716 "operation, starting_yarray, scalar_value, expected_yarray" ,
717717 [
718+ # Test scalar addition, subtraction, multiplication, and division to y-values by adding a scalar value
718719 # C1: Test scalar addition to y-values (intensity), expect no change to x-values (q, tth, d)
719720 ( # 1. Add 5
720721 "add" ,
@@ -796,6 +797,7 @@ def test_scalar_operations(operation, starting_yarray, scalar_value, expected_ya
796797@pytest .mark .parametrize (
797798 "operation, " "expected_do_1_all_arrays_with_y_modified, " "expected_do_2_all_arrays_with_y_modified" ,
798799 [
800+ # Test addition, subtraction, multiplication, and division of two DO objects
799801 ( # Test addition of two DO objects, expect combined yarray values
800802 "add" ,
801803 np .array ([[2.0 , 0.51763809 , 30.0 , 12.13818192 ], [4.0 , 1.0 , 60.0 , 6.28318531 ]]),
@@ -852,6 +854,7 @@ def test_binary_operator_on_do(
852854
853855
854856def test_operator_invalid_type (do_minimal_tth , invalid_add_type_error_msg ):
857+ # Add a string to a DiffractionObject, expect TypeError
855858 do = do_minimal_tth
856859 invalid_value = "string_value"
857860 operations = [
@@ -860,7 +863,6 @@ def test_operator_invalid_type(do_minimal_tth, invalid_add_type_error_msg):
860863 (lambda x , y : x * y ), # Test multiplication
861864 (lambda x , y : x / y ), # Test division
862865 ]
863- # Add a string to a DiffractionObject, expect TypeError
864866 for operation in operations :
865867 with pytest .raises (TypeError , match = re .escape (invalid_add_type_error_msg )):
866868 operation (do , invalid_value )
@@ -870,11 +872,11 @@ def test_operator_invalid_type(do_minimal_tth, invalid_add_type_error_msg):
870872
871873@pytest .mark .parametrize ("operation" , ["add" , "sub" , "mul" , "div" ])
872874def test_operator_invalid_yarray_length (operation , do_minimal , do_minimal_tth , y_grid_size_mismatch_error_msg ):
875+ # Add two DO objects with different yarray lengths, expect ValueError
873876 do_1 = do_minimal
874877 do_2 = do_minimal_tth
875878 assert len (do_1 .all_arrays [:, 0 ]) == 0
876879 assert len (do_2 .all_arrays [:, 0 ]) == 2
877- # Add two DO objets with different yarray lengths, expect ValueError
878880 with pytest .raises (ValueError , match = re .escape (y_grid_size_mismatch_error_msg )):
879881 if operation == "add" :
880882 do_1 + do_2
0 commit comments