{"action":"created","issue":{"url":"https://api.github.com/repos/pydata/xarray/issues/728","repository_url":"https://api.github.com/repos/pydata/xarray","labels_url":"https://api.github.com/repos/pydata/xarray/issues/728/labels{/name}","comments_url":"https://api.github.com/repos/pydata/xarray/issues/728/comments","events_url":"https://api.github.com/repos/pydata/xarray/issues/728/events","html_url":"https://github.com/pydata/xarray/issues/728","id":128980804,"number":728,"title":"Cannot inherit DataArray anymore in 0.7 release","user":{"login":"rafa-guedes","id":7799184,"avatar_url":"https://avatars.githubusercontent.com/u/7799184?v=3","gravatar_id":"","url":"https://api.github.com/users/rafa-guedes","html_url":"https://github.com/rafa-guedes","followers_url":"https://api.github.com/users/rafa-guedes/followers","following_url":"https://api.github.com/users/rafa-guedes/following{/other_user}","gists_url":"https://api.github.com/users/rafa-guedes/gists{/gist_id}","starred_url":"https://api.github.com/users/rafa-guedes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rafa-guedes/subscriptions","organizations_url":"https://api.github.com/users/rafa-guedes/orgs","repos_url":"https://api.github.com/users/rafa-guedes/repos","events_url":"https://api.github.com/users/rafa-guedes/events{/privacy}","received_events_url":"https://api.github.com/users/rafa-guedes/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2016-01-26T23:57:03Z","updated_at":"2016-03-08T17:44:08Z","closed_at":"2016-01-29T02:48:57Z","body":"I understand from @shoyer that [inheriting from DataArray](https://github.com/pydata/xarray/issues/706) may not be the best approach to extend DataArray with other specific methods but this was working before the latest release, and it is not working anymore. Just wondering if this would be some issue caused by new internal structure of DataArray, or maybe something I'm doing wrong?\r\n\r\nFor example, the code below works using xray.0.6.1:\r\n```\r\nimport numpy as np\r\n# import xarray as xr #xarray.0.7.0\r\nimport xray as xr #xray.0.6.1\r\n\r\nclass NewArray(xr.DataArray):\r\n    def __init__(self, darray):\r\n        super(NewArray, self).__init__(darray, name='spec')\r\n\r\ndata = np.random.randint(0,10,12).reshape(4,3)\r\nx = [10,20,30]\r\ny = [1,2,3,4]\r\n\r\ndarray = xr.DataArray(data, coords={'y': y, 'x': x}, dims=['y','x'])\r\nnarray = NewArray(darray)\r\n\r\nprint 'xr version: %s\\n' % xr.__version__\r\nprint 'DataArray object:\\n%s\\n' % darray\r\nprint 'NewArray object:\\n%s' % narray\r\n``` \r\nbut it does not work anymore when using the new xarray release. The NewArray instance is actually created, but if I try to access this object, or its narray.coords attribute, I get the traceback below. I can however access some other attributes from narray such as narray.values or narray.dims.\r\n```\r\n---------------------------------------------------------------------------\r\nTypeError                                 Traceback (most recent call last)\r\n/source/pymsl/pymsl/core/tests/inherit_test.py in <module>()\r\n     16 print 'xr version: %s\\n' % xr.__version__\r\n     17 print 'DataArray object:\\n%s\\n' % darray\r\n---> 18 print 'NewArray object:\\n%s' % narray\r\n\r\n/usr/local/lib/python2.7/site-packages/xarray/core/common.pyc in __repr__(self)\r\n     76\r\n     77     def __repr__(self):\r\n---> 78         return formatting.array_repr(self)\r\n     79\r\n     80     def _iter(self):\r\n\r\n/usr/local/lib/python2.7/site-packages/xarray/core/formatting.pyc in array_repr(arr)\r\n    254     if hasattr(arr, 'coords'):\r\n    255         if arr.coords:\r\n--> 256             summary.append(repr(arr.coords))\r\n    257\r\n    258     if arr.attrs:\r\n\r\n/usr/local/lib/python2.7/site-packages/xarray/core/coordinates.pyc in __repr__(self)\r\n     64\r\n     65     def __repr__(self):\r\n---> 66         return formatting.coords_repr(self)\r\n     67\r\n     68     @property\r\n\r\n/usr/local/lib/python2.7/site-packages/xarray/core/formatting.pyc in _mapping_repr(mapping, title, summarizer, col_width)\r\n    208     summary = ['%s:' % title]\r\n    209     if mapping:\r\n--> 210         summary += [summarizer(k, v, col_width) for k, v in mapping.items()]\r\n    211     else:\r\n    212         summary += [EMPTY_REPR]\r\n\r\n/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/_abcoll.pyc in items(self)\r\n    412     def items(self):\r\n    413         \"D.items() -> list of D's (key, value) pairs, as 2-tuples\"\r\n--> 414         return [(key, self[key]) for key in self]\r\n    415\r\n    416     def values(self):\r\n\r\n/usr/local/lib/python2.7/site-packages/xarray/core/coordinates.pyc in __getitem__(self, key)\r\n     44              key.split('.')[0] in self._names)):\r\n     45             # allow indexing current coordinates or components\r\n---> 46             return self._data[key]\r\n     47         else:\r\n     48             raise KeyError(key)\r\n\r\n/usr/local/lib/python2.7/site-packages/xarray/core/dataarray.pyc in __getitem__(self, key)\r\n    395                 _, key, var = _get_virtual_variable(self._coords, key)\r\n    396\r\n--> 397             return self._replace_maybe_drop_dims(var, name=key)\r\n    398         else:\r\n    399             # orthogonal array indexing\r\n\r\n/usr/local/lib/python2.7/site-packages/xarray/core/dataarray.pyc in _replace_maybe_drop_dims(self, variable, name)\r\n    234             coords = OrderedDict((k, v) for k, v in self._coords.items()\r\n    235                                  if set(v.dims) <= allowed_dims)\r\n--> 236         return self._replace(variable, coords, name)\r\n    237\r\n    238     __this_array = _ThisArray()\r\n\r\n/usr/local/lib/python2.7/site-packages/xarray/core/dataarray.pyc in _replace(self, variable, coords, name)\r\n    225         if name is self.__default:\r\n    226             name = self.name\r\n--> 227         return type(self)(variable, coords, name=name, fastpath=True)\r\n    228\r\n    229     def _replace_maybe_drop_dims(self, variable, name=__default):\r\n\r\nTypeError: __init__() takes exactly 2 arguments (5 given)\r\n```"},"comment":{"url":"https://api.github.com/repos/pydata/xarray/issues/comments/193885079","html_url":"https://github.com/pydata/xarray/issues/728#issuecomment-193885079","issue_url":"https://api.github.com/repos/pydata/xarray/issues/728","id":193885079,"user":{"login":"MaximilianR","id":5635139,"avatar_url":"https://avatars.githubusercontent.com/u/5635139?v=3","gravatar_id":"","url":"https://api.github.com/users/MaximilianR","html_url":"https://github.com/MaximilianR","followers_url":"https://api.github.com/users/MaximilianR/followers","following_url":"https://api.github.com/users/MaximilianR/following{/other_user}","gists_url":"https://api.github.com/users/MaximilianR/gists{/gist_id}","starred_url":"https://api.github.com/users/MaximilianR/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MaximilianR/subscriptions","organizations_url":"https://api.github.com/users/MaximilianR/orgs","repos_url":"https://api.github.com/users/MaximilianR/repos","events_url":"https://api.github.com/users/MaximilianR/events{/privacy}","received_events_url":"https://api.github.com/users/MaximilianR/received_events","type":"User","site_admin":false},"created_at":"2016-03-08T17:44:07Z","updated_at":"2016-03-08T17:44:07Z","body":">@MaximilianR Okay, but this won't solve the current issue. If you override the __init__ method when trying to subclass DataArray, subsequent accesses to some attributes (e.g. coords) will fail. No matter if you super up or not.\r\n\r\nWhy?"}}