avoid cryptic SVG rendering error / check that solution output is actually a tensor#27
Open
noahlt wants to merge 1 commit intosrush:mainfrom
Open
avoid cryptic SVG rendering error / check that solution output is actually a tensor#27noahlt wants to merge 1 commit intosrush:mainfrom
noahlt wants to merge 1 commit intosrush:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The problem: If the user's solution to a puzzle is a rank-0 tensor (eg,
tensor(6)), runningmake_testresults in a cryptic TypeError many levels deep in the SVG-rendering code. This is documented pretty well by @ikamensh in #23.This solution: This change adds a check,
torch.is_tensor(yours) and yours.ndim > 0, before adding the user's solution output to the data to be rendered to the SVG.Caveats: The solution checker seems to accept
tensor(6),tensor([6]),tensor([[6]]), equally. Before this change, the SVG-rendering code would error out before solution checker ran, so you could call that "failing". I don't completely understand the solution-checking code and I'm not sure whether that is intended behavior.Hopefully this makes sense. I'm happy to discuss it or make changes if you'd like. Thanks in advance!