






"""simple docstring"""
import unittest

from transformers import MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING, AutoTokenizer, is_vision_available
from transformers.pipelines import pipeline
from transformers.pipelines.document_question_answering import apply_tesseract
from transformers.testing_utils import (
    is_pipeline_test,
    nested_simplify,
    require_detectrona,
    require_pytesseract,
    require_tf,
    require_torch,
    require_vision,
    slow,
)

from .test_pipelines_common import ANY


if is_vision_available():
			from PIL import Image

			from transformers.image_utils import load_image
else:







			class      UpperCamelCase_			:





				@staticmethod
				def 	_SCREAMING_SNAKE_CASE ( *lowerCAmelCase_   :					Any      ,      **lowerCAmelCase_   :					Dict		)		->     str:
							pass





			def 							snake_case (  A__		):
						return None


# This is a pinned image from a specific revision of a document question answering space, hosted by HuggingFace,
# so we can expect it to be available.
lowerCamelCase_							      = (
    '''https://huggingface.co/spaces/impira/docquery/resolve/2f6c96314dc84dfda62d40de9da55f2f5165d403/invoice.png'''
)







@is_pipeline_test
@require_torch
@require_vision
class      UpperCamelCase_			(unittest.TestCase	):
	__magic_name__       =							MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING





	@require_pytesseract
	@require_vision
	def 	_SCREAMING_SNAKE_CASE ( self   :					Tuple      ,      lowerCAmelCase_   :					Optional[int]      ,      lowerCAmelCase_   :					Any      ,      lowerCAmelCase_   :					Optional[int]		)		->     Union[str, Any]:
				UpperCAmelCase_	:					int     	=   pipeline(
				    "document-question-answering"      ,      model=lowerCAmelCase_      ,      tokenizer=lowerCAmelCase_      ,      image_processor=lowerCAmelCase_		)

				UpperCAmelCase_	:					int     	=   INVOICE_URL
				UpperCAmelCase_	:					Union[str, Any]     	=   list(zip(*apply_tesseract(load_image(lowerCAmelCase_		)      ,      lowerCAmelCase_      ,      ""		)		)		)
				UpperCAmelCase_	:					Optional[Any]     	=   "What is the placebo?"
				UpperCAmelCase_	:					Tuple     	=   [
				    {
				        "image": load_image(lowerCAmelCase_		),
				        "question": question,
				    },
				    {
				        "image": image,
				        "question": question,
				    },
				    {
				        "image": image,
				        "question": question,
				        "word_boxes": word_boxes,
				    },
				]
				return dqa_pipeline, examples





	def 	_SCREAMING_SNAKE_CASE ( self   :					int      ,      lowerCAmelCase_   :					Any      ,      lowerCAmelCase_   :					List[Any]		)		->     int:
				UpperCAmelCase_	:					Union[str, Any]     	=   dqa_pipeline(lowerCAmelCase_      ,      top_k=2		)
				self.assertEqual(
				    lowerCAmelCase_      ,      [
				        [
				            {"score": ANY(lowerCAmelCase_		), "answer": ANY(lowerCAmelCase_		), "start": ANY(lowerCAmelCase_		), "end": ANY(lowerCAmelCase_		)},
				            {"score": ANY(lowerCAmelCase_		), "answer": ANY(lowerCAmelCase_		), "start": ANY(lowerCAmelCase_		), "end": ANY(lowerCAmelCase_		)},
				        ]
				    ]
				    * 3      ,      )





	@require_torch
	@require_detectrona
	@require_pytesseract
	def 	_SCREAMING_SNAKE_CASE ( self   :					Optional[int]		)		->     Any:
				UpperCAmelCase_	:					Tuple     	=   pipeline("document-question-answering"      ,      model="hf-internal-testing/tiny-random-layoutlmv2"		)
				UpperCAmelCase_	:					Dict     	=   INVOICE_URL
				UpperCAmelCase_	:					int     	=   "How many cats are there?"

				UpperCAmelCase_	:					Any     	=   [
				    {"score": 0.0_0_0_1, "answer": "oy 2312/2019", "start": 38, "end": 39},
				    {"score": 0.0_0_0_1, "answer": "oy 2312/2019 DUE", "start": 38, "end": 40},
				]
				UpperCAmelCase_	:					List[str]     	=   dqa_pipeline(image=lowerCAmelCase_      ,      question=lowerCAmelCase_      ,      top_k=2		)
				self.assertEqual(nested_simplify(lowerCAmelCase_      ,      decimals=4		)      ,      lowerCAmelCase_		)

				UpperCAmelCase_	:					Dict     	=   dqa_pipeline({"image": image, "question": question}      ,      top_k=2		)
				self.assertEqual(nested_simplify(lowerCAmelCase_      ,      decimals=4		)      ,      lowerCAmelCase_		)

				# This image does not detect ANY text in it, meaning layoutlmv2 should fail.
				# Empty answer probably
				UpperCAmelCase_	:					int     	=   "./tests/fixtures/tests_samples/COCO/000000039769.png"
				UpperCAmelCase_	:					Dict     	=   dqa_pipeline(image=lowerCAmelCase_      ,      question=lowerCAmelCase_      ,      top_k=2		)
				self.assertEqual(lowerCAmelCase_      ,      []		)

				# We can optionnally pass directly the words and bounding boxes
				UpperCAmelCase_	:					int     	=   "./tests/fixtures/tests_samples/COCO/000000039769.png"
				UpperCAmelCase_	:					Optional[Any]     	=   []
				UpperCAmelCase_	:					Dict     	=   []
				UpperCAmelCase_	:					Optional[Any]     	=   dqa_pipeline(image=lowerCAmelCase_      ,      question=lowerCAmelCase_      ,      words=lowerCAmelCase_      ,      boxes=lowerCAmelCase_      ,      top_k=2		)
				self.assertEqual(lowerCAmelCase_      ,      []		)





	@slow
	@require_torch
	@require_detectrona
	@require_pytesseract
	def 	_SCREAMING_SNAKE_CASE ( self   :					Any		)		->     int:
				UpperCAmelCase_	:					Dict     	=   pipeline(
				    "document-question-answering"      ,      model="tiennvcs/layoutlmv2-base-uncased-finetuned-docvqa"      ,      revision="9977165"      ,      )
				UpperCAmelCase_	:					Optional[Any]     	=   INVOICE_URL
				UpperCAmelCase_	:					Dict     	=   "What is the invoice number?"

				UpperCAmelCase_	:					int     	=   dqa_pipeline(image=lowerCAmelCase_      ,      question=lowerCAmelCase_      ,      top_k=2		)
				self.assertEqual(
				    nested_simplify(lowerCAmelCase_      ,      decimals=4		)      ,      [
				        {"score": 0.9_9_4_4, "answer": "us-001", "start": 16, "end": 16},
				        {"score": 0.0_0_0_9, "answer": "us-001", "start": 16, "end": 16},
				    ]      ,      )

				UpperCAmelCase_	:					int     	=   dqa_pipeline({"image": image, "question": question}      ,      top_k=2		)
				self.assertEqual(
				    nested_simplify(lowerCAmelCase_      ,      decimals=4		)      ,      [
				        {"score": 0.9_9_4_4, "answer": "us-001", "start": 16, "end": 16},
				        {"score": 0.0_0_0_9, "answer": "us-001", "start": 16, "end": 16},
				    ]      ,      )

				UpperCAmelCase_	:					Any     	=   dqa_pipeline(
				    [{"image": image, "question": question}, {"image": image, "question": question}]      ,      top_k=2		)
				self.assertEqual(
				    nested_simplify(lowerCAmelCase_      ,      decimals=4		)      ,      [
				        [
				            {"score": 0.9_9_4_4, "answer": "us-001", "start": 16, "end": 16},
				            {"score": 0.0_0_0_9, "answer": "us-001", "start": 16, "end": 16},
				        ],
				    ]
				    * 2      ,      )





	@slow
	@require_torch
	@require_detectrona
	@require_pytesseract
	def 	_SCREAMING_SNAKE_CASE ( self   :					Optional[int]		)		->     Tuple:
				UpperCAmelCase_	:					Tuple     	=   pipeline(
				    "document-question-answering"      ,      model="tiennvcs/layoutlmv2-base-uncased-finetuned-docvqa"      ,      revision="9977165"      ,      max_seq_len=50      ,      )
				UpperCAmelCase_	:					Tuple     	=   INVOICE_URL
				UpperCAmelCase_	:					Any     	=   "What is the invoice number?"

				UpperCAmelCase_	:					str     	=   dqa_pipeline(image=lowerCAmelCase_      ,      question=lowerCAmelCase_      ,      top_k=2		)
				self.assertEqual(
				    nested_simplify(lowerCAmelCase_      ,      decimals=4		)      ,      [
				        {"score": 0.9_9_7_4, "answer": "1110212019", "start": 23, "end": 23},
				        {"score": 0.9_9_4_8, "answer": "us-001", "start": 16, "end": 16},
				    ]      ,      )

				UpperCAmelCase_	:					Optional[int]     	=   dqa_pipeline({"image": image, "question": question}      ,      top_k=2		)
				self.assertEqual(
				    nested_simplify(lowerCAmelCase_      ,      decimals=4		)      ,      [
				        {"score": 0.9_9_7_4, "answer": "1110212019", "start": 23, "end": 23},
				        {"score": 0.9_9_4_8, "answer": "us-001", "start": 16, "end": 16},
				    ]      ,      )

				UpperCAmelCase_	:					str     	=   dqa_pipeline(
				    [{"image": image, "question": question}, {"image": image, "question": question}]      ,      top_k=2		)
				self.assertEqual(
				    nested_simplify(lowerCAmelCase_      ,      decimals=4		)      ,      [
				        [
				            {"score": 0.9_9_7_4, "answer": "1110212019", "start": 23, "end": 23},
				            {"score": 0.9_9_4_8, "answer": "us-001", "start": 16, "end": 16},
				        ]
				    ]
				    * 2      ,      )





	@slow
	@require_torch
	@require_pytesseract
	@require_vision
	def 	_SCREAMING_SNAKE_CASE ( self   :					Union[str, Any]		)		->     Union[str, Any]:
				UpperCAmelCase_	:					Any     	=   AutoTokenizer.from_pretrained(
				    "impira/layoutlm-document-qa"      ,      revision="3dc6de3"      ,      add_prefix_space=lowerCAmelCase_		)
				UpperCAmelCase_	:					str     	=   pipeline(
				    "document-question-answering"      ,      model="impira/layoutlm-document-qa"      ,      tokenizer=lowerCAmelCase_      ,      revision="3dc6de3"      ,      )
				UpperCAmelCase_	:					Any     	=   INVOICE_URL
				UpperCAmelCase_	:					List[str]     	=   "What is the invoice number?"

				UpperCAmelCase_	:					str     	=   dqa_pipeline(image=lowerCAmelCase_      ,      question=lowerCAmelCase_      ,      top_k=2		)
				self.assertEqual(
				    nested_simplify(lowerCAmelCase_      ,      decimals=4		)      ,      [
				        {"score": 0.4_2_5_1, "answer": "us-001", "start": 16, "end": 16},
				        {"score": 0.0_8_1_9, "answer": "1110212019", "start": 23, "end": 23},
				    ]      ,      )

				UpperCAmelCase_	:					Dict     	=   dqa_pipeline({"image": image, "question": question}      ,      top_k=2		)
				self.assertEqual(
				    nested_simplify(lowerCAmelCase_      ,      decimals=4		)      ,      [
				        {"score": 0.4_2_5_1, "answer": "us-001", "start": 16, "end": 16},
				        {"score": 0.0_8_1_9, "answer": "1110212019", "start": 23, "end": 23},
				    ]      ,      )

				UpperCAmelCase_	:					Union[str, Any]     	=   dqa_pipeline(
				    [{"image": image, "question": question}, {"image": image, "question": question}]      ,      top_k=2		)
				self.assertEqual(
				    nested_simplify(lowerCAmelCase_      ,      decimals=4		)      ,      [
				        [
				            {"score": 0.4_2_5_1, "answer": "us-001", "start": 16, "end": 16},
				            {"score": 0.0_8_1_9, "answer": "1110212019", "start": 23, "end": 23},
				        ]
				    ]
				    * 2      ,      )

				UpperCAmelCase_	:					Dict     	=   list(zip(*apply_tesseract(load_image(lowerCAmelCase_		)      ,      lowerCAmelCase_      ,      ""		)		)		)

				# This model should also work if `image` is set to None
				UpperCAmelCase_	:					List[str]     	=   dqa_pipeline({"image": None, "word_boxes": word_boxes, "question": question}      ,      top_k=2		)
				self.assertEqual(
				    nested_simplify(lowerCAmelCase_      ,      decimals=4		)      ,      [
				        {"score": 0.4_2_5_1, "answer": "us-001", "start": 16, "end": 16},
				        {"score": 0.0_8_1_9, "answer": "1110212019", "start": 23, "end": 23},
				    ]      ,      )





	@slow
	@require_torch
	@require_pytesseract
	@require_vision
	def 	_SCREAMING_SNAKE_CASE ( self   :					int		)		->     Tuple:
				UpperCAmelCase_	:					List[Any]     	=   AutoTokenizer.from_pretrained(
				    "impira/layoutlm-document-qa"      ,      revision="3dc6de3"      ,      add_prefix_space=lowerCAmelCase_		)
				UpperCAmelCase_	:					str     	=   pipeline(
				    "document-question-answering"      ,      model="impira/layoutlm-document-qa"      ,      tokenizer=lowerCAmelCase_      ,      revision="3dc6de3"      ,      max_seq_len=50      ,      )
				UpperCAmelCase_	:					List[Any]     	=   INVOICE_URL
				UpperCAmelCase_	:					Optional[int]     	=   "What is the invoice number?"

				UpperCAmelCase_	:					int     	=   dqa_pipeline(image=lowerCAmelCase_      ,      question=lowerCAmelCase_      ,      top_k=2		)
				self.assertEqual(
				    nested_simplify(lowerCAmelCase_      ,      decimals=4		)      ,      [
				        {"score": 0.9_9_9_9, "answer": "us-001", "start": 16, "end": 16},
				        {"score": 0.9_9_9_8, "answer": "us-001", "start": 16, "end": 16},
				    ]      ,      )

				UpperCAmelCase_	:					Tuple     	=   dqa_pipeline(
				    [{"image": image, "question": question}, {"image": image, "question": question}]      ,      top_k=2		)
				self.assertEqual(
				    nested_simplify(lowerCAmelCase_      ,      decimals=4		)      ,      [
				        [
				            {"score": 0.9_9_9_9, "answer": "us-001", "start": 16, "end": 16},
				            {"score": 0.9_9_9_8, "answer": "us-001", "start": 16, "end": 16},
				        ]
				    ]
				    * 2      ,      )

				UpperCAmelCase_	:					Optional[int]     	=   list(zip(*apply_tesseract(load_image(lowerCAmelCase_		)      ,      lowerCAmelCase_      ,      ""		)		)		)

				# This model should also work if `image` is set to None
				UpperCAmelCase_	:					Dict     	=   dqa_pipeline({"image": None, "word_boxes": word_boxes, "question": question}      ,      top_k=2		)
				self.assertEqual(
				    nested_simplify(lowerCAmelCase_      ,      decimals=4		)      ,      [
				        {"score": 0.9_9_9_9, "answer": "us-001", "start": 16, "end": 16},
				        {"score": 0.9_9_9_8, "answer": "us-001", "start": 16, "end": 16},
				    ]      ,      )





	@slow
	@require_torch
	def 	_SCREAMING_SNAKE_CASE ( self   :					Union[str, Any]		)		->     List[str]:
				UpperCAmelCase_	:					List[Any]     	=   pipeline(
				    "document-question-answering"      ,      model="naver-clova-ix/donut-base-finetuned-docvqa"      ,      tokenizer=AutoTokenizer.from_pretrained("naver-clova-ix/donut-base-finetuned-docvqa"		)      ,      feature_extractor="naver-clova-ix/donut-base-finetuned-docvqa"      ,      )

				UpperCAmelCase_	:					Optional[int]     	=   INVOICE_URL
				UpperCAmelCase_	:					int     	=   "What is the invoice number?"
				UpperCAmelCase_	:					List[str]     	=   dqa_pipeline(image=lowerCAmelCase_      ,      question=lowerCAmelCase_      ,      top_k=2		)
				self.assertEqual(nested_simplify(lowerCAmelCase_      ,      decimals=4		)      ,      [{"answer": "us-001"}]		)





	@require_tf
	@unittest.skip("Document question answering not implemented in TF"		)
	def 	_SCREAMING_SNAKE_CASE ( self   :					List[Any]		)		->     List[str]:
				pass





