Git Product home page Git Product logo

Comments (6)

tschoonj avatar tschoonj commented on June 6, 2024

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?

from xraylib.

davlars avatar davlars commented on June 6, 2024

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:

import xraylib as xrl
xrl.AtomicNumberToSymbol(1)

'H'

However not for:

import xraylib as xrl
a = np.array([1])
xrl.AtomicNumberToSymbol(a)

File "<ipython-input-12-10c1439dda30>", line 1, in <module>
   xrl.AtomicNumberToSymbol(a)
TypeError: in method 'AtomicNumberToSymbol', argument 1 of type 'int'

For that I have to define it as:

import xraylib as xrl
a = np.asscalar(np.array([1]))
xrl.AtomicNumberToSymbol(a)

'H'

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...

from xraylib.

tschoonj avatar tschoonj commented on June 6, 2024

It's indeed a python3 feature which appears to be related to all integers being 64-bit in python3.

I am looking into it.

from xraylib.

tschoonj avatar tschoonj commented on June 6, 2024

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,

from xraylib.

davlars avatar davlars commented on June 6, 2024

Very nice! Thanks for the effort!

from xraylib.

tschoonj avatar tschoonj commented on June 6, 2024

You're welcome, thanks for reporting this issue

from xraylib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.