def outFrac_3sigma68(z1, z2): delta_z = bhz.delta_z(z1, z2) return bhz.outFrac_3sigma68(delta_z)
def outlier_fraction(z1, z2): delta_z = bhz.delta_z(z1, z2) return bhz.outlier_fraction(delta_z)
def sigma_68(z1, z2): delta_z = bhz.delta_z(z1, z2) return bhz.sigma_68(delta_z)
def median(z1, z2): delta_z = bhz.delta_z(z1, z2) return np.median(delta_z)
def test_delta_z(): """can we subtract two arrays!""" for N in [1, 100, 1000]: deltaz = pval.delta_z(np.arange(N), np.arange(N)) np.testing.assert_equal(np.sum(np.abs(deltaz)), 0)
test_name = tst['test_name'] res[ptype][f][test_name] = {} #should we calculate an error on these metrics error_function = pval.key_not_none(tst, 'error_function') err_metric = {} if error_function: for ef in tst['error_function']: #turn error function.string into a function err_metric[ef.split('.')[-1]] = pval.get_function(ef) for photoz in tst['predictions']: res[ptype][f][test_name][photoz] = {} diff = pval.delta_z(d[tst['truths']], d[photoz]) diff_1pz = pval.delta_z_1pz(d[tst['truths']], d[photoz]) points = {'delta_z': diff, 'diff_1pz': diff_1pz} for metric in tst['metrics']: #set all objects equal weight, unless defined weights = get_weights(tst, 'weights', d) res[ptype][f][test_name][photoz][metric] = {} #turn string into function metric_function = pval.get_function(metric) #which residuals shall we employ?