@@ -162,7 +162,13 @@ def get_all_dtypes(
162
162
163
163
164
164
def 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 ,
166
172
):
167
173
"""
168
174
Generate a random numpy array with the specified shape and dtype.
@@ -178,6 +184,9 @@ def generate_random_numpy_array(
178
184
Desired data-type for the output array.
179
185
If not specified, data type will be determined by numpy.
180
186
Default : ``None``
187
+ order : {"C", "F"}, optional
188
+ Specify the memory layout of the output array.
189
+ Default: ``"C"``.
181
190
hermitian : bool, optional
182
191
If True, generates a Hermitian (symmetric if `dtype` is real) matrix.
183
192
Default : ``False``
@@ -194,7 +203,7 @@ def generate_random_numpy_array(
194
203
Returns
195
204
-------
196
205
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 .
198
207
The array is Hermitian or symmetric if `hermitian` is True.
199
208
200
209
Note:
@@ -224,6 +233,10 @@ def generate_random_numpy_array(
224
233
a = a .reshape (orig_shape )
225
234
else :
226
235
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 )
227
240
return a
228
241
229
242
0 commit comments