From 80600907ee33b20007f51aea97db91c9f74483d3 Mon Sep 17 00:00:00 2001 From: Veeresh Taranalli Date: Mon, 23 May 2016 00:20:23 -0700 Subject: [PATCH] Fixes #14 and #35. numpydoc module is included in the list of sphinx extensions which fixes #14 and including scipy.ndimage in the list of mock modules fixes #35. --- docs/conf.py | 14 ++++++----- docs/discrete_bayes/discrete_bayes.rst | 2 -- filterpy/kalman/kalman_filter.py | 32 ++++++++++++++------------ 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 01089b9..f9c683a 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -17,13 +17,13 @@ import os import mock - + MOCK_MODULES = ['numpy', 'scipy', 'matplotlib', 'matplotlib.pyplot', 'scipy.linalg', 'numpy.linalg', 'matplotlib.pyplot', 'numpy.random', 'scipy.sparse', 'scipy.sparse.linalg', 'scipy.stats', 'matplotlib.patches', 'scipy.ndimage.filters', - 'scipy.ndimage.interpolation'] - + 'scipy.ndimage.interpolation', 'scipy.ndimage'] + for mod_name in MOCK_MODULES: sys.modules[mod_name] = mock.Mock() @@ -32,7 +32,8 @@ # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. #sys.path.insert(0, os.path.abspath('.')) -sys.path.insert(0, os.path.abspath('../filterpy')) +#sys.path.insert(0, os.path.abspath('../filterpy')) +sys.path.insert(0, os.path.abspath('../')) from filterpy import * import filterpy @@ -53,7 +54,8 @@ 'sphinx.ext.intersphinx', 'sphinx.ext.mathjax', 'sphinx.ext.viewcode', - 'sphinx.ext.autodoc' + 'sphinx.ext.autodoc', + 'numpydoc' ] # Add any paths that contain templates here, relative to this directory. @@ -357,4 +359,4 @@ # Example configuration for intersphinx: refer to the Python standard library. intersphinx_mapping = {'http://docs.python.org/': None} -autodoc_member_order = 'bysource' \ No newline at end of file +autodoc_member_order = 'bysource' diff --git a/docs/discrete_bayes/discrete_bayes.rst b/docs/discrete_bayes/discrete_bayes.rst index c226939..8f9c045 100644 --- a/docs/discrete_bayes/discrete_bayes.rst +++ b/docs/discrete_bayes/discrete_bayes.rst @@ -16,5 +16,3 @@ words go here ----- .. autofunction:: predict - ------ diff --git a/filterpy/kalman/kalman_filter.py b/filterpy/kalman/kalman_filter.py index c47b876..579eddb 100644 --- a/filterpy/kalman/kalman_filter.py +++ b/filterpy/kalman/kalman_filter.py @@ -468,21 +468,21 @@ def batch_filter(self, zs, Fs=None, Qs=None, Hs=None, Rs=None, Bs=None, us=None, Returns ------- - means: np.array((n,dim_x,1)) + means : np.array((n,dim_x,1)) array of the state for each time step after the update. Each entry is an np.array. In other words `means[k,:]` is the state at step `k`. - covariance: np.array((n,dim_x,dim_x)) + covariance : np.array((n,dim_x,dim_x)) array of the covariances for each time step after the update. In other words `covariance[k,:,:]` is the covariance at step `k`. - means_predictions: np.array((n,dim_x,1)) + means_predictions : np.array((n,dim_x,1)) array of the state for each time step after the predictions. Each entry is an np.array. In other words `means[k,:]` is the state at step `k`. - covariance_predictions: np.array((n,dim_x,dim_x)) + covariance_predictions : np.array((n,dim_x,dim_x)) array of the covariances for each time step after the prediction. In other words `covariance[k,:,:]` is the covariance at step `k`. @@ -645,7 +645,7 @@ def get_prediction(self, u=0): Returns ------- - (x, P) + (x, P) : tuple State vector and covariance array of the prediction. """ @@ -1006,34 +1006,36 @@ def batch_filter(x, P, zs, Fs, Qs, Hs, Rs, Bs=None, us=None, update_first=False) Returns ------- - means: np.array((n,dim_x,1)) + means : np.array((n,dim_x,1)) array of the state for each time step after the update. Each entry is an np.array. In other words `means[k,:]` is the state at step `k`. - covariance: np.array((n,dim_x,dim_x)) + covariance : np.array((n,dim_x,dim_x)) array of the covariances for each time step after the update. In other words `covariance[k,:,:]` is the covariance at step `k`. - means_predictions: np.array((n,dim_x,1)) + means_predictions : np.array((n,dim_x,1)) array of the state for each time step after the predictions. Each entry is an np.array. In other words `means[k,:]` is the state at step `k`. - covariance_predictions: np.array((n,dim_x,dim_x)) + covariance_predictions : np.array((n,dim_x,dim_x)) array of the covariances for each time step after the prediction. In other words `covariance[k,:,:]` is the covariance at step `k`. Examples -------- - zs = [t + random.randn()*4 for t in range (40)] - Fs = [kf.F for t in range (40)] - Hs = [kf.H for t in range (40)] + .. code-block:: Python + + zs = [t + random.randn()*4 for t in range (40)] + Fs = [kf.F for t in range (40)] + Hs = [kf.H for t in range (40)] - (mu, cov, _, _) = kf.batch_filter(zs, Rs=R_list, Fs=Fs, Hs=Hs, Qs=None, - Bs=None, us=None, update_first=False) - (xs, Ps, Ks) = kf.rts_smoother(mu, cov, Fs=Fs, Qs=None) + (mu, cov, _, _) = kf.batch_filter(zs, Rs=R_list, Fs=Fs, Hs=Hs, Qs=None, + Bs=None, us=None, update_first=False) + (xs, Ps, Ks) = kf.rts_smoother(mu, cov, Fs=Fs, Qs=None) """