-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Closes #3051 - logp numpy array input fixed #3836
Conversation
Converts 'int' type to <TensorType(int64,Scalar)> to parse value to `astype` and allows arguments to `logp(self,value)` when called with numpy array.
Closes pymc-devs#3051 - logp numpy array input- fixed
Allows `logp(self,value)` to take `value` input of type numpy array without errors
@twiecki This should do the job of allowing arguments for logp() to be of type numpy array, right? |
Codecov Report
@@ Coverage Diff @@
## master #3836 +/- ##
=======================================
Coverage 83.45% 83.45%
=======================================
Files 103 103
Lines 14178 14178
=======================================
Hits 11832 11832
Misses 2346 2346
|
@michaelosthege Any idea how I can fix this error in base_hmc.py ? |
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.
Don't worry about the codecov thing. It often makes mistakes in counting the diff.
However, it'd be good if you can add a test to make sure this bug doesn't appear again. Around https://github.com/pymc-devs/pymc3/blob/master/pymc3/tests/test_distributions.py#L778 there are already other test cases dealing with the MvNormal
.
pymc3/distributions/multivariate.py
Outdated
@@ -327,7 +327,7 @@ def logp(self, value): | |||
TensorVariable | |||
""" | |||
quaddist, logdet, ok = self._quaddist(value) | |||
k = value.shape[-1].astype(theano.config.floatX) | |||
k = intX(value.shape[-1]).astype(theano.config.floatX) |
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.
if you want k
to become floatX
, you can use floatX(…)
directly
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.
Since, value.shape[-1] gives out an int
value, I was trying to use intX to convert it to an array form, so that the error can be fixed, but I get your point, we can directly do, k=theano.config.floatX(value.shape[-1])
.
Also, do you mean adding a test for testing this bug^ ? I'll do that right away.
@Ahanmr Could you add a comment to explain why you are using Also, it looks like first you are turning the value into a floatX and then into an intX. Is there some reason you can't simply turn it into an intX value and skip the intermediate step? |
@rpgoldman This is in reference to Issue #3051 based on which, I proceeded to parse the numpy array into an array form to allow astype() operation, but I guess it can be declared directly as |
Added the deprecation of `sd` with `sigma` in newer version with DeprecationWarning on usage of `sd`.
updated RELEASE-NOTES.md
@AlexAndorra I'm not sure why I'm getting this codecov error, any suggestions? Thanks a lot. |
I'd like to get this thing closed, but this branch is a bit messed up. At some point you had the change I requested (commit 9df27b3), but then you reversed it (commit 1d53dcf). Also, the change to the release notes is about a different issue. Git is hard, so here's what I'd like to recommend to fix the history:
The force-push overrides the branch on your forked repository with the one that has a clean history. Since this PR references that branch, the history here will also clear up. |
This looks pretty good to me and a squash-merge should take care of everything. |
Did we have tests at one point? |
We didn't test it. I'll try to get it integrated with the other logp tests |
Great stuff -- thanks @Ahanmr and @michaelosthege! |
Converts
int
type toarray(2, dtype=int32)
to parse value toastype
and allows arguments tologp(self,value)
when called with numpy array inmaster/pymc3/distributions/multivariate.py