Skip to content

Commit

Permalink
Merge pull request #1 from mcabbott/julia07fixes
Browse files Browse the repository at this point in the history
Julia07fixes
  • Loading branch information
mcabbott authored Oct 18, 2018
2 parents 7b7693a + fcb86f6 commit 824c085
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 deletions.
8 changes: 7 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@ os:
- linux
- osx
julia:
- 0.4
- 0.7
- nightly

# matrix:
# allow_failures:
# - julia: nightly

notifications:
email: false

# uncomment the following lines to override the default test script
#script:
# - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
Expand Down
3 changes: 2 additions & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
julia 0.4
julia 0.7

4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
environment:
matrix:
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.4/julia-0.4-latest-win32.exe"
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.4/julia-0.4-latest-win64.exe"
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.7/julia-0.7-latest-win32.exe"
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.7/julia-0.7-latest-win64.exe"
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"

Expand Down
12 changes: 6 additions & 6 deletions src/GroupSlices.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Base.Cartesian, Base.Cartesian.@nloops, Base.Cartesian.@nref

export groupslices, groupinds, firstinds, lastinds

immutable Prehashed
struct Prehashed
hash::UInt
end
hash(x::Prehashed) = x.hash
Expand All @@ -30,7 +30,7 @@ elseif dim == 3
end
```
"""
@generated function groupslices{T,N}(A::AbstractArray{T,N}, dim::Int)
@generated function groupslices(A::AbstractArray{T,N}, dim::Int) where {T,N}
quote
if !(1 <= dim <= $N)
ArgumentError("Input argument dim must be 1 <= dim <= $N, but is currently $dim")
Expand All @@ -44,7 +44,7 @@ end
end

# Collect index of first row for each hash
uniquerow = Array(Int, size(A, dim))
uniquerow = Array{Int}(undef,size(A, dim))
firstrow = Dict{Prehashed,Int}()
for k = 1:size(A, dim)
uniquerow[k] = get!(firstrow, Prehashed(hashes[k]), k)
Expand Down Expand Up @@ -128,7 +128,7 @@ function groupinds(ic::Vector{Int})
d[ia[i]]= i
end

ib = Array(Vector{Int},n)
ib = Array{Vector{Int}}(undef, n)
for k = 1:n
ib[k] = Int[]
end
Expand Down Expand Up @@ -160,9 +160,9 @@ operates on the output returned from `groupinds(ic::Vector{Int})`.
function firstinds(ic::Vector{Int})
id = unique(ic)
n = length(id)
ia = Array(Int,n)
ia = Array{Int}(undef,n)
for i = 1:n
ia[i] = findfirst(ic, id[i])
ia[i] = something(findfirst(isequal(id[i]), ic), 0) # findfirst(ic, id[i])
end
return ia
end
Expand Down
4 changes: 2 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using GroupSlices
using Base.Test
using Test

# Tests for groupslices, groupinds, firstinds, lastinds
A = [1 2 3 ; 4 5 6 ; 7 8 9]
B = [11 12 13 ; 14 15 16 ; 17 18 19]
C = [21 22 23 ; 24 25 26 ; 27 28 29]
D = cat(3, A, B, C, C, B, C, A)
D = cat(A, B, C, C, B, C, A; dims=3)

ic = [1;2;3;3;2;3;1]
ib = Vector{Int}[]
Expand Down

0 comments on commit 824c085

Please sign in to comment.