Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
extend error messages in element_constructor and test for nonzeroness
Browse files Browse the repository at this point in the history
  • Loading branch information
dkrenn committed Aug 26, 2015
1 parent d759c8e commit ab05e75
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/sage/rings/asymptotic/asymptotic_ring.py
Original file line number Diff line number Diff line change
Expand Up @@ -1291,7 +1291,8 @@ def _element_constructor_(self, data, summands=None, simplify=True):
sage: y = ZZ['y'].gen(); AR(y)
Traceback (most recent call last):
...
TypeError: Cannot convert y to an asymptotic expression.
TypeError: Cannot convert y to an asymptotic expression
in Asymptotic Ring <x^ZZ> over Integer Ring.
"""
if summands is not None:
if type(data) != int or data != 0:
Expand All @@ -1313,12 +1314,13 @@ def _element_constructor_(self, data, summands=None, simplify=True):
if isinstance(data, (list, tuple)):
if not all(isinstance(elem, GenericTerm) for elem in data):
raise TypeError('Not all list entries of %s '
'are asymptotic terms.' % (data,))
'are asymptotic terms, so cannot create an '
'asymptotic expression in %s.' % (data, self))
summands = AsymptoticRing._create_empty_summands_()
summands.union_update(data)
return self.element_class(self, summands, simplify=simplify)

if data == 0:
if not data or data == 0:
summands = AsymptoticRing._create_empty_summands_()
return self.element_class(self, summands, simplify=simplify)

Expand All @@ -1337,7 +1339,7 @@ def _element_constructor_(self, data, summands=None, simplify=True):
return self.create_summand('exact', growth=1, coefficient=coefficient)

raise TypeError('Cannot convert %s to an asymptotic '
'expression.' % (data,))
'expression in %s.' % (data, self))


def _coerce_map_from_(self, R):
Expand Down

0 comments on commit ab05e75

Please sign in to comment.