-
Notifications
You must be signed in to change notification settings - Fork 422
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
Added generic 1d nearest neighbor helper function #119
Conversation
Allow resampling based on given data and centers Added an example to Simple Sounding notebook
Removed whitespace, changed function name, added spaces after commas
@@ -8,6 +8,28 @@ | |||
from ..units import concatenate | |||
|
|||
|
|||
def resample_nn_1d(a, centers): | |||
"""Helper function that returns one-dimensional nearest-neighbor | |||
indexes based on user-specified centers. |
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.
Numpy docstring standard says this needs to start with Parameters
: https://raw.githubusercontent.com/numpy/numpy/master/doc/EXAMPLE_DOCSTRING.rst.txt
Thanks for putting this in--I just picked a few minor nits above. I'm also trying to decide: would this make more sense under something like Regarding the test coverage, can you add a test function as well? It helps to make sure it's working correctly now and, more importantly, doesn't break in the future. It can be really simple like: import numpy as np
from numpy.testing import assert_array_equal
def test_resample_nn():
a = np.arange(5.)
b = np.array([2.1, 3.8])
truth = np.array([2, 4])
asset_array_equal(truth, resample_nn_1d(a, b)) (I hope I got that right.) It should go in something like Anyhow, I hope I didn't scare you off with the requests. 😄 |
No problem! I understand needing to keep up the integrity of the codebase. I will incorporate your points as soon as I have some time. |
FYI, we just moved from nose to pytest for testing, so don't rely on anything in |
Created tools.py, added test_tools.py in testing folder, fixed some formatting issues as requested
Thanks for getting this in shape. For future reference, it's better not to merge master into your branch, but rather rebase your branch onto master (assuming it's up-to-date) using:
This just keeps the history cleaner. Thanks for the contribution! |
Added generic 1d nearest neighbor helper function
As requested, created generic version of function discussed in:
#99
Subsequent commits were done to fix whitespace/formatting issues after lint failed for initial commit.