-
Notifications
You must be signed in to change notification settings - Fork 1
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
test_kpi_calculation_45
(median + mean) calcs sporadically fail
#338
Comments
@dc2007git @reecehill are either of you able to pick this up? |
@cillian-rcpch ignore the rest of the above, narrowed it down to how the median is calculated. In fixing this, was wondering how you guys calculate median for an even number of elements: Eg n=4
|
(for my own debugging record)
|
Hi @anchit-chandran, the median of a list with an even number of elements is dealt with by number 2 (mean of middle). |
Thanks @cillian-rcpch. also to confirm, we have kpi 45 defined in docs as
My query filters for valid
The test also asserts the same so want to confirm |
Yep that all looks good to me @anchit-chandran ! |
Fixed in #352 |
test_kpi_calculation_45
sporadically fails. My guess is that it's because of some floating point arithmetic but I'm not too sure. Check to see if there's a difference in calculation between how the test calculates the median, vs how the SQL query calculates median.The relevant code exists in:
test file:
test_kpis_44_49.py
test_kpi_calculation_45
is the test namethe test uses
calculate_median
fn, defined on line665
kpi calculation:
kpis.py
calculation method
calculate_kpi_45_median_hba1c
is defined on line3098
there's no native
Median
fn for django's orm, so defined my own at the bottom of file on line3570
:class Median(Func):
I've noticed in a failed test output, the actual value (coming from the kpi calculation method) is a
Decimal('46.75')
, vs we're expecting a value of47.0
. It might just be thatDecimal
is more accurate and we should update the test to expectingDecimal
, but confirm this is the case as I'm not sure. Conversely, it might be the case we need to cast theDecimal
to a native python value as it's going to be passed in the view to the frontend:Cmd to test repeatedly until fail:
Example Failed test output
The text was updated successfully, but these errors were encountered: