Repository navigation
fix(lshift): shift element-wise for array shift amounts (#120) - #121
Open
umutKaracelebi wants to merge 1 commit into
Open
umutKaracelebi wants to merge 1 commit into
umutKaracelebi wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
Summary
Fxp.__lshift__/__ilshift__now accept an array of shift amounts instead of raisingValueError.Related issue(s)
Type of change
What changed
n_wordwas sized withmax(self.n_word, bits + self.signed + n). With an arraynthat sum is an array, so the scalarmax()compared an array and raisedValueError: The truth value of an array with more than one element is ambiguous. The size now comes from the largest shift amount (int(np.max(n))), soself.val << nshifts element-wise (NumPy semantics) while the result word still fits the largest shift. Scalar shift amounts take the same path as before;__ilshift__shares this code.Testing
pytest -q)tests/test_issues.py(when applicable)pytest -q->219 passed. The newtests/test_issues.py::test_issue_120_v0_5_0fails ondevelopwith the exact traceback from the issue and passes with the fix:a << np.array([1, 2, 3])->fxp-u8/0([ 2 8 24]).Compatibility and risk
>>and forshifting='keep'are out of scope here and remain unsupported.Checklist