When I tried the following in REPL, it gets stuck when I types the last line. I cannot keep typing. The command top shows that Julia is using all the CPU. Any suggestion on how to trouble shoot the problem?
I thought it might be due to the fact that I am using kitty terminal emulator. However, other terminal emulators have the same issue.
Also, it seems that running SymPy.jl code as a script does not have this issue.
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.11.2 (2024-12-01)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |
julia> using SymPy
julia> @syms n
(n,)
julia> ex = 1/(n*(n+3))
1
βββββββββ
nβ (n + 3)
julia> sympy.apart(e
Installed SymPy to check, happens to me too. The middle lines werenβt needed, anything typed after just using SymPy and sympy.apart( freezes the REPL. Windows Task Manager doesnβt say Julia is using all the CPU though. I have no earthly idea why writing a partial function call would freeze on a non-space character, and Iβm very curious. Other properties freeze upon the parentheses too:
In any case, SymPy.apart or just apart (because itβs exported) works as documented:
julia> using SymPy
julia> @syms n
(n,)
julia> ex = 1/(n*(n+3))
1
βββββββββ
nβ (n + 3)
julia> apart(ex)
1 1
- βββββββββ + βββ
3β (n + 3) 3β n
To use properties of sympy, I could work around the freezing by assigning the property access to another variable, then doing the call separately:
julia> a = sympy.apart; a(ex) # note: different object from SymPy.apart
1 1
- βββββββββ + βββ
3β (n + 3) 3β n
julia> let b = sympy.apart; b(ex) end # local variable works too, preferred
1 1
- βββββββββ + βββ
3β (n + 3) 3β n
or avoiding function call syntax via the 1-argument piping operator:
julia> ex |> sympy.apart
1 1
- βββββββββ + βββ
3β (n + 3) 3β n
or writing it in a string to be parsed and evaluated (@eval call or quoted expressions freeze):
My guess is that itβs the the REPL autocomplete code that is trying to obtain possible completions from the sympy object that is causing the issue. Can the autocomplete be turned off somehow?
Confirmed related, disabling the v1.11 REPL hinting in one of the ways that issue linked makes this go away for me, and re-enabling the hinting brings back the freeze. Before it did, using the up-arrow to find and rerun the line worked fine.
Iβm surprised that hinting does type inference for an incomplete call, I thought it would only need to search the scopes for names. This also doesnβt explain why the a = sympy.apart; a(ex) workaround worked; does REPL hinting just not bother inferring a(e there? Whatever it does, Iβd definitely want it to give up right after I type another character, on a single thread too.