-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Table cannot read numpy void dtype #12577
Comments
@mhvk, I'm not sure if ECSV is saving enough info to reconstruct the full dtype. It might be, because the type isn't just |
Yikes, I thought we had just solved that... Though it may just be to include 'void' in the first place in that list (which I'm guessing is not in the same |
Unfortunately it doesn't appear that easy a fix. Adding |
Probably good to get @taldcroft to look at this case. Let me also give a more minimal example, since it is not related to
So, I think the basic first step is to represent the data type correctly, as a structured one (which of course we just did, but may need to be careful about strings inside structured data types...) |
There is no support in ECSV for structured data like I think for now this could be called a bug in the ECSV writer that it doesn't detect such a datatype and stop with a good exception message. |
Indeed, I think that subtype trick could work! Though it would loose the names of the structure elements. Alternatively, and perhaps easier, would treat this case more like a |
@taldcroft @mhvk, I think the >>> x = np.array([(1, np.ones((2, 2))), (2, np.zeros((2, 2)))],
... dtype=[("a", "i4"), ("b", "float64", (2, 2))])
>>> x["b"]
array([[[1., 1.],
[1., 1.]],
[[0., 0.],
[0., 0.]]]) Making a problematic Table >>> QTable({"name": [x[0][()]]})
<QTable length=1>
name
void288
-------------------------
(1, [[1., 1.], [1., 1.]]) Saving similarly to >>> print(repr(QTable(x)[0]))
<Row index=0>
a b [2,2]
int32 float64
----- ----------
1 1.0 .. 1.0 though of course be read back to look like the |
Continuing the above comment, building support for this in Alternatively, I recall there was discussion in an old Issue/PR of allowing Table nesting. Would that be a similarly viable solution? |
I'm playing around with |
See #12589 for an idea. |
Am reconsidering the approach. Right now, the following actually works!
|
Humm. I'm not sure if I think that is a feature or a bug. The result is surprising to me, somewhat like how people are often surprised that (I was wondering what |
The direction from Table to Column makes some sense - it calls astropy/astropy/table/table.py Lines 749 to 753 in 2158c36
|
Yes, it should - but need to decide on implementation! |
This appears to have been fixed |
Description
Cannot read a Table from a file with a
numpy.void
dtype column.Expected behavior
Roundtripping for all numpy array types.
Actual behavior
A ValueError is raised that
void
is not a recognized dtypeSteps to Reproduce
ValueError: datatype 'void192' of column 'a' is not in allowed values ('bool', 'int8', 'int16', 'int32', 'int64', 'uint8', 'uint16', 'uint32', 'uint64', 'float16', 'float32', 'float64', 'float128', 'string')
System Details
macOS-10.16-x86_64-i386-64bit
Python 3.9.5 (default, May 18 2021, 12:31:01)
[Clang 10.0.0 ]
Numpy 1.21.4
pyerfa 2.0.0.1
astropy 5.1.dev207+gbfb9252df.d20211130
Scipy 1.7.1
Matplotlib 3.3.4
The text was updated successfully, but these errors were encountered: