question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:13 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
mhvkcommented, Sep 14, 2019

Just noticed that this will get fixed by #9165.

1reaction
mhvkcommented, Jul 12, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found