

"""simple docstring"""



import unittest

from cer import CER


SCREAMING_SNAKE_CASE_       :						str					=    CER()



class        a    (							unittest.TestCase					):



    """simple docstring"""



    def 					UpperCamelCase						(  self:			List[str]							):






         """simple docstring"""


         A__				      =	["""White House"""]
         A__				      =	["""white house"""]
         # S = 2, D = 0, I = 0, N = 11, CER = 2 / 11
         A__				      =	cer.compute(predictions=UpperCamelCase     ,    references=UpperCamelCase							)
         self.assertTrue(abs(char_error_rate - 0.1_818_181_818							) < 1e-6							)

    def 					UpperCamelCase						(  self:			str							):






         """simple docstring"""


         A__				      =	["""were wolf"""]
         A__				      =	["""werewolf"""]
         # S = 0, D = 0, I = 1, N = 9, CER = 1 / 9
         A__				      =	cer.compute(predictions=UpperCamelCase     ,    references=UpperCamelCase							)
         self.assertTrue(abs(char_error_rate - 0.1_111_111							) < 1e-6							)

         A__				      =	["""werewolf"""]
         A__				      =	["""weae     wolf"""]
         # S = 1, D = 1, I = 0, N = 8, CER = 0.25
         A__				      =	cer.compute(predictions=UpperCamelCase     ,    references=UpperCamelCase							)
         self.assertTrue(abs(char_error_rate - 0.25							) < 1e-6							)

         # consecutive whitespaces case 1
         A__				      =	["""were wolf"""]
         A__				      =	["""were               wolf"""]
         # S = 0, D = 0, I = 0, N = 9, CER = 0
         A__				      =	cer.compute(predictions=UpperCamelCase     ,    references=UpperCamelCase							)
         self.assertTrue(abs(char_error_rate - 0.0							) < 1e-6							)

         # consecutive whitespaces case 2
         A__				      =	["""were   wolf"""]
         A__				      =	["""were               wolf"""]
         # S = 0, D = 0, I = 0, N = 9, CER = 0
         A__				      =	cer.compute(predictions=UpperCamelCase     ,    references=UpperCamelCase							)
         self.assertTrue(abs(char_error_rate - 0.0							) < 1e-6							)

    def 					UpperCamelCase						(  self:			str							):






         """simple docstring"""


         A__				      =	["""werewolf"""]
         A__				      =	["""weaewolf"""]
         # S = 1, D = 0, I = 0, N = 8, CER = 0.125
         A__				      =	cer.compute(predictions=UpperCamelCase     ,    references=UpperCamelCase							)
         self.assertTrue(abs(char_error_rate - 0.125							) < 1e-6							)

    def 					UpperCamelCase						(  self:			int							):






         """simple docstring"""


         A__				      =	["""werewolf"""]
         A__				      =	["""wereawolf"""]
         # S = 0, D = 1, I = 0, N = 8, CER = 0.125
         A__				      =	cer.compute(predictions=UpperCamelCase     ,    references=UpperCamelCase							)
         self.assertTrue(abs(char_error_rate - 0.125							) < 1e-6							)

    def 					UpperCamelCase						(  self:			Tuple							):






         """simple docstring"""


         A__				      =	["""werewolf"""]
         A__				      =	["""wereolf"""]
         # S = 0, D = 0, I = 1, N = 8, CER = 0.125
         A__				      =	cer.compute(predictions=UpperCamelCase     ,    references=UpperCamelCase							)
         self.assertTrue(abs(char_error_rate - 0.125							) < 1e-6							)

    def 					UpperCamelCase						(  self:			int							):






         """simple docstring"""


         A__				      =	["""werewolf"""]
         A__				      =	cer.compute(predictions=UpperCamelCase     ,    references=UpperCamelCase							)
         self.assertEqual(UpperCamelCase     ,    0.0							)

    def 					UpperCamelCase						(  self:			Tuple							):






         """simple docstring"""


         A__				      =	["""werewolf""", """I am your father"""]
         A__				      =	cer.compute(predictions=UpperCamelCase     ,    references=UpperCamelCase							)
         self.assertEqual(UpperCamelCase     ,    0.0							)

         A__				      =	["""werewolf""", """I am your father""", """doge"""]
         A__				      =	["""werxwolf""", """I       am your father""", """doge"""]
         # S = 1, D = 0, I = 0, N = 28, CER = 1 / 28
         A__				      =	cer.compute(predictions=UpperCamelCase     ,    references=UpperCamelCase							)
         self.assertTrue(abs(char_error_rate - 0.03_571_428							) < 1e-6							)

    def 					UpperCamelCase						(  self:			Dict							):






         """simple docstring"""


         A__				      =	["""My hovercraft""", """is full of eels"""]
         A__				      =	["""My hovercraft is full""", """ of eels"""]
         # S = 0, D = 0, I = 2, N = 28, CER = 2 / 28
         # whitespace at the front of " of eels" will be strip during preporcessing
         # so need to insert 2 whitespaces
         A__				      =	cer.compute(predictions=UpperCamelCase     ,    references=UpperCamelCase     ,    concatenate_texts=UpperCamelCase							)
         self.assertTrue(abs(char_error_rate - 0.071_428							) < 1e-6							)

    def 					UpperCamelCase						(  self:			Tuple							):






         """simple docstring"""


         A__				      =	["""我能吞下玻璃而不伤身体"""]
         A__				      =	[""" 能吞虾玻璃而 不霜身体啦"""]
         # S = 3, D = 2, I = 0, N = 11, CER = 5 / 11
         A__				      =	cer.compute(predictions=UpperCamelCase     ,    references=UpperCamelCase							)
         self.assertTrue(abs(char_error_rate - 0.4_545_454_545							) < 1e-6							)

         A__				      =	["""我能吞下玻璃""", """而不伤身体"""]
         A__				      =	["""我    能 吞 下 玻 璃""", """而不伤身体"""]
         # S = 0, D = 5, I = 0, N = 11, CER = 5 / 11
         A__				      =	cer.compute(predictions=UpperCamelCase     ,    references=UpperCamelCase							)
         self.assertTrue(abs(char_error_rate - 0.454_545_454_545							) < 1e-6							)

         A__				      =	["""我能吞下玻璃而不伤身体"""]
         A__				      =	cer.compute(predictions=UpperCamelCase     ,    references=UpperCamelCase							)
         self.assertFalse(UpperCamelCase     ,    0.0							)





    def 					UpperCamelCase						(  self:			List[str]							):






         """simple docstring"""


         A__				      =	[""""""]
         A__				      =	["""Hypothesis"""]
         with self.assertRaises(UpperCamelCase							):
              cer.compute(predictions=UpperCamelCase     ,    references=UpperCamelCase							)


