Skip to content

Commit

Permalink
MAINT: use get/setattr instead of globals and inspect
Browse files Browse the repository at this point in the history
  • Loading branch information
eigenfoo committed Jan 12, 2019
1 parent 19a8b0e commit 4e46134
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pymc4/_random_variables.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from . import _template_contexts as contexts

import inspect
import sys
import tensorflow as tf
import tensorflow_probability as tfp

Expand Down Expand Up @@ -166,7 +166,9 @@ def as_tensor(self):


# Programmatically wrap tfp distrubtions into pm random variables
tfp_dists = inspect.getmodule(tfp.distributions).__dict__

for dist_name in __all__:
globals()[dist_name] = type(dist_name, (RandomVariable,), {"_base_dist": tfp_dists[dist_name]})
setattr(
sys.modules[__name__],
dist_name,
type(dist_name, (RandomVariable,), {"_base_dist": getattr(tfp.distributions, dist_name)}),
)

0 comments on commit 4e46134

Please sign in to comment.