You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The PyTorch backend wrapper converted NumPy MaskedArray inputs with torch.as_tensor. That conversion discards the mask and exposes the hidden payload, so nonzero could report masked entries as present.
For example, a masked 2×2 input whose only unmasked nonzero value is at (1, 0) returned (0, 1), (1, 0), and (1, 1) on the PyTorch backend.
Fix
fill masked entries with zero before converting to a PyTorch tensor;
preserve the existing rejection of zero-dimensional inputs;
preserve ordinary list, NumPy-array, and tensor handling;
add regression coverage for both the public and raw PyTorch backend helpers.
Validation
reproduced the pre-fix mask loss with NumPy 2.3.5 and PyTorch 2.10.0;
verified the patched helper matches numpy.nonzero for the masked input;
verified existing scalar rejection and ordinary matrix behavior in the isolated harness;
syntax-compiled both modified files;
branch comparison: 2 commits ahead, 0 behind main, with only 2 files changed.
The full supported backend and Python-version matrix is delegated to GitHub Actions.
📣 MegaLinter 9.5.0 is out! Discover the new features and security recommendations in the release announcement. (Skip this info by defining SECURITY_SUGGESTIONS: false)
Your project could benefit from a custom flavor, which would allow you to run only the linters you need, and thus improve runtime performances. (Skip this info by defining FLAVOR_SUGGESTIONS: false)
Closing as low value. This introduces NumPy masked-array semantics into the PyTorch nonzero compatibility layer, while masked arrays are not a native PyTorch input contract and are not supported consistently across PyRecEst. Isolated mask handling here would make backend behavior less coherent.
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
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.
Bug
The PyTorch backend wrapper converted NumPy
MaskedArrayinputs withtorch.as_tensor. That conversion discards the mask and exposes the hidden payload, sononzerocould report masked entries as present.For example, a masked 2×2 input whose only unmasked nonzero value is at
(1, 0)returned(0, 1),(1, 0), and(1, 1)on the PyTorch backend.Fix
Validation
numpy.nonzerofor the masked input;main, with only 2 files changed.The full supported backend and Python-version matrix is delegated to GitHub Actions.