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

add fixing of the array argument for lead and lag #61

Open
bkamins opened this issue Sep 23, 2022 · 2 comments
Open

add fixing of the array argument for lead and lag #61

bkamins opened this issue Sep 23, 2022 · 2 comments

Comments

@bkamins
Copy link

bkamins commented Sep 23, 2022

I propose that lag(2) could be a shorthand of x -> lag(x, 2), using Base.Fix2.
This definition should not introduce any ambiguities and would provide a convenient way for defining a function with lag different than 1.

The same for lead.

@piever
Copy link
Collaborator

piever commented Sep 30, 2022

I see how this would be useful (esp. for the high-level data manipulation syntax of DataFrames & co.). One issue is that for the shifts argument ShiftedArrays accepts also Tuples (actually arbitrary iterables, but that might be disallowed).

Would it be worrying that lag([1, 2]) means "shift [1, 2] by 1, whereas lag((1, 2)) is an anonymous function to shift matrices?

@bkamins
Copy link
Author

bkamins commented Sep 30, 2022

ShiftedArrays.lag((1,2)) currently errors, so I understand you are worried that people would mix-up vectors and tuples.
Indeed it might happen, but at least on my side I try to work hard to explain people that these types are not interchangeable in general and have different usages.

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

No branches or pull requests

2 participants