Skip to content

Commit

Permalink
Fix writing arrays with unconventional indices
Browse files Browse the repository at this point in the history
  • Loading branch information
timholy committed Sep 2, 2017
1 parent aad2e25 commit cfd7b19
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Writer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ Serialize a multidimensional array to JSON in column-major format. That is,
function show_json{T,n}(io::SC, s::CS, A::AbstractArray{T,n})
begin_array(io)
newdims = ntuple(_ -> :, Val{n - 1})
for j in 1:size(A, n)
for j in indices(A, n)
show_element(io, s, view(A, newdims..., j))
end
end_array(io)
Expand Down
1 change: 1 addition & 0 deletions test/REQUIRE
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
DataStructures
FixedPointNumbers
OffsetArrays
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using JSON
using Base.Test
using Compat
using OffsetArrays

import DataStructures

Expand Down
1 change: 1 addition & 0 deletions test/standard-serializer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ end

#Multidimensional arrays
@test json([0 1; 2 0]) == "[[0,2],[1,0]]"
@test json(OffsetArray([0 1; 2 0], 0:1, 10:11)) == "[[0,2],[1,0]]"
end

@testset "Pairs" begin
Expand Down

0 comments on commit cfd7b19

Please sign in to comment.