flopscope.

flopscope.numpy.isrealobj

Return True if x is a not complex type or an array of complex numbers.

Adapted from NumPy docs np.isrealobj

Areacore
Typecounted
NumPy Refnp.isrealobj
Cost
numel(output)\text{numel}(\text{output})
Flopscope Context

Return True if x is a not complex type or array.

The type of the input is checked, not the value. So even if the input has an imaginary part equal to zero, isrealobj evaluates to False if the data type is complex.

Parameters

x:any

The input can be of any type and shape.

Returns

y:bool

The return value, False if x is of a complex type.

See also

Notes

The function is only meant for arrays with numerical values but it accepts all other objects. Since it assumes array input, the return value of other objects may be True.

>>> flops.isrealobj('A string')
True
>>> flops.isrealobj(False)
True
>>> flops.isrealobj(None)
True

Examples

>>> import flopscope.numpy as fnp
>>> flops.isrealobj(1)
True
>>> flops.isrealobj(1+0j)
False
>>> flops.isrealobj([3, 1+0j, True])
False