1 // array_iter_usage.pycmd
3 // Copyright (c) 2014 - Michele De Stefano (micdestefano@users.sourceforge.net)
5 // Distributed under the MIT License (See accompanying file LICENSE)
9 * \example array_iter_usage.pycmd
11 * Shows the usage of the array_iter_usage extension from the Python prompt.
14 mds_utils::python::numpy::NDArrayIterator usage example from the Python prompt:
16 >>> import numpy as np
17 >>> import array_iter_usage as au
18 >>> a = np.array([[1.1,2.2,3.3],[4.4,5.5,6.6]])
20 array([[ 1.1, 2.2, 3.3],
22 >>> au.print_array_elements(a)
37 >>> au.modify_array_elements(a)
39 array([[ 7. , 2.2, 3.3],
41 >>> au.print_int_elements(a)
52 array([[ 1.1, 2.2, 3.3],
54 >>> au.modify_int_elements(a)
56 array([[ 10., 11., 3.],
58 >>> ca = np.array([[1.1,2.2,3.3],[4.4,5.5,6.6]])*(1.+1.j)
60 array([[ 1.1+1.1j, 2.2+2.2j, 3.3+3.3j],
61 [ 4.4+4.4j, 5.5+5.5j, 6.6+6.6j]])
62 >>> au.print_fcplx_elements(ca)
72 >>> au.modify_fcplx_elements(ca)
74 array([[ 1.10000002 +1.10000002j, 2.20000005 +2.20000005j,
75 10.10000038+30.10000038j],
76 [ 14.80000019 +9.69999981j, 5.50000000 +5.5j ,
77 6.59999990 +6.5999999j ]])