Skip to content

Commit

Permalink
Merge pull request astropy#16091 from Deen-dot/fix-binary2
Browse files Browse the repository at this point in the history
BUG: Fix Binary2 serialization for VOTable
  • Loading branch information
bsipocz authored Sep 6, 2024
2 parents fe5506c + 81e47bc commit 18288e6
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<OPTION name="bogus" value="whatever"/>
</VALUES>
</FIELD>
<FIELD ID="intNoNull" datatype="int" name="intNoNull"/>
<FIELD ID="long" datatype="long" name="long">
<VALUES ref="int_nulls"/>
<LINK href="http://www.long-integers.com/"/>
Expand Down Expand Up @@ -121,6 +122,7 @@
<TD>128</TD>
<TD>4096</TD>
<TD>268435456</TD>
<TD>3</TD>
<TD>922337203685477</TD>
<TD>8.9990234375</TD>
<TD>1</TD>
Expand Down Expand Up @@ -151,6 +153,7 @@
<TD>255</TD>
<TD>32767</TD>
<TD>2147483647</TD>
<TD>3</TD>
<TD>123456789</TD>
<TD>0</TD>
<TD>0</TD>
Expand Down Expand Up @@ -181,6 +184,7 @@
<TD>0</TD>
<TD>-4096</TD>
<TD>-268435456</TD>
<TD>3</TD>
<TD>-1152921504606846976</TD>
<TD>+InF</TD>
<TD>+InF</TD>
Expand Down Expand Up @@ -211,6 +215,7 @@
<TD>255</TD>
<TD>32767</TD>
<TD>268435455</TD>
<TD>3</TD>
<TD>1152921504606846975</TD>
<TD/>
<TD>+InF</TD>
Expand Down Expand Up @@ -241,6 +246,7 @@
<TD>255</TD>
<TD>32767</TD>
<TD>123456789</TD>
<TD>3</TD>
<TD>123456789</TD>
<TD>-InF</TD>
<TD/>
Expand Down Expand Up @@ -281,6 +287,7 @@
<TD>128</TD>
<TD>4096</TD>
<TD>268435456</TD>
<TD>3</TD>
<TD>922337203685477</TD>
<TD>8.9990234375</TD>
<TD>1</TD>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
<OPTION name="bogus" value="whatever"/>
</VALUES>
</FIELD>
<FIELD ID="intNoNull" datatype="int" name="intNoNull"/>
<FIELD ID="long" datatype="long" name="long">
<VALUES ref="int_nulls"/>
<LINK href="http://www.long-integers.com/"/>
Expand Down Expand Up @@ -120,6 +121,7 @@
<TD>128</TD>
<TD>4096</TD>
<TD>268435456</TD>
<TD>3</TD>
<TD>922337203685477</TD>
<TD>8.9990234375</TD>
<TD>1</TD>
Expand Down Expand Up @@ -150,6 +152,7 @@
<TD>255</TD>
<TD>32767</TD>
<TD>2147483647</TD>
<TD>3</TD>
<TD/>
<TD>0</TD>
<TD>0</TD>
Expand Down Expand Up @@ -180,6 +183,7 @@
<TD>0</TD>
<TD>-4096</TD>
<TD>-268435456</TD>
<TD>3</TD>
<TD>-1152921504606846976</TD>
<TD>+InF</TD>
<TD>+InF</TD>
Expand Down Expand Up @@ -210,6 +214,7 @@
<TD>255</TD>
<TD>32767</TD>
<TD>268435455</TD>
<TD>3</TD>
<TD>1152921504606846975</TD>
<TD/>
<TD>+InF</TD>
Expand Down Expand Up @@ -240,6 +245,7 @@
<TD>255</TD>
<TD>32767</TD>
<TD/>
<TD>3</TD>
<TD/>
<TD>-InF</TD>
<TD/>
Expand Down Expand Up @@ -282,6 +288,7 @@
<TD>128</TD>
<TD>4096</TD>
<TD>268435456</TD>
<TD>3</TD>
<TD>922337203685477</TD>
<TD>8.9990234375</TD>
<TD>1</TD>
Expand Down
7 changes: 7 additions & 0 deletions astropy/io/votable/tests/data/regression.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ The VOTable format is an XML standard for the interchange of data represented as
</VALUES>
<IGNORE_ME/>
</FIELD>
<FIELD ID="intNoNull" datatype="int" name="intNoNull"/>
<FIELD ID="long" name="long" datatype="long">
<LINK href="http://www.long-integers.com/"/>
<VALUES ref="int_nulls"/>
Expand Down Expand Up @@ -116,6 +117,7 @@ The VOTable format is an XML standard for the interchange of data represented as
<TD>128</TD>
<TD>4096</TD>
<TD>268435456</TD>
<TD>3</TD>
<TD>922337203685477</TD>
<TD>8.9990234375</TD>
<TD encoding="base64">P4AAAA==</TD>
Expand Down Expand Up @@ -146,6 +148,7 @@ The VOTable format is an XML standard for the interchange of data represented as
<TD>256</TD> <!-- should overflow to 0 -->
<TD>65536</TD> <!-- should overflow to 0-->
<TD>2147483647</TD> <!-- overflowing here would raise a Numpy exception -->
<TD>3</TD>
<TD></TD>
<TD>1.0e-325</TD> <!-- underflow to 0 -->
<TD>1.0e-46</TD> <!-- underflow to 0 -->
Expand Down Expand Up @@ -176,6 +179,7 @@ The VOTable format is an XML standard for the interchange of data represented as
<TD>-23</TD> <!-- negative, should wrap around to positive -->
<TD>-4096</TD> <!-- negative, perfectly valid -->
<TD>-268435456</TD> <!-- negative, perfectly valid -->
<TD>3</TD>
<TD>-1152921504606846976</TD> <!-- negative, perfectly valid -->
<TD>1.0E309</TD>
<TD>1.0E45</TD>
Expand Down Expand Up @@ -206,6 +210,7 @@ The VOTable format is an XML standard for the interchange of data represented as
<TD>0xff</TD> <!-- hex -->
<TD>0xffff</TD> <!-- hex - negative value -->
<TD>0xfffffff</TD>
<TD>3</TD>
<TD>0xfffffffffffffff</TD>
<TD>NaN</TD>
<TD>+Inf</TD>
Expand Down Expand Up @@ -236,6 +241,7 @@ The VOTable format is an XML standard for the interchange of data represented as
<TD>0x100</TD> <!-- hex, overflow -->
<TD>0x10000</TD> <!-- hex, overflow -->
<TD/>
<TD>3</TD>
<TD/>
<TD>-Inf</TD>
<TD/>
Expand Down Expand Up @@ -276,6 +282,7 @@ The VOTable format is an XML standard for the interchange of data represented as
<TD>128</TD>
<TD>4096</TD>
<TD>268435456</TD>
<TD>3</TD>
<TD>922337203685477</TD>
<TD>8.9990234375</TD>
<TD encoding="base64">P4AAAA==</TD>
Expand Down
78 changes: 39 additions & 39 deletions astropy/io/votable/tests/data/validation.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ Validation report for regression.xml
<IGNORE_ME/>
^

