Skip to content

Commit

Permalink
Fix deprecation warnings for ndim > 0 arrays becoming scalar
Browse files Browse the repository at this point in the history
  • Loading branch information
sdhiscocks committed Jun 18, 2024
1 parent f5045a1 commit 608446f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions stonesoup/measures/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,10 +485,10 @@ def __call__(self, state1, state2):
inv_state2_covar = np.linalg.inv(state2.covar)
trace_term = np.trace(inv_state2_covar@state1.covar)

delta = state2.state_vector - state1.state_vector
mahalanobis_term = delta.T @ inv_state2_covar @ delta
delta = (state2.state_vector - state1.state_vector).ravel()
mahalanobis_term = np.dot(np.dot(delta, inv_state2_covar), delta)

kld = float(0.5*(log_term - n_dims + trace_term + mahalanobis_term))
kld = 0.5*(log_term - n_dims + trace_term + mahalanobis_term)

else:
raise ValueError(f'The state dimensions are not compatible '
Expand Down
4 changes: 2 additions & 2 deletions stonesoup/movable/movable.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,8 @@ def _get_angle(vec: StateVector, axis: np.ndarray) -> float:
Angle : float
Angle, in radians, between the two vectors
"""
vel_norm = vec / np.linalg.norm(vec)
axis_norm = axis / np.linalg.norm(axis)
vel_norm = (vec / np.linalg.norm(vec)).ravel()
axis_norm = (axis / np.linalg.norm(axis)).ravel()

return np.arccos(np.clip(np.dot(axis_norm, vel_norm), -1.0, 1.0))

Expand Down
4 changes: 2 additions & 2 deletions stonesoup/tests/test_stitcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ def params():
np.random.uniform(-2, 2, 1)]*n_spacial_dimensions

for i in range(number_of_targets):
number_of_segments = int(np.random.choice(range(1, max_segments), 1))
truthlet0_length = np.random.choice(range(max_track_start), 1)
number_of_segments = np.random.choice(range(1, max_segments))
truthlet0_length = np.random.choice(range(max_track_start))
truthlet_lengths = np.random.choice(range(min_segment_length, max_segment_length),
number_of_segments)
disjoint_lengths = np.random.choice(range(min_disjoint_length, max_disjoint_length),
Expand Down

0 comments on commit 608446f

Please sign in to comment.