You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
1.0 KiB
33 lines
1.0 KiB
"""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)
|