[python-arrayfire] 157/250: Fixing bug in surface. Also adding relevant example.

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Mon Mar 28 22:59:44 UTC 2016


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch debian/master
in repository python-arrayfire.

commit 940d879d861c80b17d9bc49ce19d7982139484cf
Author: Pavan Yalamanchili <pavan at arrayfire.com>
Date:   Wed Dec 9 13:57:18 2015 -0500

    Fixing bug in surface. Also adding relevant example.
---
 arrayfire/graphics.py        | 10 +++++-----
 examples/graphics/surface.py | 29 +++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 5 deletions(-)

diff --git a/arrayfire/graphics.py b/arrayfire/graphics.py
index 5a84895..b1b4f82 100644
--- a/arrayfire/graphics.py
+++ b/arrayfire/graphics.py
@@ -175,28 +175,28 @@ class Window(object):
         _cell = _Cell(self._r, self._c, title, self._cmap)
         safe_call(backend.get().af_draw_plot3(self._wnd, line.arr, ct.pointer(_cell)))
 
-    def surface(self, z_vals, x_vals, y_vals, title=None):
+    def surface(self, x_vals, y_vals, z_vals, title=None):
         """
         Renders the input array as a 3D surface plot.
 
         Paramters
         ---------
 
-        z_vals: af.Array.
-             A 1 dimensional array containing Z co-ordinates.
-
         x_vals: af.Array.
              A 1 dimensional array containing X co-ordinates.
 
         y_vals: af.Array.
              A 1 dimensional array containing Y co-ordinates.
 
+        z_vals: af.Array.
+             A 1 dimensional array containing Z co-ordinates.
+
         title: str.
              Title used for the plot.
         """
         _cell = _Cell(self._r, self._c, title, self._cmap)
         safe_call(backend.get().af_draw_surface(self._wnd,
-                                                z_vals.arr, x_vals.arr, y_vals.arr,
+                                                x_vals.arr, y_vals.arr, z_vals.arr,
                                                 ct.pointer(_cell)))
 
     def hist(self, X, min_val, max_val, title=None):
diff --git a/examples/graphics/surface.py b/examples/graphics/surface.py
new file mode 100644
index 0000000..30ea119
--- /dev/null
+++ b/examples/graphics/surface.py
@@ -0,0 +1,29 @@
+#!/usr/bin/python
+
+#######################################################
+# Copyright (c) 2015, ArrayFire
+# All rights reserved.
+#
+# This file is distributed under 3-clause BSD license.
+# The complete license agreement can be obtained at:
+# http://arrayfire.com/licenses/BSD-3-Clause
+########################################################
+
+import arrayfire as af
+import math
+
+af.info()
+
+POINTS = 30
+N = 2 * POINTS
+
+x = (af.iota(d0 = N, d1 = 1, tile_dims = (1, N)) - POINTS) / POINTS
+y = (af.iota(d0 = 1, d1 = N, tile_dims = (N, 1)) - POINTS) / POINTS
+
+win = af.Window(800, 800, "3D Surface example using ArrayFire")
+
+t = 0
+while not win.close():
+    t = t + 0.07
+    z = 10*x*-af.abs(y) * af.cos(x*x*(y+t))+af.sin(y*(x+t))-1.5;
+    win.surface(x, y, z)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/python-arrayfire.git



More information about the debian-science-commits mailing list