Skip to content

Commit f4abfa0

Browse files
peterfpetersonjclarkeSTFCMohamedAlmakijhaigh0ajjackson
authored
Things from main (#39015)
* Update citation file for 6.12.0 release * Fix stack overflow error due to invalid condition (#38821) Fix stackoverlow error when passing comma separated paths to ConfigService::setDataSearchDirs * Better feedback for changes in the new settings widget (#38799) * add presenter base class and notify main presenter when changes occur * change 'okay' to 'ok' * add missing tests to the cmakelist * add test for settings tab presenter base class * add tests for settings presenter changes * changes to tab presenter tests * remove change making the settings tabs presenters Qt objects * added release notes * add missing calls to unittest.main() * make the base classes ABCs * Add new authors for 6.12 (#38982) * Drop __init__ from AbinsAlgorithm It doesn't seem to do anything useful Accept CacheDirectory user input to Abins (currently does nothing) Add an input parameter "CacheDirectory" which is validated as being writeable. This gives a nice user experience, with default value appearing when the field is emptied. The actual caching mechanics still need to be connected to this parameter. Modify Abins test cleanup to take cache dir; update loader tests Other tests (which create cache in different ways) still fail, this is expected. Update more tests for explicit cache dir Fix Abins Unit tests; revised cleanup function signature We are also starting to pass the cache directory to Abins explicitly, although it is not used yet. Use explicit cache_directory variable in Abins algorithms Ensure explicit cache_directory is used across Abins and tests - Temporarily raise an error if the default cache_directory (None) is passed to abins.io.IO - This helped identify where tests were using default dirs. Now there are updated to use a (somewhat inconsistent) mixture of temporary directories and the user default directory More use of tmpdir on Abins tests - With explicit cache paths we can remove the need to patch IO class and simplify tests - Using TemporaryDirectory.cleanup() simplifies post-test clean-up Rely entirely on tempfile to cleanup Abins tests More consistent attribute names Make cache_directory argument mandatory More consistent attribute names [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Add CacheDirectory to Abins-1 doctest Abins2D will still break. I'm not really happy with this "fix" because there _should_ be a default argument. Fix Abins2D doctest (but a bit clunky) As with Abins-v1, we fix the doctest by - providing a CacheDirectory argument to the Algorithm calls - setting a corresponding cleanup path The problems with this approach are: - it's ugly and distracting - it _should_ be unnecessary, there is a default value and it works when calling from GUI - /tmp probably doesn't work on Windows Add release note Doctests: default parameter for CacheDirectory seems to work! It has been a bit of a headache getting these to work nicely, but it may have been something to do with spacing between RST lines. There seems to be a little API change at work here: the default cache director is now always the default save directory. Previously, it seems that command-line runs of Mantid would sometimes use the current directory from which Mantid was launched. That may be a headscratcher or even breaking for certain user scripts. In such workflows it would be highly recommended to set an explicit directory. Rework defaultsave / cleanup logic for Abins doctests Further Abins doctest cleanup Use magic * to share test setup/cleanup logic across tests. Move cleanup to top of file and use comments so it is easier to see what is going on. * refactor to remove repeated validation code added focus_mode parameter added test coverage for different focus modes for multi-ws reformatted the HelperClass removed the abstractmethods in HelperClass updated GEM mixin class update gem run_focus added multiple_ws tests changed param from focus_mode to input_mode added reference data check for GEM added reference data check for polaris added data files to repo fixed test filenames to work with cmake * Allow User-Configured Input Spin State Orders From The GUI & Parameter File (#38783) * Return spin states from parameter file for Wildes RE #37617 * Add fredrikze spin state line-edit to gui RE #37617 * Add getters and setters to view RE #37617 * Implement input disabling logic RE #37617 * Add spin state order to Pol Corr model RE #37617 * Update model from presenter RE #37617 * Validate Fredrikze spinstate order at alg level RE #37617 * Add documentation RE #37617 * Include new field in encoder and decoder This is needed for batch saving/loading and for project recovery. RE #37617 * Use std::optional where appropriate RE #37617 * Use a SpinStateValidator for passing to Wildes Uses a SpinStateValidator to match the validator in PolarizationCorrectionWildes. This additionally fixes a problem where not including spaces when providing spin states would result in an error. RE #37617 * Get document from main * Get updates to buildscripts from main * Update zoom polarized IDF (#38979) * update ZOOM IDF * correct allignment --------- Co-authored-by: James Clarke <james.clarke@stfc.ac.uk> Co-authored-by: Mohammed Almakki <44416400+MohamedAlmaki@users.noreply.github.com> Co-authored-by: Jonathan Haigh <35813666+jhaigh0@users.noreply.github.com> Co-authored-by: James Clarke <139879523+jclarkeSTFC@users.noreply.github.com> Co-authored-by: Adam J. Jackson <a.j.jackson@physics.org> Co-authored-by: Andy Bridger <andy.bridger@stfc.ac.uk> Co-authored-by: Caila Finn <47181718+cailafinn@users.noreply.github.com> Co-authored-by: MialLewis <95620982+MialLewis@users.noreply.github.com>
1 parent c7895d5 commit f4abfa0

File tree

95 files changed

+1583
-662
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+1583
-662
lines changed

CITATION.cff

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ authors:
66
email: mantid-help@mantidproject.org
77
website: https://www.mantidproject.org/
88
title: Manipulation and Analysis Toolkit for Instrument Data
9-
version: 6.11.0
10-
doi: 10.5286/Software/Mantid6.11
11-
date-released: 2024-10-24
9+
version: 6.12.0
10+
doi: 10.5286/Software/Mantid6.12
11+
date-released: 2025-02-26
1212
keywords:
1313
- mantid
1414
- neutron

Framework/Algorithms/src/PolarizationEfficiencyCor.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,9 @@ void PolarizationEfficiencyCor::init() {
9696
"histograms: P1, P2, F1 and F2 in the Wildes method and Pp, "
9797
"Ap, Rho and Alpha for Fredrikze.");
9898

99-
const std::string full = std::string(FlipperConfigurations::OFF_OFF) + ", " + FlipperConfigurations::OFF_ON + ", " +
100-
FlipperConfigurations::ON_OFF + ", " + FlipperConfigurations::ON_ON;
101-
const std::string missing01 = std::string(FlipperConfigurations::OFF_OFF) + ", " + FlipperConfigurations::ON_OFF +
102-
", " + FlipperConfigurations::ON_ON;
103-
const std::string missing10 = std::string(FlipperConfigurations::OFF_OFF) + ", " + FlipperConfigurations::OFF_ON +
104-
", " + FlipperConfigurations::ON_ON;
105-
const std::string missing0110 = std::string(FlipperConfigurations::OFF_OFF) + ", " + FlipperConfigurations::ON_ON;
106-
const std::string noAnalyzer = std::string(FlipperConfigurations::OFF) + ", " + FlipperConfigurations::ON;
107-
const std::string directBeam = std::string(FlipperConfigurations::OFF);
108-
const std::vector<std::string> setups{{"", full, missing01, missing10, missing0110, noAnalyzer, directBeam}};
109-
declareProperty(Prop::FLIPPERS, "", std::make_shared<Kernel::ListValidator<std::string>>(setups),
99+
const auto wildesFlipperValidator =
100+
std::make_shared<SpinStateValidator>(std::unordered_set<int>{1, 2, 3, 4}, true, '0', '1', true);
101+
declareProperty(Prop::FLIPPERS, "", wildesFlipperValidator,
110102
"Flipper configurations of the input workspaces (Wildes method only)");
111103

112104
const auto spinStateValidator =

Framework/Kernel/src/ConfigService.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,20 +85,22 @@ namespace { // anonymous namespace for some utility functions
8585
/// static Logger object
8686
Logger g_log("ConfigService");
8787

88+
const std::string PATH_DELIMITERS = ";,";
89+
8890
/**
89-
* Split the supplied string on semicolons.
91+
* Split the supplied string on semicolons and commas.
9092
*
9193
* @param path The path to split.
9294
* @returns vector containing the split path.
9395
*/
9496
std::vector<std::string> splitPath(const std::string &path) {
9597
std::vector<std::string> splitted;
9698

97-
if (path.find(';') == std::string::npos) { // don't bother tokenizing
99+
if (path.find_first_of(PATH_DELIMITERS) == std::string::npos) { // don't bother tokenizing
98100
splitted.emplace_back(path);
99101
} else {
100102
int options = Mantid::Kernel::StringTokenizer::TOK_TRIM + Mantid::Kernel::StringTokenizer::TOK_IGNORE_EMPTY;
101-
Mantid::Kernel::StringTokenizer tokenizer(path, ";,", options);
103+
Mantid::Kernel::StringTokenizer tokenizer(path, PATH_DELIMITERS, options);
102104
auto iend = tokenizer.end();
103105
for (auto itr = tokenizer.begin(); itr != iend; ++itr) {
104106
if (!itr->empty()) {
@@ -425,7 +427,7 @@ std::string ConfigServiceImpl::makeAbsolute(const std::string &dir, const std::s
425427
}
426428
std::string converted;
427429
// If we have a list, chop it up and convert each one
428-
if (dir.find_first_of(";,") != std::string::npos) {
430+
if (dir.find_first_of(PATH_DELIMITERS) != std::string::npos) {
429431
auto splitted = splitPath(dir);
430432
auto iend = splitted.cend();
431433
for (auto itr = splitted.begin(); itr != iend;) {
@@ -1695,7 +1697,7 @@ void ConfigServiceImpl::updateFacilities(const std::string &fName) {
16951697
/// Empty the list of facilities, deleting the FacilityInfo objects in the
16961698
/// process
16971699
void ConfigServiceImpl::clearFacilities() {
1698-
for (auto &facility : m_facilities) {
1700+
for (const auto &facility : m_facilities) {
16991701
delete facility;
17001702
}
17011703
m_facilities.clear();

Framework/Kernel/test/ConfigServiceTest.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,35 @@ class ConfigServiceTest : public CxxTest::TestSuite {
659659
}
660660
}
661661

662+
void testsetDataSearchDirs() {
663+
std::string dirs;
664+
std::string expected = "/test/a/;/test/b/;/test/c/";
665+
666+
// separated all by ;
667+
dirs = "/test/a/;/test/b/;/test/c/";
668+
ConfigService::Instance().setDataSearchDirs(dirs);
669+
TS_ASSERT_EQUALS(ConfigService::Instance().getString("datasearch.directories"), dirs);
670+
ConfigService::Instance().reset();
671+
672+
// separated all by ,
673+
dirs = "/test/a/,/test/b/,/test/c/";
674+
ConfigService::Instance().setDataSearchDirs(dirs);
675+
TS_ASSERT_EQUALS(ConfigService::Instance().getString("datasearch.directories"), expected);
676+
ConfigService::Instance().reset();
677+
678+
// separated all by , and ;
679+
dirs = "/test/a/,/test/b/;/test/c/";
680+
ConfigService::Instance().setDataSearchDirs(dirs);
681+
TS_ASSERT_EQUALS(ConfigService::Instance().getString("datasearch.directories"), expected);
682+
ConfigService::Instance().reset();
683+
684+
// one path
685+
dirs = "/test/a/";
686+
ConfigService::Instance().setDataSearchDirs(dirs);
687+
TS_ASSERT_EQUALS(ConfigService::Instance().getString("datasearch.directories"), dirs);
688+
ConfigService::Instance().reset();
689+
}
690+
662691
protected:
663692
bool m_valueChangedSent;
664693
std::string m_key;

Framework/Properties/Mantid.properties.template

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ plots.y_min =
258258
plots.y_max =
259259

260260
# The default width of the lines for the axes
261-
plots.axesLineWidth = 1
261+
plots.axesLineWidth = 1.0
262262

263263
# Whether to enable the grid by default
264264
plots.enableGrid = Off
@@ -300,7 +300,7 @@ plots.line.Width = 1.5
300300
plots.marker.Style = None
301301

302302
# Default maker size on 1d plots
303-
plots.marker.Size = 6
303+
plots.marker.Size = 6.0
304304

305305
# Default cap size on error bars in 1d plots
306306
plots.errorbar.Capsize = 0.0
@@ -324,7 +324,7 @@ plots.errorbar.MarkerSize = 4
324324
plots.legend.Location = best
325325

326326
# Default legend size
327-
plots.legend.FontSize = 8
327+
plots.legend.FontSize = 8.0
328328

329329
# Default colormap for image plots
330330
plots.images.Colormap = viridis

Framework/PythonInterface/plugins/algorithms/Abins.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ def PyExec(self):
108108
prog_reporter.report("Input data from the user has been collected.")
109109

110110
# 2) read ab initio data
111-
ab_initio_data = abins.AbinsData.from_calculation_data(self._vibrational_or_phonon_data_file, self._ab_initio_program)
111+
ab_initio_data = abins.AbinsData.from_calculation_data(
112+
self._vibrational_or_phonon_data_file, self._ab_initio_program, cache_directory=self._cache_directory
113+
)
112114
prog_reporter.report("Vibrational/phonon data has been read.")
113115

114116
# 3) calculate S
@@ -129,6 +131,7 @@ def PyExec(self):
129131
instrument=self._instrument,
130132
quantum_order_num=self._num_quantum_order_events,
131133
autoconvolution_max=autoconvolution_max,
134+
cache_directory=self._cache_directory,
132135
)
133136
s_calculator.progress_reporter = prog_reporter
134137
s_data = s_calculator.get_formatted_data()

Framework/PythonInterface/plugins/algorithms/Abins2D.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,11 @@ def PyExec(self):
118118
prog_reporter.report("Input data from the user has been collected.")
119119

120120
# 2) read ab initio data
121-
ab_initio_data = abins.AbinsData.from_calculation_data(self._vibrational_or_phonon_data_file, self._ab_initio_program)
121+
ab_initio_data = abins.AbinsData.from_calculation_data(
122+
self._vibrational_or_phonon_data_file,
123+
self._ab_initio_program,
124+
cache_directory=self._cache_directory,
125+
)
122126
prog_reporter.report("Vibrational/phonon data has been read.")
123127

124128
# 3) calculate S
@@ -139,6 +143,7 @@ def PyExec(self):
139143
autoconvolution_max=autoconvolution_max,
140144
instrument=self._instrument,
141145
quantum_order_num=self._num_quantum_order_events,
146+
cache_directory=self._cache_directory,
142147
)
143148
s_calculator.progress_reporter = prog_reporter
144149
s_data = s_calculator.get_formatted_data()

Framework/PythonInterface/plugins/algorithms/ReflectometryReductionOneLiveData.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ def PyInit(self):
112112
"CalibrationFile",
113113
"OutputWorkspace",
114114
"PolarizationEfficiencies",
115+
"FredrikzePolarizationSpinStateOrder",
115116
"ROIDetectorIDs",
116117
]
117118
self.copyProperties("ReflectometryISISLoadAndProcess", self._child_properties)

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,16 @@ def _declarePolarizationEfficiencyProperties(self):
278278
"the Wildes or Fredrikze correction methods.",
279279
Direction.Input,
280280
)
281+
self.declareProperty(
282+
"FredrikzePolarizationSpinStateOrder",
283+
"",
284+
"The spin state order of the workspaces in the workspace group to be passed to "
285+
'PolarizationCorrectionsFredrikze. See the "Spin State Configurations" -> '
286+
'"InputSpinStates" section of the PolarizationCorrectionsFredrikze v1 documentation for '
287+
"more details. This is only applied to Fredrikze corrections. Wildes flipper "
288+
"configurations are taken from the instrument's parameter file.",
289+
Direction.Input,
290+
)
281291

282292
def _getInputWorkspaces(self, runs, isTrans):
283293
"""Convert the given run numbers into real workspace names. Uses workspaces from
@@ -637,6 +647,7 @@ def _reduce(self, input_workspace, first_trans_workspace, second_trans_workspace
637647
efficiencies_ws = self._loadPolarizationCorrectionWorkspace()
638648
if efficiencies_ws:
639649
alg.setProperty("PolarizationEfficiencies", efficiencies_ws)
650+
alg.setProperty("FredrikzePolarizationSpinStateOrder", self.getPropertyValue("FredrikzePolarizationSpinStateOrder"))
640651
alg.execute()
641652
return alg
642653

0 commit comments

Comments
 (0)