Skip to content

Commit

Permalink
Merge pull request #2624 from matthewturk/dont_cache_onload
Browse files Browse the repository at this point in the history
Update TNG tests and add another dont_cache check for loading
  • Loading branch information
munkm authored Jun 19, 2020
2 parents 59f9432 + e78c485 commit 37052e6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
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):
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):
self.regions.reset_bitmasks()
self._initialize_coarse_index()
self._initialize_refined_index()
Expand Down

0 comments on commit 37052e6

Please sign in to comment.