





import numpy as np



def 				lowerCAmelCase_			(      SCREAMING_SNAKE_CASE       :							np.array   ):


							'''simple docstring'''







							return (2 / (1 + np.exp(-2 * vector   ))) - 1


if __name__ == "__main__":
							import doctest

							doctest.testmod()











"""simple docstring"""





import builtins
import sys

from ...utils.imports import _is_package_available
from . import cursor, input
from .helpers import Direction, clear_line, forceWrite, linebreak, move_cursor, reset_cursor, writeColor
from .keymap import KEYMAP


_UpperCamelCase							=      False
try:
							_UpperCamelCase							=      _is_package_available('google.colab')
except ModuleNotFoundError:
							pass
@input.register
class 		SCREAMING_SNAKE_CASE_							:
				"""simple docstring"""




				def __init__(     self  :Union[str, Any]						,    __lowercase  :str = None						,    __lowercase  :list = []			):
											__lowerCamelCase      :      Any         =0
											__lowerCamelCase      :      List[str]         =choices
											__lowerCamelCase      :      int         =prompt
											if sys.platform == "win32":
																		__lowerCamelCase      :      Dict         ='''*'''
											else:
																		__lowerCamelCase      :      Union[str, Any]         ='''➔ '''




				def 					__lowercase  (     self  :Tuple						,    __lowercase  :Any						,    __lowercase  :str = ""			):
											if sys.platform != "win32":
																		writeColor(self.choices[index]						,    32						,    __lowercase			)
											else:
																		forceWrite(self.choices[index]						,    __lowercase			)




				def 					__lowercase  (     self  :Tuple						,    __lowercase  :int			):
											if index == self.position:
																		forceWrite(f' {self.arrow_char} '			)
																		self.write_choice(__lowercase			)
											else:
																		forceWrite(f'    {self.choices[index]}'			)
											reset_cursor()




				def 					__lowercase  (     self  :Tuple						,    __lowercase  :Direction						,    __lowercase  :int = 1			):
											__lowerCamelCase      :      List[str]         =self.position
											if direction == Direction.DOWN:
																		if self.position + 1 >= len(self.choices			):
																									return
																		self.position += num_spaces
											else:
																		if self.position - 1 < 0:
																									return
																		self.position -= num_spaces
											clear_line()
											self.print_choice(__lowercase			)
											move_cursor(__lowercase						,    direction.name			)
											self.print_choice(self.position			)




				@input.mark(KEYMAP['''up''']			)
				def 					__lowercase  (     self  :Union[str, Any]			):
											self.move_direction(Direction.UP			)




				@input.mark(KEYMAP['''down''']			)
				def 					__lowercase  (     self  :Union[str, Any]			):
											self.move_direction(Direction.DOWN			)




				@input.mark(KEYMAP['''newline''']			)
				def 					__lowercase  (     self  :Any			):
											move_cursor(len(self.choices			) - self.position						,    '''DOWN'''			)
											return self.position




				@input.mark(KEYMAP['''interrupt''']			)
				def 					__lowercase  (     self  :Any			):
											move_cursor(len(self.choices			) - self.position						,    '''DOWN'''			)
											raise KeyboardInterrupt




				@input.mark_multiple(*[KEYMAP[str(__lowercase			)] for number in range(10			)]			)
				def 					__lowercase  (     self  :Any			):
											__lowerCamelCase      :      Tuple         =int(chr(self.current_selection			)			)
											__lowerCamelCase      :      Dict         =index - self.position
											if index == self.position:
																		return
											if index < len(self.choices			):
																		if self.position > index:
																									self.move_direction(Direction.UP						,    -movement			)
																		elif self.position < index:
																									self.move_direction(Direction.DOWN						,    __lowercase			)
																		else:
																									return
											else:
																		return




				def 					__lowercase  (     self  :Optional[int]						,    __lowercase  :int = 0			):
											if self.prompt:
																		linebreak()
																		forceWrite(self.prompt						,    '''\n'''			)
																		if in_colab:
																									forceWrite('''Please input a choice index (starting from 0), and press enter'''						,    '''\n'''			)
																		else:
																									forceWrite('''Please select a choice using the arrow or number keys, and selecting with enter'''						,    '''\n'''			)
											__lowerCamelCase      :      Union[str, Any]         =default_choice
											for i in range(len(self.choices			)			):
																		self.print_choice(__lowercase			)
																		forceWrite('''\n'''			)
											move_cursor(len(self.choices			) - self.position						,    '''UP'''			)
											with cursor.hide():
																		while True:
																									if in_colab:
																																try:
																																							__lowerCamelCase      :      Union[str, Any]         =int(builtins.input()			)
																																except ValueError:
																																							__lowerCamelCase      :      Optional[Any]         =default_choice
																									else:
																																__lowerCamelCase      :      Dict         =self.handle_input()
																									if choice is not None:
																																reset_cursor()
																																for _ in range(len(self.choices			) + 1			):
																																							move_cursor(1						,    '''UP'''			)
																																							clear_line()
																																self.write_choice(__lowercase						,    '''\n'''			)
																																return choice




