-
-
Notifications
You must be signed in to change notification settings - Fork 481
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 bad code quality for recently merged #24837 #26141
Comments
comment:1
I won't comment on this specific case, but you could also consider reverting #24837 and then fixing these issues. In any case, it would be good to have one of these 3 things soon:
|
This comment has been minimized.
This comment has been minimized.
comment:2
Dear Daniel, none of these issues are blockers to me. Please don't throw such strong statements around carelessly. Also, since a lot of these issues are simple, why are you asking others to do it? Why can't you take care of them yourself? If you have time to review, you have time to code. Also, code does not need to be perfect to get into Sage (something about the enemy of good comes to mind). I am happy to delegate work to subsequent tickets. Some technical notes. PEP8 are guidelines, good ones that should be followed as much as possible, but guidelines all the same. Same for "Pythonic" code (also you can get a speed bonus for doing these things, not that it is particularly useful here). Sometimes you have to duplicate code or you have to make things somewhat convoluted to not do the duplication. Minor differences are differences. It is also really annoying to deprecate default value changes. |
comment:3
Replying to @tscrim:
It is true that each of the issues above is not a blocker, but by finding that many issues in one simple patch one gets the impression that the code was written sloppy and that the review was done sloppy. And this is something we do not want (as SageMath is sometimes advertised with high coding standards and a peer-reviewing process); this is the actual issue here.
I wouldn't have brought PEP8 up alone (and I do not mind if there is a too long line from time to time), but the code itself is very inconsistently written, so this is way it came up.
I do not insist on this either, but as I have re-reviewed the ticket, I brought it up.
In this particular case it is very easy to avoid the doubling: Use the complete code from the else-block but instead of return save the content in a variable. Then
Yes, but the major issue here is that the original behavior is simply not possible anymore; this is annoying. |
comment:4
Hello, Thank you very much for your 12 points-deep review of this recent ticket. I am on it. |
comment:5
Replying to @jplab:
Great :) If you have any questions, don't hesitate to ask :) |
Commit: |
comment:6
I agree that changing the default behavior is a sensible issue, and that the transition could have been more smooth, see https://xkcd.com/1172 . The code now gives:
so it is possible to get back the previous behavior.
The ticket #24837 introduced 10 too long lines and 12 missing spaces after commas. I added the necessary spaces after the commas in all the file and I left the other four hundred fifty E501s alone.
Thanks for mentioning, forgot to look over that.
Done.
The reason was the shifting of coefficients appearing on the right column. This column appearing on the right of the inequality sign is left justified. When a minus sign appears the coefficient start 1 character more to the left. When there is no minus sign before the coefficient, it therefore appears shifted towards the left. In other to deal with this alignment issue, we insert one character more to the right column to place the "-". This had the side effect that when no minus sign appears (which is the case when "style=positive") then, there is a space left at the end of an equation. This is now taken care of.
Done.
Done.
Jedem Tierchen sein Pläsierchen. I do not argue on this.
Done.
Forgot to change it. Thanks, they are now both
No opinion here. New commits:
|
Branch: u/jipilab/26141 |
Author: Jean-Philippe Labbé |
Changed branch from u/jipilab/26141 to u/dkrenn/26141 |
comment:9
Replying to @jplab:
I know :)))
Great. Thanks.
Thank you for doing all these changes. I've added two more space after a comma.
LGTM.
LGTM. I did a minor rewrite to hopefully improve readablity.
Thank you for the clearification and for taking care of.
LGTM.
Much better now, thank you.
I've changed this now. Please veto, if you it doesn't work for you.
Thanks.
Ok. (FWIW, I would be happy with any of the two being the default.)
I've shortend the OUTPUT-block to avoid the double-description of the style-parameter. New commits:
|
comment:10
Replying to @dkrenn:
I did a small rewrite to simplify the code.
I've introduced a new parameter to set alignment. (I hereby think of other separators than newline.)
I've factored out the padding in a separate function to obtain easier code-reading, I hope. Please cross-review these changes. |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:12
So, I am done; let's also see what the patchbot says ;) |
Changed reviewer from Daniel Krenn to Daniel Krenn, Jean-Philippe Labbé |
comment:13
The bot seems happy, and I am too. Thanks for further improvements. I set it to positive review as the issues seem to be fixed. Best, |
Changed author from Jean-Philippe Labbé to Jean-Philippe Labbé, Daniel Krenn |
comment:14
Thank you very much for your work here on this ticket and on the original #24837; I appreciate it very much and like the improvements. |
Changed branch from u/dkrenn/26141 to |
In #24837 the method
repr_pretty_Hrepresentation
was changed toHrepresentation_str
but unfortunately the quality of the code does not meet Python's and SageMath's standards. The issues (relating to #24837, sagemath/sagetrac-mirror@c868d2c):There is no parameter setting which gives back the old default behavior, which is inequalities separated by commas. Using the separator, one only gets strings containing a lot of blanks, which simple cannot be read properly.
The default values changed without a deprecation. The deprecation just aliases the old and new methods, but does not take care of the parameter setting. (I understand that some believe that this is a minor issue as the output is "only" a string represented to the user and not an (intermediate) result of a computation. However, one could have done this more smoothly)
PEP8 is not satisfied, in particular some too long lines and a lot of missing blanks after commas.
The code in some lines/blocks is considered bad in a Pythonic sense:
should be something like
or even better
Also get rid of the second
for index in range(len(...))
The line
only works if the separator has length 1. Hint: The Pythonic way to do this kind of concatentation is to use
separator.join(...)
.I cannot think of any reason, why the output has an additional blank at each end of line. Please remove this. (I personally would also get rid of all the blanks at the end of the line, i.e. the padding on the right. This maybe is a matter of taste, so should not bother us too much and probably people will find a lot of arguments why this is something wanted, so I just comment this here. ;) )
Why
and not simply
or even
?
There is quite a lot of code doubling at the end of the patch of Improve the output of repr_pretty_Hrepresentation for Polyhedron #24837:
This is very hard too read as one has to compare both almost identical blocks to find the differences. I am certain that a better solution can be found for this.
Docstring of
style
-parameter: Shouldn't the commas be set differently:either ..., or ... or ...
because the latter two should be grouped and not the former two?Docstring
So what does
None
mean here? Is it set automatically according to the input? If static, probably itsFalse
but who knows. Why usingNone
at all and notFalse
as the default then?21. The default of the
style
-parameter is'>='
in base.py and'positive'
in representation.py. Having different default values within the same module for methods doing "the same" is usually not a good idea.32. The variable
split
needs a docstring explaining what it does as this is not obvious. (And, from a technical point of view, one could consider using its inversejoin
, as it is more a' '.join(...)
than a....split(' ')
, but this is highly debatable.)Depends on #24837
CC: @jplab @tscrim @mo271 @vbraun @videlec
Component: geometry
Author: Jean-Philippe Labbé, Daniel Krenn
Branch/Commit:
31765a5
Reviewer: Daniel Krenn, Jean-Philippe Labbé
Issue created by migration from https://trac.sagemath.org/ticket/26141
The text was updated successfully, but these errors were encountered: