Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@ajwheeler
ajwheeler / minimal.yaml
Created June 26, 2017 20:41
example of chip_num not defined error
modules:
- galsim_extra
- galsim.des
psf:
type: PSFEx
gal:
type: Gaussian
sigma: 2
@ajwheeler
ajwheeler / clapping.hs
Created December 31, 2020 19:12
Steve Reich's clapping music in with Euterpea in haskell
import Euterpea
rythm = [1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0]
r1 = concat $ take 13 (repeat rythm)
r2 = concat [drop i rythm ++ take i rythm | i <- [0..12]]
clap 1 = c 4 sn
clap 0 = rest sn
@ajwheeler
ajwheeler / Autodiff.ipynb
Created June 28, 2021 17:29
autodiff with Korg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ajwheeler
ajwheeler / NLSolver.jl
Created June 16, 2023 13:29
Wraped `NLsolve.nlsolve` to allow the `residuals!` function to take additional fixed parameters as a tuple of vectors and calculate fast derivaties w.r.t. them.
"""
This module provides a wrapper for `nlsolve`, from `NLsolve.jl`, which is a package for solving
nonlinear systems of equations.
The wrapper extends `nlsolve` to allow the `residuals!` function to take additional fixed parameters
as a tuple of vectors. This convieniently handles
[julia's closure inneficiency problems](https://docs.julialang.org/en/v1/manual/performance-tips/#man-performance-captured),
but more importantly facilitates the fast differentiation (with `ForwardDiff`) of the minimizer with
respect to the parameters.
"""
@ajwheeler
ajwheeler / parallelism_with_juliacall.py
Last active February 9, 2024 01:24
Julia parallelism with JuliaCall
from juliacall import Main as jl
import time
jl.include("utils.jl")
def wait_for_spectrum(s):
while True:
time.sleep(0.1)
if jl.isready(s):
print("Worker is ready!")
print(jl.fetch(s))