[segyio] 335/376: Add doc for dict-ops on headers

Jørgen Kvalsvik jokva-guest at moszumanska.debian.org
Wed Sep 20 08:04:55 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 3d23647a07a2427a0feb677021cb947b3fa10bb0
Author: Jørgen Kvalsvik <jokva at statoil.com>
Date:   Fri Aug 11 15:14:39 2017 +0200

    Add doc for dict-ops on headers
    
    The documentation and tests were unclear on the existence of these
    features, and are extended to be clear and with examples.
---
 python/segyio/segy.py | 41 ++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 40 insertions(+), 1 deletion(-)

diff --git a/python/segyio/segy.py b/python/segyio/segy.py
index 54d3a98..0af3b34 100644
--- a/python/segyio/segy.py
+++ b/python/segyio/segy.py
@@ -217,7 +217,10 @@ class SegyFile(object):
         both in individual (trace) mode and line mode. Individual headers are
         accessed via generators and are not read from or written to disk until
         the generator is realised and the header in question is used. Supports
-        python slicing (which yields a generator), as well as direct lookup.
+        python slicing (which yields a generator), as well as direct lookup and
+        common dict operations.
+
+        The header can be considered a dictionary with a constant set of keys.
 
         Examples:
             Reading a field in a trace::
@@ -307,6 +310,24 @@ class SegyFile(object):
             Set offset line 3 offset 3 to 5::
                 >>> f.header.iline[3, 3] = { TraceField.offset: 5 }
 
+            Since v1.3, common dict operations are supported.
+
+            Get a list of keys and values::
+                >>> f.header[10].keys()
+                >>> f.header[10].values()
+
+            Get a list of key-value pairs::
+                >>> f.header[10].items()
+
+            Get the number of keys-value pairs in a header::
+                >>> len(f.header[10])
+
+            Update a set of values::
+                >>> d = { segyio.su.tracl: 10, segyio.su.nhs: 5 }
+                >>> f.header[10].update(d)
+                >>> l = [ (segyio.su.sy, 11), (segyio.su.sx, 4) ]
+                >>> f.header[11].update(l)
+
         :rtype: segyio._header.Header
         """
         return self._header
@@ -1066,6 +1087,24 @@ class SegyFile(object):
 
             Write multiple fields in a trace::
                 >>> f.bin = { 3213: 5, BinField.SweepFrequencyStart: 17 }
+
+            Since v1.3, common dict operations are supported.
+
+            Get a list of keys and values::
+                >>> f.bin.keys()
+                >>> f.bin.values()
+
+            Get a list of key-value pairs::
+                >>> f.bin.items()
+
+            Get the number of keys-value pairs in a header::
+                >>> len(f.bin)
+
+            Update a set of values::
+                >>> d = { segyio.su.jobid: 10, segyio.su.lino: 5 }
+                >>> f.bin.update(d)
+                >>> l = [ (segyio.su.hdt, 11), (segyio.su.hsfs, 4) ]
+                >>> f.bin.update(l)
         """
 
         return Field.binary(self)

-- 
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