Skip to content

Commit d62e838

Browse files
committed
Using as_type instead of af.cast in examples
1 parent 7deb63c commit d62e838

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

examples/graphics/conway.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
kernel = af.Array(h_kernel, dims=(3,3))
3939

4040
# Generate the initial state with 0s and 1s
41-
state = af.cast(af.randu(game_h, game_w) > 0.4, af.Dtype.f32)
41+
state = (af.randu(game_h, game_w) > 0.4).as_type(af.Dtype.f32)
4242

4343
# tile 3 times to display color
4444
display = af.tile(state, 1, 1, 3, 1)
@@ -50,7 +50,7 @@
5050

5151
frame_count += 1
5252
if (frame_count % reset == 0):
53-
state = af.cast(af.randu(game_h, game_w) > 0.4, af.Dtype.f32)
53+
state = (af.randu(game_h, game_w) > 0.4).as_type(af.Dtype.f32)
5454

5555
neighborhood = af.convolve(state, kernel)
5656

@@ -66,7 +66,7 @@
6666
A2 = (state == 0) & C1
6767
A3 = (state == 1) & (neighborhood > 3)
6868

69-
display = af.cast(af.join(2, A0 + A1, A1 + A2, A3), af.Dtype.f32)
69+
display = (af.join(2, A0 + A1, A1 + A2, A3).as_type(af.Dtype.f32)
7070

7171
state = state * C0 + C1
7272

examples/graphics/fractal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def mandelbrot(data, it, maxval):
3131
Z = Z * Z + C
3232

3333
# Get indices where abs(Z) crosses maxval
34-
cond = af.cast((af.abs(Z) > maxval), af.Dtype.f32)
34+
cond = ((af.abs(Z) > maxval)).as_type(af.Dtype.f32)
3535
mag = af.maxof(mag, cond * ii)
3636

3737
C = C * (1 - cond)

examples/graphics/histogram.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
hist_win = af.Window(512, 512, "3D Plot example using ArrayFire")
3030
img_win = af.Window(480, 640, "Input Image")
3131

32-
img = af.cast(af.load_image(sys.argv[1]), af.Dtype.u8)
32+
img = (af.load_image(sys.argv[1])).(af.Dtype.u8)
3333
hist = af.histogram(img, 256, 0, 255)
3434

3535
while (not hist_win.close()) and (not img_win.close()):

0 commit comments

Comments
 (0)