[sage-support] Re: the set containing the empty set

2009-01-10 Thread Robert Bradshaw

On Jan 9, 2009, at 9:21 PM, John H Palmieri wrote:

>
> On Jan 9, 7:03 pm, "William Stein"  wrote:
>> On Fri, Jan 9, 2009 at 6:42 PM, John H Palmieri  
>>  wrote:
>>
>>> Here's another question: what is the most efficient way of testing
>>> whether one Set is a subset of another?  I can do
>>
>>>S in list(T.subsets())
>>
>>> -- and it's a bit frustrating that I can't do S in T.subsets() --  
>>> and
>>> I can also manipulate intersections, unions, differences, etc. I can
>>> also convert to python sets and use <=.  Is there a preferred way?
>>
>> There should be an is_subset method, but mysteriously there  
>> isn't.   Implement
>> it and send a patch.
>
> Okay, then back to my question: what's the most efficient way of
> implement it?

Probably via python sets, or some other hashing mechanism. It also  
depends on the underlying implementation of Set.

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



[sage-support] Re: why doesn`t solve() give a proper answer

2009-01-10 Thread Slava

Thank you!
to_poly_solve() is a strong function, and it works fast.

--~--~-~--~~~---~--~~
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: the set containing the empty set

2009-01-10 Thread Jason Grout

John H Palmieri wrote:
> 
> 
> On Jan 9, 3:40 pm, "William Stein"  wrote:
>> On Fri, Jan 9, 2009 at 3:38 PM, Mike Hansen  wrote:
>>
>>> On Fri, Jan 9, 2009 at 3:36 PM, John H Palmieri  
>>> wrote:
 Is this a bug?
 sage: Set([])
 {}
 sage: Set(Set([]))
 {}
 sage: Set([]) == Set(Set([]))
 True
>>> This is because Set takes a list (iterable) for all the of the
>>> elements of the set.  So, if you want to construct the set containing
>>> the empty set, you'd do the following:
>>> sage: e = Set([])
>>> sage: ee = Set([e])
>>> sage: e
>>> {}
>>> sage: ee
>>> {{}}
>>> sage: e == ee
>>> False
>> Yep.  Think "coercion" -- Set(foo) makes foo into a set.
>> It doesn't make the set containing foo.
> 
> Oh, I should have figured that out.
> 
> Here's another question: what is the most efficient way of testing
> whether one Set is a subset of another?  I can do
> 
> S in list(T.subsets())
> 
> -- and it's a bit frustrating that I can't do S in T.subsets() -- and
> I can also manipulate intersections, unions, differences, etc. I can
> also convert to python sets and use <=.  Is there a preferred way?

You could use

all(s in T for s in S)

to do the job.  It might be faster to use another mechanism, but the 
above does shortcut (i.e., it stops when an element is found in S that 
is not in T).

Alternatively, you could calculate the set difference S \ T and check 
that is empty; that might be faster.

Do you know how to use the timeit command?

sage: timeit('all(s in T for s in S)')
625 loops, best of 3: 10.1 µs per loop
sage: timeit('S.difference(T)==Set([])')
625 loops, best of 3: 26.2 µs per loop
sage: timeit('len(S.difference(T))==0')
625 loops, best of 3: 21.4 µs per loop


Python still has this beat, though:

sage: S_python = set(S)
sage: T_python = set(T)
sage: timeit('S_python.issubset(T_python)')
625 loops, best of 3: 755 ns per loop


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



[sage-support] Re: the set containing the empty set

2009-01-10 Thread John H Palmieri

On Jan 10, 7:25 am, Jason Grout  wrote:
> John H Palmieri wrote:
> >
> > Here's another question: what is the most efficient way of testing
> > whether one Set is a subset of another?  I can do
>
> >     S in list(T.subsets())
>
> > -- and it's a bit frustrating that I can't do S in T.subsets() -- and
> > I can also manipulate intersections, unions, differences, etc. I can
> > also convert to python sets and use <=.  Is there a preferred way?
>
> You could use
>
> all(s in T for s in S)
>
> to do the job.  It might be faster to use another mechanism, but the
> above does shortcut (i.e., it stops when an element is found in S that
> is not in T).
>
> Alternatively, you could calculate the set difference S \ T and check
> that is empty; that might be faster.
>
> Do you know how to use the timeit command?
>
> sage: timeit('all(s in T for s in S)')
> 625 loops, best of 3: 10.1 µs per loop
> sage: timeit('S.difference(T)==Set([])')
> 625 loops, best of 3: 26.2 µs per loop
> sage: timeit('len(S.difference(T))==0')
> 625 loops, best of 3: 21.4 µs per loop
>
> Python still has this beat, though:
>
> sage: S_python = set(S)
> sage: T_python = set(T)
> sage: timeit('S_python.issubset(T_python)')
> 625 loops, best of 3: 755 ns per loop

However

sage: timeit('set(S).issubset(set(T))')

gives me very similar times to the first option (all(s in T for s in
S)).  So if I start with Sage sets, I don't seem to gain much by
converting back to python sets for this (not to mention that if S = Set
(ZZ), then set(S) runs into problems...).

  John

--~--~-~--~~~---~--~~
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: the set containing the empty set

2009-01-10 Thread Jason Grout

John H Palmieri wrote:
> sage: timeit('set(S).issubset(set(T))')
> 
> gives me very similar times to the first option (all(s in T for s in
> S)).  So if I start with Sage sets, I don't seem to gain much by
> converting back to python sets for this (not to mention that if S = Set
> (ZZ), then set(S) runs into problems...).


Okay.  My point was that the subset routine in python is an order of 
magnitude faster than the above attempts at a Sage subset routine, so 
hopefully we could do better than the above attempts at a subset routine 
for Sage subsets.  Sorry, I should have made that clearer.

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



[sage-support] Re: question about solve() function

2009-01-10 Thread Sand Wraith

thank you!

On Jan 9, 7:27 pm, "William Stein"  wrote:
> On Fri, Jan 9, 2009 at 3:49 AM, Sand Wraith  wrote:
>
> > Hi!
>
> > Is it possible to get order of root of equation? For example equation:
>
> > f(x)=(x+1)^2
> > and it's solution "solve(f,x)" will be "[x == -1]", but this is not
> > perfect clear, because x==-1 have second order. This equation actually
> > must have two same roots: [x == -1,x == -1].
>
> Use the roots command:
>
> sage: f = (x + 1)^2
> sage: f.roots()
> [(-1, 2)]
>
> The 2 is the multiplicity.
>
> 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: the set containing the empty set

2009-01-10 Thread William Stein

On Sat, Jan 10, 2009 at 9:22 AM, Jason Grout
 wrote:
>
> John H Palmieri wrote:
>> sage: timeit('set(S).issubset(set(T))')
>>
>> gives me very similar times to the first option (all(s in T for s in
>> S)).  So if I start with Sage sets, I don't seem to gain much by
>> converting back to python sets for this (not to mention that if S = Set
>> (ZZ), then set(S) runs into problems...).

The Sage enumerated Set type is just a light wrapper around Python's
"frozenset" type with more sage/mathematical semantics.  Just delegate
to that for implementing is_subset:

sage: X = Set([1..10])
sage: Y = Set([1..20])
sage: X._Set_object__object.issubset(Y._Set_object__object)
True
sage: Y._Set_object__object.issubset(X._Set_object__object)
False
sage: timeit('X._Set_object__object.issubset(Y._Set_object__object)')
625 loops, best of 3: 2.07 µs per loop
sage: X._Set_object__object
frozenset([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
sage: type(X)


In the actual code for is_subset, you'll have

self.__object

instead of self._Set_object__object, since of course the above example
uses the command line so __ methods are mangled.

The one interesting wrinkle will be doing, e.g.,

sage: X.is_subset(Set(ZZ))

where the Y = Set(ZZ) isn't an enumerated set.  There you have to
check each X for membership in Y.

 -- William

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: why doesn`t solve() give a proper answer

2009-01-10 Thread William Stein

On Fri, Jan 9, 2009 at 9:05 AM, William Stein  wrote:
> On Fri, Jan 9, 2009 at 9:01 AM, Robert Dodier  wrote:
>>
>> On Jan 9, 6:51 am, Slava  wrote:
>>
>>> I`m trying to solve such simple system of equations: [sqrt(x) == 1, x
>>> == y],
>>> so I type:
>>>
>>> x,y = var('x,y');
>>> solve([sqrt(x) == 1, x == y], x, y);
>>>
>>> the answer is: []
>>
>> If I understand correctly, Sage punts to Maxima to solve equations.
>> Maxima's built-in solver is not too strong. There is an add-on package
>> which can solve equations which contain radicals. Dunno how to call
>> it from Sage, but in Maxima itself it's like this:
>>
>> load (topoly_solver);
>> to_poly_solve ([sqrt(x) = 1, x = y], [x, y]);
>>  => [[x = 1, y = 1]]
>>
>> Maybe at some point in the not-too-distant future, the built-in
>> solver would call to_poly_solve automatically 

Robert,

Is there any reason not to just *always* use topoly_solver?  I.e.,
maybe Sage's solve should
just 100% always only call topoly_solver.  What do you think?

William

>
> That would be nice.  Here's doing the above in sage:
>
> sage: x,y=var('x,y')
> sage: v = [sqrt(x)==1, x==y]
> sage: w = maxima(v)
> sage: maxima.load('topoly_solver')
> sage: w.to_poly_solve([x,y])
> [[x=1,y=1]]
>
> There's currently no simple code in sage to turn the output of
> to_poly_solve into  native sage objects.
>
> William
>



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



[sage-support] Jumpy Notebook on Mac OS X

2009-01-10 Thread Justin C. Walker

Hi, all,

When using the Notebook interface on Mac OS X, I find that once the  
cells have filled the visible part of a web page, the notebook becomes  
somewhat difficult to deal with.  Specifically, if I have an  
@interact, and modify the slider, the content of the page shifts down,  
obscuring the output of the @interact.  The amount of shifting seems  
to depend on the amount of other cell space below the @interact output.

This is using Mac OS X, 10.5.6 and the version of Safari that comes  
with it.

I see the same behavior with FireFox 2.0 (latest version).

Is there some configuration foo that I'm missing?

Thanks!

Justin

--
Justin C. Walker, Curmudgeon at Large
Institute for the Absorption of Federal Funds
--
Democracy is two wolves and a lamb
voting on what to have for lunch.
Liberty is a well-armed lamb contesting
the vote.




--~--~-~--~~~---~--~~
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: why doesn`t solve() give a proper answer

2009-01-10 Thread Robert Dodier

William Stein wrote:

> Is there any reason not to just *always* use topoly_solver?  I.e.,
> maybe Sage's solve should just 100% always only call topoly_solver.
> What do you think?

to_poly_solve can only handle equations in polynomials and radicals,
while solve can handle a somewhat wider range of equations.
I guess one could invent heuristics -- e.g. try to_poly_solve first
and if it can't find anything then try solve.

Of course such heuristics could be applied within solve itself (and
there are already some in place to handle different kinds of
equations).
If you 'd like to press for modify solve to call to_poly_solve, then
I'll
encourage you to take it up on the Maxima mailing list.

Robert Dodier

--~--~-~--~~~---~--~~
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: Jumpy Notebook on Mac OS X

2009-01-10 Thread William Stein

On Sat, Jan 10, 2009 at 2:26 PM, Justin C. Walker  wrote:
>
> Hi, all,
>
> When using the Notebook interface on Mac OS X, I find that once the
> cells have filled the visible part of a web page, the notebook becomes
> somewhat difficult to deal with.  Specifically, if I have an
> @interact, and modify the slider, the content of the page shifts down,
> obscuring the output of the @interact.  The amount of shifting seems
> to depend on the amount of other cell space below the @interact output.
>
> This is using Mac OS X, 10.5.6 and the version of Safari that comes
> with it.
>
> I see the same behavior with FireFox 2.0 (latest version).
>
> Is there some configuration foo that I'm missing?

I wish.

For fun, you might try putting

return true;

at the top of the function cell_focus in the file
devel/sage/sage/server/notebook/js.py and rebuilding sage and
restarting the notebook (and refreshing your browser window).   All
jumping should then be entirely disabled.

What does it feel like?  Do you like it better?  Should this be a
trivial-to-set option?

I've done the above sometimes when giving talks.

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: Worsening of @interact auto-evaluate problems in 3.2.2?

