diff options
author | Matti Picus <matti.picus@gmail.com> | 2018-06-25 17:22:14 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-25 17:22:14 -0700 |
commit | 65f15a5e881817d8646571d36ab9a0bc39a6667e (patch) | |
tree | 30ef993f2d9cb74e9cb1e12463d5cec992991c56 /numpy | |
parent | d262c78a3132de42b1813d7f713acc6f92323c1f (diff) | |
parent | 06b2b718835661132ba45ddb336ea720919d0b61 (diff) | |
download | numpy-65f15a5e881817d8646571d36ab9a0bc39a6667e.tar.gz |
Merge pull request #11335 from pvanmulbregt/stride123
DOC: Change array lengths/entries in broadcast_arrays example to reduce confusion.
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/lib/stride_tricks.py | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/numpy/lib/stride_tricks.py b/numpy/lib/stride_tricks.py index 2abe5cdd1..bc5993802 100644 --- a/numpy/lib/stride_tricks.py +++ b/numpy/lib/stride_tricks.py @@ -219,23 +219,19 @@ def broadcast_arrays(*args, **kwargs): Examples -------- >>> x = np.array([[1,2,3]]) - >>> y = np.array([[1],[2],[3]]) + >>> y = np.array([[4],[5]]) >>> np.broadcast_arrays(x, y) [array([[1, 2, 3], - [1, 2, 3], - [1, 2, 3]]), array([[1, 1, 1], - [2, 2, 2], - [3, 3, 3]])] + [1, 2, 3]]), array([[4, 4, 4], + [5, 5, 5]])] Here is a useful idiom for getting contiguous copies instead of non-contiguous views. >>> [np.array(a) for a in np.broadcast_arrays(x, y)] [array([[1, 2, 3], - [1, 2, 3], - [1, 2, 3]]), array([[1, 1, 1], - [2, 2, 2], - [3, 3, 3]])] + [1, 2, 3]]), array([[4, 4, 4], + [5, 5, 5]])] """ # nditer is not used here to avoid the limit of 32 arrays. |