Repository navigation
FITS Table string related fails with Astropy dev - #1228
Conversation
|
@cdeil - at some level you're bitten not by @astrofrog's changes but by the introduction of the unicode sandwich for |
|
@mhvk - Thanks for the info! I'll read over astropy/astropy#5700 and educate myself tomorrow. What I want is a function that converts a def table_row_to_dict(table, idx):
data = OrderedDict()
for name, col in table.columns.items():
val = col[idx]
if col.unit:
val = val * col.unit
data[name] = val
return dataIf there is a better (i.e. mostly faster) way to extract row data from a Table, please let me know. |
|
@cdeil - don't use You could remove the |
|
@cdeil - that looks all OK (though one travis run failed; not sure whether that's related) |
|
I think now all is good: table row -> dict or also the other way around row data as list of dict -> table always go through a helper function in |
FITS Table string related fails with Astropy dev
In Gammapy we are testing against the Astropy dev version, and this started to fail:
https://travis-ci.org/gammapy/gammapy/jobs/310116908#L3261
I think the cause is this FITS Table related change by @astrofrog that was merged yesterday:
astropy/astropy#6821
From a quick look, I think all the fails in
gammapy.catalogoriginate from here, where we extract a FITS table row data into a dict that's independent from the table object:gammapy/gammapy/catalog/core.py
Line 252 in 48d7ae1
Before the change by @astrofrog FITS string column data came back as
str, now asbytes(I only tested on Python 3 so far), and then our code fails later when we comparestrwithbytes(and previously worked because we comparedstrwithstr).Here's an isolated test case: old behaviour:
New behaviour:
In both cases, this gives a
str:Actually given https://github.com/astropy/astropy/pull/6821/files#diff-db23dcd814354c954091a9b90dbfd92aR253 this makes sense:
@astrofrog So basically, this is an intentional change in Astropy, and we should update our code in Gammapy to no longer rely on
column.databeing astrfor FITS string columns, no?Concretely for the method
_make_source_dictI linked to above I think that means we need anisinstanceortryfor string columns?