@@ -47,6 +47,7 @@ def check_x(self, a_shape, b_shape, xp, dtype):
4747 testing .assert_array_equal (b_copy , b )
4848 return result
4949
50+ @testing .with_requires ("numpy>=2.0" )
5051 def test_solve (self ):
5152 self .check_x ((4 , 4 ), (4 ,))
5253 self .check_x ((5 , 5 ), (5 , 2 ))
@@ -55,15 +56,9 @@ def test_solve(self):
5556 self .check_x ((0 , 0 ), (0 ,))
5657 self .check_x ((0 , 0 ), (0 , 2 ))
5758 self .check_x ((0 , 2 , 2 ), (0 , 2 , 3 ))
58- # In numpy 2.0 the broadcast ambiguity has been removed and now
59- # b is treaded as a single vector if and only if it is 1-dimensional;
60- # for other cases this signature must be followed
61- # (..., m, m), (..., m, n) -> (..., m, n)
62- # https://github.com/numpy/numpy/pull/25914
63- if numpy .lib .NumpyVersion (numpy .__version__ ) < "2.0.0" :
64- self .check_x ((2 , 4 , 4 ), (2 , 4 ))
65- self .check_x ((2 , 3 , 2 , 2 ), (2 , 3 , 2 ))
66- self .check_x ((0 , 2 , 2 ), (0 , 2 ))
59+ # Allowed since numpy 2
60+ self .check_x ((2 , 3 , 3 ), (3 ,))
61+ self .check_x ((2 , 5 , 3 , 3 ), (3 ,))
6762
6863 def check_shape (self , a_shape , b_shape , error_types ):
6964 for xp , error_type in error_types .items ():
@@ -82,6 +77,7 @@ def test_solve_singular_empty(self, xp):
8277 # LinAlgError("Singular matrix") is not raised
8378 return xp .linalg .solve (a , b )
8479
80+ @testing .with_requires ("numpy>=2.0" )
8581 def test_invalid_shape (self ):
8682 linalg_errors = {
8783 numpy : numpy .linalg .LinAlgError ,
@@ -96,11 +92,12 @@ def test_invalid_shape(self):
9692 self .check_shape ((3 , 3 ), (2 ,), value_errors )
9793 self .check_shape ((3 , 3 ), (2 , 2 ), value_errors )
9894 self .check_shape ((3 , 3 , 4 ), (3 ,), linalg_errors )
99- # Since numpy >= 2.0, this case does not raise an error
100- if numpy .lib .NumpyVersion (numpy .__version__ ) < "2.0.0" :
101- self .check_shape ((2 , 3 , 3 ), (3 ,), value_errors )
10295 self .check_shape ((3 , 3 ), (0 ,), value_errors )
10396 self .check_shape ((0 , 3 , 4 ), (3 ,), linalg_errors )
97+ # Not allowed since numpy 2.0
98+ self .check_shape ((0 , 2 , 2 ), (0 , 2 ), value_errors )
99+ self .check_shape ((2 , 4 , 4 ), (2 , 4 ), value_errors )
100+ self .check_shape ((2 , 3 , 2 , 2 ), (2 , 3 , 2 ), value_errors )
104101
105102
106103@testing .parameterize (
0 commit comments