From 5d6ab2ecbf985d966640ed848d9c5ea7b9ed45e4 Mon Sep 17 00:00:00 2001 From: Florian Obersteiner Date: Wed, 23 Feb 2022 09:51:52 +0100 Subject: [PATCH] __str__ and __repr__ for dataset and variable classes (unfinished) --- src/icartt/dataset.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/icartt/dataset.py b/src/icartt/dataset.py index 9cb3e9b..20dc6d9 100644 --- a/src/icartt/dataset.py +++ b/src/icartt/dataset.py @@ -308,7 +308,7 @@ class Variable: :type miss: float, defaults to -99999.0 """ - def desc(self, splitChar=","): + def desc(self, splitChar=", "): """Variable description string as it appears in an ICARTT file :return: description string @@ -361,10 +361,12 @@ class Variable: self.scale = scale self.miss = miss - # TODO: should this also get a __str__ ? + def __repr__(self): + # TODO: this sould be more meaningful + return "ICARTT Variable object repr" - def __repr__(self): # TODO: this could be more meaningful? - return "ICARTT Variable description" + def __str__(self): + return self.desc() class Dataset: @@ -383,8 +385,6 @@ class Dataset: :param format: """ - # TODO: should this also get a __str__ and a __repr__ ? - @property def nHeader(self): """Header line count @@ -875,6 +875,14 @@ class Dataset: except: pass + def __repr__(self): + # TODO: this could be more meaningful + return "ICARTT Dataset object repr" + + def __str__(self): + # 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? """Constructor method""" self.format = format -- GitLab