2009-01-10 Thread JoelS

I've been having the same problem with both 3.2.2 and 3.2.3 on my
Intel MacBook running OS X.4.11.

-JoelS

kcrisman wrote:
> Dear Support,
>
> I built 3.2.2 and seem to have a worsening of the auto-evaluation of
> @interact worksheets.  Up to 3.2.1 the worksheets only autoevaluate
> interacts if I actually open them (the worksheets) up.  In 3.2.2 today
> they auto-evaluated for ALL my worksheets with @interact in them
> without opening (that is, the list of worksheets had all such sheets
> saying "running" for some reason).  That would be a lot of things to
> open just to interrupt them...
>
> This was a little unfortunate, because it meant rlmiller had to do his
> presentation for the MAA Panel session in reverse order while we
> switched computers.
>
> I don't know if this is reproducible - it may have been a once-off
> problem, something I somehow inadvertently broke (though I'm not sure
> what), or just my old OSX.4 PPC.  But I thought I would report it.
>
> The wifi here is spotty, so I don't have time to try it on sagenb or
> something, but if someone could check this out in 3.2.2 and/or 3.2.3
> on a few platforms I would appreciate it; if it's reproducible there I
> suggest this be logged as a blocker; it is a huge memory waste and
> time drain.
>
> Thanks,
> - kcrisman
--~--~-~--~~~---~--~~
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: Jumpy Notebook on Mac OS X

2009-01-10 Thread Jason Grout

Justin C. Walker wrote:
> Hi, all,
> 
> When using the Notebook interface on Mac OS X, I find that once the  
> cells have filled the visible part of a web page, the notebook becomes  
> somewhat difficult to deal with.  Specifically, if I have an  
> @interact, and modify the slider, the content of the page shifts down,  
> obscuring the output of the @interact.  The amount of shifting seems  
> to depend on the amount of other cell space below the @interact output.
> 
> This is using Mac OS X, 10.5.6 and the version of Safari that comes  
> with it.
> 
> I see the same behavior with FireFox 2.0 (latest version).
> 
> Is there some configuration foo that I'm missing?


This is a known problem and there is a trac ticket for it.  The problem 
is that the notebook height changes briefly when an interact is updated, 
which means that the browser automatically scrolls up, but then doesn't 
scroll back down.  A work-around is to create enough empty cells below 
the interact.  A better solution, noted on the trac ticket, is to make a 
div that is a screen high at the end of the notebook.  This would also 
allow you to have the last cell at the top of the screen, which would be 
very handy for presentations too.  At least MMA lets you scroll down so 
that the last cell is at the top of the screen.

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



[sage-support] Re: Jumpy Notebook on Mac OS X

2009-01-10 Thread Justin C. Walker


On Jan 10, 2009, at 15:48 , William Stein wrote:

>
> On Sat, Jan 10, 2009 at 2:26 PM, Justin C. Walker   
> wrote:
>>
>> Hi, all,
>>
>> When using the Notebook interface on Mac OS X, I find that once the
>> cells have filled the visible part of a web page, the notebook  
>> becomes
>> somewhat difficult to deal with.  Specifically, if I have an
>> @interact, and modify the slider, the content of the page shifts  
>> down,
>> obscuring the output of the @interact.  The amount of shifting seems
>> to depend on the amount of other cell space below the @interact  
>> output.
>>
>> This is using Mac OS X, 10.5.6 and the version of Safari that comes
>> with it.
>>
>> I see the same behavior with FireFox 2.0 (latest version).
>>
>> Is there some configuration foo that I'm missing?
>
> I wish.
>
> For fun, you might try putting
>
>return true;
>
> at the top of the function cell_focus in the file
> devel/sage/sage/server/notebook/js.py and rebuilding sage and
> restarting the notebook (and refreshing your browser window).

Did that.  The function is "cell_focus()", right?

>   All
> jumping should then be entirely disabled.

Boy I'll say.  Also disabled is the effect of SHIFT-RETURN in the  
cell: it now just inserts a CR and sits there.

Hmmm...

Justin

--
Justin C. Walker, Curmudgeon at Large
Institute for the Absorption of Federal Funds
---
I'm beginning to like the cut of his jibberish.
---




