Skip to content
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

Extend test case to reveal bug. #3552

Closed

Conversation

rpgoldman
Copy link
Contributor

In sample_posterior_predictive, for ObservedRVs we are supposed to generate samples with a shape that matches the shape of the observed. This fails for DensityDist, as illustrated by this expanded test.

In sample_posterior_predictive, for ObservedRVs we are supposed to generate samples with a shape that matches the shape of the `observed`. This fails for `DensityDist`, as illustrated by this expanded test.
Also revise the test to check for the resulting exception.
@rpgoldman
Copy link
Contributor Author

See questions at the bottom
Just pushed a fix along the lines @lucianopaz suggested (thanks!): this checks the dimensions of the sample returned in order to check and make sure that it's correct, and raises a TypeError otherwise. This will trap problems with DensityDist not handling observations properly.
It's possible we could fix this by changing the interface to DensityDist to allow users to provide distributions that take a shape argument, but that's for later.

  1. Is TypeError the right exception class to use?
  2. I have a yucky structure to avoid repeating the shape-checking everywhere. If anyone has a more elegant way to do this, please LMK.

Copy link
Contributor

@lucianopaz lucianopaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that the test case is already addressed by #3554 so the key feature introduced with this PR is the ShapeError.

The idea of having a special ShapeError exception subclass is nice, but I don't think that we can use it in the _draw_value context. Maybe we could raise it inside generate_samples if the broadcast_shape and dist_shape don't broadcast well with each other. I also don't fully understand why you need the Throw exception.

@twiecki
Copy link
Member

twiecki commented Jul 27, 2020

Closing due to inactivity, feel free to reopen.

@twiecki twiecki closed this Jul 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants