sfaletti / pycurve

Automatically exported from code.google.com/p/pycurve
0 stars 0 forks source link

ValueError: factorial() not defined for negative values #2

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. >>> B = Bezier([(0.0, 0.0), (0.0, 1.0), (1.0, 1.0)])
2. B(0.5) or any other value between 0 and 1

What is the expected output? What do you see instead?
not sure what to expect really, just testing...

what I get is a traceback which points to the _C() function...

What version of the product are you using? On what operating system?
not sure which revision this is...
I just typed everything in, and triple checked the code to make sure it matched 
100%
(everything matches)

using XP Black with py272, but I don't think that matters :P

Please provide any additional information below.

I think it might be because no verification is done when calling _C()

the inputs at the thrown error are
xrange(3)[-1] = 2 # n
for i in xrange(3): # for i in _n
i == 0
_C(0, 2) # _C(i, n)
factorial(0 - 2) >>> error

@ your outside Q:
why did I type everything in?
I'm limited to using my wii for net,
and this wasn't an outrageously huge task XD

Original issue reported on code.google.com by tcll5850 on 15 Apr 2013 at 12:23

GoogleCodeExporter commented 8 years ago
lets see if the 3rd time typing this works...

your Bezier call to _C() is reversed.

def _C(n, k): # _C(n, i)
for i in _n:
    _C(i, n)

Original comment by tcll5850 on 15 Apr 2013 at 12:52

GoogleCodeExporter commented 8 years ago
just tested the fix in blender,
and it appears to work perfectly ;)

Original comment by tcll5850 on 15 Apr 2013 at 1:11