From 6a8b410015ea629901ff28d38114cd7d0a3a9e50 Mon Sep 17 00:00:00 2001 From: Jesse Cusack Date: Tue, 30 Sep 2025 09:31:41 -0700 Subject: [PATCH] remove unncessary both option in find segment --- docs/conf.py | 2 +- pyproject.toml | 2 +- src/profinder/profinder.py | 18 ++++++++++-------- uv.lock | 2 +- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 0f2dd59..836c5e1 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -6,7 +6,7 @@ project = "profinder" author = "Jesse Cusack" -release = "0.2.3" +release = "0.2.4" extensions = [ "myst_nb", "sphinx.ext.autodoc", diff --git a/pyproject.toml b/pyproject.toml index a87a3dc..692f20e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "profinder" -version = "0.2.3" +version = "0.2.4" description = "Functions to find profiles in ocean pressure data" readme = "README.md" authors = [ diff --git a/src/profinder/profinder.py b/src/profinder/profinder.py index 75fd641..8716041 100644 --- a/src/profinder/profinder.py +++ b/src/profinder/profinder.py @@ -99,7 +99,7 @@ def _find_segment( time: Optional[ArrayLike] = None, velocity: Optional[ArrayLike] = None, min_speed: float = 0.2, - direction: Literal["up", "down", "both"] = "down", + direction: Literal["up", "down"] = "down", ) -> Tuple[int, int]: """Find the start and end indices of a single down or up segment. @@ -119,8 +119,8 @@ def _find_segment( Pre-computed velocity (same length as pressure). Overrides gradient(time). min_speed : float Minimum absolute velocity magnitude to be considered valid. - direction : {'up','down','both'} - Direction(s) in which the speed threshold is enforced. + direction : {'up','down'} + Direction in which the speed threshold is enforced. Returns ------- @@ -147,8 +147,10 @@ def _find_segment( good_velocity = v > min_speed elif direction == "up": good_velocity = v < -min_speed - else: # both - good_velocity = np.abs(v) > min_speed + else: + raise ValueError( + "direction must be 'up' or 'down' when applying speed threshold." + ) good_data = good_pressure & good_velocity @@ -337,7 +339,7 @@ def find_segment( time: Optional[ArrayLike] = None, velocity: Optional[ArrayLike] = None, min_speed: float = 0.2, - direction: Literal["up", "down", "both"] = "down", + direction: Literal["up", "down"] = "down", ) -> Tuple[int, int]: """Find the start and end indices of a single down or up segment @@ -358,8 +360,8 @@ def find_segment( Pre-computed velocity (same length as pressure). Overrides gradient(time). min_speed : float Minimum absolute velocity magnitude to be considered valid. - direction : {'up','down','both'} - Direction(s) in which the speed threshold is enforced. + direction : {'up','down'} + Direction in which the speed threshold is enforced. Returns ------- diff --git a/uv.lock b/uv.lock index 0f87934..9d3c7c3 100644 --- a/uv.lock +++ b/uv.lock @@ -207,7 +207,7 @@ wheels = [ [[package]] name = "profinder" -version = "0.2.3" +version = "0.2.4" source = { editable = "." } dependencies = [ { name = "numpy" },