From 92f9f89a86aa6111719b11782a05e311794da8f3 Mon Sep 17 00:00:00 2001 From: Dominic Power Date: Mon, 25 Aug 2025 16:58:39 -0400 Subject: [PATCH 1/2] Fixed incompatibility with freeqdsk>=0.5 --- INGRID/utils.py | 2 ++ tests/component/test_efit.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/INGRID/utils.py b/INGRID/utils.py index 69958dd..00b5c99 100644 --- a/INGRID/utils.py +++ b/INGRID/utils.py @@ -464,6 +464,8 @@ def LoadGEQDSK(self, geqdsk_path: str) -> None: with open(geqdsk_path, 'r') as f: geqdsk_data = geqdsk.read(f) + if not isinstance(geqdsk_data,dict): + geqdsk_data = geqdsk_data.__dict__ # # Extract quantities needed to initialize EfitData class diff --git a/tests/component/test_efit.py b/tests/component/test_efit.py index e417586..fe934f5 100644 --- a/tests/component/test_efit.py +++ b/tests/component/test_efit.py @@ -21,6 +21,8 @@ def test_load_geqdsk(data_dir): # with open(eqdsk_path, 'r') as f: baseline = geqdsk.read(f) + if not isinstance(baseline,dict): + baseline = baseline.__dict__ # # Load data using Ingrid class From eb17a8d6381c5c34f1369a63b716be887445b869 Mon Sep 17 00:00:00 2001 From: Dominic Power Date: Mon, 25 Aug 2025 21:39:35 -0400 Subject: [PATCH 2/2] Fixed problems running on python3.10 due to matplotlib updates --- INGRID/ingrid.py | 4 +++- INGRID/interpol.py | 8 ++++---- setup.py | 4 ++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/INGRID/ingrid.py b/INGRID/ingrid.py index 034655e..f3b41d8 100644 --- a/INGRID/ingrid.py +++ b/INGRID/ingrid.py @@ -836,12 +836,14 @@ def PlotPsiNormBounds(self) -> None: Dic = {'psi_1': 'lime', 'psi_core': 'cyan', 'psi_pf_1': 'white'} + num_psi_levels = 4 elif nxpt == 2: Dic = {'psi_core': 'cyan', 'psi_1': 'lime', 'psi_2': 'fuchsia', 'psi_pf_1': 'white', 'psi_pf_2': 'yellow'} + num_psi_levels = 7 for k, c in Dic.items(): self.PsiNorm.PlotLevel(self.settings['grid_settings'][k], color=Dic[k], label=k) @@ -859,7 +861,7 @@ def PlotPsiNormBounds(self) -> None: pass self.PsiNorm.fig.legend(handles=[handle for handle in lookup.values()], labels=[label for label in lookup.keys()], bbox_to_anchor=(0.5, 1), loc='upper center', - ncol=len([label for label in lookup.keys()]) // 3) + ncol=min((len([label for label in lookup.keys()]) + num_psi_levels) // 3, 5), facecolor="gray", framealpha=0.2) def PlotPsiNormMagReference(self, ax: object = None) -> None: """ diff --git a/INGRID/interpol.py b/INGRID/interpol.py index 6b324bd..3943dd1 100644 --- a/INGRID/interpol.py +++ b/INGRID/interpol.py @@ -233,11 +233,11 @@ def PlotLevel(self: object, level: float = 1.0, color: str = 'red', label: str = indexing='ij') try: self.psi_levels[label].collections[0].remove() - self.psi_levels[label] = plt.contour(rgrid, zgrid, data, [float(level)], colors=color, label=label, linestyles=linestyles) - self.psi_levels[label].collections[0].set_label(label) + self.psi_levels[label] = plt.contour(rgrid, zgrid, data, [float(level)], colors=color, linestyles=linestyles) + plt.plot([],[], label=label, color=color) except: - self.psi_levels[label] = plt.contour(rgrid, zgrid, data, [float(level)], colors=color, label=label, linestyles=linestyles) - self.psi_levels[label].collections[0].set_label(label) + self.psi_levels[label] = plt.contour(rgrid, zgrid, data, [float(level)], colors=color, linestyles=linestyles) + plt.plot([],[], label=label, color=color) def plot_data(self: object, nlevs: int = 30, interactive: bool = True, fig: object = None, ax: object = None, view_mode: str = 'filled', refined: bool = True, refine_factor: int = 10): diff --git a/setup.py b/setup.py index 393d49a..9da0f26 100644 --- a/setup.py +++ b/setup.py @@ -39,7 +39,7 @@ ], keywords='grid, mesh, generator, tokamak, edge, plasma, efit, uedge', packages=find_packages(), - python_requires='>=3.8, <4', + python_requires='>=3.9, <4', install_requires=[ 'm2r2', 'scipy >= 1.3.1', @@ -48,7 +48,7 @@ 'matplotlib', 'tk', 'sympy', - 'freeqdsk' + 'freeqdsk>=0.5' ] )