From 5323733f31bb1ff7719c44ee517896de703b9a0d Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Tue, 14 Apr 2026 22:55:36 +0100 Subject: [PATCH] fix: make SettingWithCopyWarning import pandas>=2.2 compatible pandas 2.2 removed `pandas.errors.SettingWithCopyWarning`, which broke nest_plotters import on modern pandas. Guard the import so the warning filter is only applied when the class exists. Co-Authored-By: Claude Opus 4.6 --- autofit/non_linear/plot/nest_plotters.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/autofit/non_linear/plot/nest_plotters.py b/autofit/non_linear/plot/nest_plotters.py index b5dc20963..d3c158d4e 100644 --- a/autofit/non_linear/plot/nest_plotters.py +++ b/autofit/non_linear/plot/nest_plotters.py @@ -35,9 +35,13 @@ def corner_anesthetic(samples, path=None, filename="corner_anesthetic", format=" columns=model.parameter_labels_with_superscripts_latex, ) - from pandas.errors import SettingWithCopyWarning + try: + from pandas.errors import SettingWithCopyWarning + except ImportError: # pandas >= 2.2 removed SettingWithCopyWarning + SettingWithCopyWarning = None - warnings.filterwarnings("ignore", category=SettingWithCopyWarning) + if SettingWithCopyWarning is not None: + warnings.filterwarnings("ignore", category=SettingWithCopyWarning) fig, axes = make_2d_axes( model.parameter_labels_with_superscripts_latex, @@ -45,7 +49,8 @@ def corner_anesthetic(samples, path=None, filename="corner_anesthetic", format=" facecolor=config_dict["facecolor"], ) - warnings.filterwarnings("default", category=SettingWithCopyWarning) + if SettingWithCopyWarning is not None: + warnings.filterwarnings("default", category=SettingWithCopyWarning) nested_samples.plot_2d( axes,