if __name__ == "__main__":
 unittest.main()









import unittest

from diffusers import __version__
from diffusers.utils import deprecate







class 					__lowerCamelCase							(      unittest.TestCase      ):
      lowerCamelCase_      : Dict  			=   '.'.join([str(int(__version__.split('.'      )[0]      ) + 1      )] + __version__.split('.'      )[1:]      )
      lowerCamelCase_      : int  			=   '0.0.1'







      def       lowerCAmelCase_       (	self  )		->			Optional[int]:
        snake_case_					= {"""deprecated_arg""": 4}

        with self.assertWarns(lowerCamelCase  ) as warning:
          snake_case_					= deprecate("""deprecated_arg"""				,    self.higher_version				,    """message"""				,    take_from=lowerCamelCase  )

        assert output == 4
        assert (
            str(warning.warning  )
            == f'''The `deprecated_arg` argument is deprecated and will be removed in version {self.higher_version}.'''
            " message"
        )







      def       lowerCAmelCase_       (	self  )		->			List[Any]:
        snake_case_					= {"""deprecated_arg""": 4}

        with self.assertWarns(lowerCamelCase  ) as warning:
          snake_case_					= deprecate(("""deprecated_arg""", self.higher_version, """message""")				,    take_from=lowerCamelCase  )

        assert output == 4
        assert (
            str(warning.warning  )
            == f'''The `deprecated_arg` argument is deprecated and will be removed in version {self.higher_version}.'''
            " message"
        )







      def       lowerCAmelCase_       (	self  )		->			int:
        snake_case_					= {"""deprecated_arg_1""": 4, """deprecated_arg_2""": 8}
        with self.assertWarns(lowerCamelCase  ) as warning:
          snake_case_		,							snake_case_					= deprecate(
              ("""deprecated_arg_1""", self.higher_version, """Hey""")				,    ("""deprecated_arg_2""", self.higher_version, """Hey""")				,    take_from=lowerCamelCase				,    )
        assert output_a == 4
        assert output_a == 8
        assert (
            str(warning.warnings[0].message  )
            == "The `deprecated_arg_1` argument is deprecated and will be removed in version"
            f''' {self.higher_version}. Hey'''
        )
        assert (
            str(warning.warnings[1].message  )
            == "The `deprecated_arg_2` argument is deprecated and will be removed in version"
            f''' {self.higher_version}. Hey'''
        )







      def       lowerCAmelCase_       (	self  )		->			Any:
        snake_case_					= {"""deprecated_arg""": 4}

        with self.assertRaises(lowerCamelCase  ) as error:
          deprecate(("""wrong_arg""", self.higher_version, """message""")				,    take_from=lowerCamelCase  )

        assert "test_deprecate_function_incorrect_arg in" in str(error.exception  )
        assert "line" in str(error.exception  )
        assert "got an unexpected keyword argument `deprecated_arg`" in str(error.exception  )







      def       lowerCAmelCase_       (	self  )		->			Optional[Any]:
        with self.assertWarns(lowerCamelCase  ) as warning:
          deprecate(("""deprecated_arg""", self.higher_version, """message""")  )

        assert (
            str(warning.warning  )
            == f'''`deprecated_arg` is deprecated and will be removed in version {self.higher_version}. message'''
        )







      def       lowerCAmelCase_       (	self  )		->			Any:
        with self.assertWarns(lowerCamelCase  ) as warning:
          deprecate(
              ("""deprecated_arg_1""", self.higher_version, """Hey""")				,    ("""deprecated_arg_2""", self.higher_version, """Hey""")				,    )
        assert (
            str(warning.warnings[0].message  )
            == f'''`deprecated_arg_1` is deprecated and will be removed in version {self.higher_version}. Hey'''
        )
        assert (
            str(warning.warnings[1].message  )
            == f'''`deprecated_arg_2` is deprecated and will be removed in version {self.higher_version}. Hey'''
        )







      def       lowerCAmelCase_       (	self  )		->			Any:







        class 					__lowerCamelCase							:
              lowerCamelCase_      : Dict  			=   5

        with self.assertWarns(lowerCamelCase  ) as warning:
          snake_case_					= deprecate(("""arg""", self.higher_version, """message""")				,    take_from=Args()  )

        assert arg == 5
        assert (
            str(warning.warning  )
            == f'''The `arg` attribute is deprecated and will be removed in version {self.higher_version}. message'''
        )







      def       lowerCAmelCase_       (	self  )		->			Any:







        class 					__lowerCamelCase							:
              lowerCamelCase_      : str  			=   5
              lowerCamelCase_      : List[str]  			=   7

        with self.assertWarns(lowerCamelCase  ) as warning:
          snake_case_		,							snake_case_					= deprecate(
              ("""arg""", self.higher_version, """message""")				,    ("""foo""", self.higher_version, """message""")				,    ("""does not exist""", self.higher_version, """message""")				,    take_from=Args()				,    )

        assert arg_a == 5
        assert arg_a == 7
        assert (
            str(warning.warning  )
            == f'''The `arg` attribute is deprecated and will be removed in version {self.higher_version}. message'''
        )
        assert (
            str(warning.warnings[0].message  )
            == f'''The `arg` attribute is deprecated and will be removed in version {self.higher_version}. message'''
        )
        assert (
            str(warning.warnings[1].message  )
            == f'''The `foo` attribute is deprecated and will be removed in version {self.higher_version}. message'''
        )







      def       lowerCAmelCase_       (	self  )		->			int:
        snake_case_					= {"""deprecated_arg""": 4}

        with self.assertRaises(lowerCamelCase  ) as error:
          deprecate(("""wrong_arg""", self.lower_version, """message""")				,    take_from=lowerCamelCase  )

        assert (
            str(error.exception  )
            == "The deprecation tuple ('wrong_arg', '0.0.1', 'message') should be removed since diffusers' version"
            f''' {__version__} is >= {self.lower_version}'''
        )







      def       lowerCAmelCase_       (	self  )		->			List[Any]:
        with self.assertWarns(lowerCamelCase  ) as warning:
          deprecate(("""deprecated_arg""", self.higher_version, """This message is better!!!""")				,    standard_warn=lowerCamelCase  )

        assert str(warning.warning  ) == "This message is better!!!"







      def       lowerCAmelCase_       (	self  )		->			List[Any]:
        with self.assertWarns(lowerCamelCase  ) as warning:
          deprecate(("""deprecated_arg""", self.higher_version, """This message is better!!!""")				,    standard_warn=lowerCamelCase  )
        assert str(warning.warning  ) == "This message is better!!!"
        assert "diffusers/tests/others/test_utils.py" in warning.filename