October 2014
Beginner to intermediate
348 pages
6h 55m
English
NumPy attempts to execute a procedure even though the operands do not have the same shape.
In this recipe, we will multiply an array and a scalar. The scalar is broadened to the shape of the array operand and then the multiplication is executed. The process described here is called
broadcasting. The following is the entire code for this recipe (refer to broadcasting.py in this book's code bundle):
import scipy.io.wavfile import matplotlib.pyplot as plt import urllib2 import numpy as np response = urllib2.urlopen('http://www.thesoundarchive.com/austinpowers/smashingbaby.wav') print response.info() WAV_FILE = 'smashingbaby.wav' filehandle = open(WAV_FILE, 'w') filehandle.write(response.read()) filehandle.close() sample_rate, ...Read now
Unlock full access