diff options
author | Tyler Reddy <tyler.je.reddy@gmail.com> | 2018-12-05 11:48:11 -0800 |
---|---|---|
committer | Tyler Reddy <tyler.je.reddy@gmail.com> | 2018-12-14 10:14:05 -0800 |
commit | 577a86e30014382c3fed1319379caa8728842543 (patch) | |
tree | 14043b6b19c88dc087e87fba20f9500a331b06db /numpy/core | |
parent | 0bdc587d6cf5e6806e95d9debcafe62ac9f1d7fa (diff) | |
download | numpy-577a86e30014382c3fed1319379caa8728842543.tar.gz |
MAINT: >>> # style cleanups requested
* reviewer requested that the cases where
I switched from free-floating comments to
`>>> # comments` be reverted to free-floating
in docstrings
Diffstat (limited to 'numpy/core')
-rw-r--r-- | numpy/core/_add_newdocs.py | 10 | ||||
-rw-r--r-- | numpy/core/einsumfunc.py | 16 | ||||
-rw-r--r-- | numpy/core/fromnumeric.py | 8 |
3 files changed, 21 insertions, 13 deletions
diff --git a/numpy/core/_add_newdocs.py b/numpy/core/_add_newdocs.py index 60cb62bb5..80fa1466e 100644 --- a/numpy/core/_add_newdocs.py +++ b/numpy/core/_add_newdocs.py @@ -317,8 +317,8 @@ add_newdoc('numpy.core', 'nditer', Examples -------- - >>> #Here is how we might write an ``iter_add`` function, using the - >>> #Python iterator protocol:: + Here is how we might write an ``iter_add`` function, using the + Python iterator protocol:: >>> def iter_add_py(x, y, out=None): ... addop = np.add @@ -329,7 +329,7 @@ add_newdoc('numpy.core', 'nditer', ... addop(a, b, out=c) ... return it.operands[2] - >>> # Here is the same function, but following the C-style pattern:: + Here is the same function, but following the C-style pattern:: >>> def iter_add(x, y, out=None): ... addop = np.add @@ -341,7 +341,7 @@ add_newdoc('numpy.core', 'nditer', ... it.iternext() ... return it.operands[2] - >>> # Here is an example outer product function:: + Here is an example outer product function:: >>> def outer_it(x, y, out=None): ... mulop = np.multiply @@ -361,7 +361,7 @@ add_newdoc('numpy.core', 'nditer', array([[1, 2, 3], [2, 4, 6]]) - >>> # Here is an example function which operates like a "lambda" ufunc:: + Here is an example function which operates like a "lambda" ufunc:: >>> def luf(lamdaexpr, *args, **kwargs): ... '''luf(lambdaexpr, op1, ..., opn, out=None, order='K', casting='safe', buffersize=0)''' diff --git a/numpy/core/einsumfunc.py b/numpy/core/einsumfunc.py index d5fdca785..83b7d8287 100644 --- a/numpy/core/einsumfunc.py +++ b/numpy/core/einsumfunc.py @@ -1324,16 +1324,24 @@ def einsum(*operands, **kwargs): particularly significant with larger arrays: >>> a = np.ones(64).reshape(2,4,8) - >>> # Basic `einsum`: ~1520ms (benchmarked on 3.1GHz Intel i5.) + + Basic `einsum`: ~1520ms (benchmarked on 3.1GHz Intel i5.) + >>> for iteration in range(500): ... _ = np.einsum('ijk,ilm,njm,nlk,abc->',a,a,a,a,a) - >>> # Sub-optimal `einsum` (due to repeated path calculation time): ~330ms + + Sub-optimal `einsum` (due to repeated path calculation time): ~330ms + >>> for iteration in range(500): ... _ = np.einsum('ijk,ilm,njm,nlk,abc->',a,a,a,a,a, optimize='optimal') - >>> # Greedy `einsum` (faster optimal path approximation): ~160ms + + Greedy `einsum` (faster optimal path approximation): ~160ms + >>> for iteration in range(500): ... _ = np.einsum('ijk,ilm,njm,nlk,abc->',a,a,a,a,a, optimize='greedy') - >>> # Optimal `einsum` (best usage pattern in some use cases): ~110ms + + Optimal `einsum` (best usage pattern in some use cases): ~110ms + >>> path = np.einsum_path('ijk,ilm,njm,nlk,abc->',a,a,a,a,a, optimize='optimal')[0] >>> for iteration in range(500): ... _ = np.einsum('ijk,ilm,njm,nlk,abc->',a,a,a,a,a, optimize=path) diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py index 474556b30..240eac6ce 100644 --- a/numpy/core/fromnumeric.py +++ b/numpy/core/fromnumeric.py @@ -1645,7 +1645,7 @@ def ravel(a, order='C'): Examples -------- - >>> # It is equivalent to ``reshape(-1, order=order)``. + It is equivalent to ``reshape(-1, order=order)``. >>> x = np.array([[1, 2, 3], [4, 5, 6]]) >>> np.ravel(x) @@ -1657,15 +1657,15 @@ def ravel(a, order='C'): >>> np.ravel(x, order='F') array([1, 4, 2, 5, 3, 6]) - >>> # When ``order`` is 'A', it will preserve the array's 'C' or 'F' ordering: + When ``order`` is 'A', it will preserve the array's 'C' or 'F' ordering: >>> np.ravel(x.T) array([1, 4, 2, 5, 3, 6]) >>> np.ravel(x.T, order='A') array([1, 2, 3, 4, 5, 6]) - >>> # When ``order`` is 'K', it will preserve orderings that are neither 'C' - >>> # nor 'F', but won't reverse axes: + When ``order`` is 'K', it will preserve orderings that are neither 'C' + nor 'F', but won't reverse axes: >>> a = np.arange(3)[::-1]; a array([2, 1, 0]) |