Skip to content

Commit 9535edc

Browse files
pievernalimilan
authored andcommitted
support view in histogram (#477)
1 parent 1823086 commit 9535edc

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/hist.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import LinearAlgebra: norm, normalize, normalize!
55

66

77
## Fast getindex function for multiple arrays, returns a tuple of array elements
8-
@inline Base.@propagate_inbounds @generated function _multi_getindex(i::Integer, c::AbstractArray...)
8+
@inline Base.@propagate_inbounds @generated function _multi_getindex(i::Union{Integer, CartesianIndex}, c::AbstractArray...)
99
N = length(c)
1010
result_expr = Expr(:tuple)
1111
for j in 1:N

test/hist.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ end
5858
@test fit(Histogram,0:99,weights(2*ones(100)),nbins=5).weights == [40,40,40,40,40]
5959
@test fit(Histogram{Int32},0:99,weights(2*ones(100)),nbins=5).weights == [40,40,40,40,40]
6060
@test fit(Histogram{Float32},0:99,weights(2*ones(100)),nbins=5).weights == [40,40,40,40,40]
61+
62+
d = collect(0:99)
63+
v = view(d, fill(true, 100))
64+
@test fit(Histogram{Float32},v,weights(2*ones(100)),nbins=5).weights == [40,40,40,40,40]
6165
end
6266

6367

0 commit comments

Comments
 (0)