Skip to content

Conversation

youdongguo
Copy link
Member

No description provided.

@youdongguo youdongguo requested a review from timholy August 5, 2025 03:19
Copy link
Member

@timholy timholy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice. You've done a good job of ensuring this change does not break the public API of the package, while being free to change unexported internals.

src/NMFMerge.jl Outdated
@@ -221,4 +220,7 @@ function mergecolumns(W::AbstractArray, H::AbstractArray, mergeseq::AbstractArra
return Smtx, Matrix(Tmtx), STstage, Err
end

mergepenalty(λ_min, t1sq, t2sq) = λ_min
shotpenalty(λ_min, t1sq, t2sq) = λ_min / sqrt(min(t1sq, t2sq))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we consider exporting mergepenalty and shotpenalty? If so, they would need docstrings and each to have tests. Alternatively we could keep them private. If so, then since shotpenalty is untested perhaps it should not be in this package?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deleted shotpenalty, I think keeping it private at this moment is better as I am not sure how to describe the queuepenalty in a good way. We have a queuepenalty work in a fixed way as: f(E, t1sq, t2sq), users cannot define a customized penalty function.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once this merges, they will be able to define their own queuepenalty, but I like the idea of not exporting anything.

@timholy
Copy link
Member

timholy commented Aug 5, 2025

Either in this PR or after you merge it, you should release this as v1.1.0 of the package. (It's a new feature, so it should bump the minor version number.)

One more thought, it might be worth mentioning the possibility of passing in a queuepenalty in the docstring. You'll want to describe the API that it should satisfy.


Performs "NMF-Merge" on data matrix `X`.

Arguments:

-`queuepenalty`: a function of the form `f(E, t1sq, t2sq)` that computes the penalty for merging two components, where `E` is the the merge error described in the paper, default: f(E, t1sq, t2sq)=E.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added yesterday but forgot to mention in the conversation. I am confused about how to describe it in a good way.

Copy link
Member

@timholy timholy Aug 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe put the queuepenalty argument in square brackets, as that often indicates, an optional argument: result = nmfmerge([queuepenalty,] X, ncomponents; ...). An alternative is to use multiple lines:

    result = nmfmerge(X, ncomponents; ...)
    result = nmfmerge(queuepenalty, X, ncomponents; ...)

Performs "NMF-Merge" on data matrix `X`. ...

In the API for queuepenalty you should also describe what t1sq and t2sq are.

Copy link
Member

@timholy timholy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a reminder that only a few things (mostly documentation) remain before merging:

  • indicate that queuepenalty is an optional argument to nmfmerge, e.g., with nmfmerge([queuepenalty,] X, ...) or by using two lines, one supplying queuepenalty and one not (see #33 (comment))
  • describe the meaning of the t1sq and t2sq arguments for queuepenalty
  • Docstring for colmerge2to1pq (which is also exported) should be updated to include queuepenalty. You can refer readers to the docstring for nmfmerge for an explanation about the queuepenalty API, rather than repeating the same material all over again.
  • It would be ideal to add a test where the user supplies a custom queuepenalty and verify that it changes the merge order
  • bump the version number to 1.1.0 in the Project.toml so this is ready to register as a new version

@timholy
Copy link
Member

timholy commented Sep 3, 2025

Bump

@youdongguo youdongguo requested a review from timholy September 3, 2025 20:30
@timholy
Copy link
Member

timholy commented Sep 4, 2025

Still needs a test. You could probably use something like

nmfmerge(X, ...) do E, t1sq, t2sq
    return -E
end

and then test that it picks out the worst pair to merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants