-
Notifications
You must be signed in to change notification settings - Fork 590
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP - Prototype docs examples doubling as tests
New theory of code examples in the docs: every one should live in the testsuite somewhere, and merely be included by reference in the docs. This ensures that every code example works, stays current with the evolution of the APIs, and never breaks. It also beefs up our test cases for more thorough code overage in the testsuite. I've done this with just one example here, but hopefully it serves as an example for others to -- bit by bit -- convert all the other code examples in the docs into tests in a similar manner. Doing this for any one example is a perfect "good first issue," since it's bite sized and can easily be done in a day, it doesn't require any knowledge of deep OIIO internals, and in the process it also teaches you something about how both the docs and the testsuite are set up. Signed-off-by: Larry Gritz <[email protected]>
- Loading branch information
Showing
4 changed files
with
26 additions
and
20 deletions.
There are no files selected for viewing
This file contains 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 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 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import OpenImageIO as oiio | ||
import numpy as np | ||
|
||
filename = "simple.tif" | ||
xres = 640 | ||
yres = 480 | ||
channels = 3 # RGB | ||
pixels = np.zeros((yres, xres, channels), dtype=np.uint8) | ||
|
||
out = oiio.ImageOutput.create (filename) | ||
if out: | ||
spec = oiio.ImageSpec(xres, yres, channels, 'uint8') | ||
out.open (filename, spec) | ||
out.write_image (pixels) | ||
out.close () |