Based on the full error message below, the issue starts with the plot function called on an NC material, but np.asfarray is used in a couple of places in the NCryastal codebase.
import NCrystal as NC
(...)
self.__mat = NC.load(key)
(...)
self.__mat.plot(do_show=False)
The full error message is the fullowing:
stderr: Traceback (most recent call last):
File "/home/runner/work/nc_data_lib/nc_data_lib/database/generate_data.py", line 158, in <module>
stderr: create_DB(dbPath)
File "/home/runner/work/nc_data_lib/nc_data_lib/database/generate_data.py", line 110, in create_DB
db = create_DB_contents(plotfolder)
File "/home/runner/work/nc_data_lib/nc_data_lib/database/generate_data.py", line 100, in create_DB_contents
db.append( createDBEntry( fe, plotfolder = plotfolder ) )
File "/home/runner/work/nc_data_lib/nc_data_lib/database/generate_data.py", line 7, in createDBEntry
e = Entry( filelistentry,
File "/home/runner/work/nc_data_lib/nc_data_lib/database/generate_data.py", line 74, in __init__
stderr: self.__mat.plot(do_show=False)
File "/home/runner/.local/lib/python3.10/site-packages/NCrystal/core.py", line 1[52](https://github.com/MilanKlausz/nc_data_lib/actions/runs/9549645024/job/26319685968#step:6:53)8, in plot
stderr: return plot_xsect( self, *args, **kwargs )
File "/home/runner/.local/lib/python3.10/site-packages/NCrystal/plot.py", line 90, in plot_xsect
xs_s = xsectfactor * loadedmat.scatter.xsect(**xsectargs) if do_scat else None
File "/home/runner/.local/lib/python3.10/site-packages/NCrystal/core.py", line 1173, in xsect
stderr: ekin = Process._parseekin( ekin, wl )
File "/home/runner/.local/lib/python3.10/site-packages/NCrystal/core.py", line 1191, in _parseekin
return _nc_constants.wl2ekin(wl)
File "/home/runner/.local/lib/python3.10/site-packages/NCrystal/constants.py", line [60](https://github.com/MilanKlausz/nc_data_lib/actions/runs/9549645024/job/26319685968#step:6:61), in wl2ekin
stderr: x = _as_np_array( wl )
File "/home/runner/.local/lib/python3.10/site-packages/NCrystal/constants.py", line 46, in <lambda>
_as_np_array = ( lambda x : _np.asfarray(x,dtype=float) ) if _np else ( lambda *a,**kwargs : _ensure_numpy() )
File "/home/runner/.local/lib/python3.10/site-packages/numpy/__init__.py", line 397, in __getattr__
raise AttributeError(
stderr: AttributeError: `np.asfarray` was removed in the NumPy 2.0 release. Use `np.asarray` with a proper dtype instead.. Did you mean: 'asarray'?
I get the following error when trying to generate plots, due to the new Numpy 2.0.0 release.
The script that produces the error is: https://github.com/MilanKlausz/nc_data_lib/blob/main/database/generate_data.py
Based on the full error message below, the issue starts with the plot function called on an NC material, but
np.asfarray
is used in a couple of places in the NCryastal codebase.The full error message is the fullowing: