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 / 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 / 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 / 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 / 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
}
}
@ggggggggg
ggggggggg / searchsorted2.jl
Last active August 29, 2015 14:20
searchsorted2
function searchsortedfirst2vec(a,b)
[searchsortedfirst(a,bb, 1, length(a), Base.Sort.Forward) for bb in b]
end
c=searchsorted2(a,b)
# returns an array of indicies into a such that each points is the first value in a[i] greater than b[i]
# assumes both a and b are sorted
function searchsortedfirst2a(a,b,o::Base.Sort.Ordering=Base.Sort.Forward)
alow = 1
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.