Skip to content

Commit

Permalink
fix: wrong ets algorithm (#50)
Browse files Browse the repository at this point in the history
修复 ETS 计算逻辑错误
  • Loading branch information
Clarmy authored Nov 10, 2023
1 parent 9784bf4 commit 393588d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 0 additions & 2 deletions cyeva/core/statistic.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,6 @@ def calc_ets(

hits_ref = ((hits + misses) * (hits + false_alarms)) / total

if hits - hits_ref == hits + false_alarms + misses - hits_ref:
return 1.0
return (hits - hits_ref) / (hits + false_alarms + misses - hits_ref)


Expand Down
6 changes: 4 additions & 2 deletions tests/functions/case/precip/single/ets.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
"fct": [True, False, False, False],
"result": 0,
},
{"obs": [0, 0, 0, 0], "fct": [0, 0, 0, 0], "result": np.nan},
{"obs": [0, 0, 0, 0], "fct": [2, 0, 0, 0], "result": 0},
{"obs": [1, 1, 1, 1], "fct": [1, 1, 1, 1], "result": 1},
{"obs": [1, 1, 1, 1], "fct": [1, 1, 1, 1], "result": np.nan},
{"obs": [0, 0.5, 0, 0], "fct": [2.1, 0, 0, 0], "result": -0.14},
{"obs": [1, 2, 3, 4], "fct": [0, 0, 0, 0], "result": 0},
{"obs": [1, 2, 3, 4], "fct": [4, 3, 2, 1], "result": 1},
{"obs": [1, 2, 0, 0], "fct": [1, 2, 0, 0], "result": 1},
{"obs": [1, 2, 3, 4], "fct": [4, 3, 2, 1], "result": np.nan},
{"obs": [1, 2, 3, 0], "fct": [2, 0, 0, 0], "result": 0.11},
{"obs": [1, 2, 3, 1], "fct": [2, 0, 0, 0], "result": 0},
{"obs": np.array([1, 2, 3, 1]), "fct": [2, 0, 0, 0], "result": 0},
Expand Down

0 comments on commit 393588d

Please sign in to comment.