Skip to content

Commit

Permalink
add tests on out of bounds stereo
Browse files Browse the repository at this point in the history
  • Loading branch information
uriii3 committed Feb 18, 2025
1 parent ba9a2af commit e72b77c
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 2 deletions.
2 changes: 0 additions & 2 deletions copernicusmarine/download_functions/subset_xarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,6 @@ def _dataset_custom_sel(
coordinates_selection_method: CoordinatesSelectionMethod,
) -> xarray.Dataset:
coord_label = coord_type
logger.info(f"Selecting {coord_label} coordinates")
logger.info(f"Selection method: {dataset.sizes}")
if coord_label in dataset.sizes:
if coordinates_selection_method == "outside":
if (
Expand Down
69 changes: 69 additions & 0 deletions tests/test_originalGrid_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,72 @@ def run_one_dataset(self, dataset_info):
assert returned_value["coordinates_extent"][1]["minimum"] == float(
min_x
)

def test_out_of_bounds(self):
command = [
"copernicusmarine",
"subset",
"-i",
"cmems_mod_arc_bgc_anfc_ecosmo_P1D-m",
"--dataset-part",
"originalGrid",
"--maximum-x",
"100",
"--minimum-x",
"-100",
"--maximum-y",
"10",
"--minimum-y",
"4",
"-t",
"2020",
"-T",
"2020",
"--dry-run",
]
self.output = execute_in_terminal(command)
assert self.output.returncode == 0
assert b"WARNING" in self.output.stderr
assert (
b"Some of your subset selection [-100.0, 100.0] for the"
b" x dimension exceed the dataset coordinates [-36.0, 38.0]"
in self.output.stderr
)
assert (
b"Some of your subset selection [-100.0, 100.0] for the "
b"y dimension exceed the dataset coordinates [-43.0, 28.0]"
in self.output.stderr
)

def test_out_of_bounds_w_error(self):
command = [
"copernicusmarine",
"subset",
"-i",
"cmems_mod_arc_bgc_anfc_ecosmo_P1D-m",
"--dataset-part",
"originalGrid",
"--maximum-x",
"1",
"--minimum-x",
"-1",
"--maximum-y",
"10",
"--minimum-y",
"4",
"-t",
"2020",
"-T",
"2020",
"--dry-run",
"--coordinates-selection-method",
"strict-inside",
]
self.output = execute_in_terminal(command)
assert self.output.returncode == 1
assert b"ERROR" in self.output.stderr
assert (
b"Some of your subset selection [-100.0, 100.0] for the y"
b" dimension exceed the dataset coordinates [-43.0, 28.0]"
in self.output.stderr
)

0 comments on commit e72b77c

Please sign in to comment.