Open Jman4190 opened 2 years ago
How many teams, divisions, and conferences do you have? It looks like that code is actually generating divisions of size 3 not size 4. i//3
Gives the following pairs of values:
0,0
1,0,
2,0,
3,1,
4,1,
5,1,
6,2,
...
All divisions should be the same size. And every conference should be the same size too.
That exception just means that no valid solution was found after 100 attempts for that week (you could try increasing the number of attempts). I should change the code to actually describe the exception more clearly.
Not ruling out there isn't a bug but please let me know those values. And then what your game_types_per_week
variable looks like
my comment was also bad next to that i//4. Updated in my last commits to reflect what it actually is doing
Yes I have 12 teams in the league with 4 divisions made up of 3 teams each. There are 2 conferences with 6 teams in each each. So two divisions within each conference. I increased the attempts to 1000 and it's still failing. This is my game_types_per_week
['divisional',
'non_conference',
'non_conference',
'conference',
'divisional',
'divisional',
'conference',
'divisional',
'conference',
'conference',
'divisional',
'non_conference',
'non_conference',
'divisional']
I think I found where the issue is coming from. It doesn't look like conferences
is generating as expected. The output is the same as divisions
and when I look at universes['conference']
I see empty lists. Any potential issue here:
conferences = defaultdict(list)
conference_nums=[]
for division, teams in divisions.items():
division_num=len(teams)//2 #2 conferences
conferences[division//division_num]+=teams
conference_nums.append(division_num)
conferences
Ok I got conferences to work now by just setting division_num=2
and the output is:
defaultdict(list,
{0: ["Team One",
'Team Two',
'Team Three',
'Team Four',
'Team Five',
'Team Six'],
1: ['Team Seven',
"Team Eight",
'Team Nine',
'Team Ten',
'Team Eleven',
'Team Twelve']})
And I got my universes['non_conference']
and universes['conference']
to output the correct info. However I am still seeing this error
Exception: No valid matchups found for week 0 after 1000000 attempts. Please check your settings are valid or try increasing the number of attempts
Ah sorry, the code does not work with an odd number of teams in a division or conference. There was a bug in the conferences code you found as well.
The schedule generator does not support an odd number of teams in a division since each week is a "themed" week. Divisional week requires every team to play a team from their division and after the first matchup is set the third team in the division has no one left to play. You could probably edit the code to make it work for your use case though. Or do 2 divisions of size 6. See the new notebook https://github.com/rogerfitz/tutorials/blob/master/fantasy_football_schedule_generator/jman_issue.ipynb (it might take a few runs to get this schedule to generate validly but it should work most of the times)
Maybe in a follow up video I'll add support for odd numbered teams (it is a more complicated approach but would be way more flexible), for now I added a warning in the notebooks, README, and Youtube video
When running this block I receive an error
Error message
RuntimeError Traceback (most recent call last) /var/folders/h0/ffqb5f990rqfgzshykzbr2gm0000gn/T/ipykernel_88125/299313015.py in
21 continue
22 if not matchups:
---> 23 raise
24 else:
25 for name, universe in universes.items():
RuntimeError: No active exception to reraise