Welcome to Cadabra Q&A, where you can ask questions and receive answers from other members of the community.
+1 vote

Hi Folks,

I'm really enjoying the use of zoom/unzoom -- it's very useful for fine scale tinkering of expressions. I do have one query. When I call zoom more than once on an expression I find that a single call to unzoom resets the scope back to the full expression. I would have expected each call to unzoom to undo the action of its matching zoom. Is this the intended behaviour?

Cheers, Leo

in General questions by (1.8k points)

2 Answers

+2 votes
 
Best answer

At the moment this is the expected behaviour. What happens under the hood is that the hidden parts of the expression get wrapped in a \ldots{ } construction, and all algorithms simply step over these. You can see this by calling print(tree(ex)) on which you have done one or more zoom operations.

As these \ldots{ } nodes of the expression tree do not contain any information about when they were generated, all that unzoom can do is to unwrap them all. What would make sense is to make zoom automatically add another \ldots{ } around each existing one. Good suggestion, I'll see what I can do for 2.2.8 (we're heading for another Easter Bunny release soon).

by (82.6k points)
selected by

Hi Kasper,

Thanks for the quick reply and for the explanation. Now I understand (and looking forward to the Easter Bunny :).

Cheers, Leo

+1 vote

The easter bunny is early this year: the version now on github does unzoom step by step, except when you give it the repeat=True parameter, in which it unzooms all the way to the original expression. Let me know if you run into any issues.

by (82.6k points)

Hi Kasper,

I just had a visit from the Ester Bunny and it's smiles all around -- the changes work exactly as you described them. Many thanks for this.

Cheers, Leo

...