diff --git a/src/icartt/dataset.py b/src/icartt/dataset.py index 5c5946ea52b48b6167d618db4c39d31e0509561a..9504cbc3783d44624bfdb8b65e56bede0ba0d679 100644 --- a/src/icartt/dataset.py +++ b/src/icartt/dataset.py @@ -362,8 +362,8 @@ class Variable: self.miss = miss def __repr__(self): - # TODO: this sould be more meaningful - return "ICARTT Variable object repr" + # TODO: this sould be something else than __str__ ? + return self.desc() def __str__(self): return self.desc() @@ -419,9 +419,10 @@ class Dataset: :return: list of time steps :rtype: list """ + # TODO: this method currently does not work at all. + # suggest to also change to return a numpy array of numpy.datetime64 + # for consistency with other data output return [ - # TODO see commit f5208db0 - this will do unexpected things if - # self.dateOfCollection is a naive datetime object (think DST transitions...) self.dateOfCollection + datetime.timedelta(seconds=x) for x in self.independentVariable ] @@ -507,8 +508,11 @@ class Dataset: # line 7 - UTC date when data begin, UTC date of data reduction or revision # - comma delimited (yyyy, mm, dd, yyyy, mm, dd). dmp = f.readline() - self.dateOfCollection = datetime.datetime(*map(int, dmp[:3])) # TODO: set UTC ?! + self.dateOfCollection = datetime.datetime(*map(int, dmp[:3])) self.dateOfRevision = datetime.datetime(*map(int, dmp[3:6])) + # TODO: we should either use aware datetime (UTC), date objects or + # numpy.datetime64 here to avoid some 'rough edges' of Python's datetime library... + # line 8 - Data Interval (This value describes the time spacing (in seconds) # between consecutive data records. It is the (constant) interval between @@ -865,7 +869,8 @@ class Dataset: # TODO: this could be more meaningful return "ICARTT Dataset string representation" - def __init__(self, f=None, loadData=True, splitChar=",", format=Formats.FFI1001): # TODO: why is init comming last? + # TODO: why is init comming last? + def __init__(self, f=None, loadData=True, splitChar=",", format=Formats.FFI1001): """Constructor method""" self.format = format self.version = None @@ -883,8 +888,10 @@ class Dataset: self.dataSourceDescription = "Musterdatenprodukt" self.missionName = "MUSTEREX" - # TODO: not 100% sure if this is relevant here, but those dates should refer to UTC - # - if you leave the datetime objects naive (no tzinfo set), they represent local time. + # TODO: see also comment on _readData method. + # we should either use aware datetime (UTC), date objects or + # numpy.datetime64 here to avoid some 'rough edges' of Python's + # datetime library... self.dateOfCollection = datetime.datetime.today() self.dateOfRevision = datetime.datetime.today() self.dataIntervalCode = [0.0] diff --git a/tests/test_dataset.py b/tests/test_dataset.py index d55e8d2c55ae1cc15a41c17aeae0581401bfa699..2c78a1a767e5a71f6064d748014f84416aad0b87 100644 --- a/tests/test_dataset.py +++ b/tests/test_dataset.py @@ -311,6 +311,7 @@ class Create1001TestCase(unittest.TestCase): class BulkIOTestCase(unittest.TestCase): + # TODO: need to test invalid input # def testInvalid(self): # for fn in fns_fail: # with self.subTest(msg=f"Opening invalid file {str(fn)}"): @@ -351,6 +352,7 @@ class BulkIOTestCase(unittest.TestCase): ict.write(f=strOut) self.assertTrue(compareFiles(fn, strIn, strOut)) +# TODO: should also test dataset methods, e.g. .times if __name__ == "__main__": # pragma: no cover unittest.main()