twcrps_ensemble bounds ignore the input precision

Open Beginner friendly
#163 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
numpy, python
Domain
data

Research direction

The issue identifies uv_weighted_score_chain in core/utils.py as the cause and says the kernel scores already use asarray_matching for the bounds. Read that helper and compare its bound conversion with the kernel score conversions. Reproduce the float32 NumPy and float64 torch cases from the issue; done means outputs preserve the input precision and the torch result agrees with NumPy.

Written by the indexing model from the issue text.

Description

bug

The threshold bounds a and b of twcrps_ensemble are converted with the default dtype instead of the input's, so float32 numpy inputs return float64 (also with the default bounds), and on torch float64 inputs the bounds are rounded to float32.

obs = np.float32([0.3, 1.2])
fct = np.random.default_rng(0).normal(size=(2, 5)).astype(np.float32)
sr.twcrps_ensemble(obs, fct).dtype  # float64

With float64 torch tensors and a=0.1, b=0.7, the result differs from numpy by about 5e-9. The cause is uv_weighted_score_chain in core/utils.py; the kernel scores already convert the bounds with asarray_matching.

Dominant language
Python
Stars
108
Forks
15
Avg merge
1h 42m
Merged PRs (30d)
9

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from frazane/scoringrules

All issues in frazane/scoringrules

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.