<commit_before># offset-finder
#
# Copyright (c) 2014 British Broadcasting Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from nose.tools import *
from offset_finder import *
from numpy.testing import *
import numpy as np

def test_truncate():
    a1 = np.array([])
    a2 = np.array([])
    r1, r2 = truncate(a1, a2)
    assert_array_equal(r1, a1)
    assert_array_equal(r2, a2)

    a1 = np.array([])
    a2 = np.array([0,1,2,3])
    r1, r2 = truncate(a1, a2)
    assert_array_equal(r1, a1)
    assert_array_equal(r2, np.array([1,2,3]))

    a1 = np.array([0,0,1,2])
    a2 = np.array([0,1,2,3])
    r1, r2 = truncate(a1, a2)
    assert_array_equal(r1, np.array([1,2]))
    assert_array_equal(r2, np.array([2,3]))
<commit_msg>Fixing import in tests<commit_after># offset-finder
#
# Copyright (c) 2014 British Broadcasting Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from nose.tools import *
from audio_offset_finder import *
from numpy.testing import *
import numpy as np

def test_truncate():
    a1 = np.array([])
    a2 = np.array([])
    r1, r2 = truncate(a1, a2)
    assert_array_equal(r1, a1)
    assert_array_equal(r2, a2)

    a1 = np.array([])
    a2 = np.array([0,1,2,3])
    r1, r2 = truncate(a1, a2)
    assert_array_equal(r1, a1)
    assert_array_equal(r2, np.array([1,2,3]))

    a1 = np.array([0,0,1,2])
    a2 = np.array([0,1,2,3])
    r1, r2 = truncate(a1, a2)
    assert_array_equal(r1, np.array([1,2]))
    assert_array_equal(r2, np.array([2,3]))

{'fraction_non_alphanumeric': 0.12062726176115803, 'fraction_numerical': 0.04342581423401689, 'mean_word_length': 3.91699604743083, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5690933', 'n_tokens_mistral': 873, 'n_tokens_neox': 852, 'n_words': 277}