You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Env: sage-10.4, WSL2 Kali Linux ~/.fricas.input init file with this content:
)set output length 110
)set message time on
)set message storage on
The offending lines are the last two lines since line length is handled in src/sage/interfaces/fricas.py
Expected Behavior
No bug (good parsing of FriCAS output).
Actual Behavior
The output when this init file is present
sage: fricas(7)
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
File ~/Tmp/sage-10.4/src/sage/interfaces/expect.py:1519, in ExpectElement.__init__(self, parent, value, is_name, name)
1518 try:
-> 1519 self._name = parent._create(value, name=name)
1520 # Convert ValueError and RuntimeError to TypeError for
1521 # coercion to work properly.
File ~/Tmp/sage-10.4/src/sage/interfaces/interface.py:517, in Interface._create(self, value, name)
516 name = self._next_var_name() if name is None else name
--> 517 self.set(name, value)
518 return name
File ~/Tmp/sage-10.4/src/sage/interfaces/fricas.py:663, in FriCAS.set(self, var, value)
662 output = self.eval(cmd, reformat=False)
--> 663 self._check_errors(value, output)
File ~/Tmp/sage-10.4/src/sage/interfaces/fricas.py:556, in FriCAS._check_errors(self, line, output)
555 output = output.replace(old, new)
--> 556 raise RuntimeError("An error occurred when FriCAS evaluated '%s':\n%s" % (line, output))
558 # or even an error
RuntimeError: An error occurred when FriCAS evaluated '7':
Time: 0 sec
Storage: 0 bytes
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)
Cell In[1], line 1
----> 1 fricas(Integer(7))
File ~/Tmp/sage-10.4/src/sage/misc/lazy_import.pyx:410, in sage.misc.lazy_import.LazyImport.__call__()
408 True
409 """
--> 410 return self.get_object()(*args, **kwds)
411
412 def __repr__(self):
File ~/Tmp/sage-10.4/src/sage/interfaces/interface.py:306, in Interface.__call__(self, x, name)
299 return cls(self, x, name=name)
300 try:
301 # Special methods do not and should not have an option to
302 # set the name directly, as the identifier assigned by the
303 # interface should stay consistent. An identifier with a
304 # user-assigned name might change its value, so we return a
305 # new element.
--> 306 result = self._coerce_from_special_method(x)
307 return result if name is None else result.name(new_name=name)
308 except TypeError:
File ~/Tmp/sage-10.4/src/sage/interfaces/interface.py:334, in Interface._coerce_from_special_method(self, x)
332 s = '_gp_'
333 try:
--> 334 return (x.__getattribute__(s))(self)
335 except AttributeError:
336 return self(x._interface_init_())
File ~/Tmp/sage-10.4/src/sage/structure/sage_object.pyx:795, in sage.structure.sage_object.SageObject._fricas_()
793 import sage.interfaces.fricas
794 G = sage.interfaces.fricas.fricas
--> 795 return self._interface_(G)
796
797 def _fricas_init_(self):
File ~/Tmp/sage-10.4/src/sage/structure/sage_object.pyx:725, in sage.structure.sage_object.SageObject._interface_()
723 except Exception:
724 raise NotImplementedError("coercion of object %s to %s not implemented:\n%s\n%s" % (repr(self), I))
--> 725 X = I(s)
726 if c:
727 try:
File ~/Tmp/sage-10.4/src/sage/interfaces/interface.py:299, in Interface.__call__(self, x, name)
296 pass
298 if isinstance(x, str):
--> 299 return cls(self, x, name=name)
300 try:
301 # Special methods do not and should not have an option to
302 # set the name directly, as the identifier assigned by the
303 # interface should stay consistent. An identifier with a
304 # user-assigned name might change its value, so we return a
305 # new element.
306 result = self._coerce_from_special_method(x)
File ~/Tmp/sage-10.4/src/sage/interfaces/expect.py:1524, in ExpectElement.__init__(self, parent, value, is_name, name)
1522 except (RuntimeError, ValueError) as x:
1523 self._session_number = -1
-> 1524 raise TypeError(*x.args)
1525 except BaseException:
1526 self._session_number = -1
TypeError: An error occurred when FriCAS evaluated '7':
Time: 0 sec
Storage: 0 bytes
sage:
Additional Information
Two quick solutions, unless you want to support timing data, storage data or any other things.
One is to add some default settings to revert the ones in ~/.fricas.input:
In src/sage/interfaces/fricas.py, replacing (lines 228-238)
Or, simpler, since os is imported you can export/set the environment variable FRICAS_INITFILE with an empty string using: os.environ['FRICAS_INITFILE'] = ""
before starting FriCAS. This one is untested, but in a terminal if fricas is in the PATH, issuing
FRICAS_INITFILE='' fricas
will start FriCAS without evaluating ~/.fricas.input
This one is more robust since it starts FriCAS with well-known settings. With this solution, do not modify the actual FRICAS_INIT_CODE python variable.
There are other settings that affect the output of FriCAS for information:
(1) -> )set message
Current Values of messages Variables
Variable Description Current Value
-----------------------------------------------------------------------------
any print the internal type of objects of domain Any on
autoload print file auto-load messages off
bottomup display bottom up modemap selection off
dropmap display old map defn when replaced off
expose warning for unexposed functions off
file print msgs also to SPADMSG LISTING off
frame display messages about frames off
highlighting use highlighting in system messages off
instant present instantiation summary off
insteach present instantiation info off
interponly say when function code is interpreted on
prompt set type of input prompt to display step
selection display function selection msgs off
set show )set setting after assignment off
startup display messages on start-up on
storage print memory usage after computation off
testing print system testing header off
time print timings after computation off
type print type after computation on
void print Void value when it occurs off
(1) -> )set output
Current Values of output Variables
Variable Description Current Value
-----------------------------------------------------------------------------
abbreviate abbreviate type names off
algebra display output in algebraic form On:CONSOLE
characters choose special output character set plain
fortran create output in FORTRAN format Off:CONSOLE
fraction how fractions are formatted vertical
length line length of output displays 77
openmath create output in OpenMath style Off:CONSOLE
scripts show subscripts,... linearly off
showeditor view output of )show in editor off
tex create output in TeX style Off:CONSOLE
mathml create output in MathML style Off:CONSOLE
texmacs create output in Texmacs style Off:CONSOLE
html create output in HTML style Off:CONSOLE
formatted create output in formatted style Off:CONSOLE
(1) ->
PS: This should also be applicable to axiom.py
Environment
WSL2 Kali Linux (kali-rolling) - Windows 11 Professional:
Sage 10.4:
Checklist
I have searched the existing issues for a bug report that matches the one I want to file, without success.
I have read the documentation and troubleshoot guide
The text was updated successfully, but these errors were encountered:
Thank you! I like the first solution, it looks robust enough. Are you willing to review the fix (#38894)? (You probably don't have the rights yet, but that can be fixed.)
Steps To Reproduce
Env: sage-10.4, WSL2 Kali Linux
~/.fricas.input
init file with this content:The offending lines are the last two lines since line length is handled in src/sage/interfaces/fricas.py
Expected Behavior
No bug (good parsing of FriCAS output).
Actual Behavior
The output when this init file is present
Additional Information
Two quick solutions, unless you want to support timing data, storage data or any other things.
One is to add some default settings to revert the ones in
~/.fricas.input
:In src/sage/interfaces/fricas.py, replacing (lines 228-238)
by
Or, simpler, since
os
is imported you can export/set the environment variable FRICAS_INITFILE with an empty string using:os.environ['FRICAS_INITFILE'] = ""
before starting FriCAS. This one is untested, but in a terminal if
fricas
is in the PATH, issuingwill start FriCAS without evaluating
~/.fricas.input
This one is more robust since it starts FriCAS with well-known settings. With this solution, do not modify the actual FRICAS_INIT_CODE python variable.
There are other settings that affect the output of FriCAS for information:
PS: This should also be applicable to axiom.py
Environment
Checklist
The text was updated successfully, but these errors were encountered: