Skip to content

Instantly share code, notes, and snippets.

View tshort's full-sized avatar

Tom Short tshort

  • Electric Power Research Institute
View GitHub Profile
@tshort
tshort / nodal-jump.jl
Last active January 17, 2016 12:24
Example of nodal problem formulations with JuMP
using JuMP
function localVar(m, name = "", expose = false)
x = JuMP.Variable(m, -Inf, Inf, :Cont, name, NaN)
if expose
JuMP.registervar(m, name, x)
end
x
end
@tshort
tshort / README.md
Last active October 29, 2015 02:01
Vega working groupby version

Problems with a groupby transform involving sum

In this spec, the groupby transform works just fine using any of median, count, or average. When I use sum, the graph doesn't show. This version should display right.

@tshort
tshort / README.md
Last active October 29, 2015 01:53 — forked from espinielli/README.md
Problems with a groupby transform involving sum

Problems with a groupby transform involving sum

In this spec, the groupby transform works just fine using any of median, count, or average. When I use sum, the graph doesn't show.

@tshort
tshort / t.md
Last active September 17, 2015 20:44

hello world

# /: comment
aK
 \ hello world
.asdf#wer 456
@tshort
tshort / simondf.md
Last active August 29, 2015 14:11
Timing Simon's DataFrame

Simon's DataFrame mock-up using staged functions

module SimonDataFrame

type DataFrame{N,D}
    data::D
end
@tshort
tshort / withmacro.md
Last active August 29, 2015 13:55
Playing with an @with macro

@with macro

Here is an @with macro to evaluate DataFrame (or even Dict) columns using references.

replace_syms(x, membernames) = x
function replace_syms(e::Expr, membernames)
    if e.head != :quote
        return Expr(e.head, (isempty(e.args) ? e.args : map(x -> replace_syms(x, membernames), e.args))...)
    else
@tshort
tshort / DFVector.jl
Created April 10, 2013 17:44
Explorations with column keys for DataFrames
importall Base
using DataFrames
type IX
df::AbstractDataFrame
end
IX(args...) = IX(DataFrame([args...]'))
length(x::IX) = 1
type DFVector <: AbstractArray{AbstractDataFrame,1}
df::AbstractDataFrame
end
@tshort
tshort / testing.md
Created April 1, 2013 15:17
JLD experiments with DataFrames

Here is an extension to JLD to try to support reading of DataFrames. Writing seems to be okay.

import HDF5.read, JLD.JldFile, JLD.getrefs

function read{D<:AbstractDataFrame}(obj::HDF5Dataset{JldFile}, ::Type{D})
    kv = getrefs(obj, Any)
    keys = kv[1]
    vals = kv[2]
    d = D()
@tshort
tshort / csv.md
Created December 19, 2012 02:37
Explorations in reading CSV files in Julia

Matthew Dowle is working on a fast CSV reader for data.table. Here is test data case generated in R along with some timings:

require(data.table)

n=1e6
DT = data.table( a=sample(1:1000,n,replace=TRUE),
                 b=sample(1:1000,n,replace=TRUE),
                 c=rnorm(n),
                 d=sample(c("foo","bar","baz","qux","quux"),n,replace=TRUE),
@tshort
tshort / julia_type.md
Created October 4, 2012 18:58
Convert a string to a Julia type