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

account for lines sharing graphs with workspaces in mantidaxes #38486

Merged
merged 3 commits into from
Jan 9, 2025

Conversation

walshmm
Copy link
Contributor

@walshmm walshmm commented Dec 6, 2024

Description of work

Summary of work

Adds an additional kwarg value to the creation_args collected as part of plotting on a mantidaxes to track the type of plotting that had occurred. This is notable because we record different data depending on if we plotted a workspace or a line.

If an axline is plotted on the same axes as a workspace and we update the name of the workspace with ADS or some algorithm, this causes a python exception. In practice I didnt notice any misbehavior besides the stacktrace, but I was asked to fix it.

To test:

This can be recreated by running the following in workbench:

# import mantid algorithms, numpy and matplotlib
from mantid.simpleapi import *
import matplotlib.pyplot as plt
import numpy as np
from workbench.plotting.figuremanager import MantidFigureCanvas
from workbench.plotting.toolbar import WorkbenchNavigationToolbar
from qtpy.QtWidgets import (
    QApplication,
)
zelf = QApplication.instance().topLevelWidgets()[0]
figure = plt.figure(constrained_layout=True)
canvas = MantidFigureCanvas(figure)
navigationBar = WorkbenchNavigationToolbar(canvas, zelf)

ws = "test_ws"

CreateSampleWorkspace(
            OutputWorkspace=ws,
            # WorkspaceType="Histogram",
            Function="User Defined",
            UserDefinedFunction=f"name=Gaussian,Height=10,PeakCentre=1,Sigma=1",
            Xmin=0,
            Xmax=10,
            BinWidth=1,
            XUnit="TOF",
            NumBanks=4,  # must produce same number of pixels as fake instrument
            BankPixelWidth=2,  # each bank has 4 pixels, 4 banks, 16 total
            Random=False,
        )
wkspIndex = 1
ax = figure.add_subplot(1, 1, wkspIndex, projection="mantid")
ax.axvline(x=1, label="label", color="red")
RenameWorkspace(ws, "renamed_ws")

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.

@walshmm walshmm added Bug Issues and pull requests that are regressions or would be considered a bug by users (e.g. crashing) Framework Issues and pull requests related to components in the Framework labels Dec 6, 2024
@walshmm walshmm added this to the Release 6.12 milestone Dec 6, 2024
@walshmm walshmm marked this pull request as ready for review December 6, 2024 19:19
@walshmm walshmm force-pushed the mantidaxes_lines_and_renameworkspace_exception branch from 563c971 to 2e7242e Compare January 8, 2025 21:14
Copy link
Contributor

@ekapadi ekapadi left a comment

Choose a reason for hiding this comment

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

I went over all of the code changes, and everything is of acceptable quality.
I verified that the provided script does generate the error using the recent version of mantid (from mantid/label/nightly 6.11.20250107.1932) and that the changed version does not produce the error. Everything looks good, and I approve these changes!

@peterfpeterson peterfpeterson merged commit 0681ab2 into main Jan 9, 2025
10 checks passed
@peterfpeterson peterfpeterson deleted the mantidaxes_lines_and_renameworkspace_exception branch January 9, 2025 18:22
@walshmm walshmm restored the mantidaxes_lines_and_renameworkspace_exception branch January 9, 2025 19:10
@walshmm walshmm deleted the mantidaxes_lines_and_renameworkspace_exception branch January 9, 2025 19:11
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) Framework Issues and pull requests related to components in the Framework
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants