Commit 90ef064
committed
Stop embed_rdkit from returning a conformer-less molecule
``EmbedMultipleConfs`` does not only raise on failure - for some strained
species it returns normally having embedded zero conformers. ``embed_rdkit``
only guarded the raising path, so in that case it returned an RDMol with no
conformers and logged nothing at all. Every consumer of that object then reads
an empty list, and the first caller to index it gets
``IndexError: list index out of range`` with no record of where the molecule
came from. Reproduced on ``C1#CC1``, ``C1#CCC1`` and ``C1#CC#CC#C1``.
Treat zero conformers the same as an exception: log a warning naming the
species and return ``None``, which is what the ``RDMol | None`` return
annotation already promised and what the exception path already did.
All four callers already handle ``None`` and none of them is made worse by
receiving it: ``get_force_field_energies`` guards with ``if rd_mol is not
None``, ``get_force_field_energies_of_conformers`` returns early on ``None``,
``determine_chirality`` skips on ``rd_mol is None or not
rd_mol.GetNumConformers()``, and ``species.get_cheap_conformer`` passes it to
``rdkit_force_field``, which returns empty lists for ``None``. A conformer-less
molecule and ``None`` therefore produce the same downstream result, minus the
crash and plus a log line.1 parent 4e51b39 commit 90ef064
2 files changed
Lines changed: 17 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1465 | 1465 | | |
1466 | 1466 | | |
1467 | 1467 | | |
1468 | | - | |
| 1468 | + | |
| 1469 | + | |
1469 | 1470 | | |
1470 | 1471 | | |
1471 | 1472 | | |
| |||
1482 | 1483 | | |
1483 | 1484 | | |
1484 | 1485 | | |
| 1486 | + | |
| 1487 | + | |
| 1488 | + | |
| 1489 | + | |
1485 | 1490 | | |
1486 | 1491 | | |
1487 | 1492 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
681 | 681 | | |
682 | 682 | | |
683 | 683 | | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
684 | 695 | | |
685 | 696 | | |
686 | 697 | | |
| |||
0 commit comments