Ignore:
Timestamp:
10/05/07 21:22:57 (6 years ago)
Author:
William Stein <wstein@…>
Branch:
default
Message:

Change so that singular variables are not killed unless they are user defined.

I learned about the defined command in Singular, and change the code
to only kill variables when they have been user-defined. This is
actually much cleaner code (no exception handling needed for it), and
fixes the problem I was having with polynomial_singular_interface.py.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sage/interfaces/singular.py

    r6690 r6706  
    381381        Clear the variable named var. 
    382382        """ 
    383         try: 
    384             self.eval('kill %s;'%var) 
    385         except RuntimeError: 
    386             pass 
    387          
    388  
    389         # Reusing var names causes problems, because of strong typing. 
    390         # If you run the multi_polynomial_ideal.py doctest you'll see this. 
    391         ##self._available_vars.append(var) 
    392  
    393         #Could be an alternative to killing, if that is a problem... 
    394         #self.eval('def %s=0;'%var) 
     383        self.eval('if(defined(%s)>0){kill %s;}'%(var,var)) 
    395384 
    396385    def _create(self, value, type='def'): 
     
    609598            3*a 
    610599        """ 
    611         try: 
    612             self.eval('kill %s'%(str(vars)[1:-1])) 
    613         except (RuntimeError, TypeError):  # error if variable is not already defined. 
    614             pass 
     600        if len(vars) > 2: 
     601            s = '; '.join(['if(defined(%s)>0){kill %s;};'%(x,x) 
     602                           for x in vars[1:-1].split(',')]) 
     603            self.eval(s); 
     604 
    615605        if check and isinstance(char, (int, long, sage.rings.integer.Integer)): 
    616606            if char != 0: 
Note: See TracChangeset for help on using the changeset viewer.