Skip to content

Commit 681b75e

Browse files
committed
Remove redundant mandatory properties
RE mantidproject#38523
1 parent d74e492 commit 681b75e

File tree

2 files changed

+14
-32
lines changed
  • Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS
  • Testing/SystemTests/tests/framework/ISIS/SANS/WORKFLOWS

2 files changed

+14
-32
lines changed

Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSSave.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -314,18 +314,9 @@ def _validate_pol_props(self, errors):
314314
if not polarization_props:
315315
errors.update({"PolarizationProps": "PolarizationProps must be set to use SavePolarizedNXCanSAS."})
316316
return
317-
mandatory_props = [
318-
"InputSpinStates",
319-
"PolarizerComponentName",
320-
"AnalyzerComponentName",
321-
"FlipperComponentNames",
322-
"MagneticFieldStrengthLogName",
323-
"MagneticFieldDirection",
324-
]
325-
if not all(prop in polarization_props.keys() for prop in mandatory_props):
326-
missing_props = set(mandatory_props) - set(polarization_props.keys())
317+
if "InputSpinStates" not in polarization_props.keys():
327318
errors.update(
328-
{"PolarizationProps": f"Missing property for SavePolarizedNXCanSAS. These properties are missing: {missing_props}"}
319+
{"PolarizationProps": "Missing property for SavePolarizedNXCanSAS. These properties are missing: InputSpinStates."}
329320
)
330321

331322
def _get_file_formats(self):

Testing/SystemTests/tests/framework/ISIS/SANS/WORKFLOWS/SANSSaveTest.py

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -254,28 +254,19 @@ def test_polarization_props_throws_when_any_mandatory_properties_unset(self):
254254

255255
file_name = os.path.join(mantid.config.getString("defaultsave.directory"), "sample_sans_save_file")
256256
pol_props = {
257-
"InputSpinStates": "0,1",
258-
"PolarizerComponentName": "a",
259-
"AnalyzerComponentName": "b",
260-
"FlipperComponentNames": ["c", "d", "e"],
261-
"MagneticFieldStrengthLogName": "f",
262-
"MagneticFieldDirection": "g,h,i",
257+
"InputSpinStatez": "0,1",
263258
}
264-
for i in range(0, len(pol_props)):
265-
one_removed = pol_props.copy()
266-
one_removed.pop(list(one_removed.keys())[i])
267-
with self.assertRaisesRegex(
268-
RuntimeError,
269-
f".*PolarizationProps: Missing property for SavePolarizedNXCanSAS. "
270-
f"These properties are missing: {{'{list(pol_props.keys())[i]}'}}",
271-
):
272-
# Act
273-
SANSSave(
274-
InputWorkspace=workspace,
275-
Filename=file_name,
276-
PolarizedNXCanSAS=True,
277-
PolarizationProps=one_removed,
278-
)
259+
with self.assertRaisesRegex(
260+
RuntimeError,
261+
".*PolarizationProps: Missing property for SavePolarizedNXCanSAS. These properties are missing: InputSpinStates",
262+
):
263+
# Act
264+
SANSSave(
265+
InputWorkspace=workspace,
266+
Filename=file_name,
267+
PolarizedNXCanSAS=True,
268+
PolarizationProps=pol_props,
269+
)
279270

280271
def test_polarizer_algorithm_executed(self):
281272
# Arrange

0 commit comments

Comments
 (0)