diff --git a/dpnp/dpnp_iface_statistics.py b/dpnp/dpnp_iface_statistics.py index ab92f8cc625..b14848b4478 100644 --- a/dpnp/dpnp_iface_statistics.py +++ b/dpnp/dpnp_iface_statistics.py @@ -244,8 +244,8 @@ def cov(x1, y=None, rowvar=True, bias=False, ddof=None, fweights=None, aweights= Limitations ----------- - Input array ``m`` is supported as :obj:`dpnp.ndarray`. - Dimension of input array ``m`` is limited by ``m.ndim > 2``. + Input array ``x1`` is supported as :obj:`dpnp.ndarray`. + Dimension of input array ``x1`` is limited by ``x1.ndim > 2``. Size and shape of input arrays are supported to be equal. Prameters ``y`` is supported only with default value ``None``. Prameters ``rowvar`` is supported only with default value ``True``. @@ -274,14 +274,14 @@ def cov(x1, y=None, rowvar=True, bias=False, ddof=None, fweights=None, aweights= """ + if not rowvar and x1.shape[0] != 1: + x1 = dpnp.transpose(x1) x1_desc = dpnp.get_dpnp_descriptor(x1, copy_when_nondefault_queue=False) if x1_desc: if x1_desc.ndim > 2: pass elif y is not None: pass - elif not rowvar: - pass elif bias: pass elif ddof is not None: diff --git a/tests/test_statistics.py b/tests/test_statistics.py index 04a765a73bc..3d72da60816 100644 --- a/tests/test_statistics.py +++ b/tests/test_statistics.py @@ -114,3 +114,16 @@ def test_bincount_weights(self, array, weights): expected = numpy.bincount(np_a, weights=weights) result = dpnp.bincount(dpnp_a, weights=weights) numpy.testing.assert_array_equal(expected, result) + +def test_cov_rowvar1(): + a = dpnp.array([[0, 2], [1, 1], [2, 0]]) + b = numpy.array([[0, 2], [1, 1], [2, 0]]) + numpy.testing.assert_array_equal(dpnp.cov(a.T), dpnp.cov(a,rowvar=False)) + numpy.testing.assert_array_equal(numpy.cov(b,rowvar=False), dpnp.cov(a,rowvar=False)) + +def test_cov_rowvar2(): + a = dpnp.array([[0, 1, 2]]) + b = numpy.array([[0, 1, 2]]) + numpy.testing.assert_array_equal(numpy.cov(b,rowvar=False), dpnp.cov(a,rowvar=False)) + +