Return True if x is a not complex type or an array of complex numbers. 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
(x)
| 342 | |
| 343 | @array_function_dispatch(_is_type_dispatcher) |
| 344 | def isrealobj(x): |
| 345 | """ |
| 346 | Return True if x is a not complex type or an array of complex numbers. |
| 347 | |
| 348 | The type of the input is checked, not the value. So even if the input |
| 349 | has an imaginary part equal to zero, `isrealobj` evaluates to False |
| 350 | if the data type is complex. |
| 351 | |
| 352 | Parameters |
| 353 | ---------- |
| 354 | x : any |
| 355 | The input can be of any type and shape. |
| 356 | |
| 357 | Returns |
| 358 | ------- |
| 359 | y : bool |
| 360 | The return value, False if `x` is of a complex type. |
| 361 | |
| 362 | See Also |
| 363 | -------- |
| 364 | iscomplexobj, isreal |
| 365 | |
| 366 | Notes |
| 367 | ----- |
| 368 | The function is only meant for arrays with numerical values but it |
| 369 | accepts all other objects. Since it assumes array input, the return |
| 370 | value of other objects may be True. |
| 371 | |
| 372 | >>> np.isrealobj('A string') |
| 373 | True |
| 374 | >>> np.isrealobj(False) |
| 375 | True |
| 376 | >>> np.isrealobj(None) |
| 377 | True |
| 378 | |
| 379 | Examples |
| 380 | -------- |
| 381 | >>> np.isrealobj(1) |
| 382 | True |
| 383 | >>> np.isrealobj(1+0j) |
| 384 | False |
| 385 | >>> np.isrealobj([3, 1+0j, True]) |
| 386 | False |
| 387 | |
| 388 | """ |
| 389 | return not iscomplexobj(x) |
| 390 | |
| 391 | #----------------------------------------------------------------------------- |
| 392 |