✂️ Snippets¶
This repository contains useful, tested code snippets and command line tools.
pip install git+https://github.com/tillahoffmann/snippets.git[@optional commit hash]
✂️ Code Snippets¶
call_with_timeout(): Call a target with a timeout and return its result.sample_empirical_cdf(): Sample from a univariate empirical cumulative distribution function using interpolation of the inverse cumulative distribution function.sample_empirical_pdf(): Sample from a univariate empirical probability distribution function using interpolation of the inverse probability distribution function.NearestNeighborSampler: Draw approximate posterior samples using a nearest neighbor algorithm.Affine: Apply a fixed affine transform \(y = x A^\intercal + b\) akin totorch.nn.Linear.StopOnPlateau: Stop training when a monitored quantity plateaus akin totorch.optim.lr_scheduler.ReduceLROnPlateau.from_param_dict(): Convert a dictionary of parameters to a tensor of parameters for batch processing.to_param_dict(): Convert a tensor of parameters to a dictionary of parameters.arrow_path(): Create an arrow at the end of a path.dependence_heatmap(): Show the dependence between parameters as a heatmap.get_anchor(): Get an anchor on the boundary of an artist at the given “hour”.label_axes(): Add labels to axes.parameterization_mutual_info(): Scatter plot of the mutual information between scale and location parameters for centered and non-centered parameterizations.plot_band(): Plot a central line and shaded band for samples.rounded_path(): Create a path with rounded corners.GaussianKernelDensity: Gaussian kernel density estimator.TensorDataLoader: Fast data loader for torch tensor datasets, fusingtorch.utils.data.TensorDatasetandtorch.utils.data.DataLoader.Timer: Measure elapsed time using a context.
🧑💻 Command Line Tools¶
CheckReferences: Check LaTeX documents for missing or unused references.CheckPdfHyperlinks: Check LaTeX documents for missing or unused references.