-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created conftest.py and moved two fixtures into conftest (#57)
* created conftest.py and moved two fixtures into conftest * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
5f03e6e
commit 2c83531
Showing
2 changed files
with
31 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import pytest | ||
import xarray as xr | ||
|
||
@pytest.fixture | ||
def netcdf4_file(tmpdir): | ||
# Set up example xarray dataset | ||
ds = xr.tutorial.open_dataset("air_temperature") | ||
|
||
# Save it to disk as netCDF (in temporary directory) | ||
filepath = f"{tmpdir}/air.nc" | ||
ds.to_netcdf(filepath) | ||
|
||
return filepath | ||
|
||
|
||
@pytest.fixture | ||
def netcdf4_files(tmpdir): | ||
# Set up example xarray dataset | ||
ds = xr.tutorial.open_dataset("air_temperature") | ||
|
||
# split inrto equal chunks so we can concatenate them back together later | ||
ds1 = ds.isel(time=slice(None, 1460)) | ||
ds2 = ds.isel(time=slice(1460, None)) | ||
|
||
# Save it to disk as netCDF (in temporary directory) | ||
filepath1 = f"{tmpdir}/air1.nc" | ||
filepath2 = f"{tmpdir}/air2.nc" | ||
ds1.to_netcdf(filepath1) | ||
ds2.to_netcdf(filepath2) | ||
|
||
return filepath1, filepath2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters