Skip to content

Commit

Permalink
test: add simple test
Browse files Browse the repository at this point in the history
  • Loading branch information
agoose77 committed Sep 5, 2023
1 parent fba7380 commit 398823d
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tests/test_pickle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from __future__ import annotations

import pickle

import awkward as ak
import dask.config

import dask_awkward as dak


def test_pickle_ak_array():
buffers = []
array = ak.Array([[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]])[[0, 2]]
next_array = pickle.loads(
pickle.dumps(array, protocol=5, buffer_callback=buffers.append), buffers=buffers
)
assert ak.almost_equal(array, next_array)
assert array.layout.form == next_array.layout.form


def identity(x):
return x


def test_worker_transfer():
array = ak.Array([[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]])[[0, 2]]
darray = dak.from_awkward(array, 1)
darray_result = darray.map_partitions(identity)

first, second = dask.compute(darray, darray_result)

assert ak.almost_equal(first, second)
assert first.layout.form == second.layout.form

0 comments on commit 398823d

Please sign in to comment.