vgplot 0.32.0__tar.gz → 0.32.1__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.
- {vgplot-0.32.0 → vgplot-0.32.1}/.gitignore +1 -0
- {vgplot-0.32.0 → vgplot-0.32.1}/PKG-INFO +1 -1
- {vgplot-0.32.0 → vgplot-0.32.1}/package.json +1 -1
- {vgplot-0.32.0 → vgplot-0.32.1}/tests/test_python_api.py +46 -0
- {vgplot-0.32.0 → vgplot-0.32.1}/vgplot/_types.py +12 -1
- {vgplot-0.32.0 → vgplot-0.32.1}/vgplot/plot.py +3 -2
- {vgplot-0.32.0 → vgplot-0.32.1}/CONTRIBUTING.md +0 -0
- {vgplot-0.32.0 → vgplot-0.32.1}/README.md +0 -0
- {vgplot-0.32.0 → vgplot-0.32.1}/pyproject.toml +0 -0
- {vgplot-0.32.0 → vgplot-0.32.1}/tests/__init__.py +0 -0
- {vgplot-0.32.0 → vgplot-0.32.1}/tests/test_full_round_trip.py +0 -0
- {vgplot-0.32.0 → vgplot-0.32.1}/tests/test_schema_coverage.py +0 -0
- {vgplot-0.32.0 → vgplot-0.32.1}/tests/test_unset_sentinel.py +0 -0
- {vgplot-0.32.0 → vgplot-0.32.1}/vgplot/__init__.py +0 -0
- {vgplot-0.32.0 → vgplot-0.32.1}/vgplot/_compat.py +0 -0
- {vgplot-0.32.0 → vgplot-0.32.1}/vgplot/_generated/__init__.py +0 -0
- {vgplot-0.32.0 → vgplot-0.32.1}/vgplot/_generated/attributes.py +0 -0
- {vgplot-0.32.0 → vgplot-0.32.1}/vgplot/_generated/encodings.py +0 -0
- {vgplot-0.32.0 → vgplot-0.32.1}/vgplot/_generated/marks.py +0 -0
- {vgplot-0.32.0 → vgplot-0.32.1}/vgplot/data.py +0 -0
- {vgplot-0.32.0 → vgplot-0.32.1}/vgplot/encodings.py +0 -0
- {vgplot-0.32.0 → vgplot-0.32.1}/vgplot/params.py +0 -0
- {vgplot-0.32.0 → vgplot-0.32.1}/vgplot/spec.py +0 -0
- {vgplot-0.32.0 → vgplot-0.32.1}/vgplot/util.py +0 -0
|
@@ -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 =
|
|
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:
|
|
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:
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|