Skip to content

Commit f50f59b

Browse files
authored
deprecate ColorizedArray in favor of MappedArray (#927)
1 parent e14a49f commit f50f59b

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

src/labeledarrays.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ associated with that point's label.
1818
This computation is performed lazily, as to be suitable even for large arrays.
1919
"""
2020
function ColorizedArray(intensity, label::IndirectArray{C,N}) where {C<:Colorant,N}
21+
depwarn("`ColorizedArray(intensity, label)` is deprecated, use `mappedarray(*, intensity, label)` from `MappedArrays` instead", :ColorizedArray)
22+
2123
axes(intensity) == axes(label) || throw(DimensionMismatch("intensity and label must have the same axes, got $(axes(intensity)) and $(axes(label))"))
2224
CI = typeof(zero(C)*zero(eltype(intensity)))
2325
ColorizedArray{CI,N,typeof(intensity),typeof(label)}(intensity, label)

test/arrays.jl

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
1-
using Images, IndirectArrays, Test
1+
using Images, IndirectArrays, Test, Suppressor
2+
using Images.MappedArrays: mappedarray
23

34
@testset "ColorizedArray" begin
45
intensity = [0.1 0.3; 0.2 0.4]
56
labels = IndirectArray([1 2; 2 1], [RGB(1,0,0), RGB(0,0,1)])
6-
A = ColorizedArray(intensity, labels)
7+
colorized_A = @suppress_err ColorizedArray(intensity, labels)
8+
mapped_A = mappedarray(*, intensity, labels)
9+
710
target = intensity .* labels
8-
@test eltype(A) == RGB{Float64}
9-
@test size(A) == (2,2)
10-
@test axes(A) == (Base.OneTo(2), Base.OneTo(2))
11-
for i = 1:4
12-
@test A[i] === target[i]
13-
end
14-
for j = 1:2, i = 1:2
15-
@test A[i,j] === target[i,j]
16-
end
17-
for (a,t) in zip(A, target)
18-
@test a === t
11+
12+
for A in (colorized_A, mapped_A)
13+
@test eltype(A) == RGB{Float64}
14+
@test size(A) == (2,2)
15+
@test axes(A) == (Base.OneTo(2), Base.OneTo(2))
16+
for i = 1:4
17+
@test A[i] === target[i]
18+
end
19+
for j = 1:2, i = 1:2
20+
@test A[i,j] === target[i,j]
21+
end
22+
for (a,t) in zip(A, target)
23+
@test a === t
24+
end
1925
end
2026

2127
intensity1 = [0.1 0.3 0.6; 0.2 0.4 0.1]

0 commit comments

Comments
 (0)