Open
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR removes the unused argument “df” from AdvancedParticleFilter and updates the code and documentation accordingly. Key changes include:
- Removing the “df” argument from test and documentation examples.
- Introducing the MissingDistribution type and updating constructors to default to it.
- Adding an error check in the smoothing function to enforce that a proper noise density is provided for smoothing.
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/runtests.jl | Removed the unused “df” argument from AdvancedParticleFilter calls. |
| src/utils.jl | Introduced the MissingDistribution type as a placeholder for a missing noise density. |
| src/smoothing.jl | Added an error check to ensure that smoothing fails with a clear message if MissingDistribution is used. |
| src/PFtypes.jl | Updated the constructor to remove the dynamics_density argument and set its default to MissingDistribution. |
| docs/src/index.md | Updated documentation example to remove the “df” argument. |
| docs/src/beetle_example.md | Modified plotting parameters for consistency in the beetle tutorial example. |
Comments suppressed due to low confidence (2)
test/runtests.jl:296
- There is a typo in the comment ('Simuate' should be 'simulate').
x,u,y = LowLevelParticleFilters.simulate(apf,T,du) # Simuate trajectory using the model in the filter
src/PFtypes.jl:178
- Update the constructor documentation to clarify that a valid noise density must be supplied for smoothing since the default MissingDistribution() will trigger a runtime error in that context.
AdvancedParticleFilter(N::Integer, dynamics::Function, measurement::Function, measurement_likelihood, initial_density; p = SciMLBase.NullParameters(), threads = false, kwargs...) = AdvancedParticleFilter(N, dynamics, measurement, measurement_likelihood, MissingDistribution(), initial_density; kwargs...)
| N = num_particles(pf) | ||
| f = dynamics(pf) | ||
| df = dynamics_density(pf) | ||
| df isa MissingDistribution && error("In order to perform smoothing, you must provide a noise density for the dynamics. Use the constructor `AdvancedParticleFilter(N, dynamics, measurement, measurement_likelihood, dynamics_density, initial_density; kwargs...)` to do this") |
There was a problem hiding this comment.
[nitpick] Consider using a more specific custom exception instead of a generic error to allow downstream code to catch and handle this condition in a more controlled manner.
Suggested change
| df isa MissingDistribution && error("In order to perform smoothing, you must provide a noise density for the dynamics. Use the constructor `AdvancedParticleFilter(N, dynamics, measurement, measurement_likelihood, dynamics_density, initial_density; kwargs...)` to do this") | |
| df isa MissingDistribution && throw(MissingDynamicsDensityError("In order to perform smoothing, you must provide a noise density for the dynamics. Use the constructor `AdvancedParticleFilter(N, dynamics, measurement, measurement_likelihood, dynamics_density, initial_density; kwargs...)` to do this")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
dffor APF is only used in smoothing, where it is used in the callto the custom method
This PR thus has to