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

[query] Fix NDArrays of Non-numerics: Part 1 #9503

Merged
merged 4 commits into from Sep 29, 2020

Conversation

johnc1231
Copy link
Contributor

@johnc1231 johnc1231 commented Sep 24, 2020

CHANGELOG: Fixed bug where making NDArrays of non-numeric types would fail. Non-numeric ndarrays still cannot be collected to python though.

NDArrays of non numeric types are broken, have been for a while. No one seems to use them for that currently, so it hasn't been an issue, but I suspect with dndarray or BlockedMatrixTable experiments it's going to be desirable.

This PR starts to address that problem by doing the following:

  1. checkedConvertFrom, which only supported primitive arrays, is replaced with the more flexible copyFromType. As this was the only use of checkedConvertFrom, I removed it altogether.

  2. Add tests that show that it's now possible to make an ndarray of non-numeric types, so long as the only things that get returned in python are numbers.

The remaining problems all involve conversions to numpy. If you never convert to numpy, things should be fine:

  1. I need to get strides out of the Java ndarray representation. Strides make no sense for non-numeric objects after converting from Java to Python. We say the size of a required tuple of 3 int32's is 12 bytes, but that's not going to be the size of the python object

  2. Strings are tricky too, since the numpy string dtype comes with a max length, so we'll have to do a pass over the strings to figure out how large the largest one is before converting.

@patrick-schultz
Copy link
Collaborator

Did you confirm that the behaviors being tested in the deleted checkedConvertFrom tests are tested elsewhere for copyFromType? Otherwise, looks good.

Copy link
Collaborator

@patrick-schultz patrick-schultz left a comment

Choose a reason for hiding this comment

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

Just awaiting answer to previous question.

@johnc1231 johnc1231 dismissed patrick-schultz’s stale review September 28, 2020 17:25

I believe the arrayCopyTest just below the test being deleted covers this behavior.

@danking danking merged commit da869f2 into hail-is:main Sep 29, 2020
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.

None yet

3 participants