pkienzle / periodictable

Extensible periodic table for python
http://periodictable.readthedocs.org
Other
135 stars 36 forks source link

First item of periodictable.elements generator is "n"? #45

Open jdagdelen opened 3 years ago

jdagdelen commented 3 years ago

Wondering if this is a bug or intentional. Neutrons aren't necessarily elements.

version: 1.6.0

To reproduce:

import periodictable as pt
[e for e in pt.elements][0]
pkienzle commented 3 years ago

Yes, intentional.

I probably added it because the neutron scattering tables I am using have an entry for the cross section of a bare neutron. I can't imagine anyone is using it for anything, but no guarantees.

Here's a work-around:

for el in list(pt.elements)[1:]:
   ... # process el

With a small tweak to pt.core.PeriodicTable.__getitem__, we could support:

for el in pt.elements[1:]:
    ... # process el

My inclination is to leave it in place.

A number of files need to be updated should we decide to remove it:

The scattering cross sections and half life should be made available somewhere, such as pt.constants.

It may also show up in docs and tests.

pkienzle commented 7 months ago

Changing this would be backwards incompatible. Save it for a breaking release.