Skip to content

Commit

Permalink
Trac #20310: change for p-adic rings
Browse files Browse the repository at this point in the history
Started as a proposal to change precision of rings, this is now a more
general `change` method.

URL: https://trac.sagemath.org/20310
Reported by: caruso
Ticket author(s): David Roe
Reviewer(s): Julian Rüth, Xavier Caruso
  • Loading branch information
Release Manager authored and vbraun committed Aug 9, 2017
2 parents 44fba6b + 86b58de commit 886ed8d
Show file tree
Hide file tree
Showing 6 changed files with 530 additions and 156 deletions.
10 changes: 5 additions & 5 deletions src/sage/categories/pushout.py
Expand Up @@ -2371,7 +2371,7 @@ def __init__(self, p, prec, extras=None):
raise ValueError("completion type must be one of %s"%(", ".join(self._real_types)))
else:
if self.type not in self._dvr_types:
raise ValueError("completion type must be one of %s"%(", ".join(self._dvr_types)))
raise ValueError("completion type must be one of %s"%(", ".join(self._dvr_types[1:])))

def _repr_(self):
"""
Expand Down Expand Up @@ -2473,7 +2473,7 @@ def __ne__(self, other):
return not (self == other)

_real_types = ['Interval','Ball','MPFR','RDF','RLF']
_dvr_types = [None, 'fixed-mod','capped-abs','capped-rel','lazy']
_dvr_types = [None, 'fixed-mod','floating-point','capped-abs','capped-rel','lazy']

def merge(self, other):
"""
Expand Down Expand Up @@ -2557,9 +2557,9 @@ def merge(self, other):
return CompletionFunctor(self.p, new_prec, {'type':new_type, 'sci_not':new_scinot, 'rnd':new_rnd})
else:
new_type = self._dvr_types[min(self._dvr_types.index(self.type), self._dvr_types.index(other.type))]
if new_type == 'fixed-mod':
if self.type != 'fixed-mod' or other.type != 'fixed-mod':
return None # no coercion into fixed-mod
if new_type in ('fixed-mod', 'floating-point'):
if self.type != other.type:
return None # no coercion into fixed-mod or floating-point
new_prec = min(self.prec, other.prec)
else:
new_prec = max(self.prec, other.prec) # since elements track their own precision, we don't want to truncate them
Expand Down

0 comments on commit 886ed8d

Please sign in to comment.