Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
with self.assertRaises(TypeError):
_segyio.init_indices(f, dummy_metrics, dmy, dmy, 2)
with self.assertRaises(TypeError):
fdmy = numpy.zeros(1, dtype=numpy.single)
_segyio.init_indices(f, dummy_metrics, fdmy, dmy, dmy)
one = numpy.zeros(1, dtype=numpy.uintc)
two = numpy.zeros(2, dtype=numpy.uintc)
off = numpy.zeros(1, dtype=numpy.uintc)
with self.assertRaises(ValueError):
_segyio.init_indices(f, dummy_metrics, one, two, off)
with self.assertRaises(ValueError):
_segyio.init_indices(f, dummy_metrics, two, one, off)
# Happy Path
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)
self.assertListEqual([1, 2, 3, 4, 5], list(iline_indexes))
self.assertListEqual([20, 21, 22, 23, 24], list(xline_indexes))
self.assertListEqual([1], list(offsets))
_segyio.close(f)
# with self.assertRaises(KeyError):
# _segyio.init_indices(f, {}, dmy, dmy, dmy)
with self.assertRaises(TypeError):
_segyio.init_indices(f, dummy_metrics, 1, dmy, dmy)
with self.assertRaises(TypeError):
_segyio.init_indices(f, dummy_metrics, dmy, 2, dmy)
with self.assertRaises(TypeError):
_segyio.init_indices(f, dummy_metrics, dmy, dmy, 2)
with self.assertRaises(TypeError):
fdmy = numpy.zeros(1, dtype=numpy.single)
_segyio.init_indices(f, dummy_metrics, fdmy, dmy, dmy)
one = numpy.zeros(1, dtype=numpy.uintc)
two = numpy.zeros(2, dtype=numpy.uintc)
off = numpy.zeros(1, dtype=numpy.uintc)
with self.assertRaises(ValueError):
_segyio.init_indices(f, dummy_metrics, one, two, off)
with self.assertRaises(ValueError):
_segyio.init_indices(f, dummy_metrics, two, one, off)
# Happy Path
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)
'offset_count': 1}
with self.assertRaises(TypeError):
_segyio.init_indices(".", {}, dmy, dmy, dmy)
with self.assertRaises(TypeError):
_segyio.init_indices(f, "-", dmy, dmy, dmy)
# with self.assertRaises(KeyError):
# _segyio.init_indices(f, {}, dmy, dmy, dmy)
with self.assertRaises(TypeError):
_segyio.init_indices(f, dummy_metrics, 1, dmy, dmy)
with self.assertRaises(TypeError):
_segyio.init_indices(f, dummy_metrics, dmy, 2, dmy)
with self.assertRaises(TypeError):
_segyio.init_indices(f, dummy_metrics, dmy, dmy, 2)
with self.assertRaises(TypeError):
fdmy = numpy.zeros(1, dtype=numpy.single)
_segyio.init_indices(f, dummy_metrics, fdmy, dmy, dmy)
one = numpy.zeros(1, dtype=numpy.uintc)
two = numpy.zeros(2, dtype=numpy.uintc)
off = numpy.zeros(1, dtype=numpy.uintc)
with self.assertRaises(ValueError):
_segyio.init_indices(f, dummy_metrics, one, two, off)
with self.assertRaises(ValueError):
_segyio.init_indices(f, dummy_metrics, two, one, off)
_segyio.init_indices(".", {}, dmy, dmy, dmy)
with self.assertRaises(TypeError):
_segyio.init_indices(f, "-", dmy, dmy, dmy)
# with self.assertRaises(KeyError):
# _segyio.init_indices(f, {}, dmy, dmy, dmy)
with self.assertRaises(TypeError):
_segyio.init_indices(f, dummy_metrics, 1, dmy, dmy)
with self.assertRaises(TypeError):
_segyio.init_indices(f, dummy_metrics, dmy, 2, dmy)
with self.assertRaises(TypeError):
_segyio.init_indices(f, dummy_metrics, dmy, dmy, 2)
with self.assertRaises(TypeError):
fdmy = numpy.zeros(1, dtype=numpy.single)
_segyio.init_indices(f, dummy_metrics, fdmy, dmy, dmy)
one = numpy.zeros(1, dtype=numpy.uintc)
two = numpy.zeros(2, dtype=numpy.uintc)
off = numpy.zeros(1, dtype=numpy.uintc)
with self.assertRaises(ValueError):
_segyio.init_indices(f, dummy_metrics, one, two, off)
with self.assertRaises(ValueError):
_segyio.init_indices(f, dummy_metrics, two, one, off)
# Happy Path
iline_indexes = numpy.zeros(metrics['iline_count'], dtype=numpy.uintc)
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")
with self.assertRaises(KeyError):
_segyio.fread_trace0(2, len(iline_indexes), line_metrics['xline_stride'], offset_count, xline_indexes, "crossline")
value = _segyio.fread_trace0(1, len(xline_indexes), line_metrics['iline_stride'], offset_count, iline_indexes, "inline")
self.assertEqual(value, 0)
value = _segyio.fread_trace0(2, len(xline_indexes), line_metrics['iline_stride'], offset_count, iline_indexes, "inline")
self.assertEqual(value, 5)
value = _segyio.fread_trace0(21, len(iline_indexes), line_metrics['xline_stride'], offset_count, xline_indexes, "crossline")
self.assertEqual(value, 1)
_segyio.init_indices(f, dummy_metrics, fdmy, dmy, dmy)
one = numpy.zeros(1, dtype=numpy.uintc)
two = numpy.zeros(2, dtype=numpy.uintc)
off = numpy.zeros(1, dtype=numpy.uintc)
with self.assertRaises(ValueError):
_segyio.init_indices(f, dummy_metrics, one, two, off)
with self.assertRaises(ValueError):
_segyio.init_indices(f, dummy_metrics, two, one, off)
# Happy Path
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)
self.assertListEqual([1, 2, 3, 4, 5], list(iline_indexes))
self.assertListEqual([20, 21, 22, 23, 24], list(xline_indexes))
self.assertListEqual([1], list(offsets))
_segyio.close(f)
dummy_metrics = {'xline_count': 2,
'iline_count': 2,
'offset_count': 1}
with self.assertRaises(TypeError):
_segyio.init_indices(".", {}, dmy, dmy, dmy)
with self.assertRaises(TypeError):
_segyio.init_indices(f, "-", dmy, dmy, dmy)
# with self.assertRaises(KeyError):
# _segyio.init_indices(f, {}, dmy, dmy, dmy)
with self.assertRaises(TypeError):
_segyio.init_indices(f, dummy_metrics, 1, dmy, dmy)
with self.assertRaises(TypeError):
_segyio.init_indices(f, dummy_metrics, dmy, 2, dmy)
with self.assertRaises(TypeError):
_segyio.init_indices(f, dummy_metrics, dmy, dmy, 2)
with self.assertRaises(TypeError):
fdmy = numpy.zeros(1, dtype=numpy.single)
_segyio.init_indices(f, dummy_metrics, fdmy, dmy, dmy)
one = numpy.zeros(1, dtype=numpy.uintc)
two = numpy.zeros(2, dtype=numpy.uintc)
off = numpy.zeros(1, dtype=numpy.uintc)
with self.assertRaises(ValueError):
_segyio.init_indices(f, dummy_metrics, one, two, off)
binary_header = _segyio.read_binaryheader(f)
ilb = 189
xlb = 193
metrics = _segyio.init_metrics(f, binary_header, ilb, xlb)
dmy = numpy.zeros(2, dtype=numpy.uintc)
dummy_metrics = {'xline_count': 2,
'iline_count': 2,
'offset_count': 1}
with self.assertRaises(TypeError):
_segyio.init_indices(".", {}, dmy, dmy, dmy)
with self.assertRaises(TypeError):
_segyio.init_indices(f, "-", dmy, dmy, dmy)
# with self.assertRaises(KeyError):
# _segyio.init_indices(f, {}, dmy, dmy, dmy)
with self.assertRaises(TypeError):
_segyio.init_indices(f, dummy_metrics, 1, dmy, dmy)
with self.assertRaises(TypeError):
_segyio.init_indices(f, dummy_metrics, dmy, 2, dmy)
with self.assertRaises(TypeError):
_segyio.init_indices(f, dummy_metrics, dmy, dmy, 2)
with self.assertRaises(TypeError):
fdmy = numpy.zeros(1, dtype=numpy.single)
_segyio.init_indices(f, dummy_metrics, fdmy, dmy, dmy)