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

diff(A, dims=1) should make new gridpoints staggered (?) #163

Open
mauro3 opened this issue Apr 29, 2021 · 5 comments
Open

diff(A, dims=1) should make new gridpoints staggered (?) #163

mauro3 opened this issue Apr 29, 2021 · 5 comments

Comments

@mauro3
Copy link
Collaborator

mauro3 commented Apr 29, 2021

Currently it keeps the original grid, dropping the last point.

@rafaqz
Copy link
Owner

rafaqz commented Apr 29, 2021

Yeah I wasn't sure what to do here, this may be wrong/a bug.

What do you mean by staggered?

@mauro3
Copy link
Collaborator Author

mauro3 commented Apr 29, 2021

Move the grid by half the grid spacing: xnew = 0.5*(x[1:end-1] .+ x[2:end]). But I'm not sure whether this is "right" in all cases, it is for my current one ;-)

@rafaqz
Copy link
Owner

rafaqz commented Apr 29, 2021

Im not sure that will work for DateTime. You cant e.g. shift half months generically.

But you can hack it for your use case (not tested):

set(A, X=dims(A, X) .+ step(span(A, X))/2)

@mauro3
Copy link
Collaborator Author

mauro3 commented Apr 29, 2021

Yes, it doesn't work for integer indices either (in general). So not sure what's best.

@rafaqz
Copy link
Owner

rafaqz commented Apr 29, 2021

Thats pretty much why it is what it is... its hard to be consistent otherwise. But Im not sure what would be "correct" in terms if the meaning of diff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants