Opened 14 years ago

Closed 14 years ago

#6 closed defect (fixed)

PowerSeriesRing(QQ, 10) raises unhelpful exception

Reported by: dmharvey Owned by: somebody
Priority: minor Milestone:
Component: basic arithmetic Keywords:
Cc: Merged in:
Authors: Reviewers:
Report Upstream: Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Description

PowerSeriesRing?(QQ, 10) crashes SAGE:

Traceback (most recent call last):

PowerSeriesRing?(QQ, 10)

File "/home/server/", line 1, in ?

File "/sage/local/lib/python2.4/site-packages/sage/rings/power_series_ring.py",

line 44, in PowerSeriesRing?

R = PowerSeriesRing_over_field(base_ring, name, default_prec)

File "/sage/local/lib/python2.4/site-packages/sage/rings/power_series_ring.py",

line 171, in init

PowerSeriesRing_generic.init(self, base_ring, name, default_prec)

File "/sage/local/lib/python2.4/site-packages/sage/rings/power_series_ring.py",

line 63, in init

self.generator = self.power_series_class(self, [0,1], check=True,

is_gen=True)

File

"/sage/local/lib/python2.4/site-packages/sage/rings/power_series_ring_element.py", line 506, in init

f = R(f, check=check)

File "/sage/local/lib/python2.4/site-packages/sage/rings/multi_polynomial_ring.py",

line 481, in call

c = self.base_ring()(x)

File "/sage/local/lib/python2.4/site-packages/sage/rings/rational_field.py", line

155, in call

return sage.rings.rational.Rational(x, base)

File "rational.pyx", line 105, in rational.Rational.init File "rational.pyx", line 183, in rational.Rational.set_value

TypeError?: Unable to coerce [0, 1] (<type 'list'>) to Rational

Change History (3)

comment:1 Changed 14 years ago by anonymous

  • Summary changed from PowerSeriesRing(QQ, 10) crashes SAGE to PowerSeriesRing(QQ, 10) raises exception

comment:2 Changed 14 years ago by anonymous

  • Priority changed from major to minor
  • Summary changed from PowerSeriesRing(QQ, 10) raises exception to PowerSeriesRing(QQ, 10) raises unhelpful exception

Ah. I thought that second parameter was the precision. It's actually a variable name. Still, it shouldn't be crashing like this :-)

comment:3 Changed 14 years ago by was

  • Resolution set to fixed
  • Status changed from new to closed

Fixed

def PowerSeriesRing(base_ring, name=None, default_prec=20):
    """
    EXAMPLES:
        sage: R = PowerSeriesRing(QQ); R
        Power Series Ring in x over Rational Field

        sage: S = PowerSeriesRing(QQ, 'y'); S
        Power Series Ring in y over Rational Field
        
        sage: R = PowerSeriesRing(QQ, 10)
        Traceback (most recent call last):
        ...
        TypeError: variable name must be a string or None

        sage: S = PowerSeriesRing(QQ, default_prec = 15); S
        Power Series Ring in x over Rational Field
        sage: S.default_prec()
        15
    """
    #global _objsPowerSeriesRing
    #key = (base_ring, name, default_prec)
    #if _objsPowerSeriesRing.has_key(key):
    #    x = _objsPowerSeriesRing[key]()
    #    if x != None: return x

    if not (name is None or isinstance(name, str)):
        raise TypeError, "variable name must be a string or None"
        
                  
    if isinstance(base_ring, field.Field):
        R = PowerSeriesRing_over_field(base_ring, name, default_prec)
    elif isinstance(base_ring, integral_domain.IntegralDomain):
        R = PowerSeriesRing_domain(base_ring, name, default_prec)
    elif isinstance(base_ring, commutative_ring.CommutativeRing):
        R = PowerSeriesRing_generic(base_ring, name, default_prec)
    else:
        raise TypeError, "base_ring must be a commutative ring"
    #_objsPowerSeriesRing[key] = weakref.ref(R)
    return R
Note: See TracTickets for help on using tickets.