Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 4 additions & 2 deletions qcore/coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def nztm_to_wgs_depth(nztm_coordinates: np.ndarray) -> np.ndarray:

def distance_between_wgs_depth_coordinates(
point_a: npt.ArrayLike, point_b: npt.ArrayLike
) -> npt.ArrayLike:
) -> float | np.ndarray:
"""Return the distance between two points in lat, lon, depth format.

Valid only for points that can be converted into NZTM format.
Expand All @@ -133,7 +133,9 @@ def distance_between_wgs_depth_coordinates(
return np.linalg.norm(
wgs_depth_to_nztm(point_a) - wgs_depth_to_nztm(point_b), axis=1
)
return np.linalg.norm(wgs_depth_to_nztm(point_a) - wgs_depth_to_nztm(point_b))
return float(
np.linalg.norm(wgs_depth_to_nztm(point_a) - wgs_depth_to_nztm(point_b))
)


def nztm_bearing_to_great_circle_bearing(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def test_distance_between_wgs_depth_coordinates_multiple_points() -> None:
dist = coordinates.distance_between_wgs_depth_coordinates(points_a, points_b)
assert isinstance(dist, np.ndarray)
assert dist.shape == (2,)
assert np.all(dist > 0) # ty: ignore[unsupported-operator]
assert np.all(dist > 0)


def test_nztm_to_gc_bearing_inverse() -> None:
Expand Down
6 changes: 3 additions & 3 deletions tests/test_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def test_coordinate_meshgrid_x_boundary() -> None:
resolution = coordinates.distance_between_wgs_depth_coordinates(
x_upper, origin
) # 1 km resolution
assert isinstance(resolution, np.floating)
assert isinstance(resolution, float)
meshgrid = grid.coordinate_patchgrid(origin, x_upper, y_bottom, resolution)
assert meshgrid.shape[2] == 3 # Should have shape (ny, nx, 3) for (lat, lon, depth)
_ny, _nx = meshgrid.shape[:2]
Expand Down Expand Up @@ -119,8 +119,8 @@ def test_coordinate_patchgrid() -> None:
ny, nx = meshgrid.shape[:2]
width = coordinates.distance_between_wgs_depth_coordinates(y_bottom, origin)
length = coordinates.distance_between_wgs_depth_coordinates(x_upper, origin)
assert isinstance(length, np.floating)
assert isinstance(width, np.floating)
assert isinstance(length, float)
assert isinstance(width, float)
assert ny == round(length / resolution)
assert nx == round(width / resolution)

Expand Down
Loading