Skip to content

Commit 70b7d99

Browse files
committed
fixtests
Signed-off-by: Robert Kruszewski <github@robertk.io>
1 parent 53b9a03 commit 70b7d99

14 files changed

Lines changed: 139 additions & 150 deletions

File tree

docs/api/python/expr.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ the following expression represents the set of rows for which the `age` column l
5757
... {"x": 2, "y": {"yy": "b"}},
5858
... ])
5959
>>>
60-
>>> vx.io.write(vx.array(array), '/tmp/foo.vortex')
61-
>>> (vx.file.open('/tmp/foo.vortex')
60+
>>> session = vx.Session()
61+
>>> vx.io.write(vx.array(array), '/tmp/foo.vortex', session=session)
62+
>>> (vx.file.open('/tmp/foo.vortex', session=session)
6263
... .scan(expr=vx.expr.column("y")["yy"] == "a")
6364
... .read_all()
64-
... .to_pylist()
65+
... .to_pylist(session=session)
6566
... )
6667
[{'x': 1, 'y': {'yy': 'a'}}]
67-

docs/conf.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@
5858
nitpicky = True # ensures all :class:, :obj:, etc. links are valid
5959
nitpick_ignore = []
6060

61-
doctest_global_setup = "import pyarrow; import vortex; import vortex as vx; import random; random.seed(a=0)"
61+
doctest_global_setup = (
62+
"import pyarrow; import vortex; import vortex as vx; import random; random.seed(a=0); session = vx.Session()"
63+
)
6264
doctest_default_flags = (
6365
doctest.ELLIPSIS | doctest.IGNORE_EXCEPTION_DETAIL | doctest.DONT_ACCEPT_TRUE_FOR_1 | doctest.NORMALIZE_WHITESPACE
6466
)

docs/getting-started/python.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ Use :func:`~vortex.io.write` to write the Vortex array to disk:
3636
.. doctest::
3737

3838
>>> import vortex as vx
39-
>>> vx.io.write(vtx, "example.vortex") # doctest: +SKIP
39+
>>> session = vx.Session()
40+
>>> vx.io.write(vtx, "example.vortex", session=session) # doctest: +SKIP
4041

4142
Small Vortex files (this one is just 71KiB) currently have substantial overhead relative to their
4243
size. This will be addressed shortly. On files with at least tens of megabytes of data, Vortex is
@@ -56,7 +57,8 @@ Use :func:`~vortex.open` to open and read the Vortex array from disk:
5657
.. doctest::
5758

5859
>>> import vortex as vx
59-
>>> cvtx = vx.open("example.vortex").scan().read_all() # doctest: +SKIP
60+
>>> session = vx.Session()
61+
>>> cvtx = vx.open("example.vortex", session=session).scan().read_all() # doctest: +SKIP
6062

6163

6264
Vortex is architected to achieve fast random access, in many cases hundreds of times faster
@@ -68,7 +70,8 @@ IO and decoding and read just the data that is relevant to you:
6870
.. doctest::
6971

7072
>>> import vortex as vx
71-
>>> vf = vx.open("example.vortex") # doctest: +SKIP
73+
>>> session = vx.Session()
74+
>>> vf = vx.open("example.vortex", session=session) # doctest: +SKIP
7275
>>> # row indices must be ordered and unique
7376
>>> indices = vx.array([1, 2, 10])
7477
>>> result = vf.scan(indices=indices).read_all() # doctest: +SKIP

docs/user-guide/pandas.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ convert:
1010
```{doctest} pycon
1111
>>> import vortex as vx
1212
>>> import pyarrow.parquet as pq
13-
>>> vx.io.write(pq.read_table("_static/example.parquet"), 'example.vortex')
13+
>>> session = vx.Session()
14+
>>> vx.io.write(pq.read_table("_static/example.parquet"), 'example.vortex', session=session)
1415
>>>
15-
>>> f = vx.open('example.vortex')
16-
>>> df = f.scan().read_all().to_pandas()
16+
>>> f = vx.open('example.vortex', session=session)
17+
>>> df = f.scan().read_all().to_pandas(session=session)
1718
>>> df[['tip_amount', 'fare_amount']].head(3)
1819
tip_amount fare_amount
1920
0 0.0 61.8
@@ -36,7 +37,7 @@ convert:
3637
... {'name': 'Angela', 'age': 33},
3738
... {'name': 'Mikhail', 'age': 57},
3839
... ])
39-
>>> struct_arr.to_pandas()
40+
>>> struct_arr.to_pandas(session=session)
4041
age name
4142
0 25 Joseph
4243
1 31 Narendra
@@ -49,7 +50,7 @@ convert:
4950
```{doctest} pycon
5051
>>> import pandas as pd
5152
>>> df = pd.DataFrame({'age': [25, 31, 33, 57], 'name': ['Joseph', 'Narendra', 'Angela', 'Mikhail']})
52-
>>> vx.array(df).to_arrow_table()
53+
>>> vx.array(df).to_arrow_table(session=session)
5354
pyarrow.Table
5455
age: int64
5556
name: string_view

docs/user-guide/polars.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ Vortex integrates with Polars via {meth}`.VortexFile.to_polars`, which returns a
1313
```{doctest} pycon
1414
>>> import vortex as vx
1515
>>> import pyarrow.parquet as pq
16-
>>> vx.io.write(pq.read_table("_static/example.parquet"), 'example.vortex')
16+
>>> session = vx.Session()
17+
>>> vx.io.write(pq.read_table("_static/example.parquet"), 'example.vortex', session=session)
1718
>>>
18-
>>> lf = vx.open('example.vortex').to_polars()
19+
>>> lf = vx.open('example.vortex', session=session).to_polars()
1920
>>> lf = lf.select('tip_amount', 'fare_amount')
2021
>>> lf = lf.head(3)
2122
>>> lf.collect()

docs/user-guide/pyarrow.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,17 @@ anything that implements `IntoArrayIterator`, including {class}`pyarrow.Table` a
1313
>>> import pyarrow.parquet as pq
1414
>>> import vortex as vx
1515
>>>
16+
>>> session = vx.Session()
1617
>>> table = pq.read_table("_static/example.parquet")
17-
>>> vx.io.write(table, 'example.vortex')
18+
>>> vx.io.write(table, 'example.vortex', session=session)
1819
```
1920

2021
## Reading Vortex Files
2122

2223
Use {func}`~vortex.open` to lazily open a Vortex file:
2324

2425
```{doctest} pycon
25-
>>> f = vx.open('example.vortex')
26+
>>> f = vx.open('example.vortex', session=session)
2627
>>> len(f)
2728
1000
2829
```
@@ -75,7 +76,7 @@ int(64, nullable=True)
7576
{meth}`.Array.to_arrow_array` converts back:
7677

7778
```{doctest} pycon
78-
>>> arr.to_arrow_array()
79+
>>> arr.to_arrow_array(session=session)
7980
<pyarrow.lib.Int64Array object at ...>
8081
[
8182
1,
@@ -94,7 +95,7 @@ Struct arrays convert to Arrow tables with {meth}`.Array.to_arrow_table`:
9495
... {'name': 'Angela', 'age': 33},
9596
... {'name': 'Mikhail', 'age': 57},
9697
... ])
97-
>>> struct_arr.to_arrow_table()
98+
>>> struct_arr.to_arrow_table(session=session)
9899
pyarrow.Table
99100
age: int64
100101
name: string

docs/user-guide/ray.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ and then run `make -C docs doctest` -->
1111
>>> import os
1212
>>> os.makedirs("ray_data", exist_ok=True)
1313
>>> table = pq.read_table("_static/example.parquet")
14-
>>> vx.io.write(table, 'ray_data/example-01.vortex')
15-
>>> vx.io.write(table, 'ray_data/example-02.vortex')
16-
>>> vx.io.write(table, 'ray_data/example-03.vortex')
14+
>>> session = vx.Session()
15+
>>> vx.io.write(table, 'ray_data/example-01.vortex', session=session)
16+
>>> vx.io.write(table, 'ray_data/example-02.vortex', session=session)
17+
>>> vx.io.write(table, 'ray_data/example-03.vortex', session=session)
1718
>>>
1819
>>> from vortex.ray.datasource import VortexDatasource
1920
>>> from ray.data import read_datasource
2021
>>>
21-
>>> ds = read_datasource(VortexDatasource(url='ray_data')) # doctest: +SKIP
22+
>>> ds = read_datasource(VortexDatasource(url='ray_data', session=session)) # doctest: +SKIP
2223
>>> ds.to_pandas() # doctest: +SKIP
2324
VendorID tpep_pickup_datetime ... congestion_surcharge Airport_fee
2425
0 1 2023-11-01 00:03:03 ... 0.0 1.75

docs/user-guide/vortex-python.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,36 +82,37 @@ Available types: {func}`~vortex.null`, {func}`~vortex.bool_`,
8282
### Element Access
8383

8484
```{doctest} pycon
85+
>>> session = vx.Session()
8586
>>> arr = vx.array([10, 20, 30, 40, 50])
86-
>>> arr.scalar_at(0).as_py()
87+
>>> arr.scalar_at(0, session=session).as_py()
8788
10
88-
>>> arr.to_arrow_array().to_pylist()
89+
>>> arr.to_arrow_array(session=session).to_pylist()
8990
[10, 20, 30, 40, 50]
9091
```
9192

9293
### Slicing and Selection
9394

9495
```{doctest} pycon
95-
>>> arr.slice(1, 3).to_arrow_array().to_pylist()
96+
>>> arr.slice(1, 3).to_arrow_array(session=session).to_pylist()
9697
[20, 30]
9798
>>> indices = vx.array([0, 2, 4])
98-
>>> arr.take(indices).to_arrow_array().to_pylist()
99+
>>> arr.take(indices).to_arrow_array(session=session).to_pylist()
99100
[10, 30, 50]
100101
```
101102

102103
### Filtering
103104

104105
```{doctest} pycon
105106
>>> mask = vx.array([True, False, True, False, True])
106-
>>> arr.filter(mask).to_arrow_array().to_pylist()
107+
>>> arr.filter(mask, session=session).to_arrow_array(session=session).to_pylist()
107108
[10, 30, 50]
108109
```
109110

110111
### Comparisons
111112

112113
```{doctest} pycon
113114
>>> other = vx.array([10, 25, 25, 45, 50])
114-
>>> (arr > other).to_arrow_array().to_pylist()
115+
>>> (arr > other).to_arrow_array(session=session).to_pylist()
115116
[False, False, True, False, False]
116117
```
117118

@@ -129,7 +130,7 @@ applied directly:
129130
... {'name': 'Carol', 'age': 35},
130131
... ])
131132
>>> expr = ve.column('age') > 28
132-
>>> arr.apply(expr).to_arrow_array().to_pylist()
133+
>>> arr.apply(expr).to_arrow_array(session=session).to_pylist()
133134
[True, False, True]
134135
```
135136

@@ -139,9 +140,10 @@ applied directly:
139140

140141
```{doctest} pycon
141142
>>> import pyarrow.parquet as pq
142-
>>> vx.io.write(pq.read_table("_static/example.parquet"), 'example.vortex')
143+
>>> session = vx.Session()
144+
>>> vx.io.write(pq.read_table("_static/example.parquet"), 'example.vortex', session=session)
143145
>>>
144-
>>> f = vx.open('example.vortex')
146+
>>> f = vx.open('example.vortex', session=session)
145147
>>> len(f)
146148
1000
147149
```
@@ -150,7 +152,7 @@ Use {meth}`.VortexFile.scan` to read data with optional projection, filtering, a
150152

151153
```{doctest} pycon
152154
>>> result = f.scan(['tip_amount'], limit=3).read_all()
153-
>>> result.to_arrow_array()
155+
>>> result.to_arrow_array(session=session)
154156
<pyarrow.lib.StructArray object at ...>
155157
-- is_valid: all not null
156158
-- child 0 type: double

0 commit comments

Comments
 (0)