コード例 #1
0
def test_no_double_te():
    args = Namespace(**args_dict)
    args.locked = ['Rob Gronkowski']
    roster = run(NFL, args)
    qb = roster.sorted_players()[0]
    ntools.assert_equal(qb.pos, 'QB')
    te_count = len([x for x in roster.sorted_players() if x.pos == 'TE'])
    ntools.assert_equals(te_count, 2)
    args.no_double_te = 'y'
    roster = run(NFL, args)
    qb = roster.sorted_players()[0]
    ntools.assert_equal(qb.pos, 'QB')
    te_count = len([x for x in roster.sorted_players() if x.pos == 'TE'])
    ntools.assert_equals(te_count, 1)
コード例 #2
0
def test_force_combo():
    args = Namespace(**args_dict)
    roster = run(NFL, args)
    qb = roster.sorted_players()[0]
    ntools.assert_equal(qb.pos, 'QB')
    team_count = len([x for x in roster.sorted_players() if x.team == qb.team])
    ntools.assert_equals(team_count, 1)

    args = Namespace(**args_dict)
    args.force_combo = True
    roster = run(NFL, args)
    qb = roster.sorted_players()[0]
    ntools.assert_equal(qb.pos, 'QB')
    team_count = len([x for x in roster.sorted_players() if x.team == qb.team])
    ntools.assert_equals(team_count, 2)
コード例 #3
0
ファイル: test.py プロジェクト: RichFlorez/draft-kings-fun
def test_teams_constraint():
    default_args.teams = ['NE', 'Dal']
    roster = run(POSITIONS[NFL], NFL, [], default_args, True)
    for p in roster.players:
        if p.pos == 'DST':
            continue
        assert p.team == 'NE' or p.team == 'Dal'
コード例 #4
0
ファイル: test.py プロジェクト: RichFlorez/draft-kings-fun
def test_locked_constraint():
    jb = 'Jacoby Brissett'
    default_args.teams = ['NE', 'Dal']
    default_args.banned = []
    default_args.locked = [jb]
    roster = run(POSITIONS[NFL], NFL, [], default_args, True)
    assert [p for p in roster.players if p.name == jb][0].lock
コード例 #5
0
ファイル: test.py プロジェクト: BenBrostoff/draft-kings-fun
def test_within_avg():
    avg_test_val = 3
    default_args.v_avg = avg_test_val
    roster = run(POSITIONS[NFL], NFL, [], default_args)
    for player in roster.players:
        assert abs(player.v_avg) < avg_test_val
    default_args.v_avg = 10000
コード例 #6
0
def test_banned_constraint():
    args = Namespace(**args_dict)
    jg = 'Jimmy Garoppolo'
    args.teams = ['NE', 'Dal']
    args.banned = [jg]
    roster = run(NFL, [], args)
    ntools.assert_not_in(jg, [p.name for p in roster.players])
コード例 #7
0
def test_within_avg():
    args = Namespace(**args_dict)
    avg_test_val = 3
    args.v_avg = avg_test_val
    roster = run(NFL, [], args)
    for player in roster.players:
        ntools.assert_less(abs(player.v_avg), avg_test_val)
コード例 #8
0
ファイル: test.py プロジェクト: BenBrostoff/draft-kings-fun
def test_teams_constraint():
    default_args.teams = ['NE', 'Dal']
    roster = run(POSITIONS[NFL], NFL, [], default_args)
    for p in roster.players:
        if p.pos == 'DST':
            continue
        assert p.team == 'NE' or p.team == 'Dal'
コード例 #9
0
def test_multi_position():
    args = Namespace(**args_dict)
    args.locked = ['Eli Manning']
    roster = run(NFL, args)
    multi_pos = [p for p in roster.players if p.name == 'Eli Manning']
    ntools.assert_equal(len(multi_pos), 1)
    ntools.assert_equal(multi_pos[0].pos, 'TE')
コード例 #10
0
def test_banned_constraint():
    args = Namespace(**args_dict)
    jg = 'Jimmy Garoppolo'
    args.teams = ['NE', 'Dal']
    args.banned = [jg]
    roster = run(NFL, args)
    ntools.assert_not_in(jg, [p.name for p in roster.players])
コード例 #11
0
ファイル: test.py プロジェクト: BenBrostoff/draft-kings-fun
def test_locked_constraint():
    jb = 'Jacoby Brissett'
    default_args.teams = ['NE', 'Dal']
    default_args.banned = []
    default_args.locked = [jb]
    roster = run(POSITIONS[NFL], NFL, [], default_args)
    assert [p for p in roster.players if p.name == jb][0].lock
コード例 #12
0
def test_within_avg():
    args = Namespace(**args_dict)
    avg_test_val = 3
    args.v_avg = avg_test_val
    roster = run(NFL, args)
    for player in roster.players:
        ntools.assert_less(abs(player.v_avg), avg_test_val)
コード例 #13
0
def test_multi_position():
    args = Namespace(**args_dict)
    args.locked = ['Eli Manning']
    roster = run(NFL, [], args)
    multi_pos = [p for p in roster.players if p.name == 'Eli Manning']
    ntools.assert_equal(len(multi_pos), 1)
    ntools.assert_equal(multi_pos[0].pos, 'TE')
コード例 #14
0
def test_teams_constraint():
    args = Namespace(**args_dict)
    args.teams = ['NE', 'Dal']
    roster = run(NFL, args)
    for p in roster.players:
        if p.pos == 'DST':
            continue
        ntools.assert_true(p.team == 'NE' or p.team == 'Dal')
コード例 #15
0
def test_stack():
    args = Namespace(**args_dict)
    args.stack = 'NE'
    args.stack_count = 5
    roster = run(NFL, args)
    ne_players_count = len(
        [p for p in roster.sorted_players() if p.team == 'NE'])
    ntools.assert_equals(5, ne_players_count)
コード例 #16
0
def test_locked_constraint():
    args = Namespace(**args_dict)
    jb = 'Jacoby Brissett'
    args.teams = ['NE', 'Dal']
    args.banned = []
    args.locked = [jb]
    roster = run(NFL, [], args)
    ntools.assert_true([p for p in roster.players if p.name == jb][0].lock)
コード例 #17
0
def test_lock_overrides():
    args = Namespace(**args_dict)
    args.teams = ['NE', 'Dal']
    args.v_avg = 1
    args.locked = ['Eli Manning']
    roster = run(NFL, [], args)
    ntools.assert_true([p for p in roster.players
                        if p.name == 'Eli Manning'][0].lock)
コード例 #18
0
def test_locked_constraint():
    args = Namespace(**args_dict)
    jb = 'Jacoby Brissett'
    args.teams = ['NE', 'Dal']
    args.banned = []
    args.locked = [jb]
    roster = run(NFL, args)
    ntools.assert_true([p for p in roster.players if p.name == jb][0].lock)
コード例 #19
0
def test_teams_constraint():
    args = Namespace(**args_dict)
    args.teams = ['NE', 'Dal']
    roster = run(NFL, [], args)
    for p in roster.players:
        if p.pos == 'DST':
            continue
        ntools.assert_true(p.team == 'NE' or p.team == 'Dal')
コード例 #20
0
def test_lock_overrides():
    args = Namespace(**args_dict)
    args.teams = ['NE', 'Dal']
    args.v_avg = 1
    args.locked = ['Eli Manning']
    roster = run(NFL, args)
    ntools.assert_true(
        [
            p for p in roster.players
            if p.name == 'Eli Manning'
        ][0].lock
    )
