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

Compute Forward Vector #276

Merged
merged 18 commits into from
Oct 4, 2024
Merged
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
a7e79bf
Basic implementation of `compute_head_direction_vector()`
b-peri Aug 13, 2024
1f86141
Minor fixes docstring
b-peri Aug 19, 2024
e1758a7
Added unit test for `compute_head_direction_vector()`
b-peri Aug 22, 2024
31ca959
Bug fixes for `test_compute_head_direction_vector()`
b-peri Aug 22, 2024
1bc3e2a
Added validator (and test) to ensure input is 2D
b-peri Aug 22, 2024
e38d552
Refactored `navigation.py` and implemented PR review feedback
b-peri Aug 30, 2024
cd9c3b2
Extended testing and added `front_keypoint` argument to `compute_head…
b-peri Sep 10, 2024
39208d4
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 10, 2024
dd20af6
Implemented PR feedback and bugfixes for `compute_2d_head_direction_v…
b-peri Sep 16, 2024
6420ce0
Removed uppercase letters from function names
b-peri Sep 16, 2024
75badfc
Tweaked `compute_polar_coordinates.py` to use new function
b-peri Sep 16, 2024
8709337
Implemented feedback from Zulip discussion and created `compute_head_…
b-peri Sep 17, 2024
054d50c
Fixed typo in docstring
b-peri Sep 17, 2024
df6bed9
Tweaked `compute_forward_vector()` to use new validator
b-peri Sep 24, 2024
b00edcd
More fixes for `test_kinematics.py`
b-peri Sep 24, 2024
be75092
Bugfix for `compute_forward_vector()` and expanded `test_compute_forw…
b-peri Sep 24, 2024
b2de46a
Added test coverage for `compute_head_direction_vector()` alias
b-peri Sep 24, 2024
268d395
Reversed changes to `compute_polar_coordinates.py` and implemented fi…
b-peri Oct 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Bug fixes for test_compute_head_direction_vector()
b-peri committed Sep 24, 2024
commit 31ca959384929db17658c92ad7d894fb97e2ac12
18 changes: 4 additions & 14 deletions tests/test_unit/test_navigation.py
Original file line number Diff line number Diff line change
@@ -36,11 +36,7 @@ def test_compute_head_direction_vector(mock_dataset):
are computed from a basic mock dataset.
"""
# Test that validators work
with pytest.raises(
TypeError,
match="Input data must be an xarray.DataArray, but got <class "
"'numpy.ndarray'>.",
):
with pytest.raises(TypeError):
np_array = [
[[[1, 0], [-1, 0], [0, -1]]],
[[[0, 1], [0, -1], [1, 0]]],
@@ -51,19 +47,13 @@ def test_compute_head_direction_vector(mock_dataset):
np_array, "left_ear", "right_ear"
)

with pytest.raises(
ValueError,
match="Input data must contain 'time', 'space', and 'keypoints'"
" as dimensions.",
):
with pytest.raises(AttributeError):
mock_dataset_keypoint = mock_dataset.sel(keypoints="nose", drop=True)
navigation.compute_head_direction_vector(
mock_dataset_keypoint, "left_ear", "right_ear"
)

with pytest.raises(
ValueError, match="The left and right keypoints may not be identical."
):
with pytest.raises(ValueError):
navigation.compute_head_direction_vector(
mock_dataset, "left_ear", "left_ear"
)
@@ -72,7 +62,7 @@ def test_compute_head_direction_vector(mock_dataset):
head_vector = navigation.compute_head_direction_vector(
mock_dataset, "left_ear", "right_ear"
)
known_vectors = np.array([[0, 2], [-2, 0], [0, -2], [2, 0]])
known_vectors = np.array([[[0, 2]], [[-2, 0]], [[0, -2]], [[2, 0]]])

assert (
isinstance(head_vector, xr.DataArray)