diff --git a/tests/tests.yaml b/tests/tests.yaml index a05fd93632a..b344558cc93 100644 --- a/tests/tests.yaml +++ b/tests/tests.yaml @@ -1,5 +1,5 @@ answer_tests: - local_arepo_002: + local_arepo_003: - yt/frontends/arepo/tests/test_outputs.py local_artio_001: diff --git a/yt/frontends/arepo/tests/test_outputs.py b/yt/frontends/arepo/tests/test_outputs.py index f77d75a2552..7246c76b1cf 100644 --- a/yt/frontends/arepo/tests/test_outputs.py +++ b/yt/frontends/arepo/tests/test_outputs.py @@ -1,3 +1,5 @@ +import os +import tempfile from collections import OrderedDict from yt.testing import requires_file, ParticleSelectionComparison from yt.utilities.answer_testing.framework import \ @@ -8,6 +10,7 @@ bullet_h5 = "ArepoBullet/snapshot_150.hdf5" tng59_h5 = "TNGHalo/halo_59.hdf5" +_tng59_bbox = [[45135.0, 51343.0], [51844.0, 56184.0], [60555.0, 63451.0]] @requires_file(bullet_h5) @@ -61,15 +64,25 @@ def test_tng_hdf5(): ] ) - @requires_ds(tng59_h5) def test_arepo_tng59(): - ds = data_dir_load(tng59_h5) + ds = data_dir_load(tng59_h5, kwargs = {'bounding_box': _tng59_bbox}) for test in sph_answer(ds, 'halo_59', 10107142, tng59_fields): test_arepo_tng59.__name__ = test.description yield test +@requires_ds(tng59_h5) +def test_index_override(): + # This tests that we can supply an index_filename, and that when we do, it + # doesn't get written if our bounding_box is overwritten. + tmpfd, tmpname = tempfile.mkstemp(suffix=".ewah") + os.close(tmpfd) + ds = data_dir_load(tng59_h5, kwargs = {'index_filename': tmpname, + 'bounding_box': _tng59_bbox}) + ds.index + assert len(open(tmpname, "r").read()) == 0 + @requires_file(tng59_h5) def test_arepo_tng59_selection(): ds = data_dir_load(tng59_h5) diff --git a/yt/geometry/particle_geometry_handler.py b/yt/geometry/particle_geometry_handler.py index e91cb9e8d8a..03ac22e961c 100644 --- a/yt/geometry/particle_geometry_handler.py +++ b/yt/geometry/particle_geometry_handler.py @@ -3,6 +3,7 @@ import numpy as np import os import weakref +import struct from yt.funcs import \ get_pbar, \ @@ -128,13 +129,16 @@ def _initialize_index(self): else: fname = ds.index_filename + dont_load = dont_cache and not hasattr(ds, 'index_filename') try: + if dont_load: + raise OSError rflag = self.regions.load_bitmasks(fname) rflag = self.regions.check_bitmasks() self._initialize_frontend_specific() if rflag == 0: raise OSError - except OSError: + except (OSError, struct.error): self.regions.reset_bitmasks() self._initialize_coarse_index() self._initialize_refined_index()