Ticket #9633 (closed defect: fixed)

Opened 3 years ago

Last modified 22 months ago

binomial does not accept float

Reported by: Henryk.Trappmann Owned by: AlexGhitza
Priority: major Milestone: sage-4.7.1
Component: basic arithmetic Keywords:
Cc: kcrisman Work issues:
Report Upstream: N/A Reviewers: Douglas McNeil, Karl-Dieter Crisman
Authors: Johan Bosman Merged in: sage-4.7.1.alpha0
Dependencies: Stopgaps:

Description

sage: binomial(0.5r,5)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call
last)

/home/bo198214/projects/<ipython console> in <module>()

/opt/sage-4.5-linux-32bit-ubuntu_10.04_lts-i686-Linux/local/lib/
python2.6/site-packages/sage/rings/arith.pyc in binomial(x, m)
   2887     if isinstance(x, (float, sage.rings.real_mpfr.RealNumber,
   2888                       sage.rings.real_mpfr.RealLiteral)):
-> 2889         P = x.parent()
   2890         if m < 0:
   2891             return P(0)

AttributeError: 'float' object has no attribute 'parent' 

Attachments

trac_9633_binomial_float.patch Download (1.1 KB) - added by johanbosman 2 years ago.

Change History

comment:1 Changed 3 years ago by kcrisman

  • Cc kcrisman added

comment:2 Changed 2 years ago by johanbosman

  • Status changed from new to needs_review

comment:3 Changed 2 years ago by johanbosman

  • Authors set to Johan Bosman

comment:4 Changed 2 years ago by dsm

Two points: (1) I think "P = parent(x)" is simpler, if I'm reading sage.structure.parent correctly. (2) Doctest? :^)

Changed 2 years ago by johanbosman

comment:5 Changed 2 years ago by johanbosman

Good points. :).

comment:6 Changed 2 years ago by kcrisman

  • Reviewers set to Douglas S. McNeil, Karl-Dieter Crisman

Certainly looks good! Interesting that we didn't catch that when we put it in, even though it explicitly has 'float' in the previous version :(

Currently running tests in case there was something subtle about x.parent() that was different from parent(x), though I can't see what that would be ...

comment:7 Changed 2 years ago by kcrisman

  • Status changed from needs_review to positive_review
  • Milestone set to sage-4.7.1

Pass :) Good catch.

comment:8 Changed 2 years ago by jdemeyer

  • Status changed from positive_review to closed
  • Resolution set to fixed
  • Merged in set to sage-4.7.1.alpha0

comment:9 Changed 22 months ago by jdemeyer

  • Reviewers changed from Douglas S. McNeil, Karl-Dieter Crisman to Douglas McNeil, Karl-Dieter Crisman
Note: See TracTickets for help on using tickets.