Post-tutorial thoughts

6 views
Skip to first unread message

Pat LeSmithe

unread,
Mar 6, 2009, 4:44:58 PM3/6/09
to sage-...@googlegroups.com

Hello,

I recently finished the tutorial for Sage 3.2.3 and had a few questions,
comments, and suggestions that I've rolled into one easy-to-delete post. :)

My field is not mathematics, but most of my thoughts below relate to the
user experience in Sage. Some are simply requests for [pointers to
and/or improvements upon] features that I have found useful in MapLABica
[1] and similar programs. Others are specific to Sage's original
approach to mathematical software.

A quick disclaimer: Sage is still very new to me, so my thoughts are
born largely of naivete. In particular, I have minimal exposure to the
changes in v3.3 and none to v3.4.*. Further, I don't claim any
originality. Also, the classification below is rough.


HELP

* How about adding a Google-style search box in the notebook interface?
Pressing tab after "command?", which is definitely useful, doesn't
always work well, because it can interrupt the flow of a worksheet. For
example, if I decide not to use the command there, or if I wish to
evaluate the cell first, then I need to erase what I just typed.
Similarly, if I used a new cell for the search, it often gets in the
way, etc.
With a search box, operator keywords (e.g., doc:, example:) could offer
complex queries without adding or modifying a cell. Or a pull down menu
could select among search_*(). I'm not sure where the box itself should
go, but it would be nice not to have to scroll to use it. Perhaps it
can float in a corner, or appear to the right of the "evaluate" which
appears below the most recently active input cell. Optionally, the box
could replace "evaluate".
If remote access is OK, and instant indexing is not essential, then
there is Google Custom Search, which is free and ad-free for non-profit
and educational sites, apparently:

http://www.google.com/support/customsearch/bin/answer.py?answer=70354&topic=11497

By the way, it could just be time for me to upgrade my machine, but it
seems that recent results from search_*() are not cached. This might be
important in server settings or to individuals who do a lot of searching.

* [How about adding] A frame-based "Help Browser" which opens in its own
tab. [?]

* "Close" buttons on help popups. Perhaps also a "Move to a new tab" or
"Move to Help Browser" button.

* Scrollbars for very long help pop-ups and/or an option which tells
search_*() to open/reuse a tab or jump to a Help Browser tab. For the
Sage console, an analogue of R's help.start() could fire up a web browser.

* Tab completion for help on operators: *?, //?, etc.

* Just as clicking to the left of an output cell can hide it, a similar
feature could be useful for long pop-up docs, with extended examples and
TESTS available but hidden by default.

* It would be great if the documentation had a "SEE ALSO" section.

Please note: I'm not familiar with the ReST transition, which may
already address some or all of these.


LAYOUT

* Is there a shorthand for "print" besides "def p(d): print d"? Even
something like "%print", a sort of cell-local verbose setting?

* A check box for typeset output is missing in the interactive tutorial,
at least for v3.2.3.

* A shortcut for inserting a new cell below the current cell, without
evaluating the current cell. I think this is already somewhere on Trac.
It may not be practical in the notebook, but I miss Maple's Control-j/k
for inserting new lines of input.

* Evaluating a cell at the bottom edge of worksheet tab/window should
[optionally] scroll down more than just to the bottom edge of the next
cell. Also, a help pop-up down here is initially almost completely hidden.

* Optionally, automatically "transpose" tall-and-narrow output, e.g.,
from Somematrixgroup.conjugacy_class_representatives(), and use a
horizontal scrollbar in the cell to save [vertical] space.

* An option to suppress "evaluate" under input cells.

* Are there already scripts which can generate custom stylesheets for
Sage? Or can we easily use the output from jQuery's UI ThemeRoller:

http://www.themeroller.com/ ?

Given the complexity of CSS, my hope here is to convert a smallish set
of input parameters --- a few base colors, say, plus a bit of color
theory, if it helps --- into an approximately usable color scheme.
Ultimately, this could make it easier to add a school's emblem and
colors to the notebook ("rebrand"). There is a related Trac ticket:

http://trac.sagemath.org/sage_trac/ticket/3733

