import numpy as np
a = np.arange(1000000).reshape(1000,1000)
print(a**2)
With this code I get this answer. Why do I get negative values?
A solution to this problem is as follows (taken from here):
...change in class StringConverter._mapper (numpy/lib/_iotools.py) from:
{{{
_mapper = [(nx.bool_, str2bool, False),
(nx.integer, int, -1),
(nx.floating, float, nx.nan),
(complex, _bytes_to_complex, nx.nan + 0j),
(nx.string_, bytes, asbytes('???'))]
}}}
to
{{{
_mapper = [(nx.bool_, str2bool, False),
(nx.int64, int, -1),
(nx.floating, float, nx.nan),
(complex, _bytes_to_complex, nx.nan + 0j),
(nx.string_, bytes, asbytes('???'))]
}}}
This solved a similar problem that I had with numpy.genfromtxt for me
Note that the author describes this as a 'temporary' and 'not optimal' solution. However, I have had no side effects using v2.7 (yet?!).