(y, ynew)
return (list(zip(abs_dlist, rel_dlist)),
            (da_avg, max(abs_dlist)), (dr_avg, max(rel_dlist))
            )
returns average and maximum relative and
       absolute differences between y and ynew
       result may contain None values for y = 0
       return value - tuple:
       [(abs dif, rel dif) * len(y)],
       (abs average, abs max),
       (rel average, rel max)
returns average and maximum relative and
       absolute differences between y and ynew
       result may contain None values for y = 0
       return value - tuple:
       [(abs dif, rel dif) * len(y)],
       (abs average, abs max),
       (rel average, rel max)
returns average and maximum relative and absolute differences between y and ynew result may contain None values for y = 0 return value - tuple : [ ( abs dif rel dif ) * len ( y ) ] ( abs average abs max ) ( rel average rel max )
def difference(y, ynew):
    """returns average and maximum relative and
       absolute differences between y and ynew
       result may contain None values for y = 0
       return value - tuple:
       [(abs dif, rel dif) * len(y)],
       (abs average, abs max),
       (rel average, rel max)"""

    abs_dlist = []
    rel_dlist = []

    for y1, y2 in zip(y, ynew):
        # absolute
        abs_dlist.append(y1 - y2)

        if y1 > 1E-6:
            rel_dlist.append(abs(abs_dlist[-1] / y1))
        else:
            raise ZeroDivisionError("{0!r} is too small".format(y1))

    da_avg = sum(abs_dlist) / len(abs_dlist)
    dr_avg = sum(rel_dlist) / len(rel_dlist)

    return (list(zip(abs_dlist, rel_dlist)),
            (da_avg, max(abs_dlist)), (dr_avg, max(rel_dlist))
            )
def difference ( y , ynew ) : abs_dlist = [ ] rel_dlist = [ ] for y1 , y2 in zip ( y , ynew ) : # absolute abs_dlist . append ( y1 - y2 ) if y1 > 1E-6 : rel_dlist . append ( abs ( abs_dlist [ - 1 ] / y1 ) ) else : raise ZeroDivisionError ( "{0!r} is too small" . format ( y1 ) ) da_avg = sum ( abs_dlist ) / len ( abs_dlist ) dr_avg = sum ( rel_dlist ) / len ( rel_dlist ) return ( list ( zip ( abs_dlist , rel_dlist ) ) , ( da_avg , max ( abs_dlist ) ) , ( dr_avg , max ( rel_dlist ) ) )