diff --git a/src/pyrecest/distributions/hypertorus/abstract_hypertoroidal_distribution.py b/src/pyrecest/distributions/hypertorus/abstract_hypertoroidal_distribution.py index 379759ce5..d18079f8d 100644 --- a/src/pyrecest/distributions/hypertorus/abstract_hypertoroidal_distribution.py +++ b/src/pyrecest/distributions/hypertorus/abstract_hypertoroidal_distribution.py @@ -180,7 +180,9 @@ def hellinger_dist_fun(*args): x = array(args) return (sqrt(self.pdf(x)) - sqrt(other.pdf(x))) ** 2 - squared_dist = 0.5 * self.integrate_fun_over_domain(hellinger_dist_fun, self.dim) + squared_dist = 0.5 * self.integrate_fun_over_domain( + hellinger_dist_fun, self.dim + ) return sqrt(squared_dist) def total_variation_distance_numerical(self, other): diff --git a/src/pyrecest/filters/_ukf.py b/src/pyrecest/filters/_ukf.py index 477a021ac..3141d3f16 100644 --- a/src/pyrecest/filters/_ukf.py +++ b/src/pyrecest/filters/_ukf.py @@ -147,9 +147,7 @@ def update(self, z, R=None, hx=None, **hx_args): sigmas_h = None dim_z = None for i in range(sigmas_f.shape[0]): - sigma_h = reshape( - asarray(hx(sigmas_f[i], **hx_args), dtype=float64), (-1,) - ) + sigma_h = reshape(asarray(hx(sigmas_f[i], **hx_args), dtype=float64), (-1,)) if sigmas_h is None: dim_z = sigma_h.shape[0] sigmas_h = empty((sigmas_f.shape[0], dim_z)) @@ -179,9 +177,7 @@ def update(self, z, R=None, hx=None, **hx_args): if using_default_R else "measurement noise covariance R" ) - raise ValueError( - f"{source} has shape {R.shape}, expected {(dim_z, dim_z)}" - ) + raise ValueError(f"{source} has shape {R.shape}, expected {(dim_z, dim_z)}") z_pred = einsum("i,ij->j", Wm, sigmas_h) Pz, Pxz = self._innovation_matrices(sigmas_f, sigmas_h, z_pred, R, Wc) @@ -201,4 +197,4 @@ def __deepcopy__(self, memo): memo[id(self)] = result for k, v in self.__dict__.items(): setattr(result, k, deepcopy(v, memo)) - return result \ No newline at end of file + return result diff --git a/src/pyrecest/filters/abstract_particle_filter.py b/src/pyrecest/filters/abstract_particle_filter.py index 5684e7e55..d557f9b72 100644 --- a/src/pyrecest/filters/abstract_particle_filter.py +++ b/src/pyrecest/filters/abstract_particle_filter.py @@ -25,7 +25,9 @@ def _call_vectorized_sample_next(sample_next, particles, n_particles): return sample_next(particles, n_particles) return sample_next(particles, n=n_particles) - if any(param.kind == inspect.Parameter.VAR_KEYWORD for param in parameters.values()): + if any( + param.kind == inspect.Parameter.VAR_KEYWORD for param in parameters.values() + ): return sample_next(particles, n=n_particles) return sample_next(particles) diff --git a/src/pyrecest/filters/unscented_kalman_filter.py b/src/pyrecest/filters/unscented_kalman_filter.py index 3abb76a5f..16042db69 100644 --- a/src/pyrecest/filters/unscented_kalman_filter.py +++ b/src/pyrecest/filters/unscented_kalman_filter.py @@ -34,7 +34,11 @@ def __init__( raise ValueError( "initial_state must be a GaussianDistribution or a tuple of (mean, covariance)" ) - dim_z = reshape(asarray(hx(initial_mean), dtype=float64), (-1,)).shape[0] if dim_z is None else dim_z + dim_z = ( + reshape(asarray(hx(initial_mean), dtype=float64), (-1,)).shape[0] + if dim_z is None + else dim_z + ) if points is None: # Standard settings for Gaussian approximations diff --git a/tests/filters/test_unscented_kalman_filter.py b/tests/filters/test_unscented_kalman_filter.py index f71294eb3..f49731ee0 100644 --- a/tests/filters/test_unscented_kalman_filter.py +++ b/tests/filters/test_unscented_kalman_filter.py @@ -76,9 +76,7 @@ def test_update_linear_rectangular_measurement(self): kf.update_linear(array([1.0]), array([[1.0, 0.0]]), array([[0.5]])) npt.assert_allclose(kf.get_point_estimate(), array([2.0 / 3.0, 1.0])) - npt.assert_allclose( - kf.filter_state.covariance(), diag(array([1.0 / 3.0, 2.0])) - ) + npt.assert_allclose(kf.filter_state.covariance(), diag(array([1.0 / 3.0, 2.0]))) @unittest.skipIf( pyrecest.backend.__backend_name__ in ("pytorch", "jax"),