Skip to content

Creating table from list of rows fails with numpy-dev (OK for 1.17) #8976

@duncanmmacleod

Description

@duncanmmacleod

With astropy-3.2.1 and numpy-1.16.4 I can create one table from the rows of another, as follows:

>>> from astropy.table import Table
>>> t = Table([[1, 2, 3], [4, 5, 6]], names=('a', 'b'))
>>> print(t)
 a   b
--- ---
  1   4
  2   5
  3   6
>>> print(type(t)(rows=[row for row in t], names=t.dtype.names))
 a   b
--- ---
  1   4
  2   5
  3   6

However, with the same astropy, and numpy-1.17.0rc1 I cannot (well, I can, it just doesn't do what I expect it to):

>>> from astropy.table import Table
>>> t = Table([[1, 2, 3], [4, 5, 6]], names=('a', 'b'))
>>> print(t)
 a   b
--- ---
  1   4
  2   5
  3   6
>>> print(type(t)(rows=[row for row in t], names=t.dtype.names))
a [2]  b [2]
------ ------
1 .. 4 1 .. 4
2 .. 5 2 .. 5
3 .. 6 3 .. 6

If I manually cast each row to list, then things do work again:

>>> print(type(t)(rows=[list(row) for row in t], names=t.dtype.names))
 a   b
--- ---
  1   4
  2   5
  3   6

Is this just a consequence of an upstream change in the new pre-release of numpy, or are tables not really supposed to be created this way in the first place?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions