Saving a VOTable with an array of fixed size to a file only saves first element
See original GitHub issueDescription
I am trying to add metadata to a VOTable that I’m creating. This metadata corresponds to a tuple of known length. The data seems to be ok when inserted into the table but, when I save the table to a file, only the first element is saved.
Expected behavior
What I expect to see is the entire tuple saved in the file. The tuple is (1.0, 2.0, 3.0)
, what I see when I print params
is [<PARAM ID="sampling" arraysize="3" datatype="double" name="sampling" value="(1.0, 2.0, 3.0)"/>]
Actual behavior
Only the first element is saved in the file. When I open it, I see: PARAM
section I see: <PARAM ID="sampling" arraysize="3" datatype="double" name="sampling" value="1"/>
Steps to Reproduce
What I’m doing to create the table and add the metadata is the following:
# Create a new VOTable file
votable = VOTableFile()
# Add a resource
resource = Resource(); votable.resources.append(resource)
# Add a table for the spectra (and add the sampling as metadata)
spectra_table = Table(votable); resource.tables.append(spectra_table)
# Add sampling as param
sampling = tuple([1.0, 2.0, 3.0])
# I'm using a list because, later, I could have more than one param
params = [Param(votable, name='sampling', datatype='double', arraysize='3', value=sampling)]
spectra_table.params.extend(params)
When I print params
, I see [<PARAM ID="sampling" arraysize="3" datatype="double" name="sampling" value="(1.0, 2.0, 3.0)"/>]
which seems to be ok. However, when I save this to a file:
votable.to_xml('table_with_params.xml')
In the PARAM
section I see: <PARAM ID="sampling" arraysize="3" datatype="double" name="sampling" value="1"/>
.
I tried sampling being a tuple, list and numpy array, but they all lead to the same result. If I use *
instead of the fixed known length, the entire array is saved.
System Details
Linux-5.4.0-52-generic-x86_64-with-glibc2.29 Python 3.8.5 (default, Jul 28 2020, 12:59:40) [GCC 9.3.0] Numpy 1.18.2 astropy 4.3.dev268+g883a7c4f5 Scipy 1.4.1 Matplotlib 3.2.1
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (5 by maintainers)
Top GitHub Comments
Hello. I don’t think it is released yet, so you will have to use the dev version for now. Since #11157 was milestoned for 4.0.5, if there is an urgent need, we can try for a release soon; otherwise, it is more likely to happen when 4.3 comes out.
Hi, in which version of astropy is this patch included? I’d like to try it.