From 3d01d4dd3c13765f0de86a0443890397d4423af2 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 9 Nov 2026 05:43:24 +0000 Subject: [PATCH 1/2] Fix generate_figures crashing with polars 2 `nwb_benchmarks generate_figures` stopped partway through with `ArgumentRemovedError` when polars 2 is installed: the environment preprocessing labels each environment with its timepoint through `Expr.replace(mapping, default=None)`, and polars 2.0 removed the `default` argument of `replace`. polars is unpinned, so a fresh install gets 2.x. The figures that #221 added are written before that point, but the run then crashes in `plot_performance_across_versions`. `Expr.replace_strict(mapping, default=None)` does the same mapping (environments without a timepoint become null) and exists since polars 1.0, so this works with both 1.x and 2.x. Adds a test for the timepoint labeling, which fails with the old call under polars 2. Package version 0.4.2 -> 0.4.3 (patch). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_019XGZPsK77kY9cukQuY4a7R --- pyproject.toml | 2 +- src/nwb_benchmarks/database/_processing.py | 2 +- tests/test_environment_timepoints.py | 26 ++++++++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 tests/test_environment_timepoints.py diff --git a/pyproject.toml b/pyproject.toml index 644c871..eefac2d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,7 @@ packages = ["src/nwb_benchmarks"] [project] name = "nwb_benchmarks" -version="0.4.2" +version="0.4.3" authors = [ { name="Cody Baker", email="cody.baker@catalystneuro.com" }, ] diff --git a/src/nwb_benchmarks/database/_processing.py b/src/nwb_benchmarks/database/_processing.py index 5b7111c..2e0bd2a 100644 --- a/src/nwb_benchmarks/database/_processing.py +++ b/src/nwb_benchmarks/database/_processing.py @@ -322,7 +322,7 @@ def _preprocess_environments(self, df: pl.LazyFrame) -> pl.LazyFrame: .filter(pl.col("package_version").is_not_null()) .with_columns( pl.col("environment_id") - .replace({v: k for k, v in ENVIRONMENT_TIMEPOINTS.items()}, default=None) + .replace_strict({v: k for k, v in ENVIRONMENT_TIMEPOINTS.items()}, default=None) .alias("environment_timepoint") ) ) diff --git a/tests/test_environment_timepoints.py b/tests/test_environment_timepoints.py new file mode 100644 index 0000000..4c7692c --- /dev/null +++ b/tests/test_environment_timepoints.py @@ -0,0 +1,26 @@ +import pytest + +pl = pytest.importorskip("polars") + +from nwb_benchmarks.database import BenchmarkDatabase +from nwb_benchmarks.database._processing import ( + ENVIRONMENT_TIMEPOINTS, + PACKAGES_OF_INTEREST, +) + + +def test_environments_are_labeled_with_their_timepoint(tmp_path): + timepoint, environment_id = next(iter(ENVIRONMENT_TIMEPOINTS.items())) + environments = pl.LazyFrame( + { + "environment_id": [environment_id, "unknown-environment"], + **{package: ["1.2.3=py_0", "4.5.6"] for package in PACKAGES_OF_INTEREST}, + } + ) + + database = BenchmarkDatabase(results_directory=tmp_path, db_directory=tmp_path) + labeled = database._preprocess_environments(environments).collect() + + timepoints = dict(labeled.select(["environment_id", "environment_timepoint"]).unique().iter_rows()) + assert timepoints == {environment_id: timepoint, "unknown-environment": None} + assert set(labeled["package_version"]) == {"1.2.3", "4.5.6"} From 823e9ee7b14d9942d86abfa81d897041876017fa Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 12 Nov 2026 23:50:49 +0000 Subject: [PATCH 2/2] Bump the package version to 0.4.4 #227 released 0.4.3 on main, so after merging main this branch carried the same version and the version check failed. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_019XGZPsK77kY9cukQuY4a7R --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 3a12996..2c42c23 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,7 @@ packages = ["src/nwb_benchmarks"] [project] name = "nwb_benchmarks" -version="0.4.3" +version="0.4.4" authors = [ { name="Cody Baker", email="cody.baker@catalystneuro.com" }, ]