From ffb3f43f7f88d8c2c6ffce3af9452699b797fb54 Mon Sep 17 00:00:00 2001 From: jim Date: Sun, 17 May 2015 19:41:37 -0500 Subject: [PATCH] #2 added reprs --- nd2reader/__init__.py | 2 +- nd2reader/model/__init__.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/nd2reader/__init__.py b/nd2reader/__init__.py index 0532299..c0d16d9 100644 --- a/nd2reader/__init__.py +++ b/nd2reader/__init__.py @@ -16,7 +16,7 @@ class Nd2(Nd2Parser): self._filename = filename def __repr__(self): - return "\n".join(["ND2: %s" % self._filename, + return "\n".join(["" % self._filename, "Created: %s" % self._absolute_start.strftime("%Y-%m-%d %H:%M:%S"), "Image size: %sx%s (HxW)" % (self.height, self.width), "Image cycles: %s" % self._time_index_count, diff --git a/nd2reader/model/__init__.py b/nd2reader/model/__init__.py index 796b96e..55d57c3 100644 --- a/nd2reader/model/__init__.py +++ b/nd2reader/model/__init__.py @@ -16,6 +16,15 @@ class Image(object): self._width = width self._data = None + def __repr__(self): + return "\n".join(["", + "%sx%s (HxW)" % (self._height, self._width), + "Timestamp: %s" % self.timestamp, + "Field of View: %s" % self.field_of_view, + "Channel: %s" % self.channel, + "Z-Level: %s" % self.z_level, + ]) + @property def field_of_view(self): return self._field_of_view @@ -56,6 +65,10 @@ class ImageSet(object): def __init__(self): self._images = collections.defaultdict(dict) + def __repr__(self): + return "\n".join(["", + "Image count: %s" % len(self)]) + def get(self, channel="", z_level=0): """ Retrieve an image with a given channel and z-level. For most users, z_level will always be 0.