integral of piecewise function: error
I get a weird error when trying to take an integral of a very simple piecewise function:
blah = piecewise([((0, 0.01), 0.0001), ([0.01, 0.02], 0.0002), ((0.02, 0.03), 0.0003)])
blah.integral(x, 0.01, 0.025)
gives:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-132-73d5f18533d2> in <module>()
1 blah = piecewise([((Integer(0), RealNumber('0.01')), RealNumber('0.0001')), ([RealNumber('0.01'), RealNumber('0.02')], RealNumber('0.0002')), ((RealNumber('0.02'), RealNumber('0.03')), RealNumber('0.0003')), ([RealNumber('0.03'), RealNumber('0.04')], RealNumber('0.0004'))])
----> 2 blah.integral(x, RealNumber('0.01'), RealNumber('0.025'))
/home/sschyman/Programs/sage-upgrade/local/lib/python2.7/site-packages/sage/symbolic/function_factory.pyc in new_f(ex, *args, **kwds)
400 new_args = list(ex._unpack_operands())
401 new_args.extend(args)
--> 402 return f(ex, *new_args, **kwds)
403 return new_f
/home/sschyman/Programs/sage-upgrade/local/lib/python2.7/site-packages/sage/functions/piecewise.pyc in integral(cls, self, parameters, variable, x, a, b, definite)
793 """
794 if a != None and b != None:
--> 795 F = self.integral(x)
796 return F(b) - F(a)
797
/home/sschyman/Programs/sage-upgrade/local/lib/python2.7/site-packages/sage/symbolic/function_factory.pyc in new_f(ex, *args, **kwds)
400 new_args = list(ex._unpack_operands())
401 new_args.extend(args)
--> 402 return f(ex, *new_args, **kwds)
403 return new_f
/home/sschyman/Programs/sage-upgrade/local/lib/python2.7/site-packages/sage/functions/piecewise.pyc in integral(cls, self, parameters, variable, x, a, b, definite)
828 else:
829 try:
--> 830 assume(start < x)
831 except ValueError: # Assumption is redundant
832 pass
/home/sschyman/Programs/sage-upgrade/local/lib/python2.7/site-packages/sage/symbolic/assumptions.pyc in assume(*args)
513 else:
514 try:
--> 515 x.assume()
516 except KeyError:
517 raise TypeError("assume not defined for objects of type '%s'"%type(x))
AttributeError: 'numpy.bool_' object has no attribute 'assume'
Is this a bug or did I make a mistake?
UPDATE: I uploaded an example to SMC: https://cloud.sagemath.com/projects/3...
I don't get this error. Posting the whole traceback may help. Can you try this in a brand-new session of Sage?
No error in this live example either...
Thanks for checking!! Well, if I restart the notebook and run the above code, I also don't get an error message. Only if I run the whole worksheet and execute the same code towards the end, I get the error message. Maybe there is a memory problem or I re-defined something somewhere... I will edit my above comment to include the full error message, perhaps you see something there that I don't.