--~--~-~--~~~---~--~~
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: Jumpy Notebook on Mac OS X

2009-01-10 Thread Justin C. Walker


On Jan 10, 2009, at 16:26 , Jason Grout wrote:

>
> Justin C. Walker wrote:
>> Hi, all,
>>
>> When using the Notebook interface on Mac OS X, I find that once the
>> cells have filled the visible part of a web page, the notebook  
>> becomes
>> somewhat difficult to deal with.  Specifically, if I have an
>> @interact, and modify the slider, the content of the page shifts  
>> down,
>> obscuring the output of the @interact.  The amount of shifting seems
>> to depend on the amount of other cell space below the @interact  
>> output.
>>
>> This is using Mac OS X, 10.5.6 and the version of Safari that comes
>> with it.
>>
>> I see the same behavior with FireFox 2.0 (latest version).
>>
>> Is there some configuration foo that I'm missing?
>
>
> This is a known problem and there is a trac ticket for it.  The  
> problem
> is that the notebook height changes briefly when an interact is  
> updated,
> which means that the browser automatically scrolls up, but then  
> doesn't
> scroll back down.  A work-around is to create enough empty cells below
> the interact.  A better solution, noted on the trac ticket, is to  
> make a
> div that is a screen high at the end of the notebook.  This would also
> allow you to have the last cell at the top of the screen, which  
> would be
> very handy for presentations too.  At least MMA lets you scroll down  
> so
> that the last cell is at the top of the screen.

What's the Trac #?  I searched Trac before posting, but I didn't find  
anything that seemed pertinent.

Justin

--
Justin C. Walker, Curmudgeon at Large
Institute for the Absorption of Federal Funds
---
I'm beginning to like the cut of his jibberish.
---




--~--~-~--~~~---~--~~
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: Jumpy Notebook on Mac OS X

2009-01-10 Thread William Stein

On Sat, Jan 10, 2009 at 4:26 PM, Jason Grout
 wrote:
>
> Justin C. Walker wrote:
>> Hi, all,
>>
>> When using the Notebook interface on Mac OS X, I find that once the
>> cells have filled the visible part of a web page, the notebook becomes
>> somewhat difficult to deal with.  Specifically, if I have an
>> @interact, and modify the slider, the content of the page shifts down,
>> obscuring the output of the @interact.  The amount of shifting seems
>> to depend on the amount of other cell space below the @interact output.
>>
>> This is using Mac OS X, 10.5.6 and the version of Safari that comes
>> with it.
>>
>> I see the same behavior with FireFox 2.0 (latest version).
>>
>> Is there some configuration foo that I'm missing?
>
>
> This is a known problem and there is a trac ticket for it.  The problem
> is that the notebook height changes briefly when an interact is updated,
> which means that the browser automatically scrolls up, but then doesn't
> scroll back down.  A work-around is to create enough empty cells below
> the interact.  A better solution, noted on the trac ticket, is to make a
> div that is a screen high at the end of the notebook.  This would also
> allow you to have the last cell at the top of the screen, which would be
> very handy for presentations too.  At least MMA lets you scroll down so
> that the last cell is at the top of the screen.

This sounds much more relevant to the issue at hand than the suggestion
I made.  Thanks Jason.

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: Jumpy Notebook on Mac OS X

2009-01-10 Thread Jason Grout

Justin C. Walker wrote:
> 
> On Jan 10, 2009, at 16:26 , Jason Grout wrote:
> 
>> Justin C. Walker wrote:
>>> Hi, all,
>>>
>>> When using the Notebook interface on Mac OS X, I find that once the
>>> cells have filled the visible part of a web page, the notebook  
>>> becomes
>>> somewhat difficult to deal with.  Specifically, if I have an
>>> @interact, and modify the slider, the content of the page shifts  
>>> down,
>>> obscuring the output of the @interact.  The amount of shifting seems
>>> to depend on the amount of other cell space below the @interact  
>>> output.
>>>
>>> This is using Mac OS X, 10.5.6 and the version of Safari that comes
>>> with it.
>>>
>>> I see the same behavior with FireFox 2.0 (latest version).
>>>
>>> Is there some configuration foo that I'm missing?
>>
>> This is a known problem and there is a trac ticket for it.  The  
>> problem
>> is that the notebook height changes briefly when an interact is  
>> updated,
>> which means that the browser automatically scrolls up, but then  
>> doesn't
>> scroll back down.  A work-around is to create enough empty cells below
>> the interact.  A better solution, noted on the trac ticket, is to  
>> make a
>> div that is a screen high at the end of the notebook.  This would also
>> allow you to have the last cell at the top of the screen, which  
>> would be
>> very handy for presentations too.  At least MMA lets you scroll down  
>> so
>> that the last cell is at the top of the screen.
> 
> What's the Trac #?  I searched Trac before posting, but I didn't find  
> anything that seemed pertinent.


