Open edgarcosta opened 2 months ago
here is a temporary workaround:
sage: bar = magma('"foo"')
sage: magma.eval(f'Type({bar.name()})')
'MonStgElt'
how to tell a string from a command ? is "2+2" a string ?
I agree it is tricky for magma()
, but the issue also arises for magma.?()
,
For example:
sage: magma.HasSignature('"Print"', [])
false
sage: magma.HasSignature("Print", [])
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
File /Applications/sage-dev/src/sage/interfaces/expect.py:1520, in ExpectElement.__init__(self, parent, value, is_name, name)
1519 try:
-> 1520 self._name = parent._create(value, name=name)
1521 # Convert ValueError and RuntimeError to TypeError for
1522 # coercion to work properly.
File /Applications/sage-dev/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 /Applications/sage-dev/src/sage/interfaces/magma.py:629, in Magma.set(self, var, value)
612 """
613 Set the variable var to the given value in the Magma interpreter.
614
(...)
627 13/5
628 """
--> 629 out = self.eval("%s:=%s" % (var, value))
630 if out.lower().find("error") != -1:
File /Applications/sage-dev/src/sage/interfaces/magma.py:562, in Magma.eval(self, x, strip, **kwds)
561 if 'Runtime error' in ans or 'User error' in ans:
--> 562 raise RuntimeError("Error evaluating Magma code.\nIN:%s\nOUT:%s" % (x, ans))
563 return ans
RuntimeError: Error evaluating Magma code.
IN:_sage_[4]:=HasSignature(_sage_[2],_sage_[1]);
OUT:
>> _sage_[4]:=HasSignature(_sage_[2],_sage_[1]);
^
Runtime error in 'HasSignature': Bad argument types
Argument types given: Intrinsic, SeqEnum[Any]
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)
Cell In[2], line 1
----> 1 magma.HasSignature("Print", [])
File /Applications/sage-dev/src/sage/interfaces/magma.py:1802, in MagmaFunction.__call__(self, *args, **kwds)
1800 del kwds['nvals']
1801 M = self._parent
-> 1802 return M.function_call(self._name,
1803 list(args),
1804 params=kwds,
1805 nvals=nvals)
File /Applications/sage-dev/src/sage/interfaces/magma.py:1170, in Magma.function_call(self, function, args, params, nvals)
1165 par = ' : ' + ','.join('%s:=%s' % (a, b.name())
1166 for a, b in params.items())
1168 fun = "%s(%s%s)" % (function, ",".join(s.name() for s in args), par)
-> 1170 return self._do_call(fun, nvals)
File /Applications/sage-dev/src/sage/interfaces/magma.py:1220, in Magma._do_call(self, code, nvals)
1218 ans = None
1219 elif nvals == 1:
-> 1220 return self(code)
1221 else:
1222 v = [self._next_var_name() for _ in range(nvals)]
File /Applications/sage-dev/src/sage/interfaces/magma.py:797, in Magma.__call__(self, x, gens)
794 except TypeError: # if x isn't hashable
795 pass
--> 797 A = Expect.__call__(self, x)
798 if has_cache:
799 x._magma_cache[self] = A
File /Applications/sage-dev/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 /Applications/sage-dev/src/sage/interfaces/expect.py:1525, in ExpectElement.__init__(self, parent, value, is_name, name)
1523 except (RuntimeError, ValueError) as x:
1524 self._session_number = -1
-> 1525 raise TypeError(*x.args)
1526 except BaseException:
1527 self._session_number = -1
TypeError: Error evaluating Magma code.
IN:_sage_[4]:=HasSignature(_sage_[2],_sage_[1]);
OUT:
>> _sage_[4]:=HasSignature(_sage_[2],_sage_[1]);
^
Runtime error in 'HasSignature': Bad argument types
Argument types given: Intrinsic, SeqEnum[Any]
sage:
Steps To Reproduce
Checklist