Re: String to Float, without introducing errors

2022-12-19 Thread Ángel GR
On 2022-12-19 16:14, MRAB wrote: To be fair, I don't think I've never seen that notation either! I've only ever seen the form 6.67430E-11 ± 0.00015E-11, which is much clearer. We use it regularly in our experimental data: 6.3(4), 15.002(10). Things would become complex using exponential forms

Re: String to Float, without introducing errors

2022-12-19 Thread Michael F. Stemper
point of using Decimal if you start with nothing more than float accuracy? Right. He also interpreted the notation "6.67430(15)E-11" wrong. The digits in parentheses represent the uncertainty in the same number of last digits. So "6.67430(15)E-11" means "something between 6.

Re: String to Float, without introducing errors

2022-12-19 Thread Sabrina Almodóvar
On 17/12/2022 18:55, Stefan Ram wrote: > Grant Edwards writes: >> Yes, fixed point (or decimal) is a better fit for what he's doing. but >> I suspect that floating point would be a better fit for the problem >> he's trying to solve. > > I'd like to predict that within the next ten posts in this

Re: String to Float, without introducing errors

2022-12-19 Thread Greg Ewing
On 19/12/22 9:24 am, Stefan Ram wrote: So what's the time until a mass of one gram arrives at the ground versus a mass of ten grams? I think one needs "Decimal" to calculate this! Or you can be smarter about how you calculate it. Differentiating t with respect to m gives dt/dm = -0.5 * sqr

Re: String to Float, without introducing errors

2022-12-19 Thread Peter J. Holzer
On 2022-12-19 15:14:14 +, MRAB wrote: > On 2022-12-19 14:10, Peter J. Holzer wrote: > > He also interpreted the notation "6.67430(15)E-11" wrong. The > > digits in parentheses represent the uncertainty in the same number of > > last digits. So "6.67430(15)E-11" means "something between 6.67430E

Re: String to Float, without introducing errors

2022-12-19 Thread MRAB
h nothing more than float accuracy? Right. He also interpreted the notation "6.67430(15)E-11" wrong. The digits in parentheses represent the uncertainty in the same number of last digits. So "6.67430(15)E-11" means "something between 6.67430E-11 - 0.00015E-11 and 6.67430E-11

Re: String to Float, without introducing errors

2022-12-19 Thread Thomas Passin
more than float accuracy? Right. He also interpreted the notation "6.67430(15)E-11" wrong. The digits in parentheses represent the uncertainty in the same number of last digits. So "6.67430(15)E-11" means "something between 6.67430E-11 - 0.00015E-11 and 6.67430E-11 + 0.0001

Re: String to Float, without introducing errors

2022-12-19 Thread Peter J. Holzer
On 2022-12-19 09:25:17 +1100, Chris Angelico wrote: > On Mon, 19 Dec 2022 at 07:57, Stefan Ram wrote: > > G = Decimal( 6.6743015E-11 ) > > r = Decimal( 6.371E6 ) > > M = Decimal( 5.9722E24 ) > > What's the point of using Decimal if you start with nothing more t

Re: String to Float, without introducing errors

2022-12-18 Thread Cameron Simpson
On 19Dec2022 08:53, Cameron Simpson wrote: I'm no expert on floating point coding for precision, but I believe that trying to work with values "close together" in magnitude is important because values of different scales inherently convert one of them to the other scale (i.e. similar sized exp

Re: String to Float, without introducing errors

2022-12-18 Thread Greg Ewing
aware of what goes on under the bonnet. When you convert a string to a float, you're already getting the closest possible value in binary floating point. For things like physics simulations, you need to design your algorithms so that they're tolerant of small inaccuracies in the represe

Re: String to Float, without introducing errors

2022-12-18 Thread Chris Angelico
On Mon, 19 Dec 2022 at 07:57, Stefan Ram wrote: > G = Decimal( 6.6743015E-11 ) > r = Decimal( 6.371E6 ) > M = Decimal( 5.9722E24 ) What's the point of using Decimal if you start with nothing more than float accuracy? ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: String to Float, without introducing errors

2022-12-18 Thread Cameron Simpson
places, but I would like to be in control of or fully aware of what goes on under the bonnet. First the short take: your machine pobably is quite precise, and float is far more performant that the other numeric types available. Your source data seem to have more round off than the rounding in a

