tschoonj / xraylib

A library for X-ray matter interaction cross sections for X-ray fluorescence applications
https://github.com/tschoonj/xraylib/wiki
Other
120 stars 54 forks source link

TypeError in python bindings using numpy ints #207

Closed ckoern closed 1 year ago

ckoern commented 1 year ago

Hi Tom,

I recently updated to 4.1.2 and now get TypeErrors when calling cross sections or similar functions using numpy integer types. For example

for Z in np.arange(10,20):
     print( xrl.LineEnergy( Z, xrl.KL2_LINE ) )

will yield TypeError: in method 'LineEnergy', argument 1 of type 'int'. Instead I need

for Z in np.arange(10,20):
     print( xrl.LineEnergy( int(Z), xrl.KL2_LINE ) )

This used to work fine in previous versions (but I am unsure which one I used before) Is this change by design or a bug? Unfortunatly, it breaks a lot of existing code for me.

Thank you for your great package!

tschoonj commented 1 year ago

Thanks Christian, I will look into this.

Out of curiosity: how did you install xraylib?

ckoern commented 1 year ago

I'm using coda with conda-forge

tschoonj commented 1 year ago

Thank, I have opened #208 with a fix for this issue, which is due to a bug in the meson scripts necessary for building the swig-python bindings.

tschoonj commented 1 year ago

The fix has been merged in. I will try and make a new release tomorrow. Thanks again for reporting this bug!

ckoern commented 1 year ago

Wow, that was fast, thanks a lot!