Skip to content

Commit

Permalink
Code style gardening by black
Browse files Browse the repository at this point in the history
The changes adhere the codebase to Python's PEP 8 style guide more closely. The
primary modifications include placing conditional logic inside parentheses in
order to improve readability and understanding of the code's flow control.
  • Loading branch information
douglatornell committed Mar 7, 2024
1 parent b245205 commit 64f7849
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 28 deletions.
1 change: 1 addition & 0 deletions nowcast/daily_river_flows.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Module for calculating daily river flows
"""

import functools
import warnings
from pathlib import Path
Expand Down
8 changes: 5 additions & 3 deletions nowcast/workers/get_onc_ferry.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,11 @@ def _empty_device_data(
"device_category": device_category,
"qaqcFlag": numpy.array([], dtype=numpy.int64),
"unitOfMeasure": onc_units[sensor],
"units": "degrees_Celcius"
if sensor in {"temperature", "air_temperature"}
else onc_units[sensor],
"units": (
"degrees_Celcius"
if sensor in {"temperature", "air_temperature"}
else onc_units[sensor]
),
},
)
for sensor in sensors.split(",")
Expand Down
8 changes: 5 additions & 3 deletions nowcast/workers/make_ssh_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,11 @@ def make_ssh_file(parsed_args, config, *args):
neah_bay_hourly_tides = config["ssh"]["neah bay hourly"]
dates, sshs, fflags = residuals.NeahBay_forcing_anom(
data_file,
run_date.datetime
if run_type == "nowcast"
else run_date.shift(days=-1).datetime,
(
run_date.datetime
if run_type == "nowcast"
else run_date.shift(days=-1).datetime
),
tidal_preds_dir / neah_bay_hourly_tides,
parsed_args.archive,
parsed_args.text_file is None,
Expand Down
16 changes: 9 additions & 7 deletions nowcast/workers/update_forecast_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,13 +282,15 @@ def _extract_1st_forecast_day(tmp_forecast_results_archive, run_date, model, con
continue
forecast_file_24h = day_dir / forecast_file.name
forecast_time_intervals = {
"nemo": 24
if forecast_file.name.startswith("SalishSea_1h")
or forecast_file.name.startswith("CHS_currents")
else 24 * 6,
"wwatch3": 24 * 2
if forecast_file.name.startswith("SoG_ww3_fields")
else 24 * 6,
"nemo": (
24
if forecast_file.name.startswith("SalishSea_1h")
or forecast_file.name.startswith("CHS_currents")
else 24 * 6
),
"wwatch3": (
24 * 2 if forecast_file.name.startswith("SoG_ww3_fields") else 24 * 6
),
}
forecast_times = forecast_time_intervals[model]
time_var = model_params[model]["time variable"]
Expand Down
34 changes: 19 additions & 15 deletions tests/workers/test_download_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,9 +554,11 @@ def test_results_files_fix_perms(
)
p_glob = patch(
"nowcast.workers.download_results.Path.glob",
side_effect=[[Path("namelist_cfg")], [], []]
if run_type == "hindcast"
else [[], [Path("namelist_cfg")], [], []],
side_effect=(
[[Path("namelist_cfg")], [], []]
if run_type == "hindcast"
else [[], [Path("namelist_cfg")], [], []]
),
)
with p_glob:
download_results.download_results(parsed_args, config)
Expand Down Expand Up @@ -585,18 +587,20 @@ def test_checklist(
)
p_glob = patch(
"nowcast.workers.download_results.Path.glob",
side_effect=[
[],
[Path("Salishsea_1h_20180522_20180522_grid_T.nc")],
[Path("Salishsea_1d_20180522_20180522_grid_T.nc")],
]
if run_type == "hindcast"
else [
[],
[],
[Path("Salishsea_1h_20180522_20180522_grid_T.nc")],
[Path("Salishsea_1d_20180522_20180522_grid_T.nc")],
],
side_effect=(
[
[],
[Path("Salishsea_1h_20180522_20180522_grid_T.nc")],
[Path("Salishsea_1d_20180522_20180522_grid_T.nc")],
]
if run_type == "hindcast"
else [
[],
[],
[Path("Salishsea_1h_20180522_20180522_grid_T.nc")],
[Path("Salishsea_1d_20180522_20180522_grid_T.nc")],
]
),
)
with p_glob:
checklist = download_results.download_results(parsed_args, config)
Expand Down

0 comments on commit 64f7849

Please sign in to comment.