-
Notifications
You must be signed in to change notification settings - Fork 17
remove the unused argument df
#137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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...)
@@ -43,6 +43,7 @@ function smooth(pf::AbstractParticleFilter, xf, wf, wef, ll, M, u, y, p=paramete | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[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.
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")) |
Copilot uses AI. Check for mistakes.
df
for APF is only used in smoothing, where it is used in the callto the custom method
This PR thus has to