From 1e651e955600d28e8497abbeefa42871ce7488a9 Mon Sep 17 00:00:00 2001 From: Wolfgang Kerzendorf Date: Tue, 18 Jul 2023 16:00:22 -0400 Subject: [PATCH] add deprecated decorator (#2361) * add deprecated decorator * blackify --- tardis/util/base.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tardis/util/base.py b/tardis/util/base.py index ebc5d3124a6..9862b61d70e 100644 --- a/tardis/util/base.py +++ b/tardis/util/base.py @@ -17,6 +17,8 @@ from IPython import get_ipython, display import tqdm import tqdm.notebook +import functools +import warnings k_B_cgs = constants.k_B.cgs.value c_cgs = constants.c.cgs.value @@ -761,3 +763,21 @@ def fix_bar_layout(bar, no_of_packets=None, total_iterations=None): bar.reset(total=total_iterations) else: pass + + +def deprecated(func): + """ + A decorator to add a deprecation warning to a function that is no longer used + + Parameters + ---------- + + func : function + """ + + @functools.wraps(func) + def wrapper(*args, **kwargs): + warnings.warn("This function is deprecated.", DeprecationWarning) + return func(*args, **kwargs) + + return wrapper