44# SPDX-License-Identifier: Apache-2.0
55# https://github.com/AcademySoftwareFoundation/OpenImageIO
66
7+ from __future__ import annotations
78
89import OpenImageIO as oiio
910
1516test_channames = ("R" , "G" , "B" , "A" , "Z" , "Zback" )
1617print ("test_chantypes " , str (test_chantypes [0 ]), str (test_chantypes [1 ]), str (test_chantypes [2 ]), str (test_chantypes [3 ]), str (test_chantypes [4 ]), str (test_chantypes [5 ]))
1718
18- def set_dd_sample (dd , pixel , sample , vals ) :
19- if dd .samples (pixel ) <= sample :
20- dd .set_samples (pixel , sample + 1 )
21- for c in range (ib .nchannels ) :
22- dd .set_value (pixel , c , sample , vals [c ])
23-
24- def add_dd_sample (dd , pixel , sample , vals ) :
25- set_dd_sample (dd , pixel , dd .samples (pixel ), vale )
26-
2719
2820# Make a simple deep image
2921# Only odd pixel indes have samples, and they have #samples = pixel index.
30- def make_test_deep_image () :
22+ def make_test_deep_image () -> oiio . DeepData :
3123 dd = oiio .DeepData ()
3224 dd .init (test_xres * test_yres , test_nchannels , test_chantypes , test_channames )
3325 for p in range (dd .pixels ) :
@@ -54,7 +46,7 @@ def make_test_deep_image () :
5446
5547
5648
57- def print_deep_image (dd , prefix = "After init," ) :
49+ def print_deep_image (dd : oiio . DeepData , prefix : str = "After init," ) :
5850 print (prefix , "dd has" , dd .pixels , "pixels," , dd .channels , "channels." )
5951 print (" Channel indices: Z=" , dd .Z_channel , "Zback=" , dd .Zback_channel , "A=" , dd .A_channel , "AR=" , dd .AR_channel , "AG=" , dd .AG_channel , "AB=" , dd .AB_channel )
6052 for p in range (dd .pixels ) :
@@ -68,7 +60,7 @@ def print_deep_image (dd, prefix="After init,") :
6860 print ()
6961
7062
71- def print_deep_imagebuf (buf , prefix ) :
63+ def print_deep_imagebuf (buf : oiio . ImageBuf , prefix : str ) :
7264 print_deep_image (buf .deepdata (), prefix )
7365
7466
@@ -241,13 +233,13 @@ def test_opaque_z () :
241233 print ()
242234
243235
244- def set_ib_sample (ib , x , y , sample , vals ) :
236+ def set_ib_sample (ib : oiio . ImageBuf , x : int , y : int , sample : int , vals : tuple [ float , ...] ) :
245237 if ib .deep_samples (x , y ) <= sample :
246238 ib .set_deep_samples (x , y , 0 , sample + 1 )
247239 for c in range (ib .nchannels ) :
248240 ib .set_deep_value (x , y , 0 , c , sample , vals [c ])
249241
250- def add_ib_sample (ib , x , y , vals ) :
242+ def add_ib_sample (ib : oiio . ImageBuf , x : int , y : int , vals : tuple [ float , ...] ) :
251243 set_ib_sample (ib , x , y , ib .deep_samples (x ,y ), vals )
252244
253245
@@ -301,13 +293,15 @@ def test_iba_deep_holdout () :
301293 spec .channelformats = test_chantypes
302294 spec .deep = True
303295 output = oiio .ImageOutput .create ("deeptest.exr" )
296+ assert output is not None
304297 output .open ("deeptest.exr" , spec , "create" )
305298 output .write_deep_image (dd )
306299 output .close ()
307300
308301 # read the exr file and double check it
309302 print ("\n Reading image..." )
310303 input = oiio .ImageInput .open ("deeptest.exr" )
304+ assert input is not None
311305 ddr = input .read_native_deep_image ()
312306 if ddr :
313307 print_deep_image (ddr )
0 commit comments