@@ -780,28 +780,28 @@ def test_scalar_operations(operation, starting_yarray, scalar_value, expected_ya
780
780
781
781
782
782
@pytest .mark .parametrize (
783
- "operation, " " expected_do_1_all_arrays_with_y_modified, " " expected_do_2_all_arrays_with_y_modified" ,
783
+ "operation, expected_do_1_all_arrays_with_y_modified, expected_do_2_all_arrays_with_y_modified" ,
784
784
[
785
785
# Test addition, subtraction, multiplication, and division of two DO objects
786
786
( # Test addition of two DO objects, expect combined yarray values
787
787
"add" ,
788
788
np .array ([[2.0 , 0.51763809 , 30.0 , 12.13818192 ], [4.0 , 1.0 , 60.0 , 6.28318531 ]]),
789
- np .array ([[2.0 , 6.28318531 , 100.70777771 , 1 ], [4.0 , 3.14159265 , 45.28748053 , 2.0 ]]),
789
+ np .array ([[2.0 , 0.51763809 , 30.0 , 12.13818192 ], [4.0 , 1.0 , 60.0 , 6.28318531 ]]),
790
790
),
791
791
( # Test subtraction of two DO objects, expect differences in yarray values
792
792
"sub" ,
793
793
np .array ([[0.0 , 0.51763809 , 30.0 , 12.13818192 ], [0.0 , 1.0 , 60.0 , 6.28318531 ]]),
794
- np .array ([[0.0 , 6.28318531 , 100.70777771 , 1 ], [0.0 , 3.14159265 , 45.28748053 , 2.0 ]]),
794
+ np .array ([[0.0 , 0.51763809 , 30.0 , 12.13818192 ], [0.0 , 1.0 , 60.0 , 6.28318531 ]]),
795
795
),
796
796
( # Test multiplication of two DO objects, expect multiplication in yarray values
797
797
"mul" ,
798
798
np .array ([[1.0 , 0.51763809 , 30.0 , 12.13818192 ], [4.0 , 1.0 , 60.0 , 6.28318531 ]]),
799
- np .array ([[1.0 , 6.28318531 , 100.70777771 , 1 ], [4.0 , 3.14159265 , 45.28748053 , 2.0 ]]),
799
+ np .array ([[1.0 , 0.51763809 , 30.0 , 12.13818192 ], [4.0 , 1.0 , 60.0 , 6.28318531 ]]),
800
800
),
801
801
( # Test division of two DO objects, expect division in yarray values
802
802
"div" ,
803
803
np .array ([[1.0 , 0.51763809 , 30.0 , 12.13818192 ], [1.0 , 1.0 , 60.0 , 6.28318531 ]]),
804
- np .array ([[1.0 , 6.28318531 , 100.70777771 , 1 ], [1.0 , 3.14159265 , 45.28748053 , 2.0 ]]),
804
+ np .array ([[1.0 , 0.51763809 , 30.0 , 12.13818192 ], [1.0 , 1.0 , 60.0 , 6.28318531 ]]),
805
805
),
806
806
],
807
807
)
@@ -810,15 +810,14 @@ def test_binary_operator_on_do(
810
810
expected_do_1_all_arrays_with_y_modified ,
811
811
expected_do_2_all_arrays_with_y_modified ,
812
812
do_minimal_tth ,
813
- do_minimal_d ,
814
813
):
815
814
do_1 = do_minimal_tth
816
- do_2 = do_minimal_d
815
+ do_2 = do_minimal_tth
817
816
assert np .allclose (
818
817
do_1 .all_arrays , np .array ([[1.0 , 0.51763809 , 30.0 , 12.13818192 ], [2.0 , 1.0 , 60.0 , 6.28318531 ]])
819
818
)
820
819
assert np .allclose (
821
- do_2 .all_arrays , np .array ([[1.0 , 6.28318531 , 100.70777771 , 1 ], [2.0 , 3.14159265 , 45.28748053 , 2.0 ]])
820
+ do_2 .all_arrays , np .array ([[1.0 , 0.51763809 , 30.0 , 12.13818192 ], [2.0 , 1.0 , 60.0 , 6.28318531 ]])
822
821
)
823
822
824
823
if operation == "add" :
@@ -856,13 +855,31 @@ def test_operator_invalid_type(do_minimal_tth, invalid_add_type_error_msg):
856
855
857
856
858
857
@pytest .mark .parametrize ("operation" , ["add" , "sub" , "mul" , "div" ])
859
- def test_operator_invalid_yarray_length (operation , do_minimal , do_minimal_tth , y_grid_size_mismatch_error_msg ):
860
- # Add two DO objects with different yarray lengths, expect ValueError
858
+ def test_operator_invalid_xarray_values_not_equal (
859
+ operation , do_minimal_tth , do_minimal_d , x_values_not_equal_error_msg
860
+ ):
861
+ # Add two DO objects with different xarray values but equal in shape, expect ValueError
862
+ do_1 = do_minimal_tth
863
+ do_2 = do_minimal_d
864
+ with pytest .raises (ValueError , match = re .escape (x_values_not_equal_error_msg )):
865
+ if operation == "add" :
866
+ do_1 + do_2
867
+ elif operation == "sub" :
868
+ do_1 - do_2
869
+ elif operation == "mul" :
870
+ do_1 * do_2
871
+ elif operation == "div" :
872
+ do_1 / do_2
873
+
874
+
875
+ @pytest .mark .parametrize ("operation" , ["add" , "sub" , "mul" , "div" ])
876
+ def test_operator_invalid_xarray_shape_not_equal (
877
+ operation , do_minimal , do_minimal_tth , x_values_not_equal_error_msg
878
+ ):
879
+ # Add two DO objects with different xarrays shape, expect ValueError
861
880
do_1 = do_minimal
862
881
do_2 = do_minimal_tth
863
- assert len (do_1 .all_arrays [:, 0 ]) == 0
864
- assert len (do_2 .all_arrays [:, 0 ]) == 2
865
- with pytest .raises (ValueError , match = re .escape (y_grid_size_mismatch_error_msg )):
882
+ with pytest .raises (ValueError , match = re .escape (x_values_not_equal_error_msg )):
866
883
if operation == "add" :
867
884
do_1 + do_2
868
885
elif operation == "sub" :
0 commit comments