Re: [sage-devel] random_element and randtest_element

2018-06-07 Thread Jori Mäntysalo

On Wed, 6 Jun 2018, Travis Scrimshaw wrote:


Heisenfailures are very difficult to debug: One run, doctests fail. You make
a small tweak (one that changes the random seed), which you think fixes the
issue, and then tests pass. However, if it is a random test, then you have
no idea if you have fixed the problem or not.


True, we should somehow save the random seed used and give it with a 
failure notice.


I have done something to help random testing:

sage: from sage.tests.finite_poset import test_finite_lattice
sage: L = posets.RandomLattice(10, 0.98)
sage: test_finite_lattice(L) is None  # Long time
True

We could check, for example, that matrix AB is invertible iff both A and B 
are, and so on.


 * * *

Another thing, should we try to classify bugs we found? I mean that could 
we get insight of places to look for possible other bugs?


--
Jori Mäntysalo

Re: [sage-devel] random_element and randtest_element

2018-06-06 Thread Travis Scrimshaw
I agree with Thierry and also Jeroen: If there are corner cases, you should 
just test them all outright in a TESTS section and/or via some_elements() 
and/or passing them explicitly as TestSuite(foo).run(elements=bar).

Heisenfailures are very difficult to debug: One run, doctests fail. You 
make a small tweak (one that changes the random seed), which you think 
fixes the issue, and then tests pass. However, if it is a random test, then 
you have no idea if you have fixed the problem or not.

Best,
Travis


On Wednesday, June 6, 2018 at 4:14:51 AM UTC+10, Thierry 
(sage-googlesucks@xxx) wrote:
>
> Hi, 
>
> On Tue, Jun 05, 2018 at 10:31:38AM -0700, Samuel Lelievre wrote: 
> > How about adding an optional argument "distribution" 
> > defaulting to None, and for polynomials having say, 
> > if distribution == 'for_testing', then, 
> > 
> > - with probability 1/4, 
> >   select at random among R.some_elements() 
> > - with probability 1/4, 
> >   return random polynomial of density 1 
> > - with probability 1/4, 
> >   return random polynomial of density 1/2 
> > - with probability 1/4, 
> >   return random polynomial of <= 3 monomials 
>
> This will make the code of random_element overloaded hence less readable. 
> If those four tests are interesting, we should just add them to the TEST 
> section. 
>
> Ciao, 
> Thierry 
>
>
> > -- 
> > 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+...@googlegroups.com . 
> > To post to this group, send email to sage-...@googlegroups.com 
> . 
> > Visit this group at https://groups.google.com/group/sage-devel. 
> > For more options, visit https://groups.google.com/d/optout. 
>
>

-- 
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 https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


Re: [sage-devel] random_element and randtest_element

2018-06-05 Thread Thierry
Hi,

On Tue, Jun 05, 2018 at 10:31:38AM -0700, Samuel Lelievre wrote:
> How about adding an optional argument "distribution"
> defaulting to None, and for polynomials having say,
> if distribution == 'for_testing', then,
> 
> - with probability 1/4,
>   select at random among R.some_elements()
> - with probability 1/4,
>   return random polynomial of density 1
> - with probability 1/4,
>   return random polynomial of density 1/2
> - with probability 1/4,
>   return random polynomial of <= 3 monomials

This will make the code of random_element overloaded hence less readable.
If those four tests are interesting, we should just add them to the TEST
section.

Ciao,
Thierry


> -- 
> 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 https://groups.google.com/group/sage-devel.
> For more options, visit https://groups.google.com/d/optout.

-- 
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 https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


Re: [sage-devel] random_element and randtest_element

2018-06-05 Thread Samuel Lelievre
How about adding an optional argument "distribution"
defaulting to None, and for polynomials having say,
if distribution == 'for_testing', then,

- with probability 1/4,
  select at random among R.some_elements()
- with probability 1/4,
  return random polynomial of density 1
- with probability 1/4,
  return random polynomial of density 1/2
- with probability 1/4,
  return random polynomial of <= 3 monomials

-- 
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 https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


Re: [sage-devel] random_element and randtest_element

2018-06-05 Thread Thierry
On Tue, Jun 05, 2018 at 06:01:35PM +0200, Jeroen Demeyer wrote:
> On 2018-06-05 17:52, Vincent Delecroix wrote:
> >   2) a new method randtest_element that would generate (quickly) a
> >  random element suited for testing. Such a method would try to
> >  return "corner cases" with good probability.
> 
> I thought that some_elements() was meant for that:

+1.

Ciao,
Thierry



> 
> sage: R. = ZZ[]
> sage: list(R.some_elements())
> [x, 0, 1, 1, x^2 + 2*x + 1, x^3, x^2 - 1, x^2 + 1, 2*x^2 + 2]
> 
> Obviously, this some_elements() method could be improved but that's besides
> the point.
> 
> -- 
> 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 https://groups.google.com/group/sage-devel.
> For more options, visit https://groups.google.com/d/optout.

-- 
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 https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


Re: [sage-devel] random_element and randtest_element

2018-06-05 Thread Jeroen Demeyer

On 2018-06-05 17:52, Vincent Delecroix wrote:

   2) a new method randtest_element that would generate (quickly) a
  random element suited for testing. Such a method would try to
  return "corner cases" with good probability.


I thought that some_elements() was meant for that:

sage: R. = ZZ[]
sage: list(R.some_elements())
[x, 0, 1, 1, x^2 + 2*x + 1, x^3, x^2 - 1, x^2 + 1, 2*x^2 + 2]

Obviously, this some_elements() method could be improved but that's 
besides the point.


--
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 https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.