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 argparse | |
from pathlib import Path | |
import signature | |
def concat(folder: str, output: str = 'concat.txt', include_names: bool = True): | |
"""Concatenates a list of files from a folder and saves them into a single file.""" | |
p = Path(folder) | |
files = [] | |
for filename in p.iterdir(): |
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 argparse | |
import signature | |
def make_cli(func: callable): | |
parser = argparse.ArgumentParser() | |
sig = inspect.signature(func) | |
empty = inspect._empty | |
for param in sig.parameters.values(): | |
annot = param.annotation |
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 pathlib import Path | |
def concat(folder: str, output: str = 'concat.txt', include_names: bool = True): | |
"""Concatenates a list of files from a folder and saves them into a single file.""" | |
p = Path(folder) | |
files = [] | |
for filename in p.iterdir(): | |
content = filename.open('r').read().strip() | |
if include_names: | |
content = f'{filename}\n{content}\n' |
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 pytest | |
@pytest.mark.parametrize('state', [ | |
'ooo|x.x|..x', | |
'xo.|xo.|x..', | |
'x..|.xo|o.x' | |
]) | |
def test_game_has_winner(state): | |
game = Game(state) | |
assert game.has_winner() |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
def generate_dataset(n_rows, num_count, cat_count, max_nan=0.1, max_cat_size=100): | |
"""Randomly generate datasets with numerical and categorical features. | |
The numerical features are taken from the normal distribution X ~ N(0, 1). | |
The categorical features are generated as random uuid4 strings with | |
cardinality C where 2 <= C <= max_cat_size. | |
Also, a max_nan proportion of both numerical and categorical features is replaces | |
with NaN values. | |
""" |
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 curses | |
def main(term): | |
term.clear() | |
for i in range(10): | |
# try to debug after curses mangled the terminal | |
breakpoint() | |
term.addstr(i, 0, f'String: {i + 1:d}') | |
term.refresh() | |
term.getkey() |
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 itertools import chain | |
import click | |
import matplotlib.pyplot as plt | |
from matplotlib import rcParams | |
default_style = { | |
'font.family': 'monospace', | |
'font.size': 18, | |
'figure.figsize': (8, 6) |
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
""" | |
Scatter plots generator. | |
Usage: | |
scatter <filename> <X> <Y> (<X> <Y>)... | |
""" | |
from itertools import chain | |
import docopt | |
import matplotlib.pyplot as plt |