From 96662d54ee5f3c2bb8aed3bcf4c4384a8067aa7c Mon Sep 17 00:00:00 2001 From: tempoxylophone <15273090+tempoxylophone@users.noreply.github.com> Date: Sat, 1 Jun 2024 23:06:48 -0400 Subject: [PATCH 1/3] Add support for negative array shifting. --- nbs/shift.ipynb | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/nbs/shift.ipynb b/nbs/shift.ipynb index 5103259..8344ed6 100644 --- a/nbs/shift.ipynb +++ b/nbs/shift.ipynb @@ -44,6 +44,8 @@ "def shift_array(input_array: np.ndarray, offset: int) -> np.ndarray:\n", " n_samples = input_array.size\n", " output_array = np.full_like(input_array, np.nan)\n", + " ub = n_samples - offset if offset > 0 else n_samples\n", + " lb = offset * -1 if offset < 0 else 0\n", " for i in range(n_samples - offset):\n", " output_array[i + offset] = input_array[i]\n", " return output_array" @@ -77,9 +79,21 @@ ], "metadata": { "kernelspec": { - "display_name": "python3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.12" } }, "nbformat": 4, From f833c1cf66209b8c75c2f464852c999e8ba8d48a Mon Sep 17 00:00:00 2001 From: tempoxylophone <15273090+tempoxylophone@users.noreply.github.com> Date: Sat, 1 Jun 2024 23:11:44 -0400 Subject: [PATCH 2/3] change note in contributing to use nbdev 2.0 hook install command. --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 38fbde5..7ab3ecc 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,7 +4,7 @@ Before anything else, please install the git hooks that run automatic scripts during each commit and merge to strip the notebooks of superfluous metadata (and avoid merge conflicts). After cloning the repository, run the following command inside it: ``` -nbdev_install_git_hooks +nbdev_install_hooks ``` ## Did you find a bug? From 0f8475521d5cfa96054ba0b3057b3f34582a1ce4 Mon Sep 17 00:00:00 2001 From: tempoxylophone <15273090+tempoxylophone@users.noreply.github.com> Date: Sat, 1 Jun 2024 23:38:46 -0400 Subject: [PATCH 3/3] actually replace the bounds of iteration this time. --- nbs/shift.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nbs/shift.ipynb b/nbs/shift.ipynb index 8344ed6..c172580 100644 --- a/nbs/shift.ipynb +++ b/nbs/shift.ipynb @@ -46,7 +46,7 @@ " output_array = np.full_like(input_array, np.nan)\n", " ub = n_samples - offset if offset > 0 else n_samples\n", " lb = offset * -1 if offset < 0 else 0\n", - " for i in range(n_samples - offset):\n", + " for i in range(lb, ub):\n", " output_array[i + offset] = input_array[i]\n", " return output_array" ]