






from cva import destroyAllWindows, imread, imshow, waitKey

def 						snake_case      (UpperCAmelCase__			,					UpperCAmelCase__						) ->       Any:
  UpperCamelCase_   ,UpperCamelCase_:      Any					   =       img.shape[0], img.shape[1]

  def to_grayscale(UpperCAmelCase__			,					UpperCAmelCase__			,					UpperCAmelCase__						):
    return 0.2126 * red + 0.587 * green + 0.114 * blue

  def normalize(UpperCAmelCase__						):
    return min(UpperCAmelCase__			,					2_5_5						)

  for i in range(UpperCAmelCase__						):
    for j in range(UpperCAmelCase__						):
      UpperCamelCase_:      int					   =       int(to_grayscale(*img[i][j]						)						)
      UpperCamelCase_:      Optional[Any]					   =       [
          normalize(UpperCAmelCase__						),
          normalize(greyscale + factor						),
          normalize(greyscale + 2 * factor						),
      ]

  return img


if __name__ == "__main__":
   # read original image
   A_	:	Optional[int]				=				{
       percentage: imread('image_data/lena.jpg', 1) for percentage in (10, 20, 30, 40)
   }

   for percentage, img in images.items():
      make_sepia(img, percentage)

   for percentage, img in images.items():
      imshow(F'''Original image with sepia (factor: {percentage})''', img)

   waitKey(0)
   destroyAllWindows()







from datetime import date

import requests

A_	:	Any				=				'https://api.carbonintensity.org.uk/intensity'

def 						snake_case      () ->       str:
  UpperCamelCase_:      Any					   =       requests.get(UpperCAmelCase__						).json()['data'][0]
  return last_half_hour["intensity"]["actual"]

def 						snake_case      (UpperCAmelCase__			,					UpperCAmelCase__						) ->       list:
  return requests.get(F'''{BASE_URL}/{start}/{end}'''						).json()["data"]


if __name__ == "__main__":
   for entry in fetch_from_to(start=date(2020, 10, 1), end=date(2020, 10, 3)):
      print('from {from} to {to}: {intensity[actual]}'.format(**entry))
   print(F'''{fetch_last_half_hour() = }''')