periodictable icon indicating copy to clipboard operation
periodictable copied to clipboard

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

Open jdagdelen opened this issue 4 years ago • 2 comments

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]

jdagdelen avatar Jul 12 '21 06:07 jdagdelen

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:

  • pt.core.element_base
  • pt.mass.init()
  • pt.density.element_densities
  • pt.crystal_structure.crystal_structures
  • pt.nsf.nsftable

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 avatar Jul 12 '21 20:07 pkienzle

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

pkienzle avatar Feb 13 '24 21:02 pkienzle