j-andrews7/kenpompy

FAILED tests/test_summary.py::test_get_height

Closed this issue · 3 comments

esqew commented

One test out of the suite is currently failing:

FAILED tests/test_summary.py::test_get_height - AssertionError: assert ['Louisville',\n 'ACC',\n '76.8',\n '181',\n '+0.6',\n '87',\n '+1.3',\n '44',...

Full test log:

================================================================= test session starts ==================================================================
platform darwin -- Python 3.8.9, pytest-7.1.2, pluggy-1.0.0 -- /Applications/Xcode.app/Contents/Developer/usr/bin/python3
cachedir: .pytest_cache
rootdir: <redacted>/kenpompy
collected 17 items                                                                                                                                     

tests/test_fanmatch.py::test_fanmatch PASSED                                                                                                     [  5%]
tests/test_misc.py::test_get_pomeroy_ratings PASSED                                                                                              [ 11%]
tests/test_misc.py::test_get_trends PASSED                                                                                                       [ 17%]
tests/test_misc.py::test_get_refs PASSED                                                                                                         [ 23%]
tests/test_misc.py::test_get_hca PASSED                                                                                                          [ 29%]
tests/test_misc.py::test_get_arenas PASSED                                                                                                       [ 35%]
tests/test_misc.py::test_get_gameattribs PASSED                                                                                                  [ 41%]
tests/test_misc.py::test_get_program_ratings PASSED                                                                                              [ 47%]
tests/test_summary.py::test_get_efficiency PASSED                                                                                                [ 52%]
tests/test_summary.py::test_get_fourfactors PASSED                                                                                               [ 58%]
tests/test_summary.py::test_get_teamstats PASSED                                                                                                 [ 64%]
tests/test_summary.py::test_get_pointdist PASSED                                                                                                 [ 70%]
tests/test_summary.py::test_get_height FAILED                                                                                                    [ 76%]
tests/test_summary.py::test_get_playerstats PASSED                                                                                               [ 82%]
tests/test_summary.py::test_get_kpoy PASSED                                                                                                      [ 88%]
tests/test_team.py::test_get_valid_teams PASSED                                                                                                  [ 94%]
tests/test_team.py::test_get_schedule PASSED                                                                                                     [100%]

======================================================================= FAILURES =======================================================================
___________________________________________________________________ test_get_height ____________________________________________________________________

browser = <mechanicalsoup.stateful_browser.StatefulBrowser object at 0x12b014340>

    def test_get_height(browser):
        expected = ['Louisville', 'ACC', '76.8', '181', '+0.6', '87', '+1.3', '44', '-0.1', '190', '-0.1', '189', '-0.9',
                                '272', '-0.5', '233', '1.92', '102', '33.3', '97', '36.7', '273']
    
        df = kpsum.get_height(browser, season = '2019')
>       assert [str(i) for i in df[df.Team == 'Louisville'].iloc[0].to_list()] == expected
E    AssertionError: assert ['Louisville',\n 'ACC',\n '76.8',\n '181',\n '+0.6',\n '87',\n '+1.3',\n '44',\n '-0.1',\n '190',\n '-0.1',\n '189',\n '-0.9',\n '272',\n '-0.5',\n '233',\n '2.18',\n '29',\n '33.3',\n '97',\n '36.7',\n '273'] == ['Louisville',\n 'ACC',\n '76.8',\n '181',\n '+0.6',\n '87',\n '+1.3',\n '44',\n '-0.1',\n '190',\n '-0.1',\n '189',\n '-0.9',\n '272',\n '-0.5',\n '233',\n '1.92',\n '102',\n '33.3',\n '97',\n '36.7',\n '273']
E      At index 16 diff: '2.18' != '1.92'
E      Full diff:
E        [
E         'Louisville',
E         'ACC',
E         '76.8',
E         '181',
E         '+0.6',
E         '87',
E         '+1.3',
E         '44',
E         '-0.1',
E         '190',
E         '-0.1',
E         '189',
E         '-0.9',
E         '272',
E         '-0.5',
E         '233',
E      -  '1.92',
E      +  '2.18',
E      -  '102',
E      ?   --
E      +  '29',
E      ?    +
E         '33.3',
E         '97',
E         '36.7',
E         '273',
E        ]

tests/test_summary.py:66: AssertionError
esqew commented

After further research, it seems KenPom somewhat recently changed the methodology on how Experience is quantified - from his (undated) blog post:

So a solution is needed. And that solution is to measure a player’s experience by minutes played in previous seasons. I have more or less scaled this new measure to the previous measure. The new measure can be thought of as average number of full D-1 seasons played by the current roster, weighted by minutes played.

Seems it's likely this test is failing since it's using data from the old methodology to test - it's probably just a matter of updating the constants in the test file to be asserted against.

Latest release (v0.3.2) fixes this, available via pip now. Thanks for the help.