Coverage for src\pqlattice\_utils.py: 100%
9 statements
« prev ^ index » next coverage.py v7.11.0, created at 2026-01-07 08:10 +0100
« prev ^ index » next coverage.py v7.11.0, created at 2026-01-07 08:10 +0100
1from collections.abc import Iterable
2from fractions import Fraction
3from typing import Any
5import numpy as np
7from .typing import Array
10def as_integer(a: Iterable[Any]) -> Array:
11 """_summary_
13 Parameters
14 ----------
15 a : Iterable[Any]
16 _description_
18 Returns
19 -------
20 Array
21 _description_
22 """
23 return (np.vectorize(int)(np.array(a, dtype=object))).astype(object)
26def as_rational(a: Iterable[Any]) -> Array:
27 """_summary_
29 Parameters
30 ----------
31 a : Iterable[Any]
32 _description_
34 Returns
35 -------
36 Array
37 _description_
38 """
39 return (np.vectorize(Fraction)(np.array(a, dtype=object))).astype(object)