This file contains 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
"""Build the timefunc decorator.""" | |
import time | |
import functools | |
def timefunc(func): | |
"""timefunc's doc""" | |
@functools.wraps(func) |
This file contains 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 os | |
from sqlalchemy import create_engine | |
from sqlalchemy.ext.declarative import declarative_base | |
from sqlalchemy.orm import sessionmaker | |
SQLALCHEMY_DATABASE_URL = os.getenv("DB_CONN") | |
engine = create_engine(SQLALCHEMY_DATABASE_URL) | |
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) |
This file contains 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 functools | |
def tracefunc(func): | |
"""Decorates a function to show its trace.""" | |
@functools.wraps(func) | |
def tracefunc_closure(*args, **kwargs): | |
"""The closure.""" | |
result = func(*args, **kwargs) |
This file contains 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
[tool.poetry] | |
name = "covid-forecast-poetry" | |
version = "0.1.0" | |
description = "" | |
authors = ["edkrueger <edkrueger@gmail.com>"] | |
[tool.poetry.dependencies] | |
python = "==3.7.5" | |
fbprophet = "==0.6" | |
matplotlib = "==3.2.2" |
This file contains 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
pikachu_cry = make_pokemon("Pika") | |
pikachu_cry() |
This file contains 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
pikachu = Pokemon("Pika") | |
pikachu.cry() |
This file contains 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
def citrus_press_factory(press_type): | |
"""Creates a citrus press.""" | |
press_types = {"lime", "lemon", "orange", "grapefruit"} | |
if not press_type in press_types: | |
raise ValueError(f"press_type must be one of {press_types}") | |
compatible_fruit_types_lookup = { | |
"lime": {"lime", "lemon"}, | |
"lemon": {"lime", "lemon"}, |
This file contains 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
"""You can use currying to replicate the behavior of some classes.""" | |
class Pokemon: | |
def __init__(self, sound): | |
self.sound = sound | |
def cry(self): | |
return self.sound |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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 joblib import Parallel, delayed | |
def multiprocess(inputs): | |
return Parallel(n_jobs=2)(delayed(f)(x) for x in inputs) |
NewerOlder