<commit_before>import argparse

from classes.cstatistics import CStatistics
from classes.csv_export import CSVExport
from time import sleep
from classes.yoctoammeter import YoctoDevice


def main():
    r"""
    Main program of LightPowertool.

    LightPowertool is a software to measure automatically the energy\
     consumption of devices, using the Yoctopuce ammeter.
    """
    # Parse arguments
    parser = argparse.ArgumentParser()
    parser.add_argument("-f", "--framerate", type=str, default="50/s",
                        help="Give to the main program the framerate.")
    parser.add_argument("-n", "--network", action="store_true",
                        help="Use the network to send your data\
                        - local server like LightPowertoolServer")
    parser.add_argument("-o", "--output", type=str,
                        help="Give an output file name\
                         to store measured values.")
    parser.add_argument("-s", "--statistics", action="store_true",
                        help="Ask to output basic statistics\
                         (mean, median, pvariance,...) on measured values.")
    parser.add_argument("-t", "--time", type=int, default=60,
                        help="Due time to measure data.")
    args = parser.parse_args()

    # Get the yocto device
    yocto_device = YoctoDevice(args.framerate, network=args.network)
    print(yocto_device)

    yocto_device.run()
    sleep(args.time)
    yocto_device.stopMeasure()

    if args.output:
        CSVExport(args.output).export_data(yocto_device._values)

    if args.statistics:
        measures = [y for x, y in yocto_device._values]
        print(CStatistics(measures))

if __name__ == '__main__':
    main()<commit_msg>perf: Pass as argument generator instead of a list<commit_after>import argparse

from classes.cstatistics import CStatistics
from classes.csv_export import CSVExport
from time import sleep
from classes.yoctoammeter import YoctoDevice


def main():
    r"""
    Main program of LightPowertool.

    LightPowertool is a software to measure automatically the energy\
     consumption of devices, using the Yoctopuce ammeter.
    """
    # Parse arguments
    parser = argparse.ArgumentParser()
    parser.add_argument("-f", "--framerate", type=str, default="50/s",
                        help="Give to the main program the framerate.")
    parser.add_argument("-n", "--network", action="store_true",
                        help="Use the network to send your data\
                        - local server like LightPowertoolServer")
    parser.add_argument("-o", "--output", type=str,
                        help="Give an output file name\
                         to store measured values.")
    parser.add_argument("-s", "--statistics", action="store_true",
                        help="Ask to output basic statistics\
                         (mean, median, pvariance,...) on measured values.")
    parser.add_argument("-t", "--time", type=int, default=60,
                        help="Due time to measure data.")
    args = parser.parse_args()

    # Get the yocto device
    yocto_device = YoctoDevice(args.framerate, network=args.network)
    print(yocto_device)

    yocto_device.run()
    sleep(args.time)
    yocto_device.stopMeasure()

    if args.output:
        CSVExport(args.output)\
            .export_data((value for value in yocto_device._values))

    if args.statistics:
        measures = [y for x, y in yocto_device._values]
        print(CStatistics(measures))

if __name__ == '__main__':
    main()
{'fraction_non_alphanumeric': 0.10526315789473684, 'fraction_numerical': 0.0022396416573348264, 'mean_word_length': 2.4126074498567336, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2754995', 'n_tokens_mistral': 1007, 'n_tokens_neox': 976, 'n_words': 282}