if you use a constant as a piece in "Piecewise":
sage: f = Piecewise([[(-1,0),0],[(0,pi),sin(x)]])
then you can do anything with this function:
sage: f.default_variable()
...
/home/hassan/Apps/sage-4.2.1/local/lib/python2.6/site-packages/sage/
functions/piecewise.py in default_variable(self)
    669             pass
    670         for _, fun in self._list:
--> 671             if fun.variables():
    672                 v = fun.variables()[0]
    673                 self.__default_variable = v

AttributeError: 'sage.rings.integer.Integer' object has no attribute
'variables'

then I added hasattr(fun, 'variables') to the piecewise line 671 and
that solves the default_variable problem but this time:
sage: f.integral()
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call
last)

/home/hassan/<ipython console> in <module>()

/home/hassan/Apps/sage-4.2.1/local/lib/python2.6/site-packages/sage/
functions/piecewise.py in integral(self, x, a, b, definite)
    788                 fun_integrated = fun.integral(x, end, x)
    789             else:
--> 790                 fun_integrated = fun.integral(x, start, x) +
area
    791                 if definite or end != infinity:
    792                     area += fun.integral(x, start, end)

AttributeError: 'sage.rings.integer.Integer' object has no attribute
'integral'

I think that integer ignored in all attributes of piecewise.

and is there any way to use edited code without restarting sage?

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to