pdit 0.1.0__tar.gz → 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. {pdit-0.1.0 → pdit-0.2.0}/PKG-INFO +25 -10
  2. {pdit-0.1.0 → pdit-0.2.0}/README.md +20 -4
  3. pdit-0.2.0/pdit/_demo.py +103 -0
  4. pdit-0.1.0/pdit/_static/assets/index-BkEyY6gm.js → pdit-0.2.0/pdit/_static/assets/index-10OgdOl0.js +37 -37
  5. pdit-0.2.0/pdit/_static/assets/index-C5r-TK5N.css +1 -0
  6. {pdit-0.1.0 → pdit-0.2.0}/pdit/_static/export.html +1 -1
  7. {pdit-0.1.0 → pdit-0.2.0}/pdit/_static/index.html +2 -2
  8. {pdit-0.1.0 → pdit-0.2.0}/pdit/cli.py +50 -1
  9. {pdit-0.1.0 → pdit-0.2.0}/pdit.egg-info/PKG-INFO +25 -10
  10. {pdit-0.1.0 → pdit-0.2.0}/pdit.egg-info/SOURCES.txt +3 -2
  11. {pdit-0.1.0 → pdit-0.2.0}/pdit.egg-info/requires.txt +1 -2
  12. {pdit-0.1.0 → pdit-0.2.0}/pyproject.toml +2 -3
  13. pdit-0.1.0/pdit/_static/assets/index-DxOOJTA1.css +0 -1
  14. {pdit-0.1.0 → pdit-0.2.0}/MANIFEST.in +0 -0
  15. {pdit-0.1.0 → pdit-0.2.0}/pdit/__init__.py +0 -0
  16. {pdit-0.1.0 → pdit-0.2.0}/pdit/exporter.py +0 -0
  17. {pdit-0.1.0 → pdit-0.2.0}/pdit/file_watcher.py +0 -0
  18. {pdit-0.1.0 → pdit-0.2.0}/pdit/ipython_executor.py +0 -0
  19. {pdit-0.1.0 → pdit-0.2.0}/pdit/server.py +0 -0
  20. {pdit-0.1.0 → pdit-0.2.0}/pdit.egg-info/dependency_links.txt +0 -0
  21. {pdit-0.1.0 → pdit-0.2.0}/pdit.egg-info/entry_points.txt +0 -0
  22. {pdit-0.1.0 → pdit-0.2.0}/pdit.egg-info/top_level.txt +0 -0
  23. {pdit-0.1.0 → pdit-0.2.0}/setup.cfg +0 -0
  24. {pdit-0.1.0 → pdit-0.2.0}/tests/test_file_watcher.py +0 -0
  25. {pdit-0.1.0 → pdit-0.2.0}/tests/test_ipython_executor.py +0 -0
  26. {pdit-0.1.0 → pdit-0.2.0}/tests/test_local_import.py +0 -0
  27. {pdit-0.1.0 → pdit-0.2.0}/tests/test_server.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pdit
3
- Version: 0.1.0
3
+ Version: 0.2.0
4
4
  Summary: Interactive Python code editor with inline execution results
5
5
  Author: Harry Vangberg
6
6
  License: Private
@@ -26,11 +26,10 @@ Requires-Dist: jupyter_client>=8.0.0
26
26
  Requires-Dist: ipykernel>=6.29.0
27
27
  Requires-Dist: itables>=2.6.1
28
28
  Requires-Dist: ipython>=8.18.1
29
- Provides-Extra: examples
30
- Requires-Dist: great-tables>=0.20.0; extra == "examples"
31
- Requires-Dist: matplotlib>=3.7.5; extra == "examples"
32
- Requires-Dist: pandas>=2.0.3; extra == "examples"
33
- Requires-Dist: polars>=1.8.2; extra == "examples"
29
+ Provides-Extra: demo
30
+ Requires-Dist: great-tables>=0.20.0; extra == "demo"
31
+ Requires-Dist: matplotlib>=3.7.5; extra == "demo"
32
+ Requires-Dist: polars>=1.8.2; extra == "demo"
34
33
 
