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
Fixed io.acii
read IPAC tables for long
column types on Windows
#15992
Fixed io.acii
read IPAC tables for long
column types on Windows
#15992
Conversation
Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.
|
a10438c
to
594b4b7
Compare
io.acii
ipac read for long column types on Windowsio.acii
read IPAC tables for long column types on Windows
io.acii
read IPAC tables for long column types on Windowsio.acii
read IPAC tables for long
column types on Windows
594b4b7
to
dcaa223
Compare
@@ -214,6 +216,10 @@ def get_cols(self, lines): | |||
null = header_vals[3][i].strip() | |||
fillval = "" if issubclass(col.type, core.StrType) else "0" | |||
self.data.fill_values.append((null, fillval, col.name)) | |||
if "long".startswith(col.raw_type.lower()): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm slightly confused by this line. Is it not doing more than it should ? Is, e.g. "Lo"
a correct way to specify long
ints ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not 100% sure long
can be abbreviated as Lo
per IPAC spec, but current astropy implementation does allow all kind of abbreviation.
The above line mimics the existing ones in get_col_type()
in
astropy/astropy/io/ascii/ipac.py
Line 165 in d1579ec
if col_type_key.startswith(col.raw_type.lower()): |
The data type abbreviation has been explicitly tested in:
astropy/astropy/io/ascii/tests/test_read.py
Lines 1367 to 1370 in d1579ec
def test_ipac_abbrev(): | |
lines = [ | |
"| c1 | c2 | c3 | c4 | c5| c6 | c7 | c8 | c9|c10|c11|c12|", | |
"| r | rE | rea | real | D | do | dou | f | i | l | da| c |", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great, thank you very much for clarifying this !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unresolving just so that others can see this too!
astropy/io/ascii/ipac.py
Outdated
@@ -214,6 +216,10 @@ def get_cols(self, lines): | |||
null = header_vals[3][i].strip() | |||
fillval = "" if issubclass(col.type, core.StrType) else "0" | |||
self.data.fill_values.append((null, fillval, col.name)) | |||
if "long".startswith(col.raw_type.lower()): | |||
# ensure long columns are 64-bit int, to address (Windows-specific): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment specifically targets Windows but I don't see a sys.platform
check in the if
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue surfaces on Windows. Conceivably, the same problem could arise in some other 32-bit platform, or possibly some non-standard build of numpy
[*].
I think mapping long
to np.int64
should be safe and correct in all cases.
Thoughts?
[*] When typing is not specified, ascii
guesses and assigns type for a column in _convert_vals()
.
For integer-like columns, it uses the converter from convert_numpy(int)
, which boils down to the behavior of np.array([], int)
. For Windows (even on 64-bit), numpy
returns a np.int32
array, while for (most if not all) other platforms, it returns a np.int64
array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If your actual patch is not really platform specific, then perhaps update the comment and change log to match? Currently, from the change log, it seems like your fix is only for Windows though in reality it is not confined to Windows. Hope that makes sense. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For changelog (and similarly in the comment), how about:
Fixed reading IPAC tables for ``long`` column type on some platforms, e.g., Windows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is fine by me. Thanks for your understanding!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
Wow, thanks! Since this is already approved but there is a chance of it being superseded, I am turning this into draft to prevent pre-mature merging. |
Just in case it matters, numpy 2.0 will make |
11a6ab6
to
2ed04cc
Compare
I made the branch based on Update: Nevermind, I figured out how to change the base to |
Going to close/reopen to re-trigger checks. Thanks! |
This comment was marked as resolved.
This comment was marked as resolved.
…16005) * ensure 64 bit int columns remain 64 bit int type on Windows (Python path) * ensure 64 bit in columns read correctly, C code path * Fixed tests to reflect changes from reading 64bit integers as ints * C path int parsing: use int64_t instead of long long * update the test to reflect the policy of defaulting to 64bit ints in all cases. * update changelog to stress the 64-bit by default behavior. * forward port ipac test from #15992 * small optimization: inline int64 string parsing C function * Tweak changelog wording and add what's new entry
Description
This pull request is to address reading IPAC table files with
long
columns on Windows platforms.It forces
long
columns to usenp.int64
as the default data type (rather than 32-bit integers on Windows).Fixes #15989 for v6.0.x only. The fix for this issue in
main
(v6.1 and later) is more comprehensive at #16005 but it cannot be backported.