@@ -162,7 +162,13 @@ def get_all_dtypes(
162162
163163
164164def generate_random_numpy_array (
165- shape , dtype = None , hermitian = False , seed_value = None , low = - 10 , high = 10
165+ shape ,
166+ dtype = None ,
167+ order = "C" ,
168+ hermitian = False ,
169+ seed_value = None ,
170+ low = - 10 ,
171+ high = 10 ,
166172):
167173 """
168174 Generate a random numpy array with the specified shape and dtype.
@@ -178,6 +184,9 @@ def generate_random_numpy_array(
178184 Desired data-type for the output array.
179185 If not specified, data type will be determined by numpy.
180186 Default : ``None``
187+ order : {"C", "F"}, optional
188+ Specify the memory layout of the output array.
189+ Default: ``"C"``.
181190 hermitian : bool, optional
182191 If True, generates a Hermitian (symmetric if `dtype` is real) matrix.
183192 Default : ``False``
@@ -194,7 +203,7 @@ def generate_random_numpy_array(
194203 Returns
195204 -------
196205 out : numpy.ndarray
197- A random numpy array of the specified shape and dtype .
206+ A random numpy array of the specified shape, dtype and memory layout .
198207 The array is Hermitian or symmetric if `hermitian` is True.
199208
200209 Note:
@@ -224,6 +233,10 @@ def generate_random_numpy_array(
224233 a = a .reshape (orig_shape )
225234 else :
226235 a = numpy .conj (a .T ) @ a
236+
237+ # a.reshape(shape) returns an array in C order by default
238+ if order != "C" and a .ndim > 1 :
239+ a = numpy .array (a , order = order )
227240 return a
228241
229242
0 commit comments