Skip to content

Instantly share code, notes, and snippets.

View bdpedigo's full-sized avatar

Ben Pedigo bdpedigo

View GitHub Profile
@bdpedigo
bdpedigo / uv_tricks.md
Last active December 9, 2024 22:50
`uv` tricks

See what packages would be installed if looking for the oldest version of everything, and not building from source

uv pip install --requirements pyproject.toml --no-build --dry-run --resolution lowest

See what would be installed on Windows, and not building from source

uv pip install --requirements pyproject.toml --dry-run --no-build --python-platform windows

See what packages are constraining the version of a particular dependency

@bdpedigo
bdpedigo / matplotlib_to_ngl_shader.py
Created September 5, 2025 18:51
Convert any matplotlib colormap to a Neuroglancer shader
def linear_shader_from_matplotlib(cmap: str, n_colors=33, name=None):
"""
Convert a matplotlib colormap to a webgl shader function.
"""
colors = colormaps[cmap](np.linspace(0, 1, n_colors))
if name is None:
name = cmap
shader_string = (
f"""
vec3 {name}(float t) """
@bdpedigo
bdpedigo / csv_to_deltatable.py
Created September 12, 2025 16:22
Read in a large CSV and write it to a DeltaTable in chunks
# %%
import time
from pathlib import Path
import pandas as pd
import polars as pl
from deltalake import DeltaTable, write_deltalake
from deltalake.table import TableOptimizer
from deltalake.writer import BloomFilterProperties, ColumnProperties, WriterProperties
@bdpedigo
bdpedigo / pull_inhibitory_synapses.py
Last active October 3, 2025 16:46
Pull many synapses from a deltalake partitioned by post_pt_root_id
# %%
import time
from pathlib import Path
import matplotlib.pyplot as plt
import polars as pl
import seaborn as sns
from caveclient import CAVEclient
from nglui.statebuilder import ViewerState