

'''simple docstring'''

import json
import os
import sys
import tempfile
import unittest
from pathlib import Path
from shutil import copyfile

from huggingface_hub import HfFolder, Repository, create_repo, delete_repo
from requests.exceptions import HTTPError

import transformers
from transformers import (
    CONFIG_MAPPING,
    FEATURE_EXTRACTOR_MAPPING,
    PROCESSOR_MAPPING,
    TOKENIZER_MAPPING,
    AutoConfig,
    AutoFeatureExtractor,
    AutoProcessor,
    AutoTokenizer,
    BertTokenizer,
    ProcessorMixin,
    WavaVecaConfig,
    WavaVecaFeatureExtractor,
    WavaVecaProcessor,
)
from transformers.testing_utils import TOKEN, USER, get_tests_dir, is_staging_test
from transformers.tokenization_utils import TOKENIZER_CONFIG_FILE
from transformers.utils import FEATURE_EXTRACTOR_NAME, is_tokenizers_available


sys.path.append(str(Path(__file__).parent.parent.parent.parent / "utils"))

from test_module.custom_configuration import CustomConfig  # noqa E402
from test_module.custom_feature_extraction import CustomFeatureExtractor  # noqa E402
from test_module.custom_processing import CustomProcessor  # noqa E402
from test_module.custom_tokenization import CustomTokenizer  # noqa E402


A_							    =				get_tests_dir("fixtures/dummy_feature_extractor_config.json")
A_							    =				get_tests_dir("fixtures/vocab.json")
A_							    =				get_tests_dir("fixtures")





class 				_snake_case			(							unittest.TestCase    ):
   _A							:  Optional[Any]      =       ['[UNK]', '[CLS]', '[SEP]', '[PAD]', '[MASK]', 'bla', 'blou']
   def      __UpperCamelCase    (			self      :   List[str]				):
     SCREAMING_SNAKE_CASE:Union[str, Any]       =       0
   def      __UpperCamelCase    (			self      :   Dict				):
     SCREAMING_SNAKE_CASE:int       =       AutoProcessor.from_pretrained("facebook/wav2vec2-base-960h"				)
     self.assertIsInstance(snake_case_  ,snake_case_				)
   def      __UpperCamelCase    (			self      :   Any				):


     with tempfile.TemporaryDirectory() as tmpdirname:
       SCREAMING_SNAKE_CASE:List[str]       =       WavaVecaConfig()
       SCREAMING_SNAKE_CASE:List[Any]       =       AutoProcessor.from_pretrained("facebook/wav2vec2-base-960h"				)

       # save in new folder
       model_config.save_pretrained(snake_case_				)
       processor.save_pretrained(snake_case_				)

       SCREAMING_SNAKE_CASE:Union[str, Any]       =       AutoProcessor.from_pretrained(snake_case_				)

     self.assertIsInstance(snake_case_  ,snake_case_				)
   def      __UpperCamelCase    (			self      :   List[Any]				):


     with tempfile.TemporaryDirectory() as tmpdirname:
       # copy relevant files
       copyfile(snake_case_  ,os.path.join(snake_case_  ,snake_case_				)				)
       copyfile(snake_case_  ,os.path.join(snake_case_  ,"vocab.json"				)				)

       SCREAMING_SNAKE_CASE:Tuple       =       AutoProcessor.from_pretrained(snake_case_				)

     self.assertIsInstance(snake_case_  ,snake_case_				)
   def      __UpperCamelCase    (			self      :   Optional[Any]				):


     with tempfile.TemporaryDirectory() as tmpdirname:
       SCREAMING_SNAKE_CASE:Any       =       WavaVecaFeatureExtractor()
       SCREAMING_SNAKE_CASE:Optional[Any]       =       AutoTokenizer.from_pretrained("facebook/wav2vec2-base-960h"				)

       SCREAMING_SNAKE_CASE:Dict       =       WavaVecaProcessor(snake_case_  ,snake_case_				)

       # save in new folder
       processor.save_pretrained(snake_case_				)

       # drop `processor_class` in tokenizer
       with open(os.path.join(snake_case_  ,snake_case_				)  ,"r"				) as f:
         SCREAMING_SNAKE_CASE:Optional[Any]       =       json.load(snake_case_				)
         config_dict.pop("processor_class"				)

       with open(os.path.join(snake_case_  ,snake_case_				)  ,"w"				) as f:
         f.write(json.dumps(snake_case_				)				)

       SCREAMING_SNAKE_CASE:Union[str, Any]       =       AutoProcessor.from_pretrained(snake_case_				)

     self.assertIsInstance(snake_case_  ,snake_case_				)
   def      __UpperCamelCase    (			self      :   List[str]				):


     with tempfile.TemporaryDirectory() as tmpdirname:
       SCREAMING_SNAKE_CASE:List[Any]       =       WavaVecaFeatureExtractor()
       SCREAMING_SNAKE_CASE:str       =       AutoTokenizer.from_pretrained("facebook/wav2vec2-base-960h"				)

       SCREAMING_SNAKE_CASE:List[Any]       =       WavaVecaProcessor(snake_case_  ,snake_case_				)

       # save in new folder
       processor.save_pretrained(snake_case_				)

       # drop `processor_class` in feature extractor
       with open(os.path.join(snake_case_  ,snake_case_				)  ,"r"				) as f:
         SCREAMING_SNAKE_CASE:Tuple       =       json.load(snake_case_				)
         config_dict.pop("processor_class"				)

       with open(os.path.join(snake_case_  ,snake_case_				)  ,"w"				) as f:
         f.write(json.dumps(snake_case_				)				)

       SCREAMING_SNAKE_CASE:Union[str, Any]       =       AutoProcessor.from_pretrained(snake_case_				)

     self.assertIsInstance(snake_case_  ,snake_case_				)
   def      __UpperCamelCase    (			self      :   Union[str, Any]				):


     with tempfile.TemporaryDirectory() as tmpdirname:
       SCREAMING_SNAKE_CASE:List[Any]       =       WavaVecaConfig(processor_class="Wav2Vec2Processor"				)
       model_config.save_pretrained(snake_case_				)
       # copy relevant files
       copyfile(snake_case_  ,os.path.join(snake_case_  ,"vocab.json"				)				)
       # create emtpy sample processor
       with open(os.path.join(snake_case_  ,snake_case_				)  ,"w"				) as f:
         f.write("{}"				)

       SCREAMING_SNAKE_CASE:List[str]       =       AutoProcessor.from_pretrained(snake_case_				)

     self.assertIsInstance(snake_case_  ,snake_case_				)
   def      __UpperCamelCase    (			self      :   Dict				):


     with self.assertRaises(snake_case_				):
       SCREAMING_SNAKE_CASE:List[Any]       =       AutoProcessor.from_pretrained("hf-internal-testing/test_dynamic_processor"				)
     # If remote code is disabled, we can't load this config.
     with self.assertRaises(snake_case_				):
       SCREAMING_SNAKE_CASE:List[Any]       =       AutoProcessor.from_pretrained(
           "hf-internal-testing/test_dynamic_processor"  ,trust_remote_code=snake_case_				)

     SCREAMING_SNAKE_CASE:Any       =       AutoProcessor.from_pretrained("hf-internal-testing/test_dynamic_processor"  ,trust_remote_code=snake_case_				)
     self.assertTrue(processor.special_attribute_present				)
     self.assertEqual(processor.__class__.__name__  ,"NewProcessor"				)

     SCREAMING_SNAKE_CASE:int       =       processor.feature_extractor
     self.assertTrue(feature_extractor.special_attribute_present				)
     self.assertEqual(feature_extractor.__class__.__name__  ,"NewFeatureExtractor"				)

     SCREAMING_SNAKE_CASE:Optional[Any]       =       processor.tokenizer
     self.assertTrue(tokenizer.special_attribute_present				)
     if is_tokenizers_available():
       self.assertEqual(tokenizer.__class__.__name__  ,"NewTokenizerFast"				)

       # Test we can also load the slow version
       SCREAMING_SNAKE_CASE:Optional[int]       =       AutoProcessor.from_pretrained(
           "hf-internal-testing/test_dynamic_processor"  ,trust_remote_code=snake_case_  ,use_fast=snake_case_				)
       SCREAMING_SNAKE_CASE:Dict       =       new_processor.tokenizer
       self.assertTrue(new_tokenizer.special_attribute_present				)
       self.assertEqual(new_tokenizer.__class__.__name__  ,"NewTokenizer"				)
     else:
       self.assertEqual(tokenizer.__class__.__name__  ,"NewTokenizer"				)
   def      __UpperCamelCase    (			self      :   Any				):


     try:
       AutoConfig.register("custom"  ,snake_case_				)
       AutoFeatureExtractor.register(snake_case_  ,snake_case_				)
       AutoTokenizer.register(snake_case_  ,slow_tokenizer_class=snake_case_				)
       AutoProcessor.register(snake_case_  ,snake_case_				)
       # Trying to register something existing in the Transformers library will raise an error
       with self.assertRaises(snake_case_				):
         AutoProcessor.register(snake_case_  ,snake_case_				)

       # Now that the config is registered, it can be used as any other config with the auto-API
       SCREAMING_SNAKE_CASE:Optional[Any]       =       CustomFeatureExtractor.from_pretrained(snake_case_				)

       with tempfile.TemporaryDirectory() as tmp_dir:
         SCREAMING_SNAKE_CASE:str       =       os.path.join(snake_case_  ,"vocab.txt"				)
         with open(snake_case_  ,"w"  ,encoding="utf-8"				) as vocab_writer:
           vocab_writer.write("".join([x + "\n" for x in self.vocab_tokens]				)				)
         SCREAMING_SNAKE_CASE:str       =       CustomTokenizer(snake_case_				)

       SCREAMING_SNAKE_CASE:Union[str, Any]       =       CustomProcessor(snake_case_  ,snake_case_				)

       with tempfile.TemporaryDirectory() as tmp_dir:
         processor.save_pretrained(snake_case_				)
         SCREAMING_SNAKE_CASE:Optional[int]       =       AutoProcessor.from_pretrained(snake_case_				)
         self.assertIsInstance(snake_case_  ,snake_case_				)

     finally:
       if "custom" in CONFIG_MAPPING._extra_content:
         del CONFIG_MAPPING._extra_content["custom"]
       if CustomConfig in FEATURE_EXTRACTOR_MAPPING._extra_content:
         del FEATURE_EXTRACTOR_MAPPING._extra_content[CustomConfig]
       if CustomConfig in TOKENIZER_MAPPING._extra_content:
         del TOKENIZER_MAPPING._extra_content[CustomConfig]
       if CustomConfig in PROCESSOR_MAPPING._extra_content:
         del PROCESSOR_MAPPING._extra_content[CustomConfig]
   def      __UpperCamelCase    (			self      :   Union[str, Any]				):





     class 				_snake_case			(							__A    ):
        _A							:  int      =       False





     class 				_snake_case			(							__A    ):
        _A							:  Any      =       False





     class 				_snake_case			(							__A    ):
        _A							:  str      =       'AutoFeatureExtractor'
        _A							:  Optional[Any]      =       'AutoTokenizer'
        _A							:  List[Any]      =       False

     try:
       AutoConfig.register("custom"  ,snake_case_				)
       AutoFeatureExtractor.register(snake_case_  ,snake_case_				)
       AutoTokenizer.register(snake_case_  ,slow_tokenizer_class=snake_case_				)
       AutoProcessor.register(snake_case_  ,snake_case_				)
       # If remote code is not set, the default is to use local classes.
       SCREAMING_SNAKE_CASE:Dict       =       AutoProcessor.from_pretrained("hf-internal-testing/test_dynamic_processor"				)
       self.assertEqual(processor.__class__.__name__  ,"NewProcessor"				)
       self.assertFalse(processor.special_attribute_present				)
       self.assertFalse(processor.feature_extractor.special_attribute_present				)
       self.assertFalse(processor.tokenizer.special_attribute_present				)

       # If remote code is disabled, we load the local ones.
       SCREAMING_SNAKE_CASE:Tuple       =       AutoProcessor.from_pretrained(
           "hf-internal-testing/test_dynamic_processor"  ,trust_remote_code=snake_case_				)
       self.assertEqual(processor.__class__.__name__  ,"NewProcessor"				)
       self.assertFalse(processor.special_attribute_present				)
       self.assertFalse(processor.feature_extractor.special_attribute_present				)
       self.assertFalse(processor.tokenizer.special_attribute_present				)

       # If remote is enabled, we load from the Hub.
       SCREAMING_SNAKE_CASE:List[str]       =       AutoProcessor.from_pretrained(
           "hf-internal-testing/test_dynamic_processor"  ,trust_remote_code=snake_case_				)
       self.assertEqual(processor.__class__.__name__  ,"NewProcessor"				)
       self.assertTrue(processor.special_attribute_present				)
       self.assertTrue(processor.feature_extractor.special_attribute_present				)
       self.assertTrue(processor.tokenizer.special_attribute_present				)

     finally:
       if "custom" in CONFIG_MAPPING._extra_content:
         del CONFIG_MAPPING._extra_content["custom"]
       if CustomConfig in FEATURE_EXTRACTOR_MAPPING._extra_content:
         del FEATURE_EXTRACTOR_MAPPING._extra_content[CustomConfig]
       if CustomConfig in TOKENIZER_MAPPING._extra_content:
         del TOKENIZER_MAPPING._extra_content[CustomConfig]
       if CustomConfig in PROCESSOR_MAPPING._extra_content:
         del PROCESSOR_MAPPING._extra_content[CustomConfig]
   def      __UpperCamelCase    (			self      :   str				):
     SCREAMING_SNAKE_CASE:int       =       AutoProcessor.from_pretrained("hf-internal-testing/tiny-random-bert"				)
     self.assertEqual(processor.__class__.__name__  ,"BertTokenizerFast"				)







   def      __UpperCamelCase    (			self      :   Dict				):
     SCREAMING_SNAKE_CASE:Tuple       =       AutoProcessor.from_pretrained("hf-internal-testing/tiny-random-convnext"				)
     self.assertEqual(processor.__class__.__name__  ,"ConvNextImageProcessor"				)





