Skip to content

Minor changes to meet ruff 0.15 standards and fix some preview issues#1185

Open
oerc0122 wants to merge 1 commit into
ISISNeutronMuon:protosfrom
oerc0122:ruff-0.15-prev
Open

Minor changes to meet ruff 0.15 standards and fix some preview issues#1185
oerc0122 wants to merge 1 commit into
ISISNeutronMuon:protosfrom
oerc0122:ruff-0.15-prev

Conversation

@oerc0122

Copy link
Copy Markdown
Collaborator

Description of work
Miscellaneous changes to meet Ruff 0.l5 specs and fix some of the issues raised by the preview=True

Fixes
N/A

To test
Tests should pass.

@oerc0122 oerc0122 self-assigned this Feb 20, 2026
@oerc0122 oerc0122 added the Technical Debt Legacy code which should be cleaned up. label Feb 20, 2026
@oerc0122
oerc0122 force-pushed the ruff-0.15-prev branch 2 times, most recently from 76832ad to 5703fe7 Compare February 20, 2026 15:31
@MBartkowiakSTFC

Copy link
Copy Markdown
Collaborator

As far as I can tell, the vector shell plots (in the q vector widget) don't work in this branch. That is, I can show the vectors preview showing the shell population, but the other tab with vector distribution within the shell throws an exception:

2026-02-23 15:13:56,413 - ERROR - process[25453] - main 36 - EXCEPTION:
<class 'numpy.core._exceptions._UFuncOutputCastingError'>
Cannot cast ufunc 'divide' output from dtype('float64') to dtype('int64') with casting rule 'same_kind'
<traceback object at 0x31c6a7080>
Traceback (most recent call last):
  File "MDANSE_GUI/InputWidgets/QVectorsWidget.py", line 257, in set_shell
    self.set_upper_limit(len(vec_dict))
  File "MDANSE_GUI/InputWidgets/QVectorsWidget.py", line 237, in set_upper_limit
    self.set_shell(current_shell, update_limit=False)
  File "MDANSE_GUI/InputWidgets/QVectorsWidget.py", line 285, in set_shell
    for dataset in vector_angular_datasets(self.qvec_config, vec_key):
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "MDANSE_GUI/Tabs/Views/PlotDataView.py", line 194, in vector_angular_datasets
    return angular_datasets_from_qarray(q_array, q_weights)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "MDANSE_GUI/Tabs/Views/PlotDataView.py", line 238, in angular_datasets_from_qarray
    counts /= np.sin(mean_angles)
numpy.core._exceptions._UFuncOutputCastingError: Cannot cast ufunc 'divide' output from dtype('float64') to dtype('int64') with casting rule 'same_kind'

@MBartkowiakSTFC

Copy link
Copy Markdown
Collaborator

I also think that the play button in the trajectory view doesn't work after the changes.

@oerc0122
oerc0122 force-pushed the ruff-0.15-prev branch 2 times, most recently from ea66129 to dfba4cd Compare May 22, 2026 08:25

@ChiCheng45 ChiCheng45 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The GUI fails to load with the following error.

