[ESSDIFFRACTION] Fix multiplication with mask - #674
Open
jl-wynen wants to merge 2 commits into
Open
Conversation
jl-wynen
enabled auto-merge
July 24, 2026 09:32
Multiplication does not work with inf and nan.
nvaytet
reviewed
Jul 24, 2026
| hist.data = hist.data.copy() | ||
| hist.values *= irreducible_mask(hist.masks, hist.dim).values | ||
| if hist.variances is not None: | ||
| replacement = sc.scalar(0.0, variance=0.0, unit=hist.unit, dtype=hist.dtype) |
Member
There was a problem hiding this comment.
I guess this is the usual question: should the variance be 0, and thus being a very tight constraint on fits?
Member
There was a problem hiding this comment.
I think I would nan the masked values instead of 0. Makes them easier to distinguish from real zeros
Member
Author
There was a problem hiding this comment.
Good point. I tried that and easydiffraction doesn't like it. It raises
TypeError: Value mismatch for <reduced_tof.data.1.intensity_meas>. Provided nan outside [0, inf]. Keeping current 0.0.
Judging by that error message, inf would be valid.
@AndrewSazonov How do we best encode masked data? In this case, it is masked because the vanadium measurement has a 0 in a bin.
Member
There was a problem hiding this comment.
Inf feels like it would just be a workaround/hack. Would make more sense if NaN was accepted downstream.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I messed this up in #673
sc.whereinstead of multiplication because the latter does not work when the data is Inf or NaN.