mzechmeister / serval

calculate radial velocities from stellar spectra
MIT License
36 stars 9 forks source link

genfromtxt ValueError: need more than 4 values to unpack #39

Closed mzechmeister closed 3 years ago

mzechmeister commented 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.

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).

If all columns are floats, a possiblity is to remove the dtype, which defaults to float.

Thanks to Masayuki for pointing out this problem.