Ticket #6412 (closed defect: fixed)

Opened 14 months ago

Last modified 14 months ago

[with patch, positive review] Getting Singular's cputime does not work with negative argument

Reported by: SimonKing Owned by: SimonKing
Priority: minor Milestone: sage-4.1
Component: interfaces Keywords: cputime Singular
Cc: malb Author(s): Simon King
Report Upstream: Reviewer(s): Martin Albrecht
Merged in: sage-4.1.alpha2 Work issues:

Description

In some application, I accidentally had a negative argument t to singular.cputime(t). Actually I don't know how this came, but anyway: This lead to a Traceback, since t is inserted into a string: 'timer-%d'%t

Of coure, if t has a minus sign, Singular complains. Easy solution: Put brackets aroung %d.

Without the patch:

sage: singular.cputime(-7)
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)

/home/SimonKing/.sage/temp/sage.math.washington.edu/18981/_home_SimonKing__sage_init_sage_0.py in <module>()

/usr/local/sage/local/lib/python2.5/site-packages/sage/interfaces/singular.pyc in cputime(self, t)
    677         """
    678         if t:
--> 679             return float(self.eval('timer-%d'%(int(1000*t))))/1000.0
    680         else:
    681             return float(self.eval('timer'))/1000.0

/usr/local/sage/local/lib/python2.5/site-packages/sage/interfaces/singular.pyc in eval(self, x, allow_semicolon, strip, **kwds)
    547
    548         if s.find("error") != -1 or s.find("Segment fault") != -1:
--> 549             raise RuntimeError, 'Singular error:\n%s'%s
    550
    551         if get_verbose() > 0:

RuntimeError: Singular error:
   ? --(`int`) failed
   ? expected --(`identifier`)
   ? error occurred in STDIN line 19: `timer--7000;`

With the patch:

sage: singular.cputime(-70)
70.060000000000002

It will certainly hardly ever occur that people call the cputime with a negative starting point, but why not fix a corner case?

Attachments

cputime.patch Download (0.7 KB) - added by SimonKing 14 months ago.
Allow negative arguments for singular.cputime()

Change History

Changed 14 months ago by SimonKing

Allow negative arguments for singular.cputime()

Changed 14 months ago by malb

  • summary changed from [with patch, needs review] Getting Singular's cputime does not work with negative argument to [with patch, positive review] Getting Singular's cputime does not work with negative argument

Looks good.

Changed 14 months ago by boothby

  • status changed from new to closed
  • resolution set to fixed
  • merged set to sage-4.1.alpha2

Changed 14 months ago by mvngu

  • reviewer set to Martin Albrecht
  • author changed from SimonKing to Simon King
Note: See TracTickets for help on using tickets.