def calculate_precision_recall(TP, TN, FP, FN):
    """
    Calculates the Precision and Recall meassure of the supplied reference and test data, as per https://en.wikipedia.org/wiki/Precision_and_recall#Definition_(classification_context)
    Incase of the denominator being zero for precision/recall, the values are set to 1, as per https://stats.stackexchange.com/a/16242 and https://github.com/dice-group/gerbil/wiki/Precision,-Recall-and-F1-measure
    
    Input:
        ref: Numpy boolean array of the reference data, of size [n_samples, ]
        test: Numpy boolean array of the test data, of size [n_samples, ]
        
    Output:
        precision: The precision value of the supplied data
        recall: The recall value of the supplied data
    """
    
    if (TP+FP) > 0:
        precision = TP / (TP + FP)
    else:
        precision = 1
        
    if (TP + FN) > 0:
        recall = TP / (TP + FN)
    else:
        recall = 1
        
    return precision, recall