Open
Description
At the moment arrays can't be initialized from dictionary values in Python 3:
In [1]: import numpy as np
In [2]: d = {'a':1,'b':2,'c':3}
In [3]: np.array(d.values())
Out[3]: array(dict_values([2, 1, 3]), dtype=object)
and one has to instead explicitly convert to a list first:
In [4]: np.array(list(d.values()))
Out[4]: array([2, 1, 3])
It might be worth adding a special case in the initializer for the array to automatically do this conversion, since d.values()
is a valid iterator?
Metadata
Metadata
Assignees
Labels
No labels