mathics / IMathics

Jupyter Kernel for Mathics
20 stars 8 forks source link

example notebook with Manipulate #10

Closed sn6uv closed 8 years ago

sn6uv commented 8 years ago

Since there's currently no way to test this feature I think we should add a notebook example that can be tested manually.

sn6uv commented 8 years ago

@poke1024, does this capture all of the behaviour?

poke1024 commented 8 years ago

All the important stuff is there. Here's what could still be described in some way or another to document the current behavior:

Default values

Two examples for defaults: Manipulate[x, {{x, 0.7}, -1, 1}] Manipulate[i, {{i, b}, {a, b, c}}]

In this context, we could give examples for limiting the default:

Manipulate[x, {{x, 2}, 0, 1}] Defaults are automatically limited to the given range

Manipulate[i, {{i, c}, {a, b}}] Illegal defaults for discrete options are simply ignored

Labels

The labels example should probably use a label like this: Manipulate[Limit[Sin[k x] / x, x -> 0, i], {k, 0, 2}, {{i, -1, direction}, {-1, 1}}]

While testing this, I found a bug in the current implementation that completely breaks labels and the example just above. I fixed it in https://github.com/poke1024/Mathics/tree/manipulate (along with a much better error handling, since I, again, ran into Jupyter configuration hell, and another change in preparation to changes in Jupyter 5 I ran across recently that basically removes direct access to a magic variable). @sn6uv, I didn't find the manipulate branch you used to push this stuff into the repo, so I'm not sure how to push this change.

Integer vs. Float

A subtle thing worth noting in the example notebook might be Manipulate's usage of float and integers.

Manipulate[x, {x, 0, 1}] gives 0. (a floating point real)

whereas

Manipulate[x, {x, 0, 1, 1}] gives 0 (an integer)

The latter case happens when interval limits and step size are all integers. It's basically what you expect when you use this variable as an integer index into a list.

Error handling / continuous

Manipulate[x, {x, 0, 1, 2}] The step size must not be larger than the interval

sn6uv commented 8 years ago

I've opened mathics/Mathics/pull/379 to fix the errors. Thanks for the examples, I'll test then add them.