Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update TNG tests and add another dont_cache check for loading #2624

Merged
merged 8 commits into from
Jun 19, 2020
2 changes: 1 addition & 1 deletion tests/tests.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
answer_tests:
local_arepo_002:
local_arepo_003:
- yt/frontends/arepo/tests/test_outputs.py

local_artio_001:
Expand Down
17 changes: 15 additions & 2 deletions yt/frontends/arepo/tests/test_outputs.py
Original file line number Diff line number Diff line change
@@ -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 \
Expand All @@ -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)
Expand Down Expand Up @@ -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):
AshKelly marked this conversation as resolved.
Show resolved Hide resolved
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)
Expand Down
6 changes: 5 additions & 1 deletion yt/geometry/particle_geometry_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import numpy as np
import os
import weakref
import struct

from yt.funcs import \
get_pbar, \
Expand Down Expand Up @@ -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):
AshKelly marked this conversation as resolved.
Show resolved Hide resolved
self.regions.reset_bitmasks()
self._initialize_coarse_index()
self._initialize_refined_index()
Expand Down