コード例 #21
0
def test_te_combo():
    # wr combo
    args = Namespace(**args_dict)
    args.force_combo = True
    args.banned = ['Eli Manning']

    roster = run(NFL, args)
    qb = roster.sorted_players()[0]
    ntools.assert_equal(qb.pos, 'QB')
    team_count = len([x for x in roster.sorted_players() if x.team == qb.team])
    ntools.assert_equals(team_count, 2)

    # qb/te combo
    args.combo_allow_te = True
    roster = run(NFL, args)
    qb = roster.sorted_players()[0]
    ntools.assert_equal(qb.pos, 'QB')
    team_count = len([
        x for x in roster.sorted_players()
        if x.team == qb.team and x.pos == 'TE'
    ])
    ntools.assert_equals(team_count, 1)
コード例 #22
0
def test_optimize_with_general():
    run_args = Namespace(
        game='draftkings',
        dtype='wr',
        duo='n',
        i=1,
        season=2016,
        w=1,
        historical='n',
        league='NBA',
        limit='n',
        lp=0,
        no_double_te='n',
        mp=100,
        ms=10000,
        s='n',
        sp=3000,
        home=None,
        locked=None,
        teams=None,
        banned=None,
        po=0,
        po_location=None,
        v_avg=10000,
        source='nba_rotogrinders',
        salary_file=os.getcwd() + '/test/data/nba-test-salaries.csv',
        projection_file=os.getcwd() + '/test/data/nba-test-projections.csv',
        flex_position=None,
        min_avg=-1,
        historical_date=None,
    )
    roster = run('NBA', run_args)

    def get_player_count_at_pos(pos):
        return len([
            p for p in roster.players
            if p.nba_general_position == pos
        ])

    ntools.assert_equal(4, get_player_count_at_pos('G'))
    ntools.assert_equal(3, get_player_count_at_pos('F'))
    ntools.assert_equal(1, get_player_count_at_pos('C'))
コード例 #23
0
def test_bad_constraints():
    args = Namespace(**args_dict)
    args.lp = 1000
    roster = run(NFL, [], args)
    ntools.assert_equal(roster, None)
コード例 #24
0
def test_default_constraints():
    args = Namespace(**args_dict)
    roster = run(NFL, args)
    assert roster
コード例 #25
0
def test_is_home():
    args = Namespace(**args_dict)
    args.home = True
    roster = run(NFL, args)
    for p in roster.players:
        ntools.assert_true(p.is_home)
コード例 #26
0
ファイル: test.py プロジェクト: RichFlorez/draft-kings-fun
def test_duo_constraint():
    default_args.duo = 'NE'
    roster = run(POSITIONS[NFL], NFL, [], default_args, True)
    team_instances = Counter([p.team for p in roster.players]).values()
    assert 2 in team_instances
コード例 #27
0
ファイル: test.py プロジェクト: BenBrostoff/draft-kings-fun
def test_is_home():
    default_args.home = True
    roster = run(POSITIONS[NFL], NFL, [], default_args)
    for p in roster.players:
        assert p.is_home
    default_args.home = False
コード例 #28
0
def test_is_home():
    args = Namespace(**args_dict)
    args.home = True
    roster = run(NFL, [], args)
    for p in roster.players:
        ntools.assert_true(p.is_home)
コード例 #29
0
ファイル: test.py プロジェクト: BenBrostoff/draft-kings-fun
def test_bad_constraints():
    default_args.lp = 1000
    roster = run(POSITIONS[NFL], NFL, [], default_args)
    assert roster is None
コード例 #30
0
ファイル: test.py プロジェクト: RichFlorez/draft-kings-fun
def test_banned_constraint():
    jg = 'Jimmy Garoppolo'
    default_args.teams = ['NE', 'Dal']
    default_args.banned = [jg]
    roster = run(POSITIONS[NFL], NFL, [], default_args, True)
    assert jg not in [p.name for p in roster.players]
コード例 #31
0
def test_min_salary():
    args = Namespace(**args_dict)
    args.sp = 3500
    roster = run(NFL, args)
    for p in roster.players:
        ntools.assert_true(p.cost >= 3500)
