Skip to content
This repository was archived by the owner on Jul 10, 2025. It is now read-only.

Commit afd9247

Browse files
authored
Merge pull request #1 from rcpch/dependency-cleanup
Dependency cleanup and small bugfix
2 parents 7f76426 + 69b2e92 commit afd9247

File tree

8 files changed

+79
-75
lines changed

8 files changed

+79
-75
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 1.1.1
2+
current_version = 1.2.0
33
tag = False
44
commit = True
55

.gitignore

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,6 @@ target/
8181
profile_default/
8282
ipython_config.py
8383

84-
# pyenv
85-
.python-version
86-
8784
# pipenv
8885
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
8986
# However, in case of collaboration, if having platform-specific dependencies or dependencies
@@ -128,4 +125,5 @@ dmypy.json
128125
# Pyre type checker
129126
.pyre/
130127

131-
.vscode
128+
# VS Code
129+
.vscode/

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rcpchgrowth-python-cli

.vscode/settings.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

python-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

rcpchgrowth_python_cli/__main__.py

Lines changed: 49 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
1+
"""
2+
RCPCHGrowth Command Line Tool
3+
"""
4+
5+
6+
# standard imports
7+
from datetime import date
8+
9+
# third party imports
110
import click
2-
from datetime import datetime, date
11+
import pyfiglet
312
from scipy import stats
13+
14+
# RCPCH imports
415
from rcpchgrowth import date_calculations
516
from rcpchgrowth.global_functions import centile, measurement_from_sds, sds_for_measurement as sfm, mid_parental_height
6-
import pyfiglet
17+
718

819
@click.group()
920
def methods():
@@ -13,15 +24,16 @@ def methods():
1324
"""
1425
pass
1526

27+
1628
@click.command()
1729
@click.argument('birth_date', type=click.DateTime(formats=['%Y-%m-%d']),
18-
default=str(date.today()))
30+
default=str(date.today()))
1931
@click.argument('observation_date', type=click.DateTime(formats=['%Y-%m-%d']),
20-
default=str(date.today()))
32+
default=str(date.today()))
2133
@click.argument('gestation_weeks', type=click.INT, default=40, required=False)
2234
@click.argument('gestation_days', type=click.INT, default=0, required=False)
2335
@click.option('--adjustment', '-a', is_flag=True, default=False, help="Include if adjusting for gestational age.")
24-
def age_calculation (birth_date, observation_date, gestation_weeks, gestation_days, adjustment):
36+
def age_calculation(birth_date, observation_date, gestation_weeks, gestation_days, adjustment):
2537
"""
2638
Calculates decimal age, either chronological or corrected for gestation if the adjustment flag is true.\n
2739
Essential parameters are birth_date [format YY-M-DD],
@@ -31,27 +43,32 @@ def age_calculation (birth_date, observation_date, gestation_weeks, gestation_da
3143
If correction is required, supply the gestation and the --adjustment flag
3244
"""
3345
click.echo("Calculates decimal age, either chronological or corrected for gestation if the adjustment flag is true. Params: birth_date, observation_date, gestation_weeks, gestation_days")
34-
decimal_age=0
35-
calendar_age=""
46+
decimal_age = 0
47+
calendar_age = ""
3648
if adjustment:
37-
decimal_age=date_calculations.corrected_decimal_age(
49+
decimal_age = date_calculations.corrected_decimal_age(
3850
birth_date=birth_date,
3951
observation_date=observation_date,
4052
gestation_weeks=gestation_weeks,
4153
gestation_days=gestation_days)
42-
calendar_age=date_calculations.chronological_calendar_age(
54+
corrected_birth_date = date_calculations.estimated_date_delivery(
4355
birth_date=birth_date,
56+
gestation_weeks=gestation_weeks,
57+
gestation_days=gestation_days)
58+
calendar_age = date_calculations.chronological_calendar_age(
59+
birth_date=corrected_birth_date,
4460
observation_date=observation_date)
4561
click.echo(f"Adjusted: {decimal_age} y,\n{calendar_age}")
4662
else:
47-
decimal_age=date_calculations.chronological_decimal_age(
63+
decimal_age = date_calculations.chronological_decimal_age(
4864
birth_date=birth_date,
4965
observation_date=observation_date)
50-
calendar_age=date_calculations.chronological_calendar_age(
66+
calendar_age = date_calculations.chronological_calendar_age(
5167
birth_date=birth_date,
5268
observation_date=observation_date)
5369
click.echo(f"Unadjusted: {decimal_age} y,\n{calendar_age}")
5470

71+
5572
@click.command()
5673
@click.argument('decimal_age', type=click.FLOAT)
5774
@click.argument('measurement_method', default="height", type=click.Choice(['height', 'weight', 'bmi', 'ofc']))
@@ -69,7 +86,7 @@ def sds_for_measurement(decimal_age, measurement_method, observation_value, sex,
6986
The reference is optional - default is UK-WHO\n
7087
To change the reference pass --reference with one of "uk-who", "trisomy-21", "turners-syndrome"
7188
"""
72-
89+
7390
result = sfm(
7491
reference=reference,
7592
age=decimal_age,
@@ -82,6 +99,7 @@ def sds_for_measurement(decimal_age, measurement_method, observation_value, sex,
8299
click.echo(f"Reference: {reference_to_string(reference)}")
83100
click.echo(f"SDS: {result}\nCentile: {round(cent,1)} %\n")
84101

102+
85103
@click.command()
86104
@click.argument('decimal_age', type=click.FLOAT)
87105
@click.argument('measurement_method', default="height", type=click.Choice(['height', 'weight', 'bmi', 'ofc']))
@@ -97,7 +115,7 @@ def measurement_for_centile(decimal_age, sex, measurement_method, centile, refer
97115
centile as a float value,
98116
To change the reference pass --reference with one of "uk-who", "trisomy-21", "turners-syndrome"
99117
"""
100-
118+
101119
# convert centile to SDS
102120
sds = stats.norm.ppf(centile / 100)
103121

@@ -109,14 +127,16 @@ def measurement_for_centile(decimal_age, sex, measurement_method, centile, refer
109127
sex=sex,
110128
age=decimal_age
111129
)
112-
113-
suffix="cm"
114-
if measurement_method=="weight":
115-
suffix="kg"
116-
elif measurement_method=="bmi":
117-
suffix="kg/m2"
130+
131+
suffix = "cm"
132+
if measurement_method == "weight":
133+
suffix = "kg"
134+
elif measurement_method == "bmi":
135+
suffix = "kg/m2"
118136
click.echo(f"Reference: {reference_to_string(reference)}")
119-
click.echo(f"SDS {round(sds, 3)}\nCentile: {centile} %\n{measurement_method}: {result} {suffix}")
137+
click.echo(
138+
f"SDS {round(sds, 3)}\nCentile: {centile} %\n{measurement_method}: {result} {suffix}")
139+
120140

121141
@click.command()
122142
@click.argument('decimal_age', type=click.FLOAT)
@@ -134,20 +154,22 @@ def measurement_for_sds(reference, decimal_age, sex, measurement_method, sds):
134154
To change the reference pass --reference with one of "uk-who", "trisomy-21", "turners-syndrome"
135155
"""
136156
result = measurement_from_sds(
137-
reference=reference,
157+
reference=reference,
138158
requested_sds=sds,
139159
measurement_method=measurement_method,
140160
sex=sex,
141161
age=decimal_age
142162
)
143163
cent = centile(sds)
144-
suffix="cm"
145-
if measurement_method=="weight":
146-
suffix="kg"
147-
elif measurement_method=="bmi":
148-
suffix="kg/m2"
164+
suffix = "cm"
165+
if measurement_method == "weight":
166+
suffix = "kg"
167+
elif measurement_method == "bmi":
168+
suffix = "kg/m2"
149169
click.echo(f"Reference: {reference_to_string(reference)}")
150-
click.echo(f"SDS {sds}\nCentile: {round(cent,3)} %\n{measurement_method}: {result} {suffix}")
170+
click.echo(
171+
f"SDS {sds}\nCentile: {round(cent,3)} %\n{measurement_method}: {result} {suffix}")
172+
151173

152174
@click.command()
153175
@click.argument("maternal_height", type=click.FLOAT)

requirements.txt

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
1-
attrs==20.3.0
2-
click==8.0.1
3-
iniconfig==1.1.1
4-
numpy==1.20.2
5-
packaging==20.9
6-
pluggy==0.13.1
7-
py==1.10.0
8-
pyfiglet==0.8.post1
9-
pyparsing==2.4.7
10-
pytest==6.2.3
11-
python-dateutil==2.8.1
1+
click
2+
pyfiglet
123
rcpchgrowth
13-
scipy==1.6.2
14-
six==1.15.0
15-
toml==0.10.2
4+
scipy
165
bump2version

setup.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
from setuptools import setup, find_packages
2-
2+
33
with open('requirements.txt') as f:
44
requirements = f.readlines()
5-
5+
66
long_description = 'Calculate SDS and centiles using \
77
UK-WHO, Down and Turner reference data. \
88
This is official RCPCH software.'
9-
9+
1010
setup(
11-
name ='rcpchgrowth-python-cli',
12-
version='1.1.2',
13-
author ='Simon Chapman',
14-
author_email ='eatyourpeasapps@gmail.com',
15-
url ='https://github.com/rcpch/rcpchgrowth-python-cli',
16-
description ='Command Line Interface for RCPCHGrowth.',
17-
long_description = long_description,
18-
long_description_content_type ="text/markdown",
19-
packages=find_packages(),
20-
entry_points ={
11+
name='rcpchgrowth-python-cli',
12+
version='1.2.0',
13+
author='Simon Chapman, Marcus Baw',
14+
author_email='eatyourpeasapps@gmail.com',
15+
url='https://github.com/rcpch/rcpchgrowth-python-cli',
16+
description='Command Line Interface for RCPCHGrowth.',
17+
long_description=long_description,
18+
long_description_content_type="text/markdown",
19+
packages=find_packages(),
20+
entry_points={
2121
'console_scripts': [
2222
'rcpchgrowth=rcpchgrowth_python_cli.__main__:methods'
2323
]
24-
},
25-
classifiers =(
26-
"Programming Language :: Python :: 3",
27-
'License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)',
28-
"Operating System :: OS Independent",
29-
),
30-
keywords ='RCPCHGrowth UK-WHO Down Turner',
31-
install_requires = requirements,
32-
zip_safe = False
33-
)
24+
},
25+
classifiers=(
26+
"Programming Language :: Python :: 3",
27+
'License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)',
28+
"Operating System :: OS Independent",
29+
),
30+
keywords='RCPCHGrowth UK-WHO Down Turner Centile',
31+
install_requires=requirements,
32+
zip_safe=False
33+
)

0 commit comments

Comments
 (0)