35
34
  # pdit
36
35
 
@@ -42,6 +41,7 @@ pdit lets you write regular Python files and see execution results inline, like
42
41
 
43
42
  ```bash
44
43
  pip install pdit
44
+ pdit --demo
45
45
  pdit script.py
46
46
  ```
47
47
 
@@ -80,18 +80,29 @@ Pandas and Polars DataFrames render as interactive tables automatically.
80
80
 
81
81
  ### Plots
82
82
 
83
- Matplotlib figures display inline. Call `plt.show()`.
83
+ Matplotlib figures display inline. Call `plt.show()`. To avoid every
84
+ `plt.*` call emitting a plot, wrap plot creation in `with plt.ioff():` and
85
+ call `plt.show()` when you're ready.
86
+
87
+ ```python
88
+ import matplotlib.pyplot as plt
89
+
90
+ with plt.ioff():
91
+ plt.figure()
92
+ plt.plot(x, y)
93
+ plt.show()
94
+ ```
84
95
 
85
96
  ## Installation
86
97
 
87
98
  For development installs or running from source, use [uv](https://github.com/astral-sh/uv).
88
99
 
89
100
  ```bash
90
- # Install from dist branch (recommended, includes pre-built assets)
91
- uv add git+https://github.com/vangberg/pdit@dist
101
+ # Install from PyPI
102
+ uv add pdit
92
103
 
93
104
  # Or use directly with uvx
94
- uvx --from git+https://github.com/vangberg/pdit@dist pdit script.py
105
+ uvx pdit script.py
95
106
 
96
107
  # From cloned repo (for development)
97
108
  git clone git@github.com:vangberg/pdit.git
@@ -125,6 +136,7 @@ uv run pdit script.py
125
136
  pdit [OPTIONS] [SCRIPT]
126
137
 
127
138
  Options:
139
+ --demo Open the bundled demo script
128
140
  --port INTEGER Port to run server on (default: 8888)
129
141
  --host TEXT Host to bind to (default: 127.0.0.1)
130
142
  --no-browser Don't open browser automatically
@@ -137,6 +149,9 @@ Options:
137
149
  # Start with script
138
150
  pdit analysis.py
139
151
 
152
+ # Start with the bundled demo script
153
+ pdit --demo
154
+
140
155
  # Custom port
141
156
  pdit --port 9000 script.py
142
157
 
@@ -8,6 +8,7 @@ pdit lets you write regular Python files and see execution results inline, like
8
8
 
9
9
  ```bash
10
10
  pip install pdit
11
+ pdit --demo
11
12
  pdit script.py
12
13
  ```
13
14
 
@@ -46,18 +47,29 @@ Pandas and Polars DataFrames render as interactive tables automatically.
46
47
 
47
48
  ### Plots
48
49
 
49
- Matplotlib figures display inline. Call `plt.show()`.
50
+ Matplotlib figures display inline. Call `plt.show()`. To avoid every
51
+ `plt.*` call emitting a plot, wrap plot creation in `with plt.ioff():` and
52
+ call `plt.show()` when you're ready.
53
+
54
+ ```python
55
+ import matplotlib.pyplot as plt
56
+
57
+ with plt.ioff():
58
+ plt.figure()
59
+ plt.plot(x, y)
60
+ plt.show()
61
+ ```
50
62
 
51
63
  ## Installation
52
64
 
53
65
  For development installs or running from source, use [uv](https://github.com/astral-sh/uv).
54
66
 
55
67
  ```bash
56
- # Install from dist branch (recommended, includes pre-built assets)
57
- uv add git+https://github.com/vangberg/pdit@dist
68
+ # Install from PyPI
69
+ uv add pdit
58
70
 
59
71
  # Or use directly with uvx
60
- uvx --from git+https://github.com/vangberg/pdit@dist pdit script.py
72
+ uvx pdit script.py
61
73
 
62
74
  # From cloned repo (for development)
63
75
  git clone git@github.com:vangberg/pdit.git
@@ -91,6 +103,7 @@ uv run pdit script.py
91
103
  pdit [OPTIONS] [SCRIPT]
92
104
 
93
105
  Options:
106
+ --demo Open the bundled demo script
94
107
  --port INTEGER Port to run server on (default: 8888)
95
108
  --host TEXT Host to bind to (default: 127.0.0.1)
96
109
  --no-browser Don't open browser automatically
@@ -103,6 +116,9 @@ Options:
103
116
  # Start with script
104
117
  pdit analysis.py
105
118
 
119
+ # Start with the bundled demo script
120
+ pdit --demo
121
+
106
122
  # Custom port
107
123
  pdit --port 9000 script.py
108
124
 
@@ -0,0 +1,103 @@
1
+ """
2
+ # Markdown
3
+
4
+ Top-level strings are _rendered_ as [Markdown](https://en.wikipedia.org/wiki/Markdown).
5
+ """
6
+
7
+ """
8
+ ## Expressions
9
+ """
10
+
11
+ 1 + 2
12
+
13
+ [x * 2 for x in [1, 2, 3]]
14
+
15
+ """
16
+ ## Matplotlib
17
+ """
18
+
19
+ import math
20
+ import matplotlib.pyplot as plt
21
+
22
+ x = [i * 0.1 for i in range(0, 63)]
23
+ y = [math.sin(v) for v in x]
24
+
25
+ # Wrap in `with plt.ioff():` to avoid every call to `plt.*` rendering a
26
+ # plot.
27
+ with plt.ioff():
28
+ plt.figure()
29
+ plt.plot(x, y)
30
+ plt.xlabel('x')
31
+ plt.ylabel('sin(x)')
32
+ plt.show()
33
+
34
+ """
35
+ ## Polars/Pandas
36
+
37
+ DataFrames are rendered as interactive tables.
38
+ """
39
+
40
+ import polars as pl
41
+
42
+ df = pl.read_csv("https://raw.githubusercontent.com/mwaskom/seaborn-data/master/iris.csv")
43
+ df
44
+
45
+ """
46
+ ## GreatTables
47
+
48
+ [GreatTables](https://posit-dev.github.io/great-tables/) renders rich HTML tables.
49
+ """
50
+
51
+ from great_tables import GT
52
+
53
+ GT(df.head(5))
54
+
55
+ """
56
+ ## HTML representation
57
+
58
+ Classes that implement a `_repr_html_()` function returning HTML are rendered
59
+ as HTML.
60
+ """
61
+
62
+ class IrisSummary:
63
+ def __init__(self, df: pl.DataFrame):
64
+ self.df = df
65
+
66
+ def _repr_html_(self) -> str:
67
+ summary = (
68
+ self.df.group_by("species")
69
+ .agg(pl.col("sepal_length").mean().round(2).alias("mean"))
70
+ .sort("mean", descending=True)
71
+ )
72
+ max_mean = float(summary["mean"].max())
73
+ rows = "".join(
74
+ "<tr>"
75
+ f"<td style='padding-right:8px'>{species}</td>"
76
+ f"<td><meter min='0' max='{max_mean:.2f}' value='{mean:.2f}'></meter></td>"
77
+ f"<td style='padding-left:6px'>{mean:.2f}</td>"
78
+ "</tr>"
79
+ for species, mean in summary.iter_rows()
80
+ )
81
+ return (
82
+ "<div style='display:inline-block;border:1px solid #ddd;border-radius:8px;"
83
+ "padding:8px 10px;background:#fff;'>"
84
+ "<div style='font-weight:600;margin-bottom:6px'>Mean sepal length</div>"
85
+ "<table style='border-collapse:collapse;font-size:12px'>"
86
+ + rows
87
+ + "</table></div>"
88
+ )
89
+
90
+
91
+ IrisSummary(df)
92
+
93
+
94
+ """
95
+ ## IPython display objects
96
+
97
+ IPython [display objects](https://ipython.readthedocs.io/en/latest/api/generated/IPython.display.html)
98
+ are supported, e.g. images.
99
+ """
100
+
101
+ from IPython.display import Image
102
+
103
+ Image('pea.png')