I was just searching trac too.  I can't find anything.  The mailing list 
discussion is here, though (I found this by searching sage-devel for 
"interact jump"):

http://groups.google.com/group/sage-devel/browse_thread/thread/51b538c8212fa2a/b61655921eb0ebab

 From the discussion, it looks like a trac ticket never was created (I 
thought one was).  I just created #4963 for it.  If this doesn't get 
done by SD12, I'll try to do it then.

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



[sage-support] Re: Jumpy Notebook on Mac OS X

2009-01-10 Thread Jason Grout

William Stein wrote:
> On Sat, Jan 10, 2009 at 4:26 PM, Jason Grout
>  wrote:
>> Justin C. Walker wrote:
>>> Hi, all,
>>>
>>> When using the Notebook interface on Mac OS X, I find that once the
>>> cells have filled the visible part of a web page, the notebook becomes
>>> somewhat difficult to deal with.  Specifically, if I have an
>>> @interact, and modify the slider, the content of the page shifts down,
>>> obscuring the output of the @interact.  The amount of shifting seems
>>> to depend on the amount of other cell space below the @interact output.
>>>
>>> This is using Mac OS X, 10.5.6 and the version of Safari that comes
>>> with it.
>>>
>>> I see the same behavior with FireFox 2.0 (latest version).
>>>
>>> Is there some configuration foo that I'm missing?
>>
>> This is a known problem and there is a trac ticket for it.  The problem
>> is that the notebook height changes briefly when an interact is updated,
>> which means that the browser automatically scrolls up, but then doesn't
>> scroll back down.  A work-around is to create enough empty cells below
>> the interact.  A better solution, noted on the trac ticket, is to make a
>> div that is a screen high at the end of the notebook.  This would also
>> allow you to have the last cell at the top of the screen, which would be
>> very handy for presentations too.  At least MMA lets you scroll down so
>> that the last cell is at the top of the screen.
> 
> This sounds much more relevant to the issue at hand than the suggestion
> I made.  Thanks Jason.


No problem.  I spent some time debugging this a few months ago, but 
never did anything about it.  Marshall, if you're reading this, this 
would make a great project for your student if he wants to learn more 
about html and contribute something quickly.

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



[sage-support] Having difficulty using polyfit function

2009-01-10 Thread slybro

I am having trouble using the polyfit function.  Here are the
commands:

import numpy as np
import scipy as sc

vp = np.array([1.0, 5.0, 10.0, 20.0, 40.0, 60.0, 100.0, 200.0, 400.0,
760.0])

T = np.array([-36.7, -19.6, -11.5, -2.6, 7.6, 15.4, 26.1, 42.2, 60.6,
80.1])

(a,b,c,d) = np.polyfit(vp,T,3)

and I get the following error message which I don't understand.

Traceback (most recent call last):
  File "", line 1, in 
  File "/home/notebook/sage_notebook/worksheets/admin/7/code/7.py",
line 7, in 
(a,b,c,d) = np.polyfit(vp,T,_sage_const_3 )
  File "/usr/local/sage/local/lib/python2.5/site-packages/
zope.interface-3.3.0-py2.5-linux-i686.egg/", line 1, in 

  File "/usr/local/sage/local/lib/python2.5/site-packages/numpy/lib/
polynomial.py", line 493, in polyfit
rcond = len(x)*finfo(x.dtype).eps
  File "/usr/local/sage/local/lib/python2.5/site-packages/numpy/lib/
getlimits.py", line 98, in __new__
raise ValueError, "data type %r not inexact" % (dtype)
ValueError: data type  not inexact

