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
#!/usr/bin/env python3 | |
import argparse | |
import functools | |
import heapq | |
from collections import Counter | |
from dataclasses import dataclass | |
from typing import * | |
import more_itertools as mitt | |
import networkx as nx |
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 typing import Any, Dict, Union | |
NestedStringDict = Dict[str, Union[Any, "NestedStringDict"]] | |
def flatten_dict(nested: NestedStringDict, /, *, sep: str = "_") -> Dict[str, Any]: | |
""" | |
Flatten a nested dictionary with string keys. |
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
""" | |
Enum union based on and compatible with the standard library's `enum`. | |
""" | |
# MIT License | |
# | |
# Copyright (c) 2020 Paolo Lammens | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal |
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 keras | |
import matplotlib.pyplot as plt | |
def plot_history(history: keras.callbacks.History): | |
metrics = [metric for metric in history.history.keys() if not metric.startswith('val_')] | |
stride = len(history.epoch)//20 | |
plotted_epochs = history.epoch[::stride] | |
fig, subplots = plt.subplots(len(metrics), figsize=(8, 4*len(metrics))) |
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 re | |
import argparse | |
START_PATT = re.compile(r'^```\{r([ \w]*).*\}$') | |
END_PATT = re.compile(r'^```$') | |
HEADER_PATT = re.compile(r'^(?P<level>#+) (?P<name>.+)$') | |
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 glob | |
import re | |
pattern = re.compile(r"-D(?= *-D)") | |
for filename in glob.glob("CMakeFiles/*.dir/flags.make"): | |
print("Inspecting '{}'. ".format(filename), end='') |
NewerOlder