-
Notifications
You must be signed in to change notification settings - Fork 1k
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
auto-names throwing warnings+error with if/else list #4274
Comments
@robitalec thanks so much for the thorough report. Unfortunately your last line gave me an error:
|
CRAN shows me |
Sorry about that - I should've clarified which version of v0.1.12 has the fix (so don't use that one) I'll update above - the warnings+error can be reproduced with
|
Thanks @robitalec I see the issue:
I can see three options: (1) explicitly add (2) Branch your code before (3) use I'm not sure there's any easy way to get around this from
IINM it's only possible for code like yours to succeed if the That said, I see a logic error that can help to have made a better error message for diagnosis, at least |
Thanks for looking into this so quickly @MichaelChirico. So I'll think about just simplifying this argument or evaluating it outside of the |
Yes & yes. the analysis of your j "query" is done before evaluating it (evaluation might take a very long time & there's no way to know in advance that it's trivially fast, like in your case). Your workaround of returning an object assigned to the output of your if/else instead of returning directly I think is perfectly fine, with again the caveat that this could be inefficient. if your input has 1M groups, each group will run if(returnDistance). that's 999,999 times too many & I'm not sure whether we benefit from branch prediction in such a complex program |
Ok! Neat. And yes - for sure. I'll do some tests and try to simplify things. Thanks for the advice. |
@robitalec please close this issue if you will fix it in your package, and ideally you could link a commit in your package that fixed it, so anyone who will face similar issue can look at your solution. Thanks |
Will do @jangorecki, I wasn't sure if it would be closed by #4275. @MichaelChirico by the way, there wasn't a noticeable difference in run time for the current version and a modified version of this function that splits the logic if(returnDistance) out of the j query. Thank you both! |
@robitalec Thank you. |
Description
My package
spatsoc
v0.1.11 was returning two warnings and one error from data.table recently. I narrowed it down to version 1.12.6 vs 1.12.8, potentially the new auto-name j (#3802). These are internal warnings so not something I'm too confident diagnosing, but I did find a simple workaround that seems to make them disappear - so that might be informative for you.The warnings:
longer object length is not a multiple of shorter object length
Different branches of j expression produced different auto-named columns: [NA!=distance]; using the most "last" names
and the error:
Internal error: jvnames is length 2 but ans is 4 and bynames is 1
The fix
The fix: assign the if/else lists and explicitly return it. Here is a commit that makes that change.
The warnings and error are present in v1.12.8 but not in 1.12.6 and disappear completely with the above fix.
Minimal reproducible example
This will require an install of a couple packages, as I'm not sure how to reproduce it outside of my situation but the warnings and error can be reproduced using one of
spatsoc
's function's examples from the man.Output of
sessionInfo()
The text was updated successfully, but these errors were encountered: