Skip to content

Commit

Permalink
Fix crash in header parsing when trace count is parsing block_size
Browse files Browse the repository at this point in the history
…+ 1 (#477)

* handle singleton edge case when trace_range only has 1 trace.

* reuse variable
  • Loading branch information
tasansal authored Dec 6, 2024
1 parent eb3b35d commit 3d5cfe2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/mdio/segy/_workers.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ def header_scan_worker(
non_void_fields = [(name, dtype) for name, (dtype, _) in fields.items()]
new_dtype = np.dtype(non_void_fields)

# Allocate empty memory and assign non-void fields
trace_header_filtered = np.empty_like(trace_header, dtype=new_dtype)
trace_header_filtered[:] = trace_header
# Copy to non-padded memory, ndmin is to handle the case where there is
# 1 trace in block (singleton) so we can concat and assign stuff later.
trace_header = np.array(trace_header, dtype=new_dtype, ndmin=1)

return cast(HeaderArray, trace_header_filtered)
return cast(HeaderArray, trace_header)


def trace_worker(
Expand Down

0 comments on commit 3d5cfe2

Please sign in to comment.