(&self, vm: &VirtualMachine)
| 357 | |
| 358 | #[pymethod] |
| 359 | fn as_integer_ratio(&self, vm: &VirtualMachine) -> PyResult<(PyIntRef, PyIntRef)> { |
| 360 | let value = self.value; |
| 361 | |
| 362 | float_to_ratio(value) |
| 363 | .map(|(numer, denom)| (vm.ctx.new_bigint(&numer), vm.ctx.new_bigint(&denom))) |
| 364 | .ok_or_else(|| { |
| 365 | if value.is_infinite() { |
| 366 | vm.new_overflow_error("cannot convert Infinity to integer ratio") |
| 367 | } else if value.is_nan() { |
| 368 | vm.new_value_error("cannot convert NaN to integer ratio") |
| 369 | } else { |
| 370 | unreachable!("finite float must able to convert to integer ratio") |
| 371 | } |
| 372 | }) |
| 373 | } |
| 374 | |
| 375 | #[pyclassmethod] |
| 376 | fn from_number(cls: PyTypeRef, number: PyObjectRef, vm: &VirtualMachine) -> PyResult { |
nothing calls this directly
no test coverage detected