Skip to content
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

ENH: add tolerance argument to .sel and .reindex #629

Merged
merged 2 commits into from
Oct 21, 2015

Conversation

shoyer
Copy link
Member

@shoyer shoyer commented Oct 19, 2015

.sel and .reindex now support the tolerance argument for controlling nearest-neighbor selection:

In [5]: array = xray.DataArray([1, 2, 3], dims='x')

In [6]: array.reindex(x=[0.9, 1.5], method='nearest', tolerance=0.2)
Out[6]:
<xray.DataArray (x: 2)>
array([  2.,  nan])
Coordinates:
  * x        (x) float64 0.9 1.5

This feature requires pandas v0.17 or newer.

@shoyer
Copy link
Member Author

shoyer commented Oct 20, 2015

@jhamman I think I want to merge this and then issue a new release. We are doing more harm in waiting for ReadTheDocs at this point. Better to get the fixes out even if we can't make the stable docs yet.

"""Given a pandas.Index (or xray.Coordinate) and labels (e.g., from
__getitem__) for one dimension, return an indexer suitable for indexing an
ndarray along that dimension
"""
# backwards compatibility for pandas<0.16 (method) or pandas<0.17
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What error do we get if we use the tolerance keyword with pandas 0.16? Do we need to catch that ourselves?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should get a TypeError, since the argument does not exist. I'll double check, though.

@jhamman
Copy link
Member

jhamman commented Oct 20, 2015

I'm fine with merging this now. I agree we need to get this release out, with or without read the docs support.

shoyer added a commit that referenced this pull request Oct 21, 2015
ENH: add tolerance argument to .sel and .reindex
@shoyer shoyer merged commit c827911 into pydata:master Oct 21, 2015
@shoyer shoyer deleted the tolerance branch October 21, 2015 03:47
@shoyer shoyer modified the milestone: 0.6.1 Oct 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants