Skip to content

Commit

Permalink
test: add a test for a non-pickleable behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
ianna committed Oct 26, 2023
1 parent 625b2d3 commit 94e1427
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/test_2770_serialize_and_deserialize_behaviour_for_numba.py
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

0 comments on commit 94e1427

Please sign in to comment.