mars.tensor.modf

mars.tensor.modf(x, out1=None, out2=None, out=None, where=None, **kwargs)[source]

Return the fractional and integral parts of a tensor, element-wise.

The fractional and integral parts are negative if the given number is negative.

x : array_like
Input tensor.
out : Tensor, None, or tuple of Tensor and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated tensor is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
where : array_like, optional
Values of True indicate to calculate the ufunc at that position, values of False indicate to leave the value in the output alone.

**kwargs

y1 : Tensor
Fractional part of x.
y2 : Tensor
Integral part of x.

For integer input the return values are floats.

divmod : divmod(x, 1) is equivalent to modf with the return values
switched, except it always has a positive remainder.
>>> import mars.tensor as mt
>>> from mars.session import new_session
>>> sess = new_session().as_default()
>>> sess.run(mt.modf([0, 3.5]))
(array([ 0. ,  0.5]), array([ 0.,  3.]))
>>> sess.run(mt.modf(-0.5))
(-0.5, -0)