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

Tracking issue for missing methods in arr namespace #21302

Open
10 tasks
deanm0000 opened this issue Feb 17, 2025 · 5 comments
Open
10 tasks

Tracking issue for missing methods in arr namespace #21302

deanm0000 opened this issue Feb 17, 2025 · 5 comments
Labels
enhancement New feature or an improvement of an existing feature good first issue Good for newcomers

Comments

@deanm0000
Copy link
Collaborator

deanm0000 commented Feb 17, 2025

Description

arr seems to be missing the following methods that ought to work with fixed sizes.

As an aside, I see that arr.unique already exists which creates the precedent that an arr operation can return a list whereas I excluded operations that can't necessarily return a fixed size.

@deanm0000 deanm0000 added the enhancement New feature or an improvement of an existing feature label Feb 17, 2025
@mcrumiller
Copy link
Contributor

mcrumiller commented Feb 17, 2025

It looks like arr.concat is actually implemented already as the pl.concat_arr function, it's just not exposed to the array namespace.

import polars as pl

s1 = pl.Series([[1, 2], [3, 4]], dtype=pl.Array(pl.Int32, 2))
s2 = pl.Series([[5, 6], [7, 8]], dtype=pl.Array(pl.Int32, 2))
>>> pl.select(pl.concat_arr((s1, s2)))
# shape: (2, 1)
# ┌───────────────┐
# │               │
# │ ---           │
# │ array[i32, 4] │
# ╞═══════════════╡
# │ [1, 2, … 6]   │
# │ [3, 4, … 8]   │
# └───────────────┘

@coastalwhite coastalwhite added the good first issue Good for newcomers label Feb 20, 2025
@coastalwhite
Copy link
Collaborator

If anyone were to go about implementing this. Please, go method by method and don't do all at once. The compute-kernels used by the .list might be able to be reused.

@DhruvBShetty
Copy link

I would like to take this issue

@teomac
Copy link
Contributor

teomac commented Feb 26, 2025

Hi @DhruvBShetty
I'm already working on it :)

@coastalwhite coastalwhite changed the title Add methods to arr Tracking issue missing methods in arr namespace Mar 6, 2025
@coastalwhite coastalwhite changed the title Tracking issue missing methods in arr namespace Tracking issue for missing methods in arr namespace Mar 6, 2025
@coastalwhite
Copy link
Collaborator

For slice, head and tail, we will want an as_array flag akin to was done #20941. This will force the length (and offset) to be constant which will allow to keep the Array datatype.

Otherwise, those should output as pl.List as there is no way of knowing the datatype of a head(arbitary_expr) before evaluating the expression (and even then, the expression might not contain a constant value).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or an improvement of an existing feature good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

5 participants