@@ -49,6 +49,11 @@ class GaussianRandomWalkRV(RandomVariable):
49
49
dtype = "floatX"
50
50
_print_name = ("GaussianRandomWalk" , "\\ operatorname{GaussianRandomWalk}" )
51
51
52
+ def make_node (self , rng , size , dtype , mu , sigma , init , steps ):
53
+ steps = at .as_tensor_variable (steps )
54
+ if not steps .ndim == 0 or not steps .dtype .startswith ("float" ):
55
+ raise ValueError ("steps must be an integer scalar (ndim=0)." )
56
+
52
57
def _supp_shape_from_params (self , dist_params , reop_param_idx = 0 , param_shapes = None ):
53
58
steps = dist_params [3 ]
54
59
@@ -94,8 +99,8 @@ def rng_fn(
94
99
ndarray
95
100
"""
96
101
97
- if steps is None or steps < 1 :
98
- raise ValueError ("Steps must be None or greater than 0" )
102
+ if steps < 1 :
103
+ raise ValueError ("Steps must be greater than 0" )
99
104
100
105
# If size is None then the returned series should be (1+steps,)
101
106
if size is None :
@@ -143,17 +148,19 @@ class GaussianRandomWalk(distribution.Continuous):
143
148
144
149
rv_op = gaussianrandomwalk
145
150
146
- def __new__ (cls , name , mu = 0.0 , sigma = 1.0 , init = None , steps : int = 1 , ** kwargs ):
151
+ def __new__ (cls , name , mu = 0.0 , sigma = 1.0 , init = None , steps = None , ** kwargs ):
147
152
check_dist_not_registered (init )
148
153
return super ().__new__ (cls , name , mu , sigma , init , steps , ** kwargs )
149
154
150
155
@classmethod
151
156
def dist (
152
- cls , mu = 0.0 , sigma = 1.0 , init = None , steps : int = 1 , size = None , ** kwargs
157
+ cls , mu = 0.0 , sigma = 1.0 , init = None , steps = None , size = None , ** kwargs
153
158
) -> at .TensorVariable :
154
159
155
160
mu = at .as_tensor_variable (floatX (mu ))
156
161
sigma = at .as_tensor_variable (floatX (sigma ))
162
+ if steps is None :
163
+ raise ValueError ("Must specify steps parameter" )
157
164
steps = at .as_tensor_variable (intX (steps ))
158
165
159
166
if "shape" in kwargs .keys ():
0 commit comments