MCPcopy Create free account
hub / github.com/numpy/numpy / iscomplexobj

Function iscomplexobj

numpy/lib/type_check.py:303–340  ·  view source on GitHub ↗

Check for a complex type or an array of complex numbers. The type of the input is checked, not the value. Even if the input has an imaginary part equal to zero, `iscomplexobj` evaluates to True. Parameters ---------- x : any The input can be of any type and shape.

(x)

Source from the content-addressed store, hash-verified

301
302@array_function_dispatch(_is_type_dispatcher)
303def iscomplexobj(x):
304 """
305 Check for a complex type or an array of complex numbers.
306
307 The type of the input is checked, not the value. Even if the input
308 has an imaginary part equal to zero, `iscomplexobj` evaluates to True.
309
310 Parameters
311 ----------
312 x : any
313 The input can be of any type and shape.
314
315 Returns
316 -------
317 iscomplexobj : bool
318 The return value, True if `x` is of a complex type or has at least
319 one complex element.
320
321 See Also
322 --------
323 isrealobj, iscomplex
324
325 Examples
326 --------
327 >>> np.iscomplexobj(1)
328 False
329 >>> np.iscomplexobj(1+0j)
330 True
331 >>> np.iscomplexobj([3, 1+0j, True])
332 True
333
334 """
335 try:
336 dtype = x.dtype
337 type_ = dtype.type
338 except AttributeError:
339 type_ = asarray(x).dtype.type
340 return issubclass(type_, _nx.complexfloating)
341
342
343@array_function_dispatch(_is_type_dispatcher)

Callers 12

test_basicMethod · 0.90
test_scalarMethod · 0.90
test_listMethod · 0.90
test_duckMethod · 0.90
test_pandas_duckMethod · 0.90
test_basicMethod · 0.90
varMethod · 0.90
assert_equalFunction · 0.90
assert_almost_equalFunction · 0.90
isrealobjFunction · 0.85
common_typeFunction · 0.85

Calls 1

asarrayFunction · 0.50

Tested by 7

test_basicMethod · 0.72
test_scalarMethod · 0.72
test_listMethod · 0.72
test_duckMethod · 0.72
test_pandas_duckMethod · 0.72
test_basicMethod · 0.72