~fabrixxm/confy-dev

Re: [PATCH v2] Fix division by zero for events with zero duration

Details
Message ID
<ac876281d82c281e72705bc580604075b9c9dede.camel@fortysixandtwo.eu>
DKIM signature
missing
Download raw message
Looks, like I didn't reply to the mailinglist, sorry for the noise!

On Mon, 2021-06-14 at 02:18 +0200, Evangelos Ribeiro Tzaras wrote:
> Hi,
> On Sun, 2021-06-13 at 16:32 +0200, Fabio wrote:
> > Il giorno dom, 13/06/2021 alle 02.38 +0200, Evangelos Ribeiro
> > Tzaras
> > ha
> > scritto:
> > > 
> > > +        prc = min(max(pos/dur, 0.0), 1.0) if dur > 0 else
> > > int(pos
> > > > =
> > > 0)
> > 
> > While it's correct (and more correct than the code I was writting
> > to
> > fix this), it's a little to difficult to read.
> 
> Fair enough. I just thought doing x = foo if bar else baz
> was the pythonic way :P
> 
> > I would prefer an explicit if/else, with some comments, something
> > like
> > 
> > ```
> > if dur > 0:
> >         prc = min(max(pos/dur, 0.0), 1.0)
> > else:
> >         # not a valid event duration, 
> >         # set prc  0 if the event is in the future or 1 if passed
> >         prc = int(pos >= 0)
> > ```
> 
> Works for me!
> 
> > 
> > And same patch should be added to `src/pages.py:510`
> > 
> > 
> 
> Thanks! I missed this one.
> 
> 
Reply to thread Export thread (mbox)