Skip to content

Fix 120: Leading and trailing whitespace removed from sample position strings - #121

Open
dehoni wants to merge 3 commits into
ISISNeutronMuon:masterfrom
dehoni:Fix_120_SANS_whitespaces_in_position
Open

Fix 120: Leading and trailing whitespace removed from sample position strings#121
dehoni wants to merge 3 commits into
ISISNeutronMuon:masterfrom
dehoni:Fix_120_SANS_whitespaces_in_position

Conversation

@dehoni

@dehoni dehoni commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

…before validation

Instrument(s)

All SANS instruments

Story/Acceptance criteria

As a user running do_sans or do_trans, I want that leading or trailing whitespace in sample position strings are ignored so that valid sample positions are still recognised and executed correctly.

Description of work

Updated sample position handling to strip leading and trailing whitespace from position strings before validation.

Issue/Ticket Reference

Fixes issues #120 #120

Tests

Describing the testing undertaken for this PR

To test

Existing behaviour for correctly formatted position strings is unchanged.
Sample position strings are corrected by removing leading and trailing whitespace before validation.
Inputs such as " 1CB" and "1CB " are treated as "1CB".
Invalid sample positions continue to be rejected after normalisation.
Position strings containing only whitespace remain invalid.

Code Review

  • Is the story/acceptance criteria fulfilled?
  • Is the code of an acceptable quality?
  • Are the tests sufficient?
  • Do the changes function as described and is it robust?
  • Are the changes able to work across all intended instruments?

Final Steps

  • Are there any changes to instrument configurations required?
  • Are there any changes to instrument scripts required, e.g. change on script signature, default argument and have these been communicated?
  • Does the script need to be deployed onto the instrument?

@dehoni
dehoni requested a review from rprospero as a code owner August 11, 2026 14:49
Comment thread technique/sans/instrument.py Outdated

def do_trans(self, title=None, pos=None, thickness=None, dae=None,

def do_trans(self, title="", pos=None, thickness=1.0, dae="transmission",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you intentionally include these changes to title= and thickness= and dae= parameters in do_sans and do_trans?

The changes are unrelated to the sample changer position-stripping logic and probably better belong in a separate change, if they are needed and wanted by all SANS instruments.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having no thickness might not play well with Mantid. The default is typically 1.0 if no other input is given. Also there were issues changing dae modes. This ensures that it always sets the default behaviour. You are right, it might be better in #122 .

They are introduced in Fix ISISNeutronMuon#122 as part of the expected default behaviour on ZOOM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants