Code Duplication    Length = 19-20 lines in 2 locations

mutis/lib/correlation.py 2 locations

@@ 69-88 (lines=20) @@
66
67
    return np.mean(udcf[msk])
68
69
def welsh_old(t1, d1, t2, d2, t, dt):
70
    """Welsh (1999) correlation with adaptative binning.
71
    Old version, not using numba. Kept for debugging purposes.
72
    """
73
74
    if t.size != dt.size:
75
        log.error("Error, t and dt not the same size")
76
        return False
77
    if t1.size != d1.size:
78
        log.error("Error, t1 and d1 not the same size")
79
        return False
80
    if t2.size != d2.size:
81
        log.error("Error, t2 and d2 not the same size")
82
        return False
83
84
    # res = np.array([])
85
    res = np.empty(t.size)
86
    for i in range(t.size):
87
        res[i] = _welsh_old(t1, d1, t2, d2, t[i], dt[i])
88
    return res
89
90
@guvectorize([(float64[:], float64[:], float64[:], float64[:], float64[:], float64[:], float64[:])], '(n),(n),(m),(m),(c),(c)->(c)')
91
def _kroedel_numba(t1, d1, t2, d2, t, dt, res): # pragma: no cover
@@ 37-55 (lines=19) @@
34
    return np.mean(udcf[mask])
35
36
37
def kroedel_old(t1, d1, t2, d2, t, dt):
38
    """Krolik & Edelson (1988) correlation with adaptative binning.
39
    Old version, not using numba. Kept for debugging purposes.
40
    """
41
42
    if t.size != dt.size:
43
        log.error("Error, t and dt not the same size")
44
        return False
45
    if t1.size != d1.size:
46
        log.error("Error, t1 and d1 not the same size")
47
        return False
48
    if t2.size != d2.size:
49
        log.error("Error, t2 and d2 not the same size")
50
        return False
51
52
    res = np.empty(t.size)
53
    for i in range(t.size):
54
        res[i] = _kroedel_old(t1, d1, t2, d2, t[i], dt[i])
55
    return res
56
57
def _welsh_old(t1, d1, t2, d2, t, dt):
58
    t1m, t2m = get_grid(t1, t2)