-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BgReading.find_new_curve, division by zero ? #365
Comments
I don't see why x1 and x2 are the same. They should be 5 minutes apart. |
Both values are read from the DB: https://github.com/StephenBlackWasAlreadyTaken/xDrip-Experimental/blob/master/app/src/main/java/com/eveningoutpost/dexdrip/Models/BgReading.java#L658 This means they really should be 5 minutes apart. But as both calls query the same db with the same query the result for their curve defined by a,b and c should be the same. |
I second adrian, On xDrip there is code that checks that there is at least two minutes So for xDrip there should be no issue. On Wed, Jul 27, 2016 at 2:20 AM, AdrianLxM [email protected] wrote:
|
Ok i'll have to start debugging both versions and compare the results step by step, I'm not saving the bgreadings to database at the same moments as the android app - could be the reason |
was an error in my code |
sorry, it does seem to occur in the android version. What I do : install the app, start the sensor (shift back the time with exactly two hours) and wait for minimum two readings, when app says ("calibrate") then I do the double calibration. I think actually the error is here : https://github.com/JohanDegraeve/xDrip-Experimental/blob/master/app/src/main/java/com/eveningoutpost/dexdrip/Models/BgReading.java#L684 it says "double x2 = timestamp;" |
It seems that you are right, in your analysis of the problem. The function is called on the two points. I wonder what will happen once we fix this. It seems to me that the b part only influences the predictive code, which is off by default. |
I don't understand the algorithms itself - but I think this is a rare case, 2016-08-05 0:14 GMT+02:00 tzachi-dar [email protected]:
|
I think that your proposed solution is correct, but I want to think about it some more (and try it) before we move on. |
If I understand this right it is a problem for the first of the two readings, not for the second as for the second As far as I remember the curve is used for future prediction. Either to directly show it on the screen or for an arrow symbol. It is always taken from the latest bg reading. As it is calculated correctly for the second reading and never used for the first it should not be a problem in practice at all. It is still a bug in the code an we should correct it. |
Indeed only in case there's two readings, and only for one of the two readings it goes wrong. |
Only when there is 2 readings, only for one and only for the one we later never look at again ;) A division by zero will only lead to an ArithmeticException if it is of |
I guess we all agree. I'll make a pr, will test it and commit it once we have some more confidence. |
ok 2016-08-06 23:25 GMT+02:00 tzachi-dar [email protected]:
|
By the way, I think we have a similar bug also for the three packets case. |
Opened PR: #373 |
@tzachi-dar, good morning.
|
Thanks for finding that, i'll fix both functions but it will take a few בתאריך 7 באוג׳ 2016 10:59 לפנה״צ, "AdrianLxM" [email protected]
|
OK, fixed the other function as well. Will test that and see if there are any problems with that. |
Hi,
while porting the Android code to actionscript, I'm getting a division by zero error.
on this place :
https://github.com/StephenBlackWasAlreadyTaken/xDrip-Experimental/blob/master/app/src/main/java/com/eveningoutpost/dexdrip/Models/BgReading.java#L691
find_new_curve gets called during initial calibration. if there's only two readings stored.
This method gets called for each reading. Which means x2 will be the timestamp of the reading for which the method is called, x1 will in one the cases be the timestamp of the reading read from the database, which has exactly the same value,
which results in x1 - x2 being 0, and a division by zero error.
That's what happens in my code :
https://github.com/JohanDegraeve/iosxdripreader/blob/master/src/databaseclasses/BgReading.as#L513
in actionscript this gives "-Infinity" and the code just continues, but I would assume in Java this would throw an exception ?
(I could debug on android studio but this thing is so slow - if no one knows the answer I'll have to do it anyway)
thanks
Johan
The text was updated successfully, but these errors were encountered: