Skip to content

Commit c14de9a

Browse files
committed
Add precondition to check type and shape of data
1 parent b451a8a commit c14de9a

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

inflammation/models.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,12 @@ def daily_min(data):
4646

4747
def patient_normalise(data):
4848
"""Normalise patient data from a 2D inflammation data array."""
49+
if not isinstance(data, np.ndarray):
50+
raise TypeError('data input should be ndarray')
51+
if len(data.shape) != 2:
52+
raise ValueError('inflammation array should be 2-dimensional')
4953
if np.any(data < 0):
50-
raise ValueError('Inflammation values should not be negative')
54+
raise ValueError('inflammation values should be non-negative')
5155
max = np.nanmax(data, axis=1)
5256
with np.errstate(invalid='ignore', divide='ignore'):
5357
normalised = data / max[:, np.newaxis]

0 commit comments

Comments
 (0)