<commit_before>#!/usr/bin/python

from common import dot_product
import shtest, sys, common
 
def dot(p, q, types=[]):
    result = dot_product(p, q)
    return shtest.make_test([result], [p, q], types)

def insert_into(test):
    test.add_test(dot((1.0, 2.0, 3.0), (1.0, 2.0, 3.0)))
    test.add_test(dot((1.0, 1.0, 1.0), (1.0, 1.0, 1.0)))
    test.add_test(dot((1.0, 0.0, 1.0), (0.0, 1.0, 0.0)))
    test.add_test(dot((0.5, -1.0, 1.0), (0.5, -1.5, -6.0)))

    test.add_test(dot((1.0, 2.0, 3.0), (1.0, 2.0, 3.0), ['i', 'i', 'i']))
    test.add_test(dot((1.0, 1.0, 1.0), (1.0, 1.0, 1.0), ['i', 'i', 'i']))
    test.add_test(dot((1.0, 0.0, 1.0), (0.0, 1.0, 0.0), ['i', 'i', 'i']))
    test.add_test(dot((7.0, -1.0, 1.0), (7.0, -1.0, -6.0), ['i', 'i', 'i']))

# Test the dot product in stream programs
test = shtest.StreamTest('dot', 2)
test.add_call(shtest.Call(shtest.Call.infix, '|', 2))
insert_into(test)
test.output_header(sys.stdout)
test.output(sys.stdout, False)

# Test the dot product in immediate mode
test = shtest.ImmediateTest('dot_im', 2)
test.add_call(shtest.Call(shtest.Call.infix, '|', 2))
insert_into(test)
test.output(sys.stdout, False)

test.output_footer(sys.stdout)
<commit_msg>Improve the coverage of the unit test for both floats and integers<commit_after>#!/usr/bin/python

from common import dot_product
import shtest, sys, common
 
def dot(p, q, types=[]):
    result = dot_product(p, q)
    return shtest.make_test([result], [p, q], types)

def insert_into(test):
    test.add_test(dot((0.0,), (0.0,)))
    test.add_test(dot((0.0,), (1.0,)))
    test.add_test(dot((-1.0,), (1.0,)))
    test.add_test(dot((-1.0,), (-1.0,)))
    test.add_test(dot((5.0,), (8.0,)))
    test.add_test(dot((5000.40,), (-3450.34,)))

    test.add_test(dot((1.0, 2.0), (1.0, 2.0)))
    test.add_test(dot((1.0, 2.0, 3.0), (1.0, 2.0, 3.0)))
    test.add_test(dot((1.0, 2.0, 3.0, 4.0), (1.0, 2.0, 3.0, 4.0)))
    test.add_test(dot((1.0, 1.0, 1.0), (1.0, 1.0, 1.0)))
    test.add_test(dot((1.0, 0.0, 1.0), (0.0, 1.0, 0.0)))
    test.add_test(dot((0.5, -1.0, 1.0), (0.5, -1.5, -6.0)))

    test.add_test(dot((0,), (0,), ['i', 'i', 'i']))
    test.add_test(dot((0,), (1,), ['i', 'i', 'i']))
    test.add_test(dot((-1,), (1,), ['i', 'i', 'i']))
    test.add_test(dot((-1,), (-1,), ['i', 'i', 'i']))
    test.add_test(dot((5,), (8,), ['i', 'i', 'i']))
    test.add_test(dot((5000,), (-3450,), ['i', 'i', 'i']))

    test.add_test(dot((1, 2), (1, 2), ['i', 'i', 'i']))
    test.add_test(dot((1, 2, 3), (1, 2, 3), ['i', 'i', 'i']))
    test.add_test(dot((1, 2, 3, 4), (1, 2, 3, 4), ['i', 'i', 'i']))
    test.add_test(dot((1, 1, 1), (1, 1, 1), ['i', 'i', 'i']))
    test.add_test(dot((1, 0, 1), (0, 1, 0), ['i', 'i', 'i']))

# Test the dot product in stream programs
test = shtest.StreamTest('dot', 2)
test.add_call(shtest.Call(shtest.Call.infix, '|', 2))
insert_into(test)
test.output_header(sys.stdout)
test.output(sys.stdout, False)

# Test the dot product in immediate mode
test = shtest.ImmediateTest('dot_im', 2)
test.add_call(shtest.Call(shtest.Call.infix, '|', 2))
insert_into(test)
test.output(sys.stdout, False)

test.output_footer(sys.stdout)

{'fraction_non_alphanumeric': 0.28144853875476494, 'fraction_numerical': 0.08132147395171538, 'mean_word_length': 3.735338345864662, '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': '5796605', 'n_tokens_mistral': 1596, 'n_tokens_neox': 1497, 'n_words': 304}