Skip to content

Instantly share code, notes, and snippets.

View nalimilan's full-sized avatar

Milan Bouchet-Valat nalimilan

View GitHub Profile
@nalimilan
nalimilan / NamedArray.jl
Created November 24, 2013 13:38
"else if" error reproducer
## NamedArray.jl
## (c) 2013 David A. van Leeuwen
## Julia type that implements a drop-in replacement of Array with named dimensions.
## This code is licensed under the GNU General Public License, version 2
## See the file LICENSE in this distribution
## type definition
require("src/namedarraytypes.jl")
$ LD_DEBUG=files BUILDROOT/julia-0.2.0-1.fc19.x86_64/usr/bin/julia
23065:
23065: file=libreadline.so.6 [0]; needed by BUILDROOT/julia-0.2.0-1.fc19.x86_64/usr/bin/julia [0]
23065: file=libreadline.so.6 [0]; generating link map
23065: dynamic: 0x000000356123c6d0 base: 0x0000000000000000 size: 0x00000000002443c8
23065: entry: 0x0000003561014f50 phdr: 0x0000003561000040 phnum: 7
23065:
23065:
23065: file=libncurses.so.5 [0]; needed by BUILDROOT/julia-0.2.0-1.fc19.x86_64/usr/bin/julia [0]
23065: file=libncurses.so.5 [0]; generating link map
--- a/deps/Makefile 2013-11-30 15:23:26.387689253 +0100
+++ b/deps/Makefile 2013-12-06 17:58:34.800112867 +0100
@@ -439,14 +439,11 @@
UV_OBJ_TARGET = $(BUILD)/$(JL_LIBDIR)/libuv.a
endif
-libuv/configure:
- (cd .. && git submodule init && git submodule update)
-ifeq (exists, $(shell [ -d libuv/.git ] && echo exists ))
-libuv/config.status: libuv/.git/HEAD
@nalimilan
nalimilan / table.jl
Last active January 1, 2016 10:29
Draft implementation of table() for PooledDataVectors
using DataArrays
using NamedArrays
function table(x::PooledDataVector...; usena::Bool = false)
n = length(x)
l = [length(y) for y in x]
for i in 1:n
if l[1] != l[i]
error("arguments are not of the same length: $l")
end
@nalimilan
nalimilan / puzzle.jl
Last active January 2, 2016 06:08
A small puzzle...
function test1(x::AbstractVector)
dims = [10]
a = zeros(Int, dims...)
for i in 1:length(x)
a[1] += 1
end
a
@nalimilan
nalimilan / sumsq_sparse.jl
Last active August 29, 2015 14:09
Sum of squares for sparse matrix
# These two functions are defined only in Julia 0.4
rowvals(S::SparseMatrixCSC) = S.rowval
nzrange(S::SparseMatrixCSC, col::Integer) = S.colptr[col]:(S.colptr[col+1]-1)
# Based on the example from http://julia.readthedocs.org/en/latest/stdlib/sparse/#Base.nzrange
function sumsq(A::SparseMatrixCSC)
vals = nonzeros(A)
m, n = size(A)
count = zero(eltype(A))
for i = 1:n
# Array consisting of an element-wise transformation of another array
# Equivalent of vectorized functions
immutable LazyArray{T, N, A} <: AbstractArray{T, N}
a::A
fn::Function
args
end
LazyArray(a::AbstractArray, fn::Function, args) = LazyArray{eltype(fn(a[1], args...)), ndims(a), typeof(a)}(a, fn, args)
LazyArray(a::AbstractArray, fn::Function) = LazyArray(a, fn, ())
import Base.<, Base.next, Base.nextind, Base.prevind, Base.colon, Base.length, Base.getindex, Base.first, Base.last,
Base.is_utf8_start, Base.utf8_trailing, Base.utf8_offset
# Simple index with string plus byte offset
immutable StringIndex{S<:AbstractString}
str::S
i::Int
end
<(a::StringIndex, b::StringIndex) = a.i < b.i
Mock Version: 1.2.6
ENTER do(['bash', '--login', '-c', '/usr/bin/rpmbuild -bs --target x86_64 --nodeps /builddir/build/SPECS/julia-nightlies-0.3.spec'], chrootPath='/var/lib/mock/fedora-rawhide-x86_64-mockbuilder-11174/root'shell=FalseprintOutput=Falseenv={'LANG': 'en_US.UTF-8', 'TERM': 'vt100', 'SHELL': '/bin/bash', 'HOSTNAME': 'mock', 'PROMPT_COMMAND': 'printf "\x1b]0;<mock-chroot>\x07<mock-chroot>"', 'HOME': '/builddir', 'PATH': '/usr/bin:/bin:/usr/sbin:/sbin'}gid=135user='mockbuild'timeout=0logger=<mockbuild.trace_decorator.getLog object at 0x199bf50>uid=500)
Executing command: ['bash', '--login', '-c', '/usr/bin/rpmbuild -bs --target x86_64 --nodeps /builddir/build/SPECS/julia-nightlies-0.3.spec'] with env {'LANG': 'en_US.UTF-8', 'TERM': 'vt100', 'SHELL': '/bin/bash', 'HOSTNAME': 'mock', 'PROMPT_COMMAND': 'printf "\x1b]0;<mock-chroot>\x07<mock-chroot>"', 'HOME': '/builddir', 'PATH': '/usr/bin:/bin:/usr/sbin:/sbin'} and shell False
warning: Could not canonicalize hostname: i-00033401
Building target platf
VERSION < v"0.4-" && using Docile
VERSION < v"0.4-" && typealias Pair Tuple
@doc doc"""
recode!(dest::AbstractArray, source::AbstractArray, pairs::Pair...; default=Nullable())
Fill `dest` with elements from `source`, replacing those matching a key of `pairs`
with the corresponding value.
For each `Pair` in `pairs`, if the element is equal to (according to `==`) or `in` the key