jaraco / wolframalpha

MIT License
148 stars 25 forks source link

Result.assumptions always returns empty tuple iterator #29

Closed Jus-Codin closed 5 months ago

Jus-Codin commented 2 years ago

Assumptions seem to be inaccessible from Result.assumptions, which always returns an empty tuple iterator This seems to be caused by the function here.

When Result.assumptions is called, the function is attempting to access the key assumption

However, based on the sample query pi, assumptions are stored in the key assumptions:

{'@datatypes': '',
 '@error': 'false',
 ...
 'assumptions': {'@count': '1',
                 'assumption': {'@count': '6',
                                '@template': 'Assuming "${word}" is ${desc1}. '
                                             'Use as ${desc2} instead',
                                '@type': 'Clash',
                                '@word': 'pi',
                                'value': [...]
                 }
 },
 ...
}

Is this a bug, or intended behaviour?

jaraco commented 5 months ago

I do see that the code explicitly mentions assumptions (plural) and later strips the s to get the singular form. However, tracing the logic, I don't see how it could ever find assumptions. And looking at this test, it only performs some pretty weak assertions on the assumptions (it won't catch the condition you're describing). So yeah, probably a bug.

jaraco commented 5 months ago

Fix released in v5.0.1.