summaryrefslogtreecommitdiff
path: root/gnu/packages
diff options
context:
space:
mode:
authorDanny Milosavljevic <dannym@friendly-machines.com>2026-02-13 11:37:09 +0000
committerDanny Milosavljevic <dannym@friendly-machines.com>2026-02-21 21:52:40 +0100
commit202d682caffaf19abe62913a133a18ec15bbd589 (patch)
tree68c6b467ef95e8ecf08b08f283e1a398072ae40a /gnu/packages
parenteb3d2b85f97599c18d5133dd6c151003b78804dd (diff)
gnu: Add python-mslice.
* gnu/packages/patches/python-mslice-matplotlib-3.6-compatibility.patch: New file. * gnu/local.mk (dist_patch_DATA): Add reference to it. * gnu/packages/physics.scm (python-mslice): New variable. Change-Id: I55b884b53bef3f59d466e8980a643e4ef78fa544
Diffstat (limited to 'gnu/packages')
-rw-r--r--gnu/packages/patches/python-mslice-matplotlib-3.6-compatibility.patch46
-rw-r--r--gnu/packages/physics.scm43
2 files changed, 89 insertions, 0 deletions
diff --git a/gnu/packages/patches/python-mslice-matplotlib-3.6-compatibility.patch b/gnu/packages/patches/python-mslice-matplotlib-3.6-compatibility.patch
new file mode 100644
index 00000000000..8bbb81224da
--- /dev/null
+++ b/gnu/packages/patches/python-mslice-matplotlib-3.6-compatibility.patch
@@ -0,0 +1,46 @@
+From: Danny Milosavljevic <dannym@friendly-machines.com>
+Date: 2026-02-13
+Subject: Fix compatibility with matplotlib 3.6+
+
+Matplotlib 3.6 removed the `message` Qt signal from NavigationToolbar2QT.
+The old API was:
+
+ message = QtCore.Signal(str)
+
+ def set_message(self, s):
+ self.message.emit(s)
+ self.locLabel.setText(s)
+
+The new API just updates the label directly with no signal:
+
+ def set_message(self, s):
+ self.locLabel.setText(s)
+
+Matplotlib provides no replacement signal. The only way to intercept
+toolbar messages is to override the set_message method.
+
+This patch replaces the signal connection with a method override that
+forwards messages to the status bar.
+
+--- a/src/mslice/plotting/plot_window/plot_window.py
++++ b/src/mslice/plotting/plot_window/plot_window.py
+@@ -274,7 +274,18 @@ class PlotWindow(QtWidgets.QMainWindow):
+
+ def create_status_bar(self):
+ self.statusbar = QtWidgets.QStatusBar(self)
+- self.stock_toolbar.message.connect(self.statusbar.showMessage)
++ # Matplotlib 3.6 removed the `message` Qt signal from
++ # NavigationToolbar2QT. The old code was:
++ #
++ # self.stock_toolbar.message.connect(self.statusbar.showMessage)
++ #
++ # Since matplotlib provides no replacement signal, we override
++ # set_message to forward messages to the status bar.
++ original_set_message = self.stock_toolbar.set_message
++ def set_message_forwarding_to_statusbar(s):
++ original_set_message(s)
++ self.statusbar.showMessage(s)
++ self.stock_toolbar.set_message = set_message_forwarding_to_statusbar
+ self.setStatusBar(self.statusbar)
+
+ def flag_as_kept(self):
diff --git a/gnu/packages/physics.scm b/gnu/packages/physics.scm
index 06acf991d08..828e0f9a9f5 100644
--- a/gnu/packages/physics.scm
+++ b/gnu/packages/physics.scm
@@ -168,6 +168,49 @@ scattering simulations.")
(description "GOFit: Global Optimization for Fitting problems.")
(license license:bsd-3)))
+(define-public python-mslice
+ (package
+ (name "python-mslice")
+ (version "2.14")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/mantidproject/mslice.git")
+ (commit version)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "1bbg9hyl6jxyk79hshvqvcbwbx48x6va5nyhavj5kjg6ybd0n8fd"))
+ (patches
+ (search-patches "python-mslice-matplotlib-3.6-compatibility.patch"))))
+ (build-system pyproject-build-system)
+ (arguments
+ (list #:tests? #f ;require mantid
+ #:phases
+ #~(modify-phases %standard-phases
+ (add-after 'unpack 'fix-compatibility
+ (lambda _
+ ;; dedent_interpd was an alias for interpd; the alias was
+ ;; removed in
+ ;; <https://github.com/matplotlib/matplotlib/pull/28826>.
+ (substitute* "src/mslice/plotting/pyplot.py"
+ (("@_docstring\\.dedent_interpd")
+ "@_docstring.interpd"))
+ ;; self.execute("cls") fails; use widget's clear() method.
+ ;; <https://github.com/mantidproject/mslice/issues/1152>
+ (substitute* "src/mslice/widgets/ipythonconsole/ipython_widget.py"
+ (("self\\.execute\\(\"cls\"\\)")
+ "self.clear()"))))
+ (delete 'sanity-check)))) ;would require mantid
+ (propagated-inputs (list python-matplotlib python-pyqt python-qtpy
+ python-qtawesome))
+ (native-inputs (list python-pytest python-setuptools))
+ (home-page "https://github.com/mantidproject/mslice")
+ (synopsis "Performs slices and cuts of multi-dimensional data produced by Mantid")
+ (description "This package provides a tool for performing slices and cuts
+of multi-dimensional data produced by Mantid.")
+ (license license:gpl3+)))
+
(define-public python-pycifrw
(package
(name "python-pycifrw")