I have just attempted to use xraylib with Python and have run into a problem with the example xrlexample5.py
The example throws an exception at line 67, while attempting to call xraylib.AtomicNumberToSymbol(Z[0]), where Z=np.array([26])
The output is
Traceback (most recent call last):
File "blah/Downloads/xraylib/example/xrlexample5.py", line 67, in \<module>
symbol = xraylib.AtomicNumberToSymbol(Z[0])
File "blah/miniconda3/envs/py3/lib/python3.10/site-packages/xraylib.py", line 1037, in AtomicNumberToSymbol
return _xraylib.AtomicNumberToSymbol(Z)
TypeError: in method \'AtomicNumberToSymbol\', argument 1 of type \'int\'
ie. It looks like AtomicNumberToSymbol is expecting an int (but getting a numpy.int64).
To confirm this, I,
found a clean machine (Ubuntu 20.04),
installed xraylib using conda (> conda install -c conda-forge xraylib),
opened a python shell (python 3.9.15)
typed the following commands
>>> import numpy as np
>>> import xraylib
>>> xraylib.__version__
'4.1.2'
>>> xraylib.AtomicNumberToSymbol(26)
'Fe'
>>> type(26)
\<class 'int'>
>>> xraylib.AtomicNumberToSymbol(np.array([26])[0])
Traceback (most recent call last):
File "", line 1 in
File "~/miniconda3/envs/py3/lib/python3.9/site-packages/xraylib.py", line 1037, in AtomicNumberToSymbol
return _xraylib.AtomicNumberToSymbol(Z)
TypeError: in method 'AtomicNumberToSymbol', argument 1 of type 'int'
`>>> type(np.array([26])[0])
\<class 'numpy.int64'>
Hi,
I have just attempted to use xraylib with Python and have run into a problem with the example xrlexample5.py The example throws an exception at line 67, while attempting to call xraylib.AtomicNumberToSymbol(Z[0]), where Z=np.array([26]) The output is
ie. It looks like AtomicNumberToSymbol is expecting an int (but getting a numpy.int64).
To confirm this, I,
typed the following commands
>>> import numpy as np >>> import xraylib >>> xraylib.__version__ '4.1.2' >>> xraylib.AtomicNumberToSymbol(26) 'Fe' >>> type(26) \<class 'int'> >>> xraylib.AtomicNumberToSymbol(np.array([26])[0]) Traceback (most recent call last): File "", line 1 in
File "~/miniconda3/envs/py3/lib/python3.9/site-packages/xraylib.py", line 1037, in AtomicNumberToSymbol
return _xraylib.AtomicNumberToSymbol(Z)
TypeError: in method 'AtomicNumberToSymbol', argument 1 of type 'int'
`>>> type(np.array([26])[0])
\<class 'numpy.int64'>