# xarray.ufuncs.isreal

### xarray.ufuncs.isreal *= <xarray.ufuncs._unary_ufunc object>*

xarray specific variant of [`numpy.isreal()`](https://numpy.org/doc/stable/reference/generated/numpy.isreal.html#numpy.isreal). Handles xarray objects by dispatching to the appropriate function for the underlying array type.

Documentation from numpy:

Returns a bool array, where True if input element is real.

If element has complex type with zero imaginary part, the return value
for that element is True.

* **Parameters:**
  **x** ([array_like](https://numpy.org/doc/stable/glossary.html#term-array_like)) – Input array.
* **Returns:**
  **out** ([`ndarray`](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray), [`bool`](https://docs.python.org/3/builtins/functions.html#bool)) – Boolean array of same shape as x.

### Notes

isreal may behave unexpectedly for string or object arrays (see examples)

#### SEE ALSO
[`iscomplex`](xarray.ufuncs.iscomplex.html.md#xarray.ufuncs.iscomplex)

`isrealobj`
: Return True if x is not a complex type.

### Examples

<div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesShowIframe('0623888a-ff98-45e8-bf4f-908a4b35085e','2cbfc5ea-0c41-48e2-9ea5-d80ba969737b','62ed7b95-3852-4201-a48d-29b5ff96f6be','../lite/tree/../notebooks/index.html?path=a193c6ad_4891_4a8a_871c_1aaa41586b80.ipynb','None')">Try it in your browser!</button></div>
```pycon
>>> import numpy as np
>>> a = np.array([1+1j, 1+0j, 4.5, 3, 2, 2j], dtype=np.complex128)
>>> np.isreal(a)
array([False,  True,  True,  True,  True, False])
```

The function does not work on string arrays.

```pycon
>>> a = np.array([2j, "a"], dtype=np.str_)
>>> np.isreal(a)  # returns the result of `"" == 0` currently.
array([False, False])
```

Returns True for all elements that either have no `.imag` attribute
or for which that attribute is zero:

```pycon
>>> a = np.array([1, "2", 3+4j], dtype=np.object_)
>>> np.isreal(a)
array([ True,  True,  False])
```

<div id="62ed7b95-3852-4201-a48d-29b5ff96f6be" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('0623888a-ff98-45e8-bf4f-908a4b35085e','62ed7b95-3852-4201-a48d-29b5ff96f6be')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('0623888a-ff98-45e8-bf4f-908a4b35085e','62ed7b95-3852-4201-a48d-29b5ff96f6be')">Open In Tab</button></div><div id="2cbfc5ea-0c41-48e2-9ea5-d80ba969737b" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
