I am trying to create an array of dtype='U'
and saving that using numpy.save()
, however, when trying to load the saved file into a numpy.memmap
I get an error related to the size not being a multiple of 'U3'
I am working with python 3.5.2
. I have tried the following code where I am creating an empty array and another array with 3 entries, all with length of 3 letters and then save the array into file1.npy
file.
import numpy as np
arr = np.empty((1, 0), dtype='U')
arr2 = np.array(['111', '222', '333'], dtype='U')
arr = np.concatenate((arr, arr2), axis = None)
print(arr)
np.save('file1', arr)
rArr = np.memmap('file1.npy', dtype='U3', mode='r')
However, when I try to load the file into a numpy.memmap
I get the the following error ValueError: Size of available data is not a multiple of the data-type size.
Is there a way to load the data into a numpy.memmap
using strings? I feel I am missing something simple.