-
Notifications
You must be signed in to change notification settings - Fork 596
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Python: add ability to getattribute of int64 and uint64 data
Just a couple missing pieces were preventing getattribute() from retrieving attributes that were stored as int64 or uint64. That doesn't come up very often, but one place is retrieving certain statistics that use 64 bit counters. (This comes up in ImageCache, among other places.) While we're at it, there was no existing test dedicated to the python binding of ImageCache. So to add these getattribute calls, I made one. There is an important caveat about ImageCache.getattribute(): In this process, I discovered that the flavor of IC.getattribute(name) where you only pass the name is BROKEN, and will always return None. You MUST use the form where you pass the type, like x = ic.getattribute("foo", "int") This is unfortunate and not very Pythonic, but it is the workaround for now. I will addess getting the name-only form working in a separate PR. Closes #3537
- Loading branch information
Showing
5 changed files
with
50 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
stat:cache_memory_used 0 | ||
stat:image_size 4036864 | ||
total_files 2 | ||
all_filenames ('../common/grid.tif', '../common/tahoe-tiny.tif') | ||
|
||
Done. |
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,8 @@ | ||
#!/usr/bin/env python | ||
|
||
# Run the script | ||
command += pythonbin + " src/test_imagecache.py > out.txt ;" | ||
|
||
# compare the outputs | ||
outputs = [ "out.txt" ] | ||
|
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,30 @@ | ||
#!/usr/bin/env python | ||
|
||
from __future__ import print_function | ||
from __future__ import absolute_import | ||
import array | ||
import numpy | ||
import OpenImageIO as oiio | ||
|
||
|
||
|
||
###################################################################### | ||
# main test starts here | ||
|
||
try: | ||
ic = oiio.ImageCache() | ||
|
||
# Force a file to be touched by the IC | ||
ib = oiio.ImageBuf("../common/tahoe-tiny.tif") | ||
ib = oiio.ImageBuf("../common/grid.tif") | ||
|
||
print ("stat:cache_memory_used", ic.getattribute("stat:cache_memory_used", 'int64')) | ||
print ("stat:image_size", ic.getattribute("stat:image_size", 'int64')) | ||
total_files = ic.getattribute("total_files", 'int') | ||
print ("total_files", ic.getattribute("total_files", 'int')) | ||
print ("all_filenames", ic.getattribute("all_filenames", 'string[{}]'.format(total_files))) | ||
|
||
print ("\nDone.") | ||
except Exception as detail: | ||
print ("Unknown exception:", detail) | ||
|