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='') |
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 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))) |
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
""" | |
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 |
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
#!/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
""" | |
Metaclass for inner classes in Python. | |
""" | |
# 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 |
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
""" | |
Algorithm to recursively apply a function to a composite object. | |
Dependencies: | |
- multimethod (https://pypi.org/project/multimethod/) | |
""" | |
# MIT License | |
# | |
# Copyright (c) 2020 Paolo Lammens |
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
# MIT License | |
# | |
# Copyright (c) 2021 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 | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
# copies of the Software, and to permit persons to whom the Software is | |
# furnished to do so, subject to the following conditions: |
OlderNewer