Ticket #6412 (closed defect: fixed)
[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 | Work issues: | |
| Report Upstream: | Reviewers: | Martin Albrecht | |
| Authors: | Simon King | Merged in: | sage-4.1.alpha2 |
| Dependencies: | Stopgaps: |
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
Change History
Changed 4 years ago by SimonKing
-
attachment
cputime.patch
added
comment:1 Changed 4 years 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.
Note: See
TracTickets for help on using
tickets.

Allow negative arguments for singular.cputime()