File: test_2837_ufunc_attrs_behavior.py

package info (click to toggle)
python-awkward 2.8.9-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 24,932 kB
  • sloc: python: 178,875; cpp: 33,828; sh: 432; makefile: 21; javascript: 8
file content (28 lines) | stat: -rw-r--r-- 789 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from __future__ import annotations

import awkward as ak


def test():
    x = ak.Array([1, 2, 3], behavior={"foo": "BAR"}, attrs={"hello": "world"})
    y = ak.Array([8, 0, 9], behavior={"do": "re"}, attrs={"mi": "fa"})
    z = x + y
    assert z.attrs == {"hello": "world", "mi": "fa"}
    assert z.behavior == {"foo": "BAR", "do": "re"}


def test_unary():
    x = ak.Array([1, 2, 3], behavior={"foo": "BAR"}, attrs={"hello": "world"})
    y = -x
    assert y.attrs == x.attrs
    assert x.behavior is y.behavior


def test_two_return():
    x = ak.Array([1, 2, 3], behavior={"foo": "BAR"}, attrs={"hello": "world"})
    y, y_ret = divmod(x, 2)
    assert y.attrs == y_ret.attrs
    assert y.attrs == x.attrs

    assert y.behavior is y_ret.behavior
    assert y.behavior is x.behavior