You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importsympyimportnumpyi=sympy.var('i', integer=True)
# lambdify function with integer division (//)f=i//3lf=sympy.lambdify(i, f, modules='numpy')
# map to array of integerslf(numpy.arange(0, 10, dtype='int64'))
while the integer division is correctly done with floor and /, this gives an array of floats (array([0., 0., 0., 1., 1., 1., 2., 2., 2., 3.])), but I would expect an array of integers (array([0, 0, 0, 1, 1, 1, 2, 2, 2, 3])) as i is an integer, // gives an integer and the input datatype is also an integer. Is there anyway to force returned types?
The text was updated successfully, but these errors were encountered:
If you want to force the returned type, you can use numpy.vectorize(sympy.lambdify(i,f, modules='numpy'),otypes=[int]), you can set the output data type using otype parameter.
while the integer division is correctly done with
floor
and/
, this gives an array of floats (array([0., 0., 0., 1., 1., 1., 2., 2., 2., 3.])
), but I would expect an array of integers (array([0, 0, 0, 1, 1, 1, 2, 2, 2, 3])
) asi
is an integer,//
gives an integer and the input datatype is also an integer. Is there anyway to force returned types?The text was updated successfully, but these errors were encountered: