Traktor/myenv/Lib/site-packages/sympy/polys/domains/compositedomain.py

33 lines
1.0 KiB
Python
Raw Normal View History

2024-05-26 05:12:46 +02:00
"""Implementation of :class:`CompositeDomain` class. """
from sympy.polys.domains.domain import Domain
from sympy.polys.polyerrors import GeneratorsError
from sympy.utilities import public
@public
class CompositeDomain(Domain):
"""Base class for composite domains, e.g. ZZ[x], ZZ(X). """
is_Composite = True
gens, ngens, symbols, domain = [None]*4
def inject(self, *symbols):
"""Inject generators into this domain. """
if not (set(self.symbols) & set(symbols)):
return self.__class__(self.domain, self.symbols + symbols, self.order)
else:
raise GeneratorsError("common generators in %s and %s" % (self.symbols, symbols))
def drop(self, *symbols):
"""Drop generators from this domain. """
symset = set(symbols)
newsyms = tuple(s for s in self.symbols if s not in symset)
domain = self.domain.drop(*symbols)
if not newsyms:
return domain
else:
return self.__class__(domain, newsyms, self.order)