The following throws an error
In [27]: f=Function('f')
In [28]: parse_expr('af(t)', local_dict={'f': f }, transformations=(auto_symbol, auto_number, split_symbols, implicit_multiplication))
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
[snip]
TypeError: unbound method as_base_exp() must be called with f instance as first argument (got nothing instead)
The code it is trying to evaluate is
Symbol ('a' )*(f )*(Symbol ('t' ))
It seems the problem is the parentheses around f that were inserted in line 394:
result.extend([(OP, '('), (NAME, "%s" % char), (OP, ')'),
(NAME, 'Symbol'), (OP, '(')])
Is there any reason to add those parenthesis? Certainly, if char is a function, they should not be added. I'm not sure if there are cases where one does need those parenthesis.
I can fix the problem by changing this line to
result.extend([(NAME, "%s" % char),
(NAME, 'Symbol'), (OP, '(')])
but I'm not sure if I should test if local_dict[char] or global_dict[char] is callable (similar to _get_token_callable) and only remove the parenthesis if it is callable.
For this to work, I also have to modify the approach to remove the last 2 tokens (rather than 3) and then skip the following token so that the close parenthesis from the original Symbol is not included.
Does this fix seem reasonable?
Duane