-
-
Notifications
You must be signed in to change notification settings - Fork 491
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
Laurent polynomial/series modularization fixes #35554
Conversation
48d4ecf
to
eaef6e6
Compare
I think it would make much more sense to move symmetric functions to |
That would be a plausible redesign. However, I'm using these feature tags in a looser way: Most of |
You use two idioms
and
to modify module level imports of classes, for modularization. How are they different in terms of usage? |
sage: check(L, gen(), valuation=-5) | ||
sage: L.<z> = LazyLaurentSeriesRing(GF(2)) # optional - sage.rings.finite_rings | ||
sage: check(L, lambda n: n, valuation=-5) # optional - sage.rings.finite_rings | ||
sage: check(L, gen(), valuation=-5) # optional - sage.rings.finite_rings | ||
|
||
sage: L = LazyDirichletSeriesRing(QQbar, "s") | ||
sage: check(L, lambda n: n, valuation=2) | ||
sage: check(L, gen(), valuation=2) | ||
|
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.
sage.rings.number_field
?
By the way, this being singular is not consistent with sage.rings.finite_rings
being plural...
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.
Yes, I'm also mildly annoyed by this inconsistency
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.
Done in b9bf5bb
sage: L.<x,y> = LaurentPolynomialRing(QQ) # indirect doctest | ||
sage: x*y | ||
sage: L.<x,y> = LaurentPolynomialRing(QQ) # indirect doctest # optional - sage.modules | ||
sage: x*y # optional - sage.modules | ||
x*y |
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.
Does this (just constructing the ring and an element) depend on sage.modules
? Then the distribution package that installs laurent_polynomial.pyx
should install sage.modules
. No?
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.
see below
False | ||
sage: (2 + 4*u + 2*u^2).is_square() | ||
sage: (2 + 4*u + 2*u^2).is_square() # optional - sage.rings.number_field | ||
True |
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.
Hmm. So perhaps sage.modules
is a dependency of only multi-variate Laurent polynomial ring.
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.
yes, see below
|
||
sage: F.<t> = GF(4) # optional - sage.rings.finite_rings | ||
sage: LF.<a,b> = LaurentPolynomialRing(F) # optional - sage.rings.finite_rings | ||
sage: rho = LF.hom([b,a], base_map=F.frobenius_endomorphism()) # optional - sage.rings.finite_rings |
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.
No sage.modules
here? I am getting confused...
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.
This whole file is only shipped with sagemath-modules (#32432) because it cimport
s from sage.matrix
.
(I split out this file from laurent_polynomial.pyx
for this reason.)
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.
Thus this whole business of adding (and not-adding) optional
tags requires understanding of the hierarchy of distribution packages and which files are included in which distribution packages. This is very unlike with other doctest tags, which the author of the doctests can decide solely from his/her understanding of the code.
If the business is one time work (that is done and forgot), no matter. But every author that makes changes to doctests should be aware of the modularization structure of the sage codebase, not to break distribution packages.
I think we should later provide some tools or documentation to make the business easy and obvious.
Would Github actions testing distribution packages provide information to help authors decide on optional
tags?
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.
Yes, there is a clear gap in the documentation - both in the code and in the formatted documentation.
In the code, the plan is to annotate each file with the name of the distribution that it is shipped by: # sage_setup: distribution = sagemath-combinat
etc.; #35663 adds many of such annotations; this will enable consistency checks.
In the formatted documentation, file-level annotations # sage_setup: distribution
and # sage.doctest: optional
are not presented at all at the moment; in contrast to the line-level # optional
annotations.
I don't have a clear plan yet how to improve it.
Yes, GH Actions will run the tests for the distributions after #35095, and this will flag any mistakes.
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.
OK. Sounds nice.
They have different performance characteristics, as explained in https://sagemath-tobias.netlify.app/developer/packaging_sage_library.html#module-level-runtime-dependencies I think I tend to use the second idiom when the code that uses it seemed to be concerned about performance; but I am not sure that I have been entirely consistent with it. The first idiom, on the other hand, looks more elegant; and by adding a |
Documentation preview for this PR (built with commit b9bf5bb) is ready! 🎉 |
Good idea. Or perhaps you may add |
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.
LGTM.
Thanks for the review! |
📚 Description
We remove several obstacles to modularization:
sage.data_structures.stream
importing fromsage.combinat.sf
sage.rings.bigoh
, importingLaurentSeries
,PuiseuxSeries
, padics.LaurentSeriesRing._element_constructor_
unconditionally importingsage.libs.pari.all
just for anisinstance
testfactorial
fromsage.functions
(only the version fromsage.arith
is needed)sage.matrix
) mixed with the univariate implementationAlso adding
# optional
tags for the doctests that depend onsage.rings.finite_rings
,sage.symbolic
.Part of:
📝 Checklist
⌛ Dependencies