Fix the optional rng_key default in InitFn - #988
Draft
sapunyangkut wants to merge 1 commit into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
SamplingAlgorithm.initis typed by theInitFnprotocol. The protocol allowedrng_keyto beNone, but it omitted the= Nonedefault, so Pyright treated the argument as required even though the concrete HMC initializer acceptsinit(position).This adds the missing default to the protocol and a regression test that compares the protocol signature with the concrete HMC initializer. It does not change runtime algorithm behavior.
Related issues / discussions
Closes #782
Validation
init(position)andinit(position, rng_key)calls.uv run pytest -q tests/test_api_protocols.py tests/mcmc/test_multinomial_hmc.py: 93 passed.uv run pre-commit run --all-files: all applicable hooks passed.os.geteuidAPI on Windows, and two are unrelated numerical assertions. The same upstream commit's Ubuntu Tests workflow is successful.Checklist
General
mainpre-commit run --all-filespasses (black, isort, flake8, mypy)Code quality
New sampler / algorithm
Not applicable; this is a typing contract fix.
AI assistance disclosure
This contribution was prepared and validated with OpenAI Codex automation. The automation reproduced the static typing error and runtime signature mismatch on the current upstream commit, produced the two-file patch, and ran the checks listed above.