Re: Can one output something other than 'nan' for not a number values?

2024-02-19 Thread dn via Python-list
On 20/02/24 01:04, Chris Green via Python-list wrote: dn wrote: On 18/02/24 09:53, Grant Edwards via Python-list wrote: On 2024-02-17, Cameron Simpson via Python-list wrote: On 16Feb2024 22:12, Chris Green wrote: I'm looking for a simple way to make NaN values output as something like '-'

Re: Can one output something other than 'nan' for not a number values?

2024-02-19 Thread dn via Python-list
On 20/02/24 05:58, Grant Edwards via Python-list wrote: Here's a demonstration of how to hook custom code into the f-string formatting engine. It's brilliantly depraved. https://stackoverflow.com/questions/55876683/hook-into-the-builtin-python-f-string-format-machinery From the above:

Re: Can one output something other than 'nan' for not a number values?

2024-02-19 Thread Grant Edwards via Python-list
On 2024-02-19, Chris Green via Python-list wrote: > It's using f'{...}' at the moment. Here's a demonstration of how to hook custom code into the f-string formatting engine. It's brilliantly depraved.

Re: Can one output something other than 'nan' for not a number values?

2024-02-19 Thread Chris Green via Python-list
Grant Edwards wrote: > On 2024-02-16, Chris Green via Python-list wrote: > > > I'm looking for a simple way to make NaN values output as something > > like '-' or even just a space instead of the string 'nan'. > > It would probably help if you told us how you're "outputting" them now > (the

Re: Can one output something other than 'nan' for not a number values?

2024-02-19 Thread Chris Green via Python-list
dn wrote: > On 18/02/24 09:53, Grant Edwards via Python-list wrote: > > On 2024-02-17, Cameron Simpson via Python-list > > wrote: > >> On 16Feb2024 22:12, Chris Green wrote: > >>> I'm looking for a simple way to make NaN values output as something > >>> like '-' or even just a space instead of

Re: Can one output something other than 'nan' for not a number values?

2024-02-18 Thread dn via Python-list
On 18/02/24 09:53, Grant Edwards via Python-list wrote: On 2024-02-17, Cameron Simpson via Python-list wrote: On 16Feb2024 22:12, Chris Green wrote: I'm looking for a simple way to make NaN values output as something like '-' or even just a space instead of the string 'nan'. [...]

Re: Can one output something other than 'nan' for not a number values?

2024-02-18 Thread Chris Angelico via Python-list
On Mon, 19 Feb 2024 at 06:47, Grant Edwards via Python-list wrote: > I would be tempted to try monkey-patching the float class to override > the __format__ method. I have no idea what side effects that might > have, or if it's even used by the various formatting mechanisms, so > you might end up

Re: Can one output something other than 'nan' for not a number values?

2024-02-18 Thread Piergiorgio Sartor via Python-list
On 16/02/2024 23.12, Chris Green wrote: I'm looking for a simple way to make NaN values output as something like '-' or even just a space instead of the string 'nan'. This would then make it much easier to handle outputting values from sensors when not all sensors are present. So, for example,

Re: Can one output something other than 'nan' for not a number values?

2024-02-18 Thread Grant Edwards via Python-list
On 2024-02-16, Chris Green wrote: > I'm looking for a simple way to make NaN values output as something > like '-' or even just a space instead of the string 'nan'. I tried monkey-patching the __format__ method of float, but it's immutable, so that didnt' work. Is float.__format__ what's used

Can one output something other than 'nan' for not a number values?

2024-02-18 Thread Grant Edwards via Python-list
[I've been trying all afternoon to post via slrn, but nothing is showing up on the list. Forgive me if multiple posts eventually show up.] On 2024-02-17, Cameron Simpson via Python-list wrote: > On 16Feb2024 22:12, Chris Green wrote: >>I'm looking for a simple way to make NaN values output as

Can one output something other than 'nan' for not a number values?

2024-02-18 Thread Grant Edwards via Python-list
[Posts via slrn and my GMail account aren't showing up, so I guess I'll try subscribing from a different e-mail address.] On 2024-02-17, Cameron Simpson via Python-list wrote: On 16Feb2024 22:12, Chris Green wrote: I'm looking for a simple way to make NaN values output as something like

Re: Can one output something other than 'nan' for not a number values?

2024-02-18 Thread Grant Edwards via Python-list
On 2024-02-17, Cameron Simpson via Python-list wrote: > On 16Feb2024 22:12, Chris Green wrote: >>I'm looking for a simple way to make NaN values output as something >>like '-' or even just a space instead of the string 'nan'. [...] >> >>Battery Voltages and Currents >>Leisure Battery -

Re: Can one output something other than 'nan' for not a number values?

2024-02-18 Thread Grant Edwards via Python-list
On 2024-02-17, Cameron Simpson via Python-list wrote: > On 16Feb2024 22:12, Chris Green wrote: >>I'm looking for a simple way to make NaN values output as something >>like '-' or even just a space instead of the string 'nan'. [...] >> >>Battery Voltages and Currents >>Leisure Battery -

Re: Can one output something other than 'nan' for not a number values?

2024-02-18 Thread Grant Edwards via Python-list
On 2024-02-17, Cameron Simpson via Python-list wrote: > On 16Feb2024 22:12, Chris Green wrote: >>I'm looking for a simple way to make NaN values output as something >>like '-' or even just a space instead of the string 'nan'. [...] >> >>Battery Voltages and Currents >>Leisure Battery -

Re: Can one output something other than 'nan' for not a number values?

2024-02-18 Thread Grant Edwards via Python-list
On 2024-02-17, Cameron Simpson via Python-list wrote: > On 16Feb2024 22:12, Chris Green wrote: >>I'm looking for a simple way to make NaN values output as something >>like '-' or even just a space instead of the string 'nan'. >>[...] >> >>Battery Voltages and Currents >>Leisure Battery -

Re: Can one output something other than 'nan' for not a number values?

2024-02-18 Thread Grant Edwards via Python-list
On 2024-02-16, Chris Green via Python-list wrote: > I'm looking for a simple way to make NaN values output as something > like '-' or even just a space instead of the string 'nan'. It would probably help if you told us how you're "outputting" them now (the Python feaatures/functions used, not

Re: Can one output something other than 'nan' for not a number values?

2024-02-16 Thread Cameron Simpson via Python-list
On 16Feb2024 22:12, Chris Green wrote: I'm looking for a simple way to make NaN values output as something like '-' or even just a space instead of the string 'nan'. This would then make it much easier to handle outputting values from sensors when not all sensors are present. So, for example,

Can one output something other than 'nan' for not a number values?

2024-02-16 Thread Chris Green via Python-list
I'm looking for a simple way to make NaN values output as something like '-' or even just a space instead of the string 'nan'. This would then make it much easier to handle outputting values from sensors when not all sensors are present. So, for example, my battery monitoring program outputs:-