Ticket #1827: trac-1827.patch

File trac-1827.patch, 6.0 KB (added by was, 14 years ago)

this should completely fix the problem. But I've only tested it on one 32-bit linux system. it needs more testing

  • sage/calculus/calculus.py

    # HG changeset patch
    # User was@debian32.localdomain
    # Date 1200676522 28800
    # Node ID a66354d137082d833c30dbc577edaccf8ea987a0
    # Parent  85934f3b983c44ca9d0ebcd06d5f81492307aae8
    Fix trac #1827 -- weird maxima synchronization issues that make themselves known by big calculus expressions breaking on some platforms.
    
    diff -r 85934f3b983c -r a66354d13708 sage/calculus/calculus.py
    a b class SymbolicExpressionRing_class(Commu 
    440440        return Integer(0)
    441441
    442442    def _an_element_impl(self):
    443         return SymbolicVariable('_generic_variable_name_')
     443        try:
     444            return self.__zero
     445        except AttributeError:
     446            self.__zero = SR(0)
     447        return self.__zero
    444448       
    445449    def is_field(self):
    446450        return True
  • sage/interfaces/maxima.py

    diff -r 85934f3b983c -r a66354d13708 sage/interfaces/maxima.py
    a b class Maxima(Expect): 
    501501    def _before(self):
    502502        return self._expect.before
    503503
    504     def _batch(self, str, batchload=True):
    505         F = open(self._local_tmpfile(), 'w')
    506         F.write(str)
     504    def _batch(self, s, batchload=True):
     505        filename = '%s-%s'%(self._local_tmpfile(),randrange(2147483647))
     506        F = open(filename, 'w')
     507        F.write(s)
    507508        F.close()
    508         tmp_to_use = self._local_tmpfile()
    509509        if self.is_remote():
    510             self._send_tmpfile_to_server()
     510            self._send_tmpfile_to_server(local_file=filename)
    511511            tmp_to_use = self._remote_tmpfile()
     512        tmp_to_use = filename
    512513       
    513514        if batchload:
    514515            cmd = 'batchload("%s");'%tmp_to_use
    515516        else:
    516517            cmd = 'batch("%s");'%tmp_to_use
     518
     519        r = randrange(2147483647)
     520        s = str(r+1)
     521        cmd = "%s1+%s;\n"%(cmd,r)
     522
    517523        self._sendline(cmd)
    518         self._expect_expr()
     524        self._expect_expr(s)
    519525        out = self._before()
    520526        self._error_check(str, out)
     527        os.unlink(filename)
    521528        return out
    522529
    523530    def _error_check(self, str, out):
    class Maxima(Expect): 
    540547        self._synchronize()
    541548
    542549        if len(line) > self.__eval_using_file_cutoff:
     550            # This implicitly uses the set method, then displays the result of the thing that was set.
     551            # This only works when the input line is an expression.   But this is our only choice, since
     552            # batchmode doesn't display expressions to screen.   
    543553            a = self(line)
    544554            return repr(a)
    545555        else:
  • sage/plot/plot3d/transform.pyx

    diff -r 85934f3b983c -r a66354d13708 sage/plot/plot3d/transform.pyx
    a b def rotate_arbitrary(v, double theta): 
    203203            sage: m = rotX(theta) * m
    204204           
    205205        Do some simplfying here to avoid blow-up.
    206             sage: ix = [(i,j) for i in range(3) for j in range(3)]
    207             sage: for ij in ix: m[ij] = m[ij].simplify_rational()
     206            sage: m = m.simplify_rational()
    208207           
    209208        Now go back to the original coordinate system.
    210209            sage: m = rotZ(-s) * m
    211210            sage: m = rotX(-t) * m
    212             sage: for ij in ix: m[ij] = m[ij].simplify_rational()
     211            sage: m = m.simplify_rational()
    213212            sage: m
    214             [                                                                                                                                        (x^2*z^2 - (cos(theta)*x^2 - cos(theta))*z^2)/z^2                                                                                                          (-sqrt(-z^2 - x^2 + 1)*(cos(theta)*x*abs(z) - x*abs(z)) - sin(theta)*z^2)/abs(z)                                                                                                (-cos(theta)*x*z^2*abs(z) + x*z^2*abs(z) + sin(theta)*z^2*sqrt(-z^2 - x^2 + 1))/(z*abs(z))]
    215             [                                                                                                            (sin(theta)*z^2*abs(z) - sqrt(-z^2 - x^2 + 1)*(cos(theta)*x*z^2 - x*z^2))/z^2                                              ((-(x^2 + cos(theta) - 1)*z^2 - x^4 + 2*x^2 - 1)*abs(z) - (-cos(theta)*x^2*z^2 - cos(theta)*x^4 + cos(theta)*x^2)*abs(z))/((x^2 - 1)*abs(z)) (-sqrt(-z^2 - x^2 + 1)*(cos(theta)*x^2*z^2*abs(z) + (-x^2 - cos(theta) + 1)*z^2*abs(z)) + sin(theta)*x*z^4 - z^2*(sin(theta)*x*z^2 + sin(theta)*x^3 - sin(theta)*x))/((x^2 - 1)*z*abs(z))]
    216             [                                                                                                               (-sin(theta)*z*sqrt(-z^2 - x^2 + 1)*abs(z) - cos(theta)*x*z^3 + x*z^3)/z^2                                               (-sqrt(-z^2 - x^2 + 1)*(cos(theta)*x^2*z*abs(z) + (-x^2 - cos(theta) + 1)*z*abs(z)) - (sin(theta)*x - sin(theta)*x^3)*z)/((x^2 - 1)*abs(z))                                                                        (((x^2 + cos(theta) - 1)*z^2 + cos(theta)*x^2 - cos(theta))*abs(z) - cos(theta)*x^2*z^2*abs(z))/((x^2 - 1)*abs(z))]
    217 
     213            [                                       (1 - cos(theta))*x^2 + cos(theta) (-sin(theta)*abs(z)^3 - (cos(theta) - 1)*x*z^2*sqrt(-z^2 - x^2 + 1))/z^2  (sin(theta)*sqrt(-z^2 - x^2 + 1)*abs(z)^3 + (1 - cos(theta))*x*z^4)/z^3]
     214            [             sin(theta)*abs(z) + (1 - cos(theta))*x*sqrt(-z^2 - x^2 + 1)                          (cos(theta) - 1)*z^2 + (cos(theta) - 1)*x^2 + 1     (-sin(theta)*x*abs(z) - (cos(theta) - 1)*z^2*sqrt(-z^2 - x^2 + 1))/z]
     215            [    (-sin(theta)*sqrt(-z^2 - x^2 + 1)*abs(z) - (cos(theta) - 1)*x*z^2)/z      (sin(theta)*x*abs(z) - (cos(theta) - 1)*z^2*sqrt(-z^2 - x^2 + 1))/z                                        (1 - cos(theta))*z^2 + cos(theta)]
    218216           
    219217        Re-expressing some entries in terms of y and resolving the absolute
    220218        values introduced by eliminating y, we get the desired result.