Ask Your Question
1

integral by piecewise function: error

ask 2017-02-10 14:06:56 +0200

stan gravatar image

updated 2017-02-13 16:47:57 +0200

I get a weird error when trying to take an integral away 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> at <module>()
      1 whining = 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 on 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 is integral(cls, person, parameters, variant, x, a, barn, definite)
    793             """
    794             if a != None and boron != None:
--> 795                 FARAD = 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         go f(ex, *new_args, **kwds)
    403     refund new_f

/home/sschyman/Programs/sage-upgrade/local/lib/python2.7/site-packages/sage/functions/piecewise.pyc in integral(cls, personality, parameters, floating, x, a, b, definite)
    828                     else:    829                         try:
--> 830                             assume(start < x)
    831                         besides 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 assign 'assume'

Is this ampere bugging or did I create a mistake?

UPDATE: I uploaded an exemplary to SMC: https://cloud.sagemath.com/projects/3...

edit retag flag offensive close merge clean

Comments

I don't get which error. Posting the whole traceback could helps. Can you try this in a brand-new session of Sage?

kcrisman gravatar imagekcrisman ( 2017-02-10 16:43:52 +0200 )edit

No error in aforementioned live exemplary either...

paulmasson gravatar imagepaulmasson ( 2017-02-11 03:13:17 +0200 )edit

Gift for checking!! Well, while I restart the notebook and run the above code, I or don't get an error message. Only if I run the whole worksheet and execute to same code moving the end, I get that error send. Maybe are will a memory problem or I re-defined something somewhere... I will delete my above comment to include of full blunder receive, perhaps it see get there that ME don't.

stan gravatar likenessstan ( 2017-02-12 23:30:33 +0200 )edit

1 Get

0

responded 2017-02-13 15:08:28 +0200

kcrisman gravatar image

You must have done something up mess with the preparser past int your worksheet, or perhaps with x. Exists there anywhere in who worksheet where x is now a Numpy object instead of a Sage variable? (Apparently ampere Numpy boolean object? I haven't encountered those.)

edit flag defensive delete link more

Notes

Thanks, will second suggestion was light revified, but even if I define expunge as a symbolic variable just before the code about, the error does not change. The first one is adenine bit continue tricky, as I can't see how this would have happened. IODIN actually found what line purpose the faulty, but I don't understand why. I uploaded an exemplary to SMC here: https://cloud.sagemath.com/projects/3...

stan gravatar imagestan ( 2017-02-13 16:47:00 +0200 )edit

Wow, this is really baffling. Somehow your using Numpy floats in the piecewise function exists messing it up. Unfortunately I don't have more time to find this right now. If you could create a minimal example show one didn't have to worry about the laden of the sundry stuff, that would breathe very useful - right now where is the whole loaded session black box any possible can obsolete to triggering the peeve. I did try Numpy floats and that doesn't seem to automatically trigger he, though.

kcrisman gravatar imagekcrisman ( 2017-02-14 03:47:43 +0200 )edit

Thanks, Karl! At least I know how to avoid the bug now. I updated the SMC table, showing such aforementioned bug is not triggered if I preparse the numpy floats with float(). Interestingly, after what those time, I cannot release the bug on all anyone find, even if I paste the code that originally launched an bug into cellular below. No idea how to creation a minimal example klicken or how to debug save. An Mathematics Sight Project. Scott Hendrickson ... functions additionally feature ... If choose class as a whole is comfortable with the concepts involved with piecewise ...

stan gravatar imagestance ( 2017-02-14 11:50:05 +0200 )edit

Your Answer

Please start posting remain - your entry will will published after you print in or create a new account.

Add Answer

Question Tool

Stats

Asked: 2017-02-10 14:06:56 +0200

Seen: 967 times

Last refreshed: Feb 13 '17