-
Notifications
You must be signed in to change notification settings - Fork 133
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
Fix vinberg booktests #3939
Fix vinberg booktests #3939
Conversation
Cc: @HechtiDerLachs |
@@ -122,17 +122,17 @@ julia> g, phi1 = two_neighbor_step(Y1, fibers[2][I]); g | |||
|
|||
julia> kt2 = base_ring(parent(g)); P = kt2.([0,0]); | |||
|
|||
julia> Y2, phi2 = elliptic_surface(g, P); Y2 | |||
julia> Y2, phi2 = elliptic_surface(g, P; minimize=false); Y2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure in which Oscar versions this works. It is a recent addition. in 5dcfffb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should work in 1.1.1, but not in 1.1.0.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3939 +/- ##
==========================================
+ Coverage 83.99% 84.33% +0.34%
==========================================
Files 591 593 +2
Lines 81387 81731 +344
==========================================
+ Hits 68360 68928 +568
+ Misses 13027 12803 -224
|
Locally on 1.2-Dev the booktest goes through quickly. On 1.10 it seemed to hang. |
@benlorenz would it be possible to run the book CI in 1.1.1? So far they are run in 1.1.0. |
The book tests for a PR are always run with the code from the corresponding branch. There is no 1.1.x involved. Also they are only run for 1.10 and not 1.11. There are some output changes for the vinberg_2 file here: According to the timestamps this file took about 22 minutes in the CI, how long does it take locally and what are the memory requirements?
The |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The recent changes and the new constructor for elliptic surfaces require the tests for the book chapter to be adjusted. The changes in the code here seem rather minimal. Most of the new lines come from the changes of output in the actual tests.
If it works, the changes of this PR should be fine.
@@ -122,17 +122,17 @@ julia> g, phi1 = two_neighbor_step(Y1, fibers[2][I]); g | |||
|
|||
julia> kt2 = base_ring(parent(g)); P = kt2.([0,0]); | |||
|
|||
julia> Y2, phi2 = elliptic_surface(g, P); Y2 | |||
julia> Y2, phi2 = elliptic_surface(g, P; minimize=false); Y2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should work in 1.1.1, but not in 1.1.0.
Locally the tests run in about 15 minutes. Hence the 22 minutes in the CI seem realistic enough. The file is now changed in such a way that it will run without error and produce mathematically correct output. |
This almost doubles the time for the booktests, but as long they finish under 1 hour I think this should be ok.
How are these choices made? We do try to seed all the random number generators for the booktests and in most other tests we do get stable output even with randomness involved in the algorithms. |
Some printing depends on the ordering of At this point my impression is that this book chapter is just not suitable for a doctest. It was written to be interesting for the reader and not to be a sensible doctest.
@fingolfin |
given as the formal sum of | ||
2 * component E8_3 of fiber over (0, 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the order here keeps changing, that suggests a missing hash
method for somewhere; well, most likely for the keys (resp. the type of the keys) in some dictionary. Is there a dict being used here? What is the type of the keys?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type of the dictionary is
IdDict{Oscar.AbsIdealSheaf, ZZRingElem}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so AbsIdealSheaf
is an abstract type, but all its subtypes seem to end with IdealSheaf
. Alas git grep hash.*IdealSheaf
reveals zero hits, i.e. no hashing methods for any of those types. At the same time, there is an equality method in experimental/Schemes/src/IdealSheaves.jl:466
:
function ==(I::AbsIdealSheaf, J::AbsIdealSheaf)
I === J && return true
X = space(I)
X == space(J) || return false
for U in basic_patches(default_covering(X))
is_subset(I(U), J(U)) && is_subset(J(U), I(U)) || return false
end
return true
end
But the rules are clear: when you define a custom ==
method you have to ensure hash
still satisfies the implication if a==b then hash(a)==hash(b)
which usually means a custom hash method has to be provided.
The absolute minimal "always correct" hash function would be this:
Base.hash(x::AbsIdealSheaf, h::UInt) = h
So you could try adding this, perhaps with a comment # TODO: replace by something better
The drawback of such a hash function is that it makes lookups of a key in a Dict slower. The upside is that it also makes it less wrong, which I think is overall preferable in our business... ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aha, but you are actually storing things in an IdDict
-- so in that case the hash
method does not matter at all.
But also: you have zero control over the order, because now instead of hash
it uses objectid
which essentially is the address of the object, and that of course can change when you re-run the program.
In that case the only fix I can think of is to modify your printing code to "sort" the keys in some way, based on some parameters -- doesn't have to be perfect (i.e. not a total order), just good enough to stabilize the output for this example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this example, perhaps one could "cheaply sort" the entries so that those with a "component" in the output string come (for example) first; and then those in turn are sorted on these strings E8_4
etc.; and when there is a tie, sort next by the points they are a fiber over (i.e. (0,1)
and so on?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Or switch to a Dict
after adding a suitable hash
function -- but perhaps your ==
method is too slow for that?)
BTWH hash(h) = h
will still not give fully stable output, but assuming your algorithm is deterministic, or at least runs with a fixed RNG seed (as is the case here) the order should be stable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you guessed we chose IdDict
because ==
is prohibitively expensive
P.S.: The CI error is some unrelated (still newish) bug exposed in Schemes test code, see #3947. |
I suppressed printing of the indeterministic parts. The latest testrun reported: But somehow the tests timed out anyways. |
The booktests seem to die in garbage collection. No clue what is going on. |
I think this was a known error that happens sometimes; I can't find the issue right now though. I restarted the CI job. |
Now the actual book tests seem to have passed, but THEN there was some error?
|
That looks like an error when running the finalizers for the mongodb driver (that is used for polydb access in some other booktests), I don't remember having seen this previously. |
* booktest: explicitly destroy mongodb db and client * booktest-polydb-cleanup: try nicer cleanup
I merged #3963 into this PR here which fixes the mongoc error and the tests are all green now. |
Thank you :-) @benlorenz @joschmitt |
This reverts commit b04ecbb.
* fix booktests for vinberg_3.jlcon and move it to vinberg_2.jlcon * remove vinberg from ordered_examples.json * fix tests * suppress printing of unstable outputs * booktest: explicitly destroy mongodb db and client (oscar-system#3963) * booktest: explicitly destroy mongodb db and client * booktest-polydb-cleanup: try nicer cleanup --------- Co-authored-by: Benjamin Lorenz <[email protected]>
This removes the file vinberg_3.jlcon and copies its contents to vinberg_2.jl a minimal fix is attempted to make it run with Oscar 1.1.
The booktests are also enabled now.
Edit: resolves #3961