From 7442b63c6f7d2e88ae779e7f3c8cffdfeea377af Mon Sep 17 00:00:00 2001 From: Tim Holy Date: Sat, 29 Sep 2018 04:00:50 -0500 Subject: [PATCH 1/3] Check proper inference for Unitful AxisArrays This fails on 0.6, so it's nice to see it passing now --- test/REQUIRE | 2 +- test/core.jl | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/test/REQUIRE b/test/REQUIRE index 7bdfb32..f80fc2c 100644 --- a/test/REQUIRE +++ b/test/REQUIRE @@ -1,2 +1,2 @@ SimpleTraits - +Unitful diff --git a/test/core.jl b/test/core.jl index 6fed5ca..56c1f2f 100644 --- a/test/core.jl +++ b/test/core.jl @@ -1,7 +1,7 @@ using FixedPointNumbers, Colors, ColorVectorSpace, SimpleTraits, ImageAxes, ImageMetadata, AxisArrays -using Compat using Test import Dates: now +using Unitful: m @testset "indexing" begin # 1d images @@ -340,4 +340,19 @@ end @test_throws ErrorException M' end +@testset "Inference" begin + # Heavily-nested types tax Julia's inference capabilities + a = rand(N2f14, 3, 5, 2) + a1 = a[1,1,1] + aa = AxisArray(a, Axis{:y}(0:2), Axis{:x}(0:4), Axis{:z}(0:1)) + cv = colorview(RGB, aa, zeroarray, aa) + @test @inferred(cv[1,1,1]) == RGB(a1, zero(a1), a1) + au = AxisArray(a, Axis{:y}(0m:1m:2m), Axis{:x}(0m:1m:4m), Axis{:z}(0m:1m:1m)) + cv = colorview(RGB, au, zeroarray, au) + @test @inferred(cv[1,1,1]) == RGB(a1, zero(a1), a1) + am = ImageMeta(au) + cv = colorview(RGB, am, zeroarray, am) + @inferred cv[1,1,1] +end + nothing From 10b9455cb5423b4803c198ce63de0adf09ae6a60 Mon Sep 17 00:00:00 2001 From: Tim Holy Date: Sat, 29 Sep 2018 04:03:23 -0500 Subject: [PATCH 2/3] Fix the out-of-bounds evaluation tests --- test/core.jl | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/test/core.jl b/test/core.jl index 56c1f2f..e9f026b 100644 --- a/test/core.jl +++ b/test/core.jl @@ -89,11 +89,14 @@ using Unitful: m end # Test bounds-checking removal by @inbounds if Base.JLOptions().check_bounds != 1 && Base.JLOptions().can_inline == 1 - a = zeros(3) - sizehint!(a, 10) # make sure we don't cause a segfault + set5!(x) = @inbounds x[5] = 1.234 + get5(x) = @inbounds x[5] + aa = zeros(3) + sizehint!(aa, 10) # make sure we don't cause a segfault + a = ImageMeta(aa) @test_throws BoundsError a[5] - @inbounds a[5] = 1.234 - @inbounds val = a[5] + set5!(a) + val = get5(a) @test val == 1.234 a = zeros(3,5) end From f942f3cbf389e3c1e7d90d57d6d8a12b99c80ced Mon Sep 17 00:00:00 2001 From: Tim Holy Date: Sat, 29 Sep 2018 04:46:30 -0500 Subject: [PATCH 3/3] Fixes to documentation --- .travis.yml | 2 +- docs/make.jl | 4 ++-- docs/src/reference.md | 4 +--- src/ImageMetadata.jl | 6 ++---- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 873ee2f..20f926b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,7 +22,7 @@ script: jobs: include: - stage: deploy - julia: 0.7 + julia: 1.0 os: linux script: - julia -e 'import Pkg; Pkg.clone(pwd()); Pkg.build("ImageMetadata")' diff --git a/docs/make.jl b/docs/make.jl index 37a7064..e531cb5 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -1,12 +1,12 @@ using Documenter, ImageMetadata makedocs(modules = [ImageMetadata], - format = Documenter.Formats.HTML, + format = :html, sitename = "ImageMetadata", pages = ["intro.md", "reference.md"]) deploydocs(repo = "github.com/JuliaImages/ImageMetadata.jl.git", - julia = "0.5", + julia = "1.0", target = "build", deps = nothing, make = nothing) diff --git a/docs/src/reference.md b/docs/src/reference.md index b5ce2ed..62cfff0 100644 --- a/docs/src/reference.md +++ b/docs/src/reference.md @@ -6,9 +6,7 @@ data properties copyproperties shareproperties -getindexim -viewim spatialproperties -ImageCore.spacedirections +ImageMetadata.spacedirections permutedims ``` diff --git a/src/ImageMetadata.jl b/src/ImageMetadata.jl index 402a7dd..3309c82 100644 --- a/src/ImageMetadata.jl +++ b/src/ImageMetadata.jl @@ -30,7 +30,7 @@ export `ImageMeta` is an AbstractArray that can have metadata, stored in a dictionary. Construct an image with `ImageMeta(A, props)` (for a properties dictionary -`props`), or with `Image(A, prop1=val1, prop2=val2, ...)`. +`props`), or with `ImageMeta(A, prop1=val1, prop2=val2, ...)`. """ mutable struct ImageMeta{T,N,A<:AbstractArray} <: AbstractArray{T,N} data::A @@ -310,9 +310,7 @@ function permutedims(img::ImageMeta, perm) permutedims_props!(copyproperties(img, permutedims(img.data, perm)), ip) end -""" -Note: `adjoint` does not recurse into ImageMeta properties. -""" +# Note: `adjoint` does not recurse into ImageMeta properties. function Base.adjoint(img::ImageMeta{T,2}) where {T<:Real} ip = sortperm([2,1][[coords_spatial(img)...]]) permutedims_props!(copyproperties(img, adjoint(img.data)), ip)