cadabra2
cadabra2 copied to clipboard
Substitute with regex conditional doesn't work
I tried the code from an example on https://cadabra.science/notebooks/ref_patterns.html:
Cadabra 2.3.6 (build 1.636a232 dated 2021-01-03)
Copyright (C) 2001-2020 Kasper Peeters <[email protected]>
Using SymPy version 1.7.1
Info at https://cadabra.science/
Available under the terms of the GNU General Public License v3
> ex:= A + B3 + C7;
A + B3 + C7
> substitute(_, $A + M? + N? | \regex{M?}{"[A-Z]7"} -> \sin(M? N?)/N?$);
File "<console>", line 1
substitute(_, Ex(r"A + M? + N? | \regex{M?}{"[A-Z]7"} -> \sin(M? N?)/N?", False));
^
SyntaxError: invalid syntax
>
I use Slackware 14.2 (Python 3.7.2). I also fired up an Ubuntu 20.04.1 VPS (Python 3.8.5) and installed https://cadabra.science/packages/ubuntu2004/cadabra2-2.3.6.3-focal.deb
The result is similar:
Cadabra 2.3.6 (build 2680.636a232b66 dated 2021-01-03)
Copyright (C) 2001-2020 Kasper Peeters <[email protected]>
Using SymPy version 1.5.1
Info at https://cadabra.science/
Available under the terms of the GNU General Public License v3
> ex:= A + B3 + C7;
A + B3 + C7
> substitute(_, $A + M? + N? | \regex{M?}{"[A-Z]7"} -> \sin(M? N?)/N?$);
Traceback (most recent call last):
File "/usr/lib/python3.8/code.py", line 63, in runsource
code = self.compile(source, filename, symbol)
File "/usr/lib/python3.8/codeop.py", line 176, in __call__
return _maybe_compile(self.compiler, source, filename, symbol)
File "/usr/lib/python3.8/codeop.py", line 104, in _maybe_compile
raise err1
File "/usr/lib/python3.8/codeop.py", line 91, in _maybe_compile
code1 = compiler(source + "\n", filename, symbol)
File "/usr/lib/python3.8/codeop.py", line 141, in __call__
codeob = compile(source, filename, symbol, self.flags, 1)
File "<console>", line 1
substitute(_, Ex(r"A + M? + N? | \regex{M?}{"[A-Z]7"} -> \sin(M? N?)/N?", False));
^
SyntaxError: invalid syntax
>