@@ -723,6 +723,23 @@ def test_axis_out_of_bounds(self, xp: ModuleType):
723723 with pytest .raises (IndexError ):
724724 _ = cov (m , axis = 5 )
725725
726+ def test_weights_wrong_ndim (self , xp : ModuleType ):
727+ m = xp .asarray ([[1.0 , 2.0 , 3.0 ], [4.0 , 5.0 , 6.0 ]])
728+ w2d = xp .asarray ([[1.0 , 1.0 , 1.0 ], [1.0 , 1.0 , 1.0 ]])
729+ # Non-integer correction forces the generic path where the
730+ # validation lives; native backends raise for the same reason.
731+ with pytest .raises ((ValueError , TypeError )):
732+ _ = cov (m , correction = 0.5 , fweights = w2d )
733+ with pytest .raises ((ValueError , TypeError )):
734+ _ = cov (m , correction = 0.5 , aweights = w2d )
735+
736+ def test_weights_wrong_length (self , xp : ModuleType ):
737+ m = xp .asarray ([[1.0 , 2.0 , 3.0 ], [4.0 , 5.0 , 6.0 ]])
738+ w_bad = xp .asarray ([1.0 , 1.0 ]) # expected length 3
739+ with pytest .raises ((ValueError , RuntimeError )):
740+ _ = cov (m , correction = 0.5 , fweights = w_bad )
741+ with pytest .raises ((ValueError , RuntimeError )):
742+ _ = cov (m , correction = 0.5 , aweights = w_bad )
726743
727744
728745@pytest .mark .xfail_xp_backend (Backend .SPARSE , reason = "no arange" , strict = False )
0 commit comments