Skip to content

Commit

Permalink
Fix pep8
Browse files Browse the repository at this point in the history
  • Loading branch information
robbibt committed Aug 2, 2024
1 parent b6ea2af commit 3ec5129
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
26 changes: 14 additions & 12 deletions coastlines/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,9 +431,11 @@ def coastal_transects(

# Reverse transects so all point away from land
transect_gdf["geometry"] = transect_gdf.apply(
lambda i: LineString([i.geometry.coords[1], i.geometry.coords[0]])
if i.p1 < i.p2
else i.geometry,
lambda i: (
LineString([i.geometry.coords[1], i.geometry.coords[0]])
if i.p1 < i.p2
else i.geometry
),
axis=1,
)

Expand Down Expand Up @@ -2663,15 +2665,15 @@ def validation_cli(
recent_diff.loc["corr"] = -recent_diff.loc[
"corr"
] # Invert as higher corrs are good
recent_diff.loc[
recent_diff["diff"] < 0, "prefix"
] = ":heavy_check_mark: improved by "
recent_diff.loc[
recent_diff["diff"] == 0, "prefix"
] = ":heavy_minus_sign: no change"
recent_diff.loc[
recent_diff["diff"] > 0, "prefix"
] = ":heavy_exclamation_mark: worsened by "
recent_diff.loc[recent_diff["diff"] < 0, "prefix"] = (
":heavy_check_mark: improved by "
)
recent_diff.loc[recent_diff["diff"] == 0, "prefix"] = (
":heavy_minus_sign: no change"
)
recent_diff.loc[recent_diff["diff"] > 0, "prefix"] = (
":heavy_exclamation_mark: worsened by "
)
recent_diff["suffix"] = recent_diff["diff"].abs().round(3).replace({0: ""})
recent_diff = (
recent_diff.prefix.astype(str) + recent_diff.suffix.astype(str).str[0:5]
Expand Down
11 changes: 5 additions & 6 deletions tests/test_coastline.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import pytest
import json
from click.testing import CliRunner
from coastlines.raster import generate_rasters_cli
from coastlines.vector import generate_vectors_cli
from coastlines.continental import continental_cli
from coastlines.validation import validation_cli

import os
import json
os.environ['CLICK_DEBUG'] = '1'

@pytest.mark.dependency()
def test_generate_rasters_cli():
Expand Down Expand Up @@ -76,6 +74,7 @@ def test_generate_continental_cli():
# assert result.output == '' # for debugging
assert result.exit_code == 0


@pytest.mark.dependency(depends=["test_generate_continental_cli"])
def test_validation_cli(capsys):
runner = CliRunner()
Expand All @@ -101,9 +100,9 @@ def test_validation_cli(capsys):
"output": result.output,
"exception": str(result.exception) if result.exception else None,
}

# Convert error_info to a formatted string
error_details = json.dumps(error_info, indent=2)

# Use the detailed error information in the assertion message
assert result.exit_code == 0, f"Command failed. Error details:\n{error_details}"
assert result.exit_code == 0, f"Command failed. Error details:\n{error_details}"

0 comments on commit 3ec5129

Please sign in to comment.