summaryrefslogtreecommitdiff
path: root/docs/examples/userguide/numpy_tutorial/compute_py.py
diff options
context:
space:
mode:
Diffstat (limited to 'docs/examples/userguide/numpy_tutorial/compute_py.py')
-rw-r--r--docs/examples/userguide/numpy_tutorial/compute_py.py56
1 files changed, 28 insertions, 28 deletions
diff --git a/docs/examples/userguide/numpy_tutorial/compute_py.py b/docs/examples/userguide/numpy_tutorial/compute_py.py
index 00bcf244c..4a5f90b4d 100644
--- a/docs/examples/userguide/numpy_tutorial/compute_py.py
+++ b/docs/examples/userguide/numpy_tutorial/compute_py.py
@@ -1,28 +1,28 @@
-import numpy as np
-
-
-def clip(a, min_value, max_value):
- return min(max(a, min_value), max_value)
-
-
-def compute(array_1, array_2, a, b, c):
- """
- This function must implement the formula
- np.clip(array_1, 2, 10) * a + array_2 * b + c
-
- array_1 and array_2 are 2D.
- """
- x_max = array_1.shape[0]
- y_max = array_1.shape[1]
-
- assert array_1.shape == array_2.shape
-
- result = np.zeros((x_max, y_max), dtype=array_1.dtype)
-
- for x in range(x_max):
- for y in range(y_max):
- tmp = clip(array_1[x, y], 2, 10)
- tmp = tmp * a + array_2[x, y] * b
- result[x, y] = tmp + c
-
- return result
+import numpy as np
+
+
+def clip(a, min_value, max_value):
+ return min(max(a, min_value), max_value)
+
+
+def compute(array_1, array_2, a, b, c):
+ """
+ This function must implement the formula
+ np.clip(array_1, 2, 10) * a + array_2 * b + c
+
+ array_1 and array_2 are 2D.
+ """
+ x_max = array_1.shape[0]
+ y_max = array_1.shape[1]
+
+ assert array_1.shape == array_2.shape
+
+ result = np.zeros((x_max, y_max), dtype=array_1.dtype)
+
+ for x in range(x_max):
+ for y in range(y_max):
+ tmp = clip(array_1[x, y], 2, 10)
+ tmp = tmp * a + array_2[x, y] * b
+ result[x, y] = tmp + c
+
+ return result