I'm having the strangest behavior with an object generated by numpy.arange
:
for i in numpy.arange(xo, xn+h, h):
xs.append(float(i))
In this case, xo=1
, xn=4
, h=0.1
.
Now, I expected xs[-1]
to be exactly equal to 4.0
== float(4)
. However, I get the following:
>>> foo = xs[-1]
>>> foo == float(4)
False
>>> float(foo) == float(4)
False
>>> foo
4.0
>>> type(foo)
<type 'float'>
>>> int(sympy.ceiling(4.0)), int(sympy.ceiling(foo))
4 5
What on earth is happening here?
Placing print type(i)
in the for
loop prints <type 'numpy.float64'>
. Perhaps something going on during the float(i)
casting? Using numpy.asscalar
doesn't change anything.
Using math.ceil(foo)
instead of sympy.ceiling(foo)
issues the same thing (that's the part I actually need to work).