freegs-plasma / freegs

Free boundary Grad-Shafranov solver

Home Page:http://freegs.readthedocs.io/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

numpy.asscalar is deprecated in newer versions of numpy

cpraveen opened this issue · comments

This is used in three places in freegs/equilibium.py file.

https://numpy.org/doc/1.21/reference/generated/numpy.asscalar.html

Thanks @cpraveen ! The notice says to replace asscalar(a) with a.item() but that only works if a is an ndarray, not if it's already a scalar. Something like:

try:
  a = a.item()
except AttributeError:
  a = float(a)

might perhaps work, to make sure that a is a scalar and not a 1-element array?

I change to

if len(result) == 1:
    return result[0]

and the code runs.

Fixed in #76