[Tutor] class uncertainty
Tue, 28 Aug 2001 10:30:41 +0200
Roeland Rengelink wrote:
> Christopher Smith wrote:
> > I've created a class which keeps track of the uncertainty in a number and
> > subsequent calculations performed with that number. It works like this:
> > def log(x):
> > if type(x)==<the type of my class>:
> > return uncertain.log(x)
> > return math.log(x)
> > I would prefer the latter so the operation is as seamless as possible.
> > That's where I need the advise, though.
> I think this is a good solution.
Where I was assuming you meant something like:
if isinstance(x, uncertain):
...return uncertain log...
So that module uncertain provides
- a log function that can take both exact and uncertain numbers as
- an uncertain class that knows how to do a log of an uncertain number.
Hope this helps,
"Half of what I say is nonsense. Unfortunately I don't know which half"