Skip to content

Commit f5e656f

Browse files
author
XXPE1
committed
packaged age bands added
1 parent f01d868 commit f5e656f

6 files changed

Lines changed: 101 additions & 0 deletions

File tree

LICENSE

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Copyright 2019 NHS Digital DIS Team
2+
3+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4+
5+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6+
7+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8+
9+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10+
11+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

MANIFEST.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
recursive-include codonPython *.py
2+
3+
include LICENSE
4+
include README.md
5+
# instructions about what to include in the distribution build

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Example package
2+
3+
This is a simple example of a future package pulled from the DPS Core code base.

codonPython/__init__.py

Whitespace-only changes.

codonPython/age_bands.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import math
2+
3+
4+
def age_band_5_years(age: int)->str:
5+
"""
6+
Place age into appropriate 5 year band
7+
8+
This function takes the age supplied as an argument and returns a string representing the relevant 5 year banding.
9+
10+
Args:
11+
age: int
12+
Age of the person
13+
14+
Returns:
15+
str
16+
The 5 year age band
17+
18+
>>> age_band_5_years(3)
19+
'0-4'
20+
>>> age_band_5_years(-1)
21+
'Age not known'
22+
>>> age_band_5_years(95)
23+
'90 and over'
24+
"""
25+
26+
if age is None or age < 0:
27+
return 'Age not known'
28+
29+
if age > 89:
30+
return '90 and over'
31+
32+
lowerbound = 5 * int(math.floor(age / 5))
33+
upperbound = lowerbound + 4
34+
return '{}-{}'.format(lowerbound, upperbound)
35+
36+
37+
def age_band_10_years(age: int)->str:
38+
"""
39+
Place age into appropriate 10 year band
40+
41+
This function takes the age supplied as an argument and returns a string representing the relevant 10 year banding.
42+
43+
Args:
44+
age: int
45+
Age of the person
46+
47+
Returns:
48+
str
49+
The 10 year age band
50+
51+
>>> age_band_10_years(3)
52+
'0-9'
53+
>>> age_band_10_years(-1)
54+
'Age not known'
55+
>>> age_band_10_years(95)
56+
'90 and over'
57+
"""
58+
59+
if age is None or age < 0:
60+
return 'Age not known'
61+
62+
if age > 89:
63+
return '90 and over'
64+
65+
lowerbound = 10 * int(math.floor(age / 10))
66+
upperbound = lowerbound + 9
67+
return '{}-{}'.format(lowerbound, upperbound)

setup.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from setuptools import setup, find_packages
2+
3+
setup(
4+
name='codonPython',
5+
version='0.1',
6+
license='BSD',
7+
packages=['codonPython',],
8+
install_required=[
9+
'numpy',
10+
],
11+
author='NHS Digital DIS Team',
12+
author_email='paul.ellingham@nhs.net',
13+
url='https://digital.nhs.uk/data-and-information',
14+
description='This is a first attempt at how our package will work.'
15+
)

0 commit comments

Comments
 (0)