diff --git a/codebase_rag/tests/test_rust_extension_packaging.py b/codebase_rag/tests/test_rust_extension_packaging.py index 774fffde51..b5a2f09517 100644 --- a/codebase_rag/tests/test_rust_extension_packaging.py +++ b/codebase_rag/tests/test_rust_extension_packaging.py @@ -30,13 +30,13 @@ # What maturin names each wheel rust-wheels.yml builds, plus the sdist a # release could also carry. PUBLISHED_FILES = [ - "cgr_graph_rs-0.1.3-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", - "cgr_graph_rs-0.1.3-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", - "cgr_graph_rs-0.1.3-cp312-abi3-musllinux_1_2_x86_64.whl", - "cgr_graph_rs-0.1.3-cp312-abi3-musllinux_1_2_aarch64.whl", - "cgr_graph_rs-0.1.3-cp312-abi3-macosx_10_13_x86_64.macosx_11_0_arm64.macosx_10_13_universal2.whl", - "cgr_graph_rs-0.1.3-cp312-abi3-win_amd64.whl", - "cgr_graph_rs-0.1.3.tar.gz", + "cgr_graph_rs-0.1.4-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", + "cgr_graph_rs-0.1.4-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", + "cgr_graph_rs-0.1.4-cp312-abi3-musllinux_1_2_x86_64.whl", + "cgr_graph_rs-0.1.4-cp312-abi3-musllinux_1_2_aarch64.whl", + "cgr_graph_rs-0.1.4-cp312-abi3-macosx_10_13_x86_64.macosx_11_0_arm64.macosx_10_13_universal2.whl", + "cgr_graph_rs-0.1.4-cp312-abi3-win_amd64.whl", + "cgr_graph_rs-0.1.4.tar.gz", ] # What a Python on each wheel's platform reports to environment markers. diff --git a/pyproject.toml b/pyproject.toml index 05c5c42f0a..17f830e348 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -72,7 +72,7 @@ dependencies = [ # abi3 wheels for exactly these platforms; elsewhere the engine runs its # Python twin of every part. The floor is the crate version this code # was written against, raised with each crate release. - "cgr-graph-rs>=0.1.3,<0.2; platform_python_implementation == 'CPython' and ((sys_platform == 'linux' and (platform_machine == 'x86_64' or platform_machine == 'aarch64')) or sys_platform == 'darwin' or (sys_platform == 'win32' and platform_machine == 'AMD64'))", + "cgr-graph-rs>=0.1.4,<0.2; platform_python_implementation == 'CPython' and ((sys_platform == 'linux' and (platform_machine == 'x86_64' or platform_machine == 'aarch64')) or sys_platform == 'darwin' or (sys_platform == 'win32' and platform_machine == 'AMD64'))", ] [project.scripts] diff --git a/rust/cgr_graph_rs/Cargo.lock b/rust/cgr_graph_rs/Cargo.lock index ce5dcd5167..f654559743 100644 --- a/rust/cgr_graph_rs/Cargo.lock +++ b/rust/cgr_graph_rs/Cargo.lock @@ -53,7 +53,7 @@ checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" [[package]] name = "cgr_graph_rs" -version = "0.1.3" +version = "0.1.4" dependencies = [ "blake2", "pyo3", diff --git a/rust/cgr_graph_rs/Cargo.toml b/rust/cgr_graph_rs/Cargo.toml index 2c1699b178..0b6656f493 100644 --- a/rust/cgr_graph_rs/Cargo.toml +++ b/rust/cgr_graph_rs/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cgr_graph_rs" -version = "0.1.3" +version = "0.1.4" edition = "2021" description = "Native acceleration for code-graph-rag: its embedded graph, and its indexer's tree walks" license = "MIT" diff --git a/rust/cgr_graph_rs/pyproject.toml b/rust/cgr_graph_rs/pyproject.toml index afdbcd5d5a..2f12320e0f 100644 --- a/rust/cgr_graph_rs/pyproject.toml +++ b/rust/cgr_graph_rs/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "maturin" [project] name = "cgr-graph-rs" -version = "0.1.3" +version = "0.1.4" description = "Native acceleration for code-graph-rag's embedded graph" readme = "README.md" requires-python = ">=3.12" diff --git a/rust/cgr_graph_rs/src/lib.rs b/rust/cgr_graph_rs/src/lib.rs index 3a042f8672..e93c06ff56 100644 --- a/rust/cgr_graph_rs/src/lib.rs +++ b/rust/cgr_graph_rs/src/lib.rs @@ -32,7 +32,7 @@ pub mod snapshot; pub mod trees; pub mod walk; -const DEFAULT_ITERATIONS: u32 = 100; +const DEFAULT_ITERATIONS: u64 = 100; const DEFAULT_DAMPING: f64 = 0.85; const DEFAULT_EPSILON: f64 = 1e-5; @@ -148,7 +148,7 @@ pub fn pagerank_until( args: &[Arg], deadline: &Deadline, ) -> Result, TimedOut> { - let iterations = int_arg(args, 0).map_or(DEFAULT_ITERATIONS, |v| v.max(0) as u32); + let iterations = int_arg(args, 0).map_or(DEFAULT_ITERATIONS, |v| v.max(0) as u64); let damping = float_arg(args, 1).unwrap_or(DEFAULT_DAMPING); let epsilon = float_arg(args, 2).unwrap_or(DEFAULT_EPSILON); let n = g.ids.len(); diff --git a/rust/cgr_graph_rs/tests/algorithms.rs b/rust/cgr_graph_rs/tests/algorithms.rs index f1f70a58a1..bcfc0adeec 100644 --- a/rust/cgr_graph_rs/tests/algorithms.rs +++ b/rust/cgr_graph_rs/tests/algorithms.rs @@ -69,6 +69,24 @@ fn pagerank_is_a_distribution() { assert!((total - 1.0).abs() < 1e-9); } +/// Python's `for _ in range(iterations)` runs any count until the ranks +/// converge; a count past u32::MAX is no different. +#[test] +fn pagerank_runs_an_iteration_count_past_u32_max() { + let tight = |iterations: i64| { + let args = [Arg::Int(iterations), Arg::Float(0.85), Arg::Float(1e-12)]; + run(&sample(), "pagerank.get", &args).expect("implemented") + }; + assert_eq!(tight((1 << 32) + 1), tight(1000)); +} + +/// `range()` of a negative count is empty: the ranks stay uniform. +#[test] +fn pagerank_runs_no_iteration_for_a_negative_count() { + let records = run(&sample(), "pagerank.get", &[Arg::Int(-5)]).expect("implemented"); + assert_eq!(column(&records, "rank"), vec![Value::Float(0.25); 4]); +} + #[test] fn procedures_left_to_python_are_declined() { assert!(run(&sample(), "nxalg.simple_cycles", &[]).is_none()); diff --git a/uv.lock b/uv.lock index 57a25594d0..12fd32fa28 100644 --- a/uv.lock +++ b/uv.lock @@ -273,7 +273,7 @@ wheels = [ [[package]] name = "cgr-graph-rs" -version = "0.1.3" +version = "0.1.4" source = { directory = "rust/cgr_graph_rs" } [[package]]