# Path: praatio/klattgrid.py
# def openKlattgrid(fnFullPath: str) -> Klattgrid:
# def wavToKlattgrid(
#     praatEXE: str,
#     inputFullPath: str,
#     outputFullPath: str,
#     timeStep: float = 0.005,
#     numFormants: int = 5,
#     maxFormantFreq: float = 5500.0,
#     windowLength: float = 0.025,
#     preEmphasis: float = 50.0,
#     pitchFloor: float = 60.0,
#     pitchCeiling: float = 600.0,
#     minPitch: float = 50.0,
#     subtractMean: bool = True,
#     scriptFN: Optional[str] = None,
# ) -> None:
# def resynthesize(
#     praatEXE: str,
#     wavFN: str,
#     klattFN: str,
#     outputWavFN: str,
#     doCascade: bool = True,
#     scriptFN: Optional[str] = None,
# ) -> None:
# def _openNormalKlattgrid(data: str) -> Klattgrid:
# def _proccessContainerTierInput(sectionData: str, name: str):
# def _findIndicies(data, keyword):
# def _getSectionHeader(data, indexList, i):
# def _buildEntryList(sectionTuple):
# def _processSectionData(sectionData: str) -> List[Tuple[float, float]]:
# 
# Path: tests/testing_utils.py
# def areTheSameFiles(fn1, fn2, fileHandler, *args):
#     """
#     Tests that files contain the same data
# 
#     If fileHandler is a textgrid file reader like
#     textgrid.openTextgrid then we can compare
#     a shortTextgrid and a longTextgrid.
# 
#     If fileHandler is readFile or io.open, etc then the raw
#     text will be compared.
#     """
#     data1 = fileHandler(fn1, *args)
#     data2 = fileHandler(fn2, *args)
# 
#     return data1 == data2
# 
# Path: tests/praatio_test_case.py
# class PraatioTestCase(unittest.TestCase):
#     def __init__(self, *args, **kargs):
#         super(PraatioTestCase, self).__init__(*args, **kargs)
# 
#         root = os.path.dirname(os.path.realpath(__file__))
#         self.dataRoot = os.path.join(root, "files")
#         self.outputRoot = os.path.join(self.dataRoot, "test_output")
# 
#     def setUp(self):
#         if not os.path.exists(self.outputRoot):
#             os.mkdir(self.outputRoot)
# 
#     def assertAllAlmostEqual(self, listA, listB):
#         for valA, valB in zip(listA, listB):
#             self.assertAlmostEqual(valA, valB)


import unittest
from os.path import join
from praatio import klattgrid
from tests.testing_utils import areTheSameFiles
from tests.praatio_test_case import PraatioTestCase




class TestKlattgrid(PraatioTestCase):
    def test_reading_and_writing_klattgrids_does_not_mutate_file(self):
        """Tests for reading/writing klattgrids"""
        fn = "bobby.KlattGrid"
        inputFN = join(self.dataRoot, fn)
        outputFN = join(self.outputRoot, fn)

        kg = klattgrid.openKlattgrid(inputFN)
        kg.save(outputFN)


# Path: praatio/klattgrid.py
# def openKlattgrid(fnFullPath: str) -> Klattgrid:
# def wavToKlattgrid(
#     praatEXE: str,
#     inputFullPath: str,
#     outputFullPath: str,
#     timeStep: float = 0.005,
#     numFormants: int = 5,
#     maxFormantFreq: float = 5500.0,
#     windowLength: float = 0.025,
#     preEmphasis: float = 50.0,
#     pitchFloor: float = 60.0,
#     pitchCeiling: float = 600.0,
#     minPitch: float = 50.0,
#     subtractMean: bool = True,
#     scriptFN: Optional[str] = None,
# ) -> None:
# def resynthesize(
#     praatEXE: str,
#     wavFN: str,
#     klattFN: str,
#     outputWavFN: str,
#     doCascade: bool = True,
#     scriptFN: Optional[str] = None,
# ) -> None:
# def _openNormalKlattgrid(data: str) -> Klattgrid:
# def _proccessContainerTierInput(sectionData: str, name: str):
# def _findIndicies(data, keyword):
# def _getSectionHeader(data, indexList, i):
# def _buildEntryList(sectionTuple):
# def _processSectionData(sectionData: str) -> List[Tuple[float, float]]:
# 
# Path: tests/testing_utils.py
# def areTheSameFiles(fn1, fn2, fileHandler, *args):
#     """
#     Tests that files contain the same data
# 
#     If fileHandler is a textgrid file reader like
#     textgrid.openTextgrid then we can compare
#     a shortTextgrid and a longTextgrid.
# 
#     If fileHandler is readFile or io.open, etc then the raw
#     text will be compared.
#     """
#     data1 = fileHandler(fn1, *args)
#     data2 = fileHandler(fn2, *args)
# 
#     return data1 == data2
# 
# Path: tests/praatio_test_case.py
# class PraatioTestCase(unittest.TestCase):
#     def __init__(self, *args, **kargs):
#         super(PraatioTestCase, self).__init__(*args, **kargs)
# 
#         root = os.path.dirname(os.path.realpath(__file__))
#         self.dataRoot = os.path.join(root, "files")
#         self.outputRoot = os.path.join(self.dataRoot, "test_output")
# 
#     def setUp(self):
#         if not os.path.exists(self.outputRoot):
#             os.mkdir(self.outputRoot)
# 
#     def assertAllAlmostEqual(self, listA, listB):
#         for valA, valB in zip(listA, listB):
#             self.assertAlmostEqual(valA, valB)


# Path: tests/test_klattgrid.py
import unittest
from os.path import join
from praatio import klattgrid
from tests.testing_utils import areTheSameFiles
from tests.praatio_test_case import PraatioTestCase





class TestKlattgrid(PraatioTestCase):
    def test_reading_and_writing_klattgrids_does_not_mutate_file(self):
        """Tests for reading/writing klattgrids"""
        fn = "bobby.KlattGrid"
        inputFN = join(self.dataRoot, fn)
        outputFN = join(self.outputRoot, fn)

        kg = klattgrid.openKlattgrid(inputFN)
        kg.save(outputFN)


        self.assertTrue(areTheSameFiles(inputFN, outputFN, klattgrid.openKlattgrid))