-
-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
int vs. np.int #38
Comments
I cannot seem to reproduce this (or maybe I am not understanding your issue 😄 ) on a RHEL6 Linux box running python 2.7.12 (Anaconda): >>> import xraylib as xrl
>>> xrl.AtomicNumberToSymbol(26)
'Fe'
>>> import numpy as np
>>> a = np.array([26])
>>> xrl.AtomicNumberToSymbol(a[0])
'Fe'
>>> a = np.array([26], dtype=np.int)
>>> xrl.AtomicNumberToSymbol(a[0])
'Fe' What versions of xraylib and python are you using, and on which platform are you running it? |
Hmm, what you're running does not work for me. I'm running Python 3.5.2 on a Ubuntu 16.04 LTS system, using xraylib from the conda repo (https://anaconda.org/tacaswell/xraylib). It works fine for:
However not for:
For that I have to define it as:
Could it be a python2 vs python3 thing? Posted it as an xraylib-issue since I thought it was due to some native-int definition, but it could be my system doing strange stuff... |
It's indeed a python3 feature which appears to be related to all integers being 64-bit in python3. I am looking into it. |
Think I fixed it in #39. From what I understand numpy scalars were actually never supposed to work with the SWIG generated bindings according to the numpy docs. My latest changes appears to work fine with both built-in Python types as well numpy scalars. Feel free to give it a try, |
Very nice! Thanks for the effort! |
You're welcome, thanks for reporting this issue |
Some methods requiring (python-native) int-inputs (e.g. AtomicNumberToSymbol) seem to be crashing in the case that a non-native int (e.g. numpy.int) is provided. Is perhaps good to know (perhaps the issue could be solved by envoking np.asscalar for numpy inputs, but I'm not sure if that covers all potential input-problems)
The text was updated successfully, but these errors were encountered: