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

Redraw and cleanup python function layout figure #573

Merged
merged 3 commits into from
Sep 6, 2018
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
12 changes: 5 additions & 7 deletions _episodes/06-func.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ def fahr_to_celsius(temp):

![The Blueprint for a Python Function](../fig/python-function.svg)

<!--- see https://gist.github.com/wd15/2b4ffbe5ce0d0ddb8a5b to
regenerate the above figure --->

The function definition opens with the keyword `def` followed by the
name of the function (`fahr_to_celsius`) and a parenthesized list of parameter names (`temp`). The
Expand Down Expand Up @@ -266,9 +264,9 @@ but there are a few simple tests that will reassure us:
~~~
print('original min, mean, and max are:', numpy.min(data), numpy.mean(data), numpy.max(data))
offset_data = offset_mean(data, 0)
print('min, mean, and max of offset data are:',
numpy.min(offset_data),
numpy.mean(offset_data),
print('min, mean, and max of offset data are:',
numpy.min(offset_data),
numpy.mean(offset_data),
numpy.max(offset_data))
~~~
{: .language-python}
Expand Down Expand Up @@ -301,7 +299,7 @@ but we probably wouldn't notice if they were different in the sixth decimal plac
Let's do this instead:

~~~
print('difference in standard deviations before and after:',
print('difference in standard deviations before and after:',
numpy.std(data) - numpy.std(offset_data))
~~~
{: .language-python}
Expand All @@ -323,7 +321,7 @@ The usual way to put documentation in software is
to add [comments]({{ page.root }}/reference/#comment) like this:

~~~
# offset_mean(data, target_mean_value):
# offset_mean(data, target_mean_value):
# return a new array containing the original data with its mean offset to match the desired value.
def offset_mean(data, target_mean_value):
return (data - numpy.mean(data)) + target_mean_value
Expand Down
26 changes: 24 additions & 2 deletions fig/python-function.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.