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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ repos:
- id: check-added-large-files
# Code formatting with black
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 25.12.0
rev: 26.1.0
hooks:
- id: black
1 change: 0 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import tomllib
from pathlib import Path


sys.path.insert(0, os.path.abspath(".."))


Expand Down
7 changes: 3 additions & 4 deletions moad_tools/midoss/geotiff_watermask.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
a SalishSeaCast domain water mask for the AIS ship track density GeoTIFF files used to
generate oil spill parameters for Monte Carlo runs of MOHID.
"""

import logging
import sys
from pathlib import Path
Expand Down Expand Up @@ -130,8 +131,7 @@ def write_numpy_file(watermask, numpy_file):
logging.info(f"wrote Numpy boolean water mask array to: {numpy_path}")


@click.command(
help="""
@click.command(help="""
Calculate and store a Numpy array file containing a SalishSeaCast domain water mask for the
AIS ship track density GeoTIFF files used to generate oil spill parameters for
Monte Carlo runs of MOHID.
Expand All @@ -143,8 +143,7 @@ def write_numpy_file(watermask, numpy_file):
https://ubc-moad-tools.readthedocs.io/en/latest/moad_tools.html#module-moad_tools.midoss.geotiff_watermask

for more information about arguments and options.
"""
)
""")
@click.version_option()
@click.argument(
"geotiff_file",
Expand Down
1 change: 1 addition & 0 deletions moad_tools/midoss/hdf5_to_netcdf4.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@


"""Functions to transform an MOHID HDF5 output file into a netCDF4 file."""

import logging
import os
import shlex
Expand Down
7 changes: 3 additions & 4 deletions moad_tools/midoss/random_oil_spills.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"""Functions and command-line tool to calculate a CSV file containing parameters of a set
of random oil spills to drive Monte Carlo runs of MOHID.
"""

import collections
import logging
import sys
Expand Down Expand Up @@ -1589,8 +1590,7 @@ def write_csv_file(df, csv_file):
logging.info(f"wrote CSV file to {csv_file}")


@click.command(
help="""
@click.command(help="""
Calculate and store a CSV file containing parameters of a set of random oil spills
to drive Monte Carlo runs of MOHID.

Expand All @@ -1606,8 +1606,7 @@ def write_csv_file(df, csv_file):
https://ubc-moad-tools.readthedocs.io/en/latest/moad_tools.html#processing-configuration-yaml-file

for details of the contents of the config file.
"""
)
""")
@click.version_option()
@click.argument("n_spills", type=int)
@click.argument(
Expand Down
1 change: 1 addition & 0 deletions moad_tools/observations.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@


"""Functions for downloading observations data from web services."""

import logging
import urllib.error

Expand Down
1 change: 1 addition & 0 deletions tests/midoss/test_geotiff_watermask.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@


"""Unit tests for geotiff_watermask module."""

import shlex
import sys

Expand Down
1 change: 1 addition & 0 deletions tests/midoss/test_hdf5_to_netcdf4.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@


"""Unit tests for hdf5_to_netcdf4 module."""

import shlex
import sys

Expand Down
31 changes: 9 additions & 22 deletions tests/midoss/test_random_oil_spills.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@


"""Unit tests for random_oil_spills module."""

import logging
import shlex
import sys
Expand Down Expand Up @@ -57,9 +58,7 @@ def config_file(tmp_path):
geotiff_watermask = geotiffs_dir / "geotiff-watermask.npy"
ssc_mesh = test_data / "mesh_mask201702.nc"
config_file = tmp_path / "random_oil_spills.yaml"
config_file.write_text(
textwrap.dedent(
f"""\
config_file.write_text(textwrap.dedent(f"""\
start date: 2015-01-01
end date: 2018-12-31

Expand All @@ -81,9 +80,7 @@ def config_file(tmp_path):
- other

oil attribution: {test_data}/oil_attribution.yaml
"""
)
)
"""))
return str(config_file)


Expand Down Expand Up @@ -805,9 +802,7 @@ def test_get_oil_type_atb_tanker_cargo_spill(
data_dir = tmp_path / "marine_transport_data"
data_dir.mkdir()
cargo_info_file = data_dir / "yaml_file"
cargo_info_file.write_text(
textwrap.dedent(
"""\
cargo_info_file.write_text(textwrap.dedent("""\
Westridge Marine Terminal:
atb:
akns:
Expand Down Expand Up @@ -840,9 +835,7 @@ def test_get_oil_type_atb_tanker_cargo_spill(
fraction_of_total: 0
other:
fraction_of_total: 0
"""
)
)
"""))
monkeypatch.setitem(oil_attrs["files"], "CAD_origin", cargo_info_file)
empty_file = data_dir / "empty_file"
empty_file.write_text("")
Expand Down Expand Up @@ -912,9 +905,7 @@ def test_get_oil_type_barge_cargo_spill(
data_dir = tmp_path / "marine_transport_data"
data_dir.mkdir()
cargo_info_file = data_dir / "yaml_file"
cargo_info_file.write_text(
textwrap.dedent(
"""\
cargo_info_file.write_text(textwrap.dedent("""\
Westridge Marine Terminal:
barge:
akns:
Expand All @@ -931,9 +922,7 @@ def test_get_oil_type_barge_cargo_spill(
fraction_of_total: 0
other:
fraction_of_total: 0
"""
)
)
"""))
monkeypatch.setitem(oil_attrs["files"], "CAD_origin", cargo_info_file)
empty_file = data_dir / "empty_file"
empty_file.write_text("")
Expand Down Expand Up @@ -1056,12 +1045,10 @@ def test_write_csv_file(self, tmp_path):

random_oil_spills.write_csv_file(df, str(out_csv))

expected = textwrap.dedent(
"""\
expected = textwrap.dedent("""\
spill_date_hour,run_days
2016-08-19 18:00,7
2015-01-06 10:00,7
"""
)
""")

assert out_csv.read_text() == expected
1 change: 1 addition & 0 deletions tests/test_observations.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@


"""Unit tests for observations module."""

import urllib.error

import pandas
Expand Down
Loading