Coverage for /usr/lib/python3/dist-packages/sympy/polys/domains/groundtypes.py: 87%

31 statements  

« prev     ^ index     » next       coverage.py v7.9.1, created at 2025-06-14 15:55 +0200

1"""Ground types for various mathematical domains in SymPy. """ 

2 

3import builtins 

4from sympy.external.gmpy import HAS_GMPY, factorial, sqrt 

5 

6PythonInteger = builtins.int 

7PythonReal = builtins.float 

8PythonComplex = builtins.complex 

9 

10from .pythonrational import PythonRational 

11 

12from sympy.core.numbers import ( 

13 igcdex as python_gcdex, 

14 igcd2 as python_gcd, 

15 ilcm as python_lcm, 

16) 

17 

18from sympy.core.numbers import (Float as SymPyReal, Integer as SymPyInteger, Rational as SymPyRational) 

19 

20 

21if HAS_GMPY == 2: 

22 from gmpy2 import ( 

23 mpz as GMPYInteger, 

24 mpq as GMPYRational, 

25 numer as gmpy_numer, 

26 denom as gmpy_denom, 

27 gcdext as gmpy_gcdex, 

28 gcd as gmpy_gcd, 

29 lcm as gmpy_lcm, 

30 qdiv as gmpy_qdiv, 

31 ) 

32 gcdex = gmpy_gcdex 

33 gcd = gmpy_gcd 

34 lcm = gmpy_lcm 

35else: 

36 class _GMPYInteger: 

37 def __init__(self, obj): 

38 pass 

39 

40 class _GMPYRational: 

41 def __init__(self, obj): 

42 pass 

43 

44 GMPYInteger = _GMPYInteger 

45 GMPYRational = _GMPYRational 

46 gmpy_numer = None 

47 gmpy_denom = None 

48 gmpy_gcdex = None 

49 gmpy_gcd = None 

50 gmpy_lcm = None 

51 gmpy_qdiv = None 

52 gcdex = python_gcdex 

53 gcd = python_gcd 

54 lcm = python_lcm 

55 

56 

57__all__ = [ 

58 'PythonInteger', 'PythonReal', 'PythonComplex', 

59 

60 'PythonRational', 

61 

62 'python_gcdex', 'python_gcd', 'python_lcm', 

63 

64 'SymPyReal', 'SymPyInteger', 'SymPyRational', 

65 

66 'GMPYInteger', 'GMPYRational', 'gmpy_numer', 

67 'gmpy_denom', 'gmpy_gcdex', 'gmpy_gcd', 'gmpy_lcm', 

68 'gmpy_qdiv', 

69 

70 'factorial', 'sqrt', 

71 

72 'GMPYInteger', 'GMPYRational', 

73]