I agree with Vinzent. SymPy functions and operations on SymPy types
should return a SymPy type.

Aaron Meurer

On Thu, Aug 11, 2011 at 5:30 PM, Vinzent Steinberg
<[email protected]> wrote:
> On 10 Aug., 16:36, smichr <[email protected]> wrote:
>> A discussion arose inhttps://github.com/sympy/sympy/pull/518which
>> involves modifications to divmod. The question that arose is whether
>> divmod should return Tuple(a, b) or (a, b). This is, in essence, a
>> question of where sympy should end and where python's underlying
>> structures should be left alone.
>>
>> To start things off, I think that any function that is a duplicate of
>> a python function should return the same container but it should be
>> sure to return sympy objects in that container, so divmod(3, 2) -> (1,
>> 1) while divmod(S(3), 2) -> (S(1), S(1)). Also, I think that standard
>> containers should be used unless they appear within an object. So cse
>> returns a list of lists, not a Tuple of Tuples. Returning a sympy
>> container draws attention to the container. It also will start to
>> raise confusion in interactive sessions where, for example, since
>> Tuple looks like tuple, it becomes visually unclear when the output
>> can or can't have a sympy method applied to it:
>>
>>     >>> Tuple(x, 2)
>>     (x, 2)
>>     >>> _.count_ops()
>>     0
>>     >>> (x, 2)
>>     (x, 2)
>>     >>> _.count_ops()
>>     Traceback (most recent call last):
>>       File "<stdin>", line 1, in <module>
>>     AttributeError: 'tuple' object has no attribute 'count_ops'
>>
>> Do you have some ideas or guiding principles for this issue?
>
> I think for low-level code we should not use Tuple. For anything else,
> it probably makes sense to prefer Tuple. Or can you think of a an
> example where we shouldn't?
>
> This would for example include solve().
>
> Vinzent
>
> --
> You received this message because you are subscribed to the Google Groups 
> "sympy" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/sympy?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to