Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
neutrinoceros committed Oct 10, 2023
1 parent 9aa2a21 commit de1a04e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 19 deletions.
2 changes: 1 addition & 1 deletion yt_astro_analysis/halo_analysis/tests/test_halo_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

from yt.loaders import load
from yt.testing import requires_file
from yt.utilities.answer_testing.framework import data_dir_load_v2 as data_dir_load
from yt_astro_analysis.halo_analysis import HaloCatalog, add_quantity
from yt_astro_analysis.utilities.testing import data_dir_load


def setup():
Expand Down
13 changes: 1 addition & 12 deletions yt_astro_analysis/halo_analysis/tests/test_halo_finders.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,6 @@
from yt.loaders import load
from yt.testing import requires_file


def create_obj(ds, obj_type):
# obj_type should be tuple of
# ( obj_name, ( args ) )
if obj_type is None:
return ds.all_data()
cls = getattr(ds, obj_type[0])
obj = cls(*obj_type[1])
return obj


_fields = (
("halos", "particle_position_x"),
("halos", "particle_position_y"),
Expand Down Expand Up @@ -63,7 +52,7 @@ def test_halo_finders_single(tmp_path):
assert isinstance(ds, ds_type)

for field in _fields:
obj = create_obj(ds, None)
obj = ds.all_data()
field = obj._determine_fields(field)[0]
# fd = ds.field_info[field]
weight_field = (field[0], "particle_ones")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import numpy.testing as npt

from yt.testing import requires_file
from yt.utilities.answer_testing.framework import data_dir_load_v2 as data_dir_load
from yt_astro_analysis.radmc3d_export.api import RadMC3DWriter
from yt_astro_analysis.utilities.testing import data_dir_load

etiny = "enzo_tiny_cosmology/DD0046/DD0046"

Expand Down
18 changes: 13 additions & 5 deletions yt_astro_analysis/utilities/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,20 @@
# The full license is in the file COPYING.txt, distributed with this software.
# -----------------------------------------------------------------------------

# TODO: deprecate or remove this module (not used anymore)

import os

import yt
from yt.config import ytcfg
from yt.data_objects.time_series import SimulationTimeSeries
from yt.loaders import load_simulation
from yt.utilities.answer_testing.framework import AnswerTestingTest


def data_dir_load(fn, *args, **kwargs):
# wrap yt.load but only load from test_data_dir
path = os.path.join(ytcfg.get("yt", "test_data_dir"), fn)
return yt.load(path, *args, **kwargs)


def requires_sim(sim_fn, sim_type, file_check=False):
# TODO: deprecate this
from functools import wraps

from nose import SkipTest
Expand All @@ -45,6 +48,11 @@ def ftrue(func):


def can_run_sim(sim_fn, sim_type, file_check=False):
# TODO: deprecate this
from yt.data_objects.time_series import SimulationTimeSeries
from yt.loaders import load_simulation
from yt.utilities.answer_testing.framework import AnswerTestingTest

result_storage = AnswerTestingTest.result_storage
if isinstance(sim_fn, SimulationTimeSeries):
return result_storage is not None
Expand Down

0 comments on commit de1a04e

Please sign in to comment.