-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Refactor pm.Simulator (2nd attempt) #4877
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
********** | ||
Simulator | ||
********** | ||
|
||
.. currentmodule:: pymc3.distributions.simulator | ||
.. autosummary:: | ||
|
||
SimulatorRV | ||
Simulator | ||
|
||
.. automodule:: pymc3.distributions.simulator | ||
:members: |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -350,15 +350,26 @@ def rvs_to_value_vars( | |
|
||
""" | ||
|
||
# Avoid circular dependency | ||
from pymc3.distributions.simulator import SimulatorRV | ||
|
||
def transform_replacements(var, replacements): | ||
rv_var, rv_value_var = extract_rv_and_value_vars(var) | ||
|
||
if rv_value_var is None: | ||
warnings.warn( | ||
f"No value variable found for {rv_var}; " | ||
"the random variable will not be replaced." | ||
) | ||
return [] | ||
# If RandomVariable does not have a value_var and corresponds to | ||
# a SimulatorRV, we allow further replacements in upstream graph | ||
if isinstance(rv_var.owner.op, SimulatorRV): | ||
# First 3 inputs are just rng, dtype, and size, which don't | ||
# need to be replaced. | ||
return var.owner.inputs[3:] | ||
|
||
else: | ||
warnings.warn( | ||
f"No value variable found for {rv_var}; " | ||
"the random variable will not be replaced." | ||
) | ||
Comment on lines
+368
to
+371
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What conclusion should a user make from from this warning? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should probably raise |
||
return [] | ||
|
||
transform = getattr(rv_value_var.tag, "transform", None) | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.