Use 2021 edition for inlined format args

This commit is contained in:
Dirkjan Ochtman 2023-01-27 10:15:23 +01:00
parent 88d66186da
commit 91f67b77c4
4 changed files with 13 additions and 11 deletions

View File

@ -2,7 +2,8 @@
name = "instant-distance-py" name = "instant-distance-py"
version = "0.3.2" version = "0.3.2"
authors = ["Dirkjan Ochtman <dirkjan@ochtman.nl>"] authors = ["Dirkjan Ochtman <dirkjan@ochtman.nl>"]
edition = "2018" edition = "2021"
rust-version = "1.58"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
workspace = ".." workspace = ".."
description = "Fast minimal implementation of HNSW maps for approximate nearest neighbors searches" description = "Fast minimal implementation of HNSW maps for approximate nearest neighbors searches"

View File

@ -58,7 +58,7 @@ impl HnswMap {
bincode::deserialize_from::<_, instant_distance::HnswMap<FloatArray, MapValue>>( bincode::deserialize_from::<_, instant_distance::HnswMap<FloatArray, MapValue>>(
BufReader::with_capacity(32 * 1024 * 1024, File::open(fname)?), BufReader::with_capacity(32 * 1024 * 1024, File::open(fname)?),
) )
.map_err(|e| PyValueError::new_err(format!("deserialization error: {:?}", e)))?; .map_err(|e| PyValueError::new_err(format!("deserialization error: {e:?}")))?;
Ok(Self { inner: hnsw_map }) Ok(Self { inner: hnsw_map })
} }
@ -66,7 +66,7 @@ impl HnswMap {
fn dump(&self, fname: &str) -> PyResult<()> { fn dump(&self, fname: &str) -> PyResult<()> {
let f = BufWriter::with_capacity(32 * 1024 * 1024, File::create(fname)?); let f = BufWriter::with_capacity(32 * 1024 * 1024, File::create(fname)?);
bincode::serialize_into(f, &self.inner) bincode::serialize_into(f, &self.inner)
.map_err(|e| PyValueError::new_err(format!("serialization error: {:?}", e)))?; .map_err(|e| PyValueError::new_err(format!("serialization error: {e:?}")))?;
Ok(()) Ok(())
} }
@ -115,7 +115,7 @@ impl Hnsw {
let hnsw = bincode::deserialize_from::<_, instant_distance::Hnsw<FloatArray>>( let hnsw = bincode::deserialize_from::<_, instant_distance::Hnsw<FloatArray>>(
BufReader::with_capacity(32 * 1024 * 1024, File::open(fname)?), BufReader::with_capacity(32 * 1024 * 1024, File::open(fname)?),
) )
.map_err(|e| PyValueError::new_err(format!("deserialization error: {:?}", e)))?; .map_err(|e| PyValueError::new_err(format!("deserialization error: {e:?}")))?;
Ok(Self { inner: hnsw }) Ok(Self { inner: hnsw })
} }
@ -123,7 +123,7 @@ impl Hnsw {
fn dump(&self, fname: &str) -> PyResult<()> { fn dump(&self, fname: &str) -> PyResult<()> {
let f = BufWriter::with_capacity(32 * 1024 * 1024, File::create(fname)?); let f = BufWriter::with_capacity(32 * 1024 * 1024, File::create(fname)?);
bincode::serialize_into(f, &self.inner) bincode::serialize_into(f, &self.inner)
.map_err(|e| PyValueError::new_err(format!("serialization error: {:?}", e)))?; .map_err(|e| PyValueError::new_err(format!("serialization error: {e:?}")))?;
Ok(()) Ok(())
} }

View File

@ -3,7 +3,8 @@ name = "instant-distance"
version = "0.6.0" version = "0.6.0"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
authors = ["Dirkjan Ochtman <dirkjan@ochtman.nl>"] authors = ["Dirkjan Ochtman <dirkjan@ochtman.nl>"]
edition = "2018" edition = "2021"
rust-version = "1.58"
description = "Fast minimal implementation of HNSW maps for approximate nearest neighbors searches" description = "Fast minimal implementation of HNSW maps for approximate nearest neighbors searches"
homepage = "https://github.com/InstantDomain/instant-distance" homepage = "https://github.com/InstantDomain/instant-distance"
repository = "https://github.com/InstantDomain/instant-distance" repository = "https://github.com/InstantDomain/instant-distance"

View File

@ -16,7 +16,7 @@ fn map() {
let values = vec!["zero", "one", "two", "three", "four"]; let values = vec!["zero", "one", "two", "three", "four"];
let seed = ThreadRng::default().gen::<u64>(); let seed = ThreadRng::default().gen::<u64>();
println!("map (seed = {})", seed); println!("map (seed = {seed})");
let map = Builder::default().seed(seed).build(points, values); let map = Builder::default().seed(seed).build(points, values);
let mut search = Search::default(); let mut search = Search::default();
@ -42,15 +42,15 @@ fn map() {
#[test] #[test]
fn random_heuristic() { fn random_heuristic() {
let (seed, recall) = randomized(Builder::default()); let (seed, recall) = randomized(Builder::default());
println!("heuristic (seed = {}) recall = {}", seed, recall); println!("heuristic (seed = {seed}) recall = {recall}");
assert!(recall > 97, "expected at least 98, got {}", recall); assert!(recall > 97, "expected at least 98, got {recall}");
} }
#[test] #[test]
fn random_simple() { fn random_simple() {
let (seed, recall) = randomized(Builder::default().select_heuristic(None)); let (seed, recall) = randomized(Builder::default().select_heuristic(None));
println!("simple (seed = {}) recall = {}", seed, recall); println!("simple (seed = {seed}) recall = {recall}");
assert!(recall > 90, "expected at least 90, got {}", recall); assert!(recall > 90, "expected at least 90, got {recall}");
} }
fn randomized(builder: Builder) -> (u64, usize) { fn randomized(builder: Builder) -> (u64, usize) {