On May 1, 11:13 am, smichr wrote:
> Also, this approach is limited in that only variables can be arguments
> to functions, not node expressions. If x and d are variables, x/d
> becomes an expression and you cannot compute sin(x/d). Or am I missing
> something?
>
Note to self...it's best to restar
On Apr 18, 4:21 pm, eric.le.bi...@spectro.jussieu.fr wrote:
> On Apr 15, 5:33 pm, Arnaud Delobelle wrote:
>
> I adjusted your code in a few ways, and put the result
> athttp://code.activestate.com/recipes/576721/(with due credit):
>
> 1) There was a strange behavior, which is fixed (by performing
I happened across the recent discussion and found it very interesting as I have
been dusting off and trying to get ready a module that I had made that created
a number class that handled numeric values and uncertainties in computations by
computing (via overloaded operators) a new value and unce
On Apr 15, 5:33 pm, Arnaud Delobelle wrote:
> I still don't think mutable floats are necessary. Here is an approach
> below - I'll let the code speak because I have to do some shopping!
Hats off to you, Arnaud! I'm very impressed by the ideas found in
your code. :)
Your UExpr object is almost
Th^H^H
On Apr 16, 5:51 am, a...@pythoncraft.com (Aahz) wrote:
> In article <3b01d8f1-6a77-4374-b1c2-25bee7cdf...@x3g2000yqa.googlegroups.com>,
>
> wrote:
>
> >Steven, I'd appreciate if you could refrain from criticizing so
> >bluntly so many points. I'd be great if you trusted me more for
> >kn
In article <3b01d8f1-6a77-4374-b1c2-25bee7cdf...@x3g2000yqa.googlegroups.com>,
wrote:
>
>Steven, I'd appreciate if you could refrain from criticizing so
>bluntly so many points. I'd be great if you trusted me more for
>knowing what I'm talking about; I've been a programmer for 25 years,
>now, an
Steven D'Aprano wrote:
Oh nonsense. Many programming languages have mutable floats.
That's irrelevant. Python doesn't. So introducing one will quite
likely alter the OP's code's behavior. It doesn't matter if it's
possible, it matters whether the existing code's behav
eric.le.bi...@spectro.jussieu.fr wrote:
I initially tried to create a Float_ref class that inherits from
numpy.array, so that objects of the new class behave like numpy.array
in calculations, but also contain an "uncertainty" atribute, but this
is apparently not allowed ("cannot create 'builtin_f
spectro.jussieu.fr> writes:
>
> Hello,
>
> Is there a way to easily build an object that behaves exactly like a
> float, but whose value can be changed? The goal is to maintain a list
> [x, y,…] of these float-like objects, and to modify their value on the
> fly (with something like x.value =
eric.le.bi...@spectro.jussieu.fr writes:
> Arnaud, your code is very interesting!
>
> On Apr 15, 1:00 pm, Arnaud Delobelle wrote:
>> I still don't understand why you need mutable floats.
>
> Here is why: the code that your proposed (or any code that does
> straightforward error propagation, for t
I think the term 'mutable float' is causing a lot of confusion. My
solution I wouldn't call a mutable float, but a float container that
tries to act like a float in a context where this is required.
Another solution would have been to use automatically dereferencing
pointers but that is something
On Wed, 15 Apr 2009 05:59:39 -0400, Dave Angel wrote:
> Steven D'Aprano wrote:
>> On Tue, 14 Apr 2009 14:45:47 -0400, Dave Angel wrote:
>>
>>
>>> The answer to your original question is no. If the value can be
>>> changed, then it doesn't behave like a float. And that's not just a
>>> pedantic a
Thanks, Piet! Before reading your post, I did not know that defining
__float__() was enough for math.sin() to be able to calculate
something!
To summarize my current understanding for the original problem:
- Mutable floats seem to be the only way of performing (correct)
uncertainty calculations
Arnaud, your code is very interesting!
On Apr 15, 1:00 pm, Arnaud Delobelle wrote:
> I still don't understand why you need mutable floats.
Here is why: the code that your proposed (or any code that does
straightforward error propagation, for that matter) does not generally
calculate uncertaintie
> eric.le.bi...@spectro.jussieu.fr (ELB) wrote:
>ELB> To Dave A. and Piet: I appreciate your taking the time to make
>ELB> suggestions. I understand that there is a hitch in the approach that
>ELB> you describe, which I would like to insist on: how do you handle
>ELB> functions that use math.
It looks like Dan found what is in effect a mutable float
(numpy.array).
Now, with respect to the initial problem of having mutable floats that
also contain an uncertainty attribute, I'd like to note that
numpy.ndarray can be subclassed: it now looks possible to create a
mutable float class that a
eric.le.bi...@spectro.jussieu.fr writes:
> As for your idea of "straight-forward interval arithmetic", it's a
> good one, but I'd have to redefine lots of functions from the math
> module, to use them explicitly in my code, etc.: this is heavy; I was
> looking for a light-weight alternative, where
To Dave A. and Piet: I appreciate your taking the time to make
suggestions. I understand that there is a hitch in the approach that
you describe, which I would like to insist on: how do you handle
functions that use math.sin(), for instance? numpy does this kind of
magic, but I'm not sure it's wi
Steven D'Aprano wrote:
On Tue, 14 Apr 2009 14:45:47 -0400, Dave Angel wrote:
The answer to your original question is no. If the value can be
changed, then it doesn't behave like a float. And that's not just a
pedantic answer, it's a serious consideration.
Oh nonsense. Many programmi
Steven, I'd appreciate if you could refrain from criticizing so
bluntly so many points. I'd be great if you trusted me more for
knowing what I'm talking about; I've been a programmer for 25 years,
now, and I pretty well know what my own code looks like! I appreciate
your input, but please soften
> eric.le.bi...@spectro.jussieu.fr (ELB) wrote:
[snip]
>ELB> A couple of ideas I had:
>ELB> 1) Define a FloatWithUncert object, but get instance values as x(), as
>ELB> in "x()+y()". The code is relatively legible. 'x' is mutable. But
>ELB> formulas don't look so good, and you can't drop
eric.le.bi...@spectro.jussieu.fr wrote:
Thanks Dave for your thoughtful remarks, which you sent right when I
was writing a response to the previous posts.
I was wondering about a kind "mutable float"; so you're right, it's
not fully a float, because it's mutable. I'd like to have an object
that
Dan, wow! This looks extremely promising!
I initially tried to create a Float_ref class that inherits from
numpy.array, so that objects of the new class behave like numpy.array
in calculations, but also contain an "uncertainty" atribute, but this
is apparently not allowed ("cannot create 'builti
On Wed, 15 Apr 2009 01:05:33 -0700, Eric.Le.Bigot wrote:
> Ben F., you're right on the money! You expressed exactly what I'm
> looking for. Why should I want this? because the place in the code
> where (foo, baz) is calculated has _no idea_ of what foo and baz are, of
> where they were defined,
To Peter: What I had in mind was to implement your calc() function;
you could do something similar with your loop in the previous post by
replacing "for f.shift..." by "f.shift = 1"; this would give you 2
values, which you can combine with your unused variable in order to
obtain the same value as w
eric.le.bi...@spectro.jussieu.fr wrote:
Hello,
Is there a way to easily build an object that behaves exactly like a
float, but whose value can be changed? The goal is to maintain a list
[x, y,…] of these float-like objects, and to modify their value on the
fly (with something like x.value = 3.1
Ben F., you're right on the money! You expressed exactly what I'm
looking for. Why should I want this? because the place in the code
where (foo, baz) is calculated has _no idea_ of what foo and baz are,
of where they were defined, etc.; on the other hand, the floatref
class can keep track of the
eric.le.bi...@spectro.jussieu.fr wrote:
> Now, I would like to get the uncertainty on the result, even though we
> have no idea of what quantities are used in lattice_spacing() for the
> calculation (it can be attribute that are floats, attributes that are
> FloatWithUncert, module globals defined
On Tue, 14 Apr 2009 12:36:02 -0700, Eric.Le.Bigot wrote:
> I'll give more details, as David S. and David R. were asking for. The
> code could look like this:
>
> import crystals
> my_crystal = crystals.Crystal("Quartz 111")
>
> which would set some attributes of my_crystal as "floats with
>
Steven D'Aprano writes:
> On Tue, 14 Apr 2009 06:03:58 -0700, Eric.Le.Bigot wrote:
> > The goal is to maintain a list [x, y,…] of these float-like
> > objects, and to modify their value on the fly (with something like
> > x.value = 3.14) so that any expression like "x
> > +y" uses the new value.
On Tue, 14 Apr 2009 06:03:58 -0700, Eric.Le.Bigot wrote:
> Hello,
>
> Is there a way to easily build an object that behaves exactly like a
> float, but whose value can be changed?
Yes, have a look at the source code for UserString.MutableString for some
ideas.
> The goal is to maintain a list
On Tue, 14 Apr 2009 14:45:47 -0400, Dave Angel wrote:
> The answer to your original question is no. If the value can be
> changed, then it doesn't behave like a float. And that's not just a
> pedantic answer, it's a serious consideration.
Oh nonsense. Many programming languages have mutable flo
Thanks Dave for your thoughtful remarks, which you sent right when I
was writing a response to the previous posts.
I was wondering about a kind "mutable float"; so you're right, it's
not fully a float, because it's mutable. I'd like to have an object
that behaves like a float in numerical calcula
Thank you all for your input. It is not yet obvious how to achieve
the goal/need that I had in mind in the original post. Basically, I
would need to be able to calculate the derive() function of Peter, but
without knowing what arguments are passed to the function f under
study. Here is why:
I'
eric.le.bi...@spectro.jussieu.fr wrote:
It looks like what is needed here are a kind of "mutable float". Is
there a simple way of creating such a type? I don't mind changing the
value through x.value =.23 instead of x = 1.23... :)
On Apr 14, 3:03 pm, eric.le.bi...@spectro.jussieu.fr wrote:
eric.le.bi...@spectro.jussieu.fr wrote:
> Alternatively, I'd be happy with a way of handling numerical
> uncertainties in Python calculations (such as in "calculate the value
> and uncertainty of a*sin(b) knowing that a=3.0 +/- 0.1 and b=1.00 +/-
> 0.01").
Naive no warranties implementation:
fr
Christian Heimes wrote:
eric.le.bi...@spectro.jussieu.fr wrote:
Hello,
Is there a way to easily build an object that behaves exactly like a
float, but whose value can be changed? The goal is to maintain a list
[x, y,…] of these float-like objects, and to modify their value on the
fly (with som
eric.le.bi...@spectro.jussieu.fr wrote:
> Hello,
>
> Is there a way to easily build an object that behaves exactly like a
> float, but whose value can be changed? The goal is to maintain a list
> [x, y,…] of these float-like objects, and to modify their value on the
> fly (with something like x.v
eric.le.bi...@spectro.jussieu.fr wrote:
> It looks like what is needed here are a kind of "mutable float". Is
> there a simple way of creating such a type? I don't mind changing the
> value through x.value = 1.23 instead of x = 1.23... :)
>
> On Apr 14, 3:03 pm, eric.le.bi...@spectro.jussieu.fr
On Tue, Apr 14, 2009 at 9:03 AM, wrote:
> Hello,
>
> Is there a way to easily build an object that behaves exactly like a
> float, but whose value can be changed? The goal is to maintain a list
> [x, y,…] of these float-like objects, and to modify their value on the
> fly (with something like x.
It looks like what is needed here are a kind of "mutable float". Is
there a simple way of creating such a type? I don't mind changing the
value through x.value = 1.23 instead of x = 1.23... :)
On Apr 14, 3:03 pm, eric.le.bi...@spectro.jussieu.fr wrote:
> Hello,
>
> Is there a way to easily build
Hello,
Is there a way to easily build an object that behaves exactly like a
float, but whose value can be changed? The goal is to maintain a list
[x, y,…] of these float-like objects, and to modify their value on the
fly (with something like x.value = 3.14) so that any expression like "x
+y" uses
42 matches
Mail list logo