Skip to content

Commit

Permalink
add clear cache
Browse files Browse the repository at this point in the history
  • Loading branch information
zihaoxu98 committed Mar 14, 2024
1 parent 2437f74 commit 257001a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
16 changes: 5 additions & 11 deletions tests/test_context.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import appletree as apt
from appletree.share import _cached_configs, _cached_functions
from appletree.utils import get_file_path, load_json, check_unused_configs


def test_rn220_context():
"""Test Context of Rn220 fitting."""
_cached_functions.clear()
_cached_configs.clear()
apt.clear_cache()
context = apt.ContextRn220()

context.print_context_summary(short=False)
Expand All @@ -33,8 +31,7 @@ def test_rn220_context_1d():
["equiprob", "meshgrid", "irreg"],
[bins, bins, [instruction["likelihoods"]["rn220_llh"]["clip"]]],
):
_cached_functions.clear()
_cached_configs.clear()
apt.clear_cache()
instruction["likelihoods"]["rn220_llh"]["bins_type"] = bins_type
instruction["likelihoods"]["rn220_llh"]["bins"] = bins
context = apt.Context(instruction)
Expand All @@ -43,8 +40,7 @@ def test_rn220_context_1d():

def test_rn220_ar37_context():
"""Test Context of Rn220 & Ar37 combine fitting."""
_cached_functions.clear()
_cached_configs.clear()
apt.clear_cache()
context = apt.ContextRn220Ar37()

context.print_context_summary(short=False)
Expand All @@ -59,8 +55,7 @@ def test_rn220_ar37_context():

def test_neutron_context():
"""Test Context of neutron combine fitting."""
_cached_functions.clear()
_cached_configs.clear()
apt.clear_cache()
instruct = get_file_path("neutron_low.json")
context = apt.Context(instruct)

Expand All @@ -71,8 +66,7 @@ def test_neutron_context():

def test_literature_context():
"""Test Context of neutron combine fitting."""
_cached_functions.clear()
_cached_configs.clear()
apt.clear_cache()
instruct = get_file_path("literature_lyqy.json")
context = apt.Context(instruct)

Expand Down
1 change: 1 addition & 0 deletions tests/test_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def print(self):


def test_transformer():
apt.clear_cache()
transformer = TestTransformer()
tree = transformer(apt.ContextRn220)()
tree.fitting(iteration=10, batch_size=int(1e4))

0 comments on commit 257001a

Please sign in to comment.