Re: String to Float, without introducing errors

2022-12-18 Thread dn
On 18/12/2022 10.55, Stefan Ram wrote: Grant Edwards writes: Yes, fixed point (or decimal) is a better fit for what he's doing. but I suspect that floating point would be a better fit for the problem he's trying to solve. I'd like to predict that within the next ten posts in this thread

String to Float, without introducing errors

2022-12-18 Thread Paul St George
oach would not have helped you, because each of those calculations would be done as floating point, and you wouldn't have gotten any more precision (and maybe less) than simply doing float('64550.727'). Here is a small but interesting discussion thread about float vs Decimal: https:/

Re: String to Float, without introducing errors

2022-12-18 Thread rbowman
On Sun, 18 Dec 2022 11:14:28 -0500, Dennis Lee Bieber wrote: > .. And maybe lament the days when a 3-digit result was acceptable in > math class -- being the typical capability in reading a standard (10" > scale) slide rule. Arguably more thought was given to what those three digits meant in the

Re: String to Float, without introducing errors

2022-12-18 Thread Thomas Passin
have helped you, because each of those calculations would be done as floating point, and you wouldn't have gotten any more precision (and maybe less) than simply doing float('64550.727'). Here is a small but interesting discussion thread about float vs Decimal: https://stackoverflow.co

String to Float, without introducing errors

2022-12-18 Thread Paul St George
* 0.1) + (2 * 0.01) + (7 * 0.001) > > Now I do not need to! And that approach would not have helped you, because each of those calculations would be done as floating point, and you wouldn't have gotten any more precision (and maybe less) than simply doing float('64550.727'). H

RE: String to Float, without introducing errors

2022-12-17 Thread avi.e.gross
: python-list@python.org Subject: Re: String to Float, without introducing errors On 12/17/22 07:15, Thomas Passin wrote: > You have strings, and you want to end up with numbers. The numbers > are not integers. Other responders have gone directly to whether you > should use float or decim

Re: String to Float, without introducing errors

2022-12-17 Thread Chris Angelico
On Sun, 18 Dec 2022 at 09:46, Stefan Ram wrote: > > Grant Edwards writes: > >Yes, fixed point (or decimal) is a better fit for what he's doing. but > >I suspect that floating point would be a better fit for the problem > >he's trying to solve. > > I'd like to predict that within the next ten po

Re: String to Float, without introducing errors

