[sage-support] Re: Is "x (x)" impossible with all implicit_multiplication levels? (Please help decode warning get.)
On Aug 22, 12:35 pm, William Stein wrote: > > Also, I think "f(x)" is more explicit than "f (x)". > > > I never use "f (x)" in Python code and wonder why it is even allowed > > in Python instead of raising an exception. > > Wow, that's almost as bad as "I didn't put any cheese on the eggs for > the vegan." which I just overheard hear at Sage Days 32 from the chef. Why? -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Re: Is "x (x)" impossible with all implicit_multiplication levels? (Please help decode warning get.)
On Mon, Aug 22, 2011 at 6:06 AM, Simon King wrote: > Hi Vladimir, > > On 22 Aug., 12:05, v...@ukr.net wrote: >> Hello guys! >> Could you please explain me (and perhaps some of the other readers) >> the reasons (or advantages) of using implicit multiplication at all? >> I mean in what situations it could be useful? > > I don't know any advantage of implicit multiplication, and that's why > I wouldn't like to drop Python syntax for implicit multiplication's > sake. But apparently other people find it practical to be able to > write 2x instead of 2*x. Or paste. Personally, I found this handy when writing a lot of polynomials/power series. When my brain was in "math mode" I kept getting interrupted by syntax errors :). As far as this proposal, we try to be very cautious when adding anything to the preparser, and double cautious when changing the meaning of valid Python syntax. With the exception of leading whitespace for code blocks, Sage/Python is not whitespace sensitive. Also, to throw my 2 cents in, "f (x)" looks like a function call to me. As for the OP's original deprecation warning, this was to fix the ambiguity of sage: f = x^2 sage: g = t + 1 sage: h = f + g sage: h(2, 3) sage: z = f - x^2 sage: z(3) BOOM - Robert -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Re: Is "x (x)" impossible with all implicit_multiplication levels? (Please help decode warning get.)
On Mon, Aug 22, 2011 at 10:23 AM, Chris Seberino wrote: > > On Aug 22, 10:28 am, v...@ukr.net wrote: >> It seems to me that interpreting the "f (x)" as "f*x" could easily >> confuse the people who are new to Python and Sage. They will read (or >> maybe have already read) some book on Python and the will try to apply >> their new knowledge in Sage, but instead will find some strange >> inexplicable (at first glance) behaviour. >> Wouldn't it be better to stick to Zen of Python rule #2 in this case? >> >> "Explicit is better than implicit." > > As kcrisman said, this would only be an option. > Also, I think "f(x)" is more explicit than "f (x)". > > I never use "f (x)" in Python code and wonder why it is even allowed > in Python instead of raising an exception. Wow, that's almost as bad as "I didn't put any cheese on the eggs for the vegan." which I just overheard hear at Sage Days 32 from the chef. -- William > > cs > > -- > To post to this group, send email to sage-support@googlegroups.com > To unsubscribe from this group, send email to > sage-support+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/sage-support > URL: http://www.sagemath.org > -- William Stein Professor of Mathematics University of Washington http://wstein.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
[sage-support] Re: Is "x (x)" impossible with all implicit_multiplication levels? (Please help decode warning get.)
On Aug 22, 10:28 am, v...@ukr.net wrote: > It seems to me that interpreting the "f (x)" as "f*x" could easily > confuse the people who are new to Python and Sage. They will read (or > maybe have already read) some book on Python and the will try to apply > their new knowledge in Sage, but instead will find some strange > inexplicable (at first glance) behaviour. > Wouldn't it be better to stick to Zen of Python rule #2 in this case? > > "Explicit is better than implicit." As kcrisman said, this would only be an option. Also, I think "f(x)" is more explicit than "f (x)". I never use "f (x)" in Python code and wonder why it is even allowed in Python instead of raising an exception. cs -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
[sage-support] Re: Is "x (x)" impossible with all implicit_multiplication levels? (Please help decode warning get.)
On Aug 22, 11:28 am, v...@ukr.net wrote: > Hello! > > On Mon, 22 Aug 2011 07:43:28 -0700 (PDT) > > Chris Seberino wrote: > > On Aug 22, 8:06 am, Simon King wrote: > > > But apparently other people find it practical to be able to > > > write 2x instead of 2*x. > > > The preference comes from years of using Mathematica. Also, I think a > > space looks cleaner and it is easier to type (no shift needed! :). > > > Chris > > It seems to me that interpreting the "f (x)" as "f*x" could easily > confuse the people who are new to Python and Sage. They will read (or > maybe have already read) some book on Python and the will try to apply > their new knowledge in Sage, but instead will find some strange > inexplicable (at first glance) behaviour. > Wouldn't it be better to stick to Zen of Python rule #2 in this case? > > "Explicit is better than implicit." > I think in this case the point is not that this would be a default, but an option that people who know about Python can use for certain things they find easier this way. I think the Mathematica consideration is an important one as well - we have a few similar un- Pythonic syntax things in the preparser because the syntax is that way in Matlab. -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Re: Is "x (x)" impossible with all implicit_multiplication levels? (Please help decode warning get.)
Hello! On Mon, 22 Aug 2011 07:43:28 -0700 (PDT) Chris Seberino wrote: > On Aug 22, 8:06 am, Simon King wrote: > > But apparently other people find it practical to be able to > > write 2x instead of 2*x. > > The preference comes from years of using Mathematica. Also, I think a > space looks cleaner and it is easier to type (no shift needed! :). > > Chris > It seems to me that interpreting the "f (x)" as "f*x" could easily confuse the people who are new to Python and Sage. They will read (or maybe have already read) some book on Python and the will try to apply their new knowledge in Sage, but instead will find some strange inexplicable (at first glance) behaviour. Wouldn't it be better to stick to Zen of Python rule #2 in this case? "Explicit is better than implicit." The usage of Python as an interface language is one of the most attractive thing about Sage. And many people expect to start using Sage easily with their existing Python knowledge, I believe. So why changing its default syntax (which is clear enough and easy to use by itself) and disorientate people at their first steps? Regards, Vladimir - -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
[sage-support] Re: Is "x (x)" impossible with all implicit_multiplication levels? (Please help decode warning get.)
On Aug 22, 8:06 am, Simon King wrote: > But apparently other people find it practical to be able to > write 2x instead of 2*x. The preference comes from years of using Mathematica. Also, I think a space looks cleaner and it is easier to type (no shift needed! :). Chris -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
[sage-support] Re: Is "x (x)" impossible with all implicit_multiplication levels? (Please help decode warning get.)
On Aug 22, 3:32 am, Simon King wrote: > On 22 Aug., 04:37, Chris Seberino wrote: > > > ... > > sin (pi) # rare, sin(pi) more likely > > f (3, 4) # rare, f(3, 4) more likely > > Likelihood is a not a good guideline, IMHO. I prefer rigour. Implicit multiplication is rigorous (or any remaining corner cases can be made so). Syntax is just interpreted differently. > Hence, when you write "f (3, 4)", do you really mean that *both* blank > spaces should trigger a multiplication? Do you really mean f > multiplied with the tuple (3,) multiplied with 4? I proposed this on dev and it didn't immediately get shot down as crazy. I am only proposing parsing LETTER-WHITESPACE-LEFTPARENS" differently. Hence "3, 4" would not be affected. > And even when you write "f (3,4)" (with only one blank space): Do you > really mean "expression f multiplied with tuple (3,4)"? What is the > product of an expression with a tuple? In my proposal a function call with a space between the f and the tuple would not be allowed. Hence, your example would either give a result if the product of f and (3, 4) made sense, or, an error. That would be rigorous and preferred IMHO. -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
[sage-support] Re: Is "x (x)" impossible with all implicit_multiplication levels? (Please help decode warning get.)
On Aug 22, 12:52 am, Maarten Derickx wrote: > I don't think your proposal will be an enhancement. For two reasons. > > 1. x (x) an x*(x) have the same amount of characters. Some people prefer implicit multiplication. It is already a feature of Sage. > 2. currently the python and sage expressions are not white space dependant. > Your suggestion would introduce such a whitespace dependancy and will be > very unexpected for a lot of people if they just happen to do something like > "sin (pi)". Sage is already whitespace dependent when you turn on implicit multiplication. Thanks for info. I posted on dev and will propose this as a new level for discussion there. cs -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
[sage-support] Re: Is "x (x)" impossible with all implicit_multiplication levels? (Please help decode warning get.)
Hi Vladimir, On 22 Aug., 12:05, v...@ukr.net wrote: > Hello guys! > Could you please explain me (and perhaps some of the other readers) > the reasons (or advantages) of using implicit multiplication at all? > I mean in what situations it could be useful? I don't know any advantage of implicit multiplication, and that's why I wouldn't like to drop Python syntax for implicit multiplication's sake. But apparently other people find it practical to be able to write 2x instead of 2*x. Cheers, Simon -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Re: Is "x (x)" impossible with all implicit_multiplication levels? (Please help decode warning get.)
Hello guys! Could you please explain me (and perhaps some of the other readers) the reasons (or advantages) of using implicit multiplication at all? I mean in what situations it could be useful? Thanks Vladimir - -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
[sage-support] Re: Is "x (x)" impossible with all implicit_multiplication levels? (Please help decode warning get.)
On 22 Aug., 04:37, Chris Seberino wrote: > ... > sin (pi) # rare, sin(pi) more likely > f (3, 4) # rare, f(3, 4) more likely Likelihood is a not a good guideline, IMHO. I prefer rigour. > What about a run level that parses "f (3, 4)" as implicit > multiplication? "3," is a tuple in Python: sage: 3, (3,) Hence, when you write "f (3, 4)", do you really mean that *both* blank spaces should trigger a multiplication? Do you really mean f multiplied with the tuple (3,) multiplied with 4? And even when you write "f (3,4)" (with only one blank space): Do you really mean "expression f multiplied with tuple (3,4)"? What is the product of an expression with a tuple? Best regards, Simon -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
[sage-support] Re: Is "x (x)" impossible with all implicit_multiplication levels? (Please help decode warning get.)
I don't think your proposal will be an enhancement. For two reasons. 1. x (x) an x*(x) have the same amount of characters. 2. currently the python and sage expressions are not white space dependant. Your suggestion would introduce such a whitespace dependancy and will be very unexpected for a lot of people if they just happen to do something like "sin (pi)". -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
[sage-support] Re: Is "x (x)" impossible with all implicit_multiplication levels? (Please help decode warning get.)
On Aug 21, 1:03 pm, Simon King wrote: > If you have an object that is directly followed by parentheses, then > in Python, which is the underlying language of Sage, it means > function evaluation. Hence, when you write f(x) then you normally do > NOT want to multiply f and x, but typically f is a function and you > want to evaluate it at the point x. Simon Thanks for the info. I thought of a perfect solution. Rarely in Python or Sage, when people invoke functions, do they leave a space between the function name and the argument list e.g. sin (pi)# rare, sin(pi) more likely f (3, 4)# rare, f(3, 4) more likely What about a run level that parses "f (3, 4)" as implicit multiplication? Sincerely, Chris -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
[sage-support] Re: Is "x (x)" impossible with all implicit_multiplication levels? (Please help decode warning get.)
On 21 Aug., 20:03, Simon King wrote: > If f is a function with two variables x,y, and you want to substitute > 2 for x and 3 for y... I meant to say "If f is a symbolic expression...". If it is a properly defined function in two variables x,y, then f(2,3) is fine. Cheers, Simon -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
[sage-support] Re: Is "x (x)" impossible with all implicit_multiplication levels? (Please help decode warning get.)
Hi Chris On 21 Aug., 17:19, Chris Seberino wrote: > I want "x (x)" to return x^2. It doesn't seem to work with any > implicit_multiplication level. The use of implicit multiplication is a very improper way to talk with a CAS, IMHO. You met one of the reasons why it is improper and error prone. If you have an object that is directly followed by parentheses, then in Python, which is the underlying language of Sage, it means function evaluation. Hence, when you write f(x) then you normally do NOT want to multiply f and x, but typically f is a function and you want to evaluate it at the point x. And that's why it is a bad idea to drop the * in a multiplication. When you write x(2+3), do you mean "x (a function) evaluated at 5"? Or do you mean "x multiplied with 5"? How could Sage possibly know? So, in case of doubt, better be clear and write x*(2+3), or write x(2+3) and mean function evalutation. > What does the following error mean? It is not an error but a deprecation warning. > Does it mean this will get fixed in a future version? No, since it is not a bug. You asked for function evaluation (without being aware of), and you got function evaluation: x evaluated at x is x. The warning seems to tell that the current rules for substituting some variable in a symbolic expression will actually be more rigid soon. If f is a function with two variables x,y, and you want to substitute 2 for x and 3 for y, then currently you can do f(2,3) -- but you get a warning telling you that you should better write f(x=2,y=3), and that soon you will not only get a (harmless) warning but an actual error. Cheers, Simon -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org