4
4
5
5
from ..memoize import memoize
6
6
from ..model import Model , get_named_nodes
7
+ import sys
7
8
8
9
9
10
__all__ = ['DensityDist' , 'Distribution' , 'Continuous' , 'Discrete' , 'NoDistribution' , 'TensorType' , 'draw_values' ]
10
11
11
12
13
+ if sys .version_info [0 ] == 3 :
14
+ string_types = str
15
+ else :
16
+ string_types = basestring
17
+
18
+
12
19
class Distribution (object ):
13
20
"""Statistical distribution"""
14
21
def __new__ (cls , name , * args , ** kwargs ):
@@ -19,7 +26,7 @@ def __new__(cls, name, *args, **kwargs):
19
26
"use the Normal('x', 0,1) syntax. "
20
27
"Add a 'with model:' block" )
21
28
22
- if isinstance (name , str ):
29
+ if isinstance (name , string_types ):
23
30
data = kwargs .pop ('observed' , None )
24
31
dist = cls .dist (* args , ** kwargs )
25
32
return model .Var (name , dist , data )
@@ -65,7 +72,7 @@ def get_test_val(self, val, defaults):
65
72
66
73
67
74
def getattr_value (self , val ):
68
- if isinstance (val , str ):
75
+ if isinstance (val , string_types ):
69
76
val = getattr (self , val )
70
77
71
78
if isinstance (val , tt .TensorVariable ):
0 commit comments