@@ -31,8 +31,8 @@ def test_write_RGB():
31
31
32
32
# Generate a 3D NumPy array for RGB channels with random values
33
33
height , width = (20 , 10 )
34
- RGB = np .random .rand (height , width , 3 ).astype ('f' )
35
-
34
+ RGB = np .random .rand (height , width , 3 ).astype (np . float32 )
35
+
36
36
channels = { "RGB" : RGB }
37
37
header = { "compression" : OpenEXR .ZIP_COMPRESSION ,
38
38
"type" : OpenEXR .scanlineimage }
@@ -122,27 +122,28 @@ def test_multipart_write():
122
122
123
123
height , width = (20 , 10 )
124
124
125
- Z0 = np .zeros ((height , width ), dtype = 'f' )
125
+ Z0 = np .zeros ((height , width ), dtype = np . float32 )
126
126
P0 = OpenEXR .Part (header = {"type" : OpenEXR .scanlineimage },
127
127
channels = {"Z" : Z0 })
128
128
129
- Z1 = np .ones ((height , width ), dtype = 'f' )
129
+ Z1 = np .ones ((height , width ), dtype = np . float32 )
130
130
P1 = OpenEXR .Part (header = {"type" : OpenEXR .scanlineimage },
131
131
channels = {"Z" : Z1 })
132
132
133
- f = OpenEXR .File (parts = [P0 , P1 ])
134
- f .write ("readme_2part.exr" )
133
+ with OpenEXR .File (parts = [P0 , P1 ]) as f :
134
+ f .write ("readme_2part.exr" )
135
135
136
136
with OpenEXR .File ("readme_2part.exr" ) as o :
137
137
assert o .parts [0 ].name () == "Part0"
138
138
assert o .parts [0 ].type () == OpenEXR .scanlineimage
139
- assert o .parts [0 ].width () == 10
140
- assert o .parts [0 ].height () == 20
139
+ assert o .parts [0 ].width () == width
140
+ assert o .parts [0 ].height () == height
141
141
assert np .array_equal (o .parts [0 ].channels ["Z" ].pixels , Z0 )
142
+
142
143
assert o .parts [1 ].name () == "Part1"
143
144
assert o .parts [1 ].type () == OpenEXR .scanlineimage
144
- assert o .parts [1 ].width () == 10
145
- assert o .parts [1 ].height () == 20
145
+ assert o .parts [1 ].width () == width
146
+ assert o .parts [1 ].height () == height
146
147
assert np .array_equal (o .parts [1 ].channels ["Z" ].pixels , Z1 )
147
148
148
149
print ("ok" )
0 commit comments