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

Change unpack to avoid colname -> true mystery #621

Closed
ablaom opened this issue Aug 27, 2021 · 0 comments
Closed

Change unpack to avoid colname -> true mystery #621

ablaom opened this issue Aug 27, 2021 · 0 comments

Comments

@ablaom
Copy link
Member

ablaom commented Aug 27, 2021

A rather sophisticated user found the current behaviour of unpack difficult to understand, despite it's detailed (but possibly deficient) docstring.

I also find it annoying to include _ -> true to pick up all remaining columns for the last return value when this is what I want 90% of the time anyway.

Finally, the current design is inconsistent with partition: there you specify n - 1 fractions to get n return values, whereas unpack is requiring n filters for n return values.

I propose that unpack(data, filters...; kwargs...) return what, under the current implementation, is returned by unpack(data, filters..., _ -> true; kwargs...). That is, the last return value is always "everything left over".

So, for example, if I have a table - with columns :a, :b, :c and :d - and I want to unpack column :b as y and the rest as X then the new syntax would be

y, X = unpack(data, ==(:b))

If instead X should exclude :d (ie, include only :a and :c) then I would do

y, X, _ = unpack(data, ==(:b), !=(:d))
@ablaom ablaom added this to priority low / straightforward in General Sep 22, 2021
ablaom added a commit that referenced this issue Dec 14, 2021
@ablaom ablaom closed this as completed Dec 14, 2021
General automation moved this from priority low / straightforward to Done Dec 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

1 participant