File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change 11
11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
# See the License for the specific language governing permissions and
13
13
# limitations under the License.
14
+ import numpy as np
14
15
import pytest
15
16
16
17
import pymc3 as pm
@@ -39,6 +40,47 @@ def test_new_warnings(self):
39
40
pass
40
41
41
42
43
+ class TestInitvalEvaluation :
44
+ def test_random_draws (self ):
45
+ pmodel = pm .Model ()
46
+ rv = pm .Uniform .dist (lower = 1 , upper = 2 )
47
+ iv = pmodel ._eval_initval (
48
+ rv_var = rv ,
49
+ initval = None ,
50
+ test_value = None ,
51
+ transform = None ,
52
+ )
53
+ assert isinstance (iv , np .ndarray )
54
+ assert 1 <= iv <= 2
55
+ pass
56
+
57
+ def test_applies_transform (self ):
58
+ pmodel = pm .Model ()
59
+ rv = pm .Uniform .dist ()
60
+ tf = pm .Uniform .default_transform ()
61
+ iv = pmodel ._eval_initval (
62
+ rv_var = rv ,
63
+ initval = 0.5 ,
64
+ test_value = None ,
65
+ transform = tf ,
66
+ )
67
+ assert isinstance (iv , np .ndarray )
68
+ assert iv == 0
69
+ pass
70
+
71
+ def test_falls_back_to_test_value (self ):
72
+ pmodel = pm .Model ()
73
+ rv = pm .Flat .dist ()
74
+ iv = pmodel ._eval_initval (
75
+ rv_var = rv ,
76
+ initval = None ,
77
+ test_value = 0.6 ,
78
+ transform = None ,
79
+ )
80
+ assert iv == 0.6
81
+ pass
82
+
83
+
42
84
class TestSpecialDistributions :
43
85
def test_automatically_assigned_test_values (self ):
44
86
# ...because they don't have random number generators.
You can’t perform that action at this time.
0 commit comments