-
Notifications
You must be signed in to change notification settings - Fork 633
test: Fix docs test, used wrong namespace #4090
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
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
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.
For consistency with other examples, should this use
MakeTxTexture
instead ofoiio.MakeTxTexture
? All the other examples use stuff imported fromfrom OpenImageIO import *
.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.
Sure.
I'm not very immersed in Python culture. Remembering that this is not just a test, but its snippets will be directly used in the documentation as examples for the API calls, what's customary when documenting a library and providing code examples? Is it typical to omit any namespacing at all? Or to use a namespace in the examples? To always use the full namespace?
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.
Numpy example: https://numpy.org/doc/1.26/user/absolute_beginners.html#how-to-import-numpy
They show how to import, use a short namespace alias, and then they use the namespace everywhere in the rest of the examples. I think this is wise, as for beginners it more easily distinguishes between the Numpy API and things that might be features of Python itself.
I think we should do the same. So I want to keep the use of the oiio namespace here. And let's make a mental note that, separately, we should find anyplace in the examples that does a full
from OpenImageIO import *
and change that to use a namespace to be more clear.Uh oh!
There was an error while loading. Please reload this page.
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.
If possible, it's recommended to avoid using start imports. My initial comment was to keep the consistency, but it would be a good idea, like you suggest, to instead use
import OpenImageIO
orimport OpenImageIO as oiio
.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.
Agreed. In general, in both C++ and Python, I think it's better style to always use the namespacing explicitly, for clarity. At least as a default, and take exceptions one by one in cases where removing the namespacing clearly the code more readable.
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 not sure where the
*
import came from. Git blame says me, of course, but it's contrary to my usual style, so I think I just wasn't considering it very carefully at that moment.