Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Ichoran is diffracting imperceptibly (more, with JPEG artifacts)

Ichoran

💭
Ichoran is diffracting imperceptibly (more, with JPEG artifacts)
View GitHub Profile
@Ichoran
Ichoran / Bench.scala
Created Jun 12, 2018
Thyme benchmark of tap and pipe vs manual inlining
View Bench.scala
package bench
import scala.language.implicitConversions
import ichi.bench._
object Implicits {
final class ChainingOps[A](private val self: A) extends AnyVal {
@inline def tap[U](f: A => U): A = { f(self); self }
@inline def pipe[B](f: A => B): B = f(self)
@Ichoran
Ichoran / Weighted_Sampling_No_Replace.scala
Created Jun 10, 2018
Sketch of a reasonably efficient algorithm for weighted sampling without replacement
View Weighted_Sampling_No_Replace.scala
def cuml(wt: Array[Double]) = {
val l = wt.length
val base = if ((l & (l-1)) == 0) l else java.lang.Integer.highestOneBit(l)*2
val tree = new Array[Double](base*2)
System.arraycopy(wt, 0, tree, 0, wt.length)
var in = 0
var out = base
var n = base
while (in + 1 < out) {
while (in + 1 < n) {
@Ichoran
Ichoran / Test_Imm_List_Str.scala
Created Oct 20, 2017
Example of what generated code looks like with collection-laws rewrite
View Test_Imm_List_Str.scala
// Autogenerated test for collection List with element type String
package laws
class Test_Imm_List_Str(numb: Numbers, oper: Ops[String, Option[String]], inst: Instance[String, scala.collection.immutable.List[String]], lln: Int)
extends StrTest[scala.collection.immutable.List[String], Test_Imm_List_Str](numb, oper, inst, lln) {
import Test.ComparesTo
import Test.Logic
def renumber(numb: Numbers) = new Test_Imm_List_Str(numb, ops, instance, lawLine)
def reinstance(inst: Instance[String, scala.collection.immutable.List[String]]) = new Test_Imm_List_Str(num, ops, inst, lawLine)
@Ichoran
Ichoran / openworm_wcon_iwm_2017.md
Created Mar 16, 2017
Abstract of IWM 2017 for OpenWorm WCON project
View openworm_wcon_iwm_2017.md

A Common Format for Worm Tracking Data

Michael Currie (1a), Rex A. Kerr (2), Chee Wai Lee (1b), Jim Hokanson(1c), and Andrew E.X. Brown (3).

  1. OpenWorm (a. Somewhere; b. Somewhere Else; c. Somewhere Yet Again)
  2. Calico Life Sciences
  3. Imperial College London

Many labs, including ours, have built a wide variety of worm trackers.

@Ichoran
Ichoran / Ranged.scala
Created Jan 25, 2017
Quick and dirty benchmark of different approaches to Range specialization
View Ranged.scala
package test
class Super[+A] {
def foreach[U](f: A => U): Unit = ???
}
final class Ranged(i0: Int, iN: Int) extends Super[Int] {
override def foreach[@specialized(Unit) U](f: Int => U) {
var i = i0
while (i < iN) {
@Ichoran
Ichoran / GroupByBench.scala
Created Nov 14, 2016
Benchmarks for groupBy / map getOrElseUpdate slowdown
View GroupByBench.scala
import ichi.bench._
object GroupByBench {
class Sum(var value: Int = 0) {
def ++(): this.type = { value += 1; this }
}
val a1k = Array.tabulate(1024)(i => ((i*7) % 13).toString)
val l1k = a1k.toList
val v1k = a1k.toVector