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
edit_path () | |
{ | |
local tmpfile=$(mktemp); | |
local variable="${1:-PATH}"; | |
tr ':' '\n' <<< "${!variable}" > "$tmpfile"; | |
"$EDITOR" "$tmpfile"; | |
export ${variable}="$(tr '\n' : < "$tmpfile"| sed -e 's/:$//' )" | |
} |
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 flatten_to_wideform(df, mask_column=None, max_objects=None): | |
# get the list columns | |
lst_cols = [col for col, dtype in df.dtypes.items() | |
if pd.api.types.is_object_dtype(dtype) | |
and df[col].head(10).apply(lambda x: isinstance(x, (list, np.ndarray, tuple))).all() | |
] | |
if not lst_cols: | |
return df | |
# all columns except `lst_cols` |
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 pandas as pd | |
_interval_regex = r"^(?P<open>[[(])" | |
_interval_regex += r"(?P<low>-inf|[0-9][.0-9]*)" | |
_interval_regex += r"\s*,\s*" | |
_interval_regex += r"(?P<high>\+?inf|[0-9][.0-9]*)" | |
_interval_regex += r"(?P<close>[)\]])$" | |
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 numpy as np | |
class MaskedUprootTree(): | |
def __init__(self, tree, mask=None): | |
if isinstance(tree, MaskedUprootTree): | |
self.tree = tree.tree | |
self._mask = tree._mask | |
else: | |
self.tree = tree |
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 math import pi, cos, sin, sinh, sqrt, asinh, atan2, fabs | |
class LorentzVector(object): | |
def __init__(self, x, y, z, T, r2=None): | |
self.x = x | |
self.y = y | |
self.z = z | |
self.T = T | |
if r2: |
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 python | |
import tarfile | |
import re | |
import os | |
import subprocess | |
def find_tar_files(top_dir, exclude): | |
tar_files = [] | |
for root, dirs, files in os.walk(top_dir): |