Document (m)poly_type, (m)poly_ring_type in the manual#2314
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2314 +/- ##
==========================================
- Coverage 88.16% 88.11% -0.05%
==========================================
Files 126 126
Lines 32047 32108 +61
==========================================
+ Hits 28255 28293 +38
- Misses 3792 3815 +23 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| ```julia | ||
| mpoly_type(::Type{T}) where T <: RingElement | ||
| ``` |
There was a problem hiding this comment.
One problem with this approach (which unfortunately is used a lot in the AA docs) is that the documentation search does not pick up on it -- searching for mpoly_type will not find this.
This can be solved by using a ```@docs block instead, pulling in the docstring for mpoly_type. Of course we then can also edit and improve that docstring, drawing from the text you wrote below.
There was a problem hiding this comment.
Yes; I have just pushed a modification which I hope addresses your concern.
| This function is defined for generic polynomials and needs to be defined only for | ||
| special polynomial rings, e.g. those defined by a C implementation. |
There was a problem hiding this comment.
This sentence is for people who develop new polynomial ring implementations; but not for regular users.
I think we need to make this difference very explicit to avoid confusion. But in this case, I would actually suggest to not put this into the docstring. Instead, this section here could look like this, roughly like this:
Any implementation of the multivariate polynomial ring interface needs to provide methods for the following two functions for all the rings it supports.
```docs
mpoly_type
mpoly_ring_type
```
The default methods for these use the `Generic.MPolyRing` types. But e.g. in Nemo a type `QQMPolyRing` is provided which has optimized multivariate polynomial rings over the rationals.
If we do decide to put this into the docstring, then I suggest we at least put it into a section called # Implementation, following the guidelines from the Julia documentation on "Writing Documentation", bullet point 10.
There was a problem hiding this comment.
Now I am a little confused. What is the target readership for the documentation in mpoly_interface.md? At least from the first few paragraphs, it seems that the documentation is primarily for developers of new types of multivariate polynomial ring.
LINK https://nemocas.github.io/AbstractAlgebra.jl/dev/mpoly_interface/
There was a problem hiding this comment.
Now I am a little confused. What is the target readership for the documentation in mpoly_interface.md? At least from the first few paragraphs, it seems that the documentation is primarily for developers of new types of multivariate polynomial ring.
As I explained during lunch today, the current documentation indeed suffers from not being clear on what the target audience are for
- https://nemocas.github.io/AbstractAlgebra.jl/stable/mpolynomial/ versus
- https://nemocas.github.io/AbstractAlgebra.jl/stable/mpoly_interface/
Indeed, the former right now seems to be a documentation for Generic.MPoly ?!
But really even as a user one needs to read both pages in order to be able to work. While as an implementor, even after reading both pages it is not super clear what one must implement; what one should implement (defaults are provided but most likely you can do better); and what one might optionally implement (for example factoring would be nice to have but is not a requirement of any of the interfaces).
As I explained, we ought to overhaul the documentation to improve this (and not just for mpoly). In my mind we want two or three pages:
- one for "consumers" who use MPolys; this should describe the general interface
- optionally: another "consumer" page describes anything truly specific to
Generic.MPolythat end users ought to know about (similar pages could then exist forZZMPolyRingElemetc. in Nemo) - one page for "implementors" as outlined above.
It would also be a good idea to keep the "four quadrants" of the Diátaxis system in mind.
There was a problem hiding this comment.
I agree that the documentation seems to be "mixed up" as regards intended readership. This looks to be a good candidate for a separate issue -- and I suspect that reorganizing the documentation will be lengthy task, once a clear decision has been made on how it should be organized. In this PR I shall make only a small step in that direction.
There was a problem hiding this comment.
Sure, untangling the docs is a separate issue.
But in the meantime this section is the only place for everyone to learn about these functions. So I still think we should use the docstring approach I outlined.
There was a problem hiding this comment.
I have just read the website about the Diataxis system. It seems like a good starting point for a discussion about reorganizing the documentation -- I'm not entirely convinced by everything written there, but they do make some interesting points.
|
Tangentially related: it may be my ignorance, but I don't understand why, in the examples for |
Do you mean in the documentation? Can you point out the place? |
In the doc: |
|
I think you are right, the parameters are not necessary. |
…ection to docstrings
|
Some tests fail. The cause seems to be: in But it seems that we want it with Ahhh! The extra definition in But I do feel uneasy that the "main" definitions are in |
|
I am now confused about whether |
|
Hekp? Not sure how to fix the problem in |
|
You can click on the failing test. It is a link, which brings you to https://github.com/Nemocas/AbstractAlgebra.jl/actions/runs/21987838445/job/63526572062?pr=2314 |
|
The |
|
Thanks @thofma ! I had seen that, but was not sure what the approved way of proceeding is. The easiest (for me) would be to remove the signatures (inside the I did try inserting two new definitions: but I did not create individual docstrings for them. Maybe the solution is to make a "universal" docstring for all functions called |
|
Maybe the easiest solution is to do change the docstring to @doc raw"""
mpoly_type(::Type{T}) where T<:RingElement
mpoly_type(::T) where T<:RingElement
mpoly_type(::Type{S}) where S<:Ring
mpoly_type(::S) where S<:Ring
Return the type of a (multivariate) polynomial whose coefficients have type `T` or
type `elem_type(S)`.
The type of the corresponding polynomial ring can be found via [`mpoly_ring_type`](@ref).
For univariate polynomials see [`poly_type`](@ref).
# Implementation
This function is already defined for generic multivariate polynomials (namely `Generic.MPoly{T}`),
so _needs to be defined only for_ special polynomial rings, _e.g._ those defined by
a C implementation.
# Examples
```jldoctest
julia> mpoly_type(AbstractAlgebra.ZZ(1))
AbstractAlgebra.Generic.MPoly{BigInt}
julia> mpoly_type(elem_type(AbstractAlgebra.ZZ))
AbstractAlgebra.Generic.MPoly{BigInt}
julia> mpoly_type(AbstractAlgebra.ZZ)
AbstractAlgebra.Generic.MPoly{BigInt}
julia> mpoly_type(typeof(AbstractAlgebra.ZZ))
AbstractAlgebra.Generic.MPoly{BigInt}
```
"""
mpoly_typeand then include it via Similar for the other function. |
|
Indeed: for a |
| @@ -21,10 +21,17 @@ coefficient_ring(R::MPolyRing) = base_ring(R) | |||
| mpoly_type(::Type{S}) where S<:Ring | |||
| mpoly_type(::S) where S<:Ring | |||
There was a problem hiding this comment.
The user will see the text above this line, too!
Co-authored-by: Max Horn <max@quendi.de>
Co-authored-by: Max Horn <max@quendi.de>
…pe, mpoly_ring_type
|
|
||
| See `src/generic/GenericTypes.jl` for an example of how to implement such a cache (which | ||
| usually makes use of a dictionary). | ||
| Implementaors of a new type of polynomial ring should see `src/generic/GenericTypes.jl` |
There was a problem hiding this comment.
| Implementaors of a new type of polynomial ring should see `src/generic/GenericTypes.jl` | |
| Implementors of a new type of polynomial ring should see `src/generic/GenericTypes.jl` |
(m)poly_type, (m)poly_ring_type in the manual
First attempt at tackling issue #1316
Feedback welcome