From 604b1cd3cdbf914f775e005fe2549008aa5c02bb Mon Sep 17 00:00:00 2001 From: Parfenov Sergey Date: Sun, 1 Dec 2024 15:18:07 +0500 Subject: [PATCH 1/4] Fix incompatibility with numpy 2.0 scalar representation The scalars representation has changed in numpy 2.0: https://numpy.org/doc/stable/release/2.0.0-notes.html#representation-of-numpy-scalars-changed The change breaks the workflow with .config files and affects the visual numbers representation in GUI. This is a quick fix to get an old behavior. --- scousepy/scouse.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scousepy/scouse.py b/scousepy/scouse.py index 0babd2c..f7f76ab 100644 --- a/scousepy/scouse.py +++ b/scousepy/scouse.py @@ -14,6 +14,10 @@ from astropy import log import numpy as np +try: + np.set_printoptions(legacy='1.25') +except AttributeError: + pass import os import sys import warnings From 1653c6310ec1a3b833b21092f5a2620b5ed98550 Mon Sep 17 00:00:00 2001 From: Parfenov Sergey Date: Sun, 1 Dec 2024 17:29:40 +0500 Subject: [PATCH 2/4] Fix incompatibility with the new legendHandles name in matplotlib legendHandles attribute has been renamed to legend_handles in matplotlib: https://github.com/matplotlib/matplotlib/issues/20639/ This commit adds a workaround that handles both the new and old attribute name. --- scousepy/scousefitter.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/scousepy/scousefitter.py b/scousepy/scousefitter.py index b994d66..29a9f93 100644 --- a/scousepy/scousefitter.py +++ b/scousepy/scousefitter.py @@ -803,7 +803,12 @@ def setup_legend_connections(self, legend, lookup_artist,lookup_handle): lookup_handle : matplotlib legend handles """ - for artist in legend.legendHandles: + legend_handles_array = None + try: + legend_handles_array = legend.legendHandles + except AttributeError: + legend_handles_array = legend.legend_handles + for artist in legend_handles_array: artist.set_picker(True) artist.set_pickradius(10) # 10 points tolerance @@ -820,7 +825,11 @@ def build_legend_lookups(self, legend): """ labels = [t.get_text() for t in legend.texts] - handles = legend.legendHandles + handles = None + try: + handles = legend.legendHandles + except AttributeError: + handles = legend.legend_handles label2handle = dict(zip(labels, handles)) handle2text = dict(zip(handles, legend.texts)) lookup_artist = {} From dc49b750b8c77d4f24d925ee72e4077bcef8d861 Mon Sep 17 00:00:00 2001 From: Parfenov Sergey Date: Sun, 1 Dec 2024 17:33:16 +0500 Subject: [PATCH 3/4] Fix incompatibility with the new legendHandles name in matplotlib legendHandles attribute has been renamed to legend_handles in matplotlib: https://github.com/matplotlib/matplotlib/issues/20639/ This commit adds a workaround that handles both the new and old attribute name. --- scousepy/scousefitchecker.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/scousepy/scousefitchecker.py b/scousepy/scousefitchecker.py index 2744a6d..9fc7c75 100644 --- a/scousepy/scousefitchecker.py +++ b/scousepy/scousefitchecker.py @@ -697,7 +697,12 @@ def setup_legend_connections(self, legend, lookup_artist,lookup_handle): lookup_handle : matplotlib legend handles """ - for artist in legend.legendHandles: + legend_handles_array = None + try: + legend_handles_array = legend.legendHandles + except AttributeError: + legend_handles_array = legend.legend_handles + for artist in legend_handles_array: artist.set_picker(True) artist.set_pickradius(10) # 10 points tolerance @@ -714,7 +719,11 @@ def build_legend_lookups(self, legend): """ labels = [t.get_text() for t in legend.texts] - handles = legend.legendHandles + handles = None + try: + handles = legend.legendHandles + except AttributeError: + handles = legend.legend_handles label2handle = dict(zip(labels, handles)) handle2text = dict(zip(handles, legend.texts)) lookup_artist = {} From a48da157275e2124d7b12db094293d4d76f2f1e3 Mon Sep 17 00:00:00 2001 From: Parfenov Sergey Date: Sun, 1 Dec 2024 20:28:25 +0500 Subject: [PATCH 4/4] Fix missing radiobutton attribute The circles attribute of matplotlib radiobutton widget has been removed (see e.g. https://matplotlib.org/3.8.4/api/widgets_api.html ). This commit disables a call to circles attribute if it is missing. The radiobuttons look fine without adjusting their size. --- scousepy/scousecoverage.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scousepy/scousecoverage.py b/scousepy/scousecoverage.py index 13c6c1d..b35d321 100644 --- a/scousepy/scousecoverage.py +++ b/scousepy/scousecoverage.py @@ -1481,7 +1481,10 @@ def make_radiobuttons(ax,options,function,**kwargs): """ from matplotlib.widgets import RadioButtons myradiobuttons=RadioButtons(ax,options,**kwargs) - for circle in myradiobuttons.circles: # adjust radius here. The default is 0.05 - circle.set_radius(0.05) + try: + for circle in myradiobuttons.circles: # adjust radius here. The default is 0.05 + circle.set_radius(0.05) + except AttributeError: + pass myradiobuttons.on_clicked(function) return myradiobuttons