Closed mzechmeister closed 3 years ago
genfromtxt is often used with the option dtype=None, e.g. in https://github.com/mzechmeister/serval/blob/e2abb782fb2ce85409de7b32a47adfe5eb591554/src/serval.py#L225 I cannot remember, why I used this option; maybe it was needed in older numpy versions.
genfromtxt
dtype=None
The option causes problems, when one column has a different type e.g. 0-int drift. The result is not a matrix anymore, and cannot be transposed (yielding ValueError: need more than 3 values to unpack); also unpack will not work (https://stackoverflow.com/questions/21937979/numpy-genfromtxt-is-not-unpacking, https://github.com/numpy/numpy/issues/4341).
int
ValueError: need more than 3 values to unpack
unpack
If all columns are floats, a possiblity is to remove the dtype, which defaults to float.
dtype
float
Thanks to Masayuki for pointing out this problem.
genfromtxt
is often used with the optiondtype=None
, e.g. in https://github.com/mzechmeister/serval/blob/e2abb782fb2ce85409de7b32a47adfe5eb591554/src/serval.py#L225 I cannot remember, why I used this option; maybe it was needed in older numpy versions.The option causes problems, when one column has a different type e.g. 0-
int
drift. The result is not a matrix anymore, and cannot be transposed (yieldingValueError: need more than 3 values to unpack
); alsounpack
will not work (https://stackoverflow.com/questions/21937979/numpy-genfromtxt-is-not-unpacking, https://github.com/numpy/numpy/issues/4341).If all columns are floats, a possiblity is to remove the
dtype
, which defaults tofloat
.Thanks to Masayuki for pointing out this problem.