<commit_before>import datetime
import sys
import pigpio
import time
import math

time_record = int(time.time() * 1000)
time_limit = 50
pi = pigpio.pi()
sensor_message_size = 7
sensor_signal_pin = 4
dead_pin = 17
pi.set_mode(sensor_signal_pin, pigpio.OUTPUT)
h1 = pi.serial_open("/dev/ttyAMA0", 9600)
pi.serial_write_byte(h1, 10 * 2)
pi.write(sensor_signal_pin, pigpio.LOW)
print("start")
try:
    while True:
        while (int(time.time() * 1000) - time_record) <= time_limit:
            time.sleep(0.002)
        time_record = int(time.time() * 1000)
        distance = []
        pi.serial_read(h1)  # clear any redauntancy data
        pi.write(sensor_signal_pin, pigpio.HIGH)
        while pi.serial_data_available(h1) < sensor_message_size - 1:
            # print( pi.serial_data_available(h1))
            time.sleep(0.0007)
        (b, d) = pi.serial_read(h1, sensor_message_size)
        pi.write(sensor_signal_pin, pigpio.LOW)
        sets = []
        for a in d:
            sets.append(int(a) / 2.0)
        if pi.read(dead_pin) == pigpio.LOW:
            print("dead")

        a = sets[1]
        b = sets[2]
        c = math.sqrt(a ** 2 + b ** 2 - a * b * math.cos(math.pi * 25 / 180))
        sita = math.acos((b ** 2 + c ** 2 - a ** 2) / (2 * b * c))
        ans = a - math.sin(math.pi - sita) / math.sin(sita - math.pi * 25 / 180)

        if not (abs(sets[2] - sets[1]) > 7 and abs(sets[4] - sets[5]) > 7):
            sets[3] = ans

        print([round(sets[0] * math.cos(math.pi * 25 / 180), 1), sets[1],
               round((sets[2] + 1) * math.cos(math.pi * 35 / 180), 1), sets[3],
               round((sets[4] + 1) * math.cos(math.pi * 35 / 180), 1),
               sets[5], round((sets[6] + 1) * math.cos(math.pi * 25 / 180), 1)])
        # distance = normalize(distance)
except KeyboardInterrupt:
    pi.serial_close(h1)
    sys.exit(0)<commit_msg>correct errors<commit_after>import datetime
import sys
import pigpio
import time
import math

time_record = int(time.time() * 1000)
time_limit = 50
pi = pigpio.pi()
sensor_message_size = 7
sensor_signal_pin = 4
dead_pin = 17
pi.set_mode(sensor_signal_pin, pigpio.OUTPUT)
h1 = pi.serial_open("/dev/ttyAMA0", 9600)
pi.serial_write_byte(h1, 10 * 2)
pi.write(sensor_signal_pin, pigpio.LOW)
print("start")
try:
    while True:
        while (int(time.time() * 1000) - time_record) <= time_limit:
            time.sleep(0.002)
        time_record = int(time.time() * 1000)
        distance = []
        pi.serial_read(h1)  # clear any redauntancy data
        pi.write(sensor_signal_pin, pigpio.HIGH)
        while pi.serial_data_available(h1) < sensor_message_size - 1:
            # print( pi.serial_data_available(h1))
            time.sleep(0.0007)
        (b, d) = pi.serial_read(h1, sensor_message_size)
        pi.write(sensor_signal_pin, pigpio.LOW)
        sets = []
        for a in d:
            sets.append(int(a) / 2.0)
        if pi.read(dead_pin) == pigpio.LOW:
            print("dead")

        if not (abs(sets[2] - sets[1]) > 7 and abs(sets[4] - sets[5]) > 7):
            if abs(sets[2] - sets[1]) > 7:
                a = sets[1]
                b = sets[2]
            else:
                a = sets[7]
                b = sets[6]
            c = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(math.pi * 25 / 180))
            sita = math.acos((b ** 2 + c ** 2 - a ** 2) / (2 * b * c))
            ans = a * math.sin(math.pi - sita) / math.sin(sita - math.pi * 25 / 180)
            sets[3] = round(ans, 1)

        print([round(sets[0] * math.cos(math.pi * 25 / 180), 1), sets[1],
               round((sets[2] + 1) * math.cos(math.pi * 35 / 180), 1), sets[3],
               round((sets[4] + 1) * math.cos(math.pi * 35 / 180), 1),
               sets[5], round((sets[6] + 1) * math.cos(math.pi * 25 / 180), 1)])
        # distance = normalize(distance)
except KeyboardInterrupt:
    pi.serial_close(h1)
    sys.exit(0)
{'fraction_non_alphanumeric': 0.1571829548354172, 'fraction_numerical': 0.05537126818065833, 'mean_word_length': 2.1284916201117317, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1946815', 'n_tokens_mistral': 1588, 'n_tokens_neox': 1436, 'n_words': 317}