@@ -780,28 +780,28 @@ def test_scalar_operations(operation, starting_yarray, scalar_value, expected_ya
780780
781781
782782@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" ,
784784 [
785785 # Test addition, subtraction, multiplication, and division of two DO objects
786786 ( # Test addition of two DO objects, expect combined yarray values
787787 "add" ,
788788 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 ]]),
790790 ),
791791 ( # Test subtraction of two DO objects, expect differences in yarray values
792792 "sub" ,
793793 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 ]]),
795795 ),
796796 ( # Test multiplication of two DO objects, expect multiplication in yarray values
797797 "mul" ,
798798 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 ]]),
800800 ),
801801 ( # Test division of two DO objects, expect division in yarray values
802802 "div" ,
803803 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 ]]),
805805 ),
806806 ],
807807)
@@ -810,15 +810,14 @@ def test_binary_operator_on_do(
810810 expected_do_1_all_arrays_with_y_modified ,
811811 expected_do_2_all_arrays_with_y_modified ,
812812 do_minimal_tth ,
813- do_minimal_d ,
814813):
815814 do_1 = do_minimal_tth
816- do_2 = do_minimal_d
815+ do_2 = do_minimal_tth
817816 assert np .allclose (
818817 do_1 .all_arrays , np .array ([[1.0 , 0.51763809 , 30.0 , 12.13818192 ], [2.0 , 1.0 , 60.0 , 6.28318531 ]])
819818 )
820819 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 ]])
822821 )
823822
824823 if operation == "add" :
@@ -856,13 +855,31 @@ def test_operator_invalid_type(do_minimal_tth, invalid_add_type_error_msg):
856855
857856
858857@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
861880 do_1 = do_minimal
862881 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 )):
866883 if operation == "add" :
867884 do_1 + do_2
868885 elif operation == "sub" :
0 commit comments