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.3k stars 615 forks source link

Import of KalmanFilter class is wrong on the README #268

Closed xabirizar9 closed 2 years ago

xabirizar9 commented 2 years ago

The import should be from what i understand:

from filterpy.kalman.kalman_filter import KalmanFilter

JBannwarth commented 2 years ago

The __init__.py file in filterpy/kalman/ exposes all the methods/classes contained in filterpy/kalman/kalman_filter.py using the following bit of code:

from .kalman_filter import *

Consequently, the following import is valid:

from filterpy.kalman import KalmanFilter
rlabbe commented 2 years ago

JBannwarth is correct. I wanted to break up the classes into separate files, but following convention did not want to have imports 3 deep. Hence the init.py import. You'll see similar things in the NumPy/SciPy code.