<commit_before>import numpy as np
import pandas as pd
from scipy.stats import threshold

dataset = pd.read_csv("ecg_data.csv")
dataset=dataset.values

def HRinst(dataset):
    """
    Takes the input data from an ndarray consisting of an array of time instances in the first column and
    an array of voltage values in the second column.
    :param dataset: tuple with two elements. First element is a
    :returns: ndarray of 2 columns. First column with time in s, second column with heart rate in BPM. Values in float
    """

    time = dataset[:, 0]
    voltage = dataset[:, 1]
    thresholded = threshold(voltage, 0.8 * voltage.max())
    peakInd = np.array([0])
    HRinst = np.zeros(len(thresholded))
    for i in range(1, len(thresholded) - 1):
        HRinst[i] = HRinst[i - 1]
        if thresholded[i] > thresholded[i - 1] and thresholded[i] >= thresholded[i + 1]:
            peakInd = np.append(peakInd, int(i))
            HRinst[i] = 60/ (time[int(peakInd[-1])] - time[int(peakInd[-2])])
    HRinst=np.column_stack((time,HRinst))
    return HRinst

def bradyTachyCardia(HRinst):
    """Determines when bradycardia or tachycardia occurred in the ECG trace
    :param HRinst: (ndarray)
    :returns: list of same length as HRinst that indicates when brady- or tachycardia occurred
    """

    bradyTachy = ['']*np.size(HRinst)

    for i in range(len(HRinst)):
        if HRinst[i] <= 60:  # this indicates bradycardia, aka the heart is beating too slowly
            bradyTachy[i] = 'B'
        elif HRinst[i] >= 100:  # this indicates tachycardia, aka the heart is beating too quickly
            bradyTachy[i] = 'T'
        else:  # otherwise the heart is beating normally
            bradyTachy[i] = 'N'

    return bradyTachy<commit_msg>Revert bradyTachyCardia.py to Julias fix<commit_after>import numpy as np


def bradyTachyCardia(HRinst):
    """Determines when bradycardia or tachycardia occurred in the ECG trace
    :param HRinst: (ndarray)
    :returns: list of same length as HRinst that indicates when brady- or tachycardia occurred
    """

    bradyTachy = ['']*np.size(HRinst)

    for i in range(len(HRinst)):
        if HRinst[i] <= 60:  # this indicates bradycardia, aka the heart is beating too slowly
            bradyTachy[i] = 'B'
        elif HRinst[i] >= 100:  # this indicates tachycardia, aka the heart is beating too quickly
            bradyTachy[i] = 'T'
        else:  # otherwise the heart is beating normally
            bradyTachy[i] = 'N'

    return bradyTachy
{'fraction_non_alphanumeric': 0.09948269001193792, 'fraction_numerical': 0.009948269001193792, 'mean_word_length': 2.9841521394611727, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5679278', 'n_tokens_mistral': 845, 'n_tokens_neox': 769, 'n_words': 276}