File: test_2250_full_like_bool.py

package info (click to toggle)
python-awkward 2.6.5-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 23,088 kB
  • sloc: python: 148,689; cpp: 33,562; sh: 432; makefile: 21; javascript: 8
file content (26 lines) | stat: -rw-r--r-- 765 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
# BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE

from __future__ import annotations

import numpy as np
import pytest  # noqa: F401

import awkward as ak


def test_bool():
    result = ak.full_like([True], 2, dtype=np.int64)
    assert ak.almost_equal(result, np.asarray([2], dtype=np.int64))


def test_empty():
    result = ak.full_like([], 2, dtype=np.int64)
    assert result.layout.is_unknown
    result = ak.full_like([], 2, dtype=np.int64, including_unknown=True)
    assert result.layout.is_numpy
    assert result.layout.dtype == np.dtype(np.int64)


def test_complex128():
    result = ak.full_like([1, 2], 4j, dtype=np.complex128)
    assert ak.almost_equal(result, np.asarray([0 + 4j, 0 + 4j], dtype=np.complex128))