Use xraylib in numba nopython functions.
pip install xraylib_numba
Simply install xraylib_numba
in your environment to use xraylib
and xraylib_np
in nopython mode:
import xraylib
import xraylib_np
from numba import njit
import numpy as np
# %pip install xraylib_numba
@njit
def AtomicWeight(Z):
return xraylib.AtomicWeight(Z), xraylib_np.AtomicWeight(np.array([Z]))
print(AtomicWeight(1)) # (1.01, array([1.01]))
Currently, functions that have non-numeric arguments or returns are unsupported. If you know how to pass strings from numba to c please let me know.