Skip to content

Commit

Permalink
Data.get_[count|index|list]
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhassell committed May 12, 2022
1 parent e6e4465 commit 54d6f70
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
1 change: 0 additions & 1 deletion cf/data/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
daskified_log_level = 0



def daskified(apply_temp_log_level=None):
def decorator(method):
"""Temporary decorator to mark and log methods migrated to Dask.
Expand Down
36 changes: 36 additions & 0 deletions cf/test/test_Data.py
Original file line number Diff line number Diff line change
Expand Up @@ -3965,6 +3965,42 @@ def test_Data_get_data(self):
d = cf.Data(9)
self.assertIs(d, d.get_data())

def test_Data_get_count(self):
import cfdm

f = cfdm.read("DSG_timeSeries_contiguous.nc")[0]
f = f.data
d = cf.Data(cf.RaggedContiguousArray(source=f.source()))
self.assertIsInstance(d.get_count(), cfdm.Count)

d = cf.Data(9, "m")
with self.assertRaises(ValueError):
d.get_count()

def test_Data_get_index(self):
import cfdm

f = cfdm.read("DSG_timeSeries_indexed.nc")[0]
f = f.data
d = cf.Data(cf.RaggedIndexedArray(source=f.source()))
self.assertIsInstance(d.get_index(), cfdm.Index)

d = cf.Data(9, "m")
with self.assertRaises(ValueError):
d.get_index()

def test_Data_get_list(self):
import cfdm

f = cfdm.read("gathered.nc")[0]
f = f.data
d = cf.Data(cf.GatheredArray(source=f.source()))
self.assertIsInstance(d.get_list(), cfdm.List)

d = cf.Data(9, "m")
with self.assertRaises(ValueError):
d.get_list()


if __name__ == "__main__":
print("Run date:", datetime.datetime.now())
Expand Down

0 comments on commit 54d6f70

Please sign in to comment.