Skip to content

Instantly share code, notes, and snippets.

@ggggggggg
ggggggggg / functor_bug.jl
Created December 4, 2023 16:09
pluto functor bug
### A Pluto.jl notebook ###
# v0.19.32
using Markdown
using InteractiveUtils
# ╔═╡ a353c1f3-0921-4c9b-ab1d-a34cb262b3d9
# following docs at https://docs.julialang.org/en/v1/manual/methods/#Function-like-objects-1
# lets make a functor
@ggggggggg
ggggggggg / api.jl
Last active August 13, 2020 17:28
rough sketch of abaco autotune api
# written in Julia just because its easier and more compact to annotate the code with types (mainly vector vs scalar)
# and group the data into structs.... we will write everything in python
# the goal is just to get a sense of what functions we need from the abaco hardware side (abaco_*)
# and what functions we want to expose from some analysis package, and what data all of those will want
const Vec = Vector{Float64}
struct S21
frequency::Vec
transmission::Vec
phase::Vec # future
@ggggggggg
ggggggggg / buffered_hdf5.jl
Created October 20, 2017 19:10
buffered hdf5 dataset in juli
using HDF5
"HDF5 appears to be inefficent for small writes, so this a simple buffer that
allows me to write to HDF5 only once per unit time (typically one second) to
limit the number of small writes."
mutable struct BufferedHDF5Dataset{T}
ds::HDF5Dataset
v::Vector{T}
lasti::Int64 # last index in hdf5 dataset
timeout_s::Float64 # interval in seconds at which to transfer data from v to ds
@ggggggggg
ggggggggg / A_list_of_tasks.md
Last active November 15, 2017 21:44
mass infinity sketch

What tasks should mass_infinity accomplish?

  • Take raw data records of fixed length and noise. Return basis for analyzing that data, and future data.
  • Take raw data records. Return subspace representation + residual std deviation.
  • Take subspace representation and spectral information. Return rough calibration. J?
  • Take J and ??. Return various corrected Js.
    • Baseline-J Correlation Correction
    • Subsample arrival time Correction
  • Time Drift Correction
@ggggggggg
ggggggggg / paths.jl
Created October 25, 2017 16:22
paths problem
const NEIG_py = [[1, 4, 5], [0, 2, 4, 5, 6], [1, 3, 5, 6, 7], [2, 6, 7], [0, 1, 5, 8, 9], [0, 1, 2, 4, 6, 8, 9, 10], [1, 2, 3, 5, 7, 9, 10, 11], [2, 3, 6, 10, 11], [4, 5, 9, 12, 13], [4, 5, 6, 8, 10, 12, 13, 14], [5, 6, 7, 9, 11, 13, 14, 15], [6, 7, 10, 14, 15], [8, 9, 13], [8, 9, 10, 12, 14], [9, 10, 11, 13, 15], [10, 11, 14]];
const NEIG = [n.+1 for n in NEIG_py]
function enlarge(path::Vector{Int})
(push!(copy(path),loc) for loc in NEIG[path[end]] if !(loc in path))
end
collect(enlarge([1]))
function enlargepaths(paths)
Iterators.Flatten(enlarge(path) for path in paths)
end
collect(enlargepaths([[1],[2]]))
@ggggggggg
ggggggggg / stackexchange46809845.jl
Last active October 23, 2017 22:18
stackexchange46809845
using BenchmarkTools
dirname = "anotherdir"
isdir(dirname) || mkdir(dirname)
fname = joinpath(dirname,"stackexchange46809845_f.jl")
funname = "myfun"
funstr = """$funname() = rand(100)"""
open(fname,"w") do f
write(f,funstr)
end
@ggggggggg
ggggggggg / parsetypes.jl
Last active October 18, 2017 22:35
macros to parse code to use different types
using MacroTools, Base.Test
"@parsetype T ex
replace all numeric literals that are supertypes of `T` with type `T`"
macro parsetype(Tsym, ex)
T=getfield(Main, Tsym)
ST=parsesuper(T)
parsetype(T, ST, ex)
end
@ggggggggg
ggggggggg / output.txt
Last active August 19, 2017 02:26
Work in progress towards robust complex division algorithm in Julia
The archive paper provides 10 example hard complex divions with answers. It also provides an algorith for measuring the accuracy of the result in "bits", which I have implemented. The robust cdiv algorithm is said to get 53 bits for all but #8 on the hard problems, where it gets 52 bits. I reproduce all of the results (also the default julia / reproduces results for smith's algorithm), except I get 0 bits on #5. I've tracked this down to the division of b/c returning zero inside robust_cdiv2, after r is also zero. But it's not clear how to fix it.
cdiv #1 ,53 bits accurate, 1.1125369292536007e-308 - 1.1125369292536007e-308im
cdiv #2 ,53 bits accurate, 8.98846567431158e307 + 0.0im
cdiv #3 ,53 bits accurate, 1.4334366349937947e104 - 3.645561009778199e-304im
cdiv #4 ,53 bits accurate, 8.98846567431158e307 + 0.0im
cdiv #5 ,0 bits accurate, 3.757668132438133e109 - 2.0e-323im
cdiv #6 ,53 bits accurate, 2.0e-323 + 1.048576e6im
cdiv #7 ,53 bits accurate, 3.8981256045591133e289 + 8.174961907852354e295im
@ggggggggg
ggggggggg / chan_bench.go
Created June 30, 2015 16:12
Some go vs julia concurrency comparisons
package main
import "time"
import "fmt"
func counter(c chan int, N int) {
for j := 1; j <= N; j++ {
c <- j
}
}
# implement WirelessKeyboard as K
immutable K
f::Int
s::Int
end
# implement InterferesWith as <
>(k::K,K::K)=k.f==K.f
#prepare randomized array
k = [K(f,(j-1)*3+f) for j=1:12,f=1:3]
k9 = [K(f,(j-1)*3+f) for j=1:3,f=1:3] # smaller testing array