crps_cnormal ignores the backend argument for the tail masses

Aperta
#138 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@gopain185 ci sta già lavorando.

Dal 1/11/2026.

  • #142 di @gopain185 — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
20/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
python, pytorch

Direzione di ricerca

Read crps_cnormal and compare it with crps.gtcnormal, as the issue names both as relevant entry points. Check how the two _norm_cdf calls handle converted inputs and the requested backend. Done means the torch reproducer works with gradient-requiring tensors; pull request #142 is already open for this issue.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug
What happened?

crps_cnormal computes the censored masses with stats._norm_cdf(...) but doesn't pass backend on, so it uses the globally active backend (numpy by default) instead of the one requested. With torch tensors this goes through numpy, which fails for tensors that need gradients (and for GPU tensors). This is the same kind of bug as #98.

Suggested fix: pass backend=backend to both _norm_cdf calls, after converting the inputs with B.asarray, as crps.gtcnormal does.

Minimal reproducer
import torch
import scoringrules as sr

sr.register_backend("torch")

obs = torch.zeros(3)
mu = torch.zeros(3, requires_grad=True)
sigma = torch.ones(3)

# the active backend is still numpy
sr.crps_cnormal(obs, mu, sigma, -1.0, 1.0, backend="torch")
Backend

torch

Python version

3.12

scoringrules version

0.11.0

Lingua principale
Python
Stelle
108
Fork
15
Merge medio
1h 42m
PR unite (30g)
9

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di frazane/scoringrules

Tutte le issue di frazane/scoringrules

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.