コード例 #32
0
def test_bad_constraints():
    args = Namespace(**args_dict)
    args.lp = 1000
    roster = run(NFL, args)
    ntools.assert_equal(roster, None)
コード例 #33
0
def test_duo_constraint():
    args = Namespace(**args_dict)
    args.duo = 'NE'
    roster = run(NFL, [], args)
    team_instances = Counter([p.team for p in roster.players]).values()
    ntools.assert_in(2, team_instances)
コード例 #34
0
ファイル: test.py プロジェクト: RichFlorez/draft-kings-fun
def test_default_constraints():
    roster = run(POSITIONS[NFL], NFL, [], default_args, True)
    assert roster
コード例 #35
0
def test_default_constraints():
    args = Namespace(**args_dict)
    roster = run(NFL, [], args)
    assert roster
コード例 #36
0
def test_multi_roster():
    args = Namespace(**args_dict)
    roster = run(NFL, args)
    second_roster = run(NFL, args, [roster])
    ntools.assert_not_equals(roster == second_roster, True)
コード例 #37
0
def test_multi_roster():
    args = Namespace(**args_dict)
    roster = run(NFL, args)
    second_roster = run(NFL, args, [roster])
    ntools.assert_not_equals(roster == second_roster, True)
コード例 #38
0
def test_duo_constraint():
    args = Namespace(**args_dict)
    args.duo = 'NE'
    roster = run(NFL, args)
    team_instances = Counter([p.team for p in roster.players]).values()
    ntools.assert_in(2, team_instances)
コード例 #39
0
ファイル: test.py プロジェクト: BenBrostoff/draft-kings-fun
def test_duo_constraint():
    default_args.duo = 'NE'
    roster = run(POSITIONS[NFL], NFL, [], default_args)
    team_instances = Counter([p.team for p in roster.players]).values()
    assert 2 in team_instances
コード例 #40
0
ファイル: test.py プロジェクト: BenBrostoff/draft-kings-fun
def test_default_constraints():
    roster = run(POSITIONS[NFL], NFL, [], default_args)
    assert roster
コード例 #41
0
def test_min_salary():
    args = Namespace(**args_dict)
    args.sp = 3500
    roster = run(NFL, [], args)
    for p in roster.players:
        ntools.assert_true(p.cost >= 3500)
コード例 #42
0
ファイル: test.py プロジェクト: BenBrostoff/draft-kings-fun
def test_banned_constraint():
    jg = 'Jimmy Garoppolo'
    default_args.teams = ['NE', 'Dal']
    default_args.banned = [jg]
    roster = run(POSITIONS[NFL], NFL, [], default_args)
    assert jg not in [p.name for p in roster.players]
コード例 #43
0
ファイル: dlc.py プロジェクト: mathsaey/DLC
argParser.add_argument("--dot", action = "store_true", help = "Generate a dot graph of the program")
args = argParser.parse_args()

# ------------------- #
# Compilation Process #
# ------------------- #

if args.path is '-':
	file = sys.stdin
else: 
	file = open(args.path, 'r')
	fileName, fileExtension = os.path.splitext(args.path)

frontend.read(file.read())

try:
	graph = frontend.get()
except frontend.Error:
	print >> sys.stderr, "There are errors in your program."
	sys.exit(1)

if args.dot: IGR.dot(graph, path = "pre.dot")
optimize.run(graph)
if args.dot: IGR.dot(graph, path = "post.dot")

dis = backend.convert(graph)
if args.path is '-': 
	print dis
else:
	file = open('%s.%s' % (fileName, 'dis'), 'w')
	file.write(dis)
コード例 #44
0
ファイル: test.py プロジェクト: RichFlorez/draft-kings-fun
def test_bad_constraints():
    default_args.lp = 1000
    roster = run(POSITIONS[NFL], NFL, [], default_args, True)
    assert roster is None