Skip to content

Commit 366d4d3

Browse files
authored
Merge pull request #64 from lookfwd/patch-1
Update 03-anatomy.rst
2 parents 2c2fe32 + 22cffbe commit 366d4d3

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

03-anatomy.rst

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ an index tuple) and more precisely, how to compute the start and end offsets:
111111
.. code:: python
112112
113113
offset_start = 0
114-
for i in range(ndim):
115-
offset_start += strides[i]*index[i]
114+
for i in range(Z.ndim):
115+
offset_start += Z.strides[i] * index[i]
116116
offset_end = offset_start + Z.itemsize
117117
118118
Let's see if this is correct using the `tobytes
@@ -121,13 +121,14 @@ conversion method:
121121

122122
.. code:: python
123123
124-
>>> Z = np.arange(9).reshape(3,3).astype(np.int16)
125-
>>> index = 1,1
124+
>>> Z = np.arange(9).reshape(3, 3).astype(np.int16)
125+
>>> index = 1, 1
126126
>>> print(Z[index].tobytes())
127127
b'\x04\x00'
128-
>>> offset = 0
128+
>>> offset_start = 0
129129
>>> for i in range(Z.ndim):
130-
... offset + = Z.strides[i]*index[i]
130+
... offset_start + = Z.strides[i] * index[i]
131+
>>> offset_end = offset_start + Z.itemsize
131132
>>> print(Z.tobytes()[offset_start:offset_end]
132133
b'\x04\x00'
133134

0 commit comments

Comments
 (0)