Repository navigation
Conversation
- Add MAXIMUM_PARENTAL_HEIGHT_CM constant (260 cm) to validation_constants.py - Add comprehensive input validation to mid_parental_height() function: * Validate sex parameter (must be 'male' or 'female') * Validate maternal_height (None, type, range 50-260 cm) * Validate paternal_height (None, type, range 50-260 cm) - Add comprehensive input validation to mid_parental_height_z() function: * Validate reference parameter * Validate maternal_height (None, type, range 50-260 cm) * Validate paternal_height (None, type, range 50-260 cm) - Add 7 new test functions covering all validation scenarios - All tests pass (22,767 total tests) Fixes issue: mid-parental-height accepts impossible values
|
Thanks for the contribution @FibrinLab! It looks fine from a code point of view however we will need to run this past the statisticians who advise us before merging. Hopefully won't take too long :) |
|
Good job @FibrinLab thank you. The reason there is no error handling in the python package is because we put it in the server - see here: https://github.com/rcpch/digital-growth-charts-server/blob/live/routers/utilities.py I can see you have used the Guiness Book of Records values to set min and max. We did deprecate this in favour of using SDS cut offs - might you be happy to review the approach taken above in the server and then replicate here? That way I can remove the code in the server and just trap the errors raised in the package and return those to the user? |
|
Hello @eatyourpeas @mbarton |
|
Thank you @FibrinLab I have spun it up and it looks good, all your tests are passing. I will need a little time to integrate it with the server as there will need to be code there that will trap the errors from here. So if this sits for a little while before merging that is the reason. |
Would love to work on another issue, which do you recommend @mbarton ? |
|
you could potentially finish this off by reviewing the midparental height error handling in the server and integrating it with what you have here? The response from the api would need to be the same, so it would just be a question of removing the code there that validates the MPH by SDS and passes the errors you raise here through to the user. Would you be happy to have a go there? It is a FastAPI project, hopefully self-explanatory but do post questions if more guidance needed. I have created an issue in the server for you to attach an pull requests to. Thanks again for your help with this project. |
Sure. I will get started on that |
Review: is this still needed? Yes - and the current approach is the right oneShort answer to the question in the title: yes, this still needs addressing. Issue #53 is still live behaviour on
And What this PR does well
Why it has not merged cleanly, and what I suggestThe branch is from 2026-01-25, before a lot of recent work, and is now in
Given the rebase conflicts are trivial (essentially just the notebook cell) and the design (SDS cut-offs) is better than the absolute-cm alternative I would otherwise have suggested, I am in favour of this landing after a rebase. Alternatively, if the original contributor is no longer around to rebase, the changes are small enough to be re-applied on a fresh branch with the same test suite - with attribution. One substantive review note for the rebase: Also worth noting for the maintainer decision: raising for ±8 SDS is a behaviour change for any existing caller that deliberately calculates mid-parental heights outside those bounds (e.g. research on extreme stature). The cut-offs match the API server's existing request validation, so server behaviour is unchanged - only direct library callers see new exceptions. That is consistent with how the rest of the package treats impossible values (issue #51's raise-not-return work), so I support it. VerdictStill needed, sound design, tests are well-constructed. Recommend: rebase onto |
|
This has now been recreated from current The Digital Growth Charts documentation attribution is tracked in rcpch/digital-growth-charts-documentation#184. Closing this branch as superseded by #107. Thank you again @FibrinLab for the contribution. |
Fixes issue: mid-parental-height accepts impossible values #53