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
DiGraph constructor doc describes boundary
option wrong
#14794
Comments
Changed work issues from fix digraph documentation, get rid of mutable defaults to none |
comment:1
The patch is now up. The
None of the code modifies the list, and in fact some of it goes to some pains to make sure appropriate copies are made. Would there be any objections to replacing the list by a tuple everywhere? Apply trac_14794_v1.patch |
This comment has been minimized.
This comment has been minimized.
comment:3
I never used this thing, and to me a code which is not documented might as well not be there, if it is only meant to be used by the guy who added it in the first place. This being said, has it become illegal to use list as an object's attribute ? I understand that you want an immutable version of everything that is in Sage, but if it means preventing people from writing code as they want to perhaps you should change your plans By the way, who "frowns upon" mutable arguments ? It's useful to have a list somewhere, from time to time Nathann |
comment:4
The patch looks good to me, but I don't get why you simultaneously :
Nathann |
comment:6
by the way there is a typo in the trac ticket's number
Nathann |
comment:7
(and you probably removed a ' by mistake at the end of a line) (sorry for the ten comments) Nathann |
comment:8
Replying to @nathanncohen:
I'm not the one who added it, but it did cause a functional problem (did you see the failing test in the ticket description?), namely the
I know I got a previous patch rejected for using a list instead of a tuple or
The problem is only with mutable Replying to @nathanncohen:
It's true, I'm fixing the problem in two different ways. Maybe this is overkill. Still, bringing the documentation of I'm happy with any solution where:
If you have more/different requirements, let me know. Replying to @nathanncohen:
Yes, good catch, sorry about that. The updated patch should fix this. Cheers, Apply trac_14794_v1.2.patch |
comment:9
Yeahyeah of course. I don't like this code either. Not documented, don't know what it does. Actually I would like to have a non-authoritarian way to get rid of it. Otherwise we'll jkust be shipping useless codes forever.
What exactly is the problem with default mutable arguments ? PEP8 even tells me that I should not put blank lines in my code when I think that it improves readability (cf #14562), so to me PEP8 is like the new version of my high school internal rules.
Oh. I see. It's just that as it is, you set the default value to something that the documentation does not claim to be admissible.
I don't have any requirements. Well, short of understanding why mutable default arguments are now against the Dogma Nathann |
comment:10
I looked up the old ticket where this happened to me, and it was #10304. Apparently the default argument is from http://effbot.org/zone/default-values.htm, which I've seen lots of times in various forums at this point. I just started a thread about this on sage-devel. As for accepting Is this good enough for a positive review? Cheers, |
comment:11
Oh, it makes sense. I thought that the default value was created at each call, but it's not the case. It's actually scary
Well, you use it but don't tell others that it can be done. Anyway, it does not change much and your patch is good to go. I just want to understand stuff before obeying it. When there is a real reason behind, it does not have to take very long Nathann |
comment:12
There is still this typo in your code with the ticket number. Could you fix it then set the ticket to positive_review ? Thanks ! Nathann |
comment:13
Sorry, which typo are you referring to? I don't see it anymore in the second patch (attachment: trac_14794_v1.2.patch). I didn't see how to entirely replace the first patch file, so now only the second patch file should be applied. |
comment:14
Travis explained the typo. Thanks everyone! |
Changed keywords from digraph, mutable default to days49, digraph, mutable default |
comment:16
The patch needs a proper commit message ( |
Reviewer: Nathann Cohen |
Attachment: trac_14794_v1.2.patch.gz Now with a proper commit message. |
comment:20
Well, if only the commit message changed... Nathann |
Merged: sage-5.12.beta0 |
While working on quivers
sage.quivers.*
we ran into some confusing documentation inDiGraph
about theboundary
argument of the constructor:Here, it turns out that
None
is not actually allowed, and instead an empty list[]
should be used instead. This is described more clearly in theGraph
docstring:An example of a problem:
As a separate point, both
Graph.__init__
andDiGraph.__init__
have mutable default arguments (def __init__(..., boundary=[], ...)
) which is frowned upon.CC: @nathanncohen
Component: graph theory
Keywords: days49, digraph, mutable default
Author: Mathieu Guay-Paquet
Reviewer: Nathann Cohen
Merged: sage-5.12.beta0
Issue created by migration from https://trac.sagemath.org/ticket/14794
The text was updated successfully, but these errors were encountered: