#6412 closed defect (fixed)
[with patch, positive review] Getting Singular's cputime does not work with negative argument
Reported by: | Simon King | Owned by: | Simon King |
---|---|---|---|
Priority: | minor | Milestone: | sage-4.1 |
Component: | interfaces | Keywords: | cputime Singular |
Cc: | Martin Albrecht | Merged in: | sage-4.1.alpha2 |
Authors: | Simon King | Reviewers: | Martin Albrecht |
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
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 (1)
Change History (4)
Changed 14 years ago by
Attachment: | cputime.patch added |
---|
comment:1 Changed 14 years ago by
Summary: | [with patch, needs review] Getting Singular's cputime does not work with negative argument → [with patch, positive review] Getting Singular's cputime does not work with negative argument |
---|
Looks good.
comment:2 Changed 14 years ago by
Merged in: | → sage-4.1.alpha2 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
comment:3 Changed 14 years ago by
Authors: | SimonKing → Simon King |
---|---|
Reviewers: | → Martin Albrecht |
Note: See
TracTickets for help on using
tickets.
Allow negative arguments for singular.cputime()