Skip to content

Commit 9b06226

Browse files
Merge pull request #325 from wmvanvliet/numpy-reorder
Reorder some sentences in the NumPy introduction
2 parents 7577d05 + aa44774 commit 9b06226

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

content/numpy.rst

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,31 +20,33 @@ NumPy
2020
exercises at the end in that case.
2121

2222

23-
24-
So, we already know about python lists, and that we can put all kinds of things in there.
25-
But in scientific usage, lists are often not enough. They are slow and
26-
not very flexible.
23+
NumPy is the most used library for scientific computing.
24+
Even if you are not using it directly, chances are high that some library uses it in the background.
25+
NumPy provides the high-performance multidimensional array object and tools to use it.
2726

2827
.. highlight:: python
2928

3029
What is an array?
3130
-----------------
3231

33-
For example, consider ``[1, 2.5, 'asdf', False, [1.5, True]]`` -
34-
this is a Python list but it has different types for every
35-
element. When you do math on this, every element has to be handled separately.
36-
37-
NumPy is the most used library for scientific computing.
38-
Even if you are not using it directly, chances are high that some library uses it in the background.
39-
NumPy provides the high-performance multidimensional array object and tools to use it.
40-
41-
An array is a 'grid' of values, with all the same types. It is indexed by tuples of
32+
So, we already know about python lists, and that we can put different types of
33+
data in the same list. For example, consider
34+
``[1, 2.5, 'asdf', False, [1.5, True]]``.
35+
This is a Python list but it has different types for every element.
36+
This makes them very flexible, but this comes at a cost: if we want to do
37+
something to each element in the list, for example "add 1", we need to consider
38+
each element one-by-one, because "add 1" means something different if the item
39+
is a number then when it is a string, or a sub-list. In scientific usage, we
40+
want to be able to quickly perform operations on large groups of elements at
41+
once, which is what NumPy arrays are optimized for.
42+
43+
An array is a 'grid' of values, with all the same type. It is indexed by tuples of
4244
non negative indices and provides the framework for multiple
4345
dimensions. An array has:
4446

4547
* :ref:`dtype <arrays.dtypes>` - data type. Arrays always contain one type
4648
* :term:`shape` - shape of the data, for example ``3×2`` or ``3×2×500`` or even
47-
``500`` (one dimensional) or ``[]`` (zero dimensional).
49+
``500`` (one dimensional) or ``()`` (zero dimensional).
4850
* :attr:`data <numpy.ndarray.data>` - raw data storage in memory. This can be passed to C or
4951
Fortran code for efficient calculations.
5052

0 commit comments

Comments
 (0)