@is_staging_test
class 				_snake_case			(							unittest.TestCase    ):
   _A							:  Optional[int]      =       ['[UNK]', '[CLS]', '[SEP]', '[PAD]', '[MASK]', 'bla', 'blou']
   @classmethod
   def      __UpperCamelCase    (			cls      :   Tuple				):
     SCREAMING_SNAKE_CASE:List[Any]       =       TOKEN
     HfFolder.save_token(snake_case_				)
   @classmethod
   def      __UpperCamelCase    (			cls      :   Optional[int]				):


     try:
       delete_repo(token=cls._token  ,repo_id="test-processor"				)
     except HTTPError:
       pass

     try:
       delete_repo(token=cls._token  ,repo_id="valid_org/test-processor-org"				)
     except HTTPError:
       pass

     try:
       delete_repo(token=cls._token  ,repo_id="test-dynamic-processor"				)
     except HTTPError:
       pass
   def      __UpperCamelCase    (			self      :   Tuple				):
     SCREAMING_SNAKE_CASE:List[str]       =       WavaVecaProcessor.from_pretrained(snake_case_				)
     with tempfile.TemporaryDirectory() as tmp_dir:
       processor.save_pretrained(
           os.path.join(snake_case_  ,"test-processor"				)  ,push_to_hub=snake_case_  ,use_auth_token=self._token				)

       SCREAMING_SNAKE_CASE:Optional[int]       =       WavaVecaProcessor.from_pretrained(F'''{USER}/test-processor'''				)
       for k, v in processor.feature_extractor.__dict__.items():
         self.assertEqual(snake_case_  ,getattr(new_processor.feature_extractor  ,snake_case_				)				)
       self.assertDictEqual(new_processor.tokenizer.get_vocab()  ,processor.tokenizer.get_vocab()				)
   def      __UpperCamelCase    (			self      :   Union[str, Any]				):
     SCREAMING_SNAKE_CASE:Tuple       =       WavaVecaProcessor.from_pretrained(snake_case_				)

     with tempfile.TemporaryDirectory() as tmp_dir:
       processor.save_pretrained(
           os.path.join(snake_case_  ,"test-processor-org"				)  ,push_to_hub=snake_case_  ,use_auth_token=self._token  ,organization="valid_org"  ,)

       SCREAMING_SNAKE_CASE:Union[str, Any]       =       WavaVecaProcessor.from_pretrained("valid_org/test-processor-org"				)
       for k, v in processor.feature_extractor.__dict__.items():
         self.assertEqual(snake_case_  ,getattr(new_processor.feature_extractor  ,snake_case_				)				)
       self.assertDictEqual(new_processor.tokenizer.get_vocab()  ,processor.tokenizer.get_vocab()				)







   def      __UpperCamelCase    (			self      :   Optional[int]				):
     CustomFeatureExtractor.register_for_auto_class()
     CustomTokenizer.register_for_auto_class()
     CustomProcessor.register_for_auto_class()

     SCREAMING_SNAKE_CASE:int       =       CustomFeatureExtractor.from_pretrained(snake_case_				)

     with tempfile.TemporaryDirectory() as tmp_dir:
       SCREAMING_SNAKE_CASE:Optional[Any]       =       os.path.join(snake_case_  ,"vocab.txt"				)
       with open(snake_case_  ,"w"  ,encoding="utf-8"				) as vocab_writer:
         vocab_writer.write("".join([x + "\n" for x in self.vocab_tokens]				)				)
       SCREAMING_SNAKE_CASE:Optional[int]       =       CustomTokenizer(snake_case_				)

     SCREAMING_SNAKE_CASE:Union[str, Any]       =       CustomProcessor(snake_case_  ,snake_case_				)

     with tempfile.TemporaryDirectory() as tmp_dir:
       create_repo(F'''{USER}/test-dynamic-processor'''  ,token=self._token				)
       SCREAMING_SNAKE_CASE:List[Any]       =       Repository(snake_case_  ,clone_from=F'''{USER}/test-dynamic-processor'''  ,token=self._token				)
       processor.save_pretrained(snake_case_				)

       # This has added the proper auto_map field to the feature extractor config
       self.assertDictEqual(
           processor.feature_extractor.auto_map  ,{
               "AutoFeatureExtractor": "custom_feature_extraction.CustomFeatureExtractor",
               "AutoProcessor": "custom_processing.CustomProcessor",
           }  ,)

       # This has added the proper auto_map field to the tokenizer config
       with open(os.path.join(snake_case_  ,"tokenizer_config.json"				)				) as f:
         SCREAMING_SNAKE_CASE:List[str]       =       json.load(snake_case_				)
       self.assertDictEqual(
           tokenizer_config["auto_map"]  ,{
               "AutoTokenizer": ["custom_tokenization.CustomTokenizer", None],
               "AutoProcessor": "custom_processing.CustomProcessor",
           }  ,)

       # The code has been copied from fixtures
       self.assertTrue(os.path.isfile(os.path.join(snake_case_  ,"custom_feature_extraction.py"				)				)				)
       self.assertTrue(os.path.isfile(os.path.join(snake_case_  ,"custom_tokenization.py"				)				)				)
       self.assertTrue(os.path.isfile(os.path.join(snake_case_  ,"custom_processing.py"				)				)				)

       repo.push_to_hub()

     SCREAMING_SNAKE_CASE:Union[str, Any]       =       AutoProcessor.from_pretrained(F'''{USER}/test-dynamic-processor'''  ,trust_remote_code=snake_case_				)
     # Can't make an isinstance check because the new_processor is from the CustomProcessor class of a dynamic module
     self.assertEqual(new_processor.__class__.__name__  ,"CustomProcessor"				)







"""simple docstring"""



import unittest

from .lib import (
    Matrix,
    Vector,
    axpy,
    square_zero_matrix,
    unit_basis_vector,
    zero_vector,
)
class 						__UpperCAmelCase    (unittest.TestCase     ):







			'''simple docstring'''





			def 		lowerCamelCase					(			self							):







										'''simple docstring'''


										A__       :     Dict								=			Vector([1, 2, 3]							)
										self.assertEqual(x.component(0							)   ,      1							)
										self.assertEqual(x.component(2							)   ,      3							)
										A__       :     List[Any]								=			Vector()





			def 		lowerCamelCase					(			self							):







										'''simple docstring'''


										A__       :     List[Any]								=			Vector([0, 0, 0, 0, 0, 1]							)
										self.assertEqual(str(snake_case_							)   ,      """(0,0,0,0,0,1)"""							)





			def 		lowerCamelCase					(			self							):







										'''simple docstring'''


										A__       :     List[Any]								=			Vector([1, 2, 3, 4]							)
										self.assertEqual(len(snake_case_							)   ,      4							)





			def 		lowerCamelCase					(			self							):







										'''simple docstring'''


										A__       :     Any								=			Vector([1, 2]							)
										A__       :     Optional[int]								=			Vector([1, 2, 3, 4, 5]							)
										A__       :     Tuple								=			Vector([0, 0, 0, 0, 0, 0, 0, 0, 0, 0]							)
										A__       :     Dict								=			Vector([1, -1, 1, -1, 2, -3, 4, -5]							)
										self.assertAlmostEqual(x.euclidean_length()   ,      2.2_36   ,      3							)
										self.assertAlmostEqual(y.euclidean_length()   ,      7.4_16   ,      3							)
										self.assertEqual(z.euclidean_length()   ,      0							)
										self.assertAlmostEqual(w.euclidean_length()   ,      7.6_16   ,      3							)





			def 		lowerCamelCase					(			self							):







										'''simple docstring'''


										A__       :     Union[str, Any]								=			Vector([1, 2, 3]							)
										A__       :     Any								=			Vector([1, 1, 1]							)
										self.assertEqual((x + y).component(0							)   ,      2							)
										self.assertEqual((x + y).component(1							)   ,      3							)
										self.assertEqual((x + y).component(2							)   ,      4							)





			def 		lowerCamelCase					(			self							):







										'''simple docstring'''


										A__       :     Optional[int]								=			Vector([1, 2, 3]							)
										A__       :     int								=			Vector([1, 1, 1]							)
										self.assertEqual((x - y).component(0							)   ,      0							)
										self.assertEqual((x - y).component(1							)   ,      1							)
										self.assertEqual((x - y).component(2							)   ,      2							)





			def 		lowerCamelCase					(			self							):







										'''simple docstring'''


										A__       :     Tuple								=			Vector([1, 2, 3]							)
										A__       :     Any								=			Vector([2, -1, 4]							)  # for test of dot product
										A__       :     Optional[Any]								=			Vector([1, -2, -1]							)
										self.assertEqual(str(x * 3.0							)   ,      """(3.0,6.0,9.0)"""							)
										self.assertEqual((a * b)   ,      0							)





			def 		lowerCamelCase					(			self							):







										'''simple docstring'''


										self.assertEqual(str(zero_vector(10							)							).count("""0"""							)   ,      10							)





			def 		lowerCamelCase					(			self							):







										'''simple docstring'''


										self.assertEqual(str(unit_basis_vector(3   ,      1							)							)   ,      """(0,1,0)"""							)





			def 		lowerCamelCase					(			self							):







										'''simple docstring'''


										A__       :     Union[str, Any]								=			Vector([1, 2, 3]							)
										A__       :     Tuple								=			Vector([1, 0, 1]							)
										self.assertEqual(str(axpy(2   ,      snake_case_   ,      snake_case_							)							)   ,      """(3,4,7)"""							)





			def 		lowerCamelCase					(			self							):







										'''simple docstring'''


										A__       :     int								=			Vector([1, 0, 0, 0, 0, 0]							)
										A__       :     List[str]								=			x.copy()
										self.assertEqual(str(snake_case_							)   ,      str(snake_case_							)							)





			def 		lowerCamelCase					(			self							):







										'''simple docstring'''


										A__       :     str								=			Vector([1, 0, 0]							)
										x.change_component(0   ,      0							)
										x.change_component(1   ,      1							)
										self.assertEqual(str(snake_case_							)   ,      """(0,1,0)"""							)





			def 		lowerCamelCase					(			self							):







										'''simple docstring'''


										A__       :     List[Any]								=			Matrix([[1, 2, 3], [2, 4, 5], [6, 7, 8]]   ,      3   ,      3							)
										self.assertEqual("""|1,2,3|\n|2,4,5|\n|6,7,8|\n"""   ,      str(snake_case_							)							)





			def 		lowerCamelCase					(			self							):







										'''simple docstring'''


										A__       :     Any								=			Matrix([[1, 2, 3], [2, 4, 5], [6, 7, 8]]   ,      3   ,      3							)
										A__       :     Dict								=			[[-3, -14, -10], [-5, -10, -5], [-2, -1, 0]]
										for x in range(a.height()							):
																	for y in range(a.width()							):
																								self.assertEqual(minors[x][y]   ,      a.minor(snake_case_   ,      snake_case_							)							)





			def 		lowerCamelCase					(			self							):







										'''simple docstring'''


										A__       :     Optional[int]								=			Matrix([[1, 2, 3], [2, 4, 5], [6, 7, 8]]   ,      3   ,      3							)
										A__       :     Union[str, Any]								=			[[-3, 14, -10], [5, -10, 5], [-2, 1, 0]]
										for x in range(a.height()							):
																	for y in range(a.width()							):
																								self.assertEqual(cofactors[x][y]   ,      a.cofactor(snake_case_   ,      snake_case_							)							)





			def 		lowerCamelCase					(			self							):







										'''simple docstring'''


										A__       :     Any								=			Matrix([[1, 2, 3], [2, 4, 5], [6, 7, 8]]   ,      3   ,      3							)
										self.assertEqual(-5   ,      a.determinant()							)





			def 		lowerCamelCase					(			self							):







										'''simple docstring'''


										A__       :     Optional[int]								=			Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]]   ,      3   ,      3							)
										A__       :     int								=			Vector([1, 2, 3]							)
										self.assertEqual("""(14,32,50)"""   ,      str(a * x							)							)
										self.assertEqual("""|2,4,6|\n|8,10,12|\n|14,16,18|\n"""   ,      str(a * 2							)							)





			def 		lowerCamelCase					(			self							):







										'''simple docstring'''


										A__       :     Optional[Any]								=			Matrix([[1, 2, 3], [2, 4, 5], [6, 7, 8]]   ,      3   ,      3							)
										a.change_component(0   ,      2   ,      5							)
										self.assertEqual("""|1,2,5|\n|2,4,5|\n|6,7,8|\n"""   ,      str(snake_case_							)							)





			def 		lowerCamelCase					(			self							):







										'''simple docstring'''


										A__       :     Union[str, Any]								=			Matrix([[1, 2, 3], [2, 4, 5], [6, 7, 8]]   ,      3   ,      3							)
										self.assertEqual(7   ,      a.component(2   ,      1							)   ,      0.01							)





			def 		lowerCamelCase					(			self							):







										'''simple docstring'''


										A__       :     Optional[Any]								=			Matrix([[1, 2, 3], [2, 4, 5], [6, 7, 8]]   ,      3   ,      3							)
										A__       :     List[str]								=			Matrix([[1, 2, 7], [2, 4, 5], [6, 7, 10]]   ,      3   ,      3							)
										self.assertEqual("""|2,4,10|\n|4,8,10|\n|12,14,18|\n"""   ,      str(a + b							)							)





			def 		lowerCamelCase					(			self							):







										'''simple docstring'''


										A__       :     List[Any]								=			Matrix([[1, 2, 3], [2, 4, 5], [6, 7, 8]]   ,      3   ,      3							)
										A__       :     Tuple								=			Matrix([[1, 2, 7], [2, 4, 5], [6, 7, 10]]   ,      3   ,      3							)
										self.assertEqual("""|0,0,-4|\n|0,0,0|\n|0,0,-2|\n"""   ,      str(a - b							)							)





			def 		lowerCamelCase					(			self							):







										'''simple docstring'''


										self.assertEqual(
										    """|0,0,0,0,0|\n|0,0,0,0,0|\n|0,0,0,0,0|\n|0,0,0,0,0|\n|0,0,0,0,0|\n"""   ,      str(square_zero_matrix(5							)							)   ,      )


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





