@user2357112 identified the problem: you are assigning an Element instance to a numpy array that holds integers. This is what I get when I try something similar:
>>> import numpy as np
>>> np.__version__
'1.7.1'
>>> p = np.array([1,2,3])
>>> class Foo:
... pass
...
>>> p[0] = Foo()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
SystemError: error return without exception set
>>>
It is not surprising that this is not allowed. The cryptic error message, however, is almost certainly a numpy bug.
One way to fix the issue is to use an array of type object. Change this line:
periodicTable = np.array(range(7*32)).reshape((7,32))
to this:
periodicTable = np.empty((7,32), dtype=object)
Update
In numpy 1.10.1, the error message is still a bit cryptic:
>>> import numpy as np
>>> np.__version__
'1.10.1'
>>> p = np.array([1, 2, 3])
>>> class Foo:
... pass
...
>>> p[0] = Foo()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: Foo instance has no attribute '__trunc__'
Update 2
The error message is better is later versions of numpy:
In [1]: import numpy as np
In [2]: np.__version__
Out[2]: '1.12.1'
In [3]: class Foo:
...: pass
...:
In [4]: p = np.array([1, 2, 3])
In [5]: p[0] = Foo()
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-5-739d5e5f795b> in <module>()
----> 1 p[0] = Foo()
TypeError: int() argument must be a string, a bytes-like object or a number, not 'Foo'
int32? Also, if you want to generate an empty array, there'snumpy.zeros,ones, orempty. You don't need to create a Python list withrangeto initialize it.