scikit-beam / XrayDB

[ARCHIVED] Atomic data compiled by Elam, Ravel and Sieber. Check https://github.com/xraypy/XrayDB
9 stars 6 forks source link

read elements string as case insensitive #11

Closed jrmlhermitte closed 7 years ago

jrmlhermitte commented 7 years ago

It would be nice that XrayDB.atomic_number be case insensitive. Would this be a reasonable add?

For ex:

import xraydb
_XrayDB = xraydb.XrayDB()
Z = _XrayDB.atomic_number('Ag')

works, but

Z = _XrayDB.atomic_number('ag')

does not.

There may be drawbacks which I may have missed. If the community is okay for the change I can submit a PR (if it saves time).

thanks!

(PS: please correct me if my usage is not the intended one)

newville commented 7 years ago

@ordirules I don not have a very strong preference, but case sensitivity for atomic symbols is pretty common. Should "co" be interpreted as "cobalt" or "carbon oxygen"? When only one element is possible, case sensitivity is not necessary, but when more than one element is possible, case sensitivity is necessary. So, I'm ever so slightly against allowing case insensitivity sometimes but not always. But, I could be persuaded.

jrmlhermitte commented 7 years ago

that's a good point. I lean more towards your side (switched from xraylib which was case insensitive)