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
« prev ^ index » next coverage.py v7.9.1, created at 2025-06-14 15:55 +0200
1"""Trait for implementing domain elements. """
4from sympy.utilities import public
6@public
7class DomainElement:
8 """
9 Represents an element of a domain.
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 """
15 __slots__ = ()
17 def parent(self):
18 """Get the domain associated with ``self``
20 Examples
21 ========
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]
32 Notes
33 =====
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")