* A quick note about v3.3's TinyMCE @ sagenb.org: It's great! I use a
Minimum Font Size of 18 in Firefox, which makes the text in the
Paragraph, Font family, and Font size pull-downs too large. Perhaps
there is a way for TinyMCE to override my browser's setting,
selectively. This is not a big deal, although it is irksome that so
many high-traffic sites don't accommodate such departures from their
norm. No problems with sagemath.org!


META

* Take the conjugate-transpose of a matrix using ', as in MATLAB.
Pre-parse?

* A Sage "map()" which works quickly and transparently for functions and
operators on sequences of general structures? For example, there's a
recent thread on reusing solutions in functions:

http://groups.google.com/group/sage-devel/browse_thread/thread/9767e3a8d538438d/26f9ebe8dc72e58d#26f9ebe8dc72e58d


Another possibility:

sage: var('x y')
sage: sol = solve([x + y^2 == 6, x^2 - y == 4], x, y)
sage: f = 2*x + y
sage: map(lambda s: f(s[0].rhs(), s[1].rhs()), sol)

More generally,

sage: def apply_func_to_sols(func, sols):
... return map(lambda x: func(*x), [[s.rhs() for s in t] for t in
sols])
sage: apply_func_to_sols(f, sol)

Alternatively,

sage: def rhs(eq): return eq.rhs()
sage: [f(*map(rhs, s)) for s in sol]

I hope that's right. Either way, this seems slow. Is it mostly because
of Maxima or unoptimized tail recursion, or both? Probably, there are
better ways to do it in Sage/Python, with iterators/generators, but the
functional way is fun. How about Cython?
I'm not sure if it's still there, but there is/was public notebook with
the code above at

http://www.sagenb.org/home/pub/328/

* User-defined or simply more "%" modes, particularly for implicit
computation within structures. For instance, %integermodring(23) at the
top of a cell could tell Sage to use mod-23 arithmetic in the cell,
except where explicitly indicated otherwise.

* How to "forget" a specific assignment, e.g., y = 3, especially if it's
big, without restarting?

I apologize if there's too much "Wouldn't it be great if...?" here, but
I think some of these issues are relevant for Sage gaining acceptance
more quickly among the wider scientific and educational communities.
And when Sage becomes sentient, watch out! We already know the answer [2].

Thanks!

[1] Sorry.
[2] 42.

Sincerely,
Pat LeSmithe


Carl Witty

unread,
Mar 6, 2009, 5:12:20 PM3/6/09
to sage-...@googlegroups.com
I'm only going to comment on a couple of points here (mostly because I
never use the notebook).

On Fri, Mar 6, 2009 at 1:44 PM, Pat LeSmithe <qed...@gmail.com> wrote:
> * Take the conjugate-transpose of a matrix using ', as in MATLAB.
> Pre-parse?

Sounds tricky to combine with Python's string syntax, which can also use '.
(Probably it technically wouldn't conflict, because a string can't
appear in a postfix-operator position.)

> * A Sage "map()" which works quickly and transparently for functions and
> operators on sequences of general structures?

Sounds like a good idea.

> * User-defined or simply more "%" modes, particularly for implicit
> computation within structures.  For instance, %integermodring(23) at the
> top of a cell could tell Sage to use mod-23 arithmetic in the cell,
> except where explicitly indicated otherwise.

Interesting idea. You can probably emulate this example by putting:
Integer = Integers(23)
at the beginning of your cell, and
reset('Integer')
at the end. (This works at the command line; I haven't tested it in
the notebook.)

> * How to "forget" a specific assignment, e.g., y = 3, especially if it's
> big, without restarting?

reset('y')

Carl

William Stein

unread,
Mar 6, 2009, 8:37:48 PM3/6/09
to sage-...@googlegroups.com
If you paste this input an input cell and press shift-enter, then
Sage will do *exactly* what you requested, i.e., %integermodring(23)
will work!

class integermodring:
def __init__(self, modulus):
self.modulus = modulus
def eval(self, s, globals, locals):
_temp = locals['Integer']
locals['Integer'] = IntegerModRing(self.modulus)
ans = python.eval(preparse(s), globals, locals)
locals['Integer'] = _temp
return ans

Cool, eh?


>> * How to "forget" a specific assignment, e.g., y = 3, especially if it's
>> big, without restarting?
>
> reset('y')
>
> Carl
>
> >
>



--
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org
Reply all
Reply to author
Forward
0 new messages