astropy/astropy — pull request #2888 by mdboom (2014-08-25 16:11:10+00:00)
Title: deepcopy of SkyCoord fails

Deepcopying of ``SkyCoord`` objects doesn't currently work:

```
In [1]: from astropy import units as u

In [2]: from astropy.coordinates import SkyCoord

In [3]: c = SkyCoord(1 * u.deg, 2 * u.deg)

In [4]: from copy import deepcopy

In [5]: deepcopy(c)
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
in ()
----> 1 deepcopy(c)

/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/copy.py in deepcopy(x, memo, _nil)
180 raise Error(
181 "un(deep)copyable object of type %s" % cls)
--> 182 y = _reconstruct(x, rv, 1, memo)
183
184 # If is its own copy, don't memoize.

/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/copy.py in _reconstruct(x, info, deep, memo)
299 if deep:
300 state = deepcopy(state, memo)
--> 301 if hasattr(y, '__setstate__'):
302 y.__setstate__(state)
303 else:

/Users/tom/Library/Python/3.4/lib/python/site-packages/astropy-1.0.dev9642-py3.4-macosx-10.8-x86_64.egg/astropy/coordinates/sky_coordinate.py in __getattr__(self, attr)
330 """
331
--> 332 if self.frame.name == attr:
333 return self # Should this be a deepcopy of self?
334
[snip]
/Users/tom/Library/Python/3.4/lib/python/site-packages/astropy-1.0.dev9642-py3.4-macosx-10.8-x86_64.egg/astropy/coordinates/sky_coordinate.py in __getattr__(self, attr)
330 """
331
--> 332 if self.frame.name == attr:
333 return self # Should this be a deepcopy of self?
334

/Users/tom/Library/Python/3.4/lib/python/site-packages/astropy-1.0.dev9642-py3.4-macosx-10.8-x86_64.egg/astropy/coordinates/sky_coordinate.py in frame(self)
155 @property
156 def frame(self):
--> 157 return self._sky_coord_frame
158
159 @property

RuntimeError: maximum recursion depth exceeded
```

cc @taldcroft @eteq