rlabbe / filterpy

Python Kalman filtering and optimal estimation library. Implements Kalman filter, particle filter, Extended Kalman filter, Unscented Kalman filter, g-h (alpha-beta), least squares, H Infinity, smoothers, and more. Has companion book 'Kalman and Bayesian Filters in Python'.
MIT License
3.31k stars 617 forks source link

Shape of z incorrect when None #228

Open rlabbe opened 3 years ago

rlabbe commented 3 years ago

I initialize z to [[None], [None], [None]] in several places. It should never be 2 dimensional by default. Use z_reshape anywhere this is done to ensure it is the right shape.

This mostly causes a problem when using Saver.to_array(), as that cannot deal with a list of zs of different dimensions, so that is a good unit test to write.

I know this happens in the KalmanFilter class, but I'm sure it happens anywhere I store self.z in any of the classes.