MCPcopy Index your code
hub / github.com/numpy/numpy / _fix_real_lt_zero

Function _fix_real_lt_zero

numpy/lib/_scimath_impl.py:96–122  ·  view source on GitHub ↗

Convert `x` to complex if it has real, negative components. Otherwise, output is just the array version of the input (via asarray). Parameters ---------- x : array_like Returns ------- array Examples -------- >>> import numpy as np >>> np.lib.scimath._

(x)

Source from the content-addressed store, hash-verified

94
95
96def _fix_real_lt_zero(x):
97 """Convert `x` to complex if it has real, negative components.
98
99 Otherwise, output is just the array version of the input (via asarray).
100
101 Parameters
102 ----------
103 x : array_like
104
105 Returns
106 -------
107 array
108
109 Examples
110 --------
111 >>> import numpy as np
112 >>> np.lib.scimath._fix_real_lt_zero([1,2])
113 array([1, 2])
114
115 >>> np.lib.scimath._fix_real_lt_zero([-1,2])
116 array([-1.+0.j, 2.+0.j])
117
118 """
119 x = asarray(x)
120 if any(isreal(x) & (x < 0)):
121 x = _tocomplex(x)
122 return x
123
124
125def _fix_int_lt_zero(x):

Callers 6

sqrtFunction · 0.85
logFunction · 0.85
log10Function · 0.85
lognFunction · 0.85
log2Function · 0.85
powerFunction · 0.85

Calls 4

anyFunction · 0.90
isrealFunction · 0.90
_tocomplexFunction · 0.85
asarrayFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…