Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert some docs with **Example** to Markdown #13102

Merged
merged 1 commit into from
Sep 13, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 24 additions & 29 deletions base/docs/helpdb.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1398,22 +1398,20 @@ Determine a type big enough to hold values of each argument type without loss, w
promote_type

doc"""
```rst
.. ind2sub(dims, index) -> subscripts
ind2sub(dims, index) -> subscripts

Returns a tuple of subscripts into an array with dimensions ``dims``, corresponding to the linear index ``index``
Returns a tuple of subscripts into an array with dimensions `dims`,
corresponding to the linear index `index`.

**Example** ``i, j, ... = ind2sub(size(A), indmax(A))`` provides the indices of the maximum element
```
**Example**: `i, j, ... = ind2sub(size(A), indmax(A))` provides the
indices of the maximum element
"""
ind2sub(dims::Tuple, index::Int)

doc"""
```rst
.. ind2sub(a, index) -> subscripts
ind2sub(a, index) -> subscripts

Returns a tuple of subscripts into array ``a`` corresponding to the linear index ``index``
```
Returns a tuple of subscripts into array `a` corresponding to the linear index `index`
"""
ind2sub(a, index)

Expand Down Expand Up @@ -2888,13 +2886,12 @@ Alternate syntax for open, where a string-based mode specifier is used instead o
open(file_name, mode="r")

doc"""
```rst
.. open(f::Function, args...)
open(f::Function, args...)

Apply the function ``f`` to the result of ``open(args...)`` and close the resulting file descriptor upon completion.
Apply the function `f` to the result of `open(args...)`
and close the resulting file descriptor upon completion.

**Example**: ``open(readall, "file.txt")``
```
**Example**: `open(readall, "file.txt")`
"""
open(f::Function, args...)

Expand Down Expand Up @@ -8064,30 +8061,28 @@ Join an array of `strings` into a single string, inserting the given delimiter b
join

doc"""
```rst
.. linreg(x, y) -> [a; b]
linreg(x, y) -> a, b

Linear Regression. Returns ``a`` and ``b`` such that ``a+b*x`` is the closest line to the given points ``(x,y)``. In other words, this function determines parameters ``[a, b]`` that minimize the squared error between ``y`` and ``a+b*x``.

**Example**::

using PyPlot;
x = float([1:12])
y = [5.5; 6.3; 7.6; 8.8; 10.9; 11.79; 13.48; 15.02; 17.77; 20.81; 22.0; 22.99]
a, b = linreg(x,y) # Linear regression
plot(x, y, "o") # Plot (x,y) points
plot(x, [a+b*i for i in x]) # Plot the line determined by the linear regression
Perform linear regression. Returns `a` and `b` such that `a + b*x` is the closest
straight line to the given points `(x, y)`, i.e., such that the squared error
between `y` and `a + b*x` is minimized.

**Example**:
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't you need to put the language here? ```julia

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, good point, thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, actually, I don't -- the output in the ReST already magically says code-julia.. code-block:: julia.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

using PyPlot
x = [1.0:12.0;]
y = [5.5, 6.3, 7.6, 8.8, 10.9, 11.79, 13.48, 15.02, 17.77, 20.81, 22.0, 22.99]
a, b = linreg(x, y) # Linear regression
plot(x, y, "o") # Plot (x, y) points
plot(x, [a+b*i for i in x]) # Plot line determined by linear regression
```
"""
linreg(x,y)

doc"""
```rst
.. linreg(x, y, w)
linreg(x, y, w)

Weighted least-squares linear regression.
```
"""
linreg(x,y,w)

Expand Down
4 changes: 2 additions & 2 deletions doc/stdlib/arrays.rst
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ Basic functions

.. Docstring generated from Julia source

Returns a tuple of subscripts into an array with dimensions ``dims``, corresponding to the linear index ``index``
Returns a tuple of subscripts into an array with dimensions ``dims``\ , corresponding to the linear index ``index``\ .

**Example** ``i, j, ... = ind2sub(size(A), indmax(A))`` provides the indices of the maximum element
**Example**: ``i, j, ... = ind2sub(size(A), indmax(A))`` provides the indices of the maximum element

.. function:: ind2sub(a, index) -> subscripts

Expand Down
19 changes: 10 additions & 9 deletions doc/stdlib/linalg.rst
Original file line number Diff line number Diff line change
Expand Up @@ -754,21 +754,22 @@ Linear algebra functions in Julia are largely implemented by calling functions f

Concatenate matrices block-diagonally. Currently only implemented for sparse matrices.

.. function:: linreg(x, y) -> [a; b]
.. function:: linreg(x, y) -> a, b

.. Docstring generated from Julia source

Linear Regression. Returns ``a`` and ``b`` such that ``a+b*x`` is the closest line to the given points ``(x,y)``. In other words, this function determines parameters ``[a, b]`` that minimize the squared error between ``y`` and ``a+b*x``.
Perform linear regression. Returns ``a`` and ``b`` such that ``a + b*x`` is the closest straight line to the given points ``(x, y)``\ , i.e., such that the squared error between ``y`` and ``a + b*x`` is minimized.

**Example**::
**Example**:

using PyPlot;
x = float([1:12])
y = [5.5; 6.3; 7.6; 8.8; 10.9; 11.79; 13.48; 15.02; 17.77; 20.81; 22.0; 22.99]
a, b = linreg(x,y) # Linear regression
plot(x, y, "o") # Plot (x,y) points
plot(x, [a+b*i for i in x]) # Plot the line determined by the linear regression
.. code-block:: julia

using PyPlot
x = [1.0:12.0;]
y = [5.5, 6.3, 7.6, 8.8, 10.9, 11.79, 13.48, 15.02, 17.77, 20.81, 22.0, 22.99]
a, b = linreg(x, y) # Linear regression
plot(x, y, "o") # Plot (x, y) points
plot(x, [a+b*i for i in x]) # Plot line determined by linear regression

.. function:: linreg(x, y, w)

Expand Down