-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: port sports-league-scheduling quickstart example from Java to Python #685
base: development
Are you sure you want to change the base?
chore: port sports-league-scheduling quickstart example from Java to Python #685
Conversation
Thanks for the contribution, @PatrickDiallo23! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @PatrickDiallo23! I am impressed with the quality of the port. Some suggestions for improvement + consistency with the other quickstarts.
python/sports-league-scheduling/src/sports_league_scheduling/constraints.py
Outdated
Show resolved
Hide resolved
python/sports-league-scheduling/src/sports_league_scheduling/constraints.py
Outdated
Show resolved
Hide resolved
python/sports-league-scheduling/src/sports_league_scheduling/demo_data.py
Outdated
Show resolved
Hide resolved
python/sports-league-scheduling/src/sports_league_scheduling/demo_data.py
Outdated
Show resolved
Hide resolved
python/sports-league-scheduling/src/sports_league_scheduling/domain.py
Outdated
Show resolved
Hide resolved
python/sports-league-scheduling/src/sports_league_scheduling/domain.py
Outdated
Show resolved
Hide resolved
…-league-scheduling example
Hello @Christopher-Chianelli! I did another commit where I applied your code suggestions. Please review. Thank you! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mild formatting changes. It appears you missed the requested changes that were hidden by default (since GitHub automatically hides requested changes in the middle when there are many requests). Do the missed requested changes + the formatting ones, then it'll LGTM.
@@ -81,7 +81,7 @@ def start_to_away_hop(constraint_factory: ConstraintFactory) -> Constraint: | |||
.for_each(Match) | |||
.if_not_exists(Round, Joiners.equal(lambda match: match.round.index - 1, | |||
lambda match_round: match_round.index)) | |||
.penalize(HardSoftScore.ONE_SOFT, away_home_match_distance_lambda) | |||
.penalize(HardSoftScore.ONE_SOFT, lambda match: (match.away_team.get_distance(match.home_team))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parenthesis uneccessary
.penalize(HardSoftScore.ONE_SOFT, lambda match: (match.away_team.get_distance(match.home_team))) | |
.penalize(HardSoftScore.ONE_SOFT, lambda match: match.away_team.get_distance(match.home_team)) |
@@ -91,7 +91,7 @@ def home_to_away_hop(constraint_factory: ConstraintFactory) -> Constraint: | |||
.join(Match, | |||
Joiners.equal(lambda match: match.home_team, lambda match: match.away_team), | |||
Joiners.equal(lambda match: match.round.index + 1, lambda match: match.round.index)) | |||
.penalize(HardSoftScore.ONE_SOFT, home_matches_distance_lambda) | |||
.penalize(HardSoftScore.ONE_SOFT, lambda match, other_match: (match.home_team.get_distance(other_match.home_team))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.penalize(HardSoftScore.ONE_SOFT, lambda match, other_match: (match.home_team.get_distance(other_match.home_team))) | |
.penalize(HardSoftScore.ONE_SOFT, lambda match, other_match: match.home_team.get_distance(other_match.home_team)) |
@@ -101,7 +101,7 @@ def away_to_away_hop(constraint_factory: ConstraintFactory) -> Constraint: | |||
.join(Match, | |||
Joiners.equal(lambda match: match.away_team, lambda match: match.away_team), | |||
Joiners.equal(lambda match: match.round.index + 1, lambda match: match.round.index)) | |||
.penalize(HardSoftScore.ONE_SOFT, home_matches_distance_lambda) | |||
.penalize(HardSoftScore.ONE_SOFT, lambda match, other_match: (match.home_team.get_distance(other_match.home_team))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.penalize(HardSoftScore.ONE_SOFT, lambda match, other_match: (match.home_team.get_distance(other_match.home_team))) | |
.penalize(HardSoftScore.ONE_SOFT, lambda match, other_match: match.home_team.get_distance(other_match.home_team)) |
@@ -111,45 +111,22 @@ def away_to_home_hop(constraint_factory: ConstraintFactory) -> Constraint: | |||
.join(Match, | |||
Joiners.equal(lambda match: match.away_team, lambda match: match.home_team), | |||
Joiners.equal(lambda match: match.round.index + 1, lambda match: match.round.index)) | |||
.penalize(HardSoftScore.ONE_SOFT, home_away_matches_distance_lambda) | |||
.penalize(HardSoftScore.ONE_SOFT, lambda match, other_match: (match.home_team.get_distance(match.away_team))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.penalize(HardSoftScore.ONE_SOFT, lambda match, other_match: (match.home_team.get_distance(match.away_team))) | |
.penalize(HardSoftScore.ONE_SOFT, lambda match, other_match: match.home_team.get_distance(match.away_team)) |
|
||
def away_to_end_hop(constraint_factory: ConstraintFactory) -> Constraint: | ||
return (constraint_factory | ||
.for_each(Match) | ||
.if_not_exists(Round, Joiners.equal(lambda match: match.round.index + 1, | ||
lambda match_round: match_round.index)) | ||
.penalize(HardSoftScore.ONE_SOFT, home_away_match_distance_lambda) | ||
.penalize(HardSoftScore.ONE_SOFT, lambda match: (match.home_team.get_distance(match.away_team))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.penalize(HardSoftScore.ONE_SOFT, lambda match: (match.home_team.get_distance(match.away_team))) | |
.penalize(HardSoftScore.ONE_SOFT, lambda match: match.home_team.get_distance(match.away_team)) |
Description of the change
Port the sports-league-scheduling quickstart example from Java to Python while keeping the same functionality.
Checklist
Development
Code Review