@@ -796,24 +796,23 @@ def test_scalar_operations(operation, starting_yarray, scalar_value, expected_ya
796796@pytest .mark .parametrize (
797797 "operation, " "expected_do_1_all_arrays_with_y_modified, " "expected_do_2_all_arrays_with_y_modified" ,
798798 [
799- # Test addition of two DO objects, expect combined yarray values
800- (
799+ ( # Test addition of two DO objects, expect combined yarray values
801800 "add" ,
802801 np .array ([[2.0 , 0.51763809 , 30.0 , 12.13818192 ], [4.0 , 1.0 , 60.0 , 6.28318531 ]]),
803802 np .array ([[2.0 , 6.28318531 , 100.70777771 , 1 ], [4.0 , 3.14159265 , 45.28748053 , 2.0 ]]),
804803 ),
805- # Test subtraction of two DO objects, expect differences in yarray values
806- (
804+ ( # Test subtraction of two DO objects, expect differences in yarray values
807805 "sub" ,
808806 np .array ([[0.0 , 0.51763809 , 30.0 , 12.13818192 ], [0.0 , 1.0 , 60.0 , 6.28318531 ]]),
809807 np .array ([[0.0 , 6.28318531 , 100.70777771 , 1 ], [0.0 , 3.14159265 , 45.28748053 , 2.0 ]]),
810808 ),
811- (
809+ ( # Test multiplication of two DO objects, expect multiplication in yarray values
810+
812811 "mul" ,
813812 np .array ([[1.0 , 0.51763809 , 30.0 , 12.13818192 ], [4.0 , 1.0 , 60.0 , 6.28318531 ]]),
814813 np .array ([[1.0 , 6.28318531 , 100.70777771 , 1 ], [4.0 , 3.14159265 , 45.28748053 , 2.0 ]]),
815814 ),
816- (
815+ ( # Test division of two DO objects, expect division in yarray values
817816 "div" ,
818817 np .array ([[1.0 , 0.51763809 , 30.0 , 12.13818192 ], [1.0 , 1.0 , 60.0 , 6.28318531 ]]),
819818 np .array ([[1.0 , 6.28318531 , 100.70777771 , 1 ], [1.0 , 3.14159265 , 45.28748053 , 2.0 ]]),
@@ -856,15 +855,13 @@ def test_binary_operator_on_do(
856855def test_operator_invalid_type (do_minimal_tth , invalid_add_type_error_msg ):
857856 do = do_minimal_tth
858857 invalid_value = "string_value"
859-
860858 operations = [
861859 (lambda x , y : x + y ), # Test addition
862860 (lambda x , y : x - y ), # Test subtraction
863861 (lambda x , y : x * y ), # Test multiplication
864862 (lambda x , y : x / y ), # Test division
865863 ]
866-
867- # Test each operation with both orderings of operands
864+ # Add a string to a DiffractionObject, expect TypeError
868865 for operation in operations :
869866 with pytest .raises (TypeError , match = re .escape (invalid_add_type_error_msg )):
870867 operation (do , invalid_value )
@@ -878,6 +875,7 @@ def test_operator_invalid_yarray_length(operation, do_minimal, do_minimal_tth, y
878875 do_2 = do_minimal_tth
879876 assert len (do_1 .all_arrays [:, 0 ]) == 0
880877 assert len (do_2 .all_arrays [:, 0 ]) == 2
878+ # Add two DO objets with different yarray lengths, expect ValueError
881879 with pytest .raises (ValueError , match = re .escape (y_grid_size_mismatch_error_msg )):
882880 if operation == "add" :
883881 do_1 + do_2
0 commit comments