crcollins / molml

A library to interface molecules and machine learning.
MIT License
65 stars 17 forks source link

Key error with silicon molecule Coulomb Matrix #7

Closed dmkuntz closed 3 years ago

dmkuntz commented 3 years ago

Hello,

I am having an issue transforming silicon, and I get a key error that does not happen with other molecules. Example:

feat = CoulombMatrix()
CoulombMatrix(input_type='list', n_jobs=1, sort=False, eigen=False, drop_values=False, only_lower_triangle=False)

molecule = (['C', 'Si', 'C', 'C', 'C', 'C', 'C', 'C', 'H', 'H', 'H', 'H', 'H', 'H', 'H', 'H', 'H', 'H', 'H', 'H', 'H', 'H', 'H', 'H', 'H', 'H'], [['-0.0826', '10.0417', '-0.0377'], ['1.6128', '10.8918', '-0.0081'], ['1.3492', '12.7774', '-0.0026'], ['2.5530', '10.3596', '1.5512'], ['2.5981', '10.3748', '-1.5446'], ['2.6254', '13.6396', '0.0079'], ['2.3479', '15.1502', '0.0131'], ['3.6226', '16.0004', '0.0206'], ['0.0178', '8.9494', '-0.0394'], ['-0.6547', '10.3212', '-0.9310'], ['-0.6841', '10.3156', '0.8378'], ['0.7395', '13.0408', '-0.8808'], ['0.7291', '13.0346', '0.8701'], ['3.5444', '10.8252', '1.6057'], ['2.6993', '9.2727', '1.5738'], ['2.0075', '10.6369', '2.4617'], ['2.7430', '9.2879', '-1.5742'], ['2.0803', '10.6627', '-2.4678'], ['3.5914', '10.8388', '-1.5650'], ['3.2366', '13.3895', '0.8874'], ['3.2452', '13.3971', '-0.8676'], ['1.7396', '15.4068', '-0.8659'], ['1.7339', '15.3998', '0.8902'], ['3.3907', '17.0717', '0.0241'], ['4.2347', '15.7895', '0.9063'], ['4.2401', '15.7966', '-0.8630']])

feat.fit([molecule])
feat.transform([molecule])

The error I get is

  File "C:...\molml\base.py", line 371, in transform
    results = self.map(self._para_transform, X)

  File "C:...base.py", line 280, in map
    return list(map(f, seq))

  File "...\molml\molecule.py", line 1126, in _para_transform
    if len(data.numbers) > self._max_size:

  File "C:...\molml\utils.py", line 379, in numbers
    temp = [ELE_TO_NUM[x] for x in self._elements]

  File "C:\...\molml\utils.py", line 379, in <listcomp>
    temp = [ELE_TO_NUM[x] for x in self._elements]

  File "C:\U...bidict\_base.py", line 374, in __getitem__
    return self._fwdm[key]

KeyError: 'Si'

Thanks for your help! The error occurs at the transform but the fit works fine

dmkuntz commented 3 years ago

I was also reading some of the closed issues and it looks like Si might be in the same category as Br?