


'''simple docstring'''




import unittest

import numpy as np

from transformers.testing_utils import require_torch, require_vision
from transformers.utils import is_torch_available, is_vision_available

from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs


if is_torch_available():
       import torch

if is_vision_available():
       from PIL import Image

       from transformers import ViTImageProcessor

class 		UpperCAmelCase_      (  unittest.TestCase		):





     def __init__( self       :      str    ,      UpperCAmelCase__       :      Optional[int]    ,      UpperCAmelCase__       :      Optional[int]=1_3    ,      UpperCAmelCase__       :      Optional[Any]=3    ,      UpperCAmelCase__       :      Optional[Any]=2_2_4    ,      UpperCAmelCase__       :      Optional[Any]=3_0    ,      UpperCAmelCase__       :      Any=4_0_0    ,      UpperCAmelCase__       :      int=True    ,      UpperCAmelCase__       :      Optional[int]=None    ,      UpperCAmelCase__       :      Any=True    ,      UpperCAmelCase__       :      Optional[Any]=[0.5, 0.5, 0.5]    ,      UpperCAmelCase__       :      Optional[int]=[0.5, 0.5, 0.5]    ,      )				->  int:
        lowerCAmelCase     =			size if size is not None else {'height': 1_8, 'width': 1_8}
        lowerCAmelCase     =			parent
        lowerCAmelCase     =			batch_size
        lowerCAmelCase     =			num_channels
        lowerCAmelCase     =			image_size
        lowerCAmelCase     =			min_resolution
        lowerCAmelCase     =			max_resolution
        lowerCAmelCase     =			do_resize
        lowerCAmelCase     =			size
        lowerCAmelCase     =			do_normalize
        lowerCAmelCase     =			image_mean
        lowerCAmelCase     =			image_std





     def 							__UpperCAmelCase      ( self       :      List[Any]    )				->  Optional[Any]:
        return {
            "image_mean": self.image_mean,
            "image_std": self.image_std,
            "do_normalize": self.do_normalize,
            "do_resize": self.do_resize,
            "size": self.size,
        }




