Skip to content

[query] teach hl.array to convert 1-d ndarrays#12810

Merged
danking merged 5 commits intohail-is:mainfrom
danking:list-ndarray
Mar 23, 2023
Merged

[query] teach hl.array to convert 1-d ndarrays#12810
danking merged 5 commits intohail-is:mainfrom
danking:list-ndarray

Conversation

@danking
Copy link
Copy Markdown
Contributor

@danking danking commented Mar 22, 2023

CHANGELOG: hl.array can now convert 1-d ndarrays into the equivalent list.

We leave the improvement of the implementation of _data_array to a future PR.

CHANGELOG: hl.array can now convert 1-d ndarrays into the equivalent list.

We leave the improvement of the implementation of `_data_array` to a future PR.

There was one usage of `_data_array` that I could not convince myself used a 1-d ndarray. Thoughts?

```
    # ...
    def numpy_to_cols_table(X, field_name):
        hail_array = X._data_array()
        cols_and_X = hl.zip(A.source_table.index_globals().cols, hail_array).map(lambda tup: tup[0].annotate(**{field_name: tup[1]}))
        t = hl.Table.parallelize(cols_and_X, key=A.col_key)
        return t

    st = None
    lt = None
    eigens = hl.eval(S * S)
    if transpose:
        if compute_loadings:
            lt = numpy_to_cols_table(V, 'loadings')
    # ...
```
[1, 2, 3],
[1, 7],
[1, 2, 3, 3]
)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think you're missing an assertion?

@danking danking dismissed patrick-schultz’s stale review March 22, 2023 13:32

whoops yep; fixed. Thanks!

@danking danking merged commit 22856d6 into hail-is:main Mar 23, 2023
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.

2 participants