This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """Test data base module""" | |
| import unittest | |
| from data_engineering.database.fake_players import generate_fake_player | |
| from data_engineering.database.players import Player | |
| from data_engineering.database.postgres_db import DataBase | |
| class TestDB(unittest.TestCase): | |
| def setUp(self) -> None: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from faker import Faker | |
| import random | |
| COUNTRIES = ['Argentina', 'Portugal', 'France', 'Brazil', | |
| 'England', 'Belgium', 'Italy', 'Spain', 'Germany', | |
| 'Ivory coast', 'Guinea', 'Senegal', 'Ghana', | |
| 'Nigeria', 'Cameroun', 'Egypt', 'Morocco', 'Algeria', | |
| 'USA', 'Croatia', 'Sweden', 'Columbia', 'Netherlands', | |
| 'Danemark', 'Ireland', 'Switzerland'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """Class defining some queries for the database via SQLAlchemy""" | |
| from typing import List | |
| from data_engineering.database.base import Base, Session, data_base | |
| from data_engineering.database.players import Player | |
| class DataBase: | |
| def __init__(self): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """Create players class and define its characteristics""" | |
| from data_engineering.database.base import Base | |
| from sqlalchemy import String, Integer, Column, Boolean | |
| class Player(Base): | |
| __tablename__ = 'players' | |
| id = Column(Integer, primary_key=True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """This code creates: | |
| * a SQLAlchemy Engine that will interact with our dockerized PostgreSQL database, | |
| * a SQLAlchemy ORM session factory bound to this engine, | |
| * a base class for our classes definitions. | |
| """ | |
| from sqlalchemy import create_engine | |
| from sqlalchemy.ext.declarative import declarative_base | |
| from sqlalchemy.orm import sessionmaker |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from decimal import Decimal | |
| # We can construct decimal numbers with integers, floats and strings | |
| # Using integers and floats return the exact representation of the | |
| # as stored by Python, on 64 bits | |
| a = Decimal(0.1) # Decimal('0.1000000000000000055511151231257827021181583404541015625') | |
| b = Decimal('0.1') # Decimal('0.1') | |
| # It also works with NaN and Infinity | |
| decimal_nan = Decimal('NaN') |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| class PSO(object): | |
| """ | |
| Class implementing PSO algorithm. | |
| """ | |
| def __init__(self, func, init_pos, n_particles): | |
| """ | |
| Initialize the key variables. |