Skip to content

jax.numpy.cov and numpy.cov have different results for empty arrays #32296

@adriagarp

Description

@adriagarp

Description

While working on data-apis/array-api-extra#451, we discovered different behavior between jax.numpy.cov and numpy.cov for empty arrays:

import jax.numpy as jnp
import numpy as np
print(repr(np.cov(np.array([]))))
print(repr(jnp.cov(jnp.array([]))))

Output:

array(nan)
Array(-0., dtype=float32)

Is this intended? Is this something that you would consider changing?

Thanks!

System info (python version, jaxlib version, accelerator, etc.)

jax:    0.7.1
jaxlib: 0.7.1
numpy:  2.3.3
python: 3.13.7 | packaged by conda-forge | (main, Sep  3 2025, 14:24:46) [Clang 19.1.7 ]
device info: cpu-1, 1 local devices"
process_count: 1
platform: uname_result(system='Darwin', node='xxxxxxx', release='25.0.0', version='Darwin Kernel Version 25.0.0: Mon Aug 25 21:17:56 PDT 2025; root:xnu-12377.1.9~3/RELEASE_ARM64_T6030', machine='arm64')

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions