diff --git a/src/pyrecest/backend_support/_pytorch_take_index_contract.py b/src/pyrecest/backend_support/_pytorch_take_index_contract.py index 3edb8a38e..5cdd7c1b3 100644 --- a/src/pyrecest/backend_support/_pytorch_take_index_contract.py +++ b/src/pyrecest/backend_support/_pytorch_take_index_contract.py @@ -3,7 +3,6 @@ from __future__ import annotations import numpy as np - from pyrecest.backend_support._pytorch_assignment_index_contract import ( patch_pytorch_assignment_index_contract as _patch_pytorch_assignment_index_contract, ) diff --git a/src/pyrecest/filters/circular_fourier_filter.py b/src/pyrecest/filters/circular_fourier_filter.py index 7b11e06aa..bb36b19ad 100644 --- a/src/pyrecest/filters/circular_fourier_filter.py +++ b/src/pyrecest/filters/circular_fourier_filter.py @@ -113,13 +113,10 @@ def predict_identity(self, d_sys): # convolution. The inverse FFT returns the discrete circular sum; # multiplying by the grid spacing approximates the convolution # integral over [0, 2*pi). - predicted_values = ( - fft.irfft( - fft.rfft(density_values) * fft.rfft(d_sys), - n=no_coefficients, - ) - * (2.0 * pi / no_coefficients) - ) + predicted_values = fft.irfft( + fft.rfft(density_values) * fft.rfft(d_sys), + n=no_coefficients, + ) * (2.0 * pi / no_coefficients) # Round-off in the FFT can produce tiny negative values although a # convolution of nonnegative densities is nonnegative. predicted_values = maximum(predicted_values, 0.0) diff --git a/src/pyrecest/filters/global_nearest_neighbor.py b/src/pyrecest/filters/global_nearest_neighbor.py index 8c15af1ae..633fdfcdc 100644 --- a/src/pyrecest/filters/global_nearest_neighbor.py +++ b/src/pyrecest/filters/global_nearest_neighbor.py @@ -433,4 +433,4 @@ def update_linear( ) if self.log_posterior_estimates: - self.store_posterior_estimates() \ No newline at end of file + self.store_posterior_estimates() diff --git a/src/pyrecest/filters/kalman_filter.py b/src/pyrecest/filters/kalman_filter.py index 4b8913b54..4bd54ee67 100644 --- a/src/pyrecest/filters/kalman_filter.py +++ b/src/pyrecest/filters/kalman_filter.py @@ -56,9 +56,7 @@ def _validate_kalman_state_covariance(covariance, dim): check_symmetric=True, ) eigenvalues = linalg.eigvalsh(covariance) - if not bool( - backend_all(eigenvalues >= -_STATE_COVARIANCE_EIGENVALUE_ATOL) - ): + if not bool(backend_all(eigenvalues >= -_STATE_COVARIANCE_EIGENVALUE_ATOL)): raise ValueError("state.covariance must be positive semidefinite.") return covariance diff --git a/src/pyrecest/filters/state_space_subdivision_filter.py b/src/pyrecest/filters/state_space_subdivision_filter.py index 84697cb72..2bb14d74b 100644 --- a/src/pyrecest/filters/state_space_subdivision_filter.py +++ b/src/pyrecest/filters/state_space_subdivision_filter.py @@ -152,9 +152,7 @@ def _validated_input_argument(values): ) return values - system_matrices = _validated_matrix_argument( - system_matrices, "system_matrices" - ) + system_matrices = _validated_matrix_argument(system_matrices, "system_matrices") covariance_matrices = _validated_matrix_argument( covariance_matrices, "covariance_matrices" ) diff --git a/src/pyrecest/filters/unscented_kalman_filter.py b/src/pyrecest/filters/unscented_kalman_filter.py index 0f20b27e0..d53613cce 100644 --- a/src/pyrecest/filters/unscented_kalman_filter.py +++ b/src/pyrecest/filters/unscented_kalman_filter.py @@ -3,8 +3,9 @@ from typing import Callable import pyrecest.backend -from pyrecest.backend import atleast_1d, zeros +from pyrecest.backend import atleast_1d from pyrecest.backend import copy as backend_copy +from pyrecest.backend import zeros from pyrecest.distributions import GaussianDistribution from pyrecest.models import AdditiveNoiseMeasurementModel, AdditiveNoiseTransitionModel from pyrecest.sampling.sigma_points import MerweScaledSigmaPoints diff --git a/src/pyrecest/models/_validated_motion_models.py b/src/pyrecest/models/_validated_motion_models.py index 7e6de6868..c36e0373e 100644 --- a/src/pyrecest/models/_validated_motion_models.py +++ b/src/pyrecest/models/_validated_motion_models.py @@ -111,9 +111,7 @@ def coordinated_turn_transition( ) -def coordinated_turn_model( - dt: float = 1.0, noise_covariance: Any | None = None -) -> Any: +def coordinated_turn_model(dt: float = 1.0, noise_covariance: Any | None = None) -> Any: """Return a coordinated-turn model with validated process-noise covariance.""" dt = _motion_models._as_scalar_float( # pylint: disable=protected-access dt, @@ -180,9 +178,7 @@ def se2_unicycle_transition( ) -def se2_unicycle_model( - dt: float = 1.0, noise_covariance: Any | None = None -) -> Any: +def se2_unicycle_model(dt: float = 1.0, noise_covariance: Any | None = None) -> Any: """Return an SE(2) unicycle model with validated process noise.""" dt = _motion_models._as_scalar_float( # pylint: disable=protected-access dt, @@ -193,9 +189,7 @@ def se2_unicycle_model( return _se2_unicycle_model_impl(dt=dt, noise_covariance=noise_covariance) -def se3_pose_twist_model( - dt: float = 1.0, noise_covariance: Any | None = None -) -> Any: +def se3_pose_twist_model(dt: float = 1.0, noise_covariance: Any | None = None) -> Any: """Return an SE(3) pose/twist model with validated process noise.""" dt = _motion_models._as_scalar_float( # pylint: disable=protected-access dt, diff --git a/tests/backend_support/test_pytorch_assignment_index_contract.py b/tests/backend_support/test_pytorch_assignment_index_contract.py index a36c7a611..5c02a7c9a 100644 --- a/tests/backend_support/test_pytorch_assignment_index_contract.py +++ b/tests/backend_support/test_pytorch_assignment_index_contract.py @@ -5,7 +5,6 @@ import importlib.util import pytest - from tests.support.backend_runner import run_backend_code pytestmark = pytest.mark.backend_portable diff --git a/tests/filters/test_abstract_grid_filter_state_ownership.py b/tests/filters/test_abstract_grid_filter_state_ownership.py index f9a00b444..39878e89e 100644 --- a/tests/filters/test_abstract_grid_filter_state_ownership.py +++ b/tests/filters/test_abstract_grid_filter_state_ownership.py @@ -1,5 +1,4 @@ import numpy.testing as npt - from pyrecest.backend import array from pyrecest.distributions.circle.circular_grid_distribution import ( CircularGridDistribution, diff --git a/tests/filters/test_fejer_filter_control_validation.py b/tests/filters/test_fejer_filter_control_validation.py index 249d99c34..7289146cd 100644 --- a/tests/filters/test_fejer_filter_control_validation.py +++ b/tests/filters/test_fejer_filter_control_validation.py @@ -1,6 +1,6 @@ import numpy as np -import pytest import pyrecest.backend +import pytest from pyrecest.filters import FejerIdentityFilter diff --git a/tests/filters/test_global_nearest_neighbor_gating.py b/tests/filters/test_global_nearest_neighbor_gating.py index 2ba620d39..266979215 100644 --- a/tests/filters/test_global_nearest_neighbor_gating.py +++ b/tests/filters/test_global_nearest_neighbor_gating.py @@ -1,15 +1,12 @@ import unittest -from scipy.stats import chi2 - from pyrecest.filters import GlobalNearestNeighbor +from scipy.stats import chi2 class GlobalNearestNeighborGatingTest(unittest.TestCase): def test_default_gate_matches_distance_representation(self): - squared_tracker = GlobalNearestNeighbor( - association_param={"square_dist": True} - ) + squared_tracker = GlobalNearestNeighbor(association_param={"square_dist": True}) unsquared_tracker = GlobalNearestNeighbor( association_param={"square_dist": False} ) diff --git a/tests/filters/test_hyperhemispherical_grid_filter_state_ownership.py b/tests/filters/test_hyperhemispherical_grid_filter_state_ownership.py index 88aade4e2..5ead0e195 100644 --- a/tests/filters/test_hyperhemispherical_grid_filter_state_ownership.py +++ b/tests/filters/test_hyperhemispherical_grid_filter_state_ownership.py @@ -3,7 +3,6 @@ import numpy.testing as npt import pyrecest.backend - from pyrecest.filters.hyperhemispherical_grid_filter import ( HyperhemisphericalGridFilter, ) diff --git a/tests/filters/test_hyperspherical_ukf_dimension_validation.py b/tests/filters/test_hyperspherical_ukf_dimension_validation.py index e391b694c..2429c8e4c 100644 --- a/tests/filters/test_hyperspherical_ukf_dimension_validation.py +++ b/tests/filters/test_hyperspherical_ukf_dimension_validation.py @@ -1,10 +1,8 @@ import numpy as np import pyrecest.backend import pytest - from pyrecest.filters.hyperspherical_ukf import HypersphericalUKF - pytestmark = pytest.mark.skipif( pyrecest.backend.__backend_name__ == "jax", reason="HypersphericalUKF is unsupported on JAX.", diff --git a/tests/filters/test_hyperspherical_ukf_state_ownership.py b/tests/filters/test_hyperspherical_ukf_state_ownership.py index 451502855..a90f61a31 100644 --- a/tests/filters/test_hyperspherical_ukf_state_ownership.py +++ b/tests/filters/test_hyperspherical_ukf_state_ownership.py @@ -1,12 +1,10 @@ import numpy.testing as npt import pyrecest.backend import pytest - from pyrecest.backend import array, eye, to_numpy from pyrecest.distributions import GaussianDistribution from pyrecest.filters.hyperspherical_ukf import HypersphericalUKF - pytestmark = pytest.mark.skipif( pyrecest.backend.__backend_name__ == "jax", reason="HypersphericalUKF is unsupported on JAX.", diff --git a/tests/filters/test_imm_shared_python_matrices.py b/tests/filters/test_imm_shared_python_matrices.py index 45d7de73f..dcd2b6746 100644 --- a/tests/filters/test_imm_shared_python_matrices.py +++ b/tests/filters/test_imm_shared_python_matrices.py @@ -25,9 +25,7 @@ def predict_linear(self, system_matrix, sys_noise_cov, sys_input=None): covariance = ( system_matrix @ self.filter_state.C @ system_matrix.T + sys_noise_cov ) - self.filter_state = GaussianDistribution( - mean, covariance, check_validity=False - ) + self.filter_state = GaussianDistribution(mean, covariance, check_validity=False) @unittest.skipIf( diff --git a/tests/filters/test_kalman_filter_covariance_validation.py b/tests/filters/test_kalman_filter_covariance_validation.py index b85d9bd89..6aa9420b5 100644 --- a/tests/filters/test_kalman_filter_covariance_validation.py +++ b/tests/filters/test_kalman_filter_covariance_validation.py @@ -1,5 +1,4 @@ import pytest - from pyrecest import backend from pyrecest.distributions import GaussianDistribution from pyrecest.filters import KalmanFilter diff --git a/tests/filters/test_low_rank_hypertoroidal_fourier_filter.py b/tests/filters/test_low_rank_hypertoroidal_fourier_filter.py index 4b4b58d4d..ae1c8dee6 100644 --- a/tests/filters/test_low_rank_hypertoroidal_fourier_filter.py +++ b/tests/filters/test_low_rank_hypertoroidal_fourier_filter.py @@ -80,7 +80,9 @@ def test_filter_state_assignment_does_not_alias_low_rank_input(self): state.coefficients = LowRankHypertoroidalFourierDistribution.uniform( (5,), "identity" ).coefficients - npt.assert_allclose(low_rank_filter.filter_state.to_dense(), expected, atol=1e-12) + npt.assert_allclose( + low_rank_filter.filter_state.to_dense(), expected, atol=1e-12 + ) def test_predict_identity_matches_dense_1d(self): dense_filter = HypertoroidalFourierFilter((5,), "identity") diff --git a/tests/filters/test_nearest_neighbor_prediction_validation.py b/tests/filters/test_nearest_neighbor_prediction_validation.py index 6989c0b2e..7260e8541 100644 --- a/tests/filters/test_nearest_neighbor_prediction_validation.py +++ b/tests/filters/test_nearest_neighbor_prediction_validation.py @@ -1,7 +1,6 @@ import unittest import numpy as np - import pyrecest.backend from pyrecest.distributions import GaussianDistribution from pyrecest.filters.global_nearest_neighbor import GlobalNearestNeighbor diff --git a/tests/filters/test_piecewise_constant_filter_state_ownership.py b/tests/filters/test_piecewise_constant_filter_state_ownership.py index 5f05ceb3f..13f182b44 100644 --- a/tests/filters/test_piecewise_constant_filter_state_ownership.py +++ b/tests/filters/test_piecewise_constant_filter_state_ownership.py @@ -1,7 +1,6 @@ import unittest import numpy.testing as npt - from pyrecest.backend import array, copy from pyrecest.distributions.circle.piecewise_constant_distribution import ( PiecewiseConstantDistribution, diff --git a/tests/models/test_motion_model_noise_covariance_validation.py b/tests/models/test_motion_model_noise_covariance_validation.py index b112422ab..8fe24a53d 100644 --- a/tests/models/test_motion_model_noise_covariance_validation.py +++ b/tests/models/test_motion_model_noise_covariance_validation.py @@ -7,11 +7,11 @@ import numpy as np from pyrecest.models import ( coordinated_turn_model, + motion_models, nearly_constant_speed_model, se2_unicycle_model, se3_pose_twist_model, ) -from pyrecest.models import motion_models class TestMotionModelNoiseCovarianceValidation(unittest.TestCase):