GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Code Duplication    Length = 49-49 lines in 2 locations

voltcycle/functions_and_tests/core.py 1 location

@@ 196-244 (lines=49) @@
193
    return vector1, vector2
194
195
196
def critical_idx(arr_x, arr_y): ## Finds index where data set is no longer linear
197
    """
198
    This function takes x and y values callculate the derrivative of x and y,
199
    and calculate moving average of 5 and 15 points. Finds intercepts of different
200
    moving average curves and return the indexs of the first intercepts.
201
    ----------
202
    Parameters
203
    ----------
204
    x : Numpy array.
205
    y : Numpy array.
206
    Normally, for the use of this function, it expects numpy array
207
    that came out from split function. For example, output of
208
    split.df['potentials'] could be input for this function as x.
209
    -------
210
    Returns
211
    -------
212
    This function returns 5th index of the intercepts of different moving average curves.
213
    User can change this function according to baseline
214
    branch method 2 to get various indexes..
215
    """
216
    assert isinstance(arr_x, np.ndarray), "Input should be numpy array"
217
    assert isinstance(arr_y == np.ndarray), "Input should be numpy array"
218
    if arr_x.shape[0] != arr_y.shape[0]:
219
        raise ValueError("x and y must have same first dimension, but "
220
                         "have shapes {} and {}".format(arr_x.shape, arr_y.shape))
221
    k_val = np.diff(arr_y)/(np.diff(arr_x)) #calculated slops of x and y
222
    ## Calculate moving average for 10 and 15 points.
223
    ## This two arbitrary number can be tuned to get better fitting.
224
    ave10 = []
225
    ave15 = []
226
    for i in range(len(k_val)-10):
227
        # The reason to minus 10 is to prevent j from running out of index.
228
        a_val = 0
229
        for j in range(0, 5):
230
            a_val = a_val + k_val[i+j]
231
        ave10.append(round(a_val/10, 5))
232
        # keeping 5 desimal points for more accuracy
233
        # This numbers affect how sensitive to noise.
234
    for i in range(len(k_val)-15):
235
        b_val = 0
236
        for j in range(0, 15):
237
            b_val = b_val + k_val[i+j]
238
        ave15.append(round(b_val/15, 5))
239
    ave10i = np.asarray(ave10)
240
    ave15i = np.asarray(ave15)
241
    ## Find intercepts of different moving average curves
242
    #reshape into one row.
243
    idx = np.argwhere(np.diff(np.sign(ave15i - ave10i[:len(ave15i)]) != 0)).reshape(-1)+0
244
    return idx[5]
245
# This is based on the method 1 where user can't choose the baseline.
246
# If wanted to add that, choose method2.
247

voltcycle/functions_and_tests/baseline.py 1 location

@@ 38-86 (lines=49) @@
35
    return vector1, vector2
36
37
38
def critical_idx(arr_x, arr_y): ## Finds index where data set is no longer linear
39
    """
40
    This function takes x and y values callculate the derrivative of x and y,
41
    and calculate moving average of 5 and 15 points. Finds intercepts of different
42
    moving average curves and return the indexs of the first intercepts.
43
    ----------
44
    Parameters
45
    ----------
46
    x : Numpy array.
47
    y : Numpy array.
48
    Normally, for the use of this function, it expects numpy array
49
    that came out from split function. For example, output of
50
    split.df['potentials'] could be input for this function as x.
51
    -------
52
    Returns
53
    -------
54
    This function returns 5th index of the intercepts of different moving average curves.
55
    User can change this function according to baseline
56
    branch method 2 to get various indexes..
57
    """
58
    assert isinstance(arr_x, np.ndarray), "Input should be numpy array"
59
    assert isinstance(arr_y == np.ndarray), "Input should be numpy array"
60
    if arr_x.shape[0] != arr_y.shape[0]:
61
        raise ValueError("x and y must have same first dimension, but "
62
                         "have shapes {} and {}".format(arr_x.shape, arr_y.shape))
63
    k_val = np.diff(arr_y)/(np.diff(arr_x)) #calculated slops of x and y
64
    ## Calculate moving average for 10 and 15 points.
65
    ## This two arbitrary number can be tuned to get better fitting.
66
    ave10 = []
67
    ave15 = []
68
    for i in range(len(k_val)-10):
69
	# The reason to minus 10 is to prevent j from running out of index.
70
        a_val = 0
71
        for j in range(0, 5):
72
            a_val = a_val + k_val[i+j]
73
        ave10.append(round(a_val/10, 5))
74
	# keeping 5 desimal points for more accuracy
75
	# This numbers affect how sensitive to noise.
76
    for i in range(len(k_val)-15):
77
        b_val = 0
78
        for j in range(0, 15):
79
            b_val = b_val + k_val[i+j]
80
        ave15.append(round(b_val/15, 5))
81
    ave10i = np.asarray(ave10)
82
    ave15i = np.asarray(ave15)
83
    ## Find intercepts of different moving average curves
84
    #reshape into one row.
85
    idx = np.argwhere(np.diff(np.sign(ave15i - ave10i[:len(ave15i)]) != 0)).reshape(-1)+0
86
    return idx[5]
87
# This is based on the method 1 where user can't choose the baseline.
88
# If wanted to add that, choose method2.
89