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 tqdm | |
from joblib import Parallel | |
class ParallelTqdm(Parallel): | |
"""joblib.Parallel, but with a tqdm progressbar | |
Additional parameters: | |
---------------------- | |
total_tasks: int, default: None |
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
#!/usr/bin/env python3 | |
# Find all subdirectories with uncommitted or unpushed code. | |
# | |
# This script scans through a directory recursively to identify the status of | |
# all Git repositories found within, highlighting repos with uncommitted | |
# changes, untracked files, or branches out of sync with their remote | |
# counterparts. It also identifies directories that are not Git repositories | |
# and branches without a remote counterpart. | |
# Additionally, it can fetch updates for all repositories discovered. |
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
""" | |
based on https://andyljones.com/posts/rl-debugging.html | |
Documentation is quoted from that blogpost. | |
The usual advice to people writing RL algorithms is to use a simple environment | |
like the classic control ones from the Gym. Thing is, these envs have the same | |
problem as looking at loss curves: at best they give you a noisy indicator, and | |
if the noisy indicator looks poor you don't know why it looks poor. They don't | |
localise errors. |
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 | |
from pathlib import Path | |
class PathGroup(list): | |
def __getitem__(self, y): | |
res = super().__getitem__(y) | |
return PathGroup(res) if (type(res) == list) else res | |
def glob(self, pattern): | |
return PathGroup(chain.from_iterable(sorted(p.glob(pattern)) for p in self)) | |
def __getattr__(self, name): |
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 | |
import xarray as xr | |
def register_dataarray_module(module, accessor_name=None): | |
if accessor_name is None: | |
accessor_name = module.__name__.split(".")[-1] | |
callable_funcs = [name for name in dir(module) if callable(getattr(module, name))] |
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
#!/usr/bin/env python3 | |
import getpass | |
import json | |
import re | |
import shutil | |
import socket | |
import subprocess | |
import sys | |
from dataclasses import dataclass, field | |
from pathlib import Path |