climate-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From good...@apache.org
Subject [1/4] git commit: CLIMATE-476 - Add __str__ implementation to Dataset
Date Fri, 20 Jun 2014 15:51:48 GMT
Repository: climate
Updated Branches:
  refs/heads/master 79f20d4ab -> 0951a933e


CLIMATE-476 - Add __str__ implementation to Dataset


Project: http://git-wip-us.apache.org/repos/asf/climate/repo
Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/a2a072f9
Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/a2a072f9
Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/a2a072f9

Branch: refs/heads/master
Commit: a2a072f9b388cb88544ba2e4e829d27d78b01c3a
Parents: ab179cb
Author: Michael Joyce <joyce@apache.org>
Authored: Thu Jun 19 12:32:33 2014 -0700
Committer: Michael Joyce <joyce@apache.org>
Committed: Thu Jun 19 12:32:33 2014 -0700

----------------------------------------------------------------------
 ocw/dataset.py | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/climate/blob/a2a072f9/ocw/dataset.py
----------------------------------------------------------------------
diff --git a/ocw/dataset.py b/ocw/dataset.py
index 80ab18e..0621255 100644
--- a/ocw/dataset.py
+++ b/ocw/dataset.py
@@ -178,6 +178,29 @@ Expected shape (%s, %s, %s) but received (%s, %s, %s)""" % (time_count,
             logger.error(err_msg)
             raise ValueError(err_msg)
 
+    def __str__(self):
+        lat_min, lat_max, lon_min, lon_max = self.spatial_boundaries()
+        start, end = self.time_range()
+        lat_range = "({}, {})".format(lat_min, lon_min)
+        lon_range = "({}, {})".format(lon_min, lon_min)
+        time_range = "({}, {})".format(start, end)
+
+        formatted_repr = (
+            "<Dataset - name: {}, "
+            "lat-range: {}, "
+            "lon-range: {}, "
+            "time_range: {}, "
+            "var: {}>"
+        )
+
+        return formatted_repr.format(
+            self.name if self.name != "" else None,
+            lat_range,
+            lon_range,
+            time_range,
+            self.variable
+        )
+
 
 class Bounds(object):
     '''Container for holding spatial and temporal bounds information.


Mime
View raw message