Errata

SciPy and NumPy

Errata for SciPy and NumPy

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
CH2
end of section 2.1.3 INDEXING AND SLICING

The example

# Source code available: numpy_213_ex1.py
index = arr > 2
print(index)
[False False True True True]

differs from actual code result
[False False False True True]
and contradicts the surrounding text.

That is, the first three elements should be false as all are 'not greater than 2'.

>>> arr = np.arange(5)
>>> print(arr)
[0 1 2 3 4]

>>> index = np.where(arr > 2)
>>> print(index)
(array([3, 4]),)

>>> new_arr = arr[index]
>>> print(new_arr)
[3 4]

>>> index = arr > 2
>>> print(index)
[False False False True True]

Kelly Brant  Jan 12, 2017 
Printed Page 7
Main text paragraph on page 7

The statement "When generating arrays, NumPy will default to the bit depth of the Python environment" is not correct.
For a 32-bit system, the default floating point type is float64. (The default integer type IS 32-bit.)
A simple script illustrates this:

import sys
import numpy as np
print(sys.version)
a = np.zeros(5)
b = np.array([1, 2, 3])
print(a.dtype, b.dtype)

The output on a 64-bit Windows OS, with a 32-bit Python environment is:

2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)]
(dtype('float64'), dtype('int32'))

The main NumPy documentation also states that float64 is the default float type.

Adrian Hill  Jan 24, 2014 
Printed Page 7
One third down page from top

The last parameter to np.linspace is the number of points in the array, not the number of steps.
For example,
arr = np.linspace(0, 1, 3)
produces an array with 3 values but only two steps between the three values.
In general, there are (n - 1) equal-size steps between n values.

Adrian Hill  Jan 24, 2014 
PDF Page 9
last code spippet

# Accessing the columns is achieved in the same way
should be
# Accessing the rows is achieved in the same way

Anonymous  Jul 21, 2017 
Mobi Page 10
Code example (chapter 2.1)

The non-numpy part of example can be more concise and more pythonic than this one with additional list_times function. This example is also equivalent in functionality to numpy example.(list_times will modify original array, while arr * 1.1 will return a new one). It is also some 30-40% faster.

In [8]: timeit [a * 1.1 for a in larr]
1 loops, best of 3: 890 ms per loop

In [9]: timeit list_times(larr, 1.1)
1 loops, best of 3: 1.44 s per loop

In [10]: timeit arr * 1.1
10 loops, best of 3: 45.6 ms per loop

(There is matching pull request for this example source)

Mirko Bulaja  Jul 25, 2014 
Printed Page 20
code : x = np.linalg.inv(a).dot(b)

x = np.linealg.inv(a).dot(b) #Incorrect since there's no method called dot in numpy array.

x = np.dot(np.linalg.inv(a),b) #Correct, since dot is an explicit method of numpy and takes two arguments. Note: dot does matrix multiplication for 2-D arrays.

gaurav singh  Oct 19, 2013 
PDF Page 35
in the for loop: for i in xrange(cnumber - 1)

orange is not defined, so the code will not run.

Lee Creighton  Jul 02, 2017