Skip to content

Commit

Permalink
chore: Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: carlosgjs <[email protected]>
  • Loading branch information
lsetiawan and carlosgjs authored Dec 4, 2023
1 parent 4258847 commit f99c12f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/gnatss/harmonic_mean.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def _sv_harmon_mean(
"""
# Ensure that depth and sound speed arrays
# are the same shape
assert dd.shape == sv.shape
assert dd.shape == sv.shape, f"dd and sv should have the same shape. dd:{dd.shape} != sv:{sv.shape}"

Check warning on line 79 in src/gnatss/harmonic_mean.py

View check run for this annotation

Codecov / codecov/patch

src/gnatss/harmonic_mean.py#L79

Added line #L79 was not covered by tests

zi = zs
sum = 0.0

Check warning on line 82 in src/gnatss/harmonic_mean.py

View check run for this annotation

Codecov / codecov/patch

src/gnatss/harmonic_mean.py#L81-L82

Added lines #L81 - L82 were not covered by tests
Expand All @@ -98,7 +98,7 @@ def _sv_harmon_mean(
b = (c_z2 - c_z1) / (z2 - z1)

Check warning on line 98 in src/gnatss/harmonic_mean.py

View check run for this annotation

Codecov / codecov/patch

src/gnatss/harmonic_mean.py#L98

Added line #L98 was not covered by tests

# Ensure that slope is not 0
assert b != 0.0
assert b != 0.0, "Slope is zero"

Check warning on line 101 in src/gnatss/harmonic_mean.py

View check run for this annotation

Codecov / codecov/patch

src/gnatss/harmonic_mean.py#L101

Added line #L101 was not covered by tests

# Compute the weight
wi = np.log((zi - z1) * b + c_z1) / b
Expand Down Expand Up @@ -149,7 +149,9 @@ def sv_harmonic_mean(
for col in [SP_DEPTH, SP_SOUND_SPEED]:
if col not in svdf.columns:
raise ValueError(f"{col} column must exist in the input dataframe!")

Check warning on line 151 in src/gnatss/harmonic_mean.py

View check run for this annotation

Codecov / codecov/patch

src/gnatss/harmonic_mean.py#L151

Added line #L151 was not covered by tests


# lower the strings to normalize input
method = method.lower()
if method == "scipy":
# Make all of the values absolute values, so we're only dealing with positives
abs_start = abs(start_depth)
Expand All @@ -163,7 +165,7 @@ def sv_harmonic_mean(
end_depth = -np.abs(end_depth)

if start_depth < end_depth:
raise ValueError("Start depth must be greater than end depth!")
raise ValueError(f"Start depth {start_depth} must be greater than end depth {end_depth}!")

Check warning on line 168 in src/gnatss/harmonic_mean.py

View check run for this annotation

Codecov / codecov/patch

src/gnatss/harmonic_mean.py#L168

Added line #L168 was not covered by tests

svdf = svdf[(svdf[SP_DEPTH].round() <= start_depth)]
# Extract the numpy arrays for depth and sound speed
Expand Down

0 comments on commit f99c12f

Please sign in to comment.