Skip to content

Commit 6f2ce0f

Browse files
committed
Fix doctests for the Interfaces chapter
[ci skip]
1 parent 721bdbe commit 6f2ce0f

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

doc/manual/interfaces.rst

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,12 @@ With only those definitions, the ``Squares`` type is already pretty powerful. We
6464
36
6565
49
6666

67-
We can compute the sum of all squares up to a certain number:
67+
We can use many of the builtin methods that work with iterables, like :func:`in`, :func:`mean` and :func:`std`:
6868

6969
.. doctest::
7070

71-
julia> sum(Squares(1803))
72-
1955361914
73-
74-
Or even the mean and standard deviation:
75-
76-
.. doctest::
71+
julia> 25 in Squares(10)
72+
true
7773

7874
julia> mean(Squares(100)), std(Squares(100))
7975
(3383.5,3024.355854282583)
@@ -233,7 +229,7 @@ As a more complicated example, let's define our own toy N-dimensional sparse-lik
233229

234230
julia> Base.size(A::SparseArray) = A.dims
235231
Base.similar{T}(A::SparseArray, ::Type{T}, dims::Dims) = SparseArray(T, dims)
236-
# Define scalar indexing and indexed assignment up to 3-dimensions
232+
# Define scalar indexing and indexed assignment for up to 3 dimensions
237233
Base.getindex{T}(A::SparseArray{T,1}, i1::Int) = get(A.data, (i1,), zero(T))
238234
Base.getindex{T}(A::SparseArray{T,2}, i1::Int, i2::Int) = get(A.data, (i1,i2), zero(T))
239235
Base.getindex{T}(A::SparseArray{T,3}, i1::Int, i2::Int, i3::Int) = get(A.data, (i1,i2,i3), zero(T))
@@ -272,7 +268,7 @@ Since the ``SparseArray`` is mutable, we were able to override :func:`similar`.
272268
1.0 4.0 7.0
273269
2.0 5.0 8.0
274270

275-
And now, in addition to all the iterable and indexable methods from above, these types can interact with each other and use all the methods defined in the standard library for ``AbstractArrays``:
271+
In addition to all the iterable and indexable methods from above, these types can also interact with each other and use all of the methods defined in the standard library for ``AbstractArrays``:
276272

277273
.. doctest::
278274

0 commit comments

Comments
 (0)