@@ -715,6 +715,7 @@ def test_copy_object(do_minimal):
715
715
@pytest .mark .parametrize (
716
716
"operation, starting_yarray, scalar_value, expected_yarray" ,
717
717
[
718
+ # Test scalar addition, subtraction, multiplication, and division to y-values by adding a scalar value
718
719
# C1: Test scalar addition to y-values (intensity), expect no change to x-values (q, tth, d)
719
720
( # 1. Add 5
720
721
"add" ,
@@ -796,6 +797,7 @@ def test_scalar_operations(operation, starting_yarray, scalar_value, expected_ya
796
797
@pytest .mark .parametrize (
797
798
"operation, " "expected_do_1_all_arrays_with_y_modified, " "expected_do_2_all_arrays_with_y_modified" ,
798
799
[
800
+ # Test addition, subtraction, multiplication, and division of two DO objects
799
801
( # Test addition of two DO objects, expect combined yarray values
800
802
"add" ,
801
803
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(
852
854
853
855
854
856
def test_operator_invalid_type (do_minimal_tth , invalid_add_type_error_msg ):
857
+ # Add a string to a DiffractionObject, expect TypeError
855
858
do = do_minimal_tth
856
859
invalid_value = "string_value"
857
860
operations = [
@@ -860,7 +863,6 @@ def test_operator_invalid_type(do_minimal_tth, invalid_add_type_error_msg):
860
863
(lambda x , y : x * y ), # Test multiplication
861
864
(lambda x , y : x / y ), # Test division
862
865
]
863
- # Add a string to a DiffractionObject, expect TypeError
864
866
for operation in operations :
865
867
with pytest .raises (TypeError , match = re .escape (invalid_add_type_error_msg )):
866
868
operation (do , invalid_value )
@@ -870,11 +872,11 @@ def test_operator_invalid_type(do_minimal_tth, invalid_add_type_error_msg):
870
872
871
873
@pytest .mark .parametrize ("operation" , ["add" , "sub" , "mul" , "div" ])
872
874
def 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
873
876
do_1 = do_minimal
874
877
do_2 = do_minimal_tth
875
878
assert len (do_1 .all_arrays [:, 0 ]) == 0
876
879
assert len (do_2 .all_arrays [:, 0 ]) == 2
877
- # Add two DO objets with different yarray lengths, expect ValueError
878
880
with pytest .raises (ValueError , match = re .escape (y_grid_size_mismatch_error_msg )):
879
881
if operation == "add" :
880
882
do_1 + do_2
0 commit comments