Fix valid index bug in getIndexDigit#1042
Conversation
|
Alternatively, if we want to do this kind of validation, should we add it to the function directly? The downside would be the overhead of the check. However, to me, it feels a little weird to have the extra validation in the CLI but not on the function itself. Or, does it make sense to do the extra validation for the CLI? Would it make sense to have the function and CLI be aligned in terms of how much validation they do? |
| purge: | ||
| rm -rf build | ||
|
|
||
| test: build |
There was a problem hiding this comment.
Is this file intended to be checked in? The test commands seem specific to this change. If not, maybe gitignore it?
There was a problem hiding this comment.
I'll remove it before landing.
I keep it in the git history because I often find myself referring to these files in old PRs after I haven't touched the repo in a while and need to remember how to do things. I find it is a good historical reference of what commands I was actually running at the time.
I also get a lot of value while working on a PR from seeing the diffs of this file over time.
Ideas on better ways to organize these somewhat personalized tooling files?
There was a problem hiding this comment.
Also, I can ask questions like this: @isaacbrodsky, is this how you typically run tests in the repo? Do you tend to run ctest directly or commands like make test-fast? Do you know of a way to run just the CLI tests, or just one CLI test? Currently, ctest runs both the C and CLI tests.
:)
There was a problem hiding this comment.
I usually run make test or make test-fast. When debugging in more detail I would switch to ctest since that provides more direct control and feedback about verbosity, print-on-error, etc. When debugging a specific failure I would then go to running the test binary directly, since I may need to run it under valgrind or lldb/gdb or something.
For the CLI tests I think I mainly run them through make test. For running a specific CLI test I would probably copy out the command from the applicable CMake file.
I don't have a recommendation on the specific commands ran. I feel this would be personal unless you document more about what the commands are and why someone would want to run them. For that I would either gitignore or keep in another branch or repo (as with dotfile repos). Unfortunately that loses the association with which uber/h3 commit they go. You could then try to use submodules to take care of that but my experience is most people find submodules challenging to work with.
There was a problem hiding this comment.
Thanks. For the justfile, I'll probably just stick to my plan of keeping it in the git history while developing, removing it before merging, and then squash merge at the end to keep the history clean.
There was a problem hiding this comment.
Could add it to .gitignore and then keep it in your local?
There was a problem hiding this comment.
I like to keep it in the git history to see how it changes as I work on the diff, and also to be able to reference it later when I come back in a few months and I forget how to build everything. Removing at the last commit and then squashing (to remove it from the repo history) seems like a good compromise, but always open to other ideas!
isaacbrodsky
left a comment
There was a problem hiding this comment.
Please remove justfile before merging
| H3Error vertErr = H3_EXPORT(isValidVertex)(cell); | ||
| if (cellErr && edgeErr && vertErr) { | ||
| return cellErr; | ||
| bool isValid = H3_EXPORT(isValidCell)(cell) || |
There was a problem hiding this comment.
I see how I made this mistake. In most of the code the error condition is the "truthy" value, but here success is true, though I named these variables as if they were H3Errors. That feels like a point against Hungarian Notation.
|
Link to the |
| @@ -309,11 +309,11 @@ SUBCOMMAND(getIndexDigit, | |||
| Arg *args[] = {&getIndexDigitArg, &helpArg, &cellArg, &digitArg}; | |||
There was a problem hiding this comment.
@ajfriend should lines 265-268, 285-288, 391-394, and 420-423 be updated as well?
There was a problem hiding this comment.
Ah, good catch @LucaDiba! And thanks for the fix @justinhwang!
Similar to uber#1042
The following logic in the
getIndexDigitCLI doesn't correctly identify invalid cells/vertexes/edges:h3/src/apps/filters/h3.c
Lines 312 to 317 in 491eead
This is because the
isValid*functions return a boolean, not anH3Errorcode.You can see the bad behavior with:
$ ./build/bin/h3 getIndexDigit -r 15 -c 5 # should fail 5which should instead return an error.