Skip to content

Commit

Permalink
Fix test_ancillary_variables for CF writer
Browse files Browse the repository at this point in the history
  • Loading branch information
djhoese committed Jan 4, 2021
1 parent 3d55a23 commit 9edad60
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions satpy/tests/writer_tests/test_cf.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,14 @@ def test_ancillary_variables(self):
"""Test ancillary_variables cited each other."""
import xarray as xr
from satpy import Scene
from satpy.tests.utils import make_dataid
scn = Scene()
start_time = datetime(2018, 5, 30, 10, 0)
end_time = datetime(2018, 5, 30, 10, 15)
da = xr.DataArray([1, 2, 3],
attrs=dict(start_time=start_time,
end_time=end_time,
prerequisites=[DatasetID('hej')]))
prerequisites=[make_dataid(name='hej')]))
scn['test-array-1'] = da
scn['test-array-2'] = da.copy()
scn['test-array-1'].attrs['ancillary_variables'] = [scn['test-array-2']]
Expand Down Expand Up @@ -990,7 +991,7 @@ def test_load_module_with_old_pyproj(self):
importlib.reload(sys.modules['satpy.writers.cf_writer'])

def test_global_attr_default_history_and_Conventions(self):
"""Test saving global attributes history and Conventions"""
"""Test saving global attributes history and Conventions."""
from satpy import Scene
import xarray as xr
scn = Scene()
Expand All @@ -1008,7 +1009,7 @@ def test_global_attr_default_history_and_Conventions(self):
self.assertIn('Created by pytroll/satpy on', f.attrs['history'])

def test_global_attr_history_and_Conventions(self):
"""Test saving global attributes history and Conventions"""
"""Test saving global attributes history and Conventions."""
from satpy import Scene
import xarray as xr
scn = Scene()
Expand Down Expand Up @@ -1106,7 +1107,9 @@ def test_collect_datasets_with_latitude_named_lat(self, *mocks):

class EncodingUpdateTest(unittest.TestCase):
"""Test update of netCDF encoding."""

def setUp(self):
"""Create fake data for testing."""
import xarray as xr
self.ds = xr.Dataset({'foo': (('y', 'x'), [[1, 2], [3, 4]]),
'bar': (('y', 'x'), [[3, 4], [5, 6]])},
Expand All @@ -1115,6 +1118,7 @@ def setUp(self):
'lon': (('y', 'x'), [[7, 8], [9, 10]])})

def test_without_time(self):
"""Test data without a time dimension."""
from satpy.writers.cf_writer import update_encoding

# Without time dimension
Expand All @@ -1140,6 +1144,7 @@ def test_without_time(self):
'bar': {'chunksizes': (2, 2)}})

def test_with_time(self):
"""Test data with a time dimension."""
from satpy.writers.cf_writer import update_encoding

# With time dimension
Expand Down

0 comments on commit 9edad60

Please sign in to comment.