Skip to content

wrap_angle attribute does not pickle properly with Longitude instance #1942

@scottransom

Description

@scottransom

Hi All,

So the wrap_angle attribute for a Longitude instance is used several times in the angle class, yet it does not pickle properly. See below for a simple example.

Scott

In [1]: from astropy.coordinates import Longitude, Latitude

In [2]: import cPickle

In [3]: a = Longitude(1.23, "radian", wrap_angle='180d')

In [4]: a.wrap_angle
Out[4]: <Angle 180.0 deg>

In [5]: cPickle.dump(a, open("xxx", "wb"))

In [6]: b = cPickle.load(open("xxx"))

In [7]: a
Out[7]: <Longitude 1.2300000000000004 rad>

In [8]: b
Out[8]: <Longitude 1.2300000000000004 rad>

In [9]: b.wrap_angle
ERROR: AttributeError: Longitude instance has no attribute 'wrap_angle' [astropy.units.quantity]
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-9-c854be2560b1> in <module>()
----> 1 b.wrap_angle

/home/sransom/src/astropy_dev/astropy/units/quantity.pyc in __getattr__(self, attr)
    574             raise AttributeError(
    575                 "{0} instance has no attribute '{1}'".format(
--> 576                     self.__class__.__name__, attr))
    577         else:
    578             return value

AttributeError: Longitude instance has no attribute 'wrap_angle'

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions