[sage-support] Re: plot returns an error when given a callable class

2013-12-18 Thread Alden
Given what the patch is supposed to do, it seems like it should fix it. 
 However, when I try to install the patch, I get the error abort: failed 
to synchronize metadata for sage/plot/plot.py.  Anyway, not a huge deal, 
so I guess I should just wait until the patch is integrated in sage 6.1.

On Tuesday, December 17, 2013 5:36:34 PM UTC-6, P Purkayastha wrote:

 Does the patch here help: http://trac.sagemath.org/ticket/15030 ? 

 On 12/18/2013 06:48 AM, Alden wrote: 
  I wrote a class with a __call__ method, and I want to plot an instance 
  of it using plot() in the sage notebook.  I run the commands: 
  
  import circle_homeo 
  import cyclic_order 
  h = circle_homeo.PSL2R_action(cyclic_order.CyclicOrder('abAB'))[0] 
  
  (this doesn't matter; all that should matter is that h is some callable 
  class) 
  
  plot(h, xmin=0, xmax=1) 
  
  returns the error: 
  
  * 
  Traceback (most recent call last): 
 File stdin, line 1, in module 
 File _sage_input_32.py, line 10, in module 
   exec compile(u'open(___code___.py,w).write(# -*- coding: utf-8 
  -*-\\n + 
  
 _support_.preparse_worksheet_cell(base64.b64decode(cGxvdChoLCB4bWluPTAsIHhtYXg9MSk=),globals())+\\n);
  

  execfile(os.path.abspath(___code___.py)) 
 File , line 1, in module 
 File /tmp/tmpnBGA3K/___code___.py, line 3, in module 
   exec compile(u'plot(h, xmin=_sage_const_0 , xmax=_sage_const_1 ) 
 File , line 1, in module 
 File 
  
 /home/akwalker/Documents/software/sage-5.3/local/lib/python2.7/site-packages/sage/misc/decorators.py,
  

  line 692, in wrapper 
   return func(*args, **kwds) 
 File 
  
 /home/akwalker/Documents/software/sage-5.3/local/lib/python2.7/site-packages/sage/misc/decorators.py,
  

  line 537, in wrapper 
   return func(*args, **options) 
 File 
  
 /home/akwalker/Documents/software/sage-5.3/local/lib/python2.7/site-packages/sage/plot/plot.py,
  

  line 1130, in plot 
   G = _plot(funcs, (xmin, xmax), **kwds) 
 File 
  
 /home/akwalker/Documents/software/sage-5.3/local/lib/python2.7/site-packages/sage/plot/plot.py,
  

  line 1236, in _plot 
   funcs, ranges = setup_for_eval_on_grid(funcs, [xrange], 
  options['plot_points']) 
 File 
  
 /home/akwalker/Documents/software/sage-5.3/local/lib/python2.7/site-packages/sage/plot/misc.py,
  

  line 148, in setup_for_eval_on_grid 
   return fast_float(funcs, *vars,**options), 
  [tuple(range+[range_step]) for range,range_step in zip(ranges, 
 range_steps)] 
 File fast_eval.pyx, line 1377, in sage.ext.fast_eval.fast_float 
  (sage/ext/fast_eval.c:9718) 
  AttributeError: EquivariantRHomeo instance has no attribute '__float__' 
  *** 
  
  However, if I do: 
  
  f = lambda x:h(x) 
  plot(f, xmin=0, xmax=1) 
  
  That works fine.  Is there something I need to do to the class to 
  convince plot() to call it? 
  
  
  -- 
  You received this message because you are subscribed to the Google 
  Groups sage-support group. 
  To unsubscribe from this group and stop receiving emails from it, send 
  an email to sage-support...@googlegroups.com javascript:. 
  To post to this group, send email to 
  sage-s...@googlegroups.comjavascript:. 

  Visit this group at http://groups.google.com/group/sage-support. 
  For more options, visit https://groups.google.com/groups/opt_out. 



-- 
You received this message because you are subscribed to the Google Groups 
sage-support group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/groups/opt_out.


[sage-support] plot returns an error when given a callable class

2013-12-17 Thread Alden
I wrote a class with a __call__ method, and I want to plot an instance of 
it using plot() in the sage notebook.  I run the commands:

import circle_homeo
import cyclic_order
h = circle_homeo.PSL2R_action(cyclic_order.CyclicOrder('abAB'))[0]

(this doesn't matter; all that should matter is that h is some callable 
class)

plot(h, xmin=0, xmax=1)

returns the error:

*
Traceback (most recent call last):
  File stdin, line 1, in module
  File _sage_input_32.py, line 10, in module
exec compile(u'open(___code___.py,w).write(# -*- coding: utf-8 
-*-\\n + 
_support_.preparse_worksheet_cell(base64.b64decode(cGxvdChoLCB4bWluPTAsIHhtYXg9MSk=),globals())+\\n);
 
execfile(os.path.abspath(___code___.py))
  File , line 1, in module

  File /tmp/tmpnBGA3K/___code___.py, line 3, in module
exec compile(u'plot(h, xmin=_sage_const_0 , xmax=_sage_const_1 )
  File , line 1, in module

  File 
/home/akwalker/Documents/software/sage-5.3/local/lib/python2.7/site-packages/sage/misc/decorators.py,
 
line 692, in wrapper
return func(*args, **kwds)
  File 
/home/akwalker/Documents/software/sage-5.3/local/lib/python2.7/site-packages/sage/misc/decorators.py,
 
line 537, in wrapper
return func(*args, **options)
  File 
/home/akwalker/Documents/software/sage-5.3/local/lib/python2.7/site-packages/sage/plot/plot.py,
 
line 1130, in plot
G = _plot(funcs, (xmin, xmax), **kwds)
  File 
/home/akwalker/Documents/software/sage-5.3/local/lib/python2.7/site-packages/sage/plot/plot.py,
 
line 1236, in _plot
funcs, ranges = setup_for_eval_on_grid(funcs, [xrange], 
options['plot_points'])
  File 
/home/akwalker/Documents/software/sage-5.3/local/lib/python2.7/site-packages/sage/plot/misc.py,
 
line 148, in setup_for_eval_on_grid
return fast_float(funcs, *vars,**options), [tuple(range+[range_step]) 
for range,range_step in zip(ranges, range_steps)]
  File fast_eval.pyx, line 1377, in sage.ext.fast_eval.fast_float 
(sage/ext/fast_eval.c:9718)
AttributeError: EquivariantRHomeo instance has no attribute '__float__'
***

However, if I do:

f = lambda x:h(x)
plot(f, xmin=0, xmax=1)

That works fine.  Is there something I need to do to the class to convince 
plot() to call it?


-- 
You received this message because you are subscribed to the Google Groups 
sage-support group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/groups/opt_out.


[sage-support] simplify_radical (and thus simplify_full) forgets an absolute value

2009-05-26 Thread Alden

When I run:
var('t')
sqrt(t^2*(1+t^2)).simplify_radical()

I get the correct:
sqrt(t^2 + 1)*abs(t)

But if I run:
sqrt(t^2 + t^4).simplify_radical()

I get:
t*sqrt(t^2 + 1)

Am I doing something wrong? thanks!
-Alden



--~--~-~--~~~---~--~~
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
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] multivariate integrate possibly doesn't use assumptions and gets the wrong answer

2009-05-18 Thread Alden

When I enter:
assume(1-x^20)
and then:
integrate( integrate(x^2+y^2, y, -sqrt(1-x^2), sqrt(1-x^2)), x,-1,1)
I still get the error:
. lots of stuff.
TypeError: Error executing code in Maxima
CODE:
sage191 : integrate(sage188,sage11,sage189,sage190)$
Maxima ERROR:

Defint: Lower limit of integration must be real.

I know I can do the integral much more easily with a change of
variables, but I want to do it this way.
When I try to convince it that 1-x^2 really is nonnegative, with:
integrate( integrate(x^2+y^2, y, -sqrt(abs(1-x^2)), sqrt(abs(1-x^2))),
x,-1,1)
I get the answer 0.  Just to convince myself that I'm not crazy, I
did:
Integrate[Integrate[x^2+y^2, {y, -Sqrt[Abs[1-x^2]], Sqrt[Abs[1-x^2]]}],
{x,-1,1}]
in Mathematica, and it gives the correct answer of pi/2.

Is there some way in which I can tell Maxima that 1-x^2 really is
nonnegative, and is there a reason why it's giving an answer of 0?

I entered all these commands through the notebook of sage 3.4.2
running on Ubuntu 9.04.
-Alden

--~--~-~--~~~---~--~~
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
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: multivariate integrate possibly doesn't use assumptions and gets the wrong answer

2009-05-18 Thread Alden

Nevermind--you're right it works fine now.
The problem was that I had previously typed in assume(x-10).  I'm not
really sure why that would cause it to get the incorrect value for sqrt
(abs(1-x^2)), but it did.  In any case, it was my fault.  I do notice
one thing, though, which is that when I run
integrate(integrate(x^2+y^2, y, -sqrt(abs(1-x^2)), sqrt(abs(1-x^2))),
x,-1,1)
I get asked:
Is  (x-1)*(x+1)  zero or nonzero?
But when I tell it the answer:
sage: assumptions()
[(x - 1)*(x + 1)  0]
I get the exact same error message.   Telling it
assume(x^2-10)
Also produces the error.  However,
assume(1-x^20) gives the correct answer.  I can understand why it's
getting confused, but it's interesting.







On May 18, 4:10 pm, William Stein wst...@gmail.com wrote:
 On Mon, May 18, 2009 at 3:48 PM, Alden alden.wal...@gmail.com wrote:

  When I enter:
  assume(1-x^20)
  and then:
  integrate( integrate(x^2+y^2, y, -sqrt(1-x^2), sqrt(1-x^2)), x,-1,1)
  I still get the error:
  . lots of stuff.
  TypeError: Error executing code in Maxima
  CODE:
         sage191 : integrate(sage188,sage11,sage189,sage190)$
  Maxima ERROR:

  Defint: Lower limit of integration must be real.

 It works fine for me:

 wst...@sage:~$ sage
 --
 | Sage Version 3.4.1, Release Date: 2009-04-21                       |
 | Type notebook() for the GUI, and license() for information.        |
 --
 sage: assume(1-x^20)
 sage: var('y')
 sage: sage: assume(1-x^20)
 sage: sage: var('y')
 y
 sage:  integrate( integrate(x^2+y^2, y, -sqrt(1-x^2), sqrt(1-x^2)), x,-1,1)

 pi/2

 Can you try in a fresh session?

 William
--~--~-~--~~~---~--~~
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
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: parametric_plot3d appears to not give the correct axes values, also steals keyboard

2009-05-07 Thread Alden

thanks!

On May 6, 11:33 pm, William Cauchois wcauc...@u.washington.edu
wrote:
 I filed a ticket athttp://trac.sagemath.org/sage_trac/ticket/6002.

 -- Bill
--~--~-~--~~~---~--~~
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
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: parametric_plot3d appears to not give the correct axes values, also steals keyboard

2009-05-06 Thread Alden

Sorry, I should have noted that everything I did here was on
sagenb.com using firefox running on Xubuntu 9.04


On May 6, 12:28 pm, Alden alden.wal...@gmail.com wrote:
 0)
 sagenb.com is awesome, especially since Mathematica 7 takes up 100% of
 my processor at all times under Ubuntu 9.04.

 1)
 When I run:
 parametric_plot( (cos(t), sqrt(2)*sin(t)) , (t,0,2*pi))
 I get a nice 2d parametric plot, with the top of the ellipse clearly
 hitting close to 1.5 on the y-axis.  When I run:
 parametric_plot3d( (cos(t), 1 , sqrt(2)*sin(t)), (t,0,2*pi))
 The top of the ellipse really looks like it's at z=1, and the whole
 thing looks a lot like a circle. I realize that this is probably not a
 problem with sage and rather with whatever is doing the plotting, but
 I thought I should point it out.

 2)
 Also, after clicking and dragging on the 3d plot, I can't type
 anywhere in firefox (the notebook or the address bar) until I click
 onto another tab and then back again.  This may be a problem with java
 in my browser not taking the keyboard away from the applet.

 3-more of a feature request than an error I guess)
 I have noticed from googling that there has been some discussion about
 creating a function from R^n to R^m.  I am sure there is some good
 reason why this isn't the case, but I was curious about whether it
 would be possible to just automatically map everything over tuples of
 symbolic expressions, or make a tuple of symbolic expressions a
 symbolic expression itself.  For example, why couldn't diff( (t, 2*t),
 t) (which gives the error that a tuple is not a symbolic expression)
 notice that the tuple is a tuple of symbolic expressions, and then
 just map itself over it to get (1,2).  Also, then defining f(x,y) =
 (2*x, 2*y) seems like it would work.  Similarly, what if there was a
 dot product function which just did the obvious thing when it was
 given two tuples of symbolic expressions?  The reason that I am
 thinking about this is that it would be really awesome if I could tell
 my vector calculus class to do a line integral by defining what f(c(t))
 =fc(t) and c(t) are and then just:
 integrate( dot( fc(t),  diff( c(t), t), t, 0, 2*pi)
 rather than something like
 integrate( vector( (t,t^2,t^3) ).dot_product( diff( vector( (t,t,t) ),
 t ) ), t,0,2*pi)
 which is a little less intuitive.

 -Alden
--~--~-~--~~~---~--~~
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
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] scipy.stats.poisson.pmf doesn't work

2009-04-28 Thread Alden

On two different computers running Ubuntu 9.04, I downloaded and built
from source sage 3.4.1.  I also downloaded scipy using the synaptic
package manager.  I am under the impression that python and scipy in
sage lead completely separate lives from python and scipy outside
sage.  In normal python (i.e. running python from the command line),
the following works fine:

Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41)
[GCC 4.3.3] on linux2
Type help, copyright, credits or license for more information.
 import scipy.stats
 scipy.stats.poisson.pmf(5,1)
0.00306566200976202

But when I run sage, I get the following:
--
| Sage Version 3.4.1, Release Date: 2009-04-21   |
| Type notebook() for the GUI, and license() for information.|
--
sage: import scipy.stats
sage: scipy.stats.poisson.pmf(5,1)
---
TypeError Traceback (most recent call
last)

/home/awalker/sage-3.4.1/ipython console in module()

/home/awalker/sage-3.4.1/local/lib/python2.5/site-packages/scipy/stats/
distributions.pyc in pmf(self, k, *args, **kwds)
   3517 output = zeros(shape(cond),'d')
   3518 place(output,(1-cond0)*(cond1==cond1),self.badvalue)
- 3519 goodargs = argsreduce(cond, *((k,)+args))
   3520 place(output,cond,self._pmf(*goodargs))
   3521 return output

/home/awalker/sage-3.4.1/local/lib/python2.5/site-packages/scipy/stats/
distributions.pyc in argsreduce(cond, *args)
237 # make sure newarr is not a scalar
238 newarr = atleast_1d(args[k])
-- 239 newargs[k] = extract(cond,newarr*expand_arr)
240 return newargs
241

TypeError: unsupported operand type(s) for *: 'numpy.ndarray' and
'numpy.bool_'
--~--~-~--~~~---~--~~
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
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Problem with polynomial factoring?

2008-01-30 Thread Alden

Hi,
I get this error when I try to factor a polynomial.  I gather that it
seems to be something wrong with Singular?  I don't really know what
I'm doing, but I think I set it up correctly.  I upgraded to 2.10
yesterday or so, but this problem happened with the previous version I
had.
Thanks!
-Alden


--
| SAGE Version 2.10, Release Date: 2008-01-18|
| Type notebook() for the GUI, and license() for information.|
--

sage: R.z = PolynomialRing(CC,1)
sage: f = z^4 - 6*z + 3
sage: f.factor()
---
type 'exceptions.TypeError' Traceback (most recent call
last)

/home/alden/ipython console in module()

/usr/local/sage-2.8.15/local/lib/python2.5/site-packages/sage/rings/
polynomial/multi_polynomial_element.py in factor(self)
   1049 R = self.parent()
   1050 R._singular_().set_ring()
- 1051 S = self._singular_().factorize()
   1052 factors = S[1]
   1053 exponents = S[2]

/usr/local/sage-2.8.15/local/lib/python2.5/site-packages/sage/
interfaces/expect.py in __call__(self, *args)
952
953 def __call__(self, *args):
-- 954 return self._obj.parent().function_call(self._name,
[self._obj] + list(args))
955
956 def help(self):

/usr/local/sage-2.8.15/local/lib/python2.5/site-packages/sage/
interfaces/expect.py in function_call(self, function, args)
899 if not isinstance(args[i], ExpectElement):
900 args[i] = self.new(args[i])
-- 901 return self.new(%s(%s)%(function, ,.join([s.name()
for s in args])))
902
903 def call(self, function_name, *args):

/usr/local/sage-2.8.15/local/lib/python2.5/site-packages/sage/
interfaces/expect.py in new(self, code)
801
802 def new(self, code):
-- 803 return self(code)
804
805
###

/usr/local/sage-2.8.15/local/lib/python2.5/site-packages/sage/
interfaces/singular.py in __call__(self, x, type)
440 x = str(x)[1:-1]
441
-- 442 return SingularElement(self, type, x, False)
443
444

/usr/local/sage-2.8.15/local/lib/python2.5/site-packages/sage/
interfaces/singular.py in __init__(self, parent, type, value, is_name)
761 except (RuntimeError, TypeError,
KeyboardInterrupt), x:
762 self._session_number = -1
-- 763 raise TypeError, x
764 else:
765 self._name = value

type 'exceptions.TypeError': Singular error:
   ? not implemented
   ? error occurred in STDIN line 8: `def sage2=factorize(sage1);`
sage:

--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---