Skip to content

Commit

Permalink
Add test for multidimensional use of rotate_vector.
Browse files Browse the repository at this point in the history
  • Loading branch information
jranalli committed Oct 7, 2024
1 parent da9d59f commit 1c4d7bf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/solarspatialtools/spatial.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,9 @@ def rotate_vector(vector, theta):
Parameters
----------
vector : (x, y) numeric
A tuple (or numpy array) containing the input vector
A tuple (or numpy array) containing the input vector.
To operate on multiple points, vector should be of the form:
((x1, x2, x3, x4), (y1, y2, y3, y4))
theta : numeric
Angle of rotation in radians
Expand All @@ -321,7 +323,8 @@ def rotate_vector(vector, theta):
-------
(x, y) : numeric
A tuple (or numpy array) containing the rotated vector. Matches data
type of input.
type of input. If input an array of x's and y's, output will be
oriented ((x1', x2', x3', x4'), (y1', y2', y3', y4'))
"""

rot_matrix = np.array([[np.cos(theta), -np.sin(theta)],
Expand Down
5 changes: 5 additions & 0 deletions tests/test_spatial.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,11 @@ def test_rotate_vector_numpy():
assert r1 == approx([0, np.sqrt(2)])


def test_rotate_vector_multiple():
r1 = spatial.rotate_vector(np.array([[1, 0, 1], [0, 1, 1]]), np.deg2rad(90))
assert r1 == approx(np.array([[0, -1, -1], [1, 0, 1]]))


def test_project_points(projected_dxdy, projected_dists):
vecs = projected_dists.keys()
for vec in vecs:
Expand Down

0 comments on commit 1c4d7bf

Please sign in to comment.