vgplot 0.32.0b0__tar.gz → 0.33.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 (24) hide show
  1. {vgplot-0.32.0b0 → vgplot-0.33.0}/.gitignore +1 -0
  2. {vgplot-0.32.0b0 → vgplot-0.33.0}/PKG-INFO +1 -1
  3. {vgplot-0.32.0b0 → vgplot-0.33.0}/package.json +1 -1
  4. {vgplot-0.32.0b0 → vgplot-0.33.0}/tests/test_python_api.py +46 -0
  5. {vgplot-0.32.0b0 → vgplot-0.33.0}/vgplot/_types.py +12 -1
  6. {vgplot-0.32.0b0 → vgplot-0.33.0}/vgplot/plot.py +3 -2
  7. {vgplot-0.32.0b0 → vgplot-0.33.0}/CONTRIBUTING.md +0 -0
  8. {vgplot-0.32.0b0 → vgplot-0.33.0}/README.md +0 -0
  9. {vgplot-0.32.0b0 → vgplot-0.33.0}/pyproject.toml +0 -0
  10. {vgplot-0.32.0b0 → vgplot-0.33.0}/tests/__init__.py +0 -0
  11. {vgplot-0.32.0b0 → vgplot-0.33.0}/tests/test_full_round_trip.py +0 -0
  12. {vgplot-0.32.0b0 → vgplot-0.33.0}/tests/test_schema_coverage.py +0 -0
  13. {vgplot-0.32.0b0 → vgplot-0.33.0}/tests/test_unset_sentinel.py +0 -0
  14. {vgplot-0.32.0b0 → vgplot-0.33.0}/vgplot/__init__.py +0 -0
  15. {vgplot-0.32.0b0 → vgplot-0.33.0}/vgplot/_compat.py +0 -0
  16. {vgplot-0.32.0b0 → vgplot-0.33.0}/vgplot/_generated/__init__.py +0 -0
  17. {vgplot-0.32.0b0 → vgplot-0.33.0}/vgplot/_generated/attributes.py +0 -0
  18. {vgplot-0.32.0b0 → vgplot-0.33.0}/vgplot/_generated/encodings.py +0 -0
  19. {vgplot-0.32.0b0 → vgplot-0.33.0}/vgplot/_generated/marks.py +0 -0
  20. {vgplot-0.32.0b0 → vgplot-0.33.0}/vgplot/data.py +0 -0
  21. {vgplot-0.32.0b0 → vgplot-0.33.0}/vgplot/encodings.py +0 -0
  22. {vgplot-0.32.0b0 → vgplot-0.33.0}/vgplot/params.py +0 -0
  23. {vgplot-0.32.0b0 → vgplot-0.33.0}/vgplot/spec.py +0 -0
  24. {vgplot-0.32.0b0 → vgplot-0.33.0}/vgplot/util.py +0 -0
@@ -3,6 +3,7 @@
3
3
  .duckdb
4
4
  .ipynb_checkpoints
5
5
  .idea
6
+ *.pem
6
7
  dev/specs
7
8
  docs/.vitepress/cache
8
9
  docs/.vitepress/dist
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: vgplot
3
- Version: 0.32.0-beta.0
3
+ Version: 0.33.0
4
4
  Summary: A Python API for authoring Mosaic vgplot visualizations
5
5
  Project-URL: homepage, https://github.com/uwdata/mosaic
6
6
  Requires-Python: >=3.10
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vgplot-python",
3
- "version": "0.32.0-beta.0",
3
+ "version": "0.33.0",
4
4
  "private": true,
