Re: [sage-devel] Re: Poll for issue G2 a specific guideline for writing docstrings
On Fri, May 19, 2017 at 06:23:04AM +, Simon King wrote: > X > > In some context, the technical term ``self`` might be easier to > understand (for someone who knows python...) than natural language, > in other context it may be the other way around > > Maybe +1 as a rule of thumb, but -1 as a strict rule. Same here. Nicolas -- Nicolas M. Thiéry "Isil"http://Nicolas.Thiery.name/ -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
Re: [sage-devel] Re: Poll for issue G1 a specific guideline for writing docstrings
On Wed, May 17, 2017 at 12:32:47PM -0700, Volker Braun wrote: >I'd try to avoid the entire construct; Its the linguistic equivalent of >if condition: > return True >else: >return False >Just say "Test condition" in the docstring. Yes, I agree!!! If we want to stick to the "Return ..." idiom, an alternative is to say "Return whether ". I guess that's slightly off topic though; I imagine this sentence was just meant as one example where ``True`` could appear in our doc. For how to typeset True/False/None/... when we need to spell them out explicitly, as already suggested, I would be in favor of :obj:`True`. Cheers, Nicolas -- Nicolas M. Thiéry "Isil"http://Nicolas.Thiery.name/ -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
Re: [sage-devel] inplace transpose
On Mon, May 22, 2017 at 4:01 PM, Jori Mäntysalowrote: > On Mon, 22 May 2017, Vincent Delecroix wrote: > >> 1) add an option inplace=True/False. There is at least one such method in >> Sage: the relabel method for graphs. The behavior is as follows: > > > inplace is mentioned at > http://doc.sagemath.org/html/en/developer/coding_basics.html#miscellanous-minor-things > > So yes, I think "inplace=True" should be preferred over "return_copy=False" > or similar. > >> 2) Make a private inplace method mat._transpose_inplace() >> >> 3) Make a public inplace method mat.transpose_inplace() >> >> Any preference between 1), 2), 3) or a suggestion for something else is >> welcome! > > > I think 1 would be most natural. Though I'd also add that something like 2) makes perfect sense as an *implementation* detail. -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
Re: [sage-devel] inplace transpose
On Mon, 22 May 2017, Vincent Delecroix wrote: 1) add an option inplace=True/False. There is at least one such method in Sage: the relabel method for graphs. The behavior is as follows: inplace is mentioned at http://doc.sagemath.org/html/en/developer/coding_basics.html#miscellanous-minor-things So yes, I think "inplace=True" should be preferred over "return_copy=False" or similar. 2) Make a private inplace method mat._transpose_inplace() 3) Make a public inplace method mat.transpose_inplace() Any preference between 1), 2), 3) or a suggestion for something else is welcome! I think 1 would be most natural. -- Jori Mäntysalo
Re: [sage-devel] Second round poll for H5 a specific guideline for writing docstrings
On Monday, May 22, 2017 at 2:41:17 PM UTC+2, vdelecroix wrote: > > > Yes! A function in Python always return a unique object. This object > might be a tuple or a list with several components. Ok. Now I understand how you view things. I always thought it is a common idiom in Python that when the output consists of several items, then the output is a tuple of those items (so Python supports this idiom by allowing "Return a,b,c" rather than "Return (a,b,c)"). If you think there is always a choice between a tuple or a list when you return several items, expressing this explicitly in the docstring is essential. -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
Re: [sage-devel] inplace transpose
Hi, On Mon, May 22, 2017 at 02:35:43PM +0200, Vincent Delecroix wrote: > Dear all, > > I would like to have inplace version of transpose for matrices. For the > echelon form we have methods mat.echelonize vs mat.echelon_form. However I > do not see how to deal with transpose in the same way. I see three > reasonable possibilities > > 1) add an option inplace=True/False. There is at least one such method in > Sage: the relabel method for graphs. The behavior is as follows: > > if inplace=True: returns a new graph > if inplace=False: modifies the graph inplace and does not return anything Do you mean the converse ? Ciao, Thierry > One can do the same with .transpose for matrices. However, this would be the > first time in matrix code. > > 2) Make a private inplace method mat._transpose_inplace() > > 3) Make a public inplace method mat.transpose_inplace() > > Any preference between 1), 2), 3) or a suggestion for something else is > welcome! > > Vincent > > -- > You received this message because you are subscribed to the Google Groups > "sage-devel" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to sage-devel+unsubscr...@googlegroups.com. > To post to this group, send email to sage-devel@googlegroups.com. > Visit this group at https://groups.google.com/group/sage-devel. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
Re: [sage-devel] inplace transpose
On 22/05/2017 14:43, Erik Bray wrote: On Mon, May 22, 2017 at 2:35 PM, Vincent Delecroix <20100.delecr...@gmail.com> wrote: Dear all, I would like to have inplace version of transpose for matrices. For the echelon form we have methods mat.echelonize vs mat.echelon_form. However I do not see how to deal with transpose in the same way. I see three reasonable possibilities 1) add an option inplace=True/False. There is at least one such method in Sage: the relabel method for graphs. The behavior is as follows: if inplace=True: returns a new graph if inplace=False: modifies the graph inplace and does not return anything I like this, and there is some precedent for it elsewhere too. But I assume you meant this the other way around? Indeed! One can do the same with .transpose for matrices. However, this would be the first time in matrix code. 2) Make a private inplace method mat._transpose_inplace() 3) Make a public inplace method mat.transpose_inplace() Any preference between 1), 2), 3) or a suggestion for something else is welcome! Vincent -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
Re: [sage-devel] inplace transpose
On Mon, May 22, 2017 at 2:35 PM, Vincent Delecroix <20100.delecr...@gmail.com> wrote: > Dear all, > > I would like to have inplace version of transpose for matrices. For the > echelon form we have methods mat.echelonize vs mat.echelon_form. However I > do not see how to deal with transpose in the same way. I see three > reasonable possibilities > > 1) add an option inplace=True/False. There is at least one such method in > Sage: the relabel method for graphs. The behavior is as follows: > > if inplace=True: returns a new graph > if inplace=False: modifies the graph inplace and does not return anything I like this, and there is some precedent for it elsewhere too. But I assume you meant this the other way around? > One can do the same with .transpose for matrices. However, this would be the > first time in matrix code. > > 2) Make a private inplace method mat._transpose_inplace() > > 3) Make a public inplace method mat.transpose_inplace() > > Any preference between 1), 2), 3) or a suggestion for something else is > welcome! > > Vincent > > -- > You received this message because you are subscribed to the Google Groups > "sage-devel" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to sage-devel+unsubscr...@googlegroups.com. > To post to this group, send email to sage-devel@googlegroups.com. > Visit this group at https://groups.google.com/group/sage-devel. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
Re: [sage-devel] Second round poll for H5 a specific guideline for writing docstrings
On 22/05/2017 14:35, Kwankyu Lee wrote: It seems that some misunderstanding is going on here. If a method returns an integer and a matrix by "Return n, m". I am saying that the output block can be simply OUTPUT: - integer ... - matrix ... instead of OUTPUT: a tuple of ``(n,m)`` where - ``n`` is a integer ... - ``m`` is a matrix ... You may prefer the second style, but does the first style miss an essential information? Yes! A function in Python always return a unique object. This object might be a tuple or a list with several components. So I would say that it is mandatory to specify what the actually output is. In the above case a tuple. Compare def f(): return 1,2 def g(): return [1,2] The functions has essentially the same functionalities however these are different functions. -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
[sage-devel] inplace transpose
Dear all, I would like to have inplace version of transpose for matrices. For the echelon form we have methods mat.echelonize vs mat.echelon_form. However I do not see how to deal with transpose in the same way. I see three reasonable possibilities 1) add an option inplace=True/False. There is at least one such method in Sage: the relabel method for graphs. The behavior is as follows: if inplace=True: returns a new graph if inplace=False: modifies the graph inplace and does not return anything One can do the same with .transpose for matrices. However, this would be the first time in matrix code. 2) Make a private inplace method mat._transpose_inplace() 3) Make a public inplace method mat.transpose_inplace() Any preference between 1), 2), 3) or a suggestion for something else is welcome! Vincent -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
Re: [sage-devel] Second round poll for H5 a specific guideline for writing docstrings
It seems that some misunderstanding is going on here. If a method returns an integer and a matrix by "Return n, m". I am saying that the output block can be simply OUTPUT: - integer ... - matrix ... instead of OUTPUT: a tuple of ``(n,m)`` where - ``n`` is a integer ... - ``m`` is a matrix ... You may prefer the second style, but does the first style miss an essential information? -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
[sage-devel] About a mem / cpu -treshold
Let T = Posets.TamariLattice(7). Then for example %timeit T.is_simple() gives 1,41 seconds, whereas %timeit _ = T.lequal_matrix() T.is_simple() says 0,67 seconds. (You must restart the worksheet between tests, because meet- and join-matrices are saved.) Is it OK to add a call to lequal_matrix() at the beginning of congruence()? It will speed up most computations, as the result is cached, and then interval() is faster, so congruence() is faster, and so is_simple(), is_regular() etc. are faster. However, it will also eat memory, because LatticePoset inherits UniqueRepresentation, and every lattice ever created in a session is saved in memory. -- Jori Mäntysalo
Re: [sage-devel] Re: Second round poll for H5 a specific guideline for writing docstrings
On Monday, May 22, 2017 at 10:27:28 AM UTC+2, Jeroen Demeyer wrote: > > > > The only thing I want to see in the OUTPUT > > block is > > the *type* of the objects and how many of them. > > Why that? What's wrong with being verbose in the OUTPUT block? > The OUTPUT block appearing below other, I think we do not want to impose that OUTPUT block get so verbose that it just repeat information that appeared above it. Of course, if something needs to be verbosed at that point following the information that was/was'nt given before, then yes, I think being verbose to clarify something not explained before is okay. -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
Re: [sage-devel] Second round poll for H5 a specific guideline for writing docstrings
On Mon, 22 May 2017, Daniel Krenn wrote: My opinion is that the phrase "a tuple `(a,b,c)` where ..." is just redundant. I think that "a tuple" is important non-redundant information. +1 for "a tuple" in this case (and not skipping this information; it is essential) +1 from me too. Something printed (a, b, c) might actually be something more complicated that a plain tuple. -- Jori Mäntysalo
Re: [sage-devel] Second round poll for H5 a specific guideline for writing docstrings
On 2017-05-22 12:08, Jeroen Demeyer wrote: > On 2017-05-22 12:05, Kwankyu Lee wrote: >> My opinion is that the phrase "a tuple `(a,b,c)` where ..." is just >> redundant. > > I think that "a tuple" is important non-redundant information. +1 for "a tuple" in this case (and not skipping this information; it is essential) -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
Re: [sage-devel] Second round poll for H5 a specific guideline for writing docstrings
On 2017-05-22 12:21, Kwankyu Lee wrote: The non-redundant information will be implied by the list of hyphened items, if we stick to the convention. So, in order to understand the docstring, the user needs to read the docstring and the convention on how to read the docstring. Not good! -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
Re: [sage-devel] Second round poll for H5 a specific guideline for writing docstrings
On Monday, May 22, 2017 at 12:08:35 PM UTC+2, Jeroen Demeyer wrote: > > On 2017-05-22 12:05, Kwankyu Lee wrote: > > My opinion is that the phrase "a tuple `(a,b,c)` where ..." is just > > redundant. > > I think that "a tuple" is important non-redundant information. > The non-redundant information will be implied by the list of hyphened items, if we stick to the convention. -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
Re: [sage-devel] Second round poll for H5 a specific guideline for writing docstrings
On 2017-05-22 12:05, Kwankyu Lee wrote: My opinion is that the phrase "a tuple `(a,b,c)` where ..." is just redundant. I think that "a tuple" is important non-redundant information. -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
Re: [sage-devel] Second round poll for H5 a specific guideline for writing docstrings
On 2017-05-22 12:05, Kwankyu Lee wrote: This is ugly. By your previous opinion, wouldn't you prefer this? | OUTPUT:a tuple of ``(a,b,c)``where -``a``is... -``b``is... -``c``is... | I think that the guideline of this thread combined with your one-liner style for OUTPUT allows this. Of course, this is much better. -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
Re: [sage-devel] Re: Second round poll for H5 a specific guideline for writing docstrings
On 2017-05-22 11:35, Jori Mäntysalo wrote: Why that? What's wrong with being verbose in the OUTPUT block? This is a misquote. I meant to reply to Sébastien Labbé. -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
Re: [sage-devel] Second round poll for H5 a specific guideline for writing docstrings
On Monday, May 22, 2017 at 10:24:32 AM UTC+2, Jeroen Demeyer wrote: > > I very much object to this: > > > If the output consists > > of several items, add each starting with a hyphen. > > If the output consists of several items, the OUTPUT string should > clearly mention that fact (and it should mention whether the output is a > tuple or list or some other structure with several items). > To be clear, I meant the case that the output is by Return a, b, c My opinion is that the phrase "a tuple `(a,b,c)` where ..." is just redundant. Anyway I guess that different people have different opinions about this as well. > So something like: > > OUTPUT: > > - a tuple `(a,b,c)` where > >- ``a`` is ... > >- ``b`` is ... > >- ``c`` is ... > This is ugly. By your previous opinion, wouldn't you prefer this? OUTPUT: a tuple of ``(a,b,c)`` where - ``a`` is ... - ``b`` is ... - ``c`` is ... I think that the guideline of this thread combined with your one-liner style for OUTPUT allows this. -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
Re: [sage-devel] Re: Second round poll for H5 a specific guideline for writing docstrings
On Mon, 22 May 2017, Jeroen Demeyer wrote: On 2017-05-19 14:16, Jori Mäntysalo wrote: The only thing I want to see in the OUTPUT block is the *type* of the objects and how many of them. Why that? What's wrong with being verbose in the OUTPUT block? This is a misquote. I support something like you suggested in this mail. -- Jori Mäntysalo
Re: [sage-devel] Re: Second round poll for H5 a specific guideline for writing docstrings
On 2017-05-19 14:16, Jori Mäntysalo wrote: The only thing I want to see in the OUTPUT block is the *type* of the objects and how many of them. Why that? What's wrong with being verbose in the OUTPUT block? I would like something like INPUT: - ``certificate`` -- boolean; whether to output a certificate, see OUTPUT OUTPUT: - If ``certificate=False``: a boolean - If ``certificate=True``: something more complicated -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
Re: [sage-devel] Second round poll for H5 a specific guideline for writing docstrings
I very much object to this: If the output consists of several items, add each starting with a hyphen. If the output consists of several items, the OUTPUT string should clearly mention that fact (and it should mention whether the output is a tuple or list or some other structure with several items). So something like: OUTPUT: - a tuple `(a,b,c)` where - ``a`` is ... - ``b`` is ... - ``c`` is ... -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
[sage-devel] bug in calculus.limit reported in ask.sagemath
reported in https://ask.sagemath.org/question/37660/why-is-sage-calling-1-a-variable/ === sage: x = var('x') sage: f = 1/(x-3) sage: limit(f,x=3,dir='below') --- UnboundLocalError Traceback (most recent call last) in () > 1 limit(f,x=Integer(3),dir='below') /Users/dcoudert/sage/local/lib/python2.7/site-packages/sage/calculus/calculus.pyc in limit(ex, dir, taylor, algorithm, **argv) 1349 1350 #return l.sage() -> 1351 return ex.parent()(l) 1352 1353 # lim is alias for limit UnboundLocalError: local variable 'l' referenced before assignment === A quick look at the method shows that local variable `l` (small cap `L) used in the method is not assigned when `algorithm=maxima` and `dir='below'`. The case `dir='below'` is possible when `algorithm == 'maxima_taylor'` but is not specified in the INPUT section. Some clarification is needed. -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.