-
-
Notifications
You must be signed in to change notification settings - Fork 552
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 construction functor for p-adic relaxed types. #35441
Conversation
It looks like the linting errors were here. The PR looks fine otherwise. |
Alright, it seems like you need to merge #35418 here as well. I'll give both tickets positive review once tests pass. |
How come this is not caught by |
On sage 9.8:
The same thing works ok after this PR, I'll add running a doctest to run the testsuite as above. |
Unrelated (random) doctest failure, which I can reproduce locally with this particular random seed:
|
@roed314 all tests pass now here and in #35442. Except for:
For the failure, I'll have a look and submit a PR if it's trivial to fix or open an issue otherwise. |
Is it normal that github mentions that the file |
It is deleted in #35418. It shows up here because of the merge. That and the change to The current PR only changes two lines of code, the rest is all adding a bunch of new tests that fail without this PR and pass with this PR. |
I see, thanks for the answer. |
The precision for relaxed p-adics has 3 components: `(default_prec, halting_prec, secure)` where the last one `secure` is a boolean defaulting to `False`. However, the `construction()` method doesn't know about it: ``` sage: K = QpER(5, secure=True) sage: K.construction(forbid_frac_field=True) (Completion[5, prec=(20, 40)], Rational Field) sage: R = ZpER(5, secure=True) sage: R.construction() (Completion[5, prec=(20, 40)], Integer Ring) ``` This has two undesired consequences for the `change()` method: a. The `secure` attribute is not copied: ``` sage: K.is_secure() True sage: K.change().is_secure() False sage: R.is_secure() True sage: R.change().is_secure() False ``` b. The `check=False` option is broken: ``` sage: K.change(check=False) ... ValueError: not enough values to unpack (expected 3, got 2) sage: R.change(check=False) ... ValueError: not enough values to unpack (expected 3, got 2) ``` Fixing the `construction()` method solves both issues. After this commit: ``` sage: K = QpER(5, secure=True) sage: K.construction(forbid_frac_field=True) (Completion[5, prec=(20, 40, True)], Rational Field) sage: K.change().is_secure() True sage: K.change(check=False) 5-adic Field handled with relaxed arithmetics sage: K.change(check=False).is_secure() True sage: R = ZpER(5, secure=True) sage: R.construction() (Completion[5, prec=(20, 40, True)], Integer Ring) sage: R.change().is_secure() True sage: R.change(check=False) 5-adic Ring handled with relaxed arithmetics sage: R.change(check=False).is_secure() True ```
d9dbfe5
to
1d0a04a
Compare
Rebased to 10.0.beta8 |
Documentation preview for this PR is ready! 🎉 |
gh-35442: Make Qp.integer_ring() faster. ### 📚 Description The method pAdicGeneric.integer_ring() uses LocalGeneric.change() to turn a p-adic field into a p-adic ring. The latter calls a factory function which, by default, checks primality of p. However, when p came from a Qp this step is not necessary. We avoid it by adding `check=False` to the call to `LocalGeneric.change()` in `pAdicGeneric.integer_ring()`. This results in significant time savings for large primes, e.g. in the current test suite: Before this commit: ``` sage: R = Qp(next_prime(10^60)) sage: timeit('R.integer_ring()') 25 loops, best of 3: 22.2 ms per loop sage: %time TestSuite(R).run() CPU times: user 14.4 s, sys: 44 µs, total: 14.4 s Wall time: 14.4 s ``` After this commit: ``` sage: R = Qp(next_prime(10^60)) sage: timeit('R.integer_ring()') 625 loops, best of 3: 68 μs per loop sage: %time TestSuite(R).run() CPU times: user 714 ms, sys: 239 µs, total: 715 ms Wall time: 717 ms ``` Doctest of `padic_base_leaves.py` goes down from ~33 to ~5 seconds. Note that the `check=False` option for the `change()` method in relaxed type is broken, so this needs #35441. Other than that this is a one- liner. ### 📝 Checklist - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. ### ⌛ Dependencies - #35441 URL: #35442 Reported by: Gonzalo Tornaría Reviewer(s): roed314
The precision for relaxed p-adics has 3 components:
where the last one
secure
is a boolean defaulting toFalse
.However, the
construction()
method doesn't know about it:This has two undesired consequences for the
change()
method:a. The
secure
attribute is not copied:b. The
check=False
option is broken:Fixing the
construction()
method solves both issues.After this commit:
📝 Checklist