Skip to content

Instantly share code, notes, and snippets.

View nalimilan's full-sized avatar

Milan Bouchet-Valat nalimilan

View GitHub Profile
julia> versioninfo()
Julia Version 0.6.3
Commit d55cadc350* (2018-05-28 20:20 UTC)
Platform Info:
OS: Linux (i686-redhat-linux)
CPU: Intel Core Processor (Skylake, IBRS)
WORD_SIZE: 32
BLAS: libopenblas (DYNAMIC_ARCH NO_AFFINITY Nehalem)
LAPACK: libopenblas
LIBM: libopenlibm
(gdb) ba
#0 0x00007f0d85843b23 in select () from /lib64/libc.so.6
#1 0x00007f0d78d55031 in ?? ()
from /usr/lib/rstudio/bin/plugins/platforms/libqxcb.so
#2 0x00007f0d78d55657 in ?? ()
from /usr/lib/rstudio/bin/plugins/platforms/libqxcb.so
#3 0x00007f0d78d557a7 in ?? ()
from /usr/lib/rstudio/bin/plugins/platforms/libqxcb.so
#4 0x00007f0d78d5760a in ?? ()
from /usr/lib/rstudio/bin/plugins/platforms/libqxcb.so
git ls-files -z | xargs -0 sed -i \
-e 's/JuliaData/JuliaStats/g' \
-e 's/dt/df/g' \
-e 's/DT/DF/g' \
-e 's/data table/data frame/g' \
-e 's/datatable/dataframe/g' \
-e 's/DataTable/DataFrame/g' \
-e 's/readfable/readtable/g' \
-e 's/Readfable/Readtable/g' \
-e 's/definedfypes/definedtypes/g' \
using DataTables, StatsBase
function random_frame(nrow::Int, col_values::Dict{Symbol, Any})
DataTable(Any[isa(col_values[key], CategoricalArray) ?
categorical(sample(col_values[key], nrow)) :
NullableArray(sample(col_values[key], nrow)) for key in keys(col_values)],
keys(col_values) |> collect)
end
function random_join(kind::Symbol, nrow_left::Int, nrow_right::Int,
using DataTables
using BenchmarkTools
using Distributions
srand(1);
a = NullableArray(rand([1, 2, 4], 2000), rand(2000) .> .75)
b = rand([:a, :b], 2000);
c = rand(["a", "b"], 2000);
d = rand(rand(2), 2000);
small = DataTable(A = a, B = b, C = c, D = c);
commit 83dc06334ff95ad18a951d0bb540290510f2f81a
Author: Keno Fischer <kfischer@college.harvard.edu>
Date: Thu Dec 8 17:22:35 2016 +0000
ConstantFolding: Don't crash when encountering vector GEP
ConstantFolding tried to cast one of the scalar indices to a vector
type. Instead, use the vector type only for the first index (which
is the only one allowed to be a vector) and use its scalar type
otherwise.
# With this PR:
julia> profile_broadcast_all()
f(x, y) := x * y
Method: broadcast!(f, dest, A1, A2) (no empty entries):
For Array{Float64}: 0.022608 seconds (4 allocations: 128 bytes)
For NullableArray{Float64}: 0.169757 seconds (6 allocations: 288 bytes)
For DataArray{Float64}: 0.066087 seconds (14 allocations: 1.192 MB)
Method: broadcast!(f, dest, A1, A2) (~half empty entries):
For NullableArray{Float64}: 0.175772 seconds (6 allocations: 288 bytes)
broadcast_fuse(types::Type, f) = f
broadcast_fuse(types::Type, f, fs...) = x -> f(broadcast_fuse(types, fs...)(x))
a(x) = x+1
b(x) = x*x
f1(x) = broadcast_fuse(Array, a, b)(x) # Needed so that the compiler treats anonymous function as const
@code_warntype f1(1)
@code_native f1(1)
function sumequals{T}(A::AbstractArray{Int}, d::Dict{T, Int}, v::T)
n = 0
@inbounds for x in A
n += get(d, v, 0) == x
end
n
end
A = repeat(1:5, outer=1000)
d = Dict("A"=>1, "B"=>2, "C"=>3)
using NullableArrays
@inline function f1{S1, S2}(x::Nullable{S1}, y::Nullable{S2})
if isbits(S1) & isbits(S2)
Nullable{Base.promote_op(+, S1, S2)}(x.value + y.value, x.isnull | y.isnull)
else
error()
end
end