-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Remove .T as shortcut for transpose() #2509
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Hello @dcherian! Thanks for submitting the PR.
|
For posterity, what did we decide to do with the |
I'm not sure but I've fixed the whats-new entry to say that only Dataset.T has been removed currently. |
xarray/core/dataset.py
Outdated
d = super(Dataset, self).__dir__() | ||
d.remove('T') | ||
return d |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can drop this method entirely in favor of the super class method.
I think this is arguably still useful/expected since DataArray is modeled on a NumPy array. But I could probably be convinced otherwise... |
I agree |
Feeling like playing devils advocate here. I would expect we'll run into similar confusion with the >>> da = xr.DataArray([1, 2, 3, 4], dims=('time', ), coords={'time': pd.date_range('2018-10-24', periods=4)})
>>> da.time
<xarray.DataArray 'time' (time: 4)>
array(['2018-10-24T00:00:00.000000000', '2018-10-25T00:00:00.000000000',
'2018-10-26T00:00:00.000000000', '2018-10-27T00:00:00.000000000'],
dtype='datetime64[ns]')
Coordinates:
* time (time) datetime64[ns] 2018-10-24 2018-10-25 2018-10-26 2018-10-27
>>> da = xr.DataArray([1, 2, 3, 4], dims=('T', ), coords={'T': pd.date_range('2018-10-24', periods=4)})
>>> da.T
<xarray.DataArray (T: 4)>
array([1, 2, 3, 4])
Coordinates:
* T (T) datetime64[ns] 2018-10-24 2018-10-25 2018-10-26 2018-10-27 |
@jhamman one hiccup is that we haven't been issuing a I'm OK with removing it though. |
I'm +0.2 for merging this, but at least issuing a |
Sure, that's a good point. I just wanted to illustrate that these are the same problems and that only removing the property from the Dataset may lead to continued confusion. @shoyer thoughts? |
I suppose the case for removing The counter-argument would be that I guess that puts me at -0 for deprecating |
I think that's a good point. There are a few methods on In [4]: {x for x in set(dir(xr.DataArray)) - set(dir(xr.Dataset)) if not x.startswith("_")}
Out[4]:
{'data',
'dot',
'dt',
'dtype',
'from_cdms2',
'from_iris',
'from_series',
'get_axis_num',
'item',
'name',
'ndim',
'plot',
'searchsorted',
'shape',
'size',
'to_cdms2',
'to_dataset',
'to_index',
'to_iris',
'to_masked_array',
'to_pandas',
'to_series',
'variable'} Regardless, sounds like @shoyer thinks we should merge (and I'm probably still +0.1) |
doc/whats-new.rst
Outdated
@@ -33,6 +33,8 @@ v0.11.0 (unreleased) | |||
Breaking changes | |||
~~~~~~~~~~~~~~~~ | |||
|
|||
- ``Dataset.T`` has been removed as a shortcut for :py:meth:`transpose()`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally we don't put ()
in the docs - is this our convention or will the docs not link?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's also in the line below!
I really don't think it matters if it's only cosmetic, though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @dcherian! |
Dataset.T
property? #1232whats-new.rst
for all changes andapi.rst
for new API (remove if this change should not be visible to users, e.g., if it is an internal clean-up, or if this is part of a larger project that will be documented later)