@require_torch
@require_vision
class 		UpperCAmelCase_      (  __lowercase       ,	unittest.TestCase		):
     lowerCamelCase				:	Dict		=     ViTImageProcessor if is_vision_available() else None





     def 							__UpperCAmelCase      ( self       :      List[str]    )				->  List[Any]:
        lowerCAmelCase     =			EfficientFormerImageProcessorTester(self    )





     @property
     def 							__UpperCAmelCase      ( self       :      List[Any]    )				->  str:
        return self.image_proc_tester.prepare_image_processor_dict()





     def 							__UpperCAmelCase      ( self       :      List[Any]    )				->  Tuple:
        lowerCAmelCase     =			self.image_processing_class(**self.image_processor_dict    )
        self.assertTrue(hasattr(UpperCAmelCase__    ,      'image_mean'    )    )
        self.assertTrue(hasattr(UpperCAmelCase__    ,      'image_std'    )    )
        self.assertTrue(hasattr(UpperCAmelCase__    ,      'do_normalize'    )    )
        self.assertTrue(hasattr(UpperCAmelCase__    ,      'do_resize'    )    )
        self.assertTrue(hasattr(UpperCAmelCase__    ,      'size'    )    )





     def 							__UpperCAmelCase      ( self       :      int    )				->  Optional[int]:
        pass





     def 							__UpperCAmelCase      ( self       :      Union[str, Any]    )				->  Optional[int]:
        # Initialize image_processor
        lowerCAmelCase     =			self.image_processing_class(**self.image_processor_dict    )
        # create random PIL images
        lowerCAmelCase     =			prepare_image_inputs(self.image_proc_tester    ,      equal_resolution=UpperCAmelCase__    )
        for image in image_inputs:
           self.assertIsInstance(UpperCAmelCase__    ,      Image.Image    )

        # Test not batched input
        lowerCAmelCase     =			image_processor(image_inputs[0]    ,      return_tensors='pt'    ).pixel_values
        self.assertEqual(
            encoded_images.shape    ,      (
                1,
                self.image_proc_tester.num_channels,
                self.image_proc_tester.size['height'],
                self.image_proc_tester.size['width'],
            )    ,      )

        # Test batched
        lowerCAmelCase     =			image_processor(UpperCAmelCase__    ,      return_tensors='pt'    ).pixel_values
        self.assertEqual(
            encoded_images.shape    ,      (
                self.image_proc_tester.batch_size,
                self.image_proc_tester.num_channels,
                self.image_proc_tester.size['height'],
                self.image_proc_tester.size['width'],
            )    ,      )





     def 							__UpperCAmelCase      ( self       :      str    )				->  Tuple:
        # Initialize image_processor
        lowerCAmelCase     =			self.image_processing_class(**self.image_processor_dict    )
        # create random numpy tensors
        lowerCAmelCase     =			prepare_image_inputs(self.image_proc_tester    ,      equal_resolution=UpperCAmelCase__    ,      numpify=UpperCAmelCase__    )
        for image in image_inputs:
           self.assertIsInstance(UpperCAmelCase__    ,      np.ndarray    )

        # Test not batched input
        lowerCAmelCase     =			image_processor(image_inputs[0]    ,      return_tensors='pt'    ).pixel_values
        self.assertEqual(
            encoded_images.shape    ,      (
                1,
                self.image_proc_tester.num_channels,
                self.image_proc_tester.size['height'],
                self.image_proc_tester.size['width'],
            )    ,      )

        # Test batched
        lowerCAmelCase     =			image_processor(UpperCAmelCase__    ,      return_tensors='pt'    ).pixel_values
        self.assertEqual(
            encoded_images.shape    ,      (
                self.image_proc_tester.batch_size,
                self.image_proc_tester.num_channels,
                self.image_proc_tester.size['height'],
                self.image_proc_tester.size['width'],
            )    ,      )





     def 							__UpperCAmelCase      ( self       :      List[Any]    )				->  int:
        # Initialize image_processor
        lowerCAmelCase     =			self.image_processing_class(**self.image_processor_dict    )
        # create random PyTorch tensors
        lowerCAmelCase     =			prepare_image_inputs(self.image_proc_tester    ,      equal_resolution=UpperCAmelCase__    ,      torchify=UpperCAmelCase__    )
        for image in image_inputs:
           self.assertIsInstance(UpperCAmelCase__    ,      torch.Tensor    )

        # Test not batched input
        lowerCAmelCase     =			image_processor(image_inputs[0]    ,      return_tensors='pt'    ).pixel_values
        self.assertEqual(
            encoded_images.shape    ,      (
                1,
                self.image_proc_tester.num_channels,
                self.image_proc_tester.size['height'],
                self.image_proc_tester.size['width'],
            )    ,      )

        # Test batched
        lowerCAmelCase     =			image_processor(UpperCAmelCase__    ,      return_tensors='pt'    ).pixel_values
        self.assertEqual(
            encoded_images.shape    ,      (
                self.image_proc_tester.batch_size,
                self.image_proc_tester.num_channels,
                self.image_proc_tester.size['height'],
                self.image_proc_tester.size['width'],
            )    ,      )






"""simple docstring"""


import requests

UpperCAmelCase__     						=  """"""  # <-- Put your OpenWeatherMap appid here!
UpperCAmelCase__     						=  """https://api.openweathermap.org/data/2.5/"""






def 			__UpperCAmelCase    (	lowercase = "Chicago"      ,lowercase = APPID						):







  """simple docstring"""
  return requests.get(URL_BASE + """weather"""      ,params=locals()						).json()






def 			__UpperCAmelCase    (	lowercase = "Kolkata, India"      ,lowercase = APPID						):







  """simple docstring"""
  return requests.get(URL_BASE + """forecast"""      ,params=locals()						).json()






def 			__UpperCAmelCase    (	lowercase = 55.68      ,lowercase = 12.57      ,lowercase = APPID						):







  """simple docstring"""
  return requests.get(URL_BASE + """onecall"""      ,params=locals()						).json()


if __name__ == "__main__":
    from pprint import pprint

    while True:
        UpperCAmelCase__     						=  input("""Enter a location:""").strip()
        if location:
            pprint(current_weather(location))
        else:
            break
