Skip to content

Commit cd3bbd3

Browse files
authored
Refactor tests and increase coverage (#87)
* refactor and complete brier tests * refactor and complete crps tests * refactor and complete energy tests * refactor and complete ess tests * fix failing crps hg test * exclude ImportError from coverage * 100% coverage for crps * refactor and complete kernels tests * refactor and complete the rest * exclude backends and typing module from coverage
1 parent bc1f828 commit cd3bbd3

File tree

18 files changed

+695
-515
lines changed

18 files changed

+695
-515
lines changed

pyproject.toml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,12 @@ line-length = 88
6464
ignore = ["E741"]
6565

6666
[tool.coverage.run]
67-
omit = ["**/_gufuncs.py", "**/_gufunc.py"]
67+
omit = [
68+
"**/_gufuncs.py", # numba gufuncs are not python code
69+
"**/_gufunc.py",
70+
"scoringrules/backend/*.py", # superfluous
71+
"scoringrules/core/typing.py" # only type hints
72+
]
6873

6974
[tool.coverage.report]
70-
exclude_also = ["if tp.TYPE_CHECKING:"]
75+
exclude_also = ["if tp.TYPE_CHECKING:", "except ImportError"]

scoringrules/_crps.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1789,19 +1789,22 @@ def crps_2pnormal(
17891789
>>> sr.crps_2pnormal(0.0, 0.4, 2.0, 0.1)
17901790
"""
17911791
B = backends.active if backend is None else backends[backend]
1792+
obs, scale1, scale2, location = map(
1793+
B.asarray, (observation, scale1, scale2, location)
1794+
)
17921795
lower = float("-inf")
17931796
upper = 0.0
17941797
lmass = 0.0
17951798
umass = scale2 / (scale1 + scale2)
1796-
z = B.minimum(B.asarray(0.0), B.asarray(observation - location)) / scale1
1799+
z = B.minimum(B.asarray(0.0), B.asarray(obs - location)) / scale1
17971800
s1 = scale1 * crps.gtcnormal(
17981801
z, 0.0, 1.0, lower, upper, lmass, umass, backend=backend
17991802
)
18001803
lower = 0.0
18011804
upper = float("inf")
18021805
lmass = scale1 / (scale1 + scale2)
18031806
umass = 0.0
1804-
z = B.maximum(B.asarray(0.0), B.asarray(observation - location)) / scale2
1807+
z = B.maximum(B.asarray(0.0), B.asarray(obs - location)) / scale2
18051808
s2 = scale2 * crps.gtcnormal(
18061809
z, 0.0, 1.0, lower, upper, lmass, umass, backend=backend
18071810
)

0 commit comments

Comments
 (0)