Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace has_Field/Ring with is_Field/Ring #12719

Merged
merged 4 commits into from Jun 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions sympy/polys/densearith.py
Expand Up @@ -320,7 +320,7 @@ def dup_quo_ground(f, c, K):
if not f:
return f

if K.has_Field:
if K.is_Field:
return [ K.quo(cf, c) for cf in f ]
else:
return [ cf // c for cf in f ]
Expand Down Expand Up @@ -1527,7 +1527,7 @@ def dup_div(f, g, K):
(1/2*x + 1, 5)

"""
if K.has_Field:
if K.is_Field:
return dup_ff_div(f, g, K)
else:
return dup_rr_div(f, g, K)
Expand Down Expand Up @@ -1620,7 +1620,7 @@ def dmp_div(f, g, u, K):
(1/2*x + 1/2*y - 1/2, -y + 1)

"""
if K.has_Field:
if K.is_Field:
return dmp_ff_div(f, g, u, K)
else:
return dmp_rr_div(f, g, u, K)
Expand Down
17 changes: 14 additions & 3 deletions sympy/polys/domains/domain.py
Expand Up @@ -12,6 +12,7 @@
from sympy.polys.polyutils import _unify_gens

from sympy.utilities import default_sort_key, public
from sympy.core.decorators import deprecated

@public
class Domain(object):
Expand All @@ -21,8 +22,8 @@ class Domain(object):
zero = None
one = None

has_Ring = False
has_Field = False
is_Ring = False
is_Field = False

has_assoc_Ring = False
has_assoc_Field = False
Expand All @@ -48,6 +49,16 @@ class Domain(object):
rep = None
alias = None

@property
@deprecated(useinstead="is_Field", issue=12723, deprecated_since_version="1.1")
def has_Field(self):
return self.is_Field

@property
@deprecated(useinstead="is_Ring", issue=12723, deprecated_since_version="1.1")
def has_Ring(self):
return self.is_Ring

def __init__(self):
raise NotImplementedError

Expand Down Expand Up @@ -270,7 +281,7 @@ def unify(K0, K1, symbols=None):

if ((K0.is_FractionField and K1.is_PolynomialRing or
K1.is_FractionField and K0.is_PolynomialRing) and
(not K0_ground.has_Field or not K1_ground.has_Field) and domain.has_Field):
(not K0_ground.is_Field or not K1_ground.is_Field) and domain.is_Field):
domain = domain.get_ring()

if K0.is_Composite and (not K1.is_Composite or K0.is_FractionField or K1.is_PolynomialRing):
Expand Down
2 changes: 1 addition & 1 deletion sympy/polys/domains/field.py
Expand Up @@ -10,7 +10,7 @@
class Field(Ring):
"""Represents a field domain. """

has_Field = True
is_Field = True

def get_ring(self):
"""Returns a ring associated with ``self``. """
Expand Down
2 changes: 1 addition & 1 deletion sympy/polys/domains/ring.py
Expand Up @@ -11,7 +11,7 @@
class Ring(Domain):
"""Represents a ring domain. """

has_Ring = True
is_Ring = True

def get_ring(self):
"""Returns a ring associated with ``self``. """
Expand Down
14 changes: 7 additions & 7 deletions sympy/polys/euclidtools.py
Expand Up @@ -74,7 +74,7 @@ def dup_half_gcdex(f, g, K):
(-1/5*x + 3/5, x + 1)

"""
if not K.has_Field:
if not K.is_Field:
raise DomainError("can't compute half extended GCD over %s" % K)

a, b = [K.one], []
Expand Down Expand Up @@ -796,7 +796,7 @@ def dmp_resultant(f, g, u, K, includePRS=False):
if includePRS:
return dmp_prs_resultant(f, g, u, K)

if K.has_Field:
if K.is_Field:
if K.is_QQ and query('USE_COLLINS_RESULTANT'):
return dmp_qq_collins_resultant(f, g, u, K)
else:
Expand Down Expand Up @@ -1510,7 +1510,7 @@ def dup_inner_gcd(f, g, K):
cfg = dup_convert(cfg, exact, K)

return h, cff, cfg
elif K.has_Field:
elif K.is_Field:
if K.is_QQ and query('USE_HEU_GCD'):
try:
return dup_qq_heu_gcd(f, g, K)
Expand Down Expand Up @@ -1546,7 +1546,7 @@ def _dmp_inner_gcd(f, g, u, K):
cfg = dmp_convert(cfg, u, exact, K)

return h, cff, cfg
elif K.has_Field:
elif K.is_Field:
if K.is_QQ and query('USE_HEU_GCD'):
try:
return dmp_qq_heu_gcd(f, g, u, K)
Expand Down Expand Up @@ -1694,7 +1694,7 @@ def dup_lcm(f, g, K):
x**3 - 2*x**2 - x + 2

"""
if K.has_Field:
if K.is_Field:
return dup_ff_lcm(f, g, K)
else:
return dup_rr_lcm(f, g, K)
Expand Down Expand Up @@ -1771,7 +1771,7 @@ def dmp_lcm(f, g, u, K):
if not u:
return dup_lcm(f, g, K)

if K.has_Field:
if K.is_Field:
return dmp_ff_lcm(f, g, u, K)
else:
return dmp_rr_lcm(f, g, u, K)
Expand Down Expand Up @@ -1863,7 +1863,7 @@ def dmp_cancel(f, g, u, K, include=True):
"""
K0 = None

if K.has_Field and K.has_assoc_Ring:
if K.is_Field and K.has_assoc_Ring:
K0, K = K, K.get_ring()

cq, f = dmp_clear_denoms(f, u, K0, K, convert=True)
Expand Down
8 changes: 4 additions & 4 deletions sympy/polys/factortools.py
Expand Up @@ -1191,7 +1191,7 @@ def dup_factor_list(f, K0):
else:
K0_inexact = None

if K0.has_Field:
if K0.is_Field:
K = K0.get_ring()

denom, f = dup_clear_denoms(f, K0, K)
Expand All @@ -1213,7 +1213,7 @@ def dup_factor_list(f, K0):
else: # pragma: no cover
raise DomainError('factorization not supported over %s' % K0)

if K0.has_Field:
if K0.is_Field:
for i, (f, k) in enumerate(factors):
factors[i] = (dup_convert(f, K, K0), k)

Expand Down Expand Up @@ -1266,7 +1266,7 @@ def dmp_factor_list(f, u, K0):
else:
K0_inexact = None

if K0.has_Field:
if K0.is_Field:
K = K0.get_ring()

denom, f = dmp_clear_denoms(f, u, K0, K)
Expand All @@ -1292,7 +1292,7 @@ def dmp_factor_list(f, u, K0):
else: # pragma: no cover
raise DomainError('factorization not supported over %s' % K0)

if K0.has_Field:
if K0.is_Field:
for i, (f, k) in enumerate(factors):
factors[i] = (dmp_convert(f, u, K, K0), k)

Expand Down
6 changes: 3 additions & 3 deletions sympy/polys/fields.py
Expand Up @@ -166,7 +166,7 @@ def ground_new(self, element):
except CoercionFailed:
domain = self.domain

if not domain.has_Field and domain.has_assoc_Field:
if not domain.is_Field and domain.has_assoc_Field:
ring = self.ring
ground_field = domain.get_field()
element = ground_field.convert(element)
Expand Down Expand Up @@ -217,7 +217,7 @@ def _rebuild(expr):
try:
return domain.convert(expr)
except CoercionFailed:
if not domain.has_Field and domain.has_assoc_Field:
if not domain.is_Field and domain.has_assoc_Field:
return domain.get_field().convert(expr)
else:
raise
Expand Down Expand Up @@ -338,7 +338,7 @@ def _extract_ground(self, element):
try:
element = domain.convert(element)
except CoercionFailed:
if not domain.has_Field and domain.has_assoc_Field:
if not domain.is_Field and domain.has_assoc_Field:
ground_field = domain.get_field()

try:
Expand Down
6 changes: 3 additions & 3 deletions sympy/polys/groebnertools.py
Expand Up @@ -34,7 +34,7 @@ def groebner(seq, ring, method=None):

domain, orig = ring.domain, None

if not domain.has_Field or not domain.has_assoc_Field:
if not domain.is_Field or not domain.has_assoc_Field:
try:
orig, ring = ring, ring.clone(domain=domain.get_field())
except DomainError:
Expand Down Expand Up @@ -844,7 +844,7 @@ def groebner_gcd(f, g):
raise ValueError("Values should be equal")
domain = f.ring.domain

if not domain.has_Field:
if not domain.is_Field:
fc, f = f.primitive()
gc, g = g.primitive()
gcd = domain.gcd(fc, gc)
Expand All @@ -855,7 +855,7 @@ def groebner_gcd(f, g):
raise ValueError("Length should be 1")
h = H[0]

if not domain.has_Field:
if not domain.is_Field:
return gcd*h
else:
return h.monic()
2 changes: 1 addition & 1 deletion sympy/polys/monomials.py
Expand Up @@ -264,7 +264,7 @@ def term_div(a, b, domain):

monom = monomial_div(a_lm, b_lm)

if domain.has_Field:
if domain.is_Field:
if monom is not None:
return monom, domain.quo(a_lc, b_lc)
else:
Expand Down
2 changes: 1 addition & 1 deletion sympy/polys/polyroots.py
Expand Up @@ -976,7 +976,7 @@ def _try_heuristics(f):

coeff, f = preprocess_roots(f)

if auto and f.get_domain().has_Ring:
if auto and f.get_domain().is_Ring:
f = f.to_field()

rescale_x = None
Expand Down