"""simple docstring"""





# Imports
import numpy as np






class        _UpperCAmelCase:



		def __init__(   self							,						__a=None							,						__a=None							,						__a=None							,						__a=None							,						__a=None)			->			Dict:






							'''simple docstring'''
							self.set_matricies(red=__a							,						green=__a							,						blue=__a							,						red_edge=__a							,						nir=__a)



		def 		UpperCAmelCase				(   self							,						__a=None							,						__a=None							,						__a=None							,						__a=None							,						__a=None)			->			Dict:






							'''simple docstring'''
							if red is not None:
												_UpperCamelCase									=    red
							if green is not None:
												_UpperCamelCase									=    green
							if blue is not None:
												_UpperCamelCase									=    blue
							if red_edge is not None:
												_UpperCamelCase									=    red_edge
							if nir is not None:
												_UpperCamelCase									=    nir
							return True



		def 		UpperCAmelCase				(   self							,						__a=""							,						__a=None							,						__a=None							,						__a=None							,						__a=None							,						__a=None)			->			List[str]:






							'''simple docstring'''
							self.set_matricies(red=__a							,						green=__a							,						blue=__a							,						red_edge=__a							,						nir=__a)
							_UpperCamelCase									=    {
							    '''ARVI2''': self.arvaa,
							    '''CCCI''': self.ccci,
							    '''CVI''': self.cvi,
							    '''GLI''': self.gli,
							    '''NDVI''': self.ndvi,
							    '''BNDVI''': self.bndvi,
							    '''redEdgeNDVI''': self.red_edge_ndvi,
							    '''GNDVI''': self.gndvi,
							    '''GBNDVI''': self.gbndvi,
							    '''GRNDVI''': self.grndvi,
							    '''RBNDVI''': self.rbndvi,
							    '''PNDVI''': self.pndvi,
							    '''ATSAVI''': self.atsavi,
							    '''BWDRVI''': self.bwdrvi,
							    '''CIgreen''': self.ci_green,
							    '''CIrededge''': self.ci_rededge,
							    '''CI''': self.ci,
							    '''CTVI''': self.ctvi,
							    '''GDVI''': self.gdvi,
							    '''EVI''': self.evi,
							    '''GEMI''': self.gemi,
							    '''GOSAVI''': self.gosavi,
							    '''GSAVI''': self.gsavi,
							    '''Hue''': self.hue,
							    '''IVI''': self.ivi,
							    '''IPVI''': self.ipvi,
							    '''I''': self.i,
							    '''RVI''': self.rvi,
							    '''MRVI''': self.mrvi,
							    '''MSAVI''': self.m_savi,
							    '''NormG''': self.norm_g,
							    '''NormNIR''': self.norm_nir,
							    '''NormR''': self.norm_r,
							    '''NGRDI''': self.ngrdi,
							    '''RI''': self.ri,
							    '''S''': self.s,
							    '''IF''': self._if,
							    '''DVI''': self.dvi,
							    '''TVI''': self.tvi,
							    '''NDRE''': self.ndre,
							}

							try:
												return funcs[index]()
							except KeyError:
												print('''Index not in the list!''')
												return False



		def 		UpperCAmelCase				(   self)			->			List[Any]:






							'''simple docstring'''
							return -0.18 + (1.17 * ((self.nir - self.red) / (self.nir + self.red)))



		def 		UpperCAmelCase				(   self)			->			Any:






							'''simple docstring'''
							return ((self.nir - self.redEdge) / (self.nir + self.redEdge)) / (
							    (self.nir - self.red) / (self.nir + self.red)
							)



		def 		UpperCAmelCase				(   self)			->			Optional[int]:






							'''simple docstring'''
							return self.nir * (self.red / (self.green**2))



		def 		UpperCAmelCase				(   self)			->			str:






							'''simple docstring'''
							return (2 * self.green - self.red - self.blue) / (
							    2 * self.green + self.red + self.blue
							)



		def 		UpperCAmelCase				(   self)			->			List[str]:






							'''simple docstring'''
							return (self.nir - self.red) / (self.nir + self.red)



		def 		UpperCAmelCase				(   self)			->			str:






							'''simple docstring'''
							return (self.nir - self.blue) / (self.nir + self.blue)



		def 		UpperCAmelCase				(   self)			->			List[Any]:






							'''simple docstring'''
							return (self.redEdge - self.red) / (self.redEdge + self.red)



		def 		UpperCAmelCase				(   self)			->			Optional[int]:






							'''simple docstring'''
							return (self.nir - self.green) / (self.nir + self.green)



		def 		UpperCAmelCase				(   self)			->			Optional[Any]:






							'''simple docstring'''
							return (self.nir - (self.green + self.blue)) / (
							    self.nir + (self.green + self.blue)
							)



		def 		UpperCAmelCase				(   self)			->			Tuple:






							'''simple docstring'''
							return (self.nir - (self.green + self.red)) / (
							    self.nir + (self.green + self.red)
							)



		def 		UpperCAmelCase				(   self)			->			List[Any]:






							'''simple docstring'''
							return (self.nir - (self.blue + self.red)) / (self.nir + (self.blue + self.red))



		def 		UpperCAmelCase				(   self)			->			List[str]:






							'''simple docstring'''
							return (self.nir - (self.green + self.red + self.blue)) / (
							    self.nir + (self.green + self.red + self.blue)
							)



		def 		UpperCAmelCase				(   self							,						__a=0.08							,						__a=1.22							,						__a=0.03)			->			Optional[Any]:






							'''simple docstring'''
							return a * (
							    (self.nir - a * self.red - b)
							    / (a * self.nir + self.red - a * b + x * (1 + a**2))
							)



		def 		UpperCAmelCase				(   self)			->			Dict:






							'''simple docstring'''
							return (0.1 * self.nir - self.blue) / (0.1 * self.nir + self.blue)



		def 		UpperCAmelCase				(   self)			->			List[str]:






							'''simple docstring'''
							return (self.nir / self.green) - 1



		def 		UpperCAmelCase				(   self)			->			List[Any]:






							'''simple docstring'''
							return (self.nir / self.redEdge) - 1



		def 		UpperCAmelCase				(   self)			->			Union[str, Any]:






							'''simple docstring'''
							return (self.red - self.blue) / self.red



		def 		UpperCAmelCase				(   self)			->			Optional[int]:






							'''simple docstring'''
							_UpperCamelCase									=    self.ndvi()
							return ((ndvi + 0.5) / (abs(ndvi + 0.5))) * (abs(ndvi + 0.5) ** (1 / 2))



		def 		UpperCAmelCase				(   self)			->			Optional[int]:






							'''simple docstring'''
							return self.nir - self.green



		def 		UpperCAmelCase				(   self)			->			List[str]:






							'''simple docstring'''
							return 2.5 * (
							    (self.nir - self.red) / (self.nir + 6 * self.red - 7.5 * self.blue + 1)
							)



		def 		UpperCAmelCase				(   self)			->			Tuple:






							'''simple docstring'''
							_UpperCamelCase									=    (2 * (self.nir**2 - self.red**2) + 1.5 * self.nir + 0.5 * self.red) / (
							    self.nir + self.red + 0.5
							)
							return n * (1 - 0.25 * n) - (self.red - 0.125) / (1 - self.red)



		def 		UpperCAmelCase				(   self							,						__a=0.16)			->			Optional[Any]:






							'''simple docstring'''
							return (self.nir - self.green) / (self.nir + self.green + y)



		def 		UpperCAmelCase				(   self							,						__a=0.5)			->			Dict:






							'''simple docstring'''
							return ((self.nir - self.green) / (self.nir + self.green + n)) * (1 + n)



		def 		UpperCAmelCase				(   self)			->			Dict:






							'''simple docstring'''
							return np.arctan(
							    ((2 * self.red - self.green - self.blue) / 30.5) * (self.green - self.blue))



		def 		UpperCAmelCase				(   self							,						__a=None							,						__a=None)			->			Any:






							'''simple docstring'''
							return (self.nir - b) / (a * self.red)



		def 		UpperCAmelCase				(   self)			->			Optional[Any]:






							'''simple docstring'''
							return (self.nir / ((self.nir + self.red) / 2)) * (self.ndvi() + 1)



		def 		UpperCAmelCase				(   self)			->			Optional[Any]:






							'''simple docstring'''
							return (self.red + self.green + self.blue) / 30.5



		def 		UpperCAmelCase				(   self)			->			Any:






							'''simple docstring'''
							return self.nir / self.red



		def 		UpperCAmelCase				(   self)			->			Tuple:






							'''simple docstring'''
							return (self.rvi() - 1) / (self.rvi() + 1)



		def 		UpperCAmelCase				(   self)			->			List[Any]:






							'''simple docstring'''
							return (
							    (2 * self.nir + 1)
							    - ((2 * self.nir + 1) ** 2 - 8 * (self.nir - self.red)) ** (1 / 2)
							) / 2



		def 		UpperCAmelCase				(   self)			->			Optional[int]:






							'''simple docstring'''
							return self.green / (self.nir + self.red + self.green)



		def 		UpperCAmelCase				(   self)			->			str:






							'''simple docstring'''
							return self.nir / (self.nir + self.red + self.green)



		def 		UpperCAmelCase				(   self)			->			Optional[int]:






							'''simple docstring'''
							return self.red / (self.nir + self.red + self.green)



		def 		UpperCAmelCase				(   self)			->			Tuple:






							'''simple docstring'''
							return (self.green - self.red) / (self.green + self.red)



		def 		UpperCAmelCase				(   self)			->			Dict:






							'''simple docstring'''
							return (self.red - self.green) / (self.red + self.green)



		def 		UpperCAmelCase				(   self)			->			Any:






							'''simple docstring'''
							_UpperCamelCase									=    np.max([np.max(self.red), np.max(self.green), np.max(self.blue)])
							_UpperCamelCase									=    np.min([np.min(self.red), np.min(self.green), np.min(self.blue)])
							return (max_value - min_value) / max_value



		def 		UpperCAmelCase				(   self)			->			str:






							'''simple docstring'''
							return (2 * self.red - self.green - self.blue) / (self.green - self.blue)



		def 		UpperCAmelCase				(   self)			->			int:






							'''simple docstring'''
							return self.nir / self.red



		def 		UpperCAmelCase				(   self)			->			Any:






							'''simple docstring'''
							return (self.ndvi() + 0.5) ** (1 / 2)




		def 		UpperCAmelCase				(   self)			->			Union[str, Any]:






							'''simple docstring'''
							return (self.nir - self.redEdge) / (self.nir + self.redEdge)






