Skip to content

Commit 51cdeae

Browse files
committed
bug fixes
1 parent 1e31517 commit 51cdeae

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/functions/sparse.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function _sparse_reshape(v::SparseVector, m, n)
5858
N = length(v.nzval)
5959
I = zeros(Int, N)
6060
J = zeros(Int, N)
61-
for ind in v.nzind
61+
for (i, ind) in enumerate(v.nzind)
6262
_col, _row = divrem(ind, m)
6363
if _row == 0
6464
col = _col
@@ -67,8 +67,8 @@ function _sparse_reshape(v::SparseVector, m, n)
6767
col = _col + 1
6868
row = _row
6969
end
70-
I[ind] = row
71-
J[ind] = col
70+
I[i] = row
71+
J[i] = col
7272
end
7373
return sparse(I, J, copy(v.nzval), m, n)
7474
end

src/models/flatten.jl

+6-3
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,12 @@ _zero(x::NamedTuple) = map(_zero, x)
253253
_zero(x::Tuple) = map(_zero, x)
254254
_zero(x) = structfromnt(typeof(x), _zero(ntfromstruct(x)))
255255

256-
function _merge(d1, d2::AbstractDict)
257-
_d = OrderedDict(k => _zero(v) for (k, v) in d1)
258-
return sort!(merge(_d, OrderedDict(d2)))
256+
function _merge(d1::AbstractDict{K, V}, d2::AbstractDict) where {K, V}
257+
_d = OrderedDict{K, V}(k => _zero(v) for (k, v) in d1)
258+
return sort!(merge(_d, OrderedDict{K, V}(d2)))
259+
end
260+
function _merge(d1::Tuple, d2::Tangent)
261+
return _merge.(d1, d2.backing)
259262
end
260263
_merge(::Any, d2) = d2
261264

0 commit comments

Comments
 (0)