Calling Magma SetNthreads() from SAGE produces an error

33 views
Skip to first unread message

Rusydi H. Makarim

unread,
Nov 6, 2016, 4:28:45 PM11/6/16
to sage-s...@googlegroups.com
Hi,

Given a PolynomialSequence, I want to compute its Groebner basis using magma implementation of F4 algorithm. However, when I want to call SetNthreads() in magma to use multiple threads during F4 algorithm, SAGE throws the following error :

sage: magma.SetNthreads(4)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-1-2d29c32308b3> in <module>()
----> 1 magma.SetNthreads(Integer(4))

/home/makarimrh/sage-forked/local/lib/python2.7/site-packages/sage/interfaces/magma.pyc in __call__(self, *args, **kwds)
   1801                                list(args),
   1802                                params=kwds,
-> 1803                                nvals=nvals)
   1804

   1805     def _sage_doc_(self):

/home/makarimrh/sage-forked/local/lib/python2.7/site-packages/sage/interfaces/magma.pyc in function_call(self, function, args, params, nvals)
   1159         fun = "%s(%s%s)" % (function, ",".join([s.name() for s in args]), par)
   1160

-> 1161         return self._do_call(fun, nvals)
   1162

   1163     def _do_call(self, code, nvals):

/home/makarimrh/sage-forked/local/lib/python2.7/site-packages/sage/interfaces/magma.pyc in _do_call(self, code, nvals)
   1209             ans = None
   1210         elif nvals == 1:
-> 1211             return self(code)
   1212         else:
   1213             v = [self._next_var_name() for _ in range(nvals)]

/home/makarimrh/sage-forked/local/lib/python2.7/site-packages/sage/interfaces/magma.pyc in __call__(self, x, gens)
    789             pass
    790

--> 791         A = Expect.__call__(self, x)
    792         if has_cache:
    793             x._magma_cache[self] = A

/home/makarimrh/sage-forked/local/lib/python2.7/site-packages/sage/interfaces/interface.pyc in __call__(self, x, name)
    242

    243         if isinstance(x, six.string_types):
--> 244             return cls(self, x, name=name)
    245         try:
    246             return self._coerce_from_special_method(x)

/home/makarimrh/sage-forked/local/lib/python2.7/site-packages/sage/interfaces/expect.pyc in __init__(self, parent, value, is_name, name)
   1380             except (RuntimeError, ValueError) as x:
   1381                 self._session_number = -1
-> 1382                 raise_(TypeError, x, sys.exc_info()[2])
   1383             except BaseException:
   1384                 self._session_number = -1

/home/makarimrh/sage-forked/local/lib/python2.7/site-packages/sage/interfaces/expect.pyc in __init__(self, parent, value, is_name, name)
   1375         else:
   1376             try:
-> 1377                 self._name = parent._create(value, name=name)
   1378             # Convert ValueError and RuntimeError to TypeError for
   1379             # coercion to work properly.

/home/makarimrh/sage-forked/local/lib/python2.7/site-packages/sage/interfaces/interface.pyc in _create(self, value, name)
    432     def _create(self, value, name=None):
    433         name = self._next_var_name() if name is None else name
--> 434         self.set(name, value)
    435         return name
    436


/home/makarimrh/sage-forked/local/lib/python2.7/site-packages/sage/interfaces/magma.pyc in set(self, var, value)
    624             13/5
    625         """
--> 626         out = self.eval("%s:=%s" % (var, value))
    627         if out.lower().find("error") != -1:
    628             raise TypeError("Error executing Magma code:\n%s" % out)

/home/makarimrh/sage-forked/local/lib/python2.7/site-packages/sage/interfaces/magma.pyc in eval(self, x, strip, **kwds)
    558         ans = Expect.eval(self, x, **kwds).replace('\\\n', '')
    559         if 'Runtime error' in ans or 'User error' in ans:
--> 560             raise RuntimeError("Error evaluating Magma code.\nIN:%s\nOUT:%s" % (x, ans))
    561         return ans
    562


TypeError: Error evaluating Magma code.
IN:_sage_[2]:=SetNthreads(_sage_[1]);
OUT:
>> _sage_[2]:=SetNthreads(_sage_[1]);
                         ^
Runtime error in 'SetNthreads': Bad argument types (possibly calling function signature of intrinsic as a procedure)
Argument types given: RngIntElt


I use Magma 2.20-6 and Sage 7.3. Is this considered a bug ?

--

Nils Bruin

unread,
Nov 6, 2016, 11:02:00 PM11/6/16
to sage-support
On Sunday, November 6, 2016 at 1:28:45 PM UTC-8, Rusydi H. Makarim wrote:
                         ^
Runtime error in 'SetNthreads': Bad argument types (possibly calling function signature of intrinsic as a procedure)
Argument types given: RngIntElt


I use Magma 2.20-6 and Sage 7.3. Is this considered a bug ?

I don't think so. You get the error in Magma directly as well:

> c:=SetNthreads(3);

>> c:=SetNthreads(3);

                 ^
Runtime error in 'SetNthreads': Bad argument types (possibly calling function
signature of intrinsic as a procedure)
Argument types given: RngIntElt

The error message doesn't really say what's wrong, but the upshot is that SetNthreads gets used in a context where it doesn't fit (SetNThreads signature says it doesn't have a return value)

Instead do:

sage: magma.eval("SetNthreads(3)")
''
sage: magma.GetNthreads()
3

Reply all
Reply to author
Forward
0 new messages