2026-06-02 17:28:51,101 - ERROR - process[41404] - main 36 - EXCEPTION:
<class 'TypeError'>
PlotWidget.change_slider_coupling[bool].emit(): argument 1 has unexpected type 'method'
<traceback object at 0x00000201C9FD65C0>
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\...\AppData\Local\miniconda3\envs\MDANSE3\Scripts\mdanse_gui.exe\__main__.py", line 5, in <module>
  File "C:\Users\...\PycharmProjects\MDANSE\MDANSE_GUI\Src\MDANSE_GUI\Scripts\mdanse_gui.py", line 24, in main
    startGUI(sys.argv[1:])
  File "C:\Users\...\PycharmProjects\MDANSE\MDANSE_GUI\Src\MDANSE_GUI\main.py", line 106, in startGUI
    root = TabbedWindow(
           ^^^^^^^^^^^^^
  File "C:\Users\...\PycharmProjects\MDANSE\MDANSE_GUI\Src\MDANSE_GUI\TabbedWindow.py", line 136, in __init__
    self.makeBasicLayout()
  File "C:\Users\...\PycharmProjects\MDANSE\MDANSE_GUI\Src\MDANSE_GUI\TabbedWindow.py", line 200, in makeBasicLayout
    self.createPlotHolder()
  File "C:\Users\...\PycharmProjects\MDANSE\MDANSE_GUI\Src\MDANSE_GUI\TabbedWindow.py", line 562, in createPlotHolder
    plot_tab = PlotTab.gui_instance(
               ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\...\PycharmProjects\MDANSE\MDANSE_GUI\Src\MDANSE_GUI\Tabs\PlotTab.py", line 103, in gui_instance
    visualiser=PlotHolder(),
               ^^^^^^^^^^^^
  File "C:\Users\...\PycharmProjects\MDANSE\MDANSE_GUI\Src\MDANSE_GUI\Tabs\Visualisers\PlotHolder.py", line 49, in __init__
    self._current_id = self.new_plot("Preview")
                       ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\...\PycharmProjects\MDANSE\MDANSE_GUI\Src\MDANSE_GUI\Tabs\Visualisers\PlotHolder.py", line 70, in new_plot
    plotter = PlotWidget(self)
              ^^^^^^^^^^^^^^^^
  File "C:\Users\...\PycharmProjects\MDANSE\MDANSE_GUI\Src\MDANSE_GUI\Tabs\Visualisers\PlotWidget.py", line 220, in __init__
    self.make_canvas()
  File "C:\Users\...\PycharmProjects\MDANSE\MDANSE_GUI\Src\MDANSE_GUI\Tabs\Visualisers\PlotWidget.py", line 426, in make_canvas
    self.set_plotter(self.plot_selector.currentText())
  File "C:\Users\...\PycharmProjects\MDANSE\MDANSE_GUI\Src\MDANSE_GUI\Tabs\Visualisers\PlotWidget.py", line 250, in set_plotter
    self.change_slider_coupling.emit(self._plotter.sliders_coupled)
TypeError: PlotWidget.change_slider_coupling[bool].emit(): argument 1 has unexpected type 'method'

@oerc0122
oerc0122 force-pushed the ruff-0.15-prev branch 2 times, most recently from abe037c to 82b3994 Compare June 3, 2026 13:06
Comment on lines 18 to +27
import abc
import ctypes
import datetime
import getpass
import inspect
import os
import platform
import re
import subprocess
from abc import ABC, abstractmethod

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Any reason for the unused imports?


self._original_input = value
if value is None or value == "":
if not value:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think this causes an issue with interpolation order, as 0 is a valid input.

Image

IntegerConfigurator.__init__(self, name, **kwargs)

def configure(self, value):
def configure(self, value: str):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think this can be str or int.

Comment on lines -64 to +68
if operation == "average":
return NormOperations.AVERAGE
if operation == "sum":
return NormOperations.SUM
return NormOperations.NOT_IMPLEMENTED
return NormOperations[operation]

@ChiCheng45 ChiCheng45 Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I get the following errors when I load up MDANSE_GUI. The GUI seems to work fine, though.

Traceback (most recent call last):
  File "C:\Users\...\PycharmProjects\MDANSE\MDANSE_GUI\Src\MDANSE_GUI\Tabs\Visualisers\PlotWidget.py", line 254, in set_plotter
    self.plot_data()
  File "C:\Users\...\PycharmProjects\MDANSE\MDANSE_GUI\Src\MDANSE_GUI\Tabs\Visualisers\PlotWidget.py", line 345, in plot_data
    self._normaliser.collect_values()
  File "C:\Users\...\PycharmProjects\MDANSE\MDANSE_GUI\Src\MDANSE_GUI\Widgets\NormalisationWidget.py", line 144, in collect_values
    "operation": str_to_enum(self.combo_sum_average.currentText()),
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\...\PycharmProjects\MDANSE\MDANSE_GUI\Src\MDANSE_GUI\Tabs\Plotters\Plotter.py", line 68, in str_to_enum
    return NormOperations[operation]
           ~~~~~~~~~~~~~~^^^^^^^^^^^
  File "C:\Users\...\AppData\Local\miniconda3\envs\MDANSE3\Lib\enum.py", line 792, in __getitem__
    return cls._member_map_[name]
           ~~~~~~~~~~~~~~~~^^^^^^
KeyError: 'average'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Technical Debt Legacy code which should be cleaned up.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants