[sage-support] Re: Possible to make implicit multiplication allow (1 + 2) (3 + 4) ?

2011-06-27 Thread Chris Seberino


On Jun 24, 11:59 pm, Jason Grout jason-s...@creativetrax.com wrote:
 sage: implicit_mul('diff(f,x)(3)', level=10)
 'diff(f,x)*(3)'

 which is definitely not what I intended.

Jason

Would you agree a good robust solution to your issue would be for an
implicit_mul level that *ONLY* converted spaces to multiplication?  In
other words

This should work...

(1 + 2) (3 + 4) # Notice space between parens.

This should/would give an error...

(1 + 2)(3 + 4) # Notice no space between parens.

I reread the implicit_mul docs at 
http://www.sagemath.org/doc/reference/sage/misc/preparser.html
and I cannot find a level between 3 and 10 that does this.

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


Re: [sage-support] Re: Possible to make implicit multiplication allow (1 + 2) (3 + 4) ?

2011-06-27 Thread Robert Bradshaw
On Mon, Jun 27, 2011 at 8:23 AM, Chris Seberino cseber...@gmail.com wrote:


 On Jun 24, 11:59 pm, Jason Grout jason-s...@creativetrax.com wrote:
 sage: implicit_mul('diff(f,x)(3)', level=10)
 'diff(f,x)*(3)'

 which is definitely not what I intended.

 Jason

 Would you agree a good robust solution to your issue would be for an
 implicit_mul level that *ONLY* converted spaces to multiplication?  In
 other words

 This should work...

 (1 + 2) (3 + 4) # Notice space between parens.

 This should/would give an error...

 (1 + 2)(3 + 4) # Notice no space between parens.

That doesn't solve the call mangling issue:

sage: f(x) = x+1
sage: g(x) = x^2
sage: var('a,b')
(a, b)
sage: (f) (a)
a + 1
sage: f + g
x |-- x^2 + x + 1
sage: (f + g) (a + b)
(a + b)^2 + a + b + 1

 I reread the implicit_mul docs at 
 http://www.sagemath.org/doc/reference/sage/misc/preparser.html
 and I cannot find a level between 3 and 10 that does this.

The levels aren't tight so that we can add levels if needed, however I
think it's a bad idea for the default level to make syntactically
valid Python into something that has a totally different meaning.

- 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


[sage-support] Re: Possible to make implicit multiplication allow (1 + 2) (3 + 4) ?

2011-06-24 Thread Jason Grout

On 6/24/11 2:17 AM, Chris Seberino wrote:

I love implicit_multiplication(True) but I noticed it doesn't work
between parens!?

How make this work?...

sage: (1 + 2) (3 + 4)
---
TypeError Traceback (most recent call
last)

/home/seb/ipython console  inmodule()

TypeError: 'sage.rings.integer.Integer' object is not callable




Did you read the docs before you posted?  There's a level specifier, and 
a warning in the docs about making that case work:


http://www.sagemath.org/doc/reference/sage/misc/preparser.html#sage.misc.preparser.implicit_mul

Thanks,

Jason


--
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: Possible to make implicit multiplication allow (1 + 2) (3 + 4) ?

2011-06-24 Thread Chris Seberino
Jason

Thanks.  Usually I google and read what I find.  This one slipped my
net.  My apologies.  I'll try harder to search.
I see the may mangle call statements warning on the link you sent.
I don't see an example of a mangling.
I increased my level to 10 and tried to mangle something but I
failed.  Still not sure what I should watch out for...

sage: n( sin( ( sin( .5 ) ) ) )
0.461269555033181

sage: n( sin( ( sin( .5 ) cos( sin(.1) ) ) ) )
0.459150207292798


cs

On Jun 24, 7:57 am, Jason Grout jason-s...@creativetrax.com wrote:
 On 6/24/11 2:17 AM, Chris Seberino wrote:

  I love implicit_multiplication(True) but I noticed it doesn't work
  between parens!?

  How make this work?...

  sage: (1 + 2) (3 + 4)
  ---
  TypeError                                 Traceback (most recent call
  last)

  /home/seb/ipython console  inmodule()

  TypeError: 'sage.rings.integer.Integer' object is not callable

 Did you read the docs before you posted?  There's a level specifier, and
 a warning in the docs about making that case work:

 http://www.sagemath.org/doc/reference/sage/misc/preparser.html#sage.m...

 Thanks,

 Jason

-- 
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: Possible to make implicit multiplication allow (1 + 2) (3 + 4) ?

2011-06-24 Thread Jason Grout

On 6/24/11 11:02 PM, Chris Seberino wrote:

Jason

Thanks.  Usually I google and read what I find.  This one slipped my
net.  My apologies.  I'll try harder to search.
I see the may mangle call statements warning on the link you sent.
I don't see an example of a mangling.
I increased my level to 10 and tried to mangle something but I
failed.  Still not sure what I should watch out for...

sage: n( sin( ( sin( .5 ) ) ) )
0.461269555033181

sage: n( sin( ( sin( .5 ) cos( sin(.1) ) ) ) )
0.459150207292798


The last doctest example gives a situation to watch out for:

sage: implicit_mul('f(a)(b)', level=10)
'f(a)*(b)'

What if f(a) really returned a function, and that returned function was 
supposed to be called with b.  I do this all the time when taking 
derivatives, for example:


f(x)=x^2
diff(f,x)(3) # evaluate the derivative at x=3

This would preparse as:

sage: implicit_mul('diff(f,x)(3)', level=10)
'diff(f,x)*(3)'

which is definitely not what I intended.

Thanks,

Jason

--
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