Opened 10 years ago

Closed 7 years ago

#11283 closed defect (fixed)

algdep throws exception on valid input

Reported by: dunfield Owned by: was
Priority: major Milestone: sage-5.12
Component: number theory Keywords:
Cc: Merged in: sage-5.12.beta2
Authors: Mike Hansen Reviewers: Nathan Dunfield
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:


The algdep function chokes when the input is a vanilla Python complex number. There is explicit code in algdep to handle this case, but it tries to convert the input to a Sage ComplexField? element by a nonexistent method. Really, the traceback says it all:

sage: z = complex("1+2j")
sage: z
sage: type(z)
<type 'complex'>
sage: algdep(z, 4)
AttributeError                            Traceback (most recent call last)

/Users/dunfield/Dropbox/knot-genus/Genus-Comp/<ipython console> in <module>()

/pkgs/sage-4.6/local/lib/python2.6/site-packages/sage/rings/arith.pyc in algdep(z, degree, known_bits, use_bits, known_digits, use_digits, height_bound, proof)
    190         z = sage.rings.real_mpfr.RR(z)
    191     elif isinstance(z, complex):
--> 192         z = sage.rings.complex_field.CC(z)
    194     if isinstance(z, (sage.rings.real_mpfr.RealNumber,

AttributeError: 'module' object has no attribute 'CC'

This could be fixed simply by changing line 192 to

z = sage.rings.complex_field.ComplexField()(z)

but I'm not sure if this the canonical way to do things, and hence didn't submit a patch.

Attachments (1)

trac_11283.patch (1.0 KB) - added by mhansen 8 years ago.

Download all attachments as: .zip

Change History (6)

Changed 8 years ago by mhansen

comment:1 Changed 8 years ago by mhansen

  • Authors set to Mike Hansen
  • Status changed from new to needs_review

comment:2 Changed 7 years ago by dunfield

  • Status changed from needs_review to positive_review

This is my first time reviewing a patch, but I followed the developer instructions pretty carefully. Testing was done against Sage 5.10 on OS X Snow Leopard. All doctests pass (except "sage/numerical/mip.pyx" which don't pass on this machine normally) and the documentation looks fine. The patch certainly fixes the bug I reported and I double checked that algdep now works for various Python native types (int, float, complex).

comment:3 Changed 7 years ago by jdemeyer

  • Milestone changed from sage-5.11 to sage-5.12

You should add your real name as Reviewer on this ticket.

comment:4 Changed 7 years ago by dunfield

  • Reviewers set to Nathan Dunfield

comment:5 Changed 7 years ago by jdemeyer

  • Merged in set to sage-5.12.beta2
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.