CodeSOD: A Tight Fitter

This post was originally published on this site

The Daily WTF

Part of the pitch of Python is that it’s a language which values simplicity and ease of use. Whether it lives up to that pitch is its own discussion, but the good news is that if you really want to create really complex code with loads of inheritance and nasty interrelationships, you can.

Today’s anonymous submitter started out by verifying some of the math in some extremely math-y analytical code. Previously, they’d had problems where the documentation and the code were subtly different, so it was important that they understood exactly what the code was doing.

In one file, they found the core class they cared about:

class WeibullFitter(KnownModelParametricUnivariateFitter): # snip: some math

Now, the math looked more or less right. But there was just one problem: who knows how the superclass interacts with that? Subtle changes in behavior could appear there.

class KnownModelParametricUnivariateFitter(ParametricUnivariateFitter): _KNOWN_MODEL = True

To read the full article click on the 'post' link at the top.