From 4c1a4a0330be96b7777afa49e75ebd6111d9d426 Mon Sep 17 00:00:00 2001 From: Jim Rybarski Date: Sun, 31 May 2015 01:33:58 +0000 Subject: [PATCH] resolves #45: implements the __len__ method --- nd2reader/__init__.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/nd2reader/__init__.py b/nd2reader/__init__.py index ca14b22..befc5ae 100644 --- a/nd2reader/__init__.py +++ b/nd2reader/__init__.py @@ -24,6 +24,16 @@ class Nd2(Nd2Parser): "Z-Levels: %s" % self._z_level_count ]) + def __len__(self): + """ + This should be the total number of images in the ND2, but it may be inaccurate. If the ND2 contains a + different number of images in a cycle (i.e. there are "gap" images) it will be higher than reality. + + :rtype: int + + """ + return self._image_count * self._channel_count + @property def height(self): """