[segyio] 122/376: Move indices generation to own helper method
Jørgen Kvalsvik
jokva-guest at moszumanska.debian.org
Wed Sep 20 08:04:19 UTC 2017
This is an automated email from the git hooks/post-receive script.
jokva-guest pushed a commit to branch debian
in repository segyio.
commit 663bb5ad28667da9cb315fc12edfae8102c7f766
Author: Jørgen Kvalsvik <jokva at statoil.com>
Date: Mon Nov 14 13:00:39 2016 +0100
Move indices generation to own helper method
---
python/segyio/_line.py | 26 ++++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)
diff --git a/python/segyio/_line.py b/python/segyio/_line.py
index b76ba69..ffef196 100644
--- a/python/segyio/_line.py
+++ b/python/segyio/_line.py
@@ -74,9 +74,8 @@ class Line:
return slice(start, stop, step)
- def _get_iter(self, lineno, offset, buf):
- """ :rtype: collections.Iterable[numpy.ndarray]"""
-
+ def _indices(self, lineno, offset):
+ """ :rtype: tuple[collections.Iterable, collections.Iterable]"""
offsets = self.segy.offsets
if offset is None:
offset = offsets[0]
@@ -90,14 +89,21 @@ class Line:
lineno = self._sanitize_slice(lineno, self.lines)
offset = self._sanitize_slice(offset, offsets)
- def gen():
- offs, lns = set(self.segy.offsets), set(self.lines)
- orng = xrange(*offset.indices(offsets[-1] + 1))
- lrng = xrange(*lineno.indices(self.lines[-1] + 1))
+ offs, lns = set(self.segy.offsets), set(self.lines)
+
+ orng = range(*offset.indices(offsets[-1] + 1))
+ lrng = range(*lineno.indices(self.lines[-1] + 1))
- for l in itertools.ifilter(lns.__contains__, lrng):
- for o in itertools.ifilter(offs.__contains__, orng):
- yield self._get(l, o, buf)
+ return filter(lns.__contains__, lrng), filter(offs.__contains__, orng)
+
+ def _get_iter(self, lineno, off, buf):
+ """ :rtype: collections.Iterable[numpy.ndarray]"""
+
+ def gen():
+ lines, offsets = self._indices(lineno, off)
+ for line in lines:
+ for offset in offsets:
+ yield self._get(line, offset, buf)
return gen()
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/segyio.git
More information about the debian-science-commits
mailing list