-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Refactor Factor
properties
#5320
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
Conversation
96298da
to
e093f41
Compare
Codecov Report
@@ Coverage Diff @@
## main #5320 +/- ##
==========================================
+ Coverage 80.23% 80.34% +0.11%
==========================================
Files 89 89
Lines 14856 14805 -51
==========================================
- Hits 11919 11895 -24
+ Misses 2937 2910 -27
|
5204f90
to
3ad64e2
Compare
26ea8ce
to
354cca8
Compare
934a5bb
to
8c47f83
Compare
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.
Sorry about that nitpick, but given how much code calls these properties/methods, could you add some type hints?
Even incomplete type hints here can give a lot of mypy coverage, right?
6cf2209
to
bf4c982
Compare
96bc0dc
to
42e3eaa
Compare
42e3eaa
to
e2a6751
Compare
This is shaping up to be a really nice refactor of some quite obscure code. |
e2a6751
to
c044f34
Compare
Hopefully one will also be less lost when doing autocomplete on a Model to find a method xD |
c044f34
to
cd1b313
Compare
* compiled functions like `dlogp` are now called `compile_*` * `logp_elemwiset` -> `logpt(sum=False)` * `*_no_jacobian` graphs and functions are now obtained via the keyword `jacobian=False` * Value variables are no longer passed to `model.compile_fn` by default * Rename `logpt` to `joint_logpt`
This also fixes a bug where graphs with NotImplemented gradients were not detected before deciding on optimization method
This would fail when the chains do not have the same length, resulting in the marginal_likelihood being wrapped in a numpy array of `object` dtype. This led the nanmean call to fail with an AttributeError
cd1b313
to
a1e30eb
Compare
I'm open to having docstring link to docstrings of the other properties/methods. |
Yeah I think the |
This PR deprecates most of the Factor properties, and gives the following default methods:
The prefix
compile
is there to make it obvious this is a costly operation, and that the results should be cached once and reused afterwards. Also this makes it easier to deprecate the old properties, which couldn't easily be changed into methods.It also deprecates
LoosePointFunc
and renamesFastPointFunc
toPointFunc
which is now the default. This closes #5318.Finally this PR also renames
pm.logpt
topm.joint_logpt
, which is now the main bridge betweenPyMC
andAeppl
. The reason for this is thatpm.logpt
has diverged quite a lot from what it was doing inV3
, and because of that it has a lot of ugly internal logic that should be handled by theModel
object instead (involving trying to find value variables, transforms and scaling in the tags of the variables). The rename will hopefully help break the dependency that's there for backwards compat and facilitate refactoring in the future, such as #5033.It would be nice to find a nice way to transition fromDecided to break away immediately following discussion in #5333Model.logpt
being a property -> method that can acceptvars
,jacobian
andsum
as an argument. Then we can remove the more verboselogp_elemwiset
, which is temporarily playing this more flexible role, in service of all other methods and properties