Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/Fixed slicing shape for array of booleans #1497

Merged
merged 1 commit into from
Jun 10, 2022
Merged

Conversation

ioanaif
Copy link
Collaborator

@ioanaif ioanaif commented Jun 10, 2022

@codecov
Copy link

codecov bot commented Jun 10, 2022

Codecov Report

Merging #1497 (71bc039) into main (8a4ea2b) will increase coverage by 0.04%.
The diff coverage is 84.10%.

Impacted Files Coverage Δ
src/awkward/_v2/contents/indexedarray.py 73.83% <ø> (ø)
src/awkward/_v2/operations/ak_cartesian.py 89.68% <ø> (ø)
src/awkward/_v2/operations/ak_full_like.py 100.00% <ø> (ø)
src/awkward/_v2/operations/ak_nan_to_none.py 26.66% <ø> (ø)
src/awkward/_v2/operations/ak_with_field.py 97.87% <ø> (ø)
src/awkward/_v2/_connect/jax/__init__.py 88.88% <66.66%> (-1.59%) ⬇️
src/awkward/_v2/contents/unmaskedarray.py 68.94% <66.66%> (ø)
src/awkward/_v2/_connect/jax/_reducers.py 76.92% <76.92%> (ø)
src/awkward/_v2/contents/listoffsetarray.py 81.85% <77.77%> (ø)
src/awkward/_v2/contents/content.py 76.61% <83.33%> (ø)
... and 22 more

@jpivarski jpivarski linked an issue Jun 10, 2022 that may be closed by this pull request
Copy link
Member

@jpivarski jpivarski left a comment

Choose a reason for hiding this comment

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

Thanks for the quick fix, @ioanaif! If this is done (it looks like it is), please do squash-and-merge it.

Comment on lines -62 to +64
out.append(ak._v2.index.Index64(nplike.nonzero(x)[0]))
out[-1].metadata["shape"] = x.shape
current = ak._v2.index.Index64(nplike.nonzero(x)[0])
out.append(current)
out[-1].metadata["shape"] = current.data.shape
Copy link
Member

Choose a reason for hiding this comment

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

That makes a lot of sense: the shape had been wrong because at some point, we made the assumption that x is an array of integer positions, but here it's an array of booleans, unlike what goes into out. If this was the case, the following should have worked (pre-bug-fix), because the shape of the booleans and the shape of the integers is the same:

>>> ak._v2.Array([[1.1, 2.2, 3.3], [4.4], [5.5, 6.6]])[[True, True, True], 0]
<Array [1.1, 4.4, 5.5] type='3 * float64'>

and it did.

@ioanaif ioanaif merged commit ffa791a into main Jun 10, 2022
@ioanaif ioanaif deleted the ioanaif/fix-issue-1495 branch June 10, 2022 12:33
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.

Boolean array slice followed by integer slice in v2
2 participants