I have checked www.scipy.org with the associated documentation, the
sage help documentation, the numpy docs and it appears that I am using
the function correctly.  I'm stumped...  I'm interested in developing
an online class using sage for chemical engineering calculations.
Thanks.

--~--~-~--~~~---~--~~
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: Having difficulty using polyfit function

2009-01-10 Thread Mike Hansen

Hello,

On Sat, Jan 10, 2009 at 8:29 PM, slybro  wrote:
>
> I am having trouble using the polyfit function.  Here are the
> commands:
>
> import numpy as np
> import scipy as sc
>
> vp = np.array([1.0, 5.0, 10.0, 20.0, 40.0, 60.0, 100.0, 200.0, 400.0,
> 760.0])
>
> T = np.array([-36.7, -19.6, -11.5, -2.6, 7.6, 15.4, 26.1, 42.2, 60.6,
> 80.1])
>
> (a,b,c,d) = np.polyfit(vp,T,3)

You must explicitly make the Numpy array's have dtype float as numpy
does not automatically convert Sage's RealNumber to a float.  If you
don't do this, the array's dtype will be "object'.

sage: vp = np.array([1.0, 5.0, 10.0, 20.0, 40.0, 60.0, 100.0, 200.0,
400.0, 760.0],dtype=float)
sage: T = np.array([-36.7, -19.6, -11.5, -2.6, 7.6, 15.4, 26.1, 42.2,
60.6, 80.1], dtype=float)
sage: np.polyfit(vp,T,3)
array([  1.13148994e-06,  -1.49004659e-03,   6.12784745e-01,
-2.13934587e+01])

There are other ways to achieve a similar effect such as turning off
the Sage preparser with "preparser(False)" or making Sage's RealNumber
an alias of float ("RealNumber = float").

--Mike

--~--~-~--~~~---~--~~
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: Having difficulty using polyfit function

2009-01-10 Thread Jason Grout

slybro wrote:
> I am having trouble using the polyfit function.  Here are the
> commands:
> 
> import numpy as np
> import scipy as sc
> 
> vp = np.array([1.0, 5.0, 10.0, 20.0, 40.0, 60.0, 100.0, 200.0, 400.0,
> 760.0])
> 
> T = np.array([-36.7, -19.6, -11.5, -2.6, 7.6, 15.4, 26.1, 42.2, 60.6,
> 80.1])
> 
> (a,b,c,d) = np.polyfit(vp,T,3)
> 
> and I get the following error message which I don't understand.
> 


I'm pretty sure this has to do with Sage giving you the sage floating 
point numbers by default.  Your example seems to work if you declare 
your arrays like:



vp = np.array([1.0, 5.0, 10.0, 20.0, 40.0, 60.0, 100.0, 200.0, 
400.0,760.0],dtype=float)
T = np.array([-36.7, -19.6, -11.5, -2.6, 7.6, 15.4, 26.1, 42.2, 60.6,
80.1],dtype=float)

The "dtype" at the end makes sure that the numbers are python floating 
point numbers, rather than Sage floating point numbers.

Thanks,

Jason

















> Traceback (most recent call last):
>   File "", line 1, in 
>   File "/home/notebook/sage_notebook/worksheets/admin/7/code/7.py",
> line 7, in 
> (a,b,c,d) = np.polyfit(vp,T,_sage_const_3 )
>   File "/usr/local/sage/local/lib/python2.5/site-packages/
> zope.interface-3.3.0-py2.5-linux-i686.egg/", line 1, in 
> 
>   File "/usr/local/sage/local/lib/python2.5/site-packages/numpy/lib/
> polynomial.py", line 493, in polyfit
> rcond = len(x)*finfo(x.dtype).eps
>   File "/usr/local/sage/local/lib/python2.5/site-packages/numpy/lib/
> getlimits.py", line 98, in __new__
> raise ValueError, "data type %r not inexact" % (dtype)
> ValueError: data type  not inexact
> 
> I have checked www.scipy.org with the associated documentation, the
> sage help documentation, the numpy docs and it appears that I am using
> the function correctly.  I'm stumped...  I'm interested in developing
> an online class using sage for chemical engineering calculations.
> Thanks.
> 
> > 
> 


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