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

Extend function chunk() to expect a chunk size parameter? #109

Closed
gruberchr opened this issue Jun 28, 2022 · 2 comments · Fixed by #112
Closed

Extend function chunk() to expect a chunk size parameter? #109

gruberchr opened this issue Jun 28, 2022 · 2 comments · Fixed by #112

Comments

@gruberchr
Copy link

Hi, I have a use case, where I want to split an Array x into parts in the same way as the function chunk() is doing, but with known chunk size and unknown number of parts. AFAIKS there is no similar function to chunk() in MLUtils.jl which expects the chunk size parameter instead of the number of parts.

Of course, I could write a wrapper around chunk(), which calculates the number of parts from the array size and the desired chunk size. But as can be seen in utils.jl internally the number of parts is already converted to the chunk size. That means writing a wrapper around chunk() would do the conversion from chunk size to the number of parts and the function chunk() would convert the number of parts back to the chunk size.

My question therefore is, if it would be meaningful to provide a similar function like chunk() in MLUtils.jl, which expects a chunk size parameter? The current implementation of chunk() could then be rewritten as a wrapper around this new function, which calculates the chunk size from the number of parts.

@CarloLucibello
Copy link
Member

we can add a method chunk(x; size) for convenience. PR welcome!

@gruberchr
Copy link
Author

I'll give my best

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 a pull request may close this issue.

2 participants