Adds incremental module creator to magic #883
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The idea is simple. Allow one to build up a module easily and quickly. This is useful when explaining a concept.
Example use:
The idea is that you can partition creating a module over multiple cells. The ONLY CAVEAT is that you maintain a unique identifier (int or string) for each cell so that they can are distinct; i.e. it's possible to override an earlier cell if you use the same identifier. Note: we use the sorted set of identifiers and build the module up in order of that. This is probably an unused feature, since we expect most people to logically increment the identifier and order things correctly top to bottom.
There are some utility methods to help reset state. Otherwise I duplicate some logic, since it wasn't easy to refactor. I centralized logic where it made sense.
Changes
incr_cell_to_module
cell magic.print_module
line magic to print what's createdreset_module
line magic to reset an incremental module.How I tested this
Notes
Checklist