Add ShiftedArrays.diff for differences between elements in a vector#51
Add ShiftedArrays.diff for differences between elements in a vector#51pdeffebach wants to merge 1 commit intoJuliaArrays:masterfrom
ShiftedArrays.diff for differences between elements in a vector#51Conversation
|
I agree we really need this, but it's not specific to ShiftedArrays at all since it returns a plain |
|
Filed an issue here |
|
I also think it's a bit odd that this should live here. IMO, the idea behind Returning an eager result whose value differs from |
|
Ah yeah so you mean it would make sense to have |
|
If it's performant to have the object be lazy, and if it takes advantage of the same infrastructure as @piever do you want to experiment with making this be lazy? Or should I modify the PR to make it return something which looks like what |
I think it'd make sense for it to return a lazy object, as for instance diff(v, n = 1; default) = Broadcast.broadcasted(-, v, lag(v, n; default))My main concern was that |
|
Okay, I see your point about consistency with Base. Sorry for missing it earlier. If possible can you show your support in the linked issue? Would be good to coalesce these two discussions into one. |
| export ShiftedArray, ShiftedVector, shifts, default | ||
| export CircShiftedArray, CircShiftedVector | ||
| export lag, lead | ||
| # ShiftedArrays.diff unexported due to collision |
There was a problem hiding this comment.
it should not be exported - no need to comment I think
Base.diffdoes not return a vector of the same size as the original. I find this very frustrating, as I express in #41.This PR adds
ShiftedArrays.diffas a function to get the difference between elements, but pre-pendsmissingat the first element.I understand that
ShiftedArrays.diffis more characters thanx .- lag(x), but it's more declarative.