The function pysteps.utils.cleansing.decluster returns the first output with an incorrect shape in the specific case of n==1.
How to reproduce
import numpy as np
from pysteps.utils.cleansing import decluster
X = np.array([[0.0, 0.0]]) # ndim==2
V = np.array([[1.0, 1.0]]) # ndim==2
(X_dec, V_dec) = decluster(X, V, 20)
print(X_dec, V_dec)
print(X_dec.ndim)
print(V_dec.ndim)
Prints:
[0. 0.] [[1. 1.]]
1
2
Expected output
According to the documentation of the decluster function:
Returns
-------
out: tuple of ndarrays
A two-element tuple (``out_coord``, ``output_array``) containing the
declustered coordinates (l, d) and input array (l, m), where *l* is
the new number of samples with *l* <= *n*.
That is, both outputs should have ndim==2 even in the edge case of n==1.
Description
The function
pysteps.utils.cleansing.decluster
returns the first output with an incorrect shape in the specific case ofn==1
.How to reproduce
Prints:
Expected output
According to the documentation of the
decluster
function:That is, both outputs should have
ndim==2
even in the edge case ofn==1
.Notes
I didn't examine this throughly, but this may mean that
pysteps.motion.lukaskanade.dense_lucaskanade
does something funny when exactly one motion vector is found by the sparse motion vector search. See call todecluster
here: https://github.com/pySTEPS/pysteps/blob/e2c3484ef234e3ef1ac8f1f11b1e64bc6911f35c/pysteps/motion/lucaskanade.py#L273