On Mon, 22 Jun 2020, 10:58 'Jonathan Kliem' via sage-devel, <
sage-devel@googlegroups.com> wrote:

> I had a doctest
>
>             sage: ls = [randint(-100,100) for _ in range(4)]
>             sage: intervals = [[x, x+randint(1,50)] for x in ls]
>             sage: P = polytopes.hypercube(4, intervals, backend='field')
>
> which then checked `P` for consistency. However it was somewhat
> meaningless (missing `set_random_seed()`) as all entries in `ls` where
> positive. It never caught a sign error that we introduced  in #28866
> <https://trac.sagemath.org/ticket/28866>.
> Adding `set_random_seed` to it, does catch the error.
>

unless I misunderstand how Sage random numbers are set, by adding an
explicit set_random_seed() call you merely  went with another bunch of
pseudorandom values than these ones you were hitting without it, not that
you were fixing a bug. In other words you just hit a more favourable  bunch
of pseudorandom data.

To make such tests more robust, one needs to call them in a loop, without
resetting the seed. Then you get a bit more of (pseudo) randomness.







> Now this check for consistency certainly wasn't very good in the first
> place, as two polyhedra might compare equal, even if one is set up
> incorrectly (I just noticed this because of your post, thank you). But it
> still would have caught the error even randomness was true randomness.
>
> You might say, I should have known to add `set_random_seed()` in the first
> place, but I'm definitely not the only one who made that mistake and there
> are plenty of doctests that claim to test a random event, but they really
> test the same event all over and over.
>
> Am Montag, 22. Juni 2020 11:24:59 UTC+2 schrieb Dima Pasechnik:
>>
>>
>>
>> On Mon, 22 Jun 2020, 10:01 'Jonathan Kliem' via sage-devel, <
>> sage-...@googlegroups.com> wrote:
>>
>>> Hi. Could we maybe turn off reproducible "randomness" in doctests by
>>> default. There are probably thousands of meaningless doctests because of
>>> this.
>>>
>>> E.g. https://trac.sagemath.org/ticket/29904
>>>
>>
>> I don't understand, you say there that it went unnoticed due to a too
>> easy doctest. I don't see how that one had anything to do with randomness.
>>
>> Also, could you explain what you mean by "randomness" there.  Doctests
>> are either tagged "random" (and do matching of answers skipped),
>>
>> or use random inputs. If a doctest with random input produces
>> inconsistent results due to not properly set seeds, it would have been
>> caught all along.
>>
>>
>>
>>> or the doctests for the namespace function `bernoulli` or the
>>> `number_of_partitions` function also in the namespace.
>>>
>>> Alternatively we should add `set_random_seed` to all of those places.
>>>
>>> Either way, this might be a huge project, because of possible bugs.
>>>
>>> Jonathan
>>>
>>> --
>>> 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-...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/sage-devel/6a5005ec-717e-400c-b253-514f9101bc72o%40googlegroups.com
>>> <https://groups.google.com/d/msgid/sage-devel/6a5005ec-717e-400c-b253-514f9101bc72o%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/sage-devel/fcc3910a-e851-4f58-9a26-4eaf3dced699o%40googlegroups.com
> <https://groups.google.com/d/msgid/sage-devel/fcc3910a-e851-4f58-9a26-4eaf3dced699o%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/CAAWYfq2TLzN5SwyoEUestmpM%3DoRR1fy_tODU29vdLVCQ5d-%2B8g%40mail.gmail.com.

Reply via email to