-
Notifications
You must be signed in to change notification settings - Fork 37
Improvements to @submodel in #309
#348
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
1d6b305
added prefix keyword argument to submodel-macro
torfjelde 83e5527
Apply suggestions from code review
torfjelde f1ec6a0
converted example in docs into test
torfjelde 92747ca
Merge branch 'tor/simple-varinfo-v2' into tor/submodel-improvements
torfjelde 3e2ac78
fixed docstring
torfjelde 1b5fc00
Apply suggestions from code review
torfjelde 18d07e8
removed redundant prefix_submodel_context def and added another examp…
torfjelde 89d0b38
fixed doctests
torfjelde dc9564f
attempt at fixing doctests
torfjelde 80b5c6b
another attempt at fixing doctests
torfjelde 2980cb0
had a typo in docstring
torfjelde File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm late to the party but I thought I'd add a comment anyway 😄
Isn't the amount of supported types (in particular the boolean special case) and different behaviours here potentially confusing for users? And does the documentation have to distinguish between the last two cases (strings - or symbols? - and expressions) - isn't a string also an expression 😛 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, we don't have to make the distinction clear to the user. Then all they need to know is that:
Boolspecifies whether or not do prefix, and iftruewe'll try to do it automatically.The reason why I decided to make them distinct is that they will potentially have different performance implications, as noted later on. But maybe you're right that it's unnecessary to put in the initial part of the docstring, so I'm happy to just combine
prefix="my prefix"andprefix=expressioninto a common note, just saying that it will be converted intoSymbol(result of evaluating expression).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think this would improve the docstring.
Additionally, another approach (I think Hong mentioned it somewhere and probably it was discussed there?) could be to always try to set it automatically if it is not provided and force users to state e.g. "prefix=nothing" if they don't want a prefix - assuming that one basically always wants a prefix. Then one could avoid the
Booleans and would just have to handlenothing.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool! I'll make that change and push it to #309 .
Though I do kind of like the
nothingidea, I'm not a big fan of the automatic prefixing. It will error very often because you can capture any return-value on the LHS, and many of these ways, e.g.(a, b) = ..., is not compatible withVarInfo😕