Skip to content

Commit 773b4a5

Browse files
Deprecate quasielasticbayes (#41712)
Co-authored-by: James Clarke <james.clarke@stfc.ac.uk>
1 parent 027b845 commit 773b4a5

20 files changed

Lines changed: 47 additions & 18 deletions

File tree

Framework/PythonInterface/mantid/utils/deprecator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def deprecated_algorithm(new_name, deprecation_date): # decorator factory
5555
def decorator_instance(cls):
5656
depr_msg = f'Algorithm "{cls.__name__}" is deprecated since {deprecation_date}.'
5757
if new_name:
58-
depr_msg += ' Use "{new_name}" instead'
58+
depr_msg += f' Use "{new_name}" instead'
5959
raise_msg = 'Configuration "algorithms.deprecated" set to raise upon use of any deprecated algorithm'
6060

6161
cls_category = cls.category

Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/BayesQuasi.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
)
2323
from mantid.kernel import StringListValidator, Direction
2424
import mantid.simpleapi as s_api
25+
from mantid.utils.deprecator import deprecated_algorithm
2526
from mantid import config, logger
2627
from IndirectCommon import (
2728
check_analysers_or_e_fixed,
@@ -45,6 +46,7 @@ def _calculate_eisf(
4546
return eisf, eisf_error
4647

4748

49+
@deprecated_algorithm("BayesQuasi", "2026-06-22")
4850
class BayesQuasi(PythonAlgorithm):
4951
_program = None
5052
_samWS = None

Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/BayesStretch.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88
from mantid.api import PythonAlgorithm, AlgorithmFactory, MatrixWorkspaceProperty, WorkspaceGroupProperty, Progress
99
from mantid.kernel import StringListValidator, Direction
1010
import mantid.simpleapi as s_api
11+
from mantid.utils.deprecator import deprecated_algorithm
1112
from mantid import config, logger
1213
import os
1314
import numpy as np
1415

1516

17+
@deprecated_algorithm("BayesStretch2", "2026-06-22")
1618
class BayesStretch(PythonAlgorithm):
1719
_sam_name = None
1820
_sam_ws = None

Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/BayesQuasiTest.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# SPDX - License - Identifier: GPL - 3.0 +
77
import unittest
88
import numpy as np
9+
from mantid.kernel import ConfigService
910
from mantid.simpleapi import BayesQuasi, CreateWorkspace, DeleteWorkspace, Load
1011
from mantid.api import MatrixWorkspace, WorkspaceGroup
1112
from plugins.algorithms.WorkflowAlgorithms.BayesQuasi import _calculate_eisf
@@ -28,11 +29,15 @@ def setUp(self):
2829
self._resnorm_ws = Load(Filename="irs26173_graphite002_ResNorm.nxs", OutputWorkspace="irs26173_graphite002_ResNorm")
2930
self._num_bins = self._sample_ws.blocksize()
3031
self._num_hists = self._sample_ws.getNumberHistograms()
32+
config_service = ConfigService.Instance()
33+
self._original_deprecation_setting = config_service["algorithms.deprecated"]
34+
config_service["algorithms.deprecated"] = "Log"
3135

3236
def tearDown(self):
3337
"""
3438
Remove workspaces from ADS.
3539
"""
40+
ConfigService.Instance()["algorithms.deprecated"] = self._original_deprecation_setting
3641
DeleteWorkspace(self._sample_ws)
3742
DeleteWorkspace(self._res_ws)
3843
DeleteWorkspace(self._resnorm_ws)

Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/BayesStretchTest.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# SPDX - License - Identifier: GPL - 3.0 +
77
import unittest
88
from mantid.api import WorkspaceGroup
9+
from mantid.kernel import ConfigService
910
from mantid.simpleapi import BayesStretch, DeleteWorkspace, Load
1011

1112

@@ -20,13 +21,17 @@ def setUp(self):
2021
self._res_ws = Load(Filename="irs26173_graphite002_res.nxs", OutputWorkspace="__BayesStretchTest_Resolution")
2122
self._sample_ws = Load(Filename="irs26176_graphite002_red.nxs", OutputWorkspace="__BayesStretchTest_Sample")
2223
self._num_hists = self._sample_ws.getNumberHistograms()
24+
config = ConfigService.Instance()
25+
self._original_deprectation_setting = config["algorithms.deprecated"]
26+
config["algorithms.deprecated"] = "Log"
2327

2428
def tearDown(self):
2529
"""
2630
Remove workspaces from ADS.
2731
"""
2832
DeleteWorkspace(self._sample_ws)
2933
DeleteWorkspace(self._res_ws)
34+
ConfigService.Instance()["algorithms.deprecated"] = self._original_deprectation_setting
3035

3136
# ----------------------------------Algorithm tests----------------------------------------
3237

Testing/SystemTests/tests/framework/BayesQuasiTest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def skipTests(self):
2626
return platform == "darwin"
2727

2828
def runTest(self):
29+
config["algorithms.deprecated"] = "Log"
2930
workdir = tempfile.mkdtemp(prefix="bayes_")
3031
config["defaultsave.directory"] = workdir
3132
Load(Filename=f"{self._sample_name}.nxs", OutputWorkspace=self._sample_name, LoadHistory=False)

Testing/SystemTests/tests/framework/ISISIndirectBayesTest.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class QLresTest(systemtesting.MantidSystemTest):
3636
def runTest(self):
3737
workdir = tempfile.mkdtemp(prefix="bayes_")
3838
config["defaultsave.directory"] = workdir
39+
config["algorithms.deprecated"] = "Log"
3940
prefix = "rt_"
4041
sname = "irs26176_graphite002_red"
4142
rname = "irs26173_graphite002_res"
@@ -86,6 +87,7 @@ class QuestTest(systemtesting.MantidSystemTest):
8687
def runTest(self):
8788
workdir = tempfile.mkdtemp(prefix="bayes_")
8889
config["defaultsave.directory"] = workdir
90+
config["algorithms.deprecated"] = "Log"
8991
sname = "irs26176_graphite002_red"
9092
rname = "irs26173_graphite002_res"
9193

@@ -125,6 +127,7 @@ class QSeTest(systemtesting.MantidSystemTest):
125127
def runTest(self):
126128
workdir = tempfile.mkdtemp(prefix="bayes_")
127129
config["defaultsave.directory"] = workdir
130+
config["algorithms.deprecated"] = "Log"
128131
sname = "irs26176_graphite002_red"
129132
rname = "irs26173_graphite002_res"
130133
e_min = -0.5
@@ -169,6 +172,7 @@ class QLDataTest(systemtesting.MantidSystemTest):
169172
def runTest(self):
170173
workdir = tempfile.mkdtemp(prefix="bayes_")
171174
config["defaultsave.directory"] = workdir
175+
config["algorithms.deprecated"] = "Log"
172176
sname = "irs26176_graphite002_red"
173177
rname = "irs26173_graphite002_red"
174178
e_min = -0.5
@@ -219,6 +223,7 @@ class QLResNormTest(systemtesting.MantidSystemTest):
219223
def runTest(self):
220224
workdir = tempfile.mkdtemp(prefix="bayes_")
221225
config["defaultsave.directory"] = workdir
226+
config["algorithms.deprecated"] = "Log"
222227
sname = "irs26176_graphite002_red"
223228
rname = "irs26173_graphite002_res"
224229
rsname = "irs26173_graphite002_ResNorm"
@@ -273,6 +278,7 @@ class QLWidthTest(systemtesting.MantidSystemTest):
273278
def runTest(self):
274279
workdir = tempfile.mkdtemp(prefix="bayes_")
275280
config["defaultsave.directory"] = workdir
281+
config["algorithms.deprecated"] = "Log"
276282
prefix = "wt_"
277283
sname = "irs26176_graphite002_red"
278284
rname = "irs26173_graphite002_res"

docs/source/algorithms/BayesQuasi-v1.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
Description
1111
-----------
1212

13+
This algorithm has been deprecated in favour of :ref:`algm-BayesQuasi2`
14+
1315
The model that is being fitted is that of a \delta-function (elastic component) of amplitude A(0)
1416
and Lorentzians of amplitude A(j) and HWHM W(j) where j=1,2,3. The whole function is then convolved
1517
with the resolution function. The -function and Lorentzians are intrinsically normalised to unity
@@ -33,7 +35,7 @@ Usage
3335

3436
**Example - BayesQuasi**
3537

36-
.. testcode:: BayesQuasiExample
38+
.. code-block:: python
3739
3840
# Load in test data
3941
sampleWs = Load('irs26176_graphite002_red.nxs')

docs/source/algorithms/BayesStretch-v1.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
Description
1010
-----------
1111

12+
This algorithm has been deprecated in favour of :ref:`algm-BayesStretch2`
13+
1214
This is a variation of the stretched exponential option of
1315
:ref:`Quasi <algm-BayesQuasi>`. For each spectrum a fit is performed
1416
for a grid of :math:`\beta` and :math:`\sigma` values. The distribution of goodness of fit values
@@ -22,7 +24,7 @@ Usage
2224

2325
**Example - BayesStretch**
2426

25-
.. testcode:: BayesStretchExample
27+
.. code-block:: python
2628
2729
# Load in test data
2830
sample_ws = Load('irs26176_graphite002_red.nxs')

docs/source/release/v6.16.0/direct_geometry.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ New features
99
############
1010
- (`#41309 <https://github.com/mantidproject/mantid/pull/41309>`_) In :ref:`DGS Planner <dgsplanner-ref>`, the minimal value for the Incident Energy has been lowered from 1.0 to 0.1 meV.
1111
- (`#41305 <https://github.com/mantidproject/mantid/pull/41305>`_) CNCS has a new parameter file to update the calculation of T0 offset.
12+
- (`#41432 <https://github.com/mantidproject/mantid/pull/41432>`_) :ref:`LoadPLNnxs <algm-LoadPLNnxs>` now supports loading ANSTO PELICAN data collected with the AESS framework.
1213

1314
MSlice
1415
------

0 commit comments

Comments
 (0)