Skip to content
Merged
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
22 changes: 11 additions & 11 deletions src/bathytools/actions/dig_rivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ class DigRivers(SimpleAction):
"""

@staticmethod
def _steam_length_to_stem(
steam_length: int, side: Literal["N", "S", "E", "W"]
def _stem_length_to_stem(
stem_length: int, side: Literal["N", "S", "E", "W"]
) -> List[Movement]:
"""
Converts the "stem_length" parameter into a list of `Movement` objects.
Expand All @@ -194,7 +194,7 @@ def _steam_length_to_stem(
its defined side.

Args:
steam_length: The length of the river's stem measured in grid
stem_length: The length of the river's stem measured in grid
cells.
side: The side of the grid (North, South, East, or West)
representing the river's origin.
Expand All @@ -204,22 +204,22 @@ def _steam_length_to_stem(
direction and length.

Raises:
ValueError: If the provided side is invalid or `steam_length` is not
ValueError: If the provided side is invalid or `stem_length` is not
a positive integer.
"""
if side not in ("N", "S", "E", "W"):
raise ValueError(f"Invalid side: {side}")
if steam_length <= 0:
if stem_length <= 0:
raise ValueError(
"Steam length must be a positive number of cell: received "
f"{steam_length}"
"Stem length must be a positive number of cell: received "

Copilot AI Mar 12, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message has a grammatical typo: "positive number of cell" should be "positive number of cells" (and possibly "cells:" vs "cells;" depending on style). This string is user-facing, so it’s worth correcting while touching it.

Suggested change
"Stem length must be a positive number of cell: received "
"Stem length must be a positive number of cells: received "

Copilot uses AI. Check for mistakes.
f"{stem_length}"
)
river_side = Direction(side)

Copilot AI Mar 12, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docstring says the river flows "in the direction opposite to its defined side", but the implementation uses river_side = Direction(side) and builds Movement(stem_length, river_side) (i.e., same direction as side). Please either update the docstring to match the actual movement direction, or change the code to use the opposite direction (e.g., -Direction(side)) if the doc is correct.

Suggested change
river_side = Direction(side)
river_side = -Direction(side)

Copilot uses AI. Check for mistakes.

output = [Movement(steam_length, river_side)]
output = [Movement(stem_length, river_side)]
LOGGER.debug(
'Converting steam length "%s" from side "%s" to stem %s',
steam_length,
'Converting stem length "%s" from side "%s" to stem %s',
stem_length,
side,
output,
)
Expand Down Expand Up @@ -441,7 +441,7 @@ def __init__(
)
else:
# noinspection PyTypeChecker
river_geometry["stem"] = self._steam_length_to_stem(
river_geometry["stem"] = self._stem_length_to_stem(
river_stem["stem_length"], river_geometry["side"]
)
del river_stem["stem_length"]
Expand Down
Loading