Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Generalize the update and predicted measurement, rather than using the specific Gaussian state subclasses.

Co-authored-by: Steven Hiscocks <sdhiscocks@dstl.gov.uk>
  • Loading branch information
ekhunter123 and sdhiscocks committed Jul 28, 2022
1 parent 05eaa7c commit 136a794
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion stonesoup/feeder/track.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def data_gen(self):
detections.append(
GaussianDetection.from_state(
track.state,
measurement_model=LinearGaussian(dim, range(dim), np.asarray(track.covar)),
measurement_model=LinearGaussian(dim, list(range(dim)), np.asarray(track.covar)),
target_type=GaussianDetection)
)

Expand Down
15 changes: 7 additions & 8 deletions stonesoup/updater/chernoff.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

from ..base import Property
from .base import Updater
from ..types.prediction import GaussianMeasurementPrediction
from ..types.update import GaussianStateUpdate
from ..types.prediction import MeasurementPrediction
from ..types.update import Update


class ChernoffUpdater(Updater):
Expand Down Expand Up @@ -86,9 +86,9 @@ def predict_measurement(self, predicted_state, measurement_model=None, **kwargs
meas_cross_cov = predicted_state.covar

# Combine everything into a GaussianMeasurementPrediction object
return GaussianMeasurementPrediction(predicted_meas, innov_covar,
predicted_state.timestamp,
cross_covar=meas_cross_cov)
return MeasurementPrediction.from_state(predicted_state, predicted_meas, innov_covar,
predicted_state.timestamp,
cross_covar=meas_cross_cov)

def update(self, hypothesis, force_symmetric_covariance=False, **kwargs):
'''
Expand Down Expand Up @@ -127,6 +127,5 @@ def update(self, hypothesis, force_symmetric_covariance=False, **kwargs):
(posterior_covariance + posterior_covariance.T)/2

# Return the updated state
return GaussianStateUpdate(posterior_mean, posterior_covariance,
hypothesis,
hypothesis.measurement.timestamp)
return Update.from_state(hypothesis.prediction, posterior_mean, posterior_covariance,
hypothesis, hypothesis.measurement.timestamp)

0 comments on commit 136a794

Please sign in to comment.