Skip to content

Commit

Permalink
equal comparison between NMF.Results
Browse files Browse the repository at this point in the history
and hash of NMF.Results
  • Loading branch information
youdongguo committed Aug 15, 2023
1 parent 07419bf commit 2552277
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/common.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ struct Result{T}
end
end


Base.:(==)(A::Result, B::Result) = A.W == B.W && A.H == B.H && A.niters == B.niters && A.converged == B.converged && A.objvalue == B.objvalue
Base.hash(s::Result, h::UInt) = hash(s.objvalue, hash(s.converged, hash(s.niters, hash(s.H, hash(s.W, h + (0x09c9f08cfcba6de3 % UInt))))))


# common algorithmic skeleton for iterative updating methods

abstract type NMFUpdater{T} end
Expand Down
6 changes: 6 additions & 0 deletions test/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,10 @@
Xr = zeros(4, 5)
NMF.pdrsolve!(Y, B, Xr)
@test Xr X

X, Wg, Hg = laurberg6x3(0.3)
Xnmf = NMF.solve!(NMF.CoordinateDescent{Float64}=0.0, maxiter=1000, tol=1e-9), X, Wg, Hg)
Xnmf1 = deepcopy(Xnmf)
@test Xnmf == Xnmf1
@test hash(Xnmf) == hash(Xnmf1)
end

0 comments on commit 2552277

Please sign in to comment.