I need to write an array to a file using numpy, and I am trying to read in an array as raw input and convert it to an array. My problem seems to be coming from the line
inarray = np.array(inlist)
, because the code is not returning an array.
Here is my entire code:
import numpy as np
def write():
inlist = raw_input('Please enter a square array of booleans.')
print inlist
inarray = np.array(inlist)
print inarray
dims = inarray.shape
print dims
dim = dims[0]
name = open(name,'w')
name.write(dims)
dimint = int(dim)
i = 0
while i < dimint:
name.write(inarray[i])
i = i+1
return name
write()