astropy/astropy — pull request #2695 by mhvk (2014-07-06 23:28:57+00:00)
Title: Bug in Quantity.itemset for NaN values

The following demonstrates the issue:

```
In [7]: x = np.array([1,2,3]) * u.m

In [8]: x[1] = np.nan * u.m
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
in ()
----> 1 x[1] = np.nan * u.m

/Users/tom/Library/Python/2.7/lib/python/site-packages/astropy/units/quantity.pyc in __setitem__(self, i, value)
797
798 def __setitem__(self, i, value):
--> 799 self.view(np.ndarray).__setitem__(i, self._to_own_unit(value))
800
801 def __setslice__(self, i, j, value):

/Users/tom/Library/Python/2.7/lib/python/site-packages/astropy/units/quantity.pyc in _to_own_unit(self, value, check_precision)
1016
1017 np.any(np.array(value, self.dtype) != np.array(value))):
-> 1018 raise TypeError("cannot convert value type to array type without "
1019 "precision loss")
1020 return value

TypeError: cannot convert value type to array type without precision loss
```

This is due to this test:

```
np.any(np.array(value, self.dtype) != np.array(value))):
```

on line 1017 of ``quantity.py``, which fails because NaN != NaN