def create(**kwargs):
        # subject = Field.query.filter_by(id=field_id).first()

        comp = Competition(name=kwargs['name'],
                           date=kwargs['date'],
                           field_id=kwargs['field'].id)
        comp.field = kwargs['field']

        return CompetitionService.add(comp, kwargs.get('commit', False))
    def pop_competition(self):
        comp = None

        if self.validate():
            comp = Competition(name=self.name.data,
                               date=self.date.data,
                               field_id=self.subject.data.id)

            comp.field = self.subject.data

        return comp
Beispiel #3
0
    def test_your_competition_class(self):
        # TODO: Run tests against your competition class.
        self.run_test(Competition)

        for testcase in testcases.testcases:
            competition = Competition(competitors=testcase['competitors'],
                                      duration=testcase['duration'])
            events = list(competition.run())

            expected_winner = events[len(events) - 1].name
            real_winner = competition.winner()
            self.assertEqual(real_winner, expected_winner)
Beispiel #4
0
class CompetitionTest(unittest.TestCase):
    def setUp(self):
        self.competition = Competition('fixture1.csv')

    def test_init(self):
        self.assertEqual(len(self.competition.games), 3)
        self.assertEqual(len(self.competition.teams.keys()), 3)

    def test_processing(self):
        self.competition.process()
        self.assertEqual(len(self.competition.teams), 3)
        gro = self.competition.teams['GRO']
        self.assertEqual(gro.points, 4)
        self.assertEqual(gro.goals, 3)
        self.assertEqual(gro.goals_against, 3)
        self.assertEqual(gro.saldo(), 0)
Beispiel #5
0
def create_comp(comp):
  with open(f'./competitions/{comp}.json') as comp_json:
    comp_dict = json.load(comp_json)
    teams = []
    for team in comp_dict["teams"]:
      matches_needed = team["min_matches"]
      temp_team = Team(team["names"], matches_needed)
      teams.append(temp_team)
  return Competition(teams)
Beispiel #6
0
    def __init__(self, host, port, competition=None):
        self._host = host
        self._port = port
        self._app = Bottle()
        self._route()

        self.competition = competition
        if not self.competition:
            self.competition = Competition(games_to_run=100)

            # Have a default AI for people to play against
            self.competition.add("Internal Demo", BattleshipsAI)
Beispiel #7
0
 def get_move(self, board):
     start = time.time()
     from competition import Competition
     self.board = board
     random_player = Player('random')
     best_move = {
         engine.UP: 0,
         engine.DOWN: 0,
         engine.LEFT: 0,
         engine.RIGHT: 0
     }
     for initial_move in best_move:
         new_board = copy.deepcopy(self.board)
         new_board.move_board(initial_move)
         comp = Competition(games_number=self.games_number,
                            game_size=self.board.size,
                            max_turns=self.max_turns,
                            players=[random_player],
                            initial_board=new_board,
                            store_in_db=False)
         comp.play()
         comp.show_results()
         average = comp.results['score'].mean()
         best_move[initial_move] = average
     maxi = max(best_move, key=lambda k: best_move[k])
     end = time.time()
     #print('move is ',maxi,'time is ', end-start)
     return maxi
def setup():
    a_competition = Competition('Mitre 10 Cup', 2018)
    competition_data = json.loads(open('json.txt').read())
    results_data = json.loads(open('BETTERresultsJSON.txt').read())

    all_teams = competition_data['teams']
    for team in all_teams:
        a_competition.add_team(team['rank'], team['name'], team['venue'], team['city'])
    all_games = competition_data['games']
    for game in all_games:
        a_competition.add_game(game['week'], game['homeTeamRank'], game['awayTeamRank'], game['dateTime'])

    all_results = results_data['results']
    for result in all_results:
        a_competition.find_game_add_result(result['homeTeamRank'], result['awayTeamRank'], result['homeTeamScore'], result['awayTeamScore'], result['homeTeamTries'], result['awayTeamTries'])
    return a_competition
