-
-
Notifications
You must be signed in to change notification settings - Fork 580
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 AttributeError in PowerSeriesRing for division #39713
base: develop
Are you sure you want to change the base?
Conversation
Note that the failure is recent. It used to work just fine. One should first find what change broke the example and then investigate how that breakage can be mitigated. Certainly, any division operation should get a chance to run through the coercion framework, so implementing a fresh It may well be possible that power series rings were previously not properly cooperating in the coercion framework and that the breakage is due to an attempt to fix this, which ended up having some flaws that need further attention. In older versions we find:
I didn't check if that is also what is actually done, but it shows that the coercion framework is perfectly capable of figuring out what operation to do. |
Thanks for the feedback! I realize |
Possibly useful piece of info, in 10.5.beta6 we still had
so it used to work by just inheriting from the normal place. The first place to look for breakage is into why that inheritance doesn't happen anymore. In fact, with git-blame the problem is quickly identified: |
Hi @nbruin, thanks for the pointer! Here’s what I found and did:
def _pseudo_fraction_field(self):
return LaurentSeriesRing(self.base_ring(), self._names[0]) Is this the right approach? Could you provide feedback on it? |
A few points:
Main takeaway: this bug is indicative of a more systemic issue and it's probably better to deal with it on a higher level. Otherwise, the responsibilities for where |
Yes, this method "_pseudo_fraction_field", whatever it does, should have a default implementation in the category of commutative rings. This is an oversight of my changes. The ultimate goal is to get rid of all the historical classes like |
@fchapoton OK, so it sounds this ticket should be repurposed to: make sure all functionality of |
@vidipsingh You should probably read https://doc.sagemath.org/html/en/reference/categories/sage/categories/primer.html since that's definitely going to be relevant. I suspect that the previous implementation:
should probably go in |
It is not reasonable to move several methods at once. Already just moving one method leads to bad surprises and more work than expected. This ticket should just be for moving "_pseudo_fraction_field". |
OK, that's useful. I guess an interesting experiment could be to see how much breaks when Looking at where Note that the breakage observed here was not detected by doctests, so this is probably machinery that has very poor test coverage. |
Thank you @nbruin and @fchapoton for your valuable feedback.
Is this approach acceptable for now, or should it incorporate |
With the investigations done on this ticket I think it's become clear that You mention you plan to propose at The change should probably look something like this: develop...nbruin:sage:_pseudo_fraction_field-on-Rings.Commutative |
@vidipsingh are you still planning to proceed with trying to address the issue on this PR? Or should we resolve the issue via a PR based on develop...nbruin:sage:_pseudo_fraction_field-on-Rings.Commutative ? |
Hi @nbruin, yes I still want to proceed with the issue in this PR. My exams are going on, which is why I haven't been able to work on it, but I will start working as soon as I get the time. |
Hi @nbruin, Thank you for the suggestion. I will proceed with implementing |
9244774
to
6a5e25d
Compare
@vidipsingh That patch looks fine to me. It's also literally the same patch as what I committed on my branch; down to the added doctest. So I think this is a good opportunity for you to learn about using other people's work with appropriate attribution. The "author" information for commits like this are carried in the git history, with the possibility of adding authorship information to the source file for significant and substantial contributions (I don't think this passes that bar). So I think the appropriate measure on your side is to include in the commit message where you sourced this code. A github URL to a branch in someone's private fork is not going to be very stable, so in this case I think just adding "code contributed by Nils Bruin" would sufficient. I don't really care about the credit for this very trivial piece of code, but I think it is important for new contributors to pay attention to attribution. It may well be that we find out after testing this commit that there are some further changes and/or doctests necessary. Those would then be fully your commits. An alternative would be for you to fetch my branch into your own sagemath git and then force-push that one the pull-request here. Then you'd start out with a commit that has the original author info and you could then put further commits on that as necessary. |
Code contributed by Nils Bruin. This resolves the AttributeError in PowerSeriesRing by defining _pseudo_fraction_field in the Rings.Commutative category, aligning with the transition initiated in sagemath#38741.
6a5e25d
to
740aaea
Compare
@nbruin I have included your name in the commit message description as you suggested. Apologies for not adding authorship initially—I'll be more mindful of proper attribution in the future. Thanks for pointing this out! |
Documentation preview for this PR (built with commit 740aaea; changes) is ready! 🎉 |
CI tests are not working. Perhaps that's because the branch is out-of-date. We do need to see that the tests complete successfully on this branch before approving it for merge. Actually, the logs of the tests show that something indeed went wrong: https://github.com/sagemath/sage/actions/runs/14153599086/job/39650014464?pr=39713#step:10:2264 |
This PR resolves a bug where attempting to divide a power series element, like
x/(1-z)
, inPowerSeriesRing_over_field_with_category
would result in an AttributeError due to the missing_pseudo_fraction_field
attribute. The fix ensures that operations involving division within power series rings work as expected, similar to multiplication.Fixes: #39684
📝 Checklist
⌛ Dependencies