From: Vivien Maisonneuve Date: Mon, 18 Aug 2014 22:06:00 +0000 (+0200) Subject: Reorder functions in linexprs.py X-Git-Tag: 1.0~62 X-Git-Url: https://scm.cri.mines-paristech.fr/git/linpy.git/commitdiff_plain/09190394388163ef7df51c76bb33077ec8fc0949?ds=sidebyside Reorder functions in linexprs.py --- diff --git a/linpy/linexprs.py b/linpy/linexprs.py index 834c3b4..fce77a6 100644 --- a/linpy/linexprs.py +++ b/linpy/linexprs.py @@ -518,6 +518,21 @@ class Symbol(LinExpr): raise TypeError('expr must be a sympy.Symbol instance') +def symbols(names): + """ + This function returns a tuple of symbols whose names are taken from a comma + or whitespace delimited string, or a sequence of strings. It is useful to + define several symbols at once. + + >>> x, y = symbols('x y') + >>> x, y = symbols('x, y') + >>> x, y = symbols(['x', 'y']) + """ + if isinstance(names, str): + names = names.replace(',', ' ').split() + return tuple(Symbol(name) for name in names) + + class Dummy(Symbol): """ A variation of Symbol in which all symbols are unique and identified by @@ -571,21 +586,6 @@ class Dummy(Symbol): return '$${}_{{{}}}$$'.format(self.name, self._index) -def symbols(names): - """ - This function returns a tuple of symbols whose names are taken from a comma - or whitespace delimited string, or a sequence of strings. It is useful to - define several symbols at once. - - >>> x, y = symbols('x y') - >>> x, y = symbols('x, y') - >>> x, y = symbols(['x', 'y']) - """ - if isinstance(names, str): - names = names.replace(',', ' ').split() - return tuple(Symbol(name) for name in names) - - class Rational(LinExpr, Fraction): """ A particular case of linear expressions are rational values, i.e. linear