summaryrefslogtreecommitdiff
path: root/doc/release/upcoming_changes/16650.compatibility.rst
blob: 6532323552c437ef2aabe2a9522b64acd3d54f22 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
`numpy.genfromtxt` now correctly unpacks structured arrays
----------------------------------------------------------
Previously, `numpy.genfromtxt` failed to unpack if it was called with
``unpack=True`` and a structured datatype was passed to the ``dtype`` argument
(or ``dtype=None`` was passed and a structured datatype was inferred).
For example::

    >>> data = StringIO("21 58.0\n35 72.0")
    >>> np.genfromtxt(data, dtype=None, unpack=True)
    array([(21, 58.), (35, 72.)], dtype=[('f0', '<i8'), ('f1', '<f8')])

Structured arrays will now correctly unpack into a list of arrays,
one for each column::

    >>> np.genfromtxt(data, dtype=None, unpack=True)
    [array([21, 35]), array([58., 72.])]