5
5
  "scripts": {
6
6
  "prerelease": "uv run ruff check && uv run ruff format --check",
@@ -105,6 +105,52 @@ class TestDataFrames:
105
105
  assert d["data"]["weather"] is weather
106
106
  assert d["data"]["athletes"] == {"type": "csv", "file": "athletes.csv"}
107
107
 
108
+ def test_frame_typing(self) -> None:
109
+ pytest.importorskip("polars")
110
+ pytest.importorskip("pandas")
111
+ pytest.importorskip("duckdb")
112
+ pytest.importorskip("pyarrow")
113
+ import duckdb
114
+ import pandas as pd
115
+ import polars as pl
116
+ import pyarrow as pa
117
+
118
+ data = {"a": [1]}
119
+
120
+ df_polars = pl.DataFrame(data)
121
+ df_pandas = pd.DataFrame(data)
122
+ df_duckdb = duckdb.from_arrow(df_polars)
123
+ df_pyarrow = pa.table(data)
124
+
125
+ mark_polars = vg.bar_x(df_polars)
126
+ vg.line(df_polars)
127
+ vg.circle(df_polars)
128
+ vg.mark("rectX", df_polars)
129
+
130
+ mark_pandas = vg.bar_x(df_pandas)
131
+ vg.line(df_pandas)
132
+ vg.circle(df_pandas)
133
+ vg.mark("rectX", df_pandas)
134
+
135
+ mark_duckdb = vg.bar_x(df_duckdb)
136
+ vg.line(df_duckdb)
137
+ vg.circle(df_duckdb)
138
+ vg.mark("rectX", df_duckdb)
139
+
140
+ mark_pyarrow = vg.bar_x(df_pyarrow)
141
+ vg.line(df_pyarrow)
142
+ vg.circle(df_pyarrow)
143
+ vg.mark("rectX", df_pyarrow)
144
+
145
+ if TYPE_CHECKING:
146
+ from typing_extensions import assert_type
147
+ from vgplot._types import MarkData
148
+
149
+ assert_type(mark_polars.data, MarkData)
150
+ assert_type(mark_pandas.data, MarkData)
151
+ assert_type(mark_duckdb.data, MarkData)
152
+ assert_type(mark_pyarrow.data, MarkData)
153
+
108
154
 
109
155
  if TYPE_CHECKING:
110
156
 
@@ -4,6 +4,8 @@ from collections.abc import Sequence
4
4
  from datetime import date
5
5
  from typing import Any, TypeAlias
6
6
 
7
+ from narwhals.typing import IntoFrame
8
+
7
9
  from vgplot._compat import sentinel
8
10
 
9
11
  from .data import DataDef
@@ -19,7 +21,16 @@ ChannelValue = (
19
21
  AttrValue = (
20
22
  str | float | bool | date | dict[str, Any] | Sequence[Any] | _ParamBase | None
21
23
  )
22
- MarkData = str | FromRef | DataDef | dict[str, Any] | Sequence[Any] | _ParamBase | None
24
+ MarkData: TypeAlias = (
25
+ str
26
+ | FromRef
27
+ | DataDef
28
+ | IntoFrame
29
+ | dict[str, Any]
30
+ | Sequence[Any]
31
+ | _ParamBase
32
+ | None
33
+ )
23
34
  TransformArg = str | float | bool | dict[str, Any] | _ParamBase
24
35
 
25
36
  UNSET = sentinel("UNSET")
@@ -9,6 +9,7 @@ from .params import _ParamBase
9
9
  from .util import camelize, omit_none
10
10
 
11
11
  if TYPE_CHECKING:
12
+ from vgplot._types import MarkData
12
13
  from vgplot.spec import View
13
14
 
14
15
 
@@ -37,7 +38,7 @@ class Directive:
37
38
  @dataclass
38
39
  class Mark:
39
40
  mark: str
40
- data: Any | None = None
41
+ data: MarkData = None
41
42
  enc: dict[str, Any] | None = None
42
43
 
43
44
  def to_dict(self, param_names: dict[int, str] | None = None) -> dict[str, Any]:
@@ -123,7 +124,7 @@ def directive(key: str, value: Any) -> Directive:
123
124
  return Directive(key, value)
124
125
 
125
126
 
126
- def mark(name: str, data: Any = None, **enc: Any) -> Mark:
127
+ def mark(name: str, data: MarkData = None, **enc: Any) -> Mark:
127
128
  return Mark(name, data=data, enc=enc)
128
129
 
129
130
 
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