Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor test case virtual dataset creation into pytest fixture. #58

Closed
Closed
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
14 changes: 14 additions & 0 deletions virtualizarr/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,17 @@ def netcdf4_files(tmpdir):
ds2.to_netcdf(filepath2)

return filepath1, filepath2

@pytest.fixture
def concated_virtual_dataset_with_indexes(netcdf4_files):
"""Fixture to supply concatenated virtual dataset including indexes"""
from virtualizarr import open_virtual_dataset

filepath1, filepath2 = netcdf4_files

vds1 = open_virtual_dataset(filepath1)
vds2 = open_virtual_dataset(filepath2)

return xr.combine_by_coords(
[vds2, vds1],
)
10 changes: 2 additions & 8 deletions virtualizarr/tests/test_xarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,14 +257,8 @@ def index_mappings_equal(indexes1: Mapping[str, Index], indexes2: Mapping[str, I


class TestCombineUsingIndexes:
def test_combine_by_coords(self, netcdf4_files):
filepath1, filepath2 = netcdf4_files
def test_combine_by_coords(self, concated_virtual_dataset_with_indexes):

vds1 = open_virtual_dataset(filepath1)
vds2 = open_virtual_dataset(filepath2)

combined_vds = xr.combine_by_coords(
[vds2, vds1],
)
combined_vds = concated_virtual_dataset_with_indexes

assert combined_vds.xindexes["time"].to_pandas_index().is_monotonic_increasing
Loading