Issue #930: np.concatenate fails for YTArrays (yt_analysis/yt)
![](https://secure.gravatar.com/avatar/4f4e2225d21fe9d39a9309496e866894.jpg?s=120&d=mm&r=g)
New issue 930: np.concatenate fails for YTArrays https://bitbucket.org/yt_analysis/yt/issue/930/npconcatenate-fails-for-ytarr... Douglas Rudd: YTArrays cannot be compared using numpy functions like intersect1d because np.concatenate either fails (for dimensional arrays) or for dimensionless arrays it produces a YTArray object where the units attribute is `None` (which then fails in `__eq__`, `__lt__`, etc). This may already be known and may be unfixable (due to the way numpy implements concatenate)... ``` #!python import yt import numpy as np A = yt.YTArray(range(10)) B = yt.YTArray(range(10)) np.intersect1d(A,B) --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) <ipython-input-10-90c76c488fa7> in <module>() ----> 1 np.intersect1d(A,B) /usr/local/lib/python2.7/site-packages/numpy/lib/arraysetops.pyc in intersect1d(ar1, ar2, assume_unique) 248 aux = np.concatenate((ar1, ar2)) 249 aux.sort() --> 250 return aux[:-1][aux[1:] == aux[:-1]] 251 252 def setxor1d(ar1, ar2, assume_unique=False): /Users/drudd/Programs/yt/yt/units/yt_array.pyc in __eq__(self, other) 854 return False 855 if isinstance(other, YTArray): --> 856 if not self.units.same_dimensions_as(other.units): 857 raise YTUnitOperationError("equal", self.units, other.units) 858 AttributeError: 'NoneType' object has no attribute 'same_dimensions_as' ```
participants (1)
-
Douglas Rudd