Skip to content

Regression: ce.parse fails on expressions containing subscripts. #201

@rasmus-rasmus

Description

@rasmus-rasmus

Description

I've been using ce.parse to parse latex expressions, where all variable names consist of one capital letter and one numerical subscript, e. g., 'A_1', 'B_2', 'Q_{22}', etc. These are preprocessed to the form 'A_\\text{1}' etc and then parsed.

This used to work, but as of v0.26.* expressions of this form are parsed to ['At', 'A', "'1'"] in stead giving errors when I'm trying to parse an expression such as for example 'A_1+B_1' since operand types are incompatible.

Steps to Reproduce

To just parse a variable name:

ce.parse('A_\\text{1}')

To parse an algebraic expression of several variables:

ce.parse('A_\\text{1} + B_\\text{1}')

Actual Result

First code snippet will return [ 'At', 'A', "'1'" ].

Second returns:

["At","A",["Add",["Error",["ErrorCode","'incompatible-type'","'number'","'string'"]],["Error",["ErrorCode","'incompatible-type'","'number'","'any'"]]]]

Expected Result

I would expect first to return ['A_1']
and second to return ['Add', 'A_1', B_1']

Environment

It worked in v0.25.1

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions