From e4039211d31a9d5b77ecbf9aa343bb0a75ed8740 Mon Sep 17 00:00:00 2001 From: StanChan03 Date: Thu, 26 Dec 2024 20:58:47 -0800 Subject: [PATCH] update --- .github/tests/lm_tests.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/tests/lm_tests.py b/.github/tests/lm_tests.py index dd26a06..da3dfab 100644 --- a/.github/tests/lm_tests.py +++ b/.github/tests/lm_tests.py @@ -525,6 +525,10 @@ def test_operator_cache(setup_models, model): pd.testing.assert_frame_equal(result_1, expected_response) pd.testing.assert_frame_equal(result_2, expected_response) + lm.reset_cache() + lm.reset_stats() + assert lm.stats.total_usage.operator_cache_hits == 0 + @pytest.mark.parametrize("model", get_enabled("gpt-4o-mini")) def test_disable_operator_cache(setup_models, model): @@ -573,9 +577,11 @@ def test_disable_operator_cache(setup_models, model): # Now enable operator cache. lotus.settings.configure(enable_operator_cache=True) - first_responses = df.sem_map(user_instruction)["_map"].str.replace(r"[^a-zA-Z\s]", "", regex=True) + first_responses = df.sem_map(user_instruction) + first_responses = first_responses[first_responses["_map"].str.replace(r"[^a-zA-Z\s]", "", regex=True)] assert lm.stats.total_usage.operator_cache_hits == 0 - second_responses = df.sem_map(user_instruction)["_map"].str.replace(r"[^a-zA-Z\s]", "", regex=True) + second_responses = df.sem_map(user_instruction) + second_responses = second_responses[second_responses["_map"].str.replace(r"[^a-zA-Z\s]", "", regex=True)] assert lm.stats.total_usage.operator_cache_hits == 1 pd.testing.assert_frame_equal(first_responses, second_responses)