Skip to content

Commit 0bd6775

Browse files
authored
Merge pull request #35 from LLNL/bugfix/plasdom/python_310_issues
Fixed issues running INGRID on python>=3.10
2 parents 1cf4265 + eb17a8d commit 0bd6775

5 files changed

Lines changed: 13 additions & 7 deletions

File tree

INGRID/ingrid.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -836,12 +836,14 @@ def PlotPsiNormBounds(self) -> None:
836836
Dic = {'psi_1': 'lime',
837837
'psi_core': 'cyan',
838838
'psi_pf_1': 'white'}
839+
num_psi_levels = 4
839840
elif nxpt == 2:
840841
Dic = {'psi_core': 'cyan',
841842
'psi_1': 'lime',
842843
'psi_2': 'fuchsia',
843844
'psi_pf_1': 'white',
844845
'psi_pf_2': 'yellow'}
846+
num_psi_levels = 7
845847

846848
for k, c in Dic.items():
847849
self.PsiNorm.PlotLevel(self.settings['grid_settings'][k], color=Dic[k], label=k)
@@ -859,7 +861,7 @@ def PlotPsiNormBounds(self) -> None:
859861
pass
860862
self.PsiNorm.fig.legend(handles=[handle for handle in lookup.values()], labels=[label for label in lookup.keys()],
861863
bbox_to_anchor=(0.5, 1), loc='upper center',
862-
ncol=len([label for label in lookup.keys()]) // 3)
864+
ncol=min((len([label for label in lookup.keys()]) + num_psi_levels) // 3, 5), facecolor="gray", framealpha=0.2)
863865

864866
def PlotPsiNormMagReference(self, ax: object = None) -> None:
865867
"""

INGRID/interpol.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,11 @@ def PlotLevel(self: object, level: float = 1.0, color: str = 'red', label: str =
233233
indexing='ij')
234234
try:
235235
self.psi_levels[label].collections[0].remove()
236-
self.psi_levels[label] = plt.contour(rgrid, zgrid, data, [float(level)], colors=color, label=label, linestyles=linestyles)
237-
self.psi_levels[label].collections[0].set_label(label)
236+
self.psi_levels[label] = plt.contour(rgrid, zgrid, data, [float(level)], colors=color, linestyles=linestyles)
237+
plt.plot([],[], label=label, color=color)
238238
except:
239-
self.psi_levels[label] = plt.contour(rgrid, zgrid, data, [float(level)], colors=color, label=label, linestyles=linestyles)
240-
self.psi_levels[label].collections[0].set_label(label)
239+
self.psi_levels[label] = plt.contour(rgrid, zgrid, data, [float(level)], colors=color, linestyles=linestyles)
240+
plt.plot([],[], label=label, color=color)
241241

242242
def plot_data(self: object, nlevs: int = 30, interactive: bool = True, fig: object = None,
243243
ax: object = None, view_mode: str = 'filled', refined: bool = True, refine_factor: int = 10):

INGRID/utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,8 @@ def LoadGEQDSK(self, geqdsk_path: str) -> None:
472472

473473
with open(geqdsk_path, 'r') as f:
474474
geqdsk_data = geqdsk.read(f)
475+
if not isinstance(geqdsk_data,dict):
476+
geqdsk_data = geqdsk_data.__dict__
475477

476478
#
477479
# Extract quantities needed to initialize EfitData class

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
],
4040
keywords='grid, mesh, generator, tokamak, edge, plasma, efit, uedge',
4141
packages=find_packages(),
42-
python_requires='>=3.8, <4',
42+
python_requires='>=3.9, <4',
4343
install_requires=[
4444
'm2r2',
4545
'scipy >= 1.3.1',
@@ -48,7 +48,7 @@
4848
'matplotlib',
4949
'tk',
5050
'sympy',
51-
'freeqdsk'
51+
'freeqdsk>=0.5'
5252
]
5353
)
5454

tests/component/test_efit.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ def test_load_geqdsk(data_dir):
2121
#
2222
with open(eqdsk_path, 'r') as f:
2323
baseline = geqdsk.read(f)
24+
if not isinstance(baseline,dict):
25+
baseline = baseline.__dict__
2426

2527
#
2628
# Load data using Ingrid class

0 commit comments

Comments
 (0)