diff --git a/src/core.jl b/src/core.jl index 3dd35e6d..dfda25f4 100644 --- a/src/core.jl +++ b/src/core.jl @@ -76,8 +76,8 @@ ndims(img::AbstractImage) = ndims(img.data) strides(img::AbstractImage) = strides(img.data) -copy(img::Image) = Image(copy(img.data), deepcopy(img.properties)) -copy(img::ImageCmap) = ImageCmap(copy(img.data), copy(img.cmap), deepcopy(img.properties)) +copy(img::Image) = Image(copy(img.data), deepcopy(img.properties)::typeof(img.properties)) # see issue #356 +copy(img::ImageCmap) = ImageCmap(copy(img.data), copy(img.cmap), deepcopy(img.properties)::typeof(img.properties)) # Create a new "Image" (could be just an Array) copying the properties but replacing the data copyproperties(img::AbstractArray, data::AbstractArray) = data diff --git a/test/core.jl b/test/core.jl index e3879214..db0fb8d6 100644 --- a/test/core.jl +++ b/test/core.jl @@ -6,6 +6,9 @@ if testing_units end facts("Core") do + a = rand(3,3) + @inferred(Image(a)) + # support integer-valued types, but these are NOT recommended (use Ufixed) B = rand(convert(UInt16, 1):convert(UInt16, 20), 3, 5) # img, imgd, and imgds will be used in many more tests @@ -127,7 +130,7 @@ facts("Core") do context("Copy / similar") do A = randn(3,5,3) - imgc = copy(img) + imgc = @inferred(copy(img)) @fact imgc.data --> img.data imgc = copyproperties(imgd, A) @fact imgc.data --> A