%reload_ext rubberize
from rubberize import configRendering Code
Note
Documentation pages are generated using actual notebook cells, so in the succeeding pages you will see setup cells like these:
When a %%tap cell is executed, Rubberize analyzes the Python code and generates an equivalent mathematical notation for each statement or expression it finds.
%%tap
import math
r = 10 # Radius
A = math.pi * r**2 # Area\( \displaystyle r = 10 \)
Radius
\( \displaystyle A = \pi\,r^{2} = \pi \cdot 10^{2} = 314.16 \)
Area
Rubberize does not change how Python executes. The original code still runs normally, and variables remain available for later cells. Rendering simply provides a mathematical view of the code.
Topics in this Chapter
The following sections in this chapter describe how specific Python constructs are rendered.
Expressions
Statements
Miscellaneous
Supported Features
The table below summarizes Python constructs that are supported by Rubberize.
Expressions
| Feature | Support |
|---|---|
| Identifier names | Yes |
| Attribute access | Yes |
int |
Yes |
float |
Yes |
complex |
Yes |
list |
Yes |
list comprehensions |
Yes |
list subscript access |
Yes |
list slices |
Yes |
tuple |
Yes |
tuple subscript access |
Yes |
tuple slices |
Yes |
set |
Yes |
set comprehensions |
Yes |
dict |
Yes |
dict comprehensions |
Yes |
dict subscript access |
Yes |
str |
Yes |
| f-strings | No |
| Feature | Support |
|---|---|
| Formatting field in an f-string | No |
Boolean (True and False) |
Yes |
None |
Yes |
range |
Yes |
Ellipsis (...) |
Yes |
| Calls | Yes |
| Binary operations | Yes |
| Unary operations | Yes |
| Comparisons | Yes |
| Logical operations | Yes |
| Conditional expressions | Yes |
| Named expressions | Yes |
lambda functions |
Yes |
| Generator expressions | Yes |
| Starred expressions | Yes |
| Await | No |
| Yield | No |
| Yield from | No |
In addition to built-in features, the following constructs from other libraries are also supported
Statements
| Feature | Support |
|---|---|
| Expressions | Yes |
| Assignments | Yes |
| Augmented assignments | No |
| Annotated assignments | Ignored |
if |
Yes |
def |
Yes |
async def |
No |
class |
No |
return |
Partially (see def) |
del |
No |
type |
No |
for |
No |
async for |
No |
| Feature | Support |
|---|---|
while |
No |
with |
No |
async with |
No |
match |
No |
raise |
No |
try |
No |
assert |
No |
import |
Ignored |
global |
No |
nonlocal |
No |
pass |
No |
break |
No |
continue |
No |