On 2020-06-22 05:01, 'Jonathan Kliem' via sage-devel 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
> 
> 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.
> 

For anyone who doesn't know what you're talking about, e.g.

  sage: ZZ.random_element()

in a doctest always produces the same number.

I'm violently opposed to the existing behavior because it's caused me to
introduce several embarrassing bugs. It's counterintuitive and unique to
sage, so new users and reviewers never learn about it until it's too
late. And finally, the reasoning behind it is just silly. There are
plenty of ways to test random functions without being able to predict
their literal output. For example, instead of,

  """
  Ensure that we can produce random integers::

      sage: ZZ.random_element()
      42
  """

One can easily use

  """
  Ensure that we can produce random integers::

      sage: ZZ.random_element() in ZZ
      True
  """

Changing the behavior will break a lot of tests (as well as shed light
upon many bugs), but the working tests at least can be addressed with
set_random_seed(), in essence by removing their randomness again.

-- 
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/ed175873-fc41-812f-a92e-edbb2180ee9e%40orlitzky.com.

Reply via email to