Skip to content

Commit 47789df

Browse files
committed
Update dpnp.cov implementation to properly transposes 2d array when rowvar=False
1 parent 7b8e014 commit 47789df

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

dpnp/dpnp_utils/dpnp_utils_statistics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def _get_2dmin_array(x, dtype):
153153
elif x.ndim == 1:
154154
x = x[dpnp.newaxis, :]
155155

156-
if not rowvar and x.shape[0] != 1:
156+
if not rowvar and x.ndim != 1:
157157
x = x.T
158158

159159
if x.dtype != dtype:

dpnp/tests/test_statistics.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
get_float_complex_dtypes,
1717
has_support_aspect64,
1818
)
19+
from .third_party.cupy.testing import with_requires
1920

2021

2122
class TestAverage:
@@ -619,6 +620,8 @@ def test_cov_rowvar(dtype):
619620
assert_allclose(numpy.cov(b, rowvar=False), dpnp.cov(a, rowvar=False))
620621

621622

623+
# numpy 2.2 properly transposes 2d array when rowvar=False
624+
@with_requires("numpy>=2.2")
622625
@pytest.mark.parametrize(
623626
"dtype", get_all_dtypes(no_bool=True, no_none=True, no_complex=True)
624627
)

0 commit comments

Comments
 (0)