Skip to content

Instantly share code, notes, and snippets.

View brandonwillard's full-sized avatar

Brandon T. Willard brandonwillard

View GitHub Profile
@brandonwillard
brandonwillard / .pdbrc
Created July 22, 2021 19:37
A `.pdbrc` file with custom `pdb` commands
#
# XXX: This .pdbrc is only valid for Python > 3.x
#
import os
import pdb
from pprint import pprint as __pprint
from contextlib import suppress as __suppress
# Use IPython's pretty printing within PDB
@brandonwillard
brandonwillard / aesara-composite-numba-compare.py
Last active June 24, 2021 21:22
A script that runs comparisons of Aesara implementations of log-sum-exp compiled to Numba
import inspect
import numba
import numpy as np
import pandas as pd
import aesara
import aesara.tensor as at
@brandonwillard
brandonwillard / categorical-time-varying-transitions.py
Created September 2, 2020 16:45
Simple time-varying transition matrix example
import pymc3 as pm
import numpy as np
import pandas as pd
import patsy
import matplotlib.pyplot as plt
import theano
import theano.tensor as tt
@brandonwillard
brandonwillard / theano_jax_linker.py
Last active July 31, 2020 05:44
JAX Compilation Using Theano via a Custom Linker Class
import numpy as np
import theano
import theano.tensor as tt
import jax
import jax.numpy as jnp
from warnings import warn
from functools import partial, update_wrapper
@brandonwillard
brandonwillard / pymc3-poisson-zero-testing-example.ipynb
Last active June 20, 2020 05:58
PyMC3 Poisson-Zero HMM Testing Example
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@brandonwillard
brandonwillard / numba_bug.py
Created June 7, 2020 22:14 — forked from nouiz/numba_bug.py
Test how to make a Theano op that call Numba.
import numba
import numpy
#The filter2d with the same signature as Theano
#but not a class method.
def filter2d_theano(node, inputs, outputs):
image, filt = inputs
M, N = image.shape
Mf, Nf = filt.shape
@brandonwillard
brandonwillard / pymc3-to-randomvariable.py
Created June 7, 2020 02:55
Automatic PyMC3 to RandomVariable conversion prototype
import theano
import theano.tensor as tt
import pymc3 as pm
from warnings import warn
from unittest.mock import patch
from types import SimpleNamespace
from inspect import Signature
from collections import OrderedDict
@brandonwillard
brandonwillard / pymc3-toposorting.py
Last active June 6, 2020 18:57
PyMC3 Toposorting
import numpy as np
import theano.tensor as tt
import pymc3 as pm
from itertools import chain, filterfalse
tt.optimizer = 'fast_compile'
@brandonwillard
brandonwillard / ox-jupyter-notebook-notes.org
Created March 25, 2020 18:22
Notes on a Better Implementation of org-to-jupyter-notebook Conversion

Overall, it looks easier to write a Jupyter Notebook exporter from scratch. The Notebook format is given here.

(require 'ox-gfm)

(org-export-define-derived-backend 'jnb 'gfm
  :filters-alist '((:filter-parse-tree . org-jnb-separate-elements))
  :menu-entry
@brandonwillard
brandonwillard / simple_dlm_sim_example.py
Last active March 16, 2020 19:51
Simple Theano DLM Simulation Example using Symbolic PyMC
import numpy as np
import theano
import theano.tensor as tt
import matplotlib.pyplot as plt
from theano.printing import debugprint as tt_dprint
from symbolic_pymc.theano.random_variables import NormalRV, MvNormalRV, InvGammaRV, observed