@@ -49,28 +49,28 @@ def atleast_nd(x: Array, *, ndim: int, xp: ModuleType) -> Array:
4949 return x
5050
5151
52- def cov (x : Array , * , xp : ModuleType ) -> Array :
52+ def cov (m : Array , * , xp : ModuleType ) -> Array :
5353 """..."""
54- x = xp .asarray (x , copy = True )
54+ m = xp .asarray (m , copy = True )
5555 dtype = (
56- xp .float64 if xp .isdtype (x .dtype , "integral" ) else xp .result_type (x , xp .float64 )
56+ xp .float64 if xp .isdtype (m .dtype , "integral" ) else xp .result_type (m , xp .float64 )
5757 )
5858
59- x = atleast_nd (x , ndim = 2 , xp = xp )
60- x = xp .astype (x , dtype )
59+ m = atleast_nd (m , ndim = 2 , xp = xp )
60+ m = xp .astype (m , dtype )
6161
62- avg = mean (x , axis = 1 , xp = xp )
63- fact = x .shape [1 ] - 1
62+ avg = mean (m , axis = 1 , xp = xp )
63+ fact = m .shape [1 ] - 1
6464
6565 if fact <= 0 :
6666 warnings .warn ("Degrees of freedom <= 0 for slice" , RuntimeWarning , stacklevel = 2 )
6767 fact = 0.0
6868
69- x -= avg [:, None ]
70- y_transpose = x .T
71- if xp .isdtype (y_transpose .dtype , "complex floating" ):
72- y_transpose = xp .conj (y_transpose )
73- c = x @ y_transpose
69+ m -= avg [:, None ]
70+ m_transpose = m .T
71+ if xp .isdtype (m_transpose .dtype , "complex floating" ):
72+ m_transpose = xp .conj (m_transpose )
73+ c = m @ m_transpose
7474 c /= fact
7575 axes = tuple (axis for axis , length in enumerate (c .shape ) if length == 1 )
7676 return xp .squeeze (c , axis = axes )
0 commit comments