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
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repos:
types: [text]
files: \.(json|ipynb)$
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.3
rev: v0.9.6
hooks:
- id: ruff
args: [--fix, --show-fixes]
Expand All @@ -22,6 +22,6 @@ repos:
- id: ruff-format
types_or: [python, jupyter]
- repo: https://github.com/rbubley/mirrors-prettier # Update mirror as official mirror is deprecated
rev: v3.4.2
rev: v3.5.0
hooks:
- id: prettier
2 changes: 1 addition & 1 deletion docs/user-guide/tutorials/ADCP_data_tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
" {\"long_name\": \"distance to coast\", \"units\": \"m\", \"positive\": \"shoreward\"}\n",
")\n",
"peru = peru.set_coords(\"s\").sortby(\"s\")\n",
"print(f\"max distance from coast: {abs(peru.s.min()).data/1000:.2f} km\")"
"print(f\"max distance from coast: {abs(peru.s.min()).data / 1000:.2f} km\")"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions docs/user-guide/tutorials/CTD_data_tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,12 @@
"source": [
"# Fill the dataset with values from the csv files.\n",
"for ob in range(5): # loop through files\n",
" header = pd.read_csv(f\"Japan/CTD_Japan_station_{ob+1}.csv\", nrows=7, header=None)\n",
" header = pd.read_csv(f\"Japan/CTD_Japan_station_{ob + 1}.csv\", nrows=7, header=None)\n",
" ctd.lon[ob] = header.iloc[0, 1]\n",
" ctd.lat[ob] = header.iloc[1, 1]\n",
" ctd.start_time[ob] = header.iloc[2, 1]\n",
" ctd.end_time[ob] = header.iloc[3, 1]\n",
" data = pd.read_csv(f\"Japan/CTD_Japan_station_{ob+1}.csv\", skiprows=4)\n",
" data = pd.read_csv(f\"Japan/CTD_Japan_station_{ob + 1}.csv\", skiprows=4)\n",
" ctd.P[:, ob] = data[\"pressure [hPa]\"]\n",
" ctd.T[:, ob] = data[\"temperature [degC]\"]\n",
" ctd.S[:, ob] = data[\"salinity [g kg-1]\"]"
Expand Down
2 changes: 1 addition & 1 deletion docs/user-guide/tutorials/Drifter_data_tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
" Drifter(\n",
" Spacetime(\n",
" Location(latitude=-30, longitude=lon),\n",
" time=np.datetime64(f\"2023-07-{i+2:02d} 00:00:00\"),\n",
" time=np.datetime64(f\"2023-07-{i + 2:02d} 00:00:00\"),\n",
" ),\n",
" depth=0.0,\n",
" lifetime=timedelta(days=90),\n",
Expand Down
6 changes: 3 additions & 3 deletions src/virtualship/expedition/do_expedition.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ def do_expedition(expedition_dir: str | Path, input_data: Path | None = None) ->
os.makedirs(expedition_dir.joinpath("results"))

# calculate expedition cost in US$
assert (
schedule.waypoints[0].time is not None
), "First waypoint has no time. This should not be possible as it should have been verified before."
assert schedule.waypoints[0].time is not None, (
"First waypoint has no time. This should not be possible as it should have been verified before."
)
time_past = schedule_results.time - schedule.waypoints[0].time
cost = expedition_cost(schedule_results, time_past)
with open(expedition_dir.joinpath("results", "cost.txt"), "w") as file:
Expand Down
6 changes: 3 additions & 3 deletions src/virtualship/expedition/simulate_schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ def __init__(
self._ship_config = ship_config
self._schedule = schedule

assert (
self._schedule.waypoints[0].time is not None
), "First waypoint must have a time. This should have been verified before calling this function."
assert self._schedule.waypoints[0].time is not None, (
"First waypoint must have a time. This should have been verified before calling this function."
)
self._time = schedule.waypoints[0].time
self._location = schedule.waypoints[0].location

Expand Down
12 changes: 6 additions & 6 deletions tests/instruments/test_adcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ def test_simulate_adcp(tmpdir) -> None:
for var in ["lat", "lon"]:
obs_value = obs[var].values.item()
exp_value = exp[var]
assert np.isclose(
obs_value, exp_value
), f"Observation incorrect {vert_loc=} {obs_i=} {var=} {obs_value=} {exp_value=}."
assert np.isclose(obs_value, exp_value), (
f"Observation incorrect {vert_loc=} {obs_i=} {var=} {obs_value=} {exp_value=}."
)
for var in ["V", "U"]:
obs_value = obs[var].values.item()
exp_value = exp[var][vert_loc]
assert np.isclose(
obs_value, exp_value
), f"Observation incorrect {vert_loc=} {i=} {var=} {obs_value=} {exp_value=}."
assert np.isclose(obs_value, exp_value), (
f"Observation incorrect {vert_loc=} {i=} {var=} {obs_value=} {exp_value=}."
)
6 changes: 3 additions & 3 deletions tests/instruments/test_ctd.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,6 @@ def test_simulate_ctds(tmpdir) -> None:
for var in ["salinity", "temperature", "lat", "lon"]:
obs_value = obs[var].values.item()
exp_value = exp[var]
assert np.isclose(
obs_value, exp_value
), f"Observation incorrect {ctd_i=} {loc=} {var=} {obs_value=} {exp_value=}."
assert np.isclose(obs_value, exp_value), (
f"Observation incorrect {ctd_i=} {loc=} {var=} {obs_value=} {exp_value=}."
)
18 changes: 9 additions & 9 deletions tests/instruments/test_drifter.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ def test_simulate_drifters(tmpdir) -> None:
# Check if drifters are moving
# lat, lon, should be increasing values (with the above positive VU fieldset)
dlat = np.diff(results.sel(trajectory=traj)["lat"].values)
assert np.all(
dlat[np.isfinite(dlat)] > 0
), f"Drifter is not moving over y {drifter_i=}"
assert np.all(dlat[np.isfinite(dlat)] > 0), (
f"Drifter is not moving over y {drifter_i=}"
)
dlon = np.diff(results.sel(trajectory=traj)["lon"].values)
assert np.all(
dlon[np.isfinite(dlon)] > 0
), f"Drifter is not moving over x {drifter_i=}"
assert np.all(dlon[np.isfinite(dlon)] > 0), (
f"Drifter is not moving over x {drifter_i=}"
)
temp = results.sel(trajectory=traj)["temperature"].values
assert np.all(
temp[np.isfinite(temp)] == CONST_TEMPERATURE
), f"measured temperature does not match {drifter_i=}"
assert np.all(temp[np.isfinite(temp)] == CONST_TEMPERATURE), (
f"measured temperature does not match {drifter_i=}"
)
6 changes: 3 additions & 3 deletions tests/instruments/test_ship_underwater_st.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,6 @@ def test_simulate_ship_underwater_st(tmpdir) -> None:
for var in ["S", "T", "lat", "lon"]:
obs_value = obs[var].values.item()
exp_value = exp[var]
assert np.isclose(
obs_value, exp_value
), f"Observation incorrect {i=} {var=} {obs_value=} {exp_value=}."
assert np.isclose(obs_value, exp_value), (
f"Observation incorrect {i=} {var=} {obs_value=} {exp_value=}."
)
6 changes: 3 additions & 3 deletions tests/instruments/test_xbt.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,6 @@ def test_simulate_xbts(tmpdir) -> None:
for var in ["temperature", "lat", "lon"]:
obs_value = obs[var].values.item()
exp_value = exp[var]
assert np.isclose(
obs_value, exp_value
), f"Observation incorrect {xbt_i=} {loc=} {var=} {obs_value=} {exp_value=}."
assert np.isclose(obs_value, exp_value), (
f"Observation incorrect {xbt_i=} {loc=} {var=} {obs_value=} {exp_value=}."
)