-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add a test for a non-pickleable behaviour
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
tests/test_2770_serialize_and_deserialize_behaviour_for_numba.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE | ||
|
||
import pytest | ||
|
||
import awkward as ak | ||
|
||
numba = pytest.importorskip("numba") | ||
|
||
|
||
def test_ArrayBuilder_inNumba(): | ||
SOME_ATTRS = {"FOO": "BAR"} | ||
builder = ak.ArrayBuilder(behavior=SOME_ATTRS) | ||
|
||
@numba.njit | ||
def func(array): | ||
return array | ||
|
||
assert builder.behavior is SOME_ATTRS | ||
# In Python, when we create a dictionary literal like {'FOO': 'BAR'}, it | ||
# creates a new dictionary object. If we serialize this dictionary to | ||
# a JSON string, or to a tuple and then deserialize it, we get a new dictionary | ||
# object that is structurally identical to the original one, but it is not | ||
# the same object in terms of identity. | ||
|
||
# To check if two dictionaries are equal in terms of their contents, | ||
# we should use the == operator instead of is. | ||
assert func(builder).behavior == SOME_ATTRS |