Skip to content

Commit 39b03ba

Browse files
committed
fixed pylint warnings
1 parent 3616e7d commit 39b03ba

12 files changed

+23
-17
lines changed

creating_a_release.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ Steps to Create Release
33

44
* run pytest
55

6-
* run pylint --disable=similarities filterpy
6+
* run pylint --disable=similarities --disable=R0205 filterpy
7+
R0205 turns off warning about deriving from object. We still support 2.7, so it is needed
78

89
* update filterpy/filterpy/__init__.py with the version number.
910

filterpy/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from . import discrete_bayes
2424
from . import gh
2525
from . import hinfinity
26+
from . import kalman
2627
from . import leastsq
2728
from . import memory
2829
from . import monte_carlo

filterpy/common/discretization.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def Q_discrete_white_noise(dim, dt=1., var=1., block_size=1, order_by_dim=True):
124124
John Wiley & Sons, 2001. Page 274.
125125
"""
126126

127-
if not (dim == 2 or dim == 3 or dim == 4):
127+
if dim not in [2, 3, 4]:
128128
raise ValueError("dim must be between 2 and 4")
129129

130130
if dim == 2:
@@ -195,7 +195,7 @@ def Q_continuous_white_noise(dim, dt=1., spectral_density=1.,
195195
[0. , 0. , 0. , 0. , 0.005 , 0.1 ]])
196196
"""
197197

198-
if not (dim == 2 or dim == 3 or dim == 4):
198+
if dim not in [2, 3, 4]:
199199
raise ValueError("dim must be between 2 and 4")
200200

201201
if dim == 2:
@@ -288,6 +288,10 @@ def van_loan_discretization(F, G, dt):
288288

289289

290290
def linear_ode_discretation(F, L=None, Q=None, dt=1.):
291+
"""
292+
Not sure what this does, probably should be removed
293+
"""
294+
291295
n = F.shape[0]
292296

293297
if L is None:

filterpy/common/helpers.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
#pylint: disable=invalid-name
2+
#pylint: disable=invalid-name, bare-except
33

44
"""Copyright 2015 Roger R Labbe Jr.
55
@@ -361,7 +361,7 @@ def inv_diagonal(S):
361361

362362

363363
def outer_product_sum(A, B=None):
364-
"""
364+
r"""
365365
Computes the sum of the outer products of the rows in A and B
366366
367367
P = \Sum {A[i] B[i].T} for i in 0..N

filterpy/common/kinematic.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
#pylint: disable=invalid-name
2+
#pylint: disable=invalid-name, too-many-locals, import-outside-toplevel
33

44
"""Copyright 2018 Roger R Labbe Jr.
55
@@ -137,6 +137,7 @@ def kinematic_kf(dim, order, dt=1., dim_z=1, order_by_dim=True):
137137
"""
138138

139139
from filterpy.kalman import KalmanFilter
140+
140141
if dim < 1:
141142
raise ValueError("dim must be >= 1")
142143
if order < 0:
@@ -169,4 +170,3 @@ def kinematic_kf(dim, order, dt=1., dim_z=1, order_by_dim=True):
169170
kf.H[i, j] = 1.
170171

171172
return kf
172-

filterpy/kalman/CubatureKalmanFilter.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from math import log, exp, sqrt
2424
import sys
2525
import numpy as np
26-
from numpy import eye, zeros, dot, isscalar, outer
26+
from numpy import eye, zeros, dot, isscalar
2727
from scipy.linalg import inv, cholesky
2828
from filterpy.stats import logpdf
2929
from filterpy.common import pretty_str, outer_product_sum
@@ -376,7 +376,8 @@ def update(self, z, R=None, hx_args=()):
376376
self.y = self.residual_z(z, zp) # residual
377377

378378
self.x = self.x + dot(self.K, self.y)
379-
self.P = self.P - dot(self.K, self.S).dot(self.K.T)
379+
self.P = self.P - dot(self.K, self.S).dot(self.K.T) # pylint: disable=no-member
380+
380381

381382
# save measurement and posterior state
382383
self.z = deepcopy(z)

filterpy/kalman/__init__.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
for more information.
1717
"""
1818

19-
from __future__ import (absolute_import, division, print_function,
20-
unicode_literals)
19+
from __future__ import (absolute_import)
2120

2221
from .EKF import *
2322
from .ensemble_kalman_filter import *

filterpy/kalman/ensemble_kalman_filter.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ def update(self, z, R=None):
254254

255255
P_zz = (outer_product_sum(sigmas_h - z_mean) / (N-1)) + R
256256
P_xz = outer_product_sum(
257-
self.sigmas - self.x, sigmas_h - z_mean) / (N - 1)
257+
self.sigmas - self.x, sigmas_h - z_mean) / (N - 1)
258258

259259
self.S = P_zz
260260
self.SI = self.inv(self.S)

filterpy/kalman/kalman_filter.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@
123123
from copy import deepcopy
124124
from math import log, exp, sqrt
125125
import sys
126-
import warnings
127126
import numpy as np
128127
from numpy import dot, zeros, eye, isscalar, shape
129128
import numpy.linalg as linalg
@@ -1295,7 +1294,7 @@ def test_matrix_dimensions(self, z=None, H=None, R=None, F=None, Q=None):
12951294

12961295
if H.shape[0] == 1:
12971296
# r can be scalar, 1D, or 2D in this case
1298-
assert r_shape == () or r_shape == (1,) or r_shape == (1, 1), \
1297+
assert r_shape in [(), (1,), (1, 1)], \
12991298
"R must be scalar or one element array, but is shaped {}".format(
13001299
r_shape)
13011300
else:

filterpy/kalman/sigma_points.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -502,9 +502,9 @@ def sigma_points(self, x, P):
502502
Istar = np.array([[-1/np.sqrt(2*lambda_), 1/np.sqrt(2*lambda_)]])
503503

504504
for d in range(2, n+1):
505-
row = np.ones((1, Istar.shape[1] + 1)) * 1. / np.sqrt(lambda_*d*(d + 1))
505+
row = np.ones((1, Istar.shape[1] + 1)) * 1. / np.sqrt(lambda_*d*(d + 1)) # pylint: disable=unsubscriptable-object
506506
row[0, -1] = -d / np.sqrt(lambda_ * d * (d + 1))
507-
Istar = np.r_[np.c_[Istar, np.zeros((Istar.shape[0]))], row]
507+
Istar = np.r_[np.c_[Istar, np.zeros((Istar.shape[0]))], row] # pylint: disable=unsubscriptable-object
508508

509509
I = np.sqrt(n)*Istar
510510
scaled_unitary = (U.T).dot(I)

filterpy/stats/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717

1818
from __future__ import absolute_import
1919

20-
__all__ = ["stats"]
20+
#__all__ = ["stats"]
2121

2222
from .stats import *

filterpy/stats/stats.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# -*- coding: utf-8 -*-
22
# pylint: disable=invalid-name, too-many-arguments, bad-whitespace
33
# pylint: disable=too-many-lines, too-many-locals, len-as-condition
4+
# pylint: disable=import-outside-toplevel
45

56
"""Copyright 2015 Roger R Labbe Jr.
67

0 commit comments

Comments
 (0)