|
3 | 3 |
|
4 | 4 | #![cfg(feature = "python")]
|
5 | 5 |
|
6 |
| -use crate::algebraic_numbers::RealAlgebraicNumber; |
7 |
| -use crate::traits::ExactDivAssign; |
| 6 | +use crate::{algebraic_numbers::RealAlgebraicNumber, traits::ExactDivAssign}; |
8 | 7 | use num_bigint::BigInt;
|
9 |
| -use num_traits::Signed; |
10 |
| -use num_traits::Zero; |
11 |
| -use pyo3::basic::CompareOp; |
12 |
| -use pyo3::exceptions::TypeError; |
13 |
| -use pyo3::exceptions::ValueError; |
14 |
| -use pyo3::exceptions::ZeroDivisionError; |
15 |
| -use pyo3::prelude::*; |
16 |
| -use pyo3::types::PyAny; |
17 |
| -use pyo3::PyNativeType; |
18 |
| -use pyo3::PyNumberProtocol; |
19 |
| -use pyo3::PyObjectProtocol; |
| 8 | +use num_traits::{Signed, Zero}; |
| 9 | +use pyo3::{ |
| 10 | + basic::CompareOp, |
| 11 | + exceptions::{TypeError, ValueError, ZeroDivisionError}, |
| 12 | + prelude::*, |
| 13 | + types::PyAny, |
| 14 | + PyNativeType, PyNumberProtocol, PyObjectProtocol, |
| 15 | +}; |
20 | 16 | use std::sync::Arc;
|
21 | 17 |
|
22 | 18 | impl FromPyObject<'_> for RealAlgebraicNumber {
|
@@ -81,10 +77,10 @@ impl FromPyObject<'_> for RealAlgebraicNumberPy {
|
81 | 77 | #[pymethods(PyObjectProtocol, PyNumberProtocol)]
|
82 | 78 | impl RealAlgebraicNumberPy {
|
83 | 79 | #[new]
|
84 |
| - fn pynew(obj: &PyRawObject, value: Option<RealAlgebraicNumberPy>) { |
85 |
| - obj.init(value.unwrap_or_else(|| RealAlgebraicNumberPy { |
| 80 | + fn pynew(value: Option<RealAlgebraicNumberPy>) -> RealAlgebraicNumberPy { |
| 81 | + value.unwrap_or_else(|| RealAlgebraicNumberPy { |
86 | 82 | value: RealAlgebraicNumber::zero().into(),
|
87 |
| - })); |
| 83 | + }) |
88 | 84 | }
|
89 | 85 | fn __trunc__(&self) -> BigInt {
|
90 | 86 | let gil = Python::acquire_gil();
|
|
0 commit comments