You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
As described in title -- a boost::any_cast error is thrown when you try to cast a property set by applyMolListPropsToAtoms<int64_t> to a string.
Steps to reproduce
To reproduce from C++:
std::unique_ptr<RWMol> m(SmilesToMol("CCC"));
m->setProp("atom.iprop.foo1", "1 6 9");
FileParserUtils::applyMolListPropsToAtoms<std::int64_t>(*m, "atom.iprop.");
int int_res = m->getAtomWithIdx(0)->getProp<std::int64_t>("foo1"); // this is fine
std::string str_res = m->getAtomWithIdx(0)->getProp<std::string>("foo1"); // this is not fine
that last line will throw
due to unexpected exception with message:
boost::bad_any_cast: failed conversion using boost::any_cast
This seems like a bug to me, because we can cast between property types when we set properties using setProp. This can be reproduced from python by reading a molblock that has property lists:
Atom label: C1
Has prop: 1
Traceback (most recent call last):
File "../rdkit/testing.py", line 91, in
print(at.GetProp('NumHeavyNeighbors'))
ValueError: key NumHeavyNeighbors exists but does not result in unregistered C++ type reason: boost::bad_any_cast: failed conversion using boost::any_cast
It looks like this is just an issue for integers (you can't even use GetIntProp from python?):
PartialCharge: 0.008, 0.0080000000000000002
IsCarbon: True, 1
Traceback (most recent call last):
File "../rdkit/testing.py", line 89, in
print(at.GetIntProp('NumHeavyNeighbors'))
ValueError: key NumHeavyNeighbors exists but does not result in an integer value reason: boost::bad_any_cast: failed conversion using boost::any_cast
Additional comments
I noticed this when working on #6453 when @bp-kelley suggested testing with atom property lists. Because of this issue, the substructure search option added in that PR will not work for int properties set using property lists.
Configuration
RDKit version: '2023.09.1pre'
OS: Mac
Are you using conda? No
The text was updated successfully, but these errors were encountered:
I added a PR to fix this, thanks for checking the atom lists. We didn't have conversions for int64 from boost::any to std::string, just long which is an odd type anyway.
Describe the bug
As described in title -- a
boost::any_cast
error is thrown when you try to cast a property set byapplyMolListPropsToAtoms<int64_t>
to a string.Steps to reproduce
To reproduce from C++:
that last line will throw
This seems like a bug to me, because we can cast between property types when we set properties using
setProp
. This can be reproduced from python by reading a molblock that has property lists:It looks like this is just an issue for integers (you can't even use
GetIntProp
from python?):Additional comments
I noticed this when working on #6453 when @bp-kelley suggested testing with atom property lists. Because of this issue, the substructure search option added in that PR will not work for int properties set using property lists.
Configuration
RDKit version: '2023.09.1pre'
OS: Mac
Are you using conda? No
The text was updated successfully, but these errors were encountered: