Permalink
Browse files

add docstrings to random variables (#394)

* add docstrings to random variables

* unit tests for randomvariable docstrings
  • Loading branch information...
1 parent b1bda5b commit 9f53d0cde82c6e7b70286a023eaa881b6b883bbf @jkerfs jkerfs committed with dustinvtran Jan 12, 2017
Showing with 21 additions and 8 deletions.
  1. +2 −8 edward/models/random_variables.py
  2. +19 −0 tests/test-models/test_bernoulli_doc.py
@@ -3,7 +3,6 @@
from __future__ import print_function
import inspect
-import tensorflow as tf
from edward.models.empirical import Empirical as distributions_Empirical
from edward.models.point_mass import PointMass as distributions_PointMass
@@ -30,12 +29,7 @@ def __init__(self, *args, **kwargs):
_candidate != distributions.Distribution and
issubclass(_candidate, distributions.Distribution)):
- class _WrapperRandomVariable(RandomVariable, _candidate):
- def __init__(self, *args, **kwargs):
- RandomVariable.__init__(self, *args, **kwargs)
+ params = {'__doc__': _candidate.__doc__}
+ _globals[_name] = type(_name, (RandomVariable, _candidate), params)
- _WrapperRandomVariable.__name__ = _name
- _globals[_name] = _WrapperRandomVariable
-
- del _WrapperRandomVariable
del _candidate
@@ -0,0 +1,19 @@
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+
+import tensorflow as tf
+from tensorflow.contrib.distributions import Bernoulli as tfBernoulli
+
+from edward.models import Bernoulli
+
+
+class test_bernoulli_doc_class(tf.test.TestCase):
+
+ def test_0d(self):
+ assert len(Bernoulli.__doc__) > 0
+ assert Bernoulli.__doc__ == tfBernoulli.__doc__
+ assert Bernoulli.__name__ == "Bernoulli"
+
+if __name__ == '__main__':
+ tf.test.main()

0 comments on commit 9f53d0c

Please sign in to comment.