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

1from collections.abc import Iterable 

2from fractions import Fraction 

3from typing import Any 

4 

5import numpy as np 

6 

7from .typing import Array 

8 

9 

10def 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 

26def 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)