Skip to content

Set n_PCs rather than nPCs in highd_settings#46

Open
bendichter wants to merge 1 commit into
MouseLand:mainfrom
bendichter:fix-highd-settings-npcs
Open

Set n_PCs rather than nPCs in highd_settings#46
bendichter wants to merge 1 commit into
MouseLand:mainfrom
bendichter:fix-highd-settings-npcs

Conversation

@bendichter

Copy link
Copy Markdown

Fixes #45.

highd_settings() wrote its PC count into settings["nPCs"], but the keyword on Rastermap is n_PCs. The returned dict therefore carried an unused nPCs: 400 alongside the n_PCs: 200 inherited from default_settings(), so Rastermap(**highd_settings()) raised TypeError for the unexpected argument, and anyone who worked around that by dropping the unknown key silently got 200 PCs rather than the 400 the function intends. Renaming the key fixes both.

This does change what the helper returns. Callers who were filtering the dict will now get 400 PCs where they previously got 200, which looks like the original intent, but it is a behaviour change rather than a pure no-op and I wanted to flag it.

The Test

The added test checks that each settings helper returns only keys that Rastermap accepts. Without the fix it fails with AssertionError: highd_settings returns unknown keys: {'nPCs'}, and it covers default_settings and sequence_settings at the same time, both of which are already fine.

It compares against the signature rather than fitting anything. highd_settings() asks for 3 splits on 100 clusters, so actually fitting it needs a dataset large enough to support 800 nodes, and on smaller data it fails inside scaled_kmeans for an unrelated reason that I have written up separately. Checking the keys is what would have caught this bug, and it runs without needing the test dataset.

I did not touch the export list. highd_settings and sequence_settings are reachable only as from rastermap.rastermap import ..., since __init__.py exports just default_settings and settings_info, which is probably why this went unnoticed. Whether those helpers should be part of the public API seemed like your call rather than something to fold into a typo fix.

Note on Tooling

I used Claude Code to find this and write the patch. The test fails on the current code and passes with the change, so the claim does not rest on trusting the tool. Happy to drop it if a change of this shape is unwelcome.

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 MouseLand#45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

highd_settings() sets nPCs instead of n_PCs, so it raises TypeError when passed to Rastermap and the intended 400 PCs never take effect

1 participant