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

Function _fix_real_lt_zero

numpy/lib/scimath.py:112–137  ·  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 -------- >>> np.lib.scimath._fix_real_lt_zero([1,2])

(x)

Source from the content-addressed store, hash-verified

110
111
112def _fix_real_lt_zero(x):
113 """Convert `x` to complex if it has real, negative components.
114
115 Otherwise, output is just the array version of the input (via asarray).
116
117 Parameters
118 ----------
119 x : array_like
120
121 Returns
122 -------
123 array
124
125 Examples
126 --------
127 >>> np.lib.scimath._fix_real_lt_zero([1,2])
128 array([1, 2])
129
130 >>> np.lib.scimath._fix_real_lt_zero([-1,2])
131 array([-1.+0.j, 2.+0.j])
132
133 """
134 x = asarray(x)
135 if any(isreal(x) & (x < 0)):
136 x = _tocomplex(x)
137 return x
138
139
140def _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