@@ -162,7 +162,7 @@ def get_all_dtypes(
162162
163163
164164def generate_random_numpy_array (
165- shape , dtype = None , hermitian = False , seed_value = None
165+ shape , dtype = None , hermitian = False , seed_value = None , low = - 10 , high = 10
166166):
167167 """
168168 Generate a random numpy array with the specified shape and dtype.
@@ -177,13 +177,19 @@ def generate_random_numpy_array(
177177 dtype : str or dtype, optional
178178 Desired data-type for the output array.
179179 If not specified, data type will be determined by numpy.
180- Default : None
180+ Default : `` None``
181181 hermitian : bool, optional
182182 If True, generates a Hermitian (symmetric if `dtype` is real) matrix.
183- Default : False
183+ Default : `` False``
184184 seed_value : int, optional
185185 The seed value to initialize the random number generator.
186- Default : None
186+ Default : ``None``
187+ low : {int, float}, optional
188+ Lower boundary of the generated samples from a uniform distribution.
189+ Default : ``-10``.
190+ high : {int, float}, optional
191+ Upper boundary of the generated samples from a uniform distribution.
192+ Default : ``10``.
187193
188194 Returns
189195 -------
@@ -197,13 +203,15 @@ def generate_random_numpy_array(
197203
198204 """
199205
200- numpy .random .seed (seed_value )
206+ numpy .random .seed (seed_value ) if seed_value else numpy . random . seed ( 42 )
201207
202- a = numpy .random .randn (* shape ).astype (dtype )
208+ # dtype=int is needed for 0d arrays
209+ size = numpy .prod (shape , dtype = int )
210+ a = numpy .random .uniform (low , high , size ).astype (dtype )
203211 if numpy .issubdtype (a .dtype , numpy .complexfloating ):
204- numpy .random .seed (seed_value )
205- a += 1j * numpy .random .randn (* shape )
212+ a += 1j * numpy .random .uniform (low , high , size )
206213
214+ a = a .reshape (shape )
207215 if hermitian and a .size > 0 :
208216 if a .ndim > 2 :
209217 orig_shape = a .shape
0 commit comments