Skip to content
Open
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: 0 additions & 4 deletions xbout/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -1155,10 +1155,6 @@ def _open_grid(datapath, chunks, keep_xboundaries, keep_yboundaries, mxg=2, **kw
if len(unrecognised_dims) > 0:
# Weird string formatting is a workaround to deal with possible bug in
# pytest warnings capture - doesn't match strings containing brackets
Comment on lines 1156 to 1157
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Weird string formatting is a workaround to deal with possible bug in
# pytest warnings capture - doesn't match strings containing brackets

Maybe also remove the comment?

warn(
"Will drop all variables containing the dimensions {} because "
"they are not recognised".format(str(unrecognised_dims)[1:-1])
)
grid = grid.drop_dims(unrecognised_dims)

if keep_xboundaries:
Expand Down
21 changes: 0 additions & 21 deletions xbout/tests/test_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,27 +41,6 @@ def test_open_grid(self, create_example_grid_file):
assert_equal(result, open_dataset(example_grid))
result.close()

def test_open_grid_extra_dims(self, create_example_grid_file, tmp_path_factory):
example_grid = open_dataset(create_example_grid_file)

new_var = DataArray(
name="new",
data=[[1, 2], [8, 9], [16, 17], [27, 28], [37, 38]],
dims=["x", "w"],
)

dodgy_grid_directory = tmp_path_factory.mktemp("dodgy_grid")
dodgy_grid_path = dodgy_grid_directory.joinpath("dodgy_grid.nc")
merge([example_grid, new_var]).to_netcdf(dodgy_grid_path, engine="h5netcdf")

with pytest.warns(
UserWarning, match="drop all variables containing " "the dimensions 'w'"
):
result = open_boutdataset(datapath=dodgy_grid_path)
result = result.drop_vars(["x", "y"])
assert_equal(result, example_grid)
result.close()

def test_open_grid_apply_geometry(self, create_example_grid_file):
@register_geometry(name="Schwarzschild")
def add_schwarzschild_coords(ds, coordinates=None):
Expand Down
Loading