Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make categories doctests ready for random seeds #29971

Closed
kliem opened this issue Jun 24, 2020 · 24 comments
Closed

Make categories doctests ready for random seeds #29971

kliem opened this issue Jun 24, 2020 · 24 comments

Comments

@kliem
Copy link
Contributor

kliem commented Jun 24, 2020

This ticket makes

sage -t --long --random-seed=n src/sage/categories/

pass for different values n than just 0.

Depends on #29962

Component: doctest framework

Author: Jonathan Kliem

Branch/Commit: d3457de

Reviewer: Markus Wageringel

Issue created by migration from https://trac.sagemath.org/ticket/29971

@kliem kliem added this to the sage-9.2 milestone Jun 24, 2020
@kliem
Copy link
Contributor Author

kliem commented Jun 24, 2020

Branch: public/29971

@kliem
Copy link
Contributor Author

kliem commented Jun 24, 2020

New commits:

da1c6bestart from a "random" random seed for doctesting
b7b836dmake random seed reproducible
eedbe5edocument random_seed
998b1b9default random seed 0 for now
1d7b00edash instead of underscore for command line options
8715b01make categories fuzz ready

@kliem
Copy link
Contributor Author

kliem commented Jun 24, 2020

Commit: 8715b01

@mkoeppe
Copy link
Contributor

mkoeppe commented Jun 25, 2020

comment:2

I'm not sure if this is a good way to update the doctests. Essentially you are disabling a test by marking it random; the only way it can fail is if it raises an error.

I think it would be better to invent a new doctest tag such as "# random_seed=0" or whatever is syntactically convenient.

@kliem
Copy link
Contributor Author

kliem commented Jun 25, 2020

comment:3

To advertise my point about testing this stuff random #29961. In this instance, the get_random_element thing really failed sometimes. It wasn't discovered before, because only seed 0 is tested.

What's the point about testing this only at seed 0. This doesn't tell us anything about how stable the method is.

But I should add a test that illustrates that this is an element of the correct thing.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jun 25, 2020

Changed commit from 8715b01 to 382abb9

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jun 25, 2020

Branch pushed to git repo; I updated commit sha1. New commits:

382abb9make random tests more meaningful

@kliem
Copy link
Contributor Author

kliem commented Jun 25, 2020

comment:5

Is this better? I would say the test is now more valuable than the old tests. It tells us that random_element will give us an element (not just on random seed 0 and not just something that looks like an element).

@mkoeppe
Copy link
Contributor

mkoeppe commented Jun 25, 2020

comment:6

Replying to @kliem:

To advertise my point about testing this stuff random #29961. In this instance, the get_random_element thing really failed sometimes. It wasn't discovered before, because only seed 0 is tested.

What's the point about testing this only at seed 0.

Well, my main point is that test coverage before and after this ticket are really incomparable. The change

  • drops the test for seed 0 giving a specific element (or, as you say, what looks like an element);
  • adds a test for an arbitrary seed giving no error and passing the __contains__ test

@kliem
Copy link
Contributor Author

kliem commented Jun 26, 2020

comment:7

The other thing that one could do, if you really want to keep the old test, is add the old test in the TESTS block (starting with set_random_seed(0)).

This way one could keep the old test.

@mkoeppe
Copy link
Contributor

mkoeppe commented Jun 26, 2020

comment:8

I'm not sure if I like explicit set_random_seed calls in the doctests because they affect all following doctests in the same block.

I would prefer a solution as proposed in comment 2 above if this can be done easily.

@kliem
Copy link
Contributor Author

kliem commented Jun 26, 2020

comment:9

How will the solution as in comment two work out if all testings are done with random seed. That would basically mean, it is never tested as well.

I know that set_random_seed(0) will affect all other tests in the same block. This is why I propsed having it in the tests section (as last thing being run). Than it wouldn't affect anything.

@jhpalmieri
Copy link
Member

comment:10

How about a Makefile target that runs tests with random_seed=0, or maybe a Makefile target that runs tests twice, once with seed=0 and once with a random seed? Then make sure that people start thinking of that as the new default.

Or as @kliem suggests, double up on some doctests:

    sage: test1
    sage: test2

End of test block::

    sage: test1 # random-seed=0
    sage: test2 # random-seed=0

@kliem
Copy link
Contributor Author

kliem commented Jun 27, 2020

comment:11

I feel like the discussion is on the wrong ticket.

This ticket is merely about making tests in categories pass with a different random seed than 0.

In principal a new flag random-seed=0 sounds fine, but shouldn't be introduced here. That should be introduced in #29962 I think, or in a seperate follow up ticket that this here is based on.

The discussion about the big pictures mainly happened on sage-devel and on #29935 so far.

I mean there are 23 tickets like this and we should really come up with a uniform way to do them all. I'm fine with doing those 23 tickets, but if the general set up should be different, I might need some help with #29962 or #29935 (one introduces random seed, one makes them default after 23 tickets made all parts of sage compatible to it).

@mkoeppe
Copy link
Contributor

mkoeppe commented Jun 27, 2020

comment:12

I agree, discussing this on sage-devel and #29935 would probably be best.

@kliem
Copy link
Contributor Author

kliem commented Jul 12, 2020

comment:13

Merge conflict.

I also need to go through it again and check I respected the design decision in #29935.

@kliem
Copy link
Contributor Author

kliem commented Jul 20, 2020

Changed commit from 382abb9 to d3457de

@kliem
Copy link
Contributor Author

kliem commented Jul 20, 2020

Changed branch from public/29971 to public/29971-reb

@kliem
Copy link
Contributor Author

kliem commented Jul 20, 2020

New commits:

b31e2d5Merge branch 'public/29962' of git://trac.sagemath.org/sage into public/29962-reb
2f30dd9small fixes
b62f781doctests do not start from a random seed by default yet
1d99129fix merge conflict
3c38b5dmake categories fuzz ready
1a6cd3fmake random tests more meaningful
d3457demake doctests according to #29935

@kliem
Copy link
Contributor Author

kliem commented Jul 20, 2020

comment:15

Note that elements of C = FiniteEnumeratedSets().example() are not elements of C, but integers.

@mwageringel
Copy link
Contributor

Reviewer: Markus Wageringel

@mwageringel
Copy link
Contributor

comment:16

This seems to work.

@kliem
Copy link
Contributor Author

kliem commented Aug 14, 2020

comment:17

Thank you.

@vbraun
Copy link
Member

vbraun commented Aug 16, 2020

Changed branch from public/29971-reb to d3457de

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants