Address clippy::float_cmp issues
This commit is contained in:
parent
f008c569a6
commit
6b4a221d61
|
@ -706,6 +706,7 @@ mod test {
|
|||
assert_eq!(buffer.to_vec::<u8>(py).unwrap(), b"abcde");
|
||||
}
|
||||
|
||||
#[allow(clippy::float_cmp)] // The test wants to ensure that no precision was lost on the Python round-trip
|
||||
#[test]
|
||||
fn test_array_buffer() {
|
||||
let gil = Python::acquire_gil();
|
||||
|
|
|
@ -196,6 +196,7 @@ mod complex_conversion {
|
|||
complex_conversion!(f32);
|
||||
complex_conversion!(f64);
|
||||
|
||||
#[allow(clippy::float_cmp)] // The test wants to ensure that no precision was lost on the Python round-trip
|
||||
#[test]
|
||||
fn from_complex() {
|
||||
let gil = Python::acquire_gil();
|
||||
|
@ -230,11 +231,13 @@ mod test {
|
|||
|
||||
#[test]
|
||||
fn test_from_double() {
|
||||
use assert_approx_eq::assert_approx_eq;
|
||||
|
||||
let gil = Python::acquire_gil();
|
||||
let py = gil.python();
|
||||
let complex = PyComplex::from_doubles(py, 3.0, 1.2);
|
||||
assert_eq!(complex.real(), 3.0);
|
||||
assert_eq!(complex.imag(), 1.2);
|
||||
assert_approx_eq!(complex.real(), 3.0);
|
||||
assert_approx_eq!(complex.imag(), 1.2);
|
||||
}
|
||||
|
||||
#[cfg(not(Py_LIMITED_API))]
|
||||
|
|
|
@ -91,11 +91,13 @@ mod test {
|
|||
($func_name:ident, $t1:ty, $t2:ty) => (
|
||||
#[test]
|
||||
fn $func_name() {
|
||||
use assert_approx_eq::assert_approx_eq;
|
||||
|
||||
let gil = Python::acquire_gil();
|
||||
let py = gil.python();
|
||||
let val = 123 as $t1;
|
||||
let obj = val.to_object(py);
|
||||
assert_eq!(obj.extract::<$t2>(py).unwrap(), val as $t2);
|
||||
assert_approx_eq!(obj.extract::<$t2>(py).unwrap(), val as $t2);
|
||||
}
|
||||
)
|
||||
);
|
||||
|
@ -106,10 +108,12 @@ mod test {
|
|||
|
||||
#[test]
|
||||
fn test_as_double_macro() {
|
||||
use assert_approx_eq::assert_approx_eq;
|
||||
|
||||
let gil = Python::acquire_gil();
|
||||
let py = gil.python();
|
||||
let v = 1.23f64;
|
||||
let obj = v.to_object(py);
|
||||
assert_eq!(v, unsafe { PyFloat_AS_DOUBLE(obj.as_ptr()) });
|
||||
assert_approx_eq!(v, unsafe { PyFloat_AS_DOUBLE(obj.as_ptr()) });
|
||||
}
|
||||
}
|
||||
|
|
|
@ -102,6 +102,7 @@ fn test_delta_check() {
|
|||
|
||||
#[test]
|
||||
fn test_datetime_utc() {
|
||||
use assert_approx_eq::assert_approx_eq;
|
||||
use pyo3::types::PyDateTime;
|
||||
|
||||
let gil = Python::acquire_gil();
|
||||
|
@ -120,7 +121,7 @@ fn test_datetime_utc() {
|
|||
.unwrap()
|
||||
.extract()
|
||||
.unwrap();
|
||||
assert_eq!(offset, 0f32);
|
||||
assert_approx_eq!(offset, 0f32);
|
||||
}
|
||||
|
||||
#[cfg(Py_3_6)]
|
||||
|
|
Loading…
Reference in New Issue