[segyio] 64/376: Correctly return segy text header size

Jørgen Kvalsvik jokva-guest at moszumanska.debian.org
Wed Sep 20 08:04:08 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 e80cde882c39edf3f08df08f8c27235278021628
Author: Jørgen Kvalsvik <jokva at statoil.com>
Date:   Thu Oct 20 10:13:15 2016 +0200

    Correctly return segy text header size
---
 python/segyio/_segyio.c | 4 ++--
 python/segyio/create.py | 2 +-
 tests/test_segyio_c.py  | 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/python/segyio/_segyio.c b/python/segyio/_segyio.c
index 92f4be2..9a0834f 100644
--- a/python/segyio/_segyio.c
+++ b/python/segyio/_segyio.c
@@ -192,7 +192,7 @@ static PyObject *py_handle_segy_error_with_index_and_name(int error, int errno_e
 // ------------ Text Header -------------
 
 static PyObject *py_textheader_size(PyObject *self) {
-    return Py_BuildValue("i", segy_textheader_size());
+    return Py_BuildValue("i", SEGY_TEXT_HEADER_SIZE);
 }
 
 static PyObject *py_read_texthdr(PyObject *self, PyObject *args) {
@@ -227,7 +227,7 @@ static PyObject *py_write_texthdr(PyObject *self, PyObject *args) {
 
     PyArg_ParseTuple(args, "Ois#", &file_capsule, &index, &buffer, &size);
 
-    if (size < segy_textheader_size() - 1) {
+    if (size < SEGY_TEXT_HEADER_SIZE) {
         return PyErr_Format(PyExc_ValueError, "String must have at least 3200 characters. Received count: %d", size);
     }
 
diff --git a/python/segyio/create.py b/python/segyio/create.py
index 618d5d1..4dcf41b 100644
--- a/python/segyio/create.py
+++ b/python/segyio/create.py
@@ -101,7 +101,7 @@ def create(filename, spec):
 
     txt_hdr_sz = segyio._segyio.textheader_size()
     bin_hdr_sz = segyio._segyio.binheader_size()
-    f._tr0          = -1 + txt_hdr_sz + bin_hdr_sz + (spec.ext_headers * (txt_hdr_sz - 1))
+    f._tr0          = txt_hdr_sz + bin_hdr_sz + (spec.ext_headers * txt_hdr_sz)
     f._sorting       = spec.sorting
     f._fmt          = spec.format
     f._offsets       = spec.offsets
diff --git a/tests/test_segyio_c.py b/tests/test_segyio_c.py
index b261c38..f71aa23 100644
--- a/tests/test_segyio_c.py
+++ b/tests/test_segyio_c.py
@@ -54,7 +54,7 @@ class _segyioTests(TestCase):
         self.assertEqual(400, _segyio.binheader_size())
 
     def test_textheader_size(self):
-        self.assertEqual(3201, _segyio.textheader_size())
+        self.assertEqual(3200, _segyio.textheader_size())
 
     def test_open_non_existing_file(self):
         with self.assertRaises(IOError):
@@ -197,7 +197,7 @@ class _segyioTests(TestCase):
 
         self.assertEqual(metrics['iline_field'], ilb)
         self.assertEqual(metrics['xline_field'], xlb)
-        self.assertEqual(metrics['trace0'], _segyio.textheader_size() + _segyio.binheader_size() - 1)
+        self.assertEqual(metrics['trace0'], _segyio.textheader_size() + _segyio.binheader_size())
         self.assertEqual(metrics['sample_count'], 50)
         self.assertEqual(metrics['format'], 1)
         self.assertEqual(metrics['trace_bsize'], 200)

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