plot3 0.6.5__tar.gz → 0.6.6__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.
- {plot3-0.6.5 → plot3-0.6.6}/PKG-INFO +12 -1
- {plot3-0.6.5 → plot3-0.6.6}/README.md +11 -0
- plot3-0.6.6/plot3/__version__.py +1 -0
- {plot3-0.6.5 → plot3-0.6.6}/plot3/jupyter.py +29 -0
- {plot3-0.6.5 → plot3-0.6.6}/plot3/masking.py +132 -0
- {plot3-0.6.5 → plot3-0.6.6}/plot3.egg-info/PKG-INFO +12 -1
- {plot3-0.6.5 → plot3-0.6.6}/tests/test_masking.py +41 -0
- plot3-0.6.5/plot3/__version__.py +0 -1
- {plot3-0.6.5 → plot3-0.6.6}/LICENSE +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/plot3/__init__.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/plot3/aesexpr.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/plot3/build.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/plot3/calculus.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/plot3/compose.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/plot3/contour.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/plot3/craft.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/plot3/encode.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/plot3/expr.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/plot3/flip.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/plot3/function.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/plot3/geoms.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/plot3/ggplot.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/plot3/io.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/plot3/latexin.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/plot3/mathtext.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/plot3/payload.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/plot3/remote.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/plot3/scales.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/plot3/scaling.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/plot3/special.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/plot3/stat2d.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/plot3/static.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/plot3/stats3d.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/plot3/table.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/plot3/themes.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/plot3/viewer.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/plot3.egg-info/SOURCES.txt +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/plot3.egg-info/dependency_links.txt +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/plot3.egg-info/requires.txt +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/plot3.egg-info/top_level.txt +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/pyproject.toml +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/setup.cfg +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/tests/test_2d_density.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/tests/test_3d.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/tests/test_animation.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/tests/test_annotate.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/tests/test_api_public.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/tests/test_array_backend.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/tests/test_arrow.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/tests/test_build_contract.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/tests/test_contour.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/tests/test_everyday_ggplot2.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/tests/test_expr.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/tests/test_facets_compose.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/tests/test_geom_function.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/tests/test_geoms_ds.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/tests/test_ggplot2_extras2.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/tests/test_ggplot2_parity.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/tests/test_ggplot_extras.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/tests/test_grammar.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/tests/test_latex_input.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/tests/test_lidar_scene.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/tests/test_math_layers.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/tests/test_mathtext.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/tests/test_payload.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/tests/test_payload_display.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/tests/test_point_cloud.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/tests/test_r_oracle_parity.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/tests/test_readme.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/tests/test_remote_bridge.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/tests/test_review_fixes.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/tests/test_save_menu.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/tests/test_scales_api.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/tests/test_scales_themes.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/tests/test_special.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/tests/test_stat2d.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/tests/test_static_save.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/tests/test_stats_semantic.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/tests/test_step3_geoms.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/tests/test_table_backends.py +0 -0
- {plot3-0.6.5 → plot3-0.6.6}/tests/test_titles_theme.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: plot3
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.6
|
|
4
4
|
Summary: ggplot2 grammar of graphics for Python: interactive WebGL figures and journal-ready PNG, SVG, and PDF
|
|
5
5
|
Author: Rigoberto Leyva Salmeron
|
|
6
6
|
License-Expression: MIT
|
|
@@ -260,6 +260,17 @@ In notebooks, bare column names work as in R: `aes(x=dose, y=response)`.
|
|
|
260
260
|
- **Jupyter / SolveIt**: bare column names and backticks work in `aes()`,
|
|
261
261
|
`facet_wrap()`, and `facet_grid()` (`aes(x=`First Name`)`). Toggle with
|
|
262
262
|
`enable_r_style()` / `disable_r_style()`. `.py` files keep quoted strings.
|
|
263
|
+
- **Layers on their own lines**, as in R, with no parentheses:
|
|
264
|
+
|
|
265
|
+
```text
|
|
266
|
+
ggplot(gapminder, aes(x=gdpPercap, y=lifeExp, colour=continent))
|
|
267
|
+
+ geom_point(alpha=0.7) # comments are fine
|
|
268
|
+
+ scale_x_log10()
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
A line starting with `+` and a plot3 function continues the plot above
|
|
272
|
+
it. Import plot3 in an earlier cell: IPython reads a whole cell before
|
|
273
|
+
running any of it. `.py` files keep the outer parentheses.
|
|
263
274
|
- **SolveIt** draws figures inline and hides their HTML from the model's
|
|
264
275
|
context (`autohide(False)` to opt out).
|
|
265
276
|
- **VS Code notebooks** block WebGL in output cells, so plot3 opens figures
|
|
@@ -233,6 +233,17 @@ In notebooks, bare column names work as in R: `aes(x=dose, y=response)`.
|
|
|
233
233
|
- **Jupyter / SolveIt**: bare column names and backticks work in `aes()`,
|
|
234
234
|
`facet_wrap()`, and `facet_grid()` (`aes(x=`First Name`)`). Toggle with
|
|
235
235
|
`enable_r_style()` / `disable_r_style()`. `.py` files keep quoted strings.
|
|
236
|
+
- **Layers on their own lines**, as in R, with no parentheses:
|
|
237
|
+
|
|
238
|
+
```text
|
|
239
|
+
ggplot(gapminder, aes(x=gdpPercap, y=lifeExp, colour=continent))
|
|
240
|
+
+ geom_point(alpha=0.7) # comments are fine
|
|
241
|
+
+ scale_x_log10()
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
A line starting with `+` and a plot3 function continues the plot above
|
|
245
|
+
it. Import plot3 in an earlier cell: IPython reads a whole cell before
|
|
246
|
+
running any of it. `.py` files keep the outer parentheses.
|
|
236
247
|
- **SolveIt** draws figures inline and hides their HTML from the model's
|
|
237
248
|
context (`autohide(False)` to opt out).
|
|
238
249
|
- **VS Code notebooks** block WebGL in output cells, so plot3 opens figures
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.6.6"
|
|
@@ -22,6 +22,7 @@ from plot3.masking import (
|
|
|
22
22
|
is_mask_transformer,
|
|
23
23
|
is_tidy3_backtick_transformer,
|
|
24
24
|
plot3_backtick_transform,
|
|
25
|
+
plot3_layer_transform,
|
|
25
26
|
)
|
|
26
27
|
|
|
27
28
|
# R-style bare-name / backtick masking for aes() / facet_wrap().
|
|
@@ -463,6 +464,28 @@ def run_plot3_from_magic(line: str = ""):
|
|
|
463
464
|
# ═════════════════════════════════════════════════════════════════════════════
|
|
464
465
|
|
|
465
466
|
|
|
467
|
+
def enable_layer_lines(ipython: Any | None = None) -> bool:
|
|
468
|
+
"""Let ``+ geom_point()`` lines continue the ggplot above them in a cell.
|
|
469
|
+
|
|
470
|
+
``ggplot(df, aes(...))`` then ``+ geom_point()`` on the next lines, with
|
|
471
|
+
no parentheses, as in R. Only a ``+`` followed by a plot3 name joins, so
|
|
472
|
+
ordinary Python is never rewritten.
|
|
473
|
+
"""
|
|
474
|
+
if ipython is None:
|
|
475
|
+
try:
|
|
476
|
+
ipython = get_ipython() if get_ipython is not None else None
|
|
477
|
+
except Exception:
|
|
478
|
+
ipython = None
|
|
479
|
+
transformers = getattr(ipython, "input_transformers_cleanup", None)
|
|
480
|
+
if not isinstance(transformers, list):
|
|
481
|
+
return False
|
|
482
|
+
transformers[:] = [
|
|
483
|
+
t for t in transformers if getattr(t, "__name__", "") != "plot3_layer_transform"
|
|
484
|
+
]
|
|
485
|
+
transformers.append(plot3_layer_transform)
|
|
486
|
+
return True
|
|
487
|
+
|
|
488
|
+
|
|
466
489
|
def register_plot3(*, quiet=True, r_style: bool = True) -> bool:
|
|
467
490
|
if get_ipython is None:
|
|
468
491
|
return False
|
|
@@ -495,6 +518,12 @@ def register_plot3(*, quiet=True, r_style: bool = True) -> bool:
|
|
|
495
518
|
ns[name] = getattr(plot3_pkg, name)
|
|
496
519
|
except Exception:
|
|
497
520
|
pass
|
|
521
|
+
# ggplot(...) then "+ geom_point()" lines, without parentheses
|
|
522
|
+
try:
|
|
523
|
+
enable_layer_lines(ip)
|
|
524
|
+
except Exception as e:
|
|
525
|
+
if not quiet:
|
|
526
|
+
print(f"plot3: multi-line layers not enabled: {e}")
|
|
498
527
|
# R-style bare names / backticks in aes() (ggplot2 parity with tidy3)
|
|
499
528
|
if r_style:
|
|
500
529
|
try:
|
|
@@ -179,6 +179,138 @@ def plot3_backtick_transform(lines: list[str]) -> list[str]:
|
|
|
179
179
|
return parts or [out]
|
|
180
180
|
|
|
181
181
|
|
|
182
|
+
_OPENERS = frozenset("([{")
|
|
183
|
+
_CLOSERS = frozenset(")]}")
|
|
184
|
+
_SKIP_TOKENS = frozenset({
|
|
185
|
+
tokenize.COMMENT, tokenize.NL, tokenize.NEWLINE, tokenize.INDENT,
|
|
186
|
+
tokenize.DEDENT, tokenize.ENCODING, tokenize.ENDMARKER,
|
|
187
|
+
})
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
def _plot3_names() -> set[str]:
|
|
191
|
+
try:
|
|
192
|
+
import plot3
|
|
193
|
+
|
|
194
|
+
return {str(name) for name in getattr(plot3, "__all__", ())}
|
|
195
|
+
except Exception:
|
|
196
|
+
return set()
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
def _logical_lines(text: str) -> list[list[tokenize.TokenInfo]] | None:
|
|
200
|
+
"""Token lists, one per logical line; ``None`` if *text* cannot tokenize."""
|
|
201
|
+
lines: list[list[tokenize.TokenInfo]] = []
|
|
202
|
+
current: list[tokenize.TokenInfo] = []
|
|
203
|
+
try:
|
|
204
|
+
for token in tokenize.generate_tokens(io.StringIO(text).readline):
|
|
205
|
+
if token.type in _SKIP_TOKENS:
|
|
206
|
+
if token.type == tokenize.NEWLINE and current:
|
|
207
|
+
lines.append(current)
|
|
208
|
+
current = []
|
|
209
|
+
continue
|
|
210
|
+
current.append(token)
|
|
211
|
+
except (tokenize.TokenError, IndentationError, SyntaxError):
|
|
212
|
+
return None
|
|
213
|
+
if current:
|
|
214
|
+
lines.append(current)
|
|
215
|
+
return lines
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
def _value_start(tokens: list[tokenize.TokenInfo]) -> tuple[int, int]:
|
|
219
|
+
"""Where the expression starts: after a top-level ``=``, else the start."""
|
|
220
|
+
depth = 0
|
|
221
|
+
for index, token in enumerate(tokens):
|
|
222
|
+
if token.string in _OPENERS:
|
|
223
|
+
depth += 1
|
|
224
|
+
elif token.string in _CLOSERS:
|
|
225
|
+
depth -= 1
|
|
226
|
+
elif depth == 0 and token.type == tokenize.OP and token.string == "=":
|
|
227
|
+
if index + 1 < len(tokens):
|
|
228
|
+
return tokens[index + 1].start
|
|
229
|
+
return tokens[0].start
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
def join_layer_lines(source: str) -> str | None:
|
|
233
|
+
"""Join ``+`` lines that add plot3 layers to the statement above them.
|
|
234
|
+
|
|
235
|
+
In a notebook, ``ggplot(df, aes(...))`` followed by lines that start
|
|
236
|
+
with ``+ geom_point()`` reads like R, but to Python each ``+`` line is
|
|
237
|
+
a statement of its own (unary plus, or an IndentationError when
|
|
238
|
+
indented). A line whose first token is ``+`` followed by a plot3 name
|
|
239
|
+
continues the top-level statement above it, across comments and blank
|
|
240
|
+
lines; the expression gets parentheses on the lines as typed, so error
|
|
241
|
+
line numbers still match. Returns ``None`` when nothing needs joining,
|
|
242
|
+
or when the result would not parse. Pipes (``>>``) are tidy3's.
|
|
243
|
+
"""
|
|
244
|
+
if not source or "+" not in source:
|
|
245
|
+
return None
|
|
246
|
+
raw = source.split("\n")
|
|
247
|
+
if not any(line.lstrip().startswith("+") for line in raw):
|
|
248
|
+
return None
|
|
249
|
+
names = _plot3_names()
|
|
250
|
+
# Indented "+ geom_point()" lines must not trip the tokenizer.
|
|
251
|
+
shift = [len(line) - len(line.lstrip()) if line.lstrip().startswith("+") else 0 for line in raw]
|
|
252
|
+
analysed = "\n".join(line[n:] for line, n in zip(raw, shift))
|
|
253
|
+
logical = _logical_lines(analysed)
|
|
254
|
+
if not logical:
|
|
255
|
+
return None
|
|
256
|
+
|
|
257
|
+
def is_layer(tokens: list[tokenize.TokenInfo]) -> bool:
|
|
258
|
+
return (
|
|
259
|
+
len(tokens) > 1
|
|
260
|
+
and tokens[0].type == tokenize.OP
|
|
261
|
+
and tokens[0].string == "+"
|
|
262
|
+
and tokens[1].type == tokenize.NAME
|
|
263
|
+
and tokens[1].string in names
|
|
264
|
+
)
|
|
265
|
+
|
|
266
|
+
groups: list[list[list[tokenize.TokenInfo]]] = []
|
|
267
|
+
for tokens in logical:
|
|
268
|
+
previous = groups[-1] if groups else None
|
|
269
|
+
head = previous[0][0] if previous else None
|
|
270
|
+
if (
|
|
271
|
+
previous is not None
|
|
272
|
+
and is_layer(tokens)
|
|
273
|
+
and head.start[1] == 0
|
|
274
|
+
and head.type != tokenize.OP
|
|
275
|
+
and head.string not in {"if", "for", "while", "with", "def", "class", "try", "elif", "else", "except", "finally", "return", "import", "from"}
|
|
276
|
+
):
|
|
277
|
+
previous.append(tokens)
|
|
278
|
+
else:
|
|
279
|
+
groups.append([tokens])
|
|
280
|
+
|
|
281
|
+
edits: list[tuple[int, int, str]] = []
|
|
282
|
+
for group in groups:
|
|
283
|
+
if len(group) < 2:
|
|
284
|
+
continue
|
|
285
|
+
opening = _value_start(group[0])
|
|
286
|
+
closing = group[-1][-1].end
|
|
287
|
+
edits.append((opening[0], opening[1] + shift[opening[0] - 1], "("))
|
|
288
|
+
edits.append((closing[0], closing[1] + shift[closing[0] - 1], ")"))
|
|
289
|
+
if not edits:
|
|
290
|
+
return None
|
|
291
|
+
lines = list(raw)
|
|
292
|
+
for row, col, piece in sorted(edits, reverse=True):
|
|
293
|
+
line = lines[row - 1]
|
|
294
|
+
lines[row - 1] = line[:col] + piece + line[col:]
|
|
295
|
+
rewritten = "\n".join(lines)
|
|
296
|
+
try:
|
|
297
|
+
ast.parse(rewrite_backticks(rewritten))
|
|
298
|
+
except SyntaxError:
|
|
299
|
+
return None
|
|
300
|
+
return rewritten
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
def plot3_layer_transform(lines: list[str]) -> list[str]:
|
|
304
|
+
"""IPython input transformer: ``+`` lines continue a ggplot (see join_layer_lines)."""
|
|
305
|
+
if not lines:
|
|
306
|
+
return lines
|
|
307
|
+
source = "".join(lines)
|
|
308
|
+
out = join_layer_lines(source)
|
|
309
|
+
if out is None:
|
|
310
|
+
return lines
|
|
311
|
+
return out.splitlines(keepends=True)
|
|
312
|
+
|
|
313
|
+
|
|
182
314
|
def _is_bt_call(node: ast.AST) -> bool:
|
|
183
315
|
return (
|
|
184
316
|
isinstance(node, ast.Call)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: plot3
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.6
|
|
4
4
|
Summary: ggplot2 grammar of graphics for Python: interactive WebGL figures and journal-ready PNG, SVG, and PDF
|
|
5
5
|
Author: Rigoberto Leyva Salmeron
|
|
6
6
|
License-Expression: MIT
|
|
@@ -260,6 +260,17 @@ In notebooks, bare column names work as in R: `aes(x=dose, y=response)`.
|
|
|
260
260
|
- **Jupyter / SolveIt**: bare column names and backticks work in `aes()`,
|
|
261
261
|
`facet_wrap()`, and `facet_grid()` (`aes(x=`First Name`)`). Toggle with
|
|
262
262
|
`enable_r_style()` / `disable_r_style()`. `.py` files keep quoted strings.
|
|
263
|
+
- **Layers on their own lines**, as in R, with no parentheses:
|
|
264
|
+
|
|
265
|
+
```text
|
|
266
|
+
ggplot(gapminder, aes(x=gdpPercap, y=lifeExp, colour=continent))
|
|
267
|
+
+ geom_point(alpha=0.7) # comments are fine
|
|
268
|
+
+ scale_x_log10()
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
A line starting with `+` and a plot3 function continues the plot above
|
|
272
|
+
it. Import plot3 in an earlier cell: IPython reads a whole cell before
|
|
273
|
+
running any of it. `.py` files keep the outer parentheses.
|
|
263
274
|
- **SolveIt** draws figures inline and hides their HTML from the model's
|
|
264
275
|
context (`autohide(False)` to opt out).
|
|
265
276
|
- **VS Code notebooks** block WebGL in output cells, so plot3 opens figures
|
|
@@ -197,3 +197,44 @@ def test_aes_expression_over_columns_passes_whole():
|
|
|
197
197
|
# Notebook variables and modules keep the old behaviour.
|
|
198
198
|
assert apply_masking("aes(x=np.log(x))", known=known) == "aes(x=np.log('x'))"
|
|
199
199
|
assert apply_masking("aes(x=wt)", known=known) == "aes(x='wt')"
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
def test_plus_lines_continue_a_ggplot():
|
|
203
|
+
# ggplot(...) then "+ geom_point()" lines, as in R: to Python each "+"
|
|
204
|
+
# line is its own statement (unary plus, or an IndentationError).
|
|
205
|
+
import ast
|
|
206
|
+
|
|
207
|
+
from plot3.masking import join_layer_lines
|
|
208
|
+
|
|
209
|
+
cell = (
|
|
210
|
+
'ggplot(df, aes(x="a", y="b"))\n'
|
|
211
|
+
' + geom_point(alpha=0.7)\n'
|
|
212
|
+
' + scale_x_log10()'
|
|
213
|
+
)
|
|
214
|
+
joined = join_layer_lines(cell)
|
|
215
|
+
assert joined == (
|
|
216
|
+
'(ggplot(df, aes(x="a", y="b"))\n'
|
|
217
|
+
' + geom_point(alpha=0.7)\n'
|
|
218
|
+
' + scale_x_log10())'
|
|
219
|
+
)
|
|
220
|
+
tree = ast.parse(joined)
|
|
221
|
+
assert len(tree.body) == 1
|
|
222
|
+
|
|
223
|
+
# An assignment, with comments and a blank line between layers.
|
|
224
|
+
cell = 'p = ggplot(df) # base\n# layers\n+ geom_point() # points\n\n+ theme_bw()\np'
|
|
225
|
+
joined = join_layer_lines(cell)
|
|
226
|
+
assert joined.startswith("p = (ggplot(df)") and "+ theme_bw())" in joined
|
|
227
|
+
assert len(ast.parse(joined).body) == 2
|
|
228
|
+
|
|
229
|
+
# patchwork: a composition takes "+ plot_layout(...)" lines too.
|
|
230
|
+
assert join_layer_lines("fig = (a | b)\n+ plot_layout(widths=[3, 2])").startswith("fig = ((a | b)")
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
def test_plus_lines_leave_other_python_alone():
|
|
234
|
+
from plot3.masking import join_layer_lines
|
|
235
|
+
|
|
236
|
+
assert join_layer_lines("x = 1\n+2") is None # unary plus
|
|
237
|
+
assert join_layer_lines("y = 1\n+ foo(2)") is None # not a plot3 name
|
|
238
|
+
assert join_layer_lines("df\n>> ggplot()\n+ geom_point()") is None # tidy3's pipe
|
|
239
|
+
assert join_layer_lines("for i in r:\n p = ggplot(df)\n + geom_point()") is None
|
|
240
|
+
assert join_layer_lines("p = ggplot(df) + geom_point()") is None # already one line
|
plot3-0.6.5/plot3/__version__.py
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.6.5"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|