Skip to content

Instantly share code, notes, and snippets.

@PaulScemama
PaulScemama / pyutil.py
Created April 4, 2024 14:03
Bunch of useful utility functions implemented in Python.
from typing import List, Dict, Generator
def flatten_luple(struct: List | tuple) -> Generator:
"""Flatten a list/tuple.
E.g. [(1,2,3), [5,6], 3] -> 1, 2, 3, 4, 5, 6
Args:
struct (List | tuple): A list or tuple
@PaulScemama
PaulScemama / gmm1d.py
Created December 13, 2023 19:17
1D Gaussian Mixture Model in JAX.
from typing import NamedTuple, Callable
import jax.numpy as jnp
import jax.random as random
import jax.scipy.stats as stats
import numpy as np
import plotext as plt
from jax import vmap
@PaulScemama
PaulScemama / printarr
Created March 14, 2023 12:42 — forked from nmwsharp/printarr
Pretty print tables summarizing properties of tensor arrays in numpy, pytorch, jax, etc.
Pretty print tables summarizing properties of tensor arrays in numpy, pytorch, jax, etc.