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

Failure when trying to save session #686

Merged
merged 2 commits into from
Jul 5, 2015
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
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ v0.6 (unreleased)

* Fixed treatment of newlines when copying detailed error. [#687]

* Fix a bug that prevented sessions from being saved with embedded files if
component units were Astropy units. [#686]

v0.5 (2015-07-03)
-----------------

Expand Down
8 changes: 8 additions & 0 deletions glue/core/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,14 @@ def __init__(self, data, units=None):

self._data = data

@property
def units(self):
return self._units

@units.setter
def units(self, value):
self._units = str(value)

@property
def hidden(self):
"""Whether the Component is hidden by default"""
Expand Down
21 changes: 21 additions & 0 deletions glue/core/tests/test_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
DerivedComponent, CoordinateComponent,
CategoricalComponent)
from ... import core
from ...tests.helpers import requires_astropy
from ...external import six


VIEWS = (np.s_[:], np.s_[1], np.s_[::-1], np.s_[0, :])
Expand Down Expand Up @@ -302,3 +304,22 @@ def test_view_derived(view):
dc = DerivedComponent(d, link)

np.testing.assert_array_equal(dc[view], comp.data[view] * 3)


@requires_astropy
def test_units():

# Make sure that units get converted to strings. At the moment if these
# are set to Astropy units for example, things can go wrong for example
# when writing out the datasets. Once we settle on a units framework, we
# can then use that instead of converting units to strings.

from astropy import units as u

comp = Component([1,2,3], units='m')
assert comp.units == 'm'
assert isinstance(comp.units, six.string_types)

comp = Component([1,2,3], units=u.m)
assert comp.units == 'm'
assert isinstance(comp.units, six.string_types)