Skip to content

Commit

Permalink
fix travis, move to IntervalSets
Browse files Browse the repository at this point in the history
  • Loading branch information
mronian committed Sep 1, 2016
1 parent 0f65fd8 commit a2aa5bb
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 36 deletions.
10 changes: 4 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# Documentation: http://docs.travis-ci.com/user/languages/julia/
language: julia
os:
- linux
- osx
julia:
- release
- 0.5
- nightly
notifications:
email: false
Expand All @@ -13,7 +12,6 @@ notifications:
# - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
# - julia -e 'Pkg.clone(pwd()); Pkg.build("IntegralArrays"); Pkg.test("IntegralArrays"; coverage=true)'
after_success:
# push coverage results to Coveralls
- julia -e 'cd(Pkg.dir("IntegralArrays")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'
# push coverage results to Codecov
- julia -e 'cd(Pkg.dir("IntegralArrays")); Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())'
- if [ $TRAVIS_OS_NAME = "linux" ]; then
julia -e 'cd(Pkg.dir("IntegralArrays")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())';
fi
4 changes: 2 additions & 2 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
julia 0.5
julia 0.5-
Images
ClosedIntervals
IntervalSets
10 changes: 3 additions & 7 deletions src/IntegralArrays.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module IntegralArrays

# package code goes here
using Images, ClosedIntervals
using Images, IntervalSets

import Base: size, getindex, linearindexing

export IntegralArray, ±, ..
export IntegralArray

"""
```
Expand Down Expand Up @@ -52,18 +52,14 @@ function IntegralArray(array::AbstractArray)
IntegralArray{eltype(array), ndims(array), typeof(array)}(integral_array)
end

..(x, y) = ClosedInterval(x, y)
±(x, y) = ClosedInterval(x + y, x - y)
±(x::CartesianIndex, y) = map(ClosedInterval, (x + y).I, (x - y).I)

linearindexing(A::IntegralArray) = Base.LinearFast()
size(A::IntegralArray) = size(A.data)
getindex(A::IntegralArray, i::Int...) = A.data[i...]

getindex(A::IntegralArray, ids::Tuple...) = getindex(A, ids[1]...)

function getindex(A::IntegralArray, i::ClosedInterval...)
_boxdiff(A, left(i[1]), left(i[2]), right(i[1]), right(i[2]))
_boxdiff(A, i[1].left, i[2].left, i[1].right, i[2].right)
end

function _boxdiff{T}(int_array::IntegralArray{T, 2}, tl_y::Integer, tl_x::Integer, br_y::Integer, br_x::Integer)
Expand Down
2 changes: 1 addition & 1 deletion test/REQUIRE
Original file line number Diff line number Diff line change
@@ -1 +1 @@
FactCheck
IntervalSets
40 changes: 20 additions & 20 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,52 +1,52 @@
module IntegralArraysTests

using IntegralArrays, Base.Test, FactCheck
using IntegralArrays, Base.Test, IntervalSets

facts("IntegralArrays") do
@testset "IntegralArrays" begin
a = zeros(10, 10)
int_array = IntegralArray(a)
@fact all(int_array == a) --> true
@test all(int_array == a)

a = ones(10,10)
int_array = IntegralArray(a)
chk = Array(1:10)
@fact all([vec(int_array[i, :]) == chk * i for i in 1:10]) --> true
@test all([vec(int_array[i, :]) == chk * i for i in 1:10])

int_sum = int_array[1..5, 1..2]
@fact int_sum --> 10.0
@test int_sum == 10.0
int_sum = int_array[3 ± 2, 1..2]
@fact int_sum --> 10.0
@test int_sum == 10.0
int_sum = int_array[CartesianIndex((3, 3)) ± 2]
@fact int_sum --> 25.0
@test int_sum == 25.0
int_sum = int_array[1..2, 1..5]
@fact int_sum --> 10.0
@test int_sum == 10.0
int_sum = int_array[4..8, 4..8]
@fact int_sum --> 25.0
@test int_sum == 25.0
int_sum = int_array[6 ± 2, 6 ± 2]
@fact int_sum --> 25.0
@test int_sum == 25.0
int_sum = int_array[CartesianIndex((6, 6)) ± 2]
@fact int_sum --> 25.0
@test int_sum == 25.0

a = Array(reshape(1:100, 10, 10))
int_array = IntegralArray(a)
@fact int_array[diagind(int_array)] == Array([1, 26, 108, 280, 575, 1026, 1666, 2528, 3645, 5050]) --> true
@test int_array[diagind(int_array)] == Array([1, 26, 108, 280, 575, 1026, 1666, 2528, 3645, 5050])

int_sum = int_array[1..3, 1..3]
@fact int_sum --> 108
@test int_sum == 108
int_sum = int_array[2 ± 1, 2 ± 1]
@fact int_sum --> 108
@test int_sum == 108
int_sum = int_array[CartesianIndex((2, 2)) ± 1]
@fact int_sum --> 108
@test int_sum == 108
int_sum = int_array[1..5, 1..2]
@fact int_sum --> 80
@test int_sum == 80
int_sum = int_array[3 ± 2, 1..2]
@fact int_sum --> 80
@test int_sum == 80
int_sum = int_array[4..8, 4..8]
@fact int_sum --> 1400
@test int_sum == 1400
int_sum = int_array[6 ± 2, 6 ± 2]
@fact int_sum --> 1400
@test int_sum == 1400
int_sum = int_array[CartesianIndex((6, 6)) ± 2]
@fact int_sum --> 1400
@test int_sum == 1400
end

end

0 comments on commit a2aa5bb

Please sign in to comment.