Zero division error!
tim.hochberg at ieee.org
Thu Aug 2 20:04:04 CEST 2001
"Prem Rachakonda" <prem at engr.uky.edu> wrote in message
news:Pine.LNX.4.21.0108021330570.19621-100000 at seahawk.ecc.engr.uky.edu...
> I am writing a script for 'cubic spline interpolation' and when there is
> a float value = 0.004, it is rounded off to zero and I am getting a Zero
> Division error. Is it a python bug?
> x=array([2.056, 2.06, 2.064, 2.068, 2.072, 2.076, 2.08, 2.084, 2.088,
> 2.092, 2.096, 2.1, 2.104])
> Here d is 0.004(equally spaced points) and is being considered as 0 and
> I am getting this error.
You haven't posted enough code to be sure, but I'm going to make some
(1) array is Numeric.array
(2) d is created in a way similar to zeros([N])
If that's the case, what happening is that d is an array of ints, not floats
(int is the default). That means that when attributes are set using floats,
they are silently truncated to ints in the array. This is somewhat of a
misfeature of Numeric in my opinion, but I don't think it's actually a bug.
Assuming that your are actually using zeros to create d, you could use
Numeric.zeros([N], Numeric.Float) instead.
Then again, this is all a guess.
More information about the Python-list