Creating table from list of rows fails with numpy-dev (OK for 1.17)
See original GitHub issueWith 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?
Issue Analytics
- State:
- Created 4 years ago
- Comments:13 (13 by maintainers)
Top Results From Across the Web
NumPy
Why NumPy? Powerful n-dimensional arrays. Numerical computing tools. Interoperable. Performant. Open source.
Read more >Comparing a table with rows to an empty table raises ... - GitHub
Description Comparing an empty table to a non-empty table raises a FutureWarning from numpy. Expected behavior No warning.
Read more >Solved: NumPyArrayToTable error "RuntimeError: create tabl...
Solved: Hi - I have a web request that returns JSON that I'm trying to get into a file geodatabase table. When I...
Read more >Constructing a Table — Astropy v5.2
Row -oriented data can be used to create a table using the rows keyword argument. List or tuple of data records. If you...
Read more >python - Numpy is installed but still getting error - Stack Overflow
I will create a new environment and tensorflow11 and try again. I am using the command line to access anaconda. – Nishant. Feb...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Just noticed that this will get fixed by #9165.
Note that while the problem is caused upstream, I think it might still be good to fix
recarray_fromrecords
regardless, at it seems more than a little flaky.