
![]() | Given an object a,
a = asarray(a)converts a to a NumPy array (if possible/necessary) |
![]() | Arrays can be ordered as in C (default) or Fortran:
a = asarray(a, order='Fortran') isfortran(a) # returns True if a's order is Fortran |
![]() | Use asarray to, e.g., allow flexible arguments in functions:
def myfunc(some_sequence):
a = asarray(some_sequence)
return 3*a - 5
myfunc([1,2,3]) # list argument
myfunc((-1,1)) # tuple argument
myfunc(zeros(10)) # array argument
myfunc(-4.5) # float argument
myfunc(6) # int argument
|