to consider concrete examplesay we want to plot the heaviside functiondefined by ( > following the ideas from python implementation of this function could look like this def ( )if return elsereturn now we want to plot the function using the simple approach introduced above it is natural to simply create an array of values xand to pass this array to the function (xto compute the corresponding -valuesx linspace(- (xplot(xyfew points (simple curvehoweverif we try to run this codewe obtain an error messagea valueerror error inside the function ( )coming from the if line we can illustrate what goes wrong in an interactive python sessionx linspace(- , , array([- - ] array(truetruefalsefalsefalse]dtype=boolbool(bevaluate in boolean context valueerrorthe truth value of an array with more than one element is ambiguous use any(or all(we see here that the result of the statement is an array of boolean valueswhereasif were single numberthe result would be single boolean (true/falsethereforethe statement bool( )or tests such as if or if do not make sensesince it is impossible to say whether an array of multiple true/false values is true or false there are several ways to fix this problem one is to avoid the vectorization altogetherand return to the traditional for loop for computing the valuesimport numpy as np import matplotlib pyplot as plt np linspace(- + np zeros( + for in range(len( )) [ih( [ ]