Coverage for torch_crps / abstract.py: 100%
5 statements
« prev ^ index » next coverage.py v7.13.3, created at 2026-02-08 11:09 +0000
« prev ^ index » next coverage.py v7.13.3, created at 2026-02-08 11:09 +0000
1import torch
4def crps_abstract(accuracy: torch.Tensor, dispersion: torch.Tensor) -> torch.Tensor:
5 """High-level function to compute the CRPS from the accuracy and dispersion terms.
7 Args:
8 accuracy: The accuracy term A, independent of the methods used to compute it, of shape (*batch_shape,).
9 dispersion: The dispersion term D, independent of the methods used to compute it, of shape (*batch_shape,).
11 Returns:
12 The CRPS value for each forecast in the batch, of shape (*batch_shape,).
13 """
14 return accuracy - 0.5 * dispersion
17def scrps_abstract(accuracy: torch.Tensor, dispersion: torch.Tensor) -> torch.Tensor:
18 """High-level function to compute the SCRPS from the accuracy and dispersion terms.
20 Args:
21 accuracy: The accuracy term A, independent of the methods used to compute it, of shape (*batch_shape,).
22 dispersion: The dispersion term D, independent of the methods used to compute it, of shape (*batch_shape,).
24 Returns:
25 The SCRPS value for each forecast in the batch, of shape (*batch_shape,).
26 """
27 return accuracy / dispersion + 0.5 * torch.log(dispersion)