Skip to content

Conversation

m-messer
Copy link
Member

@m-messer m-messer commented Oct 2, 2025

Added normalise as another parameter for use with custom multi-character symbols and implicit multiplication.

So if a response is a/(bcd) for an answer of a/(bc*d) and the symbols a, bc, d. This will now return True when normalise is enabled, and False when it is disabled (as Sympy will convert the response to a/(b * c * d).

Copy link
Contributor

@peterbjohnson peterbjohnson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to my other review, we need to review whether this approach is appropriate, or whether we should be integrating more with the existing parsing.

Regarding adding a parameter that only works with another parameter, that may be problematic. E.g. (for illustration)implicit_multiplication_higher_precedence_A and implicit_multiplication_higher_precedence_B where e.g. A is normalise and B is nonnormalised - or whatever we agree on.

I'm also not clear what 'normalise' means here. It has many meanings generally and in this context it's not obvious to me.

@m-messer
Copy link
Member Author

m-messer commented Oct 3, 2025

I took a look at the transformers, including the depths of Sympy and its tokeniser. Sympy doesn't handle the case where bc is registered as a symbol with sympy, and an input of a/(bcd) is provided, as the tokeniser will treat that bcd as a token which does not match an existing symbol. Sympy does not support substring tokenisation, which is why I chose this approach.

If we are happy to go ahead with this, I will rename them implicit_multiplication_higher_precedence and implicit_multiplication_higher_precedence_multi_character. I had it has two separate parameters, as I wasn't sure if we required it anywhere else.

@peterbjohnson
Copy link
Contributor

I don't know if it's needed in other cases, I was just following your comment that it's only needed with implicit multiplication.

I think implicit multiplication works ok with bcd as bc•d where bc is a multi letter symbol? If so, I'd like to understand why it doesn't work with higher precedence implicit multiplication, and how the suggested solution works despite that.

Easiest will be for me to ask you when I have a chance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants