@@ -796,24 +796,23 @@ def test_scalar_operations(operation, starting_yarray, scalar_value, expected_ya
796
796
@pytest .mark .parametrize (
797
797
"operation, " "expected_do_1_all_arrays_with_y_modified, " "expected_do_2_all_arrays_with_y_modified" ,
798
798
[
799
- # Test addition of two DO objects, expect combined yarray values
800
- (
799
+ ( # Test addition of two DO objects, expect combined yarray values
801
800
"add" ,
802
801
np .array ([[2.0 , 0.51763809 , 30.0 , 12.13818192 ], [4.0 , 1.0 , 60.0 , 6.28318531 ]]),
803
802
np .array ([[2.0 , 6.28318531 , 100.70777771 , 1 ], [4.0 , 3.14159265 , 45.28748053 , 2.0 ]]),
804
803
),
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
807
805
"sub" ,
808
806
np .array ([[0.0 , 0.51763809 , 30.0 , 12.13818192 ], [0.0 , 1.0 , 60.0 , 6.28318531 ]]),
809
807
np .array ([[0.0 , 6.28318531 , 100.70777771 , 1 ], [0.0 , 3.14159265 , 45.28748053 , 2.0 ]]),
810
808
),
811
- (
809
+ ( # Test multiplication of two DO objects, expect multiplication in yarray values
810
+
812
811
"mul" ,
813
812
np .array ([[1.0 , 0.51763809 , 30.0 , 12.13818192 ], [4.0 , 1.0 , 60.0 , 6.28318531 ]]),
814
813
np .array ([[1.0 , 6.28318531 , 100.70777771 , 1 ], [4.0 , 3.14159265 , 45.28748053 , 2.0 ]]),
815
814
),
816
- (
815
+ ( # Test division of two DO objects, expect division in yarray values
817
816
"div" ,
818
817
np .array ([[1.0 , 0.51763809 , 30.0 , 12.13818192 ], [1.0 , 1.0 , 60.0 , 6.28318531 ]]),
819
818
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(
856
855
def test_operator_invalid_type (do_minimal_tth , invalid_add_type_error_msg ):
857
856
do = do_minimal_tth
858
857
invalid_value = "string_value"
859
-
860
858
operations = [
861
859
(lambda x , y : x + y ), # Test addition
862
860
(lambda x , y : x - y ), # Test subtraction
863
861
(lambda x , y : x * y ), # Test multiplication
864
862
(lambda x , y : x / y ), # Test division
865
863
]
866
-
867
- # Test each operation with both orderings of operands
864
+ # Add a string to a DiffractionObject, expect TypeError
868
865
for operation in operations :
869
866
with pytest .raises (TypeError , match = re .escape (invalid_add_type_error_msg )):
870
867
operation (do , invalid_value )
@@ -878,6 +875,7 @@ def test_operator_invalid_yarray_length(operation, do_minimal, do_minimal_tth, y
878
875
do_2 = do_minimal_tth
879
876
assert len (do_1 .all_arrays [:, 0 ]) == 0
880
877
assert len (do_2 .all_arrays [:, 0 ]) == 2
878
+ # Add two DO objets with different yarray lengths, expect ValueError
881
879
with pytest .raises (ValueError , match = re .escape (y_grid_size_mismatch_error_msg )):
882
880
if operation == "add" :
883
881
do_1 + do_2
0 commit comments