Skip to content

Update to PyO3 0.16, num-bigint 0.4, num-rational 0.4 #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ crate-type = ["rlib", "cdylib"]

[dependencies]
num-traits = "0.2"
num-bigint = "0.2"
num-bigint = "0.4"
num-integer = "0.1"
num-rational = "0.2"
num-rational = "0.4"
rand = "0.5"
rand_pcg = "0.1.1"
lazy_static = "1.4"

[dependencies.pyo3]
version = "0.9.0"
version = "0.16"
optional = true
features = ["num-bigint"]
17 changes: 4 additions & 13 deletions src/lattice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ where
mod tests {
use super::*;
use num_bigint::BigInt;
use num_traits::{One, Pow};
use num_traits::One;

#[test]
fn test_gram_schmidt() {
Expand Down Expand Up @@ -281,16 +281,6 @@ mod tests {
assert!(output == expected);
}

// workaround for https://github.com/rust-num/num-bigint/issues/106
fn pow<'a, T>(base: &'a Ratio<BigInt>, exponent: &'a T) -> Ratio<BigInt>
where
&'a BigInt: Pow<&'a T, Output = BigInt>,
{
let numer = base.numer().pow(exponent);
let denom = base.denom().pow(exponent);
Ratio::new(numer, denom)
}

#[test]
fn test_lll_reduce() {
let ints = |v: &[i64]| -> Vec<BigInt> { v.iter().copied().map(BigInt::from).collect() };
Expand Down Expand Up @@ -324,7 +314,7 @@ mod tests {
assert!(output == expected);

// find the minimal polynomial of sin(pi / 7)
let multiplier = BigInt::from(1) << 48;
let multiplier = BigInt::one() << 48i32;
// approximation to 1024 fractional bits
let sin_pi_7_approximation: Ratio<BigInt> =
"97498727392503287796421964844598099607650972550809391824625445149289352\
Expand All @@ -348,7 +338,8 @@ mod tests {
BigInt::zero()
}
} else {
-pow(&sin_pi_7_approximation, &x)
-(&sin_pi_7_approximation)
.pow(x as i32)
.mul(&multiplier)
.round()
.to_integer()
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub use algebraic_numbers::RealAlgebraicNumber;
macro_rules! doctest {
($x:expr) => {
#[doc = $x]
extern {}
extern "C" {}
};
}

Expand Down
Loading