- changed status to open
Minor bug in Olea
Issue #67
resolved
The method Olea._gen_vp() contains the following section:
try:
if p == 0:
yield (0,1)
return
if p == 1:
yield (n,1)
return
except:
pass
The variable p is not defined - you probably meant self.p.
The NameError that would normally be produced is being ignored because of the try…except. You should probably remove this, it’s almost never a good idea to ignore all errors like this.
(By the way, Bitbucket issues seem dreadfully broken - I couldn't submit this issue in Firefox.)
Comments (6)
-
repo owner -
No problem, glad to help
-
repo owner Fix Olea class (issues on corner cases with binomiial distributions) +UT (refs
#67)→ <<cset e2e959ba014e>>
-
repo owner Fix Olea class - small code improvement (refs
#67)→ <<cset e66ee2c1dc61>>
-
repo owner Hi, Paul! Your test suite is still very useful, as you can see.
-
repo owner - changed status to resolved
- Log in to comment
Well spotted! The issue can be visible in corner cases like
which displays entries with probabilities 0 and
which causes a ZeroDivisonError.
The odd
try: except;
construct was meant to prevent issues if probability is symbolic, i.e. a SymPy variable. After checks, thistry: except;
can be removed because both tests equating a SympPy variable with 0 or 1 returnFalse
, which is exactly what is needed.Independently of the present issue, the
p
attribute should better be renamed, so to avoid a name collision with methodp(…)
defined on any Lea instance.Many thanks for reporting this!
This will be fixed in next Lea version.