<commit_before>#!/usr/bin/env python
"""Benchmark scipy.stats.cauchy."""

from __future__ import print_function
import timeit

REPEATS = 3
COUNT = [0]  # use a list to allow modification within nested scopes


def print_version():
    """Print the TAP version."""

    print("TAP version 13")


def print_summary(total, passing):
    """Print the benchmark summary.

    # Arguments

    * `total`: total number of tests
    * `passing`: number of passing tests

    """

    print("#")
    print("1.." + str(total))  # TAP plan
    print("# total " + str(total))
    print("# pass  " + str(passing))
    print("#")
    print("# ok")


def print_results(iterations, elapsed):
    """Print benchmark results.

    # Arguments

    * `iterations`: number of iterations
    * `elapsed`: elapsed time (in seconds)

    # Examples

    ``` python
    python> print_results(1000000, 0.131009101868)
    ```
    """

    rate = iterations / elapsed

    print("  ---")
    print("  iterations: " + str(iterations))
    print("  elapsed: " + str(elapsed))
    print("  rate: " + str(rate))
    print("  ...")


def benchmark(name, setup, stmt, iterations):
    """Run the benchmark and print benchmark results.

    # Arguments

    * `name`: benchmark name
    * `setup`: benchmark setup
    * `stmt`: statement to benchmark
    * `iterations`: number of iterations

    # Examples

    ``` python
    python> benchmark("random", "from random import random;", "y = random()", 1000000)
    ```
    """

    t = timeit.Timer(stmt, setup=setup)

    print_version()

    i = 0
    while i < REPEATS:
        print("# python::" + name)
        COUNT[0] += 1
        elapsed = t.timeit(number=iterations)
        print_results(iterations, elapsed)
        print("ok " + str(COUNT[0]) + " benchmark finished")
        i += 1


def main():
    """Run the benchmarks."""

    name = "cauchy:entropy"
    setup = "from scipy.stats import cauchy; from random import random; rv = cauchy(10.0, 6.0);"
    stmt = "y = rv.entropy()"
    iterations = 1000
    benchmark(name, setup, stmt, iterations)

    name = "cauchy:median"
    setup = "from scipy.stats import cauchy; from random import random; rv = cauchy(10.0, 6.0);"
    stmt = "y = rv.median()"
    iterations = 1000
    benchmark(name, setup, stmt, iterations)

    name = "cauchy:cdf"
    setup = "from scipy.stats import cauchy; from random import random; rv = cauchy(10.0, 6.0);"
    stmt = "y = rv.cdf(random())"
    iterations = 1000
    benchmark(name, setup, stmt, iterations)

    name = "cauchy:logcdf"
    setup = "from scipy.stats import cauchy; from random import random; rv = cauchy(10.0, 6.0);"
    stmt = "y = rv.logcdf(random())"
    iterations = 1000
    benchmark(name, setup, stmt, iterations)
<commit_msg>Fix lint errors<commit_after>#!/usr/bin/env python
"""Benchmark scipy.stats.cauchy."""

from __future__ import print_function
import timeit

REPEATS = 3
COUNT = [0]  # use a list to allow modification within nested scopes


def print_version():
    """Print the TAP version."""
    print("TAP version 13")


def print_summary(total, passing):
    """Print the benchmark summary.

    # Arguments

    * `total`: total number of tests
    * `passing`: number of passing tests

    """
    print("#")
    print("1.." + str(total))  # TAP plan
    print("# total " + str(total))
    print("# pass  " + str(passing))
    print("#")
    print("# ok")


def print_results(iterations, elapsed):
    """Print benchmark results.

    # Arguments

    * `iterations`: number of iterations
    * `elapsed`: elapsed time (in seconds)

    # Examples

    ``` python
    python> print_results(1000000, 0.131009101868)
    ```
    """
    rate = iterations / elapsed

    print("  ---")
    print("  iterations: " + str(iterations))
    print("  elapsed: " + str(elapsed))
    print("  rate: " + str(rate))
    print("  ...")


def benchmark(name, setup, stmt, iterations):
    """Run the benchmark and print benchmark results.

    # Arguments

    * `name`: benchmark name
    * `setup`: benchmark setup
    * `stmt`: statement to benchmark
    * `iterations`: number of iterations

    # Examples

    ``` python
    python> benchmark("random", "from random import random;", "y = random()", 1000000)
    ```
    """
    t = timeit.Timer(stmt, setup=setup)

    print_version()

    i = 0
    while i < REPEATS:
        print("# python::" + name)
        COUNT[0] += 1
        elapsed = t.timeit(number=iterations)
        print_results(iterations, elapsed)
        print("ok " + str(COUNT[0]) + " benchmark finished")
        i += 1


def main():
    """Run the benchmarks."""
    name = "cauchy:entropy"
    setup = "from scipy.stats import cauchy; from random import random; rv = cauchy(10.0, 6.0);"
    stmt = "y = rv.entropy()"
    iterations = 1000
    benchmark(name, setup, stmt, iterations)

    name = "cauchy:median"
    setup = "from scipy.stats import cauchy; from random import random; rv = cauchy(10.0, 6.0);"
    stmt = "y = rv.median()"
    iterations = 1000
    benchmark(name, setup, stmt, iterations)

    name = "cauchy:cdf"
    setup = "from scipy.stats import cauchy; from random import random; rv = cauchy(10.0, 6.0);"
    stmt = "y = rv.cdf(random())"
    iterations = 1000
    benchmark(name, setup, stmt, iterations)

    name = "cauchy:logcdf"
    setup = "from scipy.stats import cauchy; from random import random; rv = cauchy(10.0, 6.0);"
    stmt = "y = rv.logcdf(random())"
    iterations = 1000
    benchmark(name, setup, stmt, iterations)

{'fraction_non_alphanumeric': 0.14588235294117646, 'fraction_numerical': 0.026425339366515838, 'mean_word_length': 2.8535564853556483, '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': '6651867', 'n_tokens_mistral': 2013, 'n_tokens_neox': 1749, 'n_words': 518}