-
-
Notifications
You must be signed in to change notification settings - Fork 488
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
Meta-PR: More # optional
doctest tags
#34998
Meta-PR: More # optional
doctest tags
#34998
Conversation
716c6d7
to
5e7fa7d
Compare
Codecov ReportPatch coverage has no change and project coverage change:
Additional details and impacted files@@ Coverage Diff @@
## develop #34998 +/- ##
===========================================
- Coverage 88.62% 87.93% -0.70%
===========================================
Files 2148 2148
Lines 398653 398686 +33
===========================================
- Hits 353308 350571 -2737
- Misses 45345 48115 +2770
... and 83 files with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
5e7fa7d
to
7f37354
Compare
Tests pass, ready for review |
ad237b3
to
ceecd88
Compare
Yes. But to check that For instance,
Then how can I see which is the minimal distribution package that installs the module The minimal distribution package should be unique. Right? If the smallest distribution package that installs the module containing the doctest using Which of Is this the only scenario that |
In
"sage.rings.number_field" is the name for the full functionality (not just loading some modules) of the classes defined in
When the modularization takes its final form, every module will be distributed by exactly one distribution package, so uniqueness holds trivially. However, during the modularization effort, there still exist some distribution packages that are subsets of other distribution packages: Currently, all of sagemath-{environment,repl,objects,categories} are subsets of sagemath-standard. Some PRs introduce additional such cases:
Another PR corrects such subset relations by making the subset distributions dependencies (install-requires) instead: During the modularization effort, it may also be convenient to temporarily introduce some nontrivial antichains of distribution packages; in that case, the uniqueness will not necessarily hold. (Such antichains may also be introduced inadvertently by mistakes in writing the
I think here you are asking about the modules shipped by distribution packages together with their declared runtime dependencies (install-requires). So the doctest should have |
There won't be sagemath-standard? There won't be a distribution package that requires a set of smaller distribution packages and includes some individual modules? The hierarchy will disappear? Or do you mean that every module will be included in exactly one minimal (in subset relations) distribution package? |
sagemath-standard will continue to exist but most likely will not ship any module. Instead it will declare a bunch of runtime dependencies so that installing it will install all modules. |
This hierarchy diagram is not intended to visualize inclusion; it visualizes runtime dependencies. |
Suppose there are only three modules A, B, and C. (1) If distribution package P1 installs modules A and B and distribution package P2 depends on P1 but also installs a module C, then a doctest in C would not need "#optional - A" (2) If distribution package P1 installs modules A and B and distribution P3 installs the module C and P2 depends on P1 and P3, then the same doctest in C would need "# optional - A" The modularization in final form would look like (2). Am I right? |
That's right. When C is doctested, its unique containing distribution P2 is installed, hence by declared dependencies also P1 is installed, so A is available.
Right.
Both cases can appear in the modularization in final form. |
In the example, the distribution package that installs A is P1. (I added adjective minimal for this above) In (1), the distribution package that installs C is P2. As P2 is above P1 in the hierarchy, the doctest does not need the tag In (2), the distribution package that installs C is P3. Here P3 is not above P1, and hence the doctest needs the tag. So to decide whether the tag is necessary for a doctest, we need to know the distribution that installs a module. This is my first question above. Is there a command that reports the distribution that installs module M, for input M? Or should we search through the source code of distribution packages? Is there a command that reports the relationship between two distributions in the hierarchy? Or should we rely on the hierarchy diagram in the developer manual? |
I guess that the hierarchy diagram can be outdated anytime. Then we still need to look through the source code of distribution packages if the command does not exist. |
When M is already installed, we can get this information using importlib.metadata.packages_distributions and importlib.metadata.files. On the source code level, I hope to add a comment line to the top of each file that indicates the distribution; see #30666, which adds a number of these comments. This will replace the current method of defining the distributions via |
For installed distributions, importlib.metadata.requires provides this information. |
I wrote quickly this: from importlib.metadata import packages_distributions, distribution, requires
def sage_distribution_packages():
sage_dists = []
for dist_list in packages_distributions().values():
for dist in dist_list:
if dist.startswith('sage-') or dist.startswith('sagemath-'):
sage_dists.append(dist)
return list(set(sage_dists))
def find_sage_distribution_package(mod):
dists = []
for dist_pack in sage_distribution_packages():
for pack in distribution(dist_pack).files:
if pack.name.endswith('.py'):
parts = pack.parts
mod2 = '.'.join(list(parts[:-1]) + [pack.name[:-3]])
elif pack.name.endswith('.pyx'):
parts = pack.parts
mod2 = '.'.join(list(parts[:-1]) + [pack.name[:-4]])
else:
continue
if mod2 == mod:
dists.append(dist_pack)
break
return dists The I get sage: sage_distribution_packages()
['sagemath-standard', 'sage-docbuild', 'sage-conf']
sage: m = CyclotomicField.__module__; m
'sage.rings.number_field.number_field'
sage: find_sage_distribution_package(m)
['sagemath-standard']
sage: find_sage_distribution_package('sage.structure.coerce')
['sagemath-standard'] So there is no need to add But this PR is provisional to modularized distributions |
Thanks for writing this! It would be a useful addition to |
Here you ran your code in a non-modularized installation: sagemath-standard ships everything, so your code will tell you that nothing needs a |
No, this PR does not have any dependencies because the added annotations do nothing in the monolithic installation. |
I meant rather that to see the necessity of those tags you added in this PR through the commands, I should run the commands in sage where the new modularized distribution packages are installed. |
Yes, testing with the subset distributions, for example using |
This merge-conflicts with #35095. Would you make either of them dependent on the other so that they can be reviewed together? |
Thanks, I've merged it into #35095. |
b55ba8f
to
4b6a8df
Compare
…onal_doctest_tags
…tional_doctest_tags
# optional
doctest tags# optional
doctest tags
SageMath version 10.0.rc0, Release Date: 2023-04-23
Documentation preview for this PR is ready! 🎉 |
…mat doctests <!-- Please provide a concise, informative and self-explanatory title. --> <!-- Don't put issue numbers in the title. Put it in the Description below. --> <!-- For example, instead of "Fixes #12345", use "Add a new method to multiply two integers" --> ### 📚 Description <!-- Describe your changes here in detail. --> Adding doctest tags `# optional - sage.rings.finite_rings`, `...number_field`, `...padics` etc. for modularization purposes. Also: - some coding style fixes in the doctests (such as adding spaces around some operators and after commas, following PEP 8) - improved the readability of doctests in the HTML format by breaking long lines to avoid having to scroll horizontally <!-- Why is this change required? What problem does it solve? --> <!-- If this PR resolves an open issue, please link to it here. For example "Fixes #12345". --> <!-- If your change requires a documentation PR, please link it appropriately. --> This is: - Part of #29705 - Split out & squashed from #34998 ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. It should be `[x]` not `[x ]`. --> - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on - #12345: short description why this is a dependency - #34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: #35422 Reported by: Matthias Köppe Reviewer(s): Gonzalo Tornaría, Kwankyu Lee, Matthias Köppe
Outdated. |
We add
# optional
tags for various doctests, depending onsage.symbolic
,sage.rings.number_field
,sage.groups
,sage.libs.singular
,sage.modules
pplpy
,sympy
,numpy
(fromsage.features
: Addsage.libs.singular
, features for standard Python packages #35237)There is no change when doctesting the monolithic sage library, but it eliminates numerous failures when testing modularized distributions such as sagemath-standard-no-symbolics (#35150) and sagemath-polyhedra (#35095).
In short:
sage.libs.pari
CombinatorialFreeModule
) needs to be markedsage.modules
Depends on:
sage.{geometry,rings}
: More# optional
tags in doctests #35136sage.features
: Addsage.libs.singular
, features for standard Python packages #35237# optional
for modularization; reformat doctests #35422 (split out from here, squashed)sage.rings
: Reformat doctests, add# optional
annotations #35457 (split out from here and Modularization of sagelib: Distributions sagemath-{brial,combinat,eclib,flint,gap,giac,glpk,graphs,groups,homfly,lcalc,libbraiding,libecm,linbox,modules,mpmath,ntl,pari,plot,polyhedra,schemes,singular,standard-no-symbolics,symbolics} #35095)