Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Julia 1.x #9

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions appveyor.yml → .appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
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/1.0/julia-1.0-latest-win32.exe"
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/1.0/julia-1.0-latest-win64.exe"
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/1.0/julia-1.1-latest-win32.exe"
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/1.0/julia-1.1-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
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ os:
- linux
- osx
julia:
- 0.4
- 1.0
- 1.1
- nightly
notifications:
email: false
Expand Down
33 changes: 33 additions & 0 deletions Manifest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This file is machine-generated - editing it directly is not advised

[[Base64]]
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"

[[Distributed]]
deps = ["Random", "Serialization", "Sockets"]
uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"

[[InteractiveUtils]]
deps = ["Markdown"]
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"

[[Logging]]
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"

[[Markdown]]
deps = ["Base64"]
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"

[[Random]]
deps = ["Serialization"]
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

[[Serialization]]
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"

[[Sockets]]
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"

[[Test]]
deps = ["Distributed", "InteractiveUtils", "Logging", "Random"]
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
5 changes: 5 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name = "GroupSlices"
uuid = "d853e229-7c7c-56e9-b6be-9a1acc5f13d9"

[deps]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
1 change: 0 additions & 1 deletion REQUIRE

This file was deleted.

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 = Vector{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 = Vector{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 = Vector{Int}(undef, n)
for i = 1:n
ia[i] = findfirst(ic, id[i])
ia[i] = findfirst(isequal(id[i]), ic)
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