From af7ffd41e5cbf93602baee105fda9ff7848c54ff Mon Sep 17 00:00:00 2001 From: Alison Wu Date: Sat, 23 Nov 2024 23:30:47 -0500 Subject: [PATCH 1/3] add deprecation warning to resample function --- news/resample-dep-warning.rst | 23 +++++++++++++++++++++++ src/diffpy/utils/resampler.py | 9 +++++++++ 2 files changed, 32 insertions(+) create mode 100644 news/resample-dep-warning.rst diff --git a/news/resample-dep-warning.rst b/news/resample-dep-warning.rst new file mode 100644 index 0000000..186e3c1 --- /dev/null +++ b/news/resample-dep-warning.rst @@ -0,0 +1,23 @@ +**Added:** + +* Deprecation warning for resample function in resampler + +**Changed:** + +* + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* diff --git a/src/diffpy/utils/resampler.py b/src/diffpy/utils/resampler.py index e88c4f0..4a5e1b4 100644 --- a/src/diffpy/utils/resampler.py +++ b/src/diffpy/utils/resampler.py @@ -15,6 +15,8 @@ """Various utilities related to data parsing and manipulation.""" +import warnings + import numpy @@ -97,6 +99,13 @@ def resample(r, s, dr): Returns resampled (r, s). """ + warnings.warn( + "The 'resample' function is deprecated and will be removed in a future release. \n" + "Please use 'wsinterp' instead.", + DeprecationWarning, + stacklevel=2, + ) + dr0 = r[1] - r[0] # Constant timestep if dr0 < dr: From fbf761d12a0b370421fcefd5d676d8a2f529cb42 Mon Sep 17 00:00:00 2001 From: Alison Wu Date: Fri, 6 Dec 2024 11:44:26 -0500 Subject: [PATCH 2/3] @deprecated and better message wording --- src/diffpy/utils/resampler.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/diffpy/utils/resampler.py b/src/diffpy/utils/resampler.py index 4a5e1b4..0745fa7 100644 --- a/src/diffpy/utils/resampler.py +++ b/src/diffpy/utils/resampler.py @@ -15,7 +15,7 @@ """Various utilities related to data parsing and manipulation.""" -import warnings +from warnings import deprecated import numpy @@ -79,6 +79,11 @@ def wsinterp(x, xp, fp, left=None, right=None): return fp_at_x +@deprecated( + "The 'resample' function is deprecated and will be removed in a future release 3.6.3. \n" + "'resample' has been renamed 'wsinterp' to better reflect functionality. \n" + "Please use 'wsinterp' instead." +) def resample(r, s, dr): """Resample a PDF on a new grid. @@ -99,13 +104,6 @@ def resample(r, s, dr): Returns resampled (r, s). """ - warnings.warn( - "The 'resample' function is deprecated and will be removed in a future release. \n" - "Please use 'wsinterp' instead.", - DeprecationWarning, - stacklevel=2, - ) - dr0 = r[1] - r[0] # Constant timestep if dr0 < dr: From 02a2c702460e3634f403feb5a1e1882d5df4a6eb Mon Sep 17 00:00:00 2001 From: Alison Wu Date: Fri, 6 Dec 2024 11:46:47 -0500 Subject: [PATCH 3/3] fixed version number in dep message --- src/diffpy/utils/resampler.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/diffpy/utils/resampler.py b/src/diffpy/utils/resampler.py index 0745fa7..3687f3a 100644 --- a/src/diffpy/utils/resampler.py +++ b/src/diffpy/utils/resampler.py @@ -80,9 +80,8 @@ def wsinterp(x, xp, fp, left=None, right=None): @deprecated( - "The 'resample' function is deprecated and will be removed in a future release 3.6.3. \n" - "'resample' has been renamed 'wsinterp' to better reflect functionality. \n" - "Please use 'wsinterp' instead." + "The 'resample' function is deprecated and will be removed in a future release (3.8.0). \n" + "'resample' has been renamed 'wsinterp' to better reflect functionality. Please use 'wsinterp' instead." ) def resample(r, s, dr): """Resample a PDF on a new grid.