(v1: Complex64, v2: Complex64, vm: &VirtualMachine)
| 151 | } |
| 152 | |
| 153 | fn inner_pow(v1: Complex64, v2: Complex64, vm: &VirtualMachine) -> PyResult<Complex64> { |
| 154 | if v1.is_zero() { |
| 155 | return if v2.re < 0.0 || v2.im != 0.0 { |
| 156 | let msg = format!("{v1} cannot be raised to a negative or complex power"); |
| 157 | Err(vm.new_zero_division_error(msg)) |
| 158 | } else if v2.is_zero() { |
| 159 | Ok(Complex64::new(1.0, 0.0)) |
| 160 | } else { |
| 161 | Ok(Complex64::new(0.0, 0.0)) |
| 162 | }; |
| 163 | } |
| 164 | |
| 165 | let ans = powc(v1, v2); |
| 166 | if ans.is_infinite() && !(v1.is_infinite() || v2.is_infinite()) { |
| 167 | Err(vm.new_overflow_error("complex exponentiation overflow")) |
| 168 | } else { |
| 169 | Ok(ans) |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | // num-complex changed their powc() implementation in 0.4.4, making it incompatible |
| 174 | // with what the regression tests expect. this is that old formula. |
nothing calls this directly
no test coverage detected