Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_metrics(self):
f = _segyio.open(self.filename, "r")
binary_header = _segyio.read_binaryheader(f)
ilb = 189
xlb = 193
with self.assertRaises(TypeError):
metrics = _segyio.init_metrics("?", binary_header, ilb, xlb)
with self.assertRaises(TypeError):
metrics = _segyio.init_metrics(f, "?", ilb, xlb)
with self.assertRaises(IndexError):
metrics = _segyio.init_metrics(f, binary_header, ilb + 1, xlb)
metrics = _segyio.init_metrics(f, binary_header, ilb, xlb)
self.assertEqual(metrics['iline_field'], ilb)
self.assertEqual(metrics['xline_field'], xlb)
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)
self.assertEqual(metrics['sorting'], 2) # inline sorting = 2, crossline sorting = 1
self.assertEqual(metrics['trace_count'], 25)
self.assertEqual(metrics['offset_count'], 1)
self.assertEqual(metrics['iline_count'], 5)
self.assertEqual(metrics['xline_count'], 5)
_segyio.close(f)
with self.assertRaises(IOError):
def test_metrics(self):
f = _segyio.open(self.filename, "r")
binary_header = _segyio.read_binaryheader(f)
ilb = 189
xlb = 193
with self.assertRaises(TypeError):
metrics = _segyio.init_metrics("?", binary_header, ilb, xlb)
with self.assertRaises(TypeError):
metrics = _segyio.init_metrics(f, "?", ilb, xlb)
with self.assertRaises(IndexError):
metrics = _segyio.init_metrics(f, binary_header, ilb + 1, xlb)
metrics = _segyio.init_metrics(f, binary_header, ilb, xlb)
self.assertEqual(metrics['iline_field'], ilb)
self.assertEqual(metrics['xline_field'], xlb)
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)
self.assertEqual(metrics['sorting'], 2) # inline sorting = 2, crossline sorting = 1
self.assertEqual(metrics['trace_count'], 25)
self.assertEqual(metrics['offset_count'], 1)
self.assertEqual(metrics['iline_count'], 5)
def test_metrics(self):
f = _segyio.open(self.filename, "r")
binary_header = _segyio.read_binaryheader(f)
ilb = 189
xlb = 193
with self.assertRaises(TypeError):
metrics = _segyio.init_metrics("?", binary_header, ilb, xlb)
with self.assertRaises(TypeError):
metrics = _segyio.init_metrics(f, "?", ilb, xlb)
with self.assertRaises(IndexError):
metrics = _segyio.init_metrics(f, binary_header, ilb + 1, xlb)
metrics = _segyio.init_metrics(f, binary_header, ilb, xlb)
self.assertEqual(metrics['iline_field'], ilb)
self.assertEqual(metrics['xline_field'], xlb)
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)
self.assertEqual(metrics['sorting'], 2) # inline sorting = 2, crossline sorting = 1
self.assertEqual(metrics['trace_count'], 25)
self.assertEqual(metrics['offset_count'], 1)
self.assertEqual(metrics['iline_count'], 5)
self.assertEqual(metrics['xline_count'], 5)
_segyio.close(f)
def test_line_metrics(self):
f = _segyio.open(self.filename, "r")
binary_header = _segyio.read_binaryheader(f)
ilb = 189
xlb = 193
metrics = _segyio.init_metrics(f, binary_header, ilb, xlb)
_segyio.close(f)
sorting = metrics['sorting']
trace_count = metrics['trace_count']
inline_count = metrics['iline_count']
crossline_count = metrics['xline_count']
offset_count = metrics['offset_count']
metrics = _segyio.init_line_metrics(sorting, trace_count, inline_count, crossline_count, offset_count)
self.assertEqual(metrics['xline_length'], 5)
self.assertEqual(metrics['xline_stride'], 5)
self.assertEqual(metrics['iline_length'], 5)
self.assertEqual(metrics['iline_stride'], 1)
# (sorting, trace_count, inline_count, crossline_count, offset_count)
def test_metrics(self):
f = _segyio.open(self.filename, "r")
binary_header = _segyio.read_binaryheader(f)
ilb = 189
xlb = 193
with self.assertRaises(TypeError):
metrics = _segyio.init_metrics("?", binary_header, ilb, xlb)
with self.assertRaises(TypeError):
metrics = _segyio.init_metrics(f, "?", ilb, xlb)
with self.assertRaises(IndexError):
metrics = _segyio.init_metrics(f, binary_header, ilb + 1, xlb)
metrics = _segyio.init_metrics(f, binary_header, ilb, xlb)
self.assertEqual(metrics['iline_field'], ilb)
self.assertEqual(metrics['xline_field'], xlb)
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)
self.assertEqual(metrics['sorting'], 2) # inline sorting = 2, crossline sorting = 1
self.assertEqual(metrics['iline_field'], ilb)
self.assertEqual(metrics['xline_field'], xlb)
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)
self.assertEqual(metrics['sorting'], 2) # inline sorting = 2, crossline sorting = 1
self.assertEqual(metrics['trace_count'], 25)
self.assertEqual(metrics['offset_count'], 1)
self.assertEqual(metrics['iline_count'], 5)
self.assertEqual(metrics['xline_count'], 5)
_segyio.close(f)
with self.assertRaises(IOError):
metrics = _segyio.init_metrics(f, binary_header, ilb, xlb)
def test_fread_trace0(self):
f = _segyio.open(self.filename, "r")
binary_header = _segyio.read_binaryheader(f)
ilb = 189
xlb = 193
metrics = _segyio.init_metrics(f, binary_header, ilb, xlb)
sorting = metrics['sorting']
trace_count = metrics['trace_count']
inline_count = metrics['iline_count']
crossline_count = metrics['xline_count']
offset_count = metrics['offset_count']
line_metrics = _segyio.init_line_metrics(sorting, trace_count, inline_count, crossline_count, offset_count)
iline_indexes = numpy.zeros(metrics['iline_count'], dtype=numpy.uintc)
xline_indexes = numpy.zeros(metrics['xline_count'], dtype=numpy.uintc)
offsets = numpy.zeros(metrics['offset_count'], dtype=numpy.uintc)
_segyio.init_indices(f, metrics, iline_indexes, xline_indexes, offsets)
with self.assertRaises(KeyError):
_segyio.fread_trace0(0, len(xline_indexes), line_metrics['iline_stride'], offset_count, iline_indexes, "inline")