Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ repos:
exclude: .md5$|^external/|^tools/|Testing/Tools/cxxtest

- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v19.1.2 # updating to a new version should wait until maintenance
rev: v19.1.3 # updating to a new version should wait until maintenance
hooks:
- id: clang-format
exclude: Testing/Tools/cxxtest|tools|qt/icons/resources/
Expand Down Expand Up @@ -59,7 +59,7 @@ repos:
)$

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.0
rev: v0.7.2
# ruff must appear before black in the list of hooks
hooks:
- id: ruff
Expand Down
2 changes: 1 addition & 1 deletion Framework/PythonInterface/mantid/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# NScD Oak Ridge National Laboratory, European Spallation Source,
# Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
# SPDX - License - Identifier: GPL - 3.0 +
# ruff: noqa: F403 # Allow wild imports
# ruff: noqa: E402,F403 # Allow module import not at top and wild imports
"""
Mantid
======
Expand Down
2 changes: 1 addition & 1 deletion Framework/PythonInterface/mantid/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# NScD Oak Ridge National Laboratory, European Spallation Source,
# Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
# SPDX - License - Identifier: GPL - 3.0 +
# ruff: noqa: F403 # Allow wild imports
# ruff: noqa: E402,F403 # Allow module import not at top and wild imports
"""
api
===
Expand Down
2 changes: 1 addition & 1 deletion Framework/PythonInterface/mantid/geometry/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# NScD Oak Ridge National Laboratory, European Spallation Source,
# Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
# SPDX - License - Identifier: GPL - 3.0 +
# ruff: noqa: F403 # Allow wild imports
# ruff: noqa: E402,F403 # Allow module import not at top and wild imports
"""
mantid.geometry
===============
Expand Down
2 changes: 1 addition & 1 deletion Framework/PythonInterface/mantid/kernel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# NScD Oak Ridge National Laboratory, European Spallation Source,
# Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
# SPDX - License - Identifier: GPL - 3.0 +
# ruff: noqa: F403 # Allow wild imports
# ruff: noqa: E402,F403 # Allow module import not at top and wild imports
"""
kernel
=============
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,19 @@
set_extent.
"""

import numpy as np

import matplotlib

# Must be called before anything tries to use matplotlib
rcParams = matplotlib.rcParams

import matplotlib.image as mi
import matplotlib.colors as mcolors
import matplotlib.cbook as cbook
from matplotlib.transforms import IdentityTransform, Affine2D
import matplotlib.image as mi # noqa: E402
import matplotlib.colors as mcolors # noqa: E402
import matplotlib.cbook as cbook # noqa: E402
from matplotlib.transforms import IdentityTransform, Affine2D # noqa: E402

from mantid.plots.mantidimage import MantidImage

import numpy as np
from mantid.plots.mantidimage import MantidImage # noqa: E402

IDENTITY_TRANSFORM = IdentityTransform()

Expand Down
3 changes: 2 additions & 1 deletion conda/recipes/conda_build_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,9 @@ qtconsole:
qscintilla2:
- 2.13

# 2.4.2 fails workbench.test_mainwindow.test_mainwindow which uses isinstance()
qtpy:
- '>=1.9.0'
- '>=2.4,!=2.4.2'

tbb:
- 2021
Expand Down
3 changes: 2 additions & 1 deletion conda/recipes/mantid/run_test.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Turn off network required things that the framework does
from mantid.kernel import ConfigService

# Must be configured before importing the simpleapi
ConfigService["UpdateInstrumentDefinitions.OnStartup"] = "0"
ConfigService["usagereports.enabled"] = "0"
ConfigService["CheckMantidVersion.OnStartup"] = "0"

import mantid.simpleapi
import mantid.simpleapi # noqa: E402

assert "Rebin" in dir(mantid.simpleapi), "Rebin not found in simpleapi!"
2 changes: 1 addition & 1 deletion dev-docs/source/AlgorithmProfiler.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ It consists two to parts: special mantid build and analytical tool.
Mantid build
^^^^^^^^^^^^

On linux the profiler is built by default but to enable profiling, the :ref:`properties <mantd:Algorithm_Profiling>` must be set.
On linux the profiler is built by default but to enable profiling, the :ref:`properties <mantid:Algorithm_Profiling>` must be set.
Enabling the profiler will create a file that contains the time stamps for start and finish of executed algorithms with ~nanosecond precision in a very simple text format.

Adding more detailed information
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
line-length = 140
# https://beta.ruff.rs/docs/rules/
lint.select = ["C90", "E", "F", "RUF100", "W"]
lint.ignore = ["E402", # module level import not at top of file
"E722", # bare except
lint.ignore = ["E722", # bare except
]
exclude = [
"Framework/PythonInterface/test",
Expand Down
12 changes: 6 additions & 6 deletions qt/applications/workbench/workbench/app/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
# Find Qt plugins for development builds on some platforms
plugins.setup_library_paths()

from qtpy.QtGui import QIcon, QSurfaceFormat
from qtpy.QtWidgets import QApplication
from qtpy.QtCore import QCoreApplication, Qt
from qtpy.QtGui import QIcon, QSurfaceFormat # noqa: E402
from qtpy.QtWidgets import QApplication # noqa: E402
from qtpy.QtCore import QCoreApplication, Qt # noqa: E402

# Importing resources loads the data in. This must be imported before the
# QApplication is created or paths to Qt's resources will not be set up correctly
from workbench.app.resources import qCleanupResources
from workbench.config import APPNAME, ORG_DOMAIN, ORGANIZATION
from workbench.widgets.about.presenter import AboutPresenter
from workbench.app.resources import qCleanupResources # noqa: E402
from workbench.config import APPNAME, ORG_DOMAIN, ORGANIZATION # noqa: E402
from workbench.widgets.about.presenter import AboutPresenter # noqa: E402

# Constants
SYSCHECK_INTERVAL = 50
Expand Down
19 changes: 8 additions & 11 deletions qt/applications/workbench/workbench/plugins/jupyterconsole.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,21 @@
# NScD Oak Ridge National Laboratory, European Spallation Source,
# Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
# SPDX - License - Identifier: GPL - 3.0 +
# This file is part of the mantid workbench.
#
#
from qtpy.QtWidgets import QVBoxLayout

# local package imports
from ..config.fonts import text_font
from ..plugins.base import PluginWidget

# system imports
import warnings

# Must be called before trying to import module with a deprecation warning
warnings.filterwarnings(action="ignore", category=DeprecationWarning, module="ipykernel")
warnings.filterwarnings(action="ignore", category=DeprecationWarning, module=".*jupyter.*")

# third-party library imports
from mantidqt.widgets.jupyterconsole import InProcessJupyterConsole
from qtpy.QtWidgets import QVBoxLayout

# local package imports
from ..config.fonts import text_font
from ..plugins.base import PluginWidget
from mantidqt.widgets.jupyterconsole import InProcessJupyterConsole # noqa: E402

# from mantidqt.utils.qt import toQSettings when readSettings/writeSettings are implemented

# should we share this with plugins.editor?
STARTUP_CODE = """
Expand Down
8 changes: 5 additions & 3 deletions qt/python/mantidqt/mantidqt/utils/qt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@
from importlib import import_module
import warnings

