details: http://hg.sympy.org/sympy/rev/25d56fd9568e changeset: 1840:25d56fd9568e user: Andy R. Terrel <[EMAIL PROTECTED]> date: Sun Oct 19 21:55:26 2008 +0200 description: Issue 883, a rework of the patch submitted by Boris Timokhin <[EMAIL PROTECTED]>: - Removes sympify_lists keyword for sympify - Removes conversion of lists and tuples of length 2 to Intervals - Adds tests for sympify of lists, tuples, and set
diffs (74 lines): diff -r 6422f5d608d2 -r 25d56fd9568e sympy/core/interval.py --- a/sympy/core/interval.py Sun Oct 19 21:41:36 2008 +0200 +++ b/sympy/core/interval.py Sun Oct 19 21:55:26 2008 +0200 @@ -16,8 +16,3 @@ @property def end(self): return self._args[1] - -# /cyclic/ -import sympify as _ -_.Interval = Interval -del _ diff -r 6422f5d608d2 -r 25d56fd9568e sympy/core/sympify.py --- a/sympy/core/sympify.py Sun Oct 19 21:41:36 2008 +0200 +++ b/sympy/core/sympify.py Sun Oct 19 21:55:26 2008 +0200 @@ -1,7 +1,6 @@ """sympify -- convert objects SymPy internal format""" # from basic import Basic, BasicType, S # from numbers import Integer, Real -# from interval import Interval import decimal class SympifyError(ValueError): @@ -15,7 +14,7 @@ return "Sympify of expression '%s' failed, because of exception being raised:\n%s: %s" % (self.expr, self.base_exc.__class__.__name__, str(self.base_exc)) -def sympify(a, sympify_lists=False, locals= {}): +def sympify(a, locals= {}): """Converts an arbitrary expression to a type that can be used inside sympy. For example, it will convert python int's into instance of sympy.Rational, floats into intances of sympy.Real, @@ -73,11 +72,8 @@ return real + S.ImaginaryUnit * imag elif isinstance(a, bool): raise NotImplementedError("bool support") - elif (a.__class__ in [list,tuple]) and len(a) == 2: - # isinstance causes problems in the issue #432, so we use .__class__ - return Interval(*a) - elif isinstance(a, (list,tuple,set)) and sympify_lists: - return type(a)([sympify(x, True) for x in a]) + elif isinstance(a, (list,tuple,set)): + return type(a)([sympify(x) for x in a]) # let's see if 'a' implements conversion methods such as '_sympy_' or # '__int__', that returns a SymPy (by definition) or SymPy compatible diff -r 6422f5d608d2 -r 25d56fd9568e sympy/core/tests/test_sympify.py --- a/sympy/core/tests/test_sympify.py Sun Oct 19 21:41:36 2008 +0200 +++ b/sympy/core/tests/test_sympify.py Sun Oct 19 21:55:26 2008 +0200 @@ -234,6 +234,12 @@ assert a == Integer(4) assert a.is_Integer +def test_issue883(): + a = [3,2.0] + assert sympify(a) == [Integer(3), Real(2.0)] + assert sympify(tuple(a)) == (Integer(3), Real(2.0)) + assert sympify(set(a)) == set([Integer(3), Real(2.0)]) + def test_S_sympify(): assert S(1)/2 == sympify(1)/2 assert (-2)**(S(1)/2) == sqrt(2)*I diff -r 6422f5d608d2 -r 25d56fd9568e sympy/integrals/integrals.py --- a/sympy/integrals/integrals.py Sun Oct 19 21:41:36 2008 +0200 +++ b/sympy/integrals/integrals.py Sun Oct 19 21:55:26 2008 +0200 @@ -388,7 +388,7 @@ thoroughly the strategy that SymPy uses for integration. """ - new_args = [sympify(arg, sympify_lists=True) for arg in args] + new_args = [sympify(arg) for arg in args] integral = Integral(*new_args, **kwargs) if isinstance(integral, Integral): --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy-commits" group. To post to this group, send email to sympy-commits@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sympy-commits?hl=en -~----------~----~----~----~------~----~------~--~---