-
-
Notifications
You must be signed in to change notification settings - Fork 701
Basic functionalities for weighted projective {curves, points, spaces} #41170
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
base: develop
Are you sure you want to change the base?
Conversation
|
Documentation preview for this PR (built with commit 8c4f225; changes) is ready! 🎉 |
vincentmacri
left a comment
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.
Looks good overall, just a bunch of nitpicks.
Tagging @GiacomoPope @grhkm21 who were involved in the previous PR.
src/sage/schemes/weighted_projective/weighted_projective_homset.py
Outdated
Show resolved
Hide resolved
src/sage/schemes/weighted_projective/weighted_projective_space.py
Outdated
Show resolved
Hide resolved
src/sage/schemes/weighted_projective/weighted_projective_space.py
Outdated
Show resolved
Hide resolved
| sage: WP.change_ring(GF(5)) | ||
| Weighted Projective Space of dimension 2 with weights (1, 3, 1) over Finite Field of size 5 | ||
| """ | ||
| if isinstance(R, Map): |
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.
It would be nice to include an example of this in the docstring.
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.
actually I find this mathematically questionable. Map of rings induce map of their scheme in opposite direction, right.
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.
actually I find this mathematically questionable. Map of rings induce map of their scheme in opposite direction, right.
Honestly not sure, I don't use the scheme approach to this topic myself. This code does seem to match with projective_space.py though. Either way, I think this is more of a convenience thing, so it should be fine as long as the behaviour is clearly documented. To that effect, could you add a note to the INPUT section of the docstring saying that if R is a morphism then we return a weighted projective space over the codomain of the morphism?
src/sage/schemes/weighted_projective/weighted_projective_space.py
Outdated
Show resolved
Hide resolved
Co-authored-by: Vincent Macri <[email protected]>
|
Someone else may want to double check the equality comparison logic in case of rings with zero divisor (I haven't). |
vincentmacri
left a comment
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.
Remove redundant assert. Other than the integral domain issue I think this looks good.
src/sage/schemes/weighted_projective/weighted_projective_point.py
Outdated
Show resolved
Hide resolved
| sage: WP.change_ring(GF(5)) | ||
| Weighted Projective Space of dimension 2 with weights (1, 3, 1) over Finite Field of size 5 | ||
| """ | ||
| if isinstance(R, Map): |
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.
actually I find this mathematically questionable. Map of rings induce map of their scheme in opposite direction, right.
Honestly not sure, I don't use the scheme approach to this topic myself. This code does seem to match with projective_space.py though. Either way, I think this is more of a convenience thing, so it should be fine as long as the behaviour is clearly documented. To that effect, could you add a note to the INPUT section of the docstring saying that if R is a morphism then we return a weighted projective space over the codomain of the morphism?
|
|
||
| if op in [op_EQ, op_NE]: | ||
| weights = space._weights | ||
| # (other[i] / self[i])^(1 / weight[i]) all equal |
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.
It might exist if c2 is a unit. Or it raises an error, which is bad. We could catch the error, but then what do we return if we are unable to determine if the elements are equal or not?
Doesn't the way it's implemented actually require it to be a field (since it assume we can divide)? Maybe |
|
not really, you can divide in integral domain (and even anyway not like it's my code. I'd struggle to figure out whether |
Okay, and I guess the coercion system handles this?
I'll need to think about this, but I'm pretty busy this week. I'll try to get back to you on Friday. |
pretty much. There's a lot of (possibly slow…) magic going on under the hood. [edit] not really. The return value is whatever sometimes some classes override the coercion system and e.g. implement |
|
P = WeightedProjectiveSpace(Zmod(8), (1, 2))
a = P(4, 1)
b = P(0, 4)
print(a == b) # Returns False, but these are equivalent
I think I misunderstood the definition of projective space over non-fields. I'll double check |
|
I misunderstood the definition, P = WeightedProjectiveSpace(Zmod(8), (1, 1))
P(4, 4) # Works
P = ProjectiveSpace(Zmod(8), 1) # Same as WeightedProjectiveSpace(Zmod(8), (1, 1))
P(4, 4) # ValueError: [4, 4] does not define a valid projective point since it is a multiple of a zero divisorso WeightedProjectiveSpace is allowing us to construct points that are not valid points. |
vincentmacri
left a comment
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.
Let's not allow non-integral domains when check=True.
Otherwise this looks good.
| if len(v) != d and len(v) != d-1: | ||
| raise TypeError("v (=%s) must have %s components" % (v, d)) | ||
|
|
||
| R = X.value_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.
| R = X.value_ring() | |
| R = X.value_ring() | |
| if R not in IntegralDomains(): | |
| raise ValueError("cannot check point over a ring that is not an integral domain") |
| # over other rings, we do not have a generic method to check | ||
| # whether the given coordinates is a multiple of a zero divisor | ||
| # so we just let it pass. |
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.
| # over other rings, we do not have a generic method to check | |
| # whether the given coordinates is a multiple of a zero divisor | |
| # so we just let it pass. |
Don't let it pass, the user should have to specify check=False to allow something potentially invalid to happen.
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.
possible, but the API would be excessively clumsy if you have to check=False the creation of every point.
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.
Perhaps, but we could always move the check option to the WeightedProjectiveSpace itself if that becomes an issue, and then it would just need to be given once. I doubt many users are likely to do significant computations over a ring that isn't an integral domain anyway. The main motivation for this PR was to use it for hyperelliptic Jacobian computations, which is done over fields anyway.
I'll take one last look at the code later today, but unless I find something I missed earlier I'll approve it. Thank you for picking this up!
|
CI failures seem irrelevant. Looks good to me! Thank you again for picking this up! Now we can move forward with #39161. |
Picking up #40070
as far as I can tell the fedora:42 failure is irrelevant.
📝 Checklist
⌛ Dependencies