fix tests

This commit is contained in:
Vadim committed 2024-07-24 21:46:12 +02:00
1 parent e293587f30
commit 557e0e2283
8 files changed
+325 -119

No files matched your search

@@ -5,6 +5,7 @@ from unittest.mock import patch
from src.modules.Speech_Recognition.hyphenation import hyphenation, language_check
from hyphen import Hyphenator
class TestHypenation(unittest.TestCase):
def test_hypenation(self):
@@ -17,18 +18,17 @@ class TestHypenation(unittest.TestCase):
@patch('hyphen.dictools.list_installed')
def test_language_check_has_installed_language(self, mock_list_installed):
mock_list_installed.return_value = ['de', 'de_DE', 'en', 'en_US', 'en_GB']
assert language_check("en") == "en_US"
assert language_check("de") == "de_DE"
@patch('hyphen.dictools.list_installed')
def test_language_check_not_installed_language(self, mock_list_installed):
mock_list_installed.return_value = []
assert language_check("fr") == "fr_FR"
assert language_check("de") == "de"
assert language_check("none") == None
if __name__ == "__main__":
unittest.main()
unittest.main()
@@ -0,0 +1,17 @@
"""Tests for ultrastar_txt_converter.py"""
import unittest
from modules.Ultrastar.coverter.ultrastar_txt_converter import extract_year
class TestUltrastarTxtConverter(unittest.TestCase):
def test_extract_year(self):
years = {extract_year("2023-12-31"), extract_year("2023-12-31 23:59:59"), extract_year("2023/12/31"),
extract_year("2023\\12\\31"), extract_year("2023.12.31"), extract_year("2023 12 31"),
extract_year("12-31-2023"), extract_year("12/31/2023"), extract_year("12\\31\\2023"),
extract_year("12.31.2023"), extract_year("12 31 2023"), extract_year("12-2023"),
extract_year("12/2023"), extract_year("2023")}
for year in years:
self.assertEqual(year, "2023")
@@ -0,0 +1,36 @@
"""Tests for ultrastar_parser.py"""
import unittest
import os
from unittest.mock import patch, MagicMock
from modules.Ultrastar.ultrastar_parser import parse_ultrastar_txt
class TestUltraStarParser(unittest.TestCase):
@patch("modules.Ultrastar.ultrastar_parser.parse")
@patch("modules.Ultrastar.ultrastar_parser.os.path.dirname")
@patch("modules.os_helper.create_folder")
def test_parse_ultrastar_txt(self, mock_create_folder, mock_dirname, mock_parse):
# Arrange
mock_parse.return_value = MagicMock(mp3="test.mp3",
artist=" Test Artist ",
# Also test leading and trailing whitespaces
title=" Test Title ") # Also test leading and trailing whitespaces
mock_dirname.return_value = os.path.join("path", "to", "input")
output_file_path = os.path.join("path", "to", "output")
mock_create_folder.return_value = None
# Act
result = parse_ultrastar_txt(mock_dirname.return_value, output_file_path)
# Assert
self.assertEqual(result, ("Test Artist - Test Title",
os.path.join("path", "to", "output", "Test Artist - Test Title"),
os.path.join("path", "to", "input", "test.mp3"),
mock_parse.return_value))
#
mock_parse.assert_called_once()
mock_dirname.assert_called_once()
mock_create_folder.assert_called_once()
+257 -44
View File
@@ -1,38 +1,39 @@
"""Tests for the ultrastar_writer.py module."""
import unittest
from packaging import version
from unittest.mock import patch, mock_open
from src.modules.Ultrastar.ultrastar_writer import create_ultrastar_txt, deviation
from src.modules.Speech_Recognition.TranscribedData import TranscribedData
from src.modules.Ultrastar.ultrastar_writer import create_ultrastar_txt, deviation, format_separated_string
from src.modules.Midi.MidiSegment import MidiSegment
from src.modules.Ultrastar.ultrastar_txt import UltrastarTxtValue, UltrastarTxtTag
class TestCreateUltrastarTxt(unittest.TestCase):
def test_create_ultrastar_txt_from_automation_default_values(self):
# Arrange
bpm, note_numbers, transcribed_data, ultrastar_file_output = self.arrange()
bpm, midi_segments, ultrastar_file_output = self.arrange()
class_under_test = UltrastarTxtValue()
# Act and Assert default values
class_under_test.version = "0.2.0"
expected_calls = self.default_values(class_under_test, class_under_test.version)
self.act_and_assert(bpm, class_under_test, expected_calls, note_numbers, transcribed_data,
self.act_and_assert(bpm, class_under_test, expected_calls, midi_segments,
ultrastar_file_output)
class_under_test.version = "1.0.0"
expected_calls = self.default_values(class_under_test, class_under_test.version)
self.act_and_assert(bpm, class_under_test, expected_calls, note_numbers, transcribed_data,
self.act_and_assert(bpm, class_under_test, expected_calls, midi_segments,
ultrastar_file_output)
class_under_test.version = "1.1.0"
expected_calls = self.default_values(class_under_test, class_under_test.version)
self.act_and_assert(bpm, class_under_test, expected_calls, note_numbers, transcribed_data,
self.act_and_assert(bpm, class_under_test, expected_calls, midi_segments,
ultrastar_file_output)
def test_create_ultrastar_txt_from_automation_full_values(self):
# Arrange
bpm, note_numbers, transcribed_data, ultrastar_file_output = self.arrange()
bpm, midi_segments, ultrastar_file_output = self.arrange()
class_under_test = UltrastarTxtValue()
class_under_test.artist = "artist"
@@ -52,50 +53,33 @@ class TestCreateUltrastarTxt(unittest.TestCase):
class_under_test.version = "0.2.0"
expected_calls = self.full_values(class_under_test, class_under_test.version)
self.act_and_assert(bpm, class_under_test, expected_calls, note_numbers, transcribed_data,
self.act_and_assert(bpm, class_under_test, expected_calls, midi_segments,
ultrastar_file_output)
class_under_test.version = "1.0.0"
expected_calls = self.full_values(class_under_test, class_under_test.version)
self.act_and_assert(bpm, class_under_test, expected_calls, note_numbers, transcribed_data,
self.act_and_assert(bpm, class_under_test, expected_calls, midi_segments,
ultrastar_file_output)
class_under_test.version = "1.1.0"
expected_calls = self.full_values(class_under_test, class_under_test.version)
self.act_and_assert(bpm, class_under_test, expected_calls, note_numbers, transcribed_data,
self.act_and_assert(bpm, class_under_test, expected_calls, midi_segments,
ultrastar_file_output)
def arrange(self):
# Arrange
transcribed_data = [
TranscribedData.from_dict({
"confidence": 0.95,
"word": "UltraSinger ",
"end": 2.5,
"start": 0.5
}),
TranscribedData.from_dict({
"confidence": 0.9,
"word": "is ",
"end": 4.5,
"start": 3.0
}),
TranscribedData.from_dict({
"confidence": 0.85,
"word": "cool! ",
"end": 7.5,
"start": 5.5
}),
]
note_numbers = [1, 2, 3]
def arrange(self) -> tuple[int, list[MidiSegment], str]:
midi_segments = [
MidiSegment(note="C#3", start=0.5, end=2.5, word="UltraSinger "),
MidiSegment(note="D3", start=3.0, end=4.5, word="is "),
MidiSegment(note="D#3", start=5.5, end=7.5, word="cool! ")]
ultrastar_file_output = "output.txt"
bpm = 120
return bpm, note_numbers, transcribed_data, ultrastar_file_output
return bpm, midi_segments, ultrastar_file_output
def act_and_assert(self, bpm, default_ultrastar_class, expected_calls_default_values, note_numbers,
transcribed_data, ultrastar_file_output):
def act_and_assert(self, bpm, default_ultrastar_class, expected_calls_default_values, midi_segments,
ultrastar_file_output):
# Act
mock_file = self.act(bpm, default_ultrastar_class, note_numbers, transcribed_data, ultrastar_file_output)
mock_file = self.act(bpm, default_ultrastar_class, midi_segments, ultrastar_file_output)
# Assert the file was opened and is utf-8
mock_file.assert_called_once_with(ultrastar_file_output, "w", encoding='utf-8')
@@ -164,17 +148,81 @@ class TestCreateUltrastarTxt(unittest.TestCase):
return expected_calls
@staticmethod
def act(bpm, default_ultrastar_class, note_numbers, transcribed_data, ultrastar_file_output):
def act(bpm, default_ultrastar_class, midi_segments, ultrastar_file_output):
with patch("builtins.open", mock_open()) as mock_file:
create_ultrastar_txt(
transcribed_data, note_numbers, ultrastar_file_output,
midi_segments, ultrastar_file_output,
default_ultrastar_class, bpm
)
return mock_file
def test_most_common_silent_part_CorTaySnf(self):
# Arrange
val = [0.020000000000000018, 0.0, 0.020000000000000018, 0.019999999999999796, 0.039999999999999813, 0.46099999999999985, 0.040000000000000036, 0.03999999999999959, 0.040000000000000036, 0.040000000000000036, 0.040000000000000036, 5.702, 0.02000000000000135, 0.21999999999999886, 0.03999999999999915, 0.040000000000000924, 0.019999999999999574, 0.14000000000000057, 0.5999999999999996, 0.0600000000000005, 0.0, 0.0, 0.019999999999999574, 0.0, 0.02000000000000135, 0.03999999999999915, 0.27999999999999936, 0.03999999999999915, 0.02000000000000135, 0.05999999999999872, 0.03999999999999915, 0.03999999999999915, 0.0600000000000005, 0.02000000000000135, 0.040000000000000924, 0.019999999999999574, 0.040000000000000924, 10.298999999999998, 10.557999999999996, 0.01999999999999602, 0.3810000000000002, 0.03999999999999915, 0.10000000000000142, 0.020000000000003126, 0.05999999999999517, 0.03999999999999915, 3.347999999999999, 0.12000000000000455, 0.14000000000000057, 0.020000000000003126, 0.0, 0.0, 0.7199999999999989, 0.060000000000002274, 0.0799999999999983, 0.060000000000002274, 0.12000000000000455, 1.3530000000000015, 0.30000000000000426, 0.05999999999999517, 0.0799999999999983, 0.10000000000000142, 0.0799999999999983, 0.09999999999999432, 0.0799999999999983, 0.10000000000000142, 3.201999999999998, 0.0799999999999983, 0.0799999999999983, 0.2610000000000028, 0.09999999999999432, 0.0, 0.0, 0.45999999999999375, 0.03999999999999915, 0.060000000000002274, 0.0, 0.0800000000000054, 13.022999999999996, 0.1599999999999966, 0.04000000000000625, 0.05999999999998806, 0.01999999999999602, 0.0799999999999983, 0.04000000000000625, 0.060000000000002274, 0.020000000000010232, 1.1110000000000042, 0.060000000000002274, 0.01999999999999602, 0.0, 0.28000000000000114, 0.05999999999998806, 1.3870000000000005, 0.060000000000002274, 0.0799999999999983, 0.03999999999999204, 0.01999999999999602, 0.060000000000002274, 0.01999999999999602, 0.060000000000002274, 0.01999999999999602, 1.5009999999999906, 0.01999999999999602, 0.0, 0.060000000000002274, 0.0799999999999983, 0.12000000000000455, 0.060000000000002274, 1.3410000000000082, 0.0, 0.060000000000002274, 0.0800000000000125, 0.060000000000002274, 0.14000000000000057, 1.4209999999999923, 0.1799999999999926, 0.1600000000000108, 0.060000000000002274, 0.060000000000002274, 0.0, 0.04000000000000625, 1.4609999999999985, 0.01999999999999602, 0.020000000000010232, 0.0, 0.03999999999999204, 0.0799999999999983, 0.060000000000002274, 3.307000000000002, 0.03999999999999204, 0.01999999999999602, 0.01999999999999602, 0.09999999999999432, 0.04000000000000625, 0.01999999999999602, 0.04000000000000625, 0.060000000000002274, 0.04000000000000625, 0.020000000000010232, 0.03999999999999204, 0.1600000000000108, 0.060000000000002274, 0.12000000000000455, 0.01999999999999602, 13.403999999999996, 0.10000000000000853, 0.10000000000000853, 0.11999999999999034, 0.0, 0.0799999999999983, 0.09999999999999432, 0.060000000000002274, 3.4599999999999937, 0.0, 0.10000000000002274, 0.18000000000000682, 0.11999999999997613, 2.552000000000021, 0.0800000000000125, 1.4210000000000207, 0.07999999999998408, 0.13999999999998636, 0.22100000000000364, 0.12000000000000455, 0.060000000000002274, 0.09999999999999432, 0.14000000000001478, 3.7220000000000084, 0.01999999999998181, 0.09999999999999432, 0.09999999999999432, 0.18000000000000682, 0.12000000000000455, 0.9000000000000057, 0.060000000000002274, 0.060000000000002274, 0.0, 0.03999999999999204, 0.03999999999999204, 0.37999999999999545, 0.060000000000002274, 0.03999999999999204, 0.03999999999999204, 0.12000000000000455, 0.03999999999999204, 0.060000000000002274, 0.12000000000000455, 0.020000000000010232, 1.4609999999999843, 0.0800000000000125, 0.020000000000010232, 0.07999999999998408, 0.03999999999999204, 0.21999999999999886, 1.281000000000006, 0.060000000000002274, 0.060000000000002274, 0.060000000000002274, 0.03999999999999204, 0.03999999999999204, 1.2800000000000011, 0.01999999999998181, 0.060000000000002274, 0.0, 0.040000000000020464, 0.060000000000002274, 0.1599999999999966, 2.009999999999991, 0.09999999999999432, 0.020000000000010232, 0.040000000000020464, 0.03999999999999204, 0.0, 0.060000000000002274, 0.12000000000000455, 1.3410000000000082, 0.07999999999998408, 0.020000000000010232, 0.12000000000000455, 0.01999999999998181, 0.14000000000001478, 0.03999999999999204, 0.30000000000001137, 1.4209999999999923, 0.05999999999997385, 0.07999999999998408, 0.03999999999999204, 0.07999999999998408, 0.0800000000000125, 0.12000000000000455, 2.3220000000000027, 0.2599999999999909, 0.03999999999999204, 0.0800000000000125, 0.0, 0.03999999999999204, 0.060000000000002274, 0.060000000000002274, 0.03999999999999204, 0.03999999999999204, 0.040000000000020464, 0.12000000000000455, 0.06100000000000705, 0.020000000000010232, 0.03999999999999204, 0.03999999999999204, 26.329000000000008, 0.05999999999997385, 0.040000000000020464, 0.0, 0.09999999999999432, 0.07999999999998408, 0.09999999999999432, 1.3Line truncated
val = [0.020000000000000018, 0.0, 0.020000000000000018, 0.019999999999999796, 0.039999999999999813,
0.46099999999999985, 0.040000000000000036, 0.03999999999999959, 0.040000000000000036,
0.040000000000000036, 0.040000000000000036, 5.702, 0.02000000000000135, 0.21999999999999886,
0.03999999999999915, 0.040000000000000924, 0.019999999999999574, 0.14000000000000057, 0.5999999999999996,
0.0600000000000005, 0.0, 0.0, 0.019999999999999574, 0.0, 0.02000000000000135, 0.03999999999999915,
0.27999999999999936, 0.03999999999999915, 0.02000000000000135, 0.05999999999999872, 0.03999999999999915,
0.03999999999999915, 0.0600000000000005, 0.02000000000000135, 0.040000000000000924, 0.019999999999999574,
0.040000000000000924, 10.298999999999998, 10.557999999999996, 0.01999999999999602, 0.3810000000000002,
0.03999999999999915, 0.10000000000000142, 0.020000000000003126, 0.05999999999999517, 0.03999999999999915,
3.347999999999999, 0.12000000000000455, 0.14000000000000057, 0.020000000000003126, 0.0, 0.0,
0.7199999999999989, 0.060000000000002274, 0.0799999999999983, 0.060000000000002274, 0.12000000000000455,
1.3530000000000015, 0.30000000000000426, 0.05999999999999517, 0.0799999999999983, 0.10000000000000142,
0.0799999999999983, 0.09999999999999432, 0.0799999999999983, 0.10000000000000142, 3.201999999999998,
0.0799999999999983, 0.0799999999999983, 0.2610000000000028, 0.09999999999999432, 0.0, 0.0,
0.45999999999999375, 0.03999999999999915, 0.060000000000002274, 0.0, 0.0800000000000054,
13.022999999999996, 0.1599999999999966, 0.04000000000000625, 0.05999999999998806, 0.01999999999999602,
0.0799999999999983, 0.04000000000000625, 0.060000000000002274, 0.020000000000010232, 1.1110000000000042,
0.060000000000002274, 0.01999999999999602, 0.0, 0.28000000000000114, 0.05999999999998806,
1.3870000000000005, 0.060000000000002274, 0.0799999999999983, 0.03999999999999204, 0.01999999999999602,
0.060000000000002274, 0.01999999999999602, 0.060000000000002274, 0.01999999999999602, 1.5009999999999906,
0.01999999999999602, 0.0, 0.060000000000002274, 0.0799999999999983, 0.12000000000000455,
0.060000000000002274, 1.3410000000000082, 0.0, 0.060000000000002274, 0.0800000000000125,
0.060000000000002274, 0.14000000000000057, 1.4209999999999923, 0.1799999999999926, 0.1600000000000108,
0.060000000000002274, 0.060000000000002274, 0.0, 0.04000000000000625, 1.4609999999999985,
0.01999999999999602, 0.020000000000010232, 0.0, 0.03999999999999204, 0.0799999999999983,
0.060000000000002274, 3.307000000000002, 0.03999999999999204, 0.01999999999999602, 0.01999999999999602,
0.09999999999999432, 0.04000000000000625, 0.01999999999999602, 0.04000000000000625, 0.060000000000002274,
0.04000000000000625, 0.020000000000010232, 0.03999999999999204, 0.1600000000000108, 0.060000000000002274,
0.12000000000000455, 0.01999999999999602, 13.403999999999996, 0.10000000000000853, 0.10000000000000853,
0.11999999999999034, 0.0, 0.0799999999999983, 0.09999999999999432, 0.060000000000002274,
3.4599999999999937, 0.0, 0.10000000000002274, 0.18000000000000682, 0.11999999999997613,
2.552000000000021, 0.0800000000000125, 1.4210000000000207, 0.07999999999998408, 0.13999999999998636,
0.22100000000000364, 0.12000000000000455, 0.060000000000002274, 0.09999999999999432, 0.14000000000001478,
3.7220000000000084, 0.01999999999998181, 0.09999999999999432, 0.09999999999999432, 0.18000000000000682,
0.12000000000000455, 0.9000000000000057, 0.060000000000002274, 0.060000000000002274, 0.0,
0.03999999999999204, 0.03999999999999204, 0.37999999999999545, 0.060000000000002274, 0.03999999999999204,
0.03999999999999204, 0.12000000000000455, 0.03999999999999204, 0.060000000000002274, 0.12000000000000455,
0.020000000000010232, 1.4609999999999843, 0.0800000000000125, 0.020000000000010232, 0.07999999999998408,
0.03999999999999204, 0.21999999999999886, 1.281000000000006, 0.060000000000002274, 0.060000000000002274,
0.060000000000002274, 0.03999999999999204, 0.03999999999999204, 1.2800000000000011, 0.01999999999998181,
0.060000000000002274, 0.0, 0.040000000000020464, 0.060000000000002274, 0.1599999999999966,
2.009999999999991, 0.09999999999999432, 0.020000000000010232, 0.040000000000020464, 0.03999999999999204,
0.0, 0.060000000000002274, 0.12000000000000455, 1.3410000000000082, 0.07999999999998408,
0.020000000000010232, 0.12000000000000455, 0.01999999999998181, 0.14000000000001478, 0.03999999999999204,
0.30000000000001137, 1.4209999999999923, 0.05999999999997385, 0.07999999999998408, 0.03999999999999204,
0.07999999999998408, 0.0800000000000125, 0.12000000000000455, 2.3220000000000027, 0.2599999999999909,
0.03999999999999204, 0.0800000000000125, 0.0, 0.03999999999999204, 0.060000000000002274,
0.060000000000002274, 0.03999999999999204, 0.03999999999999204, 0.040000000000020464,
0.12000000000000455, 0.06100000000000705, 0.020000000000010232, 0.03999999999999204, 0.03999999999999204,
26.329000000000008, 0.05999999999997385, 0.040000000000020464, 0.0, 0.09999999999999432,
0.07999999999998408, 0.09999999999999432, 1.3810000000000002, 0.040000000000020464, 0.03999999999999204,
0.03999999999999204, 0.09999999999999432, 0.0800000000000125, 0.12000000000000455, 1.3810000000000002,
0.07999999999998408, 0.12000000000000455, 0.12000000000000455, 0.0800000000000125, 1.9370000000000118,
0.0800000000000125, 0.03999999999999204, 0.14000000000001478, 0.020000000000010232, 0.03999999999999204,
0.060000000000002274, 0.0, 0.020000000000010232, 0.48699999999999477, 0.060000000000002274,
0.01999999999998181, 0.09999999999999432, 0.040000000000020464, 0.03999999999999204, 0.12000000000000455,
0.9199999999999875, 0.08099999999998886, 0.060000000000002274, 0.07999999999998408, 0.09999999999999432,
0.060000000000002274, 0.09999999999999432, 1.4809999999999945, 0.0, 0.1599999999999966,
0.020000000000010232, 0.03999999999999204, 0.07999999999998408, 0.0, 2.7450000000000045,
0.03999999999999204, 0.03999999999999204, 0.09999999999999432, 0.0, 0.060000000000002274,
0.020000000000010232, 0.020000000000010232, 0.060000000000002274, 0.03999999999999204,
0.01999999999998181, 0.03999999999999204, 0.13999999999998636, 0.03999999999999204, 0.03999999999999204,
0.03999999999999204, 0.01999999999998181, 2.4029999999999916, 0.020000000000010232, 0.020000000000010232,
0.03999999999999204, 0.14000000000001478, 0.040000000000020464, 0.04099999999999682,
0.040000000000020464, 0.040000000000020464]
# Act
result = deviation(val)
@@ -185,7 +233,52 @@ class TestCreateUltrastarTxt(unittest.TestCase):
def test_most_common_silent_part_AnenRegnen(self):
# Arrange
val = [0.03999999999999915, 0.0, 0.0600000000000005, 0.0, 0.08000000000000007, 0.0600000000000005, 0.0600000000000005, 0.06099999999999994, 1.556000000000001, 0.0400000000000027, 0.03999999999999915, 0.10000000000000142, 0.019999999999999574, 0.03999999999999915, 0.6400000000000006, 0.03999999999999915, 0.03999999999999915, 0.03999999999999915, 0.03999999999999915, 0.0400000000000027, 1.5410000000000004, 0.05999999999999872, 0.03999999999999915, 0.0, 0.0, 0.03999999999999915, 0.0, 1.0869999999999997, 0.13999999999999702, 0.0, 0.019999999999999574, 0.10000000000000142, 0.34550000000000125, 0.08000000000000185, 0.019999999999999574, 0.0, 0.019999999999999574, 6.531000000000002, 0.03999999999999915, 0.0, 0.03999999999999915, 0.060000000000002274, 0.03999999999999915, 0.04099999999999682, 0.03999999999999915, 0.0, 1.7520000000000024, 0.0, 0.03999999999999915, 0.05999999999999517, 0.020000000000003126, 0.0, 0.03999999999999915, 0.0800000000000054, 0.14000000000000057, 0.03999999999999915, 1.7509999999999977, 0.03999999999999915, 0.03999999999999915, 0.04000000000000625, 0.060000000000002274, 0.0, 0.11299999999999955, 0.09999999999999432, 0.03999999999999915, 0.05999999999999517, 0.01999999999999602, 0.0, 0.9639999999999986, 0.03999999999999915, 0.03999999999999915, 0.01999999999999602, 0.03999999999999915, 0.060000000000002274, 0.0, 0.01999999999999602, 0.05999999999999517, 0.0799999999999983, 0.03999999999999915, 1.8969999999999985, 0.0799999999999983, 0.05999999999999517, 0.0, 0.03999999999999915, 0.0, 0.09999999999999432, 1.3980000000000032, 0.0799999999999983, 0.020000000000003126, 0.0, 0.03999999999999915, 0.0, 0.0800000000000054, 0.01999999999999602, 0.06000000000000938, 0.060000000000002274, 0.0, 2.1199999999999903, 0.03999999999999204, 0.10000000000000853, 0.01999999999999602, 0.03999999999999204, 0.5179999999999865, 0.060000000000002274, 0.01999999999999602, 0.04000000000000625, 0.04000000000000625, 0.04000000000000625, 1.3790000000000049, 0.01999999999999602, 0.03999999999999204, 0.0, 0.0, 0.03999999999999204, 0.0, 1.024000000000001, 0.14000000000000057, 0.0, 0.01999999999999602, 0.10000000000000853, -0.1909999999999883, 0.3719999999999999, 0.0799999999999983, 0.01999999999999602, 0.0, 0.03999999999999204, 17.049000000000007, 0.01999999999999602, 0.0, 0.04000000000000625, 0.03999999999999204, 0.03999999999999204, 0.01999999999999602, 0.04000000000000625, 0.29649999999999466, 0.060000000000002274, 0.04000000000000625, 0.04000000000000625, 0.0, 0.03999999999999204, 0.0, 0.0799999999999983, 0.03999999999999204, 0.04000000000000625, 0.060000000000002274, 0.04000000000000625, 0.3200000000000074, 0.04000000000000625, 0.0, 0.060000000000002274, 0.0, 0.01999999999999602, 0.12000000000000455, 0.04000000000000625, 0.0799999999999983, 0.0, 0.01999999999999602, 0.03999999999999204, 0.5090000000000003, 0.03999999999999204, 0.0, 0.04000000000000625, 0.05999999999998806, 0.0, 0.37400000000000944, 0.01999999999999602, 0.04000000000000625, 0.03999999999999204, 0.0799999999999983, 0.060000000000002274, 0.04000000000000625, 0.021000000000000796, 0.03999999999999204, 0.0, 0.0, 0.09999999999999432, 0.0, 0.936000000000007, 0.04000000000000625, 0.0, 0.01999999999999602, 0.060000000000002274, 0.2670000000000101, 0.03999999999999204, 0.0, 0.03999999999999204, 0.0, 0.09999999999999432, 1.4819999999999993, 0.04000000000000625, 0.01999999999999602, 0.0, 0.060000000000002274, 0.0, 0.0799999999999983, 0.03999999999999204, 0.060000000000002274, 0.060000000000002274, 0.0, 2.5289999999999964, 0.040000000000020464, 0.0, 0.03999999999999204, 0.8095000000000141, 0.03999999999999204, 0.03999999999999204, 0.020000000000010232, 0.37999999999999545, 1.2280000000000086, 0.0, 0.03999999999999204, 0.0, 0.0, 0.2599999999999909, 1.7789999999999964, 0.060000000000002274, 0.040000000000020464, 0.0, 0.03999999999999204, 0.0, 0.20000000000001705, 0.01999999999998181, 0.07999999999998408, 0.07999999999998408, 6.7309999999999945, 0.060000000000002274, 0.12699999999998113, 0.0, 0.060000000000002274, 0.0, 0.09999999999999432, 0.060000000000002274, 0.17000000000001592, 0.0800000000000125, 0.14599999999998658, 2.466000000000008, 0.060000000000002274, 0.19999999999998863, 0.020000000000010232, 0.15500000000000114, 0.9489999999999839, 0.040000000000020464, 0.0, 0.03999999999999204, 0.040000000000020464, 0.14500000000001023]
val = [0.03999999999999915, 0.0, 0.0600000000000005, 0.0, 0.08000000000000007, 0.0600000000000005,
0.0600000000000005, 0.06099999999999994, 1.556000000000001, 0.0400000000000027, 0.03999999999999915,
0.10000000000000142, 0.019999999999999574, 0.03999999999999915, 0.6400000000000006, 0.03999999999999915,
0.03999999999999915, 0.03999999999999915, 0.03999999999999915, 0.0400000000000027, 1.5410000000000004,
0.05999999999999872, 0.03999999999999915, 0.0, 0.0, 0.03999999999999915, 0.0, 1.0869999999999997,
0.13999999999999702, 0.0, 0.019999999999999574, 0.10000000000000142, 0.34550000000000125,
0.08000000000000185, 0.019999999999999574, 0.0, 0.019999999999999574, 6.531000000000002,
0.03999999999999915, 0.0, 0.03999999999999915, 0.060000000000002274, 0.03999999999999915,
0.04099999999999682, 0.03999999999999915, 0.0, 1.7520000000000024, 0.0, 0.03999999999999915,
0.05999999999999517, 0.020000000000003126, 0.0, 0.03999999999999915, 0.0800000000000054,
0.14000000000000057, 0.03999999999999915, 1.7509999999999977, 0.03999999999999915, 0.03999999999999915,
0.04000000000000625, 0.060000000000002274, 0.0, 0.11299999999999955, 0.09999999999999432,
0.03999999999999915, 0.05999999999999517, 0.01999999999999602, 0.0, 0.9639999999999986,
0.03999999999999915, 0.03999999999999915, 0.01999999999999602, 0.03999999999999915, 0.060000000000002274,
0.0, 0.01999999999999602, 0.05999999999999517, 0.0799999999999983, 0.03999999999999915,
1.8969999999999985, 0.0799999999999983, 0.05999999999999517, 0.0, 0.03999999999999915, 0.0,
0.09999999999999432, 1.3980000000000032, 0.0799999999999983, 0.020000000000003126, 0.0,
0.03999999999999915, 0.0, 0.0800000000000054, 0.01999999999999602, 0.06000000000000938,
0.060000000000002274, 0.0, 2.1199999999999903, 0.03999999999999204, 0.10000000000000853,
0.01999999999999602, 0.03999999999999204, 0.5179999999999865, 0.060000000000002274, 0.01999999999999602,
0.04000000000000625, 0.04000000000000625, 0.04000000000000625, 1.3790000000000049, 0.01999999999999602,
0.03999999999999204, 0.0, 0.0, 0.03999999999999204, 0.0, 1.024000000000001, 0.14000000000000057, 0.0,
0.01999999999999602, 0.10000000000000853, -0.1909999999999883, 0.3719999999999999, 0.0799999999999983,
0.01999999999999602, 0.0, 0.03999999999999204, 17.049000000000007, 0.01999999999999602, 0.0,
0.04000000000000625, 0.03999999999999204, 0.03999999999999204, 0.01999999999999602, 0.04000000000000625,
0.29649999999999466, 0.060000000000002274, 0.04000000000000625, 0.04000000000000625, 0.0,
0.03999999999999204, 0.0, 0.0799999999999983, 0.03999999999999204, 0.04000000000000625,
0.060000000000002274, 0.04000000000000625, 0.3200000000000074, 0.04000000000000625, 0.0,
0.060000000000002274, 0.0, 0.01999999999999602, 0.12000000000000455, 0.04000000000000625,
0.0799999999999983, 0.0, 0.01999999999999602, 0.03999999999999204, 0.5090000000000003,
0.03999999999999204, 0.0, 0.04000000000000625, 0.05999999999998806, 0.0, 0.37400000000000944,
0.01999999999999602, 0.04000000000000625, 0.03999999999999204, 0.0799999999999983, 0.060000000000002274,
0.04000000000000625, 0.021000000000000796, 0.03999999999999204, 0.0, 0.0, 0.09999999999999432, 0.0,
0.936000000000007, 0.04000000000000625, 0.0, 0.01999999999999602, 0.060000000000002274,
0.2670000000000101, 0.03999999999999204, 0.0, 0.03999999999999204, 0.0, 0.09999999999999432,
1.4819999999999993, 0.04000000000000625, 0.01999999999999602, 0.0, 0.060000000000002274, 0.0,
0.0799999999999983, 0.03999999999999204, 0.060000000000002274, 0.060000000000002274, 0.0,
2.5289999999999964, 0.040000000000020464, 0.0, 0.03999999999999204, 0.8095000000000141,
0.03999999999999204, 0.03999999999999204, 0.020000000000010232, 0.37999999999999545, 1.2280000000000086,
0.0, 0.03999999999999204, 0.0, 0.0, 0.2599999999999909, 1.7789999999999964, 0.060000000000002274,
0.040000000000020464, 0.0, 0.03999999999999204, 0.0, 0.20000000000001705, 0.01999999999998181,
0.07999999999998408, 0.07999999999998408, 6.7309999999999945, 0.060000000000002274, 0.12699999999998113,
0.0, 0.060000000000002274, 0.0, 0.09999999999999432, 0.060000000000002274, 0.17000000000001592,
0.0800000000000125, 0.14599999999998658, 2.466000000000008, 0.060000000000002274, 0.19999999999998863,
0.020000000000010232, 0.15500000000000114, 0.9489999999999839, 0.040000000000020464, 0.0,
0.03999999999999204, 0.040000000000020464, 0.14500000000001023]
# Act
result = deviation(val)
@@ -196,7 +289,51 @@ class TestCreateUltrastarTxt(unittest.TestCase):
def test_most_common_silent_part_discw(self):
# Arrange
val = [0.08000000000000007, 0.08000000000000007, 0.17999999999999972, 0.03999999999999915, 0.0, 0.0600000000000005, 0.0, 1.3010000000000002, 0.0600000000000005, 0.08000000000000007, 0.08000000000000007, 0.120000000000001, 0.019999999999999574, 0.08000000000000007, 1.6209999999999987, 0.0, 0.09999999999999787, 0.18100000000000094, 0.11999999999999744, 1.1210000000000022, 0.0799999999999983, 0.4209999999999994, 0.0, 0.0, 0.1999999999999993, 0.9000000000000021, 0.23999999999999844, 1.7409999999999997, 0.05999999999999872, 0.10000000000000142, 0.03999999999999915, 0.03999999999999915, 0.08000000000000185, 1.5809999999999995, 0.12000000000000455, 0.03999999999999915, 0.10000000000000142, 0.060000000000002274, 1.561, 0.05999999999999517, 0.01999999999999602, 0.09999999999999432, 0.05999999999999517, 0.03999999999999915, 0.0799999999999983, 0.5399999999999991, 0.5, 0.10000000000000142, 1.3810000000000002, 0.020000000000003126, 0.0799999999999983, 0.0, 0.1010000000000062, 0.060000000000002274, 1.561, 0.060000000000002274, 0.060000000000002274, 0.03999999999999915, 0.0, 0.03999999999999915, 0.14100000000000534, 1.061, 0.05999999999999517, 0.0799999999999983, 0.060000000000002274, 0.0, 0.04000000000000625, 0.10000000000000142, 2.182000000000002, 0.03999999999999915, 0.03999999999999915, 0.35999999999999943, 0.04000000000000625, 0.11999999999999744, 0.17999999999999972, 0.10000000000000142, 0.14000000000000057, 0.5600000000000023, 0.03999999999999915, 0.17999999999999972, 0.11999999999999744, 0.060000000000002274, 1.2809999999999988, 0.12000000000000455, 0.14000000000000057, 0.12000000000000455, 0.020000000000010232, 0.29999999999999716, 1.4810000000000088, 0.03999999999999204, 0.060000000000002274, 0.10000000000000853, 0.04000000000000625, 0.18000000000000682, 0.8400000000000034, 0.12000000000000455, 0.16100000000000136, 0.060000000000002274, 0.0799999999999983, 1.2609999999999957, 0.14000000000000057, 0.10000000000000853, 0.060000000000002274, 0.0, 0.14000000000000057, 0.5400000000000063, 0.3400000000000034, 0.20000000000000284, 1.5319999999999965, 0.09999999999999432, 0.06099999999999284, 0.060000000000002274, 0.14100000000000534, 0.9410000000000025, 0.0799999999999983, 0.0799999999999983, 0.12000000000000455, 0.0, 0.0799999999999983, 1.0009999999999906, 0.060000000000002274, 0.060000000000002274, 0.0799999999999983, 0.0799999999999983, 0.03999999999999204, 0.0799999999999983, 0.0799999999999983, 0.8810000000000002, 1.7019999999999982, 0.0, 0.060000000000002274, 0.03999999999999204, 0.060000000000002274, 0.0799999999999983, 0.9410000000000025, 0.1599999999999966, 0.060000000000002274, 0.09999999999999432, 0.09999999999999432, 0.6800000000000068, 0.22100000000000364, 0.04000000000000625, 0.060000000000002274, 0.6599999999999966, 0.060000000000002274, 0.11999999999999034, 0.14000000000000057, 0.06100000000000705, 8.11699999999999, 0.19999999999998863, 0.6199999999999903, 0.29999999999999716, 0.020000000000010232, 0.05999999999998806, 0.0799999999999983, 0.04000000000000625, 0.0, 2.021000000000001, 0.10000000000000853, 0.12000000000000455, 0.09999999999999432, 0.060000000000002274, 0.01999999999999602, 2.1809999999999974, 0.09999999999999432, 0.060000000000002274, 0.0, 0.12000000000000455, 0.01999999999999602, 0.9200000000000017, 0.9809999999999945, 0.28000000000000114, 0.18000000000000682, 0.2400000000000091, 0.020000000000010232, 0.03999999999999204, 0.12000000000000455, 0.0, 0.0800000000000125, 0.01999999999998181, 0.0800000000000125, 1.460000000000008, 0.07999999999998408, 0.1599999999999966, 0.0, 0.0800000000000125, 0.07999999999998408, 1.6099999999999852, 0.14000000000001478, 0.0800000000000125, 0.09999999999999432, 0.07999999999998408, 0.060000000000002274, 0.0, 3.062000000000012, 0.1799999999999784, 0.12000000000000455, 0.21999999999999886, 0.10000000000002274, 0.07999999999998408, 1.0009999999999764, 0.060000000000002274, 0.12000000000000455, 0.13999999999998636, 0.060000000000002274, 0.18000000000000682, 0.6200000000000045, 0.10000000000002274, 0.040000000000020464, 0.18000000000000682, 0.0800000000000125, 0.060000000000002274, 0.37999999999999545, 0.07999999999998408, 0.060000000000002274, 2.1619999999999777, 0.14000000000001478, 0.07999999999998408, 0.01999999999998181, 0.4199999999999875, 0.12000000000000455, 0.6200000000000045, 0.09999999999999432, 6.356999999999999, 0.03999999999999204, 0.14099999999999113]
val = [0.08000000000000007, 0.08000000000000007, 0.17999999999999972, 0.03999999999999915, 0.0,
0.0600000000000005, 0.0, 1.3010000000000002, 0.0600000000000005, 0.08000000000000007,
0.08000000000000007, 0.120000000000001, 0.019999999999999574, 0.08000000000000007, 1.6209999999999987,
0.0, 0.09999999999999787, 0.18100000000000094, 0.11999999999999744, 1.1210000000000022,
0.0799999999999983, 0.4209999999999994, 0.0, 0.0, 0.1999999999999993, 0.9000000000000021,
0.23999999999999844, 1.7409999999999997, 0.05999999999999872, 0.10000000000000142, 0.03999999999999915,
0.03999999999999915, 0.08000000000000185, 1.5809999999999995, 0.12000000000000455, 0.03999999999999915,
0.10000000000000142, 0.060000000000002274, 1.561, 0.05999999999999517, 0.01999999999999602,
0.09999999999999432, 0.05999999999999517, 0.03999999999999915, 0.0799999999999983, 0.5399999999999991,
0.5, 0.10000000000000142, 1.3810000000000002, 0.020000000000003126, 0.0799999999999983, 0.0,
0.1010000000000062, 0.060000000000002274, 1.561, 0.060000000000002274, 0.060000000000002274,
0.03999999999999915, 0.0, 0.03999999999999915, 0.14100000000000534, 1.061, 0.05999999999999517,
0.0799999999999983, 0.060000000000002274, 0.0, 0.04000000000000625, 0.10000000000000142,
2.182000000000002, 0.03999999999999915, 0.03999999999999915, 0.35999999999999943, 0.04000000000000625,
0.11999999999999744, 0.17999999999999972, 0.10000000000000142, 0.14000000000000057, 0.5600000000000023,
0.03999999999999915, 0.17999999999999972, 0.11999999999999744, 0.060000000000002274, 1.2809999999999988,
0.12000000000000455, 0.14000000000000057, 0.12000000000000455, 0.020000000000010232, 0.29999999999999716,
1.4810000000000088, 0.03999999999999204, 0.060000000000002274, 0.10000000000000853, 0.04000000000000625,
0.18000000000000682, 0.8400000000000034, 0.12000000000000455, 0.16100000000000136, 0.060000000000002274,
0.0799999999999983, 1.2609999999999957, 0.14000000000000057, 0.10000000000000853, 0.060000000000002274,
0.0, 0.14000000000000057, 0.5400000000000063, 0.3400000000000034, 0.20000000000000284,
1.5319999999999965, 0.09999999999999432, 0.06099999999999284, 0.060000000000002274, 0.14100000000000534,
0.9410000000000025, 0.0799999999999983, 0.0799999999999983, 0.12000000000000455, 0.0, 0.0799999999999983,
1.0009999999999906, 0.060000000000002274, 0.060000000000002274, 0.0799999999999983, 0.0799999999999983,
0.03999999999999204, 0.0799999999999983, 0.0799999999999983, 0.8810000000000002, 1.7019999999999982, 0.0,
0.060000000000002274, 0.03999999999999204, 0.060000000000002274, 0.0799999999999983, 0.9410000000000025,
0.1599999999999966, 0.060000000000002274, 0.09999999999999432, 0.09999999999999432, 0.6800000000000068,
0.22100000000000364, 0.04000000000000625, 0.060000000000002274, 0.6599999999999966, 0.060000000000002274,
0.11999999999999034, 0.14000000000000057, 0.06100000000000705, 8.11699999999999, 0.19999999999998863,
0.6199999999999903, 0.29999999999999716, 0.020000000000010232, 0.05999999999998806, 0.0799999999999983,
0.04000000000000625, 0.0, 2.021000000000001, 0.10000000000000853, 0.12000000000000455,
0.09999999999999432, 0.060000000000002274, 0.01999999999999602, 2.1809999999999974, 0.09999999999999432,
0.060000000000002274, 0.0, 0.12000000000000455, 0.01999999999999602, 0.9200000000000017,
0.9809999999999945, 0.28000000000000114, 0.18000000000000682, 0.2400000000000091, 0.020000000000010232,
0.03999999999999204, 0.12000000000000455, 0.0, 0.0800000000000125, 0.01999999999998181,
0.0800000000000125, 1.460000000000008, 0.07999999999998408, 0.1599999999999966, 0.0, 0.0800000000000125,
0.07999999999998408, 1.6099999999999852, 0.14000000000001478, 0.0800000000000125, 0.09999999999999432,
0.07999999999998408, 0.060000000000002274, 0.0, 3.062000000000012, 0.1799999999999784,
0.12000000000000455, 0.21999999999999886, 0.10000000000002274, 0.07999999999998408, 1.0009999999999764,
0.060000000000002274, 0.12000000000000455, 0.13999999999998636, 0.060000000000002274,
0.18000000000000682, 0.6200000000000045, 0.10000000000002274, 0.040000000000020464, 0.18000000000000682,
0.0800000000000125, 0.060000000000002274, 0.37999999999999545, 0.07999999999998408, 0.060000000000002274,
2.1619999999999777, 0.14000000000001478, 0.07999999999998408, 0.01999999999998181, 0.4199999999999875,
0.12000000000000455, 0.6200000000000045, 0.09999999999999432, 6.356999999999999, 0.03999999999999204,
0.14099999999999113]
# Act
result = deviation(val)
@@ -208,7 +345,75 @@ class TestCreateUltrastarTxt(unittest.TestCase):
def test_most_common_silent_part_kumr(self):
# Arrange
val = [0.16800000000000104, 0.019999999999999574, 0.019999999999999574, 0.0, 0.03999999999999915, 0.0, 0.0600000000000005, 0.040000000000000924, 0.5960000000000001, 0.03999999999999915, 0.0, 0.040000000000000924, 0.019999999999999574, 0.019999999999999574, 0.03999999999999915, 0.0, 0.019999999999999574, 0.0, 0.03999999999999915, 0.0, 0.05999999999999872, 0.0, 0.03999999999999915, 0.0, 0.019999999999999574, 0.0, 0.0, 0.0, 0.019999999999999574, 0.019999999999999574, 0.0400000000000027, 0.0, 0.03999999999999915, 0.0, 0.0400000000000027, 0.10899999999999821, 0.019999999999999574, 0.019999999999999574, 0.14700000000000202, 0.0, 0.0, 0.019999999999999574, 0.020000000000003126, 0.03999999999999915, 0.3069999999999986, 0.0400000000000027, 0.03999999999999915, 0.0400000000000027, 0.13100000000000023, 0.03999999999999915, 0.03999999999999915, 0.0, 0.0, 0.019999999999999574, 0.09299999999999997, 0.3719999999999999, 0.03999999999999915, 0.0400000000000027, 0.0, 0.10400000000000276, 0.019999999999999574, 0.0400000000000027, 0.0, 0.03999999999999915, 0.0, 0.05999999999999872, 0.0, 0.0400000000000027, 0.0, 0.03999999999999915, 0.03999999999999915, 0.0, 0.0, 0.0, 0.03999999999999915, 0.11199999999999832, 0.03999999999999915, 0.019999999999999574, 0.0400000000000027, 0.0, 0.0, 0.0, 0.060000000000002274, 0.1600000000000037, 0.03999999999999915, 0.0, 0.21699999999999875, 0.0, 0.03999999999999915, 0.03999999999999915, 0.05999999999999517, 0.020000000000003126, 0.01999999999999602, 0.03999999999999915, 0.0, 0.03999999999999915, 0.0800000000000054, 0.19200000000000017, 0.01999999999999602, 0.03999999999999915, 0.0, 0.03999999999999915, 0.0, 0.03999999999999915, 0.03999999999999915, 0.020000000000003126, 0.0, 0.03999999999999915, 0.0, 0.04000000000000625, 1.9950000000000045, 0.03999999999999915, 0.03999999999999915, 0.0, 0.03999999999999915, 0.0, 0.021000000000000796, 0.0, 0.45700000000000074, 0.03999999999999915, 0.0, 0.03999999999999915, 0.020000000000003126, 0.03999999999999915, 0.0, 0.060000000000002274, 0.03999999999999915, 0.03999999999999915, 0.0, 0.03999999999999915, 0.03999999999999915, 0.03999999999999915, 0.03999999999999915, 0.060000000000002274, 0.020000000000003126, 0.020000000000003126, 0.0, 0.01999999999999602, 0.05999999999999517, 0.0, 0.2959999999999994, 0.04000000000000625, 0.04000000000000625, 0.01999999999999602, 0.03999999999999915, 0.0, 0.0, 0.03999999999999915, 0.03999999999999915, 0.0, 0.060000000000002274, 0.0, 0.03999999999999915, 0.01999999999999602, 1.8879999999999981, 0.03999999999999915, 0.0, 0.03999999999999915, 0.03999999999999915, 0.03999999999999915, 0.03999999999999915, 0.03999999999999915, 0.05999999999999517, 0.10000000000000142, 0.09999999999999432, 0.060000000000002274, 0.060000000000002274, 0.0, 0.05999999999999517, 0.1630000000000038, 1.509999999999998, 0.03999999999999915, 0.0, 0.04000000000000625, 0.03999999999999915, 0.0, 0.26899999999999835, 0.03999999999999915, 0.0, 0.0, 0.04000000000000625, 0.0, 0.060000000000002274, 0.060000000000002274, 0.0, 0.060000000000002274, 0.03999999999999204, 1.7930000000000064, 0.04099999999999682, 0.0, 0.04099999999999682, 0.06099999999999284, 0.03999999999999204, 0.0, 0.04000000000000625, 0.04000000000000625, 0.03999999999999204, 0.020000000000010232, 0.04099999999999682, 0.04000000000000625, 0.0, 0.04099999999999682, 0.060000000000002274, 0.0, 0.03999999999999204, 0.03999999999999204, 1.5649999999999977, 0.01999999999999602, 0.04000000000000625, 0.04000000000000625, 0.03999999999999204, 0.04000000000000625, 0.05999999999998806, 0.06100000000000705, 0.0, 0.060000000000002274, 0.060000000000002274, 28.479, 0.03999999999999204, 0.04000000000000625, 0.0, 0.04000000000000625, 0.0, 0.03999999999999204, 0.0, 0.0, 0.060000000000002274, 0.0, 0.03999999999999204, 0.03999999999999204, 0.03999999999999204, 0.0, 0.03999999999999204, 0.04000000000000625, 0.04000000000000625, 0.0, 0.03999999999999204, 0.03999999999999204, 0.03999999999999204, 0.04000000000000625, 0.04099999999999682, 0.01999999999999602, 0.01999999999999602, 0.0, 0.01999999999999602, 0.05999999999998806, 0.0, 0.0, 0.03999999999999204, 0.04000000000000625, 0.01999999999999602, 0.12000000000000455, 0.01999999999999602, 0.04000000000000625, 0.04000000000000625, 0.03999999999999204, 0.0, 0.0, 0.04000000000000625, 0.04000000000000625, 0.0, 10.948999999999998, 0.0, 0.040000000000020464, 0.020000000000010232, 2.0900000000000034, 0.03999999999999204, 0.0, 0.020000000000010232, 0.03999999999999204, 0.03999999999999204, 0.01999999999998181, 0.040000000000020464, 0.060000000000002274, 0.09999999999999432, 0.020000000000010232, 0.0800000000000125, 0.03999999999999204, 0.0, 0.03999999999999204, 0.01999999999998181, 1.5370000000000061, 0.040000000000020464, 0.0, 0.03999999999999204, 0.060000000000002274, 0.0, 0.03999999999999204, 0.040000000000020464, 0.0, 0.0, 0.020000000000010232, 0.0, 0.0800000000000125, 0.03999999999999204, 0.0, 0.03999999999999204, 0.040000000000020464, 0.7199999999999989, 0.14599999Line truncated
val = [0.16800000000000104, 0.019999999999999574, 0.019999999999999574, 0.0, 0.03999999999999915, 0.0,
0.0600000000000005, 0.040000000000000924, 0.5960000000000001, 0.03999999999999915, 0.0,
0.040000000000000924, 0.019999999999999574, 0.019999999999999574, 0.03999999999999915, 0.0,
0.019999999999999574, 0.0, 0.03999999999999915, 0.0, 0.05999999999999872, 0.0, 0.03999999999999915, 0.0,
0.019999999999999574, 0.0, 0.0, 0.0, 0.019999999999999574, 0.019999999999999574, 0.0400000000000027, 0.0,
0.03999999999999915, 0.0, 0.0400000000000027, 0.10899999999999821, 0.019999999999999574,
0.019999999999999574, 0.14700000000000202, 0.0, 0.0, 0.019999999999999574, 0.020000000000003126,
0.03999999999999915, 0.3069999999999986, 0.0400000000000027, 0.03999999999999915, 0.0400000000000027,
0.13100000000000023, 0.03999999999999915, 0.03999999999999915, 0.0, 0.0, 0.019999999999999574,
0.09299999999999997, 0.3719999999999999, 0.03999999999999915, 0.0400000000000027, 0.0,
0.10400000000000276, 0.019999999999999574, 0.0400000000000027, 0.0, 0.03999999999999915, 0.0,
0.05999999999999872, 0.0, 0.0400000000000027, 0.0, 0.03999999999999915, 0.03999999999999915, 0.0, 0.0,
0.0, 0.03999999999999915, 0.11199999999999832, 0.03999999999999915, 0.019999999999999574,
0.0400000000000027, 0.0, 0.0, 0.0, 0.060000000000002274, 0.1600000000000037, 0.03999999999999915, 0.0,
0.21699999999999875, 0.0, 0.03999999999999915, 0.03999999999999915, 0.05999999999999517,
0.020000000000003126, 0.01999999999999602, 0.03999999999999915, 0.0, 0.03999999999999915,
0.0800000000000054, 0.19200000000000017, 0.01999999999999602, 0.03999999999999915, 0.0,
0.03999999999999915, 0.0, 0.03999999999999915, 0.03999999999999915, 0.020000000000003126, 0.0,
0.03999999999999915, 0.0, 0.04000000000000625, 1.9950000000000045, 0.03999999999999915,
0.03999999999999915, 0.0, 0.03999999999999915, 0.0, 0.021000000000000796, 0.0, 0.45700000000000074,
0.03999999999999915, 0.0, 0.03999999999999915, 0.020000000000003126, 0.03999999999999915, 0.0,
0.060000000000002274, 0.03999999999999915, 0.03999999999999915, 0.0, 0.03999999999999915,
0.03999999999999915, 0.03999999999999915, 0.03999999999999915, 0.060000000000002274,
0.020000000000003126, 0.020000000000003126, 0.0, 0.01999999999999602, 0.05999999999999517, 0.0,
0.2959999999999994, 0.04000000000000625, 0.04000000000000625, 0.01999999999999602, 0.03999999999999915,
0.0, 0.0, 0.03999999999999915, 0.03999999999999915, 0.0, 0.060000000000002274, 0.0, 0.03999999999999915,
0.01999999999999602, 1.8879999999999981, 0.03999999999999915, 0.0, 0.03999999999999915,
0.03999999999999915, 0.03999999999999915, 0.03999999999999915, 0.03999999999999915, 0.05999999999999517,
0.10000000000000142, 0.09999999999999432, 0.060000000000002274, 0.060000000000002274, 0.0,
0.05999999999999517, 0.1630000000000038, 1.509999999999998, 0.03999999999999915, 0.0,
0.04000000000000625, 0.03999999999999915, 0.0, 0.26899999999999835, 0.03999999999999915, 0.0, 0.0,
0.04000000000000625, 0.0, 0.060000000000002274, 0.060000000000002274, 0.0, 0.060000000000002274,
0.03999999999999204, 1.7930000000000064, 0.04099999999999682, 0.0, 0.04099999999999682,
0.06099999999999284, 0.03999999999999204, 0.0, 0.04000000000000625, 0.04000000000000625,
0.03999999999999204, 0.020000000000010232, 0.04099999999999682, 0.04000000000000625, 0.0,
0.04099999999999682, 0.060000000000002274, 0.0, 0.03999999999999204, 0.03999999999999204,
1.5649999999999977, 0.01999999999999602, 0.04000000000000625, 0.04000000000000625, 0.03999999999999204,
0.04000000000000625, 0.05999999999998806, 0.06100000000000705, 0.0, 0.060000000000002274,
0.060000000000002274, 28.479, 0.03999999999999204, 0.04000000000000625, 0.0, 0.04000000000000625, 0.0,
0.03999999999999204, 0.0, 0.0, 0.060000000000002274, 0.0, 0.03999999999999204, 0.03999999999999204,
0.03999999999999204, 0.0, 0.03999999999999204, 0.04000000000000625, 0.04000000000000625, 0.0,
0.03999999999999204, 0.03999999999999204, 0.03999999999999204, 0.04000000000000625, 0.04099999999999682,
0.01999999999999602, 0.01999999999999602, 0.0, 0.01999999999999602, 0.05999999999998806, 0.0, 0.0,
0.03999999999999204, 0.04000000000000625, 0.01999999999999602, 0.12000000000000455, 0.01999999999999602,
0.04000000000000625, 0.04000000000000625, 0.03999999999999204, 0.0, 0.0, 0.04000000000000625,
0.04000000000000625, 0.0, 10.948999999999998, 0.0, 0.040000000000020464, 0.020000000000010232,
2.0900000000000034, 0.03999999999999204, 0.0, 0.020000000000010232, 0.03999999999999204,
0.03999999999999204, 0.01999999999998181, 0.040000000000020464, 0.060000000000002274,
0.09999999999999432, 0.020000000000010232, 0.0800000000000125, 0.03999999999999204, 0.0,
0.03999999999999204, 0.01999999999998181, 1.5370000000000061, 0.040000000000020464, 0.0,
0.03999999999999204, 0.060000000000002274, 0.0, 0.03999999999999204, 0.040000000000020464, 0.0, 0.0,
0.020000000000010232, 0.0, 0.0800000000000125, 0.03999999999999204, 0.0, 0.03999999999999204,
0.040000000000020464, 0.7199999999999989, 0.14599999999998658, 0.040000000000020464, 0.0,
0.03999999999999204, 0.060000000000002274, 0.03999999999999204, 0.0, 0.03999999999999204,
0.03999999999999204, 0.03999999999999204, 0.020000000000010232, 0.05999999999997385,
0.040000000000020464, 0.0, 0.060000000000002274, 0.020000000000010232, 0.0, 0.01999999999998181,
0.01999999999998181, 1.1400000000000148, 0.21199999999998909, 0.040000000000020464, 0.03999999999999204,
0.03999999999999204, 0.0, 0.060000000000002274, 0.060000000000002274, 0.06099999999997863, 0.0,
0.040000000000020464, 0.01999999999998181, 0.040000000000020464, 0.0, 0.060000000000002274,
0.060000000000002274, 5.156000000000006, 0.0, 0.020000000000010232, 0.020000000000010232,
0.020000000000010232, 0.060000000000002274, 0.0, 0.040000000000020464, 0.040000000000020464,
0.05999999999997385, 0.0, 0.060000000000002274, 0.03999999999999204, 0.020000000000010232,
0.020000000000010232, 0.0, 0.040000000000020464, 0.060000000000002274, 0.040000000000020464, 0.0,
0.03999999999999204, 0.03999999999999204, 0.060000000000002274, 0.020000000000010232,
0.060000000000002274, 0.040000000000020464, 0.0, 0.03999999999999204, 0.060000000000002274, 0.0,
0.060000000000002274, 0.040000000000020464, 0.25499999999999545, 0.03999999999999204,
0.020000000000010232, 0.01999999999998181, 0.0, 0.060000000000002274, 0.060000000000002274,
0.060000000000002274, 0.0, 0.05999999999997385, 0.040000000000020464, 0.060000000000002274, 0.0,
0.060000000000002274, 0.01999999999998181]
# Act
result = deviation(val)
@@ -217,5 +422,13 @@ class TestCreateUltrastarTxt(unittest.TestCase):
self.assertGreaterEqual(result, 0.11)
self.assertLessEqual(result, 0.168)
def test_format_separated_string(self):
self.assertEqual(format_separated_string('rock,pop,rock-pop,'), 'Rock, Pop, Rock-Pop')
self.assertEqual(format_separated_string('rock;pop;rock-pop,'), 'Rock, Pop, Rock-Pop')
self.assertEqual(format_separated_string('rock/pop/rock-pop,'), 'Rock, Pop, Rock-Pop')
self.assertEqual(format_separated_string('rock,pop/rock-pop;80s,'), 'Rock, Pop, Rock-Pop, 80s')
self.assertEqual(format_separated_string('rock, pop, rock-pop, '), 'Rock, Pop, Rock-Pop')
if __name__ == "__main__":
unittest.main()
unittest.main()
-58
View File
@@ -1,58 +0,0 @@
"""Tests for UltraSinger.py"""
import unittest
import os
from unittest.mock import patch, MagicMock
from modules.Ultrastar.ultrastar_writer import format_separated_string
from modules.Ultrastar.ultrastar_parser import parse_ultrastar_txt
from src import UltraSinger
class TestUltraSinger(unittest.TestCase):
def test_format_separated_string(self):
self.assertEqual(format_separated_string('rock,pop,rock-pop,'), 'Rock, Pop, Rock-Pop')
self.assertEqual(format_separated_string('rock;pop;rock-pop,'), 'Rock, Pop, Rock-Pop')
self.assertEqual(format_separated_string('rock/pop/rock-pop,'), 'Rock, Pop, Rock-Pop')
self.assertEqual(format_separated_string('rock,pop/rock-pop;80s,'), 'Rock, Pop, Rock-Pop, 80s')
self.assertEqual(format_separated_string('rock, pop, rock-pop, '), 'Rock, Pop, Rock-Pop')
def test_extract_year(self):
years = {__extract_year("2023-12-31"), __extract_year("2023-12-31 23:59:59"), __extract_year("2023/12/31"),
__extract_year("2023\\12\\31"), __extract_year("2023.12.31"), __extract_year("2023 12 31"),
__extract_year("12-31-2023"), __extract_year("12/31/2023"), __extract_year("12\\31\\2023"),
__extract_year("12.31.2023"), __extract_year("12 31 2023"), __extract_year("12-2023"),
__extract_year("12/2023"), __extract_year("2023")}
for year in years:
self.assertEqual(year, "2023")
@patch("src.UltraSinger.ultrastar_parser.parse_ultrastar_txt")
@patch("src.UltraSinger.ultrastar_converter.ultrastar_bpm_to_real_bpm")
@patch("src.UltraSinger.os.path.dirname")
@patch("src.UltraSinger.os_helper.create_folder")
def test_parse_ultrastar_txt(self, mock_create_folder,
mock_dirname, mock_ultrastar_bpm_to_real_bpm,
mock_parse_ultrastar_txt):
# Arrange
mock_parse_ultrastar_txt.return_value = MagicMock(mp3="test.mp3",
artist=" Test Artist ", # Also test leading and trailing whitespaces
title=" Test Title ") # Also test leading and trailing whitespaces
mock_ultrastar_bpm_to_real_bpm.return_value = 120.0
mock_dirname.return_value = os.path.join("path", "to", "input")
UltraSinger.Settings.output_file_path = os.path.join("path", "to", "output")
mock_create_folder.return_value = None
# Act
result = parse_ultrastar_txt()
# Assert
self.assertEqual(result, ("Test Artist - Test Title",
120.0,
os.path.join("path", "to", "output", "Test Artist - Test Title"),
os.path.join("path", "to", "input", "test.mp3"),
mock_parse_ultrastar_txt.return_value))
mock_parse_ultrastar_txt.assert_called_once()
mock_ultrastar_bpm_to_real_bpm.assert_called_once()
mock_dirname.assert_called_once()
mock_create_folder.assert_called_once()
@@ -1,5 +1,4 @@
"""Ultrastar Converter"""
import re
from modules.Ultrastar.ultrastar_txt import UltrastarTxtValue
@@ -98,14 +97,3 @@ def __convert_gap(gap: str) -> float:
def __convert_bpm(ultrastar_bpm: str) -> float:
real_bpm = ultrastar_bpm_to_real_bpm(float(ultrastar_bpm.replace(",", ".")))
return real_bpm
# Todo: Isnt it MusicBrainz? + Sanitize when parsing UltraStar?
def __extract_year(date: str) -> str:
match = re.search(r'\b\d{4}\b', date)
if match:
return match.group(0)
else:
return date
@@ -1,11 +1,12 @@
import os
import re
from packaging import version
from modules import os_helper
from modules.Midi.MidiSegment import MidiSegment
from modules.ProcessData import ProcessData, MediaInfo
from modules.Ultrastar.coverter.ultrastar_converter import ultrastar_bpm_to_real_bpm, __extract_year
from modules.Ultrastar.coverter.ultrastar_converter import ultrastar_bpm_to_real_bpm
from modules.Ultrastar.coverter.ultrastar_midi_converter import ultrastar_to_midi_segments, \
convert_midi_notes_to_ultrastar_notes
from modules.Ultrastar.ultrastar_txt import UltrastarTxtValue, FormatVersion
@@ -82,7 +83,7 @@ def create_ultrastar_txt_from_automation(
ultrastar_txt.title = media_info.title
ultrastar_txt.artist = media_info.artist
if media_info.year is not None:
ultrastar_txt.year = __extract_year(media_info.year)
ultrastar_txt.year = extract_year(media_info.year)
if media_info.genre is not None:
ultrastar_txt.genre = format_separated_string(media_info.genre)
@@ -106,3 +107,12 @@ def create_ultrastar_txt_from_automation(
media_info.bpm,
)
return ultrastar_file_output_path
# Todo: Isnt it MusicBrainz? + Sanitize when parsing UltraStar?
def extract_year(date: str) -> str:
match = re.search(r'\b\d{4}\b', date)
if match:
return match.group(0)
else:
return date