Skip to content

Commit c7b7241

Browse files
committed
Merge branch 'disaster_recovery_multiVersionSupport' into DR_with_modifications
2 parents 5aa4460 + 9b42fbc commit c7b7241

File tree

5 files changed

+31
-25
lines changed

5 files changed

+31
-25
lines changed

.github/workflows/constraints.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
bump-my-version==1.2.1
1+
bump-my-version==1.2.3
22
nox==2025.5.1

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "multidimio"
3-
version = "1.0.2"
3+
version = "1.0.3"
44
description = "Cloud-native, scalable, and user-friendly multi dimensional energy data!"
55
authors = [{ name = "Altay Sansal", email = "[email protected]" }]
66
requires-python = ">=3.11,<3.14"
@@ -31,7 +31,7 @@ dependencies = [
3131
"tqdm>=4.67.1",
3232
"universal-pathlib>=0.2.6",
3333
"xarray>=2025.9.0",
34-
"zarr>=3.1.2",
34+
"zarr>=3.1.3",
3535
]
3636

3737
[project.optional-dependencies]
@@ -182,7 +182,7 @@ init_typed = true
182182
warn_required_dynamic_aliases = true
183183

184184
[tool.bumpversion]
185-
current_version = "1.0.2"
185+
current_version = "1.0.3"
186186
allow_dirty = true
187187
commit = false
188188
tag = false

src/mdio/segy/_workers.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,16 @@ def trace_worker( # noqa: PLR0913
148148
ds_to_write = dataset[worker_variables]
149149

150150
if header_key in worker_variables:
151-
# Create temporary array for headers with the correct shape
151+
# TODO(BrianMichell): Implement this better so that we can enable fill values without changing the code
152+
# https://github.com/TGSAI/mdio-python/issues/584
152153
tmp_headers = np.zeros_like(dataset[header_key])
153154
# tmp_headers[not_null] = traces.header
154155
tmp_headers[not_null] = header_pipeline.apply(traces.header.copy())
155156
# Create a new Variable object to avoid copying the temporary array
156157
# The ideal solution is to use `ds_to_write[header_key][:] = tmp_headers`
157158
# but Xarray appears to be copying memory instead of doing direct assignment.
158159
# TODO(BrianMichell): #614 Look into this further.
160+
# https://github.com/TGSAI/mdio-python/issues/584
159161
ds_to_write[header_key] = Variable(
160162
ds_to_write[header_key].dims,
161163
tmp_headers,
@@ -179,8 +181,9 @@ def trace_worker( # noqa: PLR0913
179181
fill_value = _get_fill_value(ScalarType(data_variable.dtype.name))
180182
tmp_samples = np.full_like(data_variable, fill_value=fill_value)
181183
tmp_samples[not_null] = traces.sample
182-
# Create a new Variable object to avoid copying the temporary array
184+
183185
# TODO(BrianMichell): #614 Look into this further.
186+
# https://github.com/TGSAI/mdio-python/issues/584
184187
ds_to_write[data_variable_name] = Variable(
185188
ds_to_write[data_variable_name].dims,
186189
tmp_samples,
@@ -190,12 +193,13 @@ def trace_worker( # noqa: PLR0913
190193

191194
to_mdio(ds_to_write, output_path=output_path, region=region, mode="r+")
192195

196+
nonzero_samples = np.ma.masked_values(traces.sample, 0, copy=False)
193197
histogram = CenteredBinHistogram(bin_centers=[], counts=[])
194198
return SummaryStatistics(
195-
count=traces.sample.size,
196-
min=traces.sample.min(),
197-
max=traces.sample.max(),
198-
sum=traces.sample.sum(),
199-
sum_squares=(traces.sample**2).sum(),
199+
count=nonzero_samples.count(),
200+
min=nonzero_samples.min(),
201+
max=nonzero_samples.max(),
202+
sum=nonzero_samples.sum(dtype="float64"),
203+
sum_squares=(np.ma.power(nonzero_samples, 2).sum(dtype="float64")),
200204
histogram=histogram,
201205
)

tests/integration/test_segy_roundtrip_teapot.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -181,15 +181,18 @@ def test_variable_metadata(self, zarr_tmp: Path) -> None:
181181
"""Metadata reading tests."""
182182
ds = open_mdio(zarr_tmp)
183183
expected_attrs = {
184-
"count": 97354860,
185-
"sum": -8594.551666259766,
186-
"sumSquares": 40571291.6875,
184+
"count": 46854270,
185+
"sum": -8594.551589292674,
186+
"sumSquares": 40571285.42351971,
187187
"min": -8.375323295593262,
188188
"max": 7.723702430725098,
189189
"histogram": {"counts": [], "binCenters": []},
190190
}
191-
actual_attrs_json = json.loads(ds["amplitude"].attrs["statsV1"])
192-
assert actual_attrs_json == expected_attrs
191+
actual_attrs = json.loads(ds["amplitude"].attrs["statsV1"])
192+
assert actual_attrs.keys() == expected_attrs.keys()
193+
actual_attrs.pop("histogram")
194+
expected_attrs.pop("histogram")
195+
np.testing.assert_allclose(list(actual_attrs.values()), list(expected_attrs.values()))
193196

194197
def test_grid(self, zarr_tmp: Path, teapot_segy_spec: SegySpec) -> None:
195198
"""Test validating MDIO variables."""
@@ -237,23 +240,22 @@ def test_inline_reads(self, zarr_tmp: Path) -> None:
237240
"""Read and compare every 75 inlines' mean and std. dev."""
238241
ds = open_mdio(zarr_tmp)
239242
inlines = ds["amplitude"][::75, :, :]
240-
mean, std = inlines.mean(), inlines.std()
241-
npt.assert_allclose([mean, std], [1.0555277e-04, 6.0027051e-01])
243+
mean, std = inlines.mean(dtype="float64"), inlines.std(dtype="float64")
244+
npt.assert_allclose([mean, std], [0.00010555267, 0.60027058412]) # 11 precision
242245

243246
def test_crossline_reads(self, zarr_tmp: Path) -> None:
244247
"""Read and compare every 75 crosslines' mean and std. dev."""
245248
ds = open_mdio(zarr_tmp)
246249
xlines = ds["amplitude"][:, ::75, :]
247-
mean, std = xlines.mean(), xlines.std()
248-
249-
npt.assert_allclose([mean, std], [-5.0329847e-05, 5.9406823e-01])
250+
mean, std = xlines.mean(dtype="float64"), xlines.std(dtype="float64")
251+
npt.assert_allclose([mean, std], [-5.03298501828e-05, 0.59406807762]) # 11 precision
250252

251253
def test_zslice_reads(self, zarr_tmp: Path) -> None:
252254
"""Read and compare every 225 z-slices' mean and std. dev."""
253255
ds = open_mdio(zarr_tmp)
254256
slices = ds["amplitude"][:, :, ::225]
255-
mean, std = slices.mean(), slices.std()
256-
npt.assert_allclose([mean, std], [0.005236923, 0.61279935])
257+
mean, std = slices.mean(dtype="float64"), slices.std(dtype="float64")
258+
npt.assert_allclose([mean, std], [0.00523692339, 0.61279943571]) # 11 precision
257259

258260
@pytest.mark.dependency("test_3d_import")
259261
def test_3d_export(

uv.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)