warnings.filterwarnings(action="ignore", category=DeprecationWarning, module=".*uic.*")

# 3rd-party modules
from qtpy import QT_VERSION
from qtpy.QtCore import QPoint
from qtpy.QtGui import QKeySequence
from qtpy.QtWidgets import QAction, QMenu, QDesktopWidget
from qtpy.uic import loadUi, loadUiType

# Must be called before trying to import module with a deprecation warning
warnings.filterwarnings(action="ignore", category=DeprecationWarning, module=".*uic.*")

from qtpy.uic import loadUi, loadUiType # noqa: E402

LIB_SUFFIX = "qt" + QT_VERSION[0]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,23 @@

import matplotlib

# Must be called before anything tries to use matplotlib
matplotlib.use("Agg")
# Mock out simpleapi to import expensive import of something we don't use anyway
sys.modules["mantid.simpleapi"] = mock.MagicMock()

from mantidqt.widgets.sliceviewer.models.model import SliceViewerModel, WS_TYPE
from mantidqt.widgets.sliceviewer.presenters.presenter import (
from mantidqt.widgets.sliceviewer.models.model import SliceViewerModel, WS_TYPE # noqa: E402
from mantidqt.widgets.sliceviewer.presenters.presenter import ( # noqa: E402
DBLMAX,
PeaksViewerCollectionPresenter,
SliceViewer,
SliceViewXAxisEditor,
SliceViewYAxisEditor,
)
from mantidqt.widgets.sliceviewer.models.transform import NonOrthogonalTransform
from mantidqt.widgets.sliceviewer.views.toolbar import ToolItemText
from mantidqt.widgets.sliceviewer.views.view import SliceViewerView
from mantidqt.widgets.sliceviewer.views.dataview import SliceViewerDataView
from mantidqt.widgets.sliceviewer.models.transform import NonOrthogonalTransform # noqa: E402
from mantidqt.widgets.sliceviewer.views.toolbar import ToolItemText # noqa: E402
from mantidqt.widgets.sliceviewer.views.view import SliceViewerView # noqa: E402
from mantidqt.widgets.sliceviewer.views.dataview import SliceViewerDataView # noqa: E402


def _create_presenter(model: SliceViewerModel, view, mock_sliceinfo_cls, enable_nonortho_axes, supports_nonortho):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from mantidqt.gui_helper import set_matplotlib_backend, get_qapplication

set_matplotlib_backend() # must be called before anything tries to use matplotlib
from mantidqtinterfaces.FilterEvents import eventFilterGUI
from mantidqtinterfaces.FilterEvents import eventFilterGUI # noqa: E402

app, within_mantid = get_qapplication()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from mantidqt.gui_helper import set_matplotlib_backend, get_qapplication

set_matplotlib_backend() # must be called before anything tries to use matplotlib
from mantidqtinterfaces.HFIR_4Circle_Reduction import reduce4circleGUI
from mantidqtinterfaces.HFIR_4Circle_Reduction import reduce4circleGUI # noqa: E402

app, within_mantid = get_qapplication()
if "workbench" in sys.modules:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,15 @@
import sys
import os
import traceback

from mantidqt.gui_helper import get_qapplication
from mantidqt.utils.qt import load_ui
from mantidqtinterfaces.reduction_gui.instruments.instrument_factory import instrument_factory, INSTRUMENT_DICT
from mantidqtinterfaces.reduction_gui.settings.application_settings import GeneralSettings

from qtpy.QtWidgets import QAction, QDialog, QFileDialog, QMainWindow, QMessageBox
from qtpy.QtCore import QCoreApplication, QFile, QFileInfo, QSettings
from mantid.kernel import Logger


# Check whether Mantid is available
CAN_REDUCE = False
Expand All @@ -24,11 +29,6 @@
from mantid.kernel import ConfigService
except ImportError:
pass
try:
from mantidqt.utils.qt import load_ui
except ImportError:
Logger("ReductionGUI").information("Using legacy ui importer")
from mantidplot import load_ui

unicode = str

Expand All @@ -49,9 +49,6 @@
STARTUP_WARNING = "Please contact the Mantid team with the following message:\n\n\n"
STARTUP_WARNING += unicode(traceback.format_exc())

from mantidqtinterfaces.reduction_gui.instruments.instrument_factory import instrument_factory, INSTRUMENT_DICT
from mantidqtinterfaces.reduction_gui.settings.application_settings import GeneralSettings


class ReductionGUI(QMainWindow):
def __init__(self, parent=None, window_flags=None, instrument=None, instrument_list=None):
Expand Down
18 changes: 9 additions & 9 deletions scripts/Calibration/Examples/TubeCalibDemoWish1.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@
# Here we run the calibration of WISH panel03
# We base the ideal tube on one tube of this door.
#
from tube_spec import TubeSpec
from tube_calib import constructIdealTubeFromRealTube
from tube_calib_fit_params import TubeCalibFitParams
from mantid.simpleapi import ApplyCalibration, DeleteWorkspace, Integration, Load

import tube
from importlib import reload

reload(tube)
from tube_spec import TubeSpec
import tube_calib # from tube_calib import constructIdealTubeFromRealTube
from tube_calib_fit_params import TubeCalibFitParams
import mantid.simpleapi as mantid

filename = "WISH00017701.raw" # Calibration run ( found in \\isis\inst$\NDXWISH\Instrument\data\cycle_11_1 )
rawCalibInstWS = mantid.Load(filename) #'raw' in 'rawCalibInstWS' means unintegrated.
CalibInstWS = mantid.Integration(rawCalibInstWS, RangeLower=1, RangeUpper=20000)
mantid.DeleteWorkspace(rawCalibInstWS)
rawCalibInstWS = Load(filename) #'raw' in 'rawCalibInstWS' means unintegrated.
CalibInstWS = Integration(rawCalibInstWS, RangeLower=1, RangeUpper=20000)
DeleteWorkspace(rawCalibInstWS)
print("Created workspace (CalibInstWS) with integrated data from run and instrument to calibrate")

CalibratedComponent = "WISH/panel03/tube038"
Expand All @@ -41,7 +41,7 @@
# Use first tube as ideal tube
tube1 = TubeSpec(CalibInstWS)
tube1.setTubeSpecByString("WISH/panel03/tube038")
iTube = tube_calib.constructIdealTubeFromRealTube(CalibInstWS, tube1, fitPar, func_form)
iTube = constructIdealTubeFromRealTube(CalibInstWS, tube1, fitPar, func_form)

known_pos = iTube.getArray()
print(known_pos)
Expand All @@ -51,5 +51,5 @@
print("Got calibration (new positions of detectors)")

# Apply the calibration
mantid.ApplyCalibration(Workspace=CalibInstWS, CalibrationTable=calibrationTable)
ApplyCalibration(Workspace=CalibInstWS, CalibrationTable=calibrationTable)
print("Applied calibration")
Loading