Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/pyrecest/filters/circular_ukf.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def filter_state(self) -> GaussianDistribution:
@filter_state.setter
def filter_state(self, new_state):
new_state = _as_circular_gaussian(new_state, "filter_state")
self._filter_state = new_state
AbstractFilter.filter_state.fset(self, new_state)

# ------------------------------------------------------------------
# Prediction
Expand Down
30 changes: 30 additions & 0 deletions tests/filters/test_circular_ukf_state_ownership.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import unittest

import numpy.testing as npt

import pyrecest.backend
from pyrecest.backend import array
from pyrecest.distributions import GaussianDistribution
from pyrecest.filters.circular_ukf import CircularUKF


class CircularUKFStateOwnershipTest(unittest.TestCase):
@unittest.skipUnless(
pyrecest.backend.__backend_name__ == "numpy",
"mutable NumPy arrays required for aliasing regression",
)
def test_assignment_copies_state(self):
filt = CircularUKF()
assigned = GaussianDistribution(array([0.5]), array([[0.7]]))
filt.filter_state = assigned

self.assertIsNot(filt.filter_state, assigned)
assigned.mu[0] = 1.5
assigned.C[0, 0] = 2.0

npt.assert_equal(filt.filter_state.mu, array([0.5]))
npt.assert_equal(filt.filter_state.C, array([[0.7]]))


if __name__ == "__main__":
unittest.main()
Loading