Coverage for src\pqlattice\_utils.py: 100%

1 from collections.abc import Iterable

2 from fractions import Fraction

3 from typing import Any

4

5 import numpy as np

6

7 from .typing import Array

8

9

10 def as_integer(a: Iterable[Any]) -> Array:

11 """_summary_

12

13 Parameters

14 ----------

15 a : Iterable[Any]

16 _description_

17

18 Returns

19 -------

20 Array

21 _description_

22 """

23 return (np.vectorize(int)(np.array(a, dtype=object))).astype(object)

24

25

26 def as_rational(a: Iterable[Any]) -> Array:

27 """_summary_

28

29 Parameters

30 ----------

31 a : Iterable[Any]

32 _description_

33

34 Returns

35 -------

36 Array

37 _description_

38 """

39 return (np.vectorize(Fraction)(np.array(a, dtype=object))).astype(object)