Ambiguity for symbols in the sympy layer
- Dominant language
- Python
- Stars
- 593
- Forks
- 163
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 60
Description
In our sympy layer, there exist multiple implementations to query symbols in a symbolic expression. They give vastly different results for various expressions:
```python
from ast import parse
from dace.symbolic import pystr_to_symbolic, symbols_in_ast, symlist
pystr_to_symbolic("x").free_symbols
# -> {x}
symbols_in_ast(parse("x"))
# -> ['x']
symlist(pystr_to_symbolic("x"))
# -> {'x': x}
pystr_to_symbolic("a[i]").free_symbols
# -> {i}
symbols_in_ast(parse("a[i]"))
# -> ['a', 'i']
symlist(pystr_to_symbolic("a[i]"))
# -> {'i': i}
pystr_to_symbolic("a.b").free_symbols
# -> {a.b}
symbols_in_ast(parse("a.b"))
# -> ['a']
symlist(pystr_to_symbolic("a.b"))
# -> {'a': a, 'b': b}
pystr_to_symbolic("a.b[i]").free_symbols
# -> {a.b(i)}
symbols_in_ast(parse("a.b[i]"))
# -> ['i', 'a']
symlist(pystr_to_symbolic("a.b[i]"))
# -> {'a': a, 'i': i}
```
We should:
1. clearly define different concepts around symbolic expressions (symbolic variables, array variables, attribute variables or similar)
2. precisely specify the return values of these functions w.r.t. to these definitions.
For consistent specifications there must be consistent return values.
Contributor guide
Assessment
This issue has not been assessed yet.