From a94f4a84a0a5ae3cdc7e05f1ee3f69716eed0c79 Mon Sep 17 00:00:00 2001 From: Nikita Titov Date: Wed, 18 Nov 2020 17:08:08 +0300 Subject: [PATCH] Update utils.py --- tests/python_package_test/utils.py | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/tests/python_package_test/utils.py b/tests/python_package_test/utils.py index f0b160d60dfb..758f34d6e76f 100644 --- a/tests/python_package_test/utils.py +++ b/tests/python_package_test/utils.py @@ -1,23 +1,7 @@ # coding: utf-8 -import sklearn.datasets +from functools import lru_cache -try: - from functools import lru_cache -except ImportError: - import warnings - warnings.warn("Could not import functools.lru_cache", RuntimeWarning) - - def lru_cache(maxsize=None): - cache = {} - - def _lru_wrapper(user_function): - def wrapper(*args, **kwargs): - arg_key = (args, tuple(kwargs.items())) - if arg_key not in cache: - cache[arg_key] = user_function(*args, **kwargs) - return cache[arg_key] - return wrapper - return _lru_wrapper +import sklearn.datasets @lru_cache(maxsize=None)