97: W17: GROUP element contains more than one DESCRIPTION element
98: W17: GROUP element contains more than one DESCRIPTION element
This should warn of a second description.
^

104: W01: Array uses commas rather than whitespace
105: W01: Array uses commas rather than whitespace
<PARAM datatype="float" name="INPUT3" value="0.000000,0.000000" a...
^

Expand All @@ -71,163 +71,163 @@ Validation report for regression.xml
<FIELD ID="string_test" name="fixed string test" datatype="char" ar...
^

112: W46: char value is too long for specified length of 10
113: W46: char value is too long for specified length of 10
<TD>Fixed string long test</TD> <!-- Should truncate -->
^

114: W46: unicodeChar value is too long for specified length of 10
115: W46: unicodeChar value is too long for specified length of 10
<TD>Ceçi n'est pas un pipe</TD>
^

115: W46: char value is too long for specified length of 4
116: W46: char value is too long for specified length of 4
<TD>ab cd</TD>
^

134: E02: Incorrect number of elements in array. Expected multiple of
136: E02: Incorrect number of elements in array. Expected multiple of
4, got 1
<TD/>
^

134: W49: Empty cell illegal for integer fields.
136: W49: Empty cell illegal for integer fields.
<TD/>
^

142: W46: char value is too long for specified length of 10
144: W46: char value is too long for specified length of 10
<TD>0123456789A</TD>
^

145: W46: char value is too long for specified length of 4
147: W46: char value is too long for specified length of 4
<TD>0123456789A</TD>
^

146: W51: Value '256' is out of range for a 8-bit unsigned integer
148: W51: Value '256' is out of range for a 8-bit unsigned integer
field
<TD>256</TD> <!-- should overflow to 0 -->
^

147: W51: Value '65536' is out of range for a 16-bit integer field
149: W51: Value '65536' is out of range for a 16-bit integer field
<TD>65536</TD> <!-- should overflow to 0-->
^

149: W49: Empty cell illegal for integer fields.
152: W49: Empty cell illegal for integer fields.
<TD></TD>
^

