Skip to content
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

Gracefully skip vector columns from FITS files #896

Merged
merged 3 commits into from
Mar 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"