From 586cdd1b296a1e76c7c73e695dea3dc67d59987e Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Tue, 4 Dec 2012 18:50:41 -0500 Subject: [PATCH] Add a test for the empty product. Add some backticks. --- mjo/misc.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/mjo/misc.py b/mjo/misc.py index 8f50de3..061a509 100644 --- a/mjo/misc.py +++ b/mjo/misc.py @@ -5,20 +5,22 @@ Stuff that doesn't fit anywhere else. from sage.all import * from functools import reduce + def legend_latex(obj): """ - Return the LaTeX representation of `obj`, but wrap it in dollar + Return the LaTeX representation of ``obj``, but wrap it in dollar ($) signs so that we can pass it directly to plot() et al. as a legend label. """ return '$%s$' % latex(obj) + def product(factors): """ - Returns the product of the elements in the list `factors`. If the - list is empty, we return 1. + Returns the product of the elements in the list ``factors``. If + the list is empty, we return 1. - TESTS: + EXAMPLES: Normal integer multiplication:: @@ -31,5 +33,12 @@ def product(factors): sage: product([x,y,z]) x*y*z + TESTS: + + The empty product is the multiplicative identity (one):: + + sage: product([]) + 1 + """ return reduce(operator.mul, factors, 1) -- 2.43.2