2022-12-17 Thread dn
numbers in my code, I want to change the Strings to Float type because the code will not work with Strings but I do not want to change the numbers in any other way. s = "-64550.727" f = float(s) f -64550.727 type(f) (Contrary to the other people posting in this thread I don't

Re: String to Float, without introducing errors

2022-12-17 Thread Thomas Passin
imply doing float('64550.727'). Here is a small but interesting discussion thread about float vs Decimal: https://stackoverflow.com/questions/32053647/comparing-python-decimals-created-from-float-and-string Would you mind telling us why that degree of precision (that is, decimal vs

Re: String to Float, without introducing errors

2022-12-17 Thread Peter J. Holzer
On 2022-12-17 21:45:06 +0100, Paul St George wrote: > It was the rounding rounding error that I needed to avoid (as Peter J. > Holzer suggested). The use of decimal solved it and just in time. I > was about to truncate the number, get each of the characters from the > string mantissa, and then do s

Re: String to Float, without introducing errors

2022-12-17 Thread Chris Angelico
On Sun, 18 Dec 2022 at 08:22, Grant Edwards wrote: > > On 2022-12-17, Chris Angelico wrote: > > >> It was the rounding rounding error that I needed to avoid (as Peter > >> J. Holzer suggested). The use of decimal solved it and just in > >> time. I was about to truncate the number, get each of the

Re: String to Float, without introducing errors

2022-12-17 Thread Grant Edwards
On 2022-12-17, Chris Angelico wrote: >> It was the rounding rounding error that I needed to avoid (as Peter >> J. Holzer suggested). The use of decimal solved it and just in >> time. I was about to truncate the number, get each of the >> characters from the string mantissa, and then do something

Re: String to Float, without introducing errors

2022-12-17 Thread Chris Angelico
On Sun, 18 Dec 2022 at 07:46, Paul St George wrote: > > Thanks to all! > It was the rounding rounding error that I needed to avoid (as Peter J. Holzer > suggested). The use of decimal solved it and just in time. I was about to > truncate the number, get each of the characters from the string man

Re: String to Float, without introducing errors

2022-12-17 Thread Paul St George
0.727 >> -64511.489 >> -64393.637 >> -64196.763 >> -63920.2 > >> When I bring the numbers into my code, they are Strings. To use the >> numbers in my code, I want to change the Strings to Float type >> because the code will not work with Strings

Re: String to Float, without introducing errors

2022-12-17 Thread Thomas Passin
On 12/17/2022 1:41 PM, Mats Wichmann wrote: On 12/17/22 07:15, Thomas Passin wrote: You have strings, and you want to end up with numbers.  The numbers are not integers.  Other responders have gone directly to whether you should use float or decimal as the conversion, but that is a secondary

Re: String to Float, without introducing errors

2022-12-17 Thread Mats Wichmann
On 12/17/22 07:15, Thomas Passin wrote: You have strings, and you want to end up with numbers.  The numbers are not integers.  Other responders have gone directly to whether you should use float or decimal as the conversion, but that is a secondary matter. If you have integers, convert with

Re: String to Float, without introducing errors

2022-12-17 Thread Thomas Passin
You have strings, and you want to end up with numbers. The numbers are not integers. Other responders have gone directly to whether you should use float or decimal as the conversion, but that is a secondary matter. If you have integers, convert with integer = int(number_string) If you

Re: String to Float, without introducing errors

2022-12-17 Thread Peter J. Holzer
mbers in my code, I want to change the Strings to Float type because > the code will not work with Strings but I do not want to change the > numbers in any other way. >>> s = "-64550.727" >>> f = float(s) >>> f -64550.727 >>> type(f) (Contrary to th

Re: String to Float, without introducing errors

2022-12-17 Thread Alan Gauld
he > numbers in my code, I want to change the Strings to Float type > because the code will not work with Strings but I do not want > to change the numbers in any other way. That may be impossible. Float type is not exact and the conversion will be the closest binary representation of

Re: String to Float, without introducing errors

2022-12-17 Thread Weatherby,Gerard
https://docs.python.org/3/library/decimal.html Get Outlook for iOS<https://aka.ms/o0ukef> From: Python-list on behalf of Paul St George Sent: Saturday, December 17, 2022 6:51:17 AM To: python-list@python.org Subject: String to Float, without introducing

String to Float, without introducing errors

2022-12-17 Thread Paul St George
in my code, I want to change the Strings to Float type because the code will not work with Strings but I do not want to change the numbers in any other way. So, I want my Strings (above) to be these numbers. -64550.727 -64511.489 -64393.637 -64196.763 -63920.2 -63563.037 -63124.156 -62602.254

Re: About float/double type number in range.

2020-08-26 Thread Rob Cliffe via Python-list
On 26/08/2020 12:02, Peter J. Holzer wrote: On 2020-08-26 22:40:36 +1200, dn via Python-list wrote: On 26/08/2020 19:58, Joel Goldstick wrote: [...] <<< Code NB Python v3.8 >>> def fp_range( start:float, stop:float, step:float=1.0 )->float: ""&quo

Re: About float/double type number in range.

2020-08-26 Thread Terry Reedy
On 8/26/2020 6:40 AM, dn via Python-list wrote: def fp_range( start:float, stop:float, step:float=1.0 )->float:     """Generate a range of floating-point numbers."""     if stop <= start:     raise OverflowError( "RangeError: start must be less

Re: About float/double type number in range.

2020-08-26 Thread Richard Damon
On 8/25/20 10:39 PM, ADITYA wrote: >Dear Sir/Ma’am > >I am requesting you to satisfy me about float number in Range function, >because in the argument of range we can take integer but not double or >float whenever double as well as float are integer in nature but w

Re: About float/double type number in range.

2020-08-26 Thread Peter J. Holzer
On 2020-08-26 22:40:36 +1200, dn via Python-list wrote: > On 26/08/2020 19:58, Joel Goldstick wrote: > > On Wed, Aug 26, 2020 at 3:43 AM ADITYA wrote: > > > Dear Sir/Ma’am > > > > > > I am requesting you to satisfy me about float number in Rang

Re: About float/double type number in range.

2020-08-26 Thread dn via Python-list
On 26/08/2020 19:58, Joel Goldstick wrote: On Wed, Aug 26, 2020 at 3:43 AM ADITYA wrote: Dear Sir/Ma’am I am requesting you to satisfy me about float number in Range function, because in the argument of range we can take integer but not double or float whenever double as well

Re: About float/double type number in range.

2020-08-26 Thread Joel Goldstick
On Wed, Aug 26, 2020 at 3:43 AM ADITYA wrote: > >Dear Sir/Ma’am > >I am requesting you to satisfy me about float number in Range function, >because in the argument of range we can take integer but not double or >float whenever double as well as float are integer

About float/double type number in range.

2020-08-26 Thread ADITYA
Dear Sir/Ma’am I am requesting you to satisfy me about float number in Range function, because in the argument of range we can take integer but not double or float whenever double as well as float are integer in nature but when we use double/float in, it gives error that- “'

Re: Why I am getting IndexError: tuple index out of range when converting a float value to a string?

2019-06-11 Thread Terry Reedy
On 6/11/2019 1:04 PM, Rob Gaddi wrote: On 6/11/19 9:52 AM, madhavanbom...@gmail.com wrote: I wrote the following lines of code: xm = np.nanmean(x[indx],axis=None,dtype=float) xsd = np.nanstd(x[indx],axis=None,dtype=float) type(xm)    # np.float64 type(xsd    # np.float64 print(xm

Re: Why I am getting IndexError: tuple index out of range when converting a float value to a string?

2019-06-11 Thread Rob Gaddi
On 6/11/19 9:52 AM, madhavanbom...@gmail.com wrote: I wrote the following lines of code: xm = np.nanmean(x[indx],axis=None,dtype=float) xsd = np.nanstd(x[indx],axis=None,dtype=float) type(xm)# np.float64 type(xsd# np.float64 print(xm) # 0.5414720812182742 print(xsd

Why I am getting IndexError: tuple index out of range when converting a float value to a string?

2019-06-11 Thread madhavanbomidi
I wrote the following lines of code: xm = np.nanmean(x[indx],axis=None,dtype=float) xsd = np.nanstd(x[indx],axis=None,dtype=float) type(xm)# np.float64 type(xsd# np.float64 print(xm) # 0.5414720812182742 print(xsd) # 0.15748041033663002 print(str("{6.5f}"

Re: How to split a list type array into float array?

2019-05-21 Thread Ervin Hegedüs
> 27.1019 26.9223 26.7426 26.5630 26.3834 26.2037 26.0241 > 25.8445 25.6649 25.4852 25.3056 25.1260 24.9463 24.7667 24.5871 > 24.4075 24.2278 24.0482 -0.2616 -0.3215 -0.3813 -0.4412\n'] > > Can anyone help me split as a float array?

Re: How to split a list type array into float array?

2019-05-21 Thread Alister via Python-list
7.1019 26.9223 26.7426 26.5630 26.3834 26.2037 > 26.0241 25.8445 25.6649 25.4852 25.3056 25.1260 24.9463 > 24.7667 24.5871 24.4075 24.2278 24.0482 -0.2616 -0.3215 > -0.3813 -0.4412\n'] > > Can anyone help me split as a float array? >

How to split a list type array into float array?

2019-05-21 Thread Madhavan Bomidi
.4852 25.3056 25.1260 24.9463 24.7667 24.5871 24.4075 24.2278 24.0482 -0.2616 -0.3215 -0.3813 -0.4412\n'] Can anyone help me split as a float array? Thanks in advance -- https://mail.python.org/mailman/listinfo/python-list

RE: FW: Why float('Nan') == float('Nan') is False

2019-02-15 Thread Avi Gross
Greg, Good eye. You are correct! Yes, that is a side effect I did not intend when I cut and paste and the darn spell-checker saw it as useful to make my code act like the start of a normal text sentence. I just replicated it: >>> float(" nan") Nan As I watched, "nan&qu

Re: FW: Why float('Nan') == float('Nan') is False

2019-02-15 Thread Gregory Ewing
Avi Gross wrote: I can see why you may be wondering. You see the nan concept as having a specific spelling using all lowercase and to an extent you are right. No, he's talking about this particular line from the transcript you posted: >>>float(" nan") >

Re: FW: Why float('Nan') == float('Nan') is False

2019-02-14 Thread Chris Angelico
On Fri, Feb 15, 2019 at 4:15 PM Avi Gross wrote: > > > You shouldn't be testing floats for identity. > > I am not suggesting anyone compare floats. I repeat that a nan is not > anything. Now as a technicality, it is considered a float by the type > command as there is

RE: FW: Why float('Nan') == float('Nan') is False

2019-02-14 Thread Avi Gross
considered a float by the type command as there is no easy way to make an int that is a nan: Here are multiple ways to make a nan: >>> f = float("nan") >>> type(f) Oddly you can make a complex nan, sort of: >>> c = complex("nan") >>> c (n

Re: FW: Why float('Nan') == float('Nan') is False

2019-02-14 Thread Chris Angelico
all nans are the same, or is it all nans are different? > > >>> floata = float('nan') > >>> floatb = float('nan') > >>> floata, floatb > (nan, nan) > >>> floata == floatb > False > >>> floata is floatb >

RE: FW: Why float('Nan') == float('Nan') is False

2019-02-14 Thread Avi Gross
Grant, I can see why you may be wondering. You see the nan concept as having a specific spelling using all lowercase and to an extent you are right. As I pointed out. In the context of a string to convert to a float, any upper/lower-case spelling of NaN is accepted. But, to answer you anyway, I

Re: FW: Why float('Nan') == float('Nan') is False

2019-02-14 Thread Grant Edwards
On 2019-02-14, Avi Gross wrote: > I experimented a bit: > >>>> float("nan ") > nan >>>> float(" nan") > Nan >>>> float(" nAn") > nan That's curious. I've never seen "Nan" before. What versi

FW: Why float('Nan') == float('Nan') is False

2019-02-14 Thread Avi Gross
Other people have replied well enough with better ways to do this but I am stuck on WHY this was seen as a way to do this at all. The code was: r = float('Nan') while r==float('Nan'): inp = input("Enter a number\n") try: r = float(inp)

Re: Why float('Nan') == float('Nan') is False

2019-02-14 Thread Joe Pfeiffer
Chris Angelico writes: > > Or even better, use None instead of nan. There's nothing in Python > says you have to (ab)use a floating-point value as a signal. Or use > "while True" and add a break if the exception isn't thrown. Good point. -- https://mail.python.org/mailman/listinfo/python-list

Re: Why float('Nan') == float('Nan') is False

2019-02-14 Thread אורי
> Or even better, use None instead of nan. ++ On Thu, Feb 14, 2019 at 3:26 AM Joe Pfeiffer wrote: > u...@speedy.net writes: > > > There are more integers than odd numbers, and more odd numbers than prime > > numbers. An infinite set may be a subset of another infinite set although > > they may

Re: Why float('Nan') == float('Nan') is False

2019-02-14 Thread Chris Angelico
On Fri, Feb 15, 2019 at 3:56 AM Joe Pfeiffer wrote: > > ast writes: > > > Le 13/02/2019 à 14:21, ast a écrit : > >> Hello > >> > >> >>> float('Nan') == float('Nan') > >> False > >> > >> Why ? >

Re: Why float('Nan') == float('Nan') is False

2019-02-14 Thread Joe Pfeiffer
ast writes: > Le 13/02/2019 à 14:21, ast a écrit : >> Hello >> >> >>> float('Nan') == float('Nan') >> False >> >> Why ? >> >> Regards >> > > Thank you for answers. > > If you wonder how I

Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread ast
Le 13/02/2019 à 14:21, ast a écrit : Hello >>> float('Nan') == float('Nan') False Why ? Regards Thank you for answers. If you wonder how I was trapped with it, here is the failing program. r = float('Nan') while r==float('Nan'): i

Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Joe Pfeiffer
u...@speedy.net writes: > There are more integers than odd numbers, and more odd numbers than prime > numbers. An infinite set may be a subset of another infinite set although > they may both have the same cardinality. Or in other words, the number of > elements in each set is not equal. One has m

Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Joe Pfeiffer
songbird writes: > Chris Angelico wrote: >> On Thu, Feb 14, 2019 at 7:12 AM Test Bot wrote: >>> >>> This definition of NaN is much better in mentally visualizing all the so >>> called bizarreness of IEEE. This also makes intuitive that no 2 NaN will be >>> equal just as no 2 infinities would be

Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Chris Angelico
On Thu, Feb 14, 2019 at 11:01 AM songbird wrote: > all such proofs i have ever seen are based upon the > assumptions that there are infinite numbers of such > things like primes. I posted an abbreviated proof of that in a footnote. It's a proof by contradiction. First, assume that there are, in

Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread songbird
Chris Angelico wrote: > On Thu, Feb 14, 2019 at 7:12 AM Test Bot wrote: >> >> This definition of NaN is much better in mentally visualizing all the so >> called bizarreness of IEEE. This also makes intuitive that no 2 NaN will be >> equal just as no 2 infinities would be equal. I believe in a hypo

Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Chris Angelico
On Thu, Feb 14, 2019 at 9:07 AM Avi Gross wrote: > But that means that normal mathematics is warped. Well yes. Yes, it is. That's why people think "Alice's Adventures in Wonderland" is the result of a drug-induced dream - in actual fact, it's the result of the Dean of Mathematics telling stor

Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Avi Gross
I think we should realize that Nan and NA and so on are human constructs people Define in programming languages. Some have subdivisions as in not an int as compared to not a float. Python also has an Inf as well as a -Inf that are abstractions and not a real, so to speak. Number. Mathematics

Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Chris Angelico
‪On Thu, Feb 14, 2019 at 8:24 AM ‫אורי‬‎ wrote:‬ > On Wed, Feb 13, 2019 at 10:20 PM Chris Angelico wrote: >> >> Why would no two infinities be equal? In mathematics, there's one >> best-known infinity (aleph null, aka the number of counting numbers), >> and many many infinities are provably equal

Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread אורי
ther one has more elements than the first one. So the number of elements in two infinite sets can't be equal. Even, if you compare the same set to itself. > > >>> float("inf") == float("inf") > True > > NaN and infinity are quite different concepts, an

Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Rob Gaddi
x27;t know what is in them. Then, how do you explain: >>> float("nan") != float("nan") True Why's that not False? Marko Because IEEE-754 decided that it was non-optional that (x != y) was equal to not (x == y). Which is not the case for the

Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Marko Rauhamaa
. Then, how do you explain: >>> float("nan") != float("nan") True Why's that not False? Marko -- https://mail.python.org/mailman/listinfo/python-list

Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Chris Angelico
size of the set of odd numbers" [1]. And both Python and IEEE agree: >>> float("inf") == float("inf") True NaN and infinity are quite different concepts, and they behave very differently. ChrisA [1] I'm sure someone will point out something pedantica

Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Test Bot
similar to any set of operations on the set of Infinities. On Thu, Feb 14, 2019, 12:33 AM Avi Gross I won't speak for the IEEE but NOT A NUMBER does not tell you what > something > IS. > > If "Hello, World!" is not a number as in an int or a float and we throw > away >

Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Dan Sommers
On 2/13/19 1:53 PM, Grant Edwards wrote: Floating point is sort of the quantum mechanics of computer science. At first glance, it seems sort of weird. But after you work with it a while, it gets even worse. Yep! :-) -- https://mail.python.org/mailman/listinfo/python-list

Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Chris Angelico
On Thu, Feb 14, 2019 at 6:55 AM Grant Edwards wrote: > > On 2019-02-13, Schachner, Joseph wrote: > > > This makes some sense because NAN is Not A Number, so any comparison > > to a number fails. > > Ah, but you now seem to be conflating "comparison fails" with > "comparison has a boolean value of

Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Chris Angelico
a nullable column (say, taking the sum or average of the values in a field), you just ignore any rows that are NULL; but if *every* value is NULL, the sum is not 0, but NULL. Now try mapping SQL's NULL to Python's float("nan"), and performing operations on both sides. Endless fun. ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Grant Edwards
On 2019-02-13, Schachner, Joseph wrote: > This makes some sense because NAN is Not A Number, so any comparison > to a number fails. Ah, but you now seem to be conflating "comparison fails" with "comparison has a boolean value of False". The alternative to (nan == nan) => False is probably not (

RE: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Schachner, Joseph
n to a number fails. --- Joseph S. -Original Message- From: ast Sent: Wednesday, February 13, 2019 8:21 AM To: python-list@python.org Subject: Why float('Nan') == float('Nan') is False Hello >>> float('Nan') == float('Nan') False Why ?

Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Joe Pfeiffer
ast writes: > Hello > >>>> float('Nan') == float('Nan') > False > > Why ? > > Regards Others have given the real answer -- IEEE says so, and the people who wrote the standard are smarter than me. All the same, this is my take on the rea

RE: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Avi Gross
I won't speak for the IEEE but NOT A NUMBER does not tell you what something IS. If "Hello, World!" is not a number as in an int or a float and we throw away the content and simply call it a NaN or something and then we notice that an object that is a list of fruits is also not

Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Grant Edwards
On 2019-02-13, ast wrote: > Hello > > >>> float('Nan') == float('Nan') > False If you think that's odd, how about this? >>> n = float('nan') >>> n nan >>> n is n True >>> n ==

Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Dan Sommers
On 2/13/19 7:21 AM, ast wrote: Hello >>> float('Nan') == float('Nan') False Why ? Because the IEEE-754 Standard demands it, and people smarter than I worked on the IEEE-754 Standard. <https://en.wikipedia.org/wiki/NaN> is a quick starting point for a deep

Why float('Nan') == float('Nan') is False

2019-02-13 Thread ast
Hello >>> float('Nan') == float('Nan') False Why ? Regards -- https://mail.python.org/mailman/listinfo/python-list

Re: How can I find the indices of an array with float values in python?

2019-01-10 Thread Madhavan Bomidi
Thank you all for various ways of finding the indices. -- https://mail.python.org/mailman/listinfo/python-list

RE: How can I find the indices of an array with float values in python?

2019-01-10 Thread Avi Gross
and consider which way to do it and then use reasonable tools. If you really want the index so you can use it later in various indexing ways, great. But if you just want to hold multiple items together by an index, consider other choices including some of the above. -Original Message----- Fr

Re: How can I find the indices of an array with float values in python?

2019-01-10 Thread MRAB
On 2019-01-10 17:05, Madhavan Bomidi wrote: Sorry for re-posting with a correction. I have an array (numpy.ndarray) with shape (1500L,) as below: x = array([ 3.e+01, 6.e+01, 9.e+01, ..., 4.4940e+04, 4.4970e+04, 4.5000e+04]) Now, I

Re: How can I find the indices of an array with float values in python?

2019-01-10 Thread Rob Gaddi
On 1/10/19 9:25 AM, Peter Otten wrote: Madhavan Bomidi wrote: I have an array (numpy.ndarray) with shape (1500L,) as below: x = array([ 3.e+01, 6.e+01, 9.e+01, ..., 4.4940e+04, 4.4970e+04, 4.5000e+04]) Now, I wanted to determine the indic

Re: How can I find the indices of an array with float values in python?

2019-01-10 Thread Peter Otten
Madhavan Bomidi wrote: > I have an array (numpy.ndarray) with shape (1500L,) as below: > > x = array([ 3.e+01, 6.e+01, 9.e+01, ..., > 4.4940e+04, 4.4970e+04, 4.5000e+04]) > > Now, I wanted to determine the indices of the x values between 0.0

RE: How can I find the indices of an array with float values in python?

2019-01-10 Thread David Raymond
PM To: python-list@python.org Subject: Re: How can I find the indices of an array with float values in python? Sorry for re-posting with a correction. I have an array (numpy.ndarray) with shape (1500L,) as below: x = array([ 3.e+01, 6.e+01, 9.e+01, ..., 4.494000

Re: How can I find the indices of an array with float values in python?

2019-01-10 Thread Madhavan Bomidi
Sorry for re-posting with a correction. I have an array (numpy.ndarray) with shape (1500L,) as below: x = array([ 3.e+01, 6.e+01, 9.e+01, ..., 4.4940e+04, 4.4970e+04, 4.5000e+04]) Now, I wanted to determine the indices of the x values bet

How can I find the indices of an array with float values in python?

2019-01-10 Thread Madhavan Bomidi
I have an array (numpy.ndarray) with shape (1500L,) as below: x = array([ 3.e+01, 6.e+01, 9.e+01, ..., 4.4940e+04, 4.4970e+04, 4.5000e+04]) Now, I wanted to determine the indices of the x values between 0.0 and 15.0. While this is simple in M

Re: What use is of this 'cast=float ,'?

2017-10-28 Thread Rick Johnson
On Friday, October 27, 2017 at 3:35:45 PM UTC-5, Robert wrote: > I read below code snippet on line. I am interested in the > second of the last line: `cast=float`. I've tried it in > Python. Even simply with: `float` It has no error, but what > use is it? > > self.

Re: What use is of this 'cast=float ,'?

2017-10-27 Thread Tim Chase
> num_steps=100, > style=wx.SL_HORIZONTAL, > cast=float , > proportion=1, > ) > I am interested in the second of the last line. > > cast=float , The space doesn't do anything. You have a parameter list, so the comma just separates "cast=float&qu

Re: What use is of this 'cast=float ,'?

2017-10-27 Thread edmondo . giovannozzi
Il giorno venerdì 27 ottobre 2017 22:35:45 UTC+2, Robert ha scritto: > Hi, > > I read below code snippet on line. I am interested in the second of the last > line. > > cast=float , > > > I've tried it in Python. Even simply with > > float >

What use is of this 'cast=float ,'?

2017-10-27 Thread Robert
Hi, I read below code snippet on line. I am interested in the second of the last line. cast=float , I've tried it in Python. Even simply with float it has no error, but what use is it? I do see a space before the comma ','. Is it a typo or not? Thanks,

Re: optional int- and float arguments

2017-10-03 Thread Steve D'Aprano
On Wed, 4 Oct 2017 12:17 pm, Stefan Ram wrote: > |>>> str(object='abc') > |'abc' That's probably also a bug. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: optional int- and float arguments

2017-10-03 Thread Steve D'Aprano
On Wed, 4 Oct 2017 03:18 am, Stefan Ram wrote: > »int« and »float« seem to behave quite similar: > > |>>> int( x = 8 ) > |8 > |>>> float( x = 8.0 ) > |8.0 I expect that these functions taking a *named* parameter "x" is an accident that should

Re: optional int- and float arguments

2017-10-03 Thread Chris Angelico
On Wed, Oct 4, 2017 at 3:18 AM, Stefan Ram wrote: > »int« and »float« seem to behave quite similar: > > |>>> int( x = 8 ) > |8 > |>>> float( x = 8.0 ) > |8.0 > |>>> int() > |0 > |>>> float() > |0.0 > > . Yet the ways th

Re: How to change variable from list to float

2017-06-05 Thread Peter Pearson
gt;> File "calcsignal.py", line 7, in >> siglevfromexist = 34.8 + existattn >> TypeError: unsupported operand type(s) for +: 'float' and 'list' >> >> How do I convert the list variable (i.e. existattn) to a float? >> >> Ope

Re: How to change variable from list to float

2017-06-05 Thread Paul Barry
The value in existattn is a single element list. The single element is a float, so just refer to it in your calculation, like so: siglevfromexist = 34.8 + existattn[0] Regards. Paul. On 3 June 2017 at 15:42, Gary Barker wrote: > I have searched for a solution to this but have not fo

How to change variable from list to float

2017-06-05 Thread Gary Barker
I have searched for a solution to this but have not found a suitable example. The attached code generates this error: Traceback (most recent call last): File "calcsignal.py", line 7, in siglevfromexist = 34.8 + existattn TypeError: unsupported operand type(s) for +: 'f

django float round tripping

2017-04-07 Thread Robin Becker
I've been having problems with django FloatFields not round tripping properly; eg field = 0.018903438896219302 gets saved and returns as 0.0189034388962193 It turns out that this is a property of the MySQLdb python interface where in converter.py we have the definition def Float2Str(o, d):

  1   2   3   4   5   6   7   8   9   10   >