Comments (3)
Hi!
First of all, nice work on thw waste free SMC @hai-dang-dau !
On this, testing for behaviour based on the presence or absence of an attribute is an antipattern an can lead to issues as you highlighted. This should be handled by the inheritance contract, so the real thing to check is if self is an instance of APFMixin (or AuxiliaryPF, depending on logic). The way I would go around it is to delete the isAPF altogether and then replace its use by a direct isinstance check. For instance this
Line 311 in 8e5eb4c
would be replaced more cleanly by
if isinstance(self.fk, AuxiliaryPF):
if you are worried about circular imports, you can also use local imports of AuxiliaryPF
from particles.
@AdrienCorenflos Thanks for your feedback. I do not entirely agree with the type checking solution because that seems to go against Python's "duck typing" philosophy (i.e. any object with the logeta
method should work with the implementation, regardless of its type).
My proposition would be to add a boolean-valued useAPF
keyword argument in the SMC class. My arguments are:
(1) Even if a FeynmanKac
object does include the logeta
method, the user may, out of curiosity, prefers running the standard filter instead and sets useAPF=False
.
(2) If useAPF
is set to True
, the implementation shall call fk.logeta
without checking. So if the user passes in a FeynmanKac
object without logeta
method and sets useAPF=True
, an AttributeError
is therefore automatically raised (which is what we want anyway).
from particles.
I applied the quick fix recommended by Dang. Now things should work as expected.
But it's true that the current design is a bit dodgy, as proved by this "silent bug". I'll think about it.
from particles.
Related Issues (20)
- Missing feature: Multivariate normal distribution with a different covariance matrix for each particle HOT 2
- Error in guided particle filtering for pre-implemented stochastic volatility model. HOT 4
- Restricting sampling of parameters HOT 4
- Information request regarding particle attribute and predictive steps HOT 1
- nsteps in backward_sampling_mcmc
- Categorical distribution
- Automate upper_bound_log_pt
- Mixture error? HOT 3
- Potential Bug in SMC2 HOT 1
- Forum Creation HOT 3
- Not working given example in the Kalman file HOT 1
- Bug in BayesianVS_gprior HOT 1
- Feature request: parallelisation over the particles? HOT 3
- smc_samplers.AdaptiveTempering may raise an error before reaching exponent == 1. HOT 1
- Problem with missing data HOT 6
- Sensor fusion - multiple `PY` depending on which sensor is returning HOT 6
- How to use this module to implement Particle Metropolis Hastings? HOT 6
- Is there a fast way to define a vector of parameters? HOT 17
- Question : Is it possible to use control commands `u` in `PX`? HOT 2
- How to get the distribution of x in the lib? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from particles.