152: W01: Array uses commas rather than whitespace
155: W01: Array uses commas rather than whitespace
<TD>42 32, 12 32</TD>
^

168: E02: Incorrect number of elements in array. Expected multiple of
171: E02: Incorrect number of elements in array. Expected multiple of
16, got 0
<TD/>
^

168: W49: Empty cell illegal for integer fields.
171: W49: Empty cell illegal for integer fields.
<TD/>
^

168: W49: Empty cell illegal for integer fields.
171: W49: Empty cell illegal for integer fields.
<TD/>
^

168: W49: Empty cell illegal for integer fields.
171: W49: Empty cell illegal for integer fields.
<TD/>
^

168: W49: Empty cell illegal for integer fields.
171: W49: Empty cell illegal for integer fields.
<TD/>
^

168: W49: Empty cell illegal for integer fields.
171: W49: Empty cell illegal for integer fields.
<TD/>
^

168: W49: Empty cell illegal for integer fields.
171: W49: Empty cell illegal for integer fields.
<TD/>
^

168: W49: Empty cell illegal for integer fields.
171: W49: Empty cell illegal for integer fields.
<TD/>
^

168: W49: Empty cell illegal for integer fields. (suppressing further
171: W49: Empty cell illegal for integer fields. (suppressing further
warnings of this type...)
<TD/>
^

174: W46: unicodeChar value is too long for specified length of 10
177: W46: unicodeChar value is too long for specified length of 10
<TD>0123456789A</TD>
^

176: W51: Value '-23' is out of range for a 8-bit unsigned integer
179: W51: Value '-23' is out of range for a 8-bit unsigned integer
field
<TD>-23</TD> <!-- negative, should wrap around to positive -->
^

198: E02: Incorrect number of elements in array. Expected multiple of
202: E02: Incorrect number of elements in array. Expected multiple of
16, got 0
<TD/>
^

207: W51: Value '65535' is out of range for a 16-bit integer field
211: W51: Value '65535' is out of range for a 16-bit integer field
<TD>0xffff</TD> <!-- hex - negative value -->
^

212: W01: Array uses commas rather than whitespace
217: W01: Array uses commas rather than whitespace
<TD>NaN, 23</TD>
^

214: E02: Incorrect number of elements in array. Expected multiple of
219: E02: Incorrect number of elements in array. Expected multiple of
6, got 0
<TD/>
^

222: E02: Incorrect number of elements in array. Expected multiple of
227: E02: Incorrect number of elements in array. Expected multiple of
4, got 1
<TD/>
^

228: E02: Incorrect number of elements in array. Expected multiple of
233: E02: Incorrect number of elements in array. Expected multiple of
16, got 0
<TD/>
^

236: W51: Value '256' is out of range for a 8-bit unsigned integer
241: W51: Value '256' is out of range for a 8-bit unsigned integer
field
<TD>0x100</TD> <!-- hex, overflow -->
^

237: W51: Value '65536' is out of range for a 16-bit integer field
242: W51: Value '65536' is out of range for a 16-bit integer field
<TD>0x10000</TD> <!-- hex, overflow -->
^

242: W01: Array uses commas rather than whitespace
248: W01: Array uses commas rather than whitespace
<TD>31, -1</TD>
^

244: E02: Incorrect number of elements in array. Expected multiple of
250: E02: Incorrect number of elements in array. Expected multiple of
6, got 0
<TD/>
^

252: E02: Incorrect number of elements in array. Expected multiple of
258: E02: Incorrect number of elements in array. Expected multiple of
4, got 1
<TD/>
^

254: E02: Incorrect number of elements in array. Expected multiple of
260: E02: Incorrect number of elements in array. Expected multiple of
4, got 1 (suppressing further warnings of this type...)
<TD/>
^

272: W46: char value is too long for specified length of 10
278: W46: char value is too long for specified length of 10
<TD>Fixed string long test</TD> <!-- Should truncate -->
^

274: W46: unicodeChar value is too long for specified length of 10
280: W46: unicodeChar value is too long for specified length of 10
<TD>Ceçi n'est pas un pipe</TD>
^

275: W46: char value is too long for specified length of 4
281: W46: char value is too long for specified length of 4
<TD>ab cd</TD>
^
1 change: 1 addition & 0 deletions astropy/io/votable/tests/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def test_table(tmp_path):
("unsignedByte", {"datatype": "unsignedByte"}),
("short", {"datatype": "short"}),
("int", {"datatype": "int"}),
("intNoNull", {"datatype": "int"}),
("long", {"datatype": "long"}),
("double", {"datatype": "double"}),
("float", {"datatype": "float"}),
Expand Down
Loading

0 comments on commit 18288e6

Please sign in to comment.