From d4b1e5a25aeffa838ba3e4b05bda6e3c1abc9f98 Mon Sep 17 00:00:00 2001 From: Ben Dichter Date: Thu, 16 Jul 2026 14:46:47 -0400 Subject: [PATCH] Set n_PCs rather than nPCs in highd_settings highd_settings() wrote its PC count into settings["nPCs"], but the keyword on Rastermap is n_PCs, so the returned dict carried an unused nPCs key alongside the n_PCs value of 200 inherited from default_settings(). Rastermap(**highd_settings()) raised TypeError for the unexpected argument, and callers who dropped the unknown key got 200 PCs rather than the 400 the function intends. The added test checks that each settings helper returns only keys that Rastermap accepts, which is what would have caught this. It compares against the signature rather than fitting, since highd_settings() asks for 3 splits and fitting it would need a dataset large enough to support the resulting node count. Fixes #45 --- rastermap/rastermap.py | 2 +- tests/test_rastermap.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/rastermap/rastermap.py b/rastermap/rastermap.py index e7a4b12..dba0d27 100644 --- a/rastermap/rastermap.py +++ b/rastermap/rastermap.py @@ -44,7 +44,7 @@ def highd_settings(): settings = default_settings() settings["n_clusters"] = 100 settings["n_splits"] = 3 - settings["nPCs"] = 400 + settings["n_PCs"] = 400 return settings diff --git a/tests/test_rastermap.py b/tests/test_rastermap.py index 83aa148..7d9d360 100644 --- a/tests/test_rastermap.py +++ b/tests/test_rastermap.py @@ -1,5 +1,19 @@ +import inspect + import numpy as np from rastermap import Rastermap +from rastermap.rastermap import default_settings, sequence_settings, highd_settings + + +def test_settings_are_valid_kwargs(): + valid = set(inspect.signature(Rastermap.__init__).parameters) - {"self"} + for settings in (default_settings, sequence_settings, highd_settings): + unknown = set(settings()) - valid + assert not unknown, f"{settings.__name__} returns unknown keys: {unknown}" + + +def test_highd_settings_n_PCs(): + assert highd_settings()["n_PCs"] == 400 def test_rastermap(test_file):