Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Python
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Package Registry
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
swc-bb
S
swc-lessons
2020-04-20-Potsdam-Berlin
Python
Commits
af502576
Commit
af502576
authored
Aug 01, 2019
by
Thomas Etherington
Committed by
Maxim Belkin
Jul 31, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
01-numpy.md: move note on importing numpy as np (#688)
parent
67b571c1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
14 deletions
+15
-14
_episodes/01-numpy.md
_episodes/01-numpy.md
+15
-14
No files found.
_episodes/01-numpy.md
View file @
af502576
...
...
@@ -218,8 +218,21 @@ Importing a library is like getting a piece of lab equipment out of a storage lo
up on the bench. Libraries provide additional functionality to the basic Python package, much like
a new piece of equipment adds functionality to a lab space. Just like in the lab, importing too
many libraries can sometimes complicate and slow down your programs - so we only import what we
need for each program. Once we've imported the library, we can ask the library to read our data
file for us:
need for each program.
> ## Scientists Dislike Typing
>
> We will always use the syntax `import numpy` to import NumPy.
> However, in order to save typing, it is
> [often suggested](http://www.scipy.org/getting-started.html#an-example-script)
> to make a shortcut like so: `import numpy as np`.
> If you ever see Python code online using a NumPy function with `np`
> (for example, `np.loadtxt(...)`), it's because they've used this shortcut.
> When working with other people, it is important to agree on a convention of how common libraries
> are imported.
{: .callout}
Once we've imported the library, we can ask the library to read our data file for us:
~~~
numpy.loadtxt(fname='inflammation-01.csv', delimiter=',')
...
...
@@ -834,18 +847,6 @@ and that we want a tight layout.
(If we leave out that call to
`fig.tight_layout()`
,
the graphs will actually be squeezed together more closely.)
> ## Scientists Dislike Typing
>
> We will always use the syntax `import numpy` to import NumPy.
> However, in order to save typing, it is
> [often suggested](http://www.scipy.org/getting-started.html#an-example-script)
> to make a shortcut like so: `import numpy as np`.
> If you ever see Python code online using a NumPy function with `np`
> (for example, `np.loadtxt(...)`), it's because they've used this shortcut.
> When working with other people, it is important to agree on a convention of how common libraries
> are imported.
{: .callout}
> ## Check Your Understanding
>
> What values do the variables `mass` and `age` have after each statement in the following program?
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment