Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated cache bahaviour of Polaris script and how attributes are updated in InstrumentSettings to fix a bug found when making subsequent calls to focus #39024

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

warunawickramasingha
Copy link
Contributor

Description of work

Updated cache behaviour of Polaris script and how attributes are updated in InstrumentSettings to fix a bug found when making subsequent calls to focus method.

Purpose of work

It has been found that, if you have already run Polaris.focus then subsequent calls to focus will use the last empty run specified (or if not specified previously then the default in the mapping file), regardless of sample_empty user supplies.

Let's assume a, b, c, d are valid kwarg parameters for focus method

  • In old behaviour:
  1. polaris.focus(a=a1, b=b1, c=c1) //kwargs a, b, c would become attributes of the InstrumentSettings object
  2. polaris.focus(b=b2, d=d1) //still attributes 'a' and 'c' passed at step 1) are attached to InstrumentSettings object and affect the behaviour
  • New bahaviour:
  1. polaris.focus(a=a1, b=b1, c=c1) //kwargs a, b, c would become attributes of the InstrumentSettings object
  2. polaris.focus(b=b2, d=d1) //attributes 'a' and 'c' passed at step 1) are deleted from InstrumentSettings object
  3. polaris.focus(a=a2, c=c2) //now attributes 'b' and 'd' are deleted from the InstrumentSettings object

Note - If any of the old kwargs found eligible to be deleted are available in the configuration file, they will rather be reinstated to their original values from the config file.

Fixes #38959.

Further detail of work

To test:

(1) Ask me for files
(2) Update paths in .yaml files
(3) Run this script

from mantid.simpleapi import *
import numpy as np
from isis_powder import polaris, SampleDetails

config_file_path = r"C:\Users\xhg73778\Documents\POLARIS\PR34144Files\polaris_config_example.yaml"
polaris = polaris.Polaris(config_file=config_file_path, user_name="test")

sample_details = SampleDetails(height=4.0, radius=0.2985, center=[0, 0, 0], shape='cylinder')
sample_details.set_material(chemical_formula='Si', packing_fraction=0.6)
sample_details.set_container(radius=0.3175, chemical_formula='V')
polaris.set_sample_details(sample=sample_details)

# focus
polaris.create_vanadium(first_cycle_run_no="98532", multiple_scattering=True, mayers_mult_scat_events=1)
polaris.focus(run_number="98533", input_mode='Summed', sample_empty="98532",
              mode="PDF", do_absorb_corrections=True, do_van_normalisation=True,
              van_normalisation_method="Absolute",
              empty_can_subtraction_method= "PaalmanPings",
              sample_empty_scale=1.0)

(4) Check the workspace history, the last call to the Minus algorithm should use a workspace derived from run 98532
(5) Call focus again without specifying sample_empty
(6) Raise the error The PaalmanPings absorption method requires 'sample_empty' to be supplied.


Reviewer

Please comment on the points listed below (full description).
Your comments will be used as part of the gatekeeper process, so please comment clearly on what you have checked during your review. If changes are made to the PR during the review process then your final comment will be the most important for gatekeepers. In this comment you should make it clear why any earlier review is still valid, or confirm that all requested changes have been addressed.

Code Review

  • Is the code of an acceptable quality?
  • Does the code conform to the coding standards?
  • Are the unit tests small and test the class in isolation?
  • If there is GUI work does it follow the GUI standards?
  • If there are changes in the release notes then do they describe the changes appropriately?
  • Do the release notes conform to the release notes guide?

Functional Tests

  • Do changes function as described? Add comments below that describe the tests performed?
  • Do the changes handle unexpected situations, e.g. bad input?
  • Has the relevant (user and developer) documentation been added/updated?

Does everything look good? Mark the review as Approve. A member of @mantidproject/gatekeepers will take care of it.

Gatekeeper

If you need to request changes to a PR then please add a comment and set the review status to "Request changes". This will stop the PR from showing up in the list for other gatekeepers.

@warunawickramasingha warunawickramasingha added Bug Issues and pull requests that are regressions or would be considered a bug by users (e.g. crashing) Diffraction Issues and pull requests related to diffraction Powder Issues and pull requests related to powder diffraction ISIS Team: Diffraction Issue and pull requests managed by the Diffraction subteam at ISIS labels Mar 6, 2025
@warunawickramasingha warunawickramasingha added this to the Release 6.13 milestone Mar 6, 2025
@sf1919
Copy link
Contributor

sf1919 commented Mar 7, 2025

Looks like a genuine test failure so I won't re-run tests on this PR at the moment.

@warunawickramasingha
Copy link
Contributor Author

Looks like a genuine test failure so I won't re-run tests on this PR at the moment.

It's strange that, the same test passes locally on Windows.

@sf1919
Copy link
Contributor

sf1919 commented Mar 7, 2025

It looks like it is failing on three operating systems for the same test so worth reviewing why.

@sf1919
Copy link
Contributor

sf1919 commented Mar 7, 2025

Looks like genuine test failures on Linux

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Issues and pull requests that are regressions or would be considered a bug by users (e.g. crashing) Diffraction Issues and pull requests related to diffraction ISIS Team: Diffraction Issue and pull requests managed by the Diffraction subteam at ISIS Powder Issues and pull requests related to powder diffraction
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Focus not respecting sample_empty if a reduction has already been run in POLARIS script
3 participants