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

6 statements  

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

1"""Trait for implementing domain elements. """ 

2 

3 

4from sympy.utilities import public 

5 

6@public 

7class DomainElement: 

8 """ 

9 Represents an element of a domain. 

10 

11 Mix in this trait into a class whose instances should be recognized as 

12 elements of a domain. Method ``parent()`` gives that domain. 

13 """ 

14 

15 __slots__ = () 

16 

17 def parent(self): 

18 """Get the domain associated with ``self`` 

19 

20 Examples 

21 ======== 

22 

23 >>> from sympy import ZZ, symbols 

24 >>> x, y = symbols('x, y') 

25 >>> K = ZZ[x,y] 

26 >>> p = K(x)**2 + K(y)**2 

27 >>> p 

28 x**2 + y**2 

29 >>> p.parent() 

30 ZZ[x,y] 

31 

32 Notes 

33 ===== 

34 

35 This is used by :py:meth:`~.Domain.convert` to identify the domain 

36 associated with a domain element. 

37 """ 

38 raise NotImplementedError("abstract method")