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
Graphics3dGroup __add__ modifies its arguments #9089
Comments
comment:2
Attachment: trac-9089-graphics3d.patch.gz Credit goes to Ben Woodruff for reporting this issue. |
comment:3
Do you have any stats on how much this affects performance? |
comment:4
Before patch:
After patch:
So, as could be expected, performance of sum is impacted quite a bit. However, I would still say that the current behavior is wrong, and correctness trumps speed, especially if the overall total speed is still quite fast. |
comment:5
Since we now have a Sage-written sum function, maybe we could just have the sum function call first_object._sum(list of things to sum) if it exists, and make a _sum method that does a Graphics3dGroup(sum_list) behind the scenes? This would also help with a recent ticket that ncohen opened about sum being really slow for linear programming stuff. |
comment:6
Replying to @jasongrout:
That's a great idea! (Certainly a new ticket.) |
comment:7
Replying to @robertwb:
Actually, I just checked, and something like it is already being done. If you do sum(something,...), then if something has a sum method, it is called: something.sum(...). Of course, this won't work with lists or generators. Anyways, feel free to review this ticket! |
comment:8
Okay, the sum stuff is at #9115 |
comment:9
ping about reviewing this bug fix. There has been several times in the past few weeks that this bug has caught me. |
Reviewer: Karl-Dieter Crisman |
comment:10
Looks ok.
in the old example as desired, inheritance is correct. Currently building doc to make sure looks right... okay. Should |
comment:11
I'm getting a doctest failure with this patch on 4.5.alpha1:
Also, if I install this together with the patches at #9066 I get a bunch more failures coming in:
|
Attachment: trac-9089-graphics3d-2.patch.gz apply on top of previous patches |
comment:12
The errors should be taken care of now: on 4.5.2, plot/.py and plot/plot3d/.py all pass doctests. Apply the two patches on top of each other. |
comment:13
Ping to someone to look at this. I believe I corrected all of the failing doctests. |
Changed reviewer from Karl-Dieter Crisman to Karl-Dieter Crisman, David Loeffler |
comment:14
Looks OK to me. I don't use the graphics code myself; but it had a positive review before I grumbled about failing doctests, and I can confirm that the doctests are now fixed, so I feel that merits giving it a positive review again. |
comment:15
Thanks. This bug hit me again yesterday. |
Work Issues: Infinite recursion in doctest |
comment:16
Hang on a minute. I was lazy and ran long doctests on graphics and only short doctests on everything else, so I missed a weird side-effect of this patch: if you install the two patches above on vanilla 4.6.alpha1 and do
then you get an infinite loop:
Apologies for my sloppiness in not having caught this bug earlier. |
comment:17
Replying to @loefflerd:
Well, please accept my apologies for not thinking we had to check ptestlong. I'll fix it and run ptestlong before posting a new patch! Thanks for your patience. |
comment:24
solved in #17258 |
Changed author from Jason Grout to none |
Changed reviewer from Karl-Dieter Crisman, David Loeffler to Frédéric Chapoton |
In an attempt to optimize, in some cases the
__add__
method of Graphics3dGroup modifies its arguments instead of returning a new Graphics3dGroup object. This breaks the user expectation, as illustrated below:The attached patch deletes the offending optimization. If fast summing is needed, then the user can either create a Graphics3dGroup object themselves, or use something like
sage.misc.misc.balanced_sum
CC: @robertwb @sagetrac-mhampton @kcrisman @seblabbe @ppurka
Component: graphics
Work Issues: Infinite recursion in doctest
Reviewer: Frédéric Chapoton
Issue created by migration from https://trac.sagemath.org/ticket/9089
The text was updated successfully, but these errors were encountered: