Skip to content

Commit

Permalink
Merge pull request #896 from astrofrog/skip-vector-columns
Browse files Browse the repository at this point in the history
Gracefully skip vector columns from FITS files
  • Loading branch information
astrofrog committed Mar 30, 2016
2 parents 931c1c7 + 3bb5fcf commit a8786c5
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ v0.7.1 (2016-03-29)
* Fixed a bug that caused an abort trap if the filename specified on the
command line did not exist. [#903]

* Gracefully skip vector columnns when reading in FITS files. [#896]

v0.7 (2016-03-10)
-----------------

Expand Down
3 changes: 3 additions & 0 deletions glue/core/data_factories/fits.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ def new_data():
groups[hdu_name] = data
for column_name in table.columns:
column = table[column_name]
if column.ndim != 1:
warnings.warn("Dropping column '{0}' since it is not 1-dimensional".format(column_name))
continue
component = Component(column, units=column.unit)
data.add_component(component=component,
label=column_name)
Expand Down
20 changes: 20 additions & 0 deletions glue/core/data_factories/tests/data/events.fits

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions glue/core/data_factories/tests/test_fits.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import absolute_import, division, print_function

import os
import warnings
from copy import deepcopy
from collections import namedtuple

Expand Down Expand Up @@ -189,3 +190,12 @@ def test_fits_compressed():
d = df.load_data(os.path.join(DATA, 'compressed_image.fits'),
factory=df.fits_reader)
assert d.ndim == 2


@requires_astropy
def test_fits_vector():
# Regression test for bug that caused tables with vector columns to not load
with warnings.catch_warnings(record=True) as w:
df.load_data(os.path.join(DATA, 'events.fits'), factory=df.fits_reader)
assert len(w) == 1
assert str(w[0].message) == "Dropping column 'status' since it is not 1-dimensional"

0 comments on commit a8786c5

Please sign in to comment.