On 13 August 2015 at 15:58, Jori Mäntysalo <jori.mantys...@uta.fi> wrote:

> On Thu, 13 Aug 2015, Nathann Cohen wrote:
>
> All Sage methods that return integers should return Sage integer elements.
>>> Especially those that count something.
>>>
>>
> Do you know how to enforce this standard? Can it be done in the buildbot?
>>
>> We cannot have something like that without making sure that all Sage
>> functions will slowly converge and implement it. We have thousands of
>> functions that do not respect this, and a standard is of little use unless
>> it is respected.
>>
>
> But in any case it is better if these kind of things are pre-defined, at
> least as a default rule. Now I know that my suggestion to change the type
> to Integer is right, unless someone explains why this-and-this function
> should be an exception.
>
>  * * *
>
> Is it so that sage -t basically just compares strings? Can someone make a


Correct.


> program that checks what expected outputs "seems like an integer", runs
> the corresponding test and tests the type of output? I.e. from
>
> sage: Foo = Bar()
> sage: Foo.xyzzy()
> 42
>
> runs
>
> Foo = Bar()
> type(Foo.xyzzy())
>
> and says when the output is not of type Integer? Of course it will give
> false positives, as 42 might be an element of GF(101), but it could at
> least help finding functions to correct.
>
>
The trouble is that functions have many exit points and if you ever have
something like "if trivial: return 1" then the returned value will be
int(1), and such cases might not be in doctests (though of course they
should).

I doubt if this can be automated, but if coders and  reviewers are reminded
often that might help.

John


-- 
> Jori Mäntysalo

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to