kiudee / cs-ranking

Context-sensitive ranking and choice in Python with PyTorch
https://cs-ranking.readthedocs.io
Apache License 2.0
66 stars 15 forks source link

Always raise ValueError on unknown variants #123

Closed timokau closed 4 years ago

timokau commented 4 years ago

Description

Fixes https://github.com/kiudee/cs-ranking/issues/122. I think I caught all instances, I verified this by grepping for not in.

I kind of think most of those should either pass the function directly in the first place or use an enum instead. Either way, this change should be an improvement.

This is technically a breaking change, though practically not really important since it only changes behaviour in already broken code.

While working on this I noticed some surprising black behaviour (explained in the commit message), which I fixed in a separate commit.

Motivation and Context

122

How Has This Been Tested?

Ran the testsuite and pre-commit hooks.

Does this close/impact existing issues?

Fixes #122.

Types of changes

Checklist:

timokau commented 4 years ago

It is best to review the commits individually, since one of them just adds a bunch of commas.

codecov[bot] commented 4 years ago

Codecov Report

Merging #123 into master will not change coverage. The diff coverage is 27.27%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #123   +/-   ##
=======================================
  Coverage   60.01%   60.01%           
=======================================
  Files         116      116           
  Lines        7642     7642           
=======================================
  Hits         4586     4586           
  Misses       3056     3056           
Impacted Files Coverage Δ
csrank/choicefunction/cmpnet_choice.py 84.78% <ø> (ø)
csrank/choicefunction/fate_choice.py 91.30% <ø> (ø)
csrank/choicefunction/fatelinear_choice.py 92.85% <ø> (ø)
csrank/choicefunction/feta_choice.py 66.00% <ø> (ø)
csrank/choicefunction/fetalinear_choice.py 92.85% <ø> (ø)
csrank/choicefunction/generalized_linear_model.py 87.50% <ø> (ø)
csrank/choicefunction/pairwise_choice.py 94.73% <ø> (ø)
csrank/choicefunction/ranknet_choice.py 81.63% <ø> (ø)
csrank/core/cmpnet_core.py 87.61% <ø> (ø)
csrank/core/fate_linear.py 90.32% <ø> (ø)
... and 53 more