Skip to content

Instantly share code, notes, and snippets.

View lgarrison's full-sized avatar

Lehman Garrison lgarrison

View GitHub Profile
@lgarrison
lgarrison / bench_zarr_write.py
Created July 8, 2025 21:28
zarr write benchmark script
# /// script
# requires-python = ">=3.13"
# dependencies = [
# "click",
# "tqdm",
# "zarr",
# "zarrs",
# ]
# ///
@lgarrison
lgarrison / zipper.py
Last active June 24, 2025 20:14
benchmarking different index matching algorithms
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "numba",
# "numpy",
# ]
# ///
# Example output:
@lgarrison
lgarrison / halos.ecsv
Created June 2, 2024 18:35
a simple LSS catalog from N-body halos
This file has been truncated, but you can view the full file.
# %ECSV 1.0
# ---
# datatype:
# - {name: x, datatype: float32}
# - {name: y, datatype: float32}
# - {name: z, datatype: float32}
# meta: {L: 2000.0}
# schema: astropy-2.0
x y z
1002.2712 1022.61536 251.77208
@lgarrison
lgarrison / condition.ipynb
Last active February 22, 2024 23:31
finufft condition number with small inputs
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@lgarrison
lgarrison / check_bispectrum_pylians.ipynb
Created October 3, 2023 18:15
zeldovich-PLT f_NL validation notebook
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@lgarrison
lgarrison / compress.py
Created June 7, 2022 20:03
Compress a density grid with lossy + lossless compression
#!/usr/bin/env python3
'''
Compress a density grid.
Usage: ./compress.py --help
'''
from pathlib import Path
import click
@lgarrison
lgarrison / optimize_fenv.ipynb
Created February 25, 2022 18:29
optimize calc_fenv
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@lgarrison
lgarrison / potential.ipynb
Created July 13, 2021 15:54
simple N^2 gravitational potential calculator in numba
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@lgarrison
lgarrison / multithreaded_reader.py
Created May 13, 2021 19:27
Simple, blocking multithreaded reader
import numpy as np
import threading
import queue
def multithreaded_read(fns, nthreads=2):
'''
A simple multithreaded reader that spins up N threads
to read a list of files, returning the result in a list.
Reads in Numpy format by default.
@lgarrison
lgarrison / numba_ecdf.py
Last active March 29, 2021 17:44
Fast N-dimensional empirical CDF
import numba as nb
import numpy as np
def nb_ecdf(X,Rmax,ngrid=64,nthreads=1):
'''Compute the empirical CDF of points X (shape (N,D))
in domain [0,Rmax) using a histogram with `ngrid` cells
per dimension.
Rmax and ngrid can also be length D arrays.
'''