Beispiel #9
0
def setup():
    a_competition = Competition('Mitre 10 Cup', 2018)
    competition_data = json.loads(open('json.txt').read())
    all_teams = competition_data['teams']
    for team in all_teams:
        a_competition.add_team(team['rank'], team['name'], team['venue'],
                               team['city'])
    all_games = competition_data['games']
    for game in all_games:
        a_competition.add_game(game['week'], game['homeTeamRank'],
                               game['awayTeamRank'], game['dateTime'])
    getResults(the_2018_competition)
    return a_competition
Beispiel #10
0
def setup():
    the_2018_competition = Competition('Mitre 10 Cup', 2018)
    competition_data = json.loads(open('json.txt').read())
    # print (competition_data)
    all_teams = competition_data['teams']
    # print (all_teams)
    for team in all_teams:
        the_2018_competition.addTeam(team['rank'], team['name'], team['venue'],
                                     team['city'])
    all_games = competition_data['games']
    for game in all_games:
        the_2018_competition.addGame(game['week'], game['homeTeamRank'],
                                     game['awayTeamRank'], game['dateTime'])
    return the_2018_competition
Beispiel #11
0
 def __init__(self,
              club,
              teams,
              league,
              fixtures=[],
              played=[],
              competition=Competition(),
              new=True):
     super(Manager, self).__init__()
     self.club = Club(club)
     self.teams = teams
     self.league = league
     self.fixtures = fixtures
     self.played = played
     self.stats = {"Points: ": 0, "Wins: ": 0, "Draws: ": 0, "Losses: ": 0}
     self.competition = competition
     self.new = new
     print(self.new)
     if self.new:
         self._generate_fixtures()
Beispiel #12
0
 def setUp(self):
     self.competition = Competition('fixture1.csv')
Beispiel #13
0
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from competition import Competition
from competition import WIKI_MEDIUM_10M

# simple example that runs benchmark with WIKI_MEDIUM source and taks files
# Baseline here is ../trunk versus ../patch
if __name__ == '__main__':
    # debug=True uses a smaller number of documents and less iterations when searching
    comp = Competition(debug=True)

    index = comp.newIndex('trunk', WIKI_MEDIUM_10M)
    # create a competitor named baseline with sources in the ../trunk folder
    comp.competitor('baseline', 'trunk', index=index)

    # use the same index here
    # create a competitor named my_modified_version with sources in the ../patch folder
    # note that we haven't specified an index here, luceneutil will automatically use the index from the base competitor for searching
    # while the codec that is used for running this competitor is taken from this competitor.
    comp.competitor('my_modified_version', 'patch', index=index)

    # start the benchmark - this can take long depending on your index and machines
    comp.benchmark("trunk_vs_patch")
Beispiel #14
0
driver = webdriver.Chrome('/usr/bin/chromedriver', options=chrome_options)

url = "https://www.fis-ski.com/DB/alpine-skiing/calendar-results.html?eventselection=&place=&sectorcode=AL&seasoncode=2021&categorycode=WC&disciplinecode=&gendercode=&racedate=&racecodex=&nationcode=&seasonmonth=X-2021&saveselection=-1&seasonselection="

driver.get(url)
print("Main page loaded")

elems = driver.find_elements_by_class_name("table-row")

# elems = elems[10:13]

competitionList = []

for e in elems:
    competition = Competition(e)
    competitionList.append(competition)

liveEvent = []
# For each competition, go to the corresponding page
for competition in competitionList:
    competition.addEvents()

    if competition.live:
        liveEvent.append(competition)

# liveEvent=competitionList

# Send email about live competitions
# sendHTMLEmail()
Beispiel #15
0
class BattleshipsServer(object):

    """ A server for providing a dashboard to Battleships game. """

    def __init__(self, host, port, competition=None):
        self._host = host
        self._port = port
        self._app = Bottle()
        self._route()

        self.competition = competition
        if not self.competition:
            self.competition = Competition(games_to_run=100)

            # Have a default AI for people to play against
            self.competition.add("Internal Demo", BattleshipsAI)

    def _route(self):
        """ Set up bottle routes for the app. """
        self._app.route('/', method="GET", callback=self.index)
        self._app.route('/entries', method="GET", callback=self.entries)
        self._app.route('/enter', method="POST", callback=self.add_entry)
        self._app.route('/static/bower_components/<filepath:path>',
                        callback=self.serve_bower)
        self._app.route('/static/<filepath:path>', callback=self.serve_static)

    def start(self):
        """ Start the bottle server. """
        self._app.run(host=self._host, port=self._port)

    def serve_bower(self, filepath):
        """ Serve bower components. """
        return static_file(filepath, root='server/bower_components')

    def serve_static(self, filepath):
        """ Server /static files. """
        return static_file(filepath, root='server/static')

    def index(self):
        """ The game dashboard. """
        return template('index')

    def entries(self):
        """ Dump all entries as json. """
        return json.dumps(self.competition.entries.values(), cls=EntryEncoder)

    def add_entry(self, code=None, forms=None):
        """ Add an entry to the competition. """
        if code is None:
            code = request.files.get("filedata").file.read()
        if forms is None:
            forms = request.forms
        exec(code, globals())
        team_name = BattleshipsAI.TEAM_NAME
        if team_name in self.competition.entries and\
                not forms.get('replace') == "1":
            increment = 1
            while team_name + " " + n2w(increment) in self.competition.entries:
                increment += 1
            team_name = team_name + " " + n2w(increment)
        self.competition.add(team_name, BattleshipsAI)
Beispiel #16
0
# -*- coding: utf-8 -*-
"""
Created on Mon May 14 17:12:19 2018

@author: greg
"""

import requests
from bs4 import BeautifulSoup
import codecs
import time
import pandas as pd
import numpy as np
from competition import Competition
from competitor import Competitor
from dataManager import DataManager

competition_manager = Competition()
competitor_manager = Competitor()
data_manager = DataManager()
Beispiel #17
0
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from competition import Competition
from sklearn.metrics import roc_auc_score
from taigapy import TaigaClient
import seaborn as sns
import random

from pygcnn.utils import *
from pygcnn.indexing import *
from pygcnn.layers import *
from pygcnn.backbone import *

# Load training + test data
client = Competition()
taiga_client = TaigaClient()

features = taiga_client.get(name='rnaseq-gene-expression-5362', file='RNAseq_CCLE_RSEM_TPM', version='6').transpose().rename(lambda x: x.split(" (", 1)[0]).transpose()
targets = taiga_client.get(name='ccle-copy-number-variants-hgnc-mapped', version='4').rename(lambda x: x.split(" (", 1)[0]).transpose()

cls = list(set(list(features.transpose())) & set(list(targets.transpose())))
random.shuffle(cls)
train_cls = cls[50:]
test_cls = cls[:50]

feature_genes = list(set(list(features)) & set(list(targets)))
target_genes = list(set(list(features)) & set(list(targets)))

features = features[feature_genes]
targets = targets[target_genes]
Beispiel #18
0
#     http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from competition import Competition
from competition import WIKI_MEDIUM_10M

# simple example that runs benchmark with WIKI_MEDIUM source and taks files 
# Baseline here is ../trunk versus ../patch
if __name__ == '__main__':
  # debug=True uses a smaller number of documents and less iterations when searching
  comp =  Competition(debug=True)

  index = comp.newIndex('trunk', WIKI_MEDIUM_10M)
  # create a competitor named baseline with sources in the ../trunk folder
  comp.competitor('baseline', 'trunk',
                  index = index)

  # use the same index here
  # create a competitor named my_modified_version with sources in the ../patch folder
  # note that we haven't specified an index here, luceneutil will automatically use the index from the base competitor for searching 
  # while the codec that is used for running this competitor is taken from this competitor.
  comp.competitor('my_modified_version', 'patch',
                  index = index)

  # start the benchmark - this can take long depending on your index and machines
  comp.benchmark("trunk_vs_patch")
Beispiel #19
0
# PlayFighting Cats App
#
# Create a program where two cats compete in a playfight for food.
#
# We need to create a couple of cats, some food, and a way to have a 
# playfight and determine who wins the food.
from food import Food
from cat import Cat
from competition import Competition

# Create some food
prize_food = Food()

# Create two cats that will playfight
sunny = Cat('Sunny the Cat', 16, 27, 'medium')
bob = Cat('Robert the Cat', 9, 30, 'large')

# we have two cats, sunny and bob, who are competing in a 
# playfight for TheFood.
# 
# What are rules do we need for a playfight?

# We have energy, size, and pride as attributes for cats.
# Let's make some rules that determine who wins a playfight
# based on those attributes.

# What should those rules be?
competition1 = Competition(sunny, bob)
competition1.playfight(prize_food)
Beispiel #20
0
def seed(database):
    """
        Function that makes an initial database data seed
        so we could have something to work on after DB init.
    """

    # User roles are inserted first
    Role.insert_roles()

    # List of object to be added to DB
    users = []

    # Users
    s1 = Student(name='John',
                 surname='Doe',
                 email='*****@*****.**',
                 index_number='10000',
                 study_year=3)
    s1.password = "******"
    s1.confirmed = True
    users.append(s1)

    s2 = Student(name='Demo',
                 surname='User',
                 email='*****@*****.**',
                 index_number='10001',
                 study_year=2)
    s2.password = "******"
    s2.confirmed = True
    users.append(s2)

    s3 = Student(name='Mary',
                 surname='Lilly',
                 email='*****@*****.**',
                 index_number='10002',
                 study_year=1)
    s3.password = '******'
    s3.confirmed = True
    users.append(s3)

    s4 = Student(name='Jolly',
                 surname='Foster',
                 email='*****@*****.**',
                 index_number='10003',
                 study_year=1)
    s4.password = '******'
    s4.confirmed = True
    users.append(s4)

    s5 = Student(name='Mike',
                 surname='Young',
                 email='*****@*****.**',
                 index_number='10004',
                 study_year=1)
    s5.password = '******'
    s5.confirmed = True
    users.append(s5)

    a1 = Administrator(name='Some',
                       surname='Body',
                       email='*****@*****.**',
                       position='Assistent')
    a1.password = '******'
    users.append(a1)

    a2 = Administrator(name='Eddy',
                       surname='Maiden',
                       email='*****@*****.**',
                       position='Professor')
    a2.password = '******'
    users.append(a2)

    a3 = Administrator(name='Master',
                       surname='Yoda',
                       email='*****@*****.**',
                       position='Professor')
    a3.password = '******'
    users.append(a3)

    a4 = Administrator(name='Qui Gon',
                       surname='Gin',
                       email='*****@*****.**',
                       position='Professor')
    a4.password = '******'
    users.append(a4)

    # Fields
    fields = [
        Field(name='Baze podataka'),
        Field(name='Operativna istraživanja'),
        Field(name='Optimizacija resursa'),
        Field(name='Paralelni računarski sistemi'),
        Field(name='Multimedijalni sistemi'),
    ]

    # Competitions
    competitions = [
        Competition("Prvo takmičenje", "11.12.2018", 1),
        Competition("Drugo takmičenje", "11.01.2018", 2),
        Competition("Treće takmičenje", "01.12.2018", 3)
    ]

    users[6].competitions.append(competitions[1])

    # Seeding the data to db session
    data = fields + competitions + users
    for o in data:
        database.session.add(o)

    database.session.flush()

    users[1].participations.append(
        Participation(user_id=users[1].id,
                      competition_name=competitions[0].name,
                      competition_date=competitions[0].date))
    users[1].participations.append(
        Participation(user_id=users[1].id,
                      competition_name=competitions[1].name,
                      competition_date=competitions[1].date))
    users[1].participations.append(
        Participation(user_id=users[1].id,
                      competition_name=competitions[2].name,
                      competition_date=competitions[2].date))

    users[7].competitions.append(competitions[1])

    database.session.flush()

    data.append(Result(participation_id=0, points_scored=10))
    data.append(Result(participation_id=1, points_scored=15))
    data.append(Result(participation_id=2, points_scored=20))