patrick-kidger / patrick-kidger/diffrax
replace_nans_at_start overwrite existing values
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.1k
- Forks
- 189
- Avg merge
- 3d 18h
- Merged PRs (30d)
- 1
Description
Hello, I am not sure if the behavior of replace_nans_at_start in backward_hermite_coefficients is expected when we have initial values that aren't all NaNs.
The documentation proposes that "replace_nans_at_start" will change the NaN values at the start by the ones given.
I believe that this parameter is only useful if ALL the values at the start are NaNs. I give an example below (based again on get_data from the NCDE example) where the dataset has no NaN values. It actually raises an assertion error because values are being switched to "means" regardless wether they're NaNs or not.
I think the problem is that in _backward_hermite_coefficients the following line:
y0 = jnp.broadcast_to(replace_nans_at_start, ys[0].shape)
doesn't consider if the values are NaNs and switches them automatically. In my opinion, the logic behind the parameter would be to only switch the NaN values and not overwrite the already existing ones. I would propose either mentioning in the docstring if this is the expected behvaior or adjusting the proposed line to consider if values are actually NaNs or not.
Thank you in advance! The library is great!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at _backward_hermite_coefficients and inspect how replace_nans_at_start is applied to ys[0], especially the y0 broadcast line mentioned in the issue. Compare that behavior with the parameter documentation and the provided example; the work is done when the documented behavior and handling of existing versus NaN initial values agree.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100