Skip to content

Commit 8fda50c

Browse files
committed
Add validation for chunking update
1 parent bc1b950 commit 8fda50c

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

tests/integration/test_rechunk.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ def test_rechunk_integration(segy_file, mdio_path):
8989
3. Perform a rechunk operation via the convenience API.
9090
4. Validate that the rechunked arrays have the same underlying data as the original,
9191
ensuring that data integrity remains undamaged.
92+
5. Validate that the chunking in zarr metadata matches the expected chunk sizes.
9293
"""
9394
# Convert the fake SEG-Y file to MDIO.
9495
# For conversion, we choose inline and crossline header values from bytes 189 and 193.
@@ -114,11 +115,15 @@ def test_rechunk_integration(segy_file, mdio_path):
114115
disk_cache=False,
115116
)
116117

117-
# Capture the original data.
118+
# Capture the original data and chunk sizes
118119
original_traces = reader._traces[
119120
:
120121
] # Main data array (3D: inline, crossline, samples).
121122
original_headers = reader._headers[:] # Header array.
123+
original_chunks = reader._traces.chunks # Original chunk sizes
124+
125+
# Verify original chunking
126+
assert original_chunks == (2, 2, 100), "Original chunk sizes do not match expected"
122127

123128
# Choose a new chunk size different from the original.
124129
# Here we change the chunking of the inline dimension.
@@ -143,7 +148,12 @@ def test_rechunk_integration(segy_file, mdio_path):
143148
# Get the rechunked data using the accessor's methods
144149
rechunked_data = rechunked_reader._traces[:]
145150
rechunked_headers = rechunked_reader._headers[:]
151+
rechunked_chunks = rechunked_reader._traces.chunks # New chunk sizes
146152

147153
# Validate that the underlying data has not changed.
148154
np.testing.assert_array_equal(original_traces, rechunked_data)
149155
np.testing.assert_array_equal(original_headers, rechunked_headers)
156+
157+
# Validate that the new chunk sizes match what we specified
158+
assert rechunked_chunks == new_chunk, "Rechunked sizes do not match expected"
159+
assert original_chunks != rechunked_chunks, "Chunk sizes should have changed"

0 commit comments

Comments
 (0)