partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | keyUp | Performs a keyboard key release (without the press down beforehand).
Args:
key (str): The key to be released up. The valid names are listed in
KEYBOARD_KEYS.
Returns:
None | pyautogui/__init__.py | def keyUp(key, pause=None, _pause=True):
"""Performs a keyboard key release (without the press down beforehand).
Args:
key (str): The key to be released up. The valid names are listed in
KEYBOARD_KEYS.
Returns:
None
"""
if len(key) > 1:
key = key.lower()
_failSafeChe... | def keyUp(key, pause=None, _pause=True):
"""Performs a keyboard key release (without the press down beforehand).
Args:
key (str): The key to be released up. The valid names are listed in
KEYBOARD_KEYS.
Returns:
None
"""
if len(key) > 1:
key = key.lower()
_failSafeChe... | [
"Performs",
"a",
"keyboard",
"key",
"release",
"(",
"without",
"the",
"press",
"down",
"beforehand",
")",
"."
] | asweigart/pyautogui | python | https://github.com/asweigart/pyautogui/blob/77524bd47334a89024013fd48e05151c3ac9289a/pyautogui/__init__.py#L977-L993 | [
"def",
"keyUp",
"(",
"key",
",",
"pause",
"=",
"None",
",",
"_pause",
"=",
"True",
")",
":",
"if",
"len",
"(",
"key",
")",
">",
"1",
":",
"key",
"=",
"key",
".",
"lower",
"(",
")",
"_failSafeCheck",
"(",
")",
"platformModule",
".",
"_keyUp",
"(",... | 77524bd47334a89024013fd48e05151c3ac9289a |
train | press | Performs a keyboard key press down, followed by a release.
Args:
key (str, list): The key to be pressed. The valid names are listed in
KEYBOARD_KEYS. Can also be a list of such strings.
presses (integer, optiional): the number of press repetition
1 by default, for just one press
inter... | pyautogui/__init__.py | def press(keys, presses=1, interval=0.0, pause=None, _pause=True):
"""Performs a keyboard key press down, followed by a release.
Args:
key (str, list): The key to be pressed. The valid names are listed in
KEYBOARD_KEYS. Can also be a list of such strings.
presses (integer, optiional): the num... | def press(keys, presses=1, interval=0.0, pause=None, _pause=True):
"""Performs a keyboard key press down, followed by a release.
Args:
key (str, list): The key to be pressed. The valid names are listed in
KEYBOARD_KEYS. Can also be a list of such strings.
presses (integer, optiional): the num... | [
"Performs",
"a",
"keyboard",
"key",
"press",
"down",
"followed",
"by",
"a",
"release",
"."
] | asweigart/pyautogui | python | https://github.com/asweigart/pyautogui/blob/77524bd47334a89024013fd48e05151c3ac9289a/pyautogui/__init__.py#L995-L1027 | [
"def",
"press",
"(",
"keys",
",",
"presses",
"=",
"1",
",",
"interval",
"=",
"0.0",
",",
"pause",
"=",
"None",
",",
"_pause",
"=",
"True",
")",
":",
"if",
"type",
"(",
"keys",
")",
"==",
"str",
":",
"keys",
"=",
"[",
"keys",
"]",
"# put string in... | 77524bd47334a89024013fd48e05151c3ac9289a |
train | typewrite | Performs a keyboard key press down, followed by a release, for each of
the characters in message.
The message argument can also be list of strings, in which case any valid
keyboard name can be used.
Since this performs a sequence of keyboard presses and does not hold down
keys, it cannot be used t... | pyautogui/__init__.py | def typewrite(message, interval=0.0, pause=None, _pause=True):
"""Performs a keyboard key press down, followed by a release, for each of
the characters in message.
The message argument can also be list of strings, in which case any valid
keyboard name can be used.
Since this performs a sequence of... | def typewrite(message, interval=0.0, pause=None, _pause=True):
"""Performs a keyboard key press down, followed by a release, for each of
the characters in message.
The message argument can also be list of strings, in which case any valid
keyboard name can be used.
Since this performs a sequence of... | [
"Performs",
"a",
"keyboard",
"key",
"press",
"down",
"followed",
"by",
"a",
"release",
"for",
"each",
"of",
"the",
"characters",
"in",
"message",
"."
] | asweigart/pyautogui | python | https://github.com/asweigart/pyautogui/blob/77524bd47334a89024013fd48e05151c3ac9289a/pyautogui/__init__.py#L1029-L1061 | [
"def",
"typewrite",
"(",
"message",
",",
"interval",
"=",
"0.0",
",",
"pause",
"=",
"None",
",",
"_pause",
"=",
"True",
")",
":",
"interval",
"=",
"float",
"(",
"interval",
")",
"_failSafeCheck",
"(",
")",
"for",
"c",
"in",
"message",
":",
"if",
"len... | 77524bd47334a89024013fd48e05151c3ac9289a |
train | hotkey | Performs key down presses on the arguments passed in order, then performs
key releases in reverse order.
The effect is that calling hotkey('ctrl', 'shift', 'c') would perform a
"Ctrl-Shift-C" hotkey/keyboard shortcut press.
Args:
key(s) (str): The series of keys to press, in order. This can also... | pyautogui/__init__.py | def hotkey(*args, **kwargs):
"""Performs key down presses on the arguments passed in order, then performs
key releases in reverse order.
The effect is that calling hotkey('ctrl', 'shift', 'c') would perform a
"Ctrl-Shift-C" hotkey/keyboard shortcut press.
Args:
key(s) (str): The series of ke... | def hotkey(*args, **kwargs):
"""Performs key down presses on the arguments passed in order, then performs
key releases in reverse order.
The effect is that calling hotkey('ctrl', 'shift', 'c') would perform a
"Ctrl-Shift-C" hotkey/keyboard shortcut press.
Args:
key(s) (str): The series of ke... | [
"Performs",
"key",
"down",
"presses",
"on",
"the",
"arguments",
"passed",
"in",
"order",
"then",
"performs",
"key",
"releases",
"in",
"reverse",
"order",
"."
] | asweigart/pyautogui | python | https://github.com/asweigart/pyautogui/blob/77524bd47334a89024013fd48e05151c3ac9289a/pyautogui/__init__.py#L1067-L1098 | [
"def",
"hotkey",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"interval",
"=",
"float",
"(",
"kwargs",
".",
"get",
"(",
"'interval'",
",",
"0.0",
")",
")",
"_failSafeCheck",
"(",
")",
"for",
"c",
"in",
"args",
":",
"if",
"len",
"(",
"c",
... | 77524bd47334a89024013fd48e05151c3ac9289a |
train | displayMousePosition | This function is meant to be run from the command line. It will
automatically display the location and RGB of the mouse cursor. | pyautogui/__init__.py | def displayMousePosition(xOffset=0, yOffset=0):
"""This function is meant to be run from the command line. It will
automatically display the location and RGB of the mouse cursor."""
print('Press Ctrl-C to quit.')
if xOffset != 0 or yOffset != 0:
print('xOffset: %s yOffset: %s' % (xOffset, yOffse... | def displayMousePosition(xOffset=0, yOffset=0):
"""This function is meant to be run from the command line. It will
automatically display the location and RGB of the mouse cursor."""
print('Press Ctrl-C to quit.')
if xOffset != 0 or yOffset != 0:
print('xOffset: %s yOffset: %s' % (xOffset, yOffse... | [
"This",
"function",
"is",
"meant",
"to",
"be",
"run",
"from",
"the",
"command",
"line",
".",
"It",
"will",
"automatically",
"display",
"the",
"location",
"and",
"RGB",
"of",
"the",
"mouse",
"cursor",
"."
] | asweigart/pyautogui | python | https://github.com/asweigart/pyautogui/blob/77524bd47334a89024013fd48e05151c3ac9289a/pyautogui/__init__.py#L1125-L1149 | [
"def",
"displayMousePosition",
"(",
"xOffset",
"=",
"0",
",",
"yOffset",
"=",
"0",
")",
":",
"print",
"(",
"'Press Ctrl-C to quit.'",
")",
"if",
"xOffset",
"!=",
"0",
"or",
"yOffset",
"!=",
"0",
":",
"print",
"(",
"'xOffset: %s yOffset: %s'",
"%",
"(",
"xO... | 77524bd47334a89024013fd48e05151c3ac9289a |
train | _keyDown | Performs a keyboard key press without the release. This will put that
key in a held down state.
NOTE: For some reason, this does not seem to cause key repeats like would
happen if a keyboard key was held down on a text field.
Args:
key (str): The key to be pressed down. The valid names are liste... | pyautogui/_pyautogui_win.py | def _keyDown(key):
"""Performs a keyboard key press without the release. This will put that
key in a held down state.
NOTE: For some reason, this does not seem to cause key repeats like would
happen if a keyboard key was held down on a text field.
Args:
key (str): The key to be pressed down.... | def _keyDown(key):
"""Performs a keyboard key press without the release. This will put that
key in a held down state.
NOTE: For some reason, this does not seem to cause key repeats like would
happen if a keyboard key was held down on a text field.
Args:
key (str): The key to be pressed down.... | [
"Performs",
"a",
"keyboard",
"key",
"press",
"without",
"the",
"release",
".",
"This",
"will",
"put",
"that",
"key",
"in",
"a",
"held",
"down",
"state",
"."
] | asweigart/pyautogui | python | https://github.com/asweigart/pyautogui/blob/77524bd47334a89024013fd48e05151c3ac9289a/pyautogui/_pyautogui_win.py#L267-L309 | [
"def",
"_keyDown",
"(",
"key",
")",
":",
"if",
"key",
"not",
"in",
"keyboardMapping",
"or",
"keyboardMapping",
"[",
"key",
"]",
"is",
"None",
":",
"return",
"needsShift",
"=",
"pyautogui",
".",
"isShiftCharacter",
"(",
"key",
")",
"\"\"\"\n # OLD CODE: The ... | 77524bd47334a89024013fd48e05151c3ac9289a |
train | _position | Returns the current xy coordinates of the mouse cursor as a two-integer
tuple by calling the GetCursorPos() win32 function.
Returns:
(x, y) tuple of the current xy coordinates of the mouse cursor. | pyautogui/_pyautogui_win.py | def _position():
"""Returns the current xy coordinates of the mouse cursor as a two-integer
tuple by calling the GetCursorPos() win32 function.
Returns:
(x, y) tuple of the current xy coordinates of the mouse cursor.
"""
cursor = POINT()
ctypes.windll.user32.GetCursorPos(ctypes.byref(cur... | def _position():
"""Returns the current xy coordinates of the mouse cursor as a two-integer
tuple by calling the GetCursorPos() win32 function.
Returns:
(x, y) tuple of the current xy coordinates of the mouse cursor.
"""
cursor = POINT()
ctypes.windll.user32.GetCursorPos(ctypes.byref(cur... | [
"Returns",
"the",
"current",
"xy",
"coordinates",
"of",
"the",
"mouse",
"cursor",
"as",
"a",
"two",
"-",
"integer",
"tuple",
"by",
"calling",
"the",
"GetCursorPos",
"()",
"win32",
"function",
"."
] | asweigart/pyautogui | python | https://github.com/asweigart/pyautogui/blob/77524bd47334a89024013fd48e05151c3ac9289a/pyautogui/_pyautogui_win.py#L352-L362 | [
"def",
"_position",
"(",
")",
":",
"cursor",
"=",
"POINT",
"(",
")",
"ctypes",
".",
"windll",
".",
"user32",
".",
"GetCursorPos",
"(",
"ctypes",
".",
"byref",
"(",
"cursor",
")",
")",
"return",
"(",
"cursor",
".",
"x",
",",
"cursor",
".",
"y",
")"
... | 77524bd47334a89024013fd48e05151c3ac9289a |
train | _mouseDown | Send the mouse down event to Windows by calling the mouse_event() win32
function.
Args:
x (int): The x position of the mouse event.
y (int): The y position of the mouse event.
button (str): The mouse button, either 'left', 'middle', or 'right'
Returns:
None | pyautogui/_pyautogui_win.py | def _mouseDown(x, y, button):
"""Send the mouse down event to Windows by calling the mouse_event() win32
function.
Args:
x (int): The x position of the mouse event.
y (int): The y position of the mouse event.
button (str): The mouse button, either 'left', 'middle', or 'right'
Returns... | def _mouseDown(x, y, button):
"""Send the mouse down event to Windows by calling the mouse_event() win32
function.
Args:
x (int): The x position of the mouse event.
y (int): The y position of the mouse event.
button (str): The mouse button, either 'left', 'middle', or 'right'
Returns... | [
"Send",
"the",
"mouse",
"down",
"event",
"to",
"Windows",
"by",
"calling",
"the",
"mouse_event",
"()",
"win32",
"function",
"."
] | asweigart/pyautogui | python | https://github.com/asweigart/pyautogui/blob/77524bd47334a89024013fd48e05151c3ac9289a/pyautogui/_pyautogui_win.py#L389-L417 | [
"def",
"_mouseDown",
"(",
"x",
",",
"y",
",",
"button",
")",
":",
"if",
"button",
"==",
"'left'",
":",
"try",
":",
"_sendMouseEvent",
"(",
"MOUSEEVENTF_LEFTDOWN",
",",
"x",
",",
"y",
")",
"except",
"(",
"PermissionError",
",",
"OSError",
")",
":",
"# T... | 77524bd47334a89024013fd48e05151c3ac9289a |
train | _mouseUp | Send the mouse up event to Windows by calling the mouse_event() win32
function.
Args:
x (int): The x position of the mouse event.
y (int): The y position of the mouse event.
button (str): The mouse button, either 'left', 'middle', or 'right'
Returns:
None | pyautogui/_pyautogui_win.py | def _mouseUp(x, y, button):
"""Send the mouse up event to Windows by calling the mouse_event() win32
function.
Args:
x (int): The x position of the mouse event.
y (int): The y position of the mouse event.
button (str): The mouse button, either 'left', 'middle', or 'right'
Returns:
... | def _mouseUp(x, y, button):
"""Send the mouse up event to Windows by calling the mouse_event() win32
function.
Args:
x (int): The x position of the mouse event.
y (int): The y position of the mouse event.
button (str): The mouse button, either 'left', 'middle', or 'right'
Returns:
... | [
"Send",
"the",
"mouse",
"up",
"event",
"to",
"Windows",
"by",
"calling",
"the",
"mouse_event",
"()",
"win32",
"function",
"."
] | asweigart/pyautogui | python | https://github.com/asweigart/pyautogui/blob/77524bd47334a89024013fd48e05151c3ac9289a/pyautogui/_pyautogui_win.py#L420-L448 | [
"def",
"_mouseUp",
"(",
"x",
",",
"y",
",",
"button",
")",
":",
"if",
"button",
"==",
"'left'",
":",
"try",
":",
"_sendMouseEvent",
"(",
"MOUSEEVENTF_LEFTUP",
",",
"x",
",",
"y",
")",
"except",
"(",
"PermissionError",
",",
"OSError",
")",
":",
"# TODO:... | 77524bd47334a89024013fd48e05151c3ac9289a |
train | _click | Send the mouse click event to Windows by calling the mouse_event() win32
function.
Args:
button (str): The mouse button, either 'left', 'middle', or 'right'
x (int): The x position of the mouse event.
y (int): The y position of the mouse event.
Returns:
None | pyautogui/_pyautogui_win.py | def _click(x, y, button):
"""Send the mouse click event to Windows by calling the mouse_event() win32
function.
Args:
button (str): The mouse button, either 'left', 'middle', or 'right'
x (int): The x position of the mouse event.
y (int): The y position of the mouse event.
Returns:
... | def _click(x, y, button):
"""Send the mouse click event to Windows by calling the mouse_event() win32
function.
Args:
button (str): The mouse button, either 'left', 'middle', or 'right'
x (int): The x position of the mouse event.
y (int): The y position of the mouse event.
Returns:
... | [
"Send",
"the",
"mouse",
"click",
"event",
"to",
"Windows",
"by",
"calling",
"the",
"mouse_event",
"()",
"win32",
"function",
"."
] | asweigart/pyautogui | python | https://github.com/asweigart/pyautogui/blob/77524bd47334a89024013fd48e05151c3ac9289a/pyautogui/_pyautogui_win.py#L451-L479 | [
"def",
"_click",
"(",
"x",
",",
"y",
",",
"button",
")",
":",
"if",
"button",
"==",
"'left'",
":",
"try",
":",
"_sendMouseEvent",
"(",
"MOUSEEVENTF_LEFTCLICK",
",",
"x",
",",
"y",
")",
"except",
"(",
"PermissionError",
",",
"OSError",
")",
":",
"# TODO... | 77524bd47334a89024013fd48e05151c3ac9289a |
train | _sendMouseEvent | The helper function that actually makes the call to the mouse_event()
win32 function.
Args:
ev (int): The win32 code for the mouse event. Use one of the MOUSEEVENTF_*
constants for this argument.
x (int): The x position of the mouse event.
y (int): The y position of the mouse event.
... | pyautogui/_pyautogui_win.py | def _sendMouseEvent(ev, x, y, dwData=0):
"""The helper function that actually makes the call to the mouse_event()
win32 function.
Args:
ev (int): The win32 code for the mouse event. Use one of the MOUSEEVENTF_*
constants for this argument.
x (int): The x position of the mouse event.
... | def _sendMouseEvent(ev, x, y, dwData=0):
"""The helper function that actually makes the call to the mouse_event()
win32 function.
Args:
ev (int): The win32 code for the mouse event. Use one of the MOUSEEVENTF_*
constants for this argument.
x (int): The x position of the mouse event.
... | [
"The",
"helper",
"function",
"that",
"actually",
"makes",
"the",
"call",
"to",
"the",
"mouse_event",
"()",
"win32",
"function",
"."
] | asweigart/pyautogui | python | https://github.com/asweigart/pyautogui/blob/77524bd47334a89024013fd48e05151c3ac9289a/pyautogui/_pyautogui_win.py#L482-L513 | [
"def",
"_sendMouseEvent",
"(",
"ev",
",",
"x",
",",
"y",
",",
"dwData",
"=",
"0",
")",
":",
"assert",
"x",
"!=",
"None",
"and",
"y",
"!=",
"None",
",",
"'x and y cannot be set to None'",
"# TODO: ARG! For some reason, SendInput isn't working for mouse events. I'm swit... | 77524bd47334a89024013fd48e05151c3ac9289a |
train | _scroll | Send the mouse vertical scroll event to Windows by calling the
mouse_event() win32 function.
Args:
clicks (int): The amount of scrolling to do. A positive value is the mouse
wheel moving forward (scrolling up), a negative value is backwards (down).
x (int): The x position of the mouse event.
... | pyautogui/_pyautogui_win.py | def _scroll(clicks, x=None, y=None):
"""Send the mouse vertical scroll event to Windows by calling the
mouse_event() win32 function.
Args:
clicks (int): The amount of scrolling to do. A positive value is the mouse
wheel moving forward (scrolling up), a negative value is backwards (down).
... | def _scroll(clicks, x=None, y=None):
"""Send the mouse vertical scroll event to Windows by calling the
mouse_event() win32 function.
Args:
clicks (int): The amount of scrolling to do. A positive value is the mouse
wheel moving forward (scrolling up), a negative value is backwards (down).
... | [
"Send",
"the",
"mouse",
"vertical",
"scroll",
"event",
"to",
"Windows",
"by",
"calling",
"the",
"mouse_event",
"()",
"win32",
"function",
"."
] | asweigart/pyautogui | python | https://github.com/asweigart/pyautogui/blob/77524bd47334a89024013fd48e05151c3ac9289a/pyautogui/_pyautogui_win.py#L520-L554 | [
"def",
"_scroll",
"(",
"clicks",
",",
"x",
"=",
"None",
",",
"y",
"=",
"None",
")",
":",
"startx",
",",
"starty",
"=",
"_position",
"(",
")",
"width",
",",
"height",
"=",
"_size",
"(",
")",
"if",
"x",
"is",
"None",
":",
"x",
"=",
"startx",
"els... | 77524bd47334a89024013fd48e05151c3ac9289a |
train | authorize | Login to Google API using OAuth2 credentials.
This is a shortcut function which
instantiates :class:`gspread.client.Client`
and performs login right away.
:returns: :class:`gspread.Client` instance. | gspread/__init__.py | def authorize(credentials, client_class=Client):
"""Login to Google API using OAuth2 credentials.
This is a shortcut function which
instantiates :class:`gspread.client.Client`
and performs login right away.
:returns: :class:`gspread.Client` instance.
"""
client = client_class(auth=credentia... | def authorize(credentials, client_class=Client):
"""Login to Google API using OAuth2 credentials.
This is a shortcut function which
instantiates :class:`gspread.client.Client`
and performs login right away.
:returns: :class:`gspread.Client` instance.
"""
client = client_class(auth=credentia... | [
"Login",
"to",
"Google",
"API",
"using",
"OAuth2",
"credentials",
".",
"This",
"is",
"a",
"shortcut",
"function",
"which",
"instantiates",
":",
"class",
":",
"gspread",
".",
"client",
".",
"Client",
"and",
"performs",
"login",
"right",
"away",
"."
] | burnash/gspread | python | https://github.com/burnash/gspread/blob/0e8debe208095aeed3e3e7136c2fa5cd74090946/gspread/__init__.py#L29-L39 | [
"def",
"authorize",
"(",
"credentials",
",",
"client_class",
"=",
"Client",
")",
":",
"client",
"=",
"client_class",
"(",
"auth",
"=",
"credentials",
")",
"client",
".",
"login",
"(",
")",
"return",
"client"
] | 0e8debe208095aeed3e3e7136c2fa5cd74090946 |
train | Spreadsheet.title | Spreadsheet title. | gspread/models.py | def title(self):
"""Spreadsheet title."""
try:
return self._properties['title']
except KeyError:
metadata = self.fetch_sheet_metadata()
self._properties.update(metadata['properties'])
return self._properties['title'] | def title(self):
"""Spreadsheet title."""
try:
return self._properties['title']
except KeyError:
metadata = self.fetch_sheet_metadata()
self._properties.update(metadata['properties'])
return self._properties['title'] | [
"Spreadsheet",
"title",
"."
] | burnash/gspread | python | https://github.com/burnash/gspread/blob/0e8debe208095aeed3e3e7136c2fa5cd74090946/gspread/models.py#L50-L57 | [
"def",
"title",
"(",
"self",
")",
":",
"try",
":",
"return",
"self",
".",
"_properties",
"[",
"'title'",
"]",
"except",
"KeyError",
":",
"metadata",
"=",
"self",
".",
"fetch_sheet_metadata",
"(",
")",
"self",
".",
"_properties",
".",
"update",
"(",
"meta... | 0e8debe208095aeed3e3e7136c2fa5cd74090946 |
train | Spreadsheet.batch_update | Lower-level method that directly calls `spreadsheets.batchUpdate <https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/batchUpdate>`_.
:param dict body: `Request body <https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/batchUpdate#request-body>`_.
:returns: `Resp... | gspread/models.py | def batch_update(self, body):
"""Lower-level method that directly calls `spreadsheets.batchUpdate <https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/batchUpdate>`_.
:param dict body: `Request body <https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/batchUpdate... | def batch_update(self, body):
"""Lower-level method that directly calls `spreadsheets.batchUpdate <https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/batchUpdate>`_.
:param dict body: `Request body <https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/batchUpdate... | [
"Lower",
"-",
"level",
"method",
"that",
"directly",
"calls",
"spreadsheets",
".",
"batchUpdate",
"<https",
":",
"//",
"developers",
".",
"google",
".",
"com",
"/",
"sheets",
"/",
"api",
"/",
"reference",
"/",
"rest",
"/",
"v4",
"/",
"spreadsheets",
"/",
... | burnash/gspread | python | https://github.com/burnash/gspread/blob/0e8debe208095aeed3e3e7136c2fa5cd74090946/gspread/models.py#L87-L103 | [
"def",
"batch_update",
"(",
"self",
",",
"body",
")",
":",
"r",
"=",
"self",
".",
"client",
".",
"request",
"(",
"'post'",
",",
"SPREADSHEET_BATCH_UPDATE_URL",
"%",
"self",
".",
"id",
",",
"json",
"=",
"body",
")",
"return",
"r",
".",
"json",
"(",
")... | 0e8debe208095aeed3e3e7136c2fa5cd74090946 |
train | Spreadsheet.values_append | Lower-level method that directly calls `spreadsheets.values.append <https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/append>`_.
:param str range: The `A1 notation <https://developers.google.com/sheets/api/guides/concepts#a1_notation>`_
of a range to searc... | gspread/models.py | def values_append(self, range, params, body):
"""Lower-level method that directly calls `spreadsheets.values.append <https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/append>`_.
:param str range: The `A1 notation <https://developers.google.com/sheets/api/guides/concepts#a1_... | def values_append(self, range, params, body):
"""Lower-level method that directly calls `spreadsheets.values.append <https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/append>`_.
:param str range: The `A1 notation <https://developers.google.com/sheets/api/guides/concepts#a1_... | [
"Lower",
"-",
"level",
"method",
"that",
"directly",
"calls",
"spreadsheets",
".",
"values",
".",
"append",
"<https",
":",
"//",
"developers",
".",
"google",
".",
"com",
"/",
"sheets",
"/",
"api",
"/",
"reference",
"/",
"rest",
"/",
"v4",
"/",
"spreadshe... | burnash/gspread | python | https://github.com/burnash/gspread/blob/0e8debe208095aeed3e3e7136c2fa5cd74090946/gspread/models.py#L105-L120 | [
"def",
"values_append",
"(",
"self",
",",
"range",
",",
"params",
",",
"body",
")",
":",
"url",
"=",
"SPREADSHEET_VALUES_APPEND_URL",
"%",
"(",
"self",
".",
"id",
",",
"quote",
"(",
"range",
")",
")",
"r",
"=",
"self",
".",
"client",
".",
"request",
... | 0e8debe208095aeed3e3e7136c2fa5cd74090946 |
train | Spreadsheet.values_clear | Lower-level method that directly calls `spreadsheets.values.clear <https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/clear>`_.
:param str range: The `A1 notation <https://developers.google.com/sheets/api/guides/concepts#a1_notation>`_ of the values to clear.
:returns: `Resp... | gspread/models.py | def values_clear(self, range):
"""Lower-level method that directly calls `spreadsheets.values.clear <https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/clear>`_.
:param str range: The `A1 notation <https://developers.google.com/sheets/api/guides/concepts#a1_notation>`_ of th... | def values_clear(self, range):
"""Lower-level method that directly calls `spreadsheets.values.clear <https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/clear>`_.
:param str range: The `A1 notation <https://developers.google.com/sheets/api/guides/concepts#a1_notation>`_ of th... | [
"Lower",
"-",
"level",
"method",
"that",
"directly",
"calls",
"spreadsheets",
".",
"values",
".",
"clear",
"<https",
":",
"//",
"developers",
".",
"google",
".",
"com",
"/",
"sheets",
"/",
"api",
"/",
"reference",
"/",
"rest",
"/",
"v4",
"/",
"spreadshee... | burnash/gspread | python | https://github.com/burnash/gspread/blob/0e8debe208095aeed3e3e7136c2fa5cd74090946/gspread/models.py#L122-L134 | [
"def",
"values_clear",
"(",
"self",
",",
"range",
")",
":",
"url",
"=",
"SPREADSHEET_VALUES_CLEAR_URL",
"%",
"(",
"self",
".",
"id",
",",
"quote",
"(",
"range",
")",
")",
"r",
"=",
"self",
".",
"client",
".",
"request",
"(",
"'post'",
",",
"url",
")"... | 0e8debe208095aeed3e3e7136c2fa5cd74090946 |
train | Spreadsheet.values_get | Lower-level method that directly calls `spreadsheets.values.get <https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/get>`_.
:param str range: The `A1 notation <https://developers.google.com/sheets/api/guides/concepts#a1_notation>`_ of the values to retrieve.
:param dict para... | gspread/models.py | def values_get(self, range, params=None):
"""Lower-level method that directly calls `spreadsheets.values.get <https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/get>`_.
:param str range: The `A1 notation <https://developers.google.com/sheets/api/guides/concepts#a1_notation>`... | def values_get(self, range, params=None):
"""Lower-level method that directly calls `spreadsheets.values.get <https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/get>`_.
:param str range: The `A1 notation <https://developers.google.com/sheets/api/guides/concepts#a1_notation>`... | [
"Lower",
"-",
"level",
"method",
"that",
"directly",
"calls",
"spreadsheets",
".",
"values",
".",
"get",
"<https",
":",
"//",
"developers",
".",
"google",
".",
"com",
"/",
"sheets",
"/",
"api",
"/",
"reference",
"/",
"rest",
"/",
"v4",
"/",
"spreadsheets... | burnash/gspread | python | https://github.com/burnash/gspread/blob/0e8debe208095aeed3e3e7136c2fa5cd74090946/gspread/models.py#L136-L149 | [
"def",
"values_get",
"(",
"self",
",",
"range",
",",
"params",
"=",
"None",
")",
":",
"url",
"=",
"SPREADSHEET_VALUES_URL",
"%",
"(",
"self",
".",
"id",
",",
"quote",
"(",
"range",
")",
")",
"r",
"=",
"self",
".",
"client",
".",
"request",
"(",
"'g... | 0e8debe208095aeed3e3e7136c2fa5cd74090946 |
train | Spreadsheet.values_update | Lower-level method that directly calls `spreadsheets.values.update <https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/update>`_.
:param str range: The `A1 notation <https://developers.google.com/sheets/api/guides/concepts#a1_notation>`_ of the values to update.
:param dict ... | gspread/models.py | def values_update(self, range, params=None, body=None):
"""Lower-level method that directly calls `spreadsheets.values.update <https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/update>`_.
:param str range: The `A1 notation <https://developers.google.com/sheets/api/guides/co... | def values_update(self, range, params=None, body=None):
"""Lower-level method that directly calls `spreadsheets.values.update <https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/update>`_.
:param str range: The `A1 notation <https://developers.google.com/sheets/api/guides/co... | [
"Lower",
"-",
"level",
"method",
"that",
"directly",
"calls",
"spreadsheets",
".",
"values",
".",
"update",
"<https",
":",
"//",
"developers",
".",
"google",
".",
"com",
"/",
"sheets",
"/",
"api",
"/",
"reference",
"/",
"rest",
"/",
"v4",
"/",
"spreadshe... | burnash/gspread | python | https://github.com/burnash/gspread/blob/0e8debe208095aeed3e3e7136c2fa5cd74090946/gspread/models.py#L151-L177 | [
"def",
"values_update",
"(",
"self",
",",
"range",
",",
"params",
"=",
"None",
",",
"body",
"=",
"None",
")",
":",
"url",
"=",
"SPREADSHEET_VALUES_URL",
"%",
"(",
"self",
".",
"id",
",",
"quote",
"(",
"range",
")",
")",
"r",
"=",
"self",
".",
"clie... | 0e8debe208095aeed3e3e7136c2fa5cd74090946 |
train | Spreadsheet.get_worksheet | Returns a worksheet with specified `index`.
:param index: An index of a worksheet. Indexes start from zero.
:type index: int
:returns: an instance of :class:`gsperad.models.Worksheet`
or `None` if the worksheet is not found.
Example. To get first worksheet of a sprea... | gspread/models.py | def get_worksheet(self, index):
"""Returns a worksheet with specified `index`.
:param index: An index of a worksheet. Indexes start from zero.
:type index: int
:returns: an instance of :class:`gsperad.models.Worksheet`
or `None` if the worksheet is not found.
... | def get_worksheet(self, index):
"""Returns a worksheet with specified `index`.
:param index: An index of a worksheet. Indexes start from zero.
:type index: int
:returns: an instance of :class:`gsperad.models.Worksheet`
or `None` if the worksheet is not found.
... | [
"Returns",
"a",
"worksheet",
"with",
"specified",
"index",
"."
] | burnash/gspread | python | https://github.com/burnash/gspread/blob/0e8debe208095aeed3e3e7136c2fa5cd74090946/gspread/models.py#L188-L209 | [
"def",
"get_worksheet",
"(",
"self",
",",
"index",
")",
":",
"sheet_data",
"=",
"self",
".",
"fetch_sheet_metadata",
"(",
")",
"try",
":",
"properties",
"=",
"sheet_data",
"[",
"'sheets'",
"]",
"[",
"index",
"]",
"[",
"'properties'",
"]",
"return",
"Worksh... | 0e8debe208095aeed3e3e7136c2fa5cd74090946 |
train | Spreadsheet.worksheets | Returns a list of all :class:`worksheets <gsperad.models.Worksheet>`
in a spreadsheet. | gspread/models.py | def worksheets(self):
"""Returns a list of all :class:`worksheets <gsperad.models.Worksheet>`
in a spreadsheet.
"""
sheet_data = self.fetch_sheet_metadata()
return [Worksheet(self, x['properties']) for x in sheet_data['sheets']] | def worksheets(self):
"""Returns a list of all :class:`worksheets <gsperad.models.Worksheet>`
in a spreadsheet.
"""
sheet_data = self.fetch_sheet_metadata()
return [Worksheet(self, x['properties']) for x in sheet_data['sheets']] | [
"Returns",
"a",
"list",
"of",
"all",
":",
"class",
":",
"worksheets",
"<gsperad",
".",
"models",
".",
"Worksheet",
">",
"in",
"a",
"spreadsheet",
"."
] | burnash/gspread | python | https://github.com/burnash/gspread/blob/0e8debe208095aeed3e3e7136c2fa5cd74090946/gspread/models.py#L211-L217 | [
"def",
"worksheets",
"(",
"self",
")",
":",
"sheet_data",
"=",
"self",
".",
"fetch_sheet_metadata",
"(",
")",
"return",
"[",
"Worksheet",
"(",
"self",
",",
"x",
"[",
"'properties'",
"]",
")",
"for",
"x",
"in",
"sheet_data",
"[",
"'sheets'",
"]",
"]"
] | 0e8debe208095aeed3e3e7136c2fa5cd74090946 |
train | Spreadsheet.worksheet | Returns a worksheet with specified `title`.
:param title: A title of a worksheet. If there're multiple
worksheets with the same title, first one will
be returned.
:type title: int
:returns: an instance of :class:`gsperad.models.Worksheet`.
E... | gspread/models.py | def worksheet(self, title):
"""Returns a worksheet with specified `title`.
:param title: A title of a worksheet. If there're multiple
worksheets with the same title, first one will
be returned.
:type title: int
:returns: an instance of :class... | def worksheet(self, title):
"""Returns a worksheet with specified `title`.
:param title: A title of a worksheet. If there're multiple
worksheets with the same title, first one will
be returned.
:type title: int
:returns: an instance of :class... | [
"Returns",
"a",
"worksheet",
"with",
"specified",
"title",
"."
] | burnash/gspread | python | https://github.com/burnash/gspread/blob/0e8debe208095aeed3e3e7136c2fa5cd74090946/gspread/models.py#L219-L243 | [
"def",
"worksheet",
"(",
"self",
",",
"title",
")",
":",
"sheet_data",
"=",
"self",
".",
"fetch_sheet_metadata",
"(",
")",
"try",
":",
"item",
"=",
"finditem",
"(",
"lambda",
"x",
":",
"x",
"[",
"'properties'",
"]",
"[",
"'title'",
"]",
"==",
"title",
... | 0e8debe208095aeed3e3e7136c2fa5cd74090946 |
train | Spreadsheet.add_worksheet | Adds a new worksheet to a spreadsheet.
:param title: A title of a new worksheet.
:type title: str
:param rows: Number of rows.
:type rows: int
:param cols: Number of columns.
:type cols: int
:returns: a newly created :class:`worksheets <gsperad.models.Worksheet>... | gspread/models.py | def add_worksheet(self, title, rows, cols):
"""Adds a new worksheet to a spreadsheet.
:param title: A title of a new worksheet.
:type title: str
:param rows: Number of rows.
:type rows: int
:param cols: Number of columns.
:type cols: int
:returns: a newl... | def add_worksheet(self, title, rows, cols):
"""Adds a new worksheet to a spreadsheet.
:param title: A title of a new worksheet.
:type title: str
:param rows: Number of rows.
:type rows: int
:param cols: Number of columns.
:type cols: int
:returns: a newl... | [
"Adds",
"a",
"new",
"worksheet",
"to",
"a",
"spreadsheet",
"."
] | burnash/gspread | python | https://github.com/burnash/gspread/blob/0e8debe208095aeed3e3e7136c2fa5cd74090946/gspread/models.py#L245-L278 | [
"def",
"add_worksheet",
"(",
"self",
",",
"title",
",",
"rows",
",",
"cols",
")",
":",
"body",
"=",
"{",
"'requests'",
":",
"[",
"{",
"'addSheet'",
":",
"{",
"'properties'",
":",
"{",
"'title'",
":",
"title",
",",
"'sheetType'",
":",
"'GRID'",
",",
"... | 0e8debe208095aeed3e3e7136c2fa5cd74090946 |
train | Spreadsheet.duplicate_sheet | Duplicates the contents of a sheet.
:param int source_sheet_id: The sheet ID to duplicate.
:param int insert_sheet_index: (optional) The zero-based index
where the new sheet should be inserted.
The index of all sheets after t... | gspread/models.py | def duplicate_sheet(
self,
source_sheet_id,
insert_sheet_index=None,
new_sheet_id=None,
new_sheet_name=None
):
"""Duplicates the contents of a sheet.
:param int source_sheet_id: The sheet ID to duplicate.
:param int insert_sheet_index: (optional) The ... | def duplicate_sheet(
self,
source_sheet_id,
insert_sheet_index=None,
new_sheet_id=None,
new_sheet_name=None
):
"""Duplicates the contents of a sheet.
:param int source_sheet_id: The sheet ID to duplicate.
:param int insert_sheet_index: (optional) The ... | [
"Duplicates",
"the",
"contents",
"of",
"a",
"sheet",
"."
] | burnash/gspread | python | https://github.com/burnash/gspread/blob/0e8debe208095aeed3e3e7136c2fa5cd74090946/gspread/models.py#L280-L323 | [
"def",
"duplicate_sheet",
"(",
"self",
",",
"source_sheet_id",
",",
"insert_sheet_index",
"=",
"None",
",",
"new_sheet_id",
"=",
"None",
",",
"new_sheet_name",
"=",
"None",
")",
":",
"body",
"=",
"{",
"'requests'",
":",
"[",
"{",
"'duplicateSheet'",
":",
"{"... | 0e8debe208095aeed3e3e7136c2fa5cd74090946 |
train | Spreadsheet.share | Share the spreadsheet with other accounts.
:param value: user or group e-mail address, domain name
or None for 'default' type.
:type value: str, None
:param perm_type: The account type.
Allowed values are: ``user``, ``group``, ``domain``,
``an... | gspread/models.py | def share(self, value, perm_type, role, notify=True, email_message=None, with_link=False):
"""Share the spreadsheet with other accounts.
:param value: user or group e-mail address, domain name
or None for 'default' type.
:type value: str, None
:param perm_type: The... | def share(self, value, perm_type, role, notify=True, email_message=None, with_link=False):
"""Share the spreadsheet with other accounts.
:param value: user or group e-mail address, domain name
or None for 'default' type.
:type value: str, None
:param perm_type: The... | [
"Share",
"the",
"spreadsheet",
"with",
"other",
"accounts",
"."
] | burnash/gspread | python | https://github.com/burnash/gspread/blob/0e8debe208095aeed3e3e7136c2fa5cd74090946/gspread/models.py#L340-L378 | [
"def",
"share",
"(",
"self",
",",
"value",
",",
"perm_type",
",",
"role",
",",
"notify",
"=",
"True",
",",
"email_message",
"=",
"None",
",",
"with_link",
"=",
"False",
")",
":",
"self",
".",
"client",
".",
"insert_permission",
"(",
"self",
".",
"id",
... | 0e8debe208095aeed3e3e7136c2fa5cd74090946 |
train | Spreadsheet.remove_permissions | Remove permissions from a user or domain.
:param value: User or domain to remove permissions from
:type value: str
:param role: (optional) Permission to remove. Defaults to all
permissions.
:type role: str
Example::
# Remove Otto's write permis... | gspread/models.py | def remove_permissions(self, value, role='any'):
"""Remove permissions from a user or domain.
:param value: User or domain to remove permissions from
:type value: str
:param role: (optional) Permission to remove. Defaults to all
permissions.
:type role: str
... | def remove_permissions(self, value, role='any'):
"""Remove permissions from a user or domain.
:param value: User or domain to remove permissions from
:type value: str
:param role: (optional) Permission to remove. Defaults to all
permissions.
:type role: str
... | [
"Remove",
"permissions",
"from",
"a",
"user",
"or",
"domain",
"."
] | burnash/gspread | python | https://github.com/burnash/gspread/blob/0e8debe208095aeed3e3e7136c2fa5cd74090946/gspread/models.py#L385-L414 | [
"def",
"remove_permissions",
"(",
"self",
",",
"value",
",",
"role",
"=",
"'any'",
")",
":",
"permission_list",
"=",
"self",
".",
"client",
".",
"list_permissions",
"(",
"self",
".",
"id",
")",
"key",
"=",
"'emailAddress'",
"if",
"'@'",
"in",
"value",
"e... | 0e8debe208095aeed3e3e7136c2fa5cd74090946 |
train | Worksheet.acell | Returns an instance of a :class:`gspread.models.Cell`.
:param label: Cell label in A1 notation
Letter case is ignored.
:type label: str
:param value_render_option: (optional) Determines how values should be
rendered in the the output. Se... | gspread/models.py | def acell(self, label, value_render_option='FORMATTED_VALUE'):
"""Returns an instance of a :class:`gspread.models.Cell`.
:param label: Cell label in A1 notation
Letter case is ignored.
:type label: str
:param value_render_option: (optional) Determines how values sh... | def acell(self, label, value_render_option='FORMATTED_VALUE'):
"""Returns an instance of a :class:`gspread.models.Cell`.
:param label: Cell label in A1 notation
Letter case is ignored.
:type label: str
:param value_render_option: (optional) Determines how values sh... | [
"Returns",
"an",
"instance",
"of",
"a",
":",
"class",
":",
"gspread",
".",
"models",
".",
"Cell",
"."
] | burnash/gspread | python | https://github.com/burnash/gspread/blob/0e8debe208095aeed3e3e7136c2fa5cd74090946/gspread/models.py#L467-L490 | [
"def",
"acell",
"(",
"self",
",",
"label",
",",
"value_render_option",
"=",
"'FORMATTED_VALUE'",
")",
":",
"return",
"self",
".",
"cell",
"(",
"*",
"(",
"a1_to_rowcol",
"(",
"label",
")",
")",
",",
"value_render_option",
"=",
"value_render_option",
")"
] | 0e8debe208095aeed3e3e7136c2fa5cd74090946 |
train | Worksheet.cell | Returns an instance of a :class:`gspread.models.Cell` located at
`row` and `col` column.
:param row: Row number.
:type row: int
:param col: Column number.
:type col: int
:param value_render_option: (optional) Determines how values should be
... | gspread/models.py | def cell(self, row, col, value_render_option='FORMATTED_VALUE'):
"""Returns an instance of a :class:`gspread.models.Cell` located at
`row` and `col` column.
:param row: Row number.
:type row: int
:param col: Column number.
:type col: int
:param value_render_optio... | def cell(self, row, col, value_render_option='FORMATTED_VALUE'):
"""Returns an instance of a :class:`gspread.models.Cell` located at
`row` and `col` column.
:param row: Row number.
:type row: int
:param col: Column number.
:type col: int
:param value_render_optio... | [
"Returns",
"an",
"instance",
"of",
"a",
":",
"class",
":",
"gspread",
".",
"models",
".",
"Cell",
"located",
"at",
"row",
"and",
"col",
"column",
"."
] | burnash/gspread | python | https://github.com/burnash/gspread/blob/0e8debe208095aeed3e3e7136c2fa5cd74090946/gspread/models.py#L492-L525 | [
"def",
"cell",
"(",
"self",
",",
"row",
",",
"col",
",",
"value_render_option",
"=",
"'FORMATTED_VALUE'",
")",
":",
"range_label",
"=",
"'%s!%s'",
"%",
"(",
"self",
".",
"title",
",",
"rowcol_to_a1",
"(",
"row",
",",
"col",
")",
")",
"data",
"=",
"self... | 0e8debe208095aeed3e3e7136c2fa5cd74090946 |
train | Worksheet.range | Returns a list of :class:`Cell` objects from a specified range.
:param name: A string with range value in A1 notation, e.g. 'A1:A5'.
:type name: str
Alternatively, you may specify numeric boundaries. All values
index from 1 (one):
:param first_row: Row number
:type fir... | gspread/models.py | def range(self, name):
"""Returns a list of :class:`Cell` objects from a specified range.
:param name: A string with range value in A1 notation, e.g. 'A1:A5'.
:type name: str
Alternatively, you may specify numeric boundaries. All values
index from 1 (one):
:param first... | def range(self, name):
"""Returns a list of :class:`Cell` objects from a specified range.
:param name: A string with range value in A1 notation, e.g. 'A1:A5'.
:type name: str
Alternatively, you may specify numeric boundaries. All values
index from 1 (one):
:param first... | [
"Returns",
"a",
"list",
"of",
":",
"class",
":",
"Cell",
"objects",
"from",
"a",
"specified",
"range",
"."
] | burnash/gspread | python | https://github.com/burnash/gspread/blob/0e8debe208095aeed3e3e7136c2fa5cd74090946/gspread/models.py#L528-L578 | [
"def",
"range",
"(",
"self",
",",
"name",
")",
":",
"range_label",
"=",
"'%s!%s'",
"%",
"(",
"self",
".",
"title",
",",
"name",
")",
"data",
"=",
"self",
".",
"spreadsheet",
".",
"values_get",
"(",
"range_label",
")",
"start",
",",
"end",
"=",
"name"... | 0e8debe208095aeed3e3e7136c2fa5cd74090946 |
train | Worksheet.get_all_values | Returns a list of lists containing all cells' values as strings.
.. note::
Empty trailing rows and columns will not be included. | gspread/models.py | def get_all_values(self):
"""Returns a list of lists containing all cells' values as strings.
.. note::
Empty trailing rows and columns will not be included.
"""
data = self.spreadsheet.values_get(self.title)
try:
return fill_gaps(data['values'])
... | def get_all_values(self):
"""Returns a list of lists containing all cells' values as strings.
.. note::
Empty trailing rows and columns will not be included.
"""
data = self.spreadsheet.values_get(self.title)
try:
return fill_gaps(data['values'])
... | [
"Returns",
"a",
"list",
"of",
"lists",
"containing",
"all",
"cells",
"values",
"as",
"strings",
"."
] | burnash/gspread | python | https://github.com/burnash/gspread/blob/0e8debe208095aeed3e3e7136c2fa5cd74090946/gspread/models.py#L580-L593 | [
"def",
"get_all_values",
"(",
"self",
")",
":",
"data",
"=",
"self",
".",
"spreadsheet",
".",
"values_get",
"(",
"self",
".",
"title",
")",
"try",
":",
"return",
"fill_gaps",
"(",
"data",
"[",
"'values'",
"]",
")",
"except",
"KeyError",
":",
"return",
... | 0e8debe208095aeed3e3e7136c2fa5cd74090946 |
train | Worksheet.get_all_records | Returns a list of dictionaries, all of them having the contents
of the spreadsheet with the head row as keys and each of these
dictionaries holding the contents of subsequent rows of cells
as values.
Cell values are numericised (strings that can be read as ints
... | gspread/models.py | def get_all_records(
self,
empty2zero=False,
head=1,
default_blank="",
allow_underscores_in_numeric_literals=False,
):
"""Returns a list of dictionaries, all of them having the contents
of the spreadsheet with the head row as keys and each of these
... | def get_all_records(
self,
empty2zero=False,
head=1,
default_blank="",
allow_underscores_in_numeric_literals=False,
):
"""Returns a list of dictionaries, all of them having the contents
of the spreadsheet with the head row as keys and each of these
... | [
"Returns",
"a",
"list",
"of",
"dictionaries",
"all",
"of",
"them",
"having",
"the",
"contents",
"of",
"the",
"spreadsheet",
"with",
"the",
"head",
"row",
"as",
"keys",
"and",
"each",
"of",
"these",
"dictionaries",
"holding",
"the",
"contents",
"of",
"subsequ... | burnash/gspread | python | https://github.com/burnash/gspread/blob/0e8debe208095aeed3e3e7136c2fa5cd74090946/gspread/models.py#L595-L645 | [
"def",
"get_all_records",
"(",
"self",
",",
"empty2zero",
"=",
"False",
",",
"head",
"=",
"1",
",",
"default_blank",
"=",
"\"\"",
",",
"allow_underscores_in_numeric_literals",
"=",
"False",
",",
")",
":",
"idx",
"=",
"head",
"-",
"1",
"data",
"=",
"self",
... | 0e8debe208095aeed3e3e7136c2fa5cd74090946 |
train | Worksheet.row_values | Returns a list of all values in a `row`.
Empty cells in this list will be rendered as :const:`None`.
:param row: Row number.
:type row: int
:param value_render_option: (optional) Determines how values should be
rendered in the the output. See
... | gspread/models.py | def row_values(self, row, value_render_option='FORMATTED_VALUE'):
"""Returns a list of all values in a `row`.
Empty cells in this list will be rendered as :const:`None`.
:param row: Row number.
:type row: int
:param value_render_option: (optional) Determines how values should b... | def row_values(self, row, value_render_option='FORMATTED_VALUE'):
"""Returns a list of all values in a `row`.
Empty cells in this list will be rendered as :const:`None`.
:param row: Row number.
:type row: int
:param value_render_option: (optional) Determines how values should b... | [
"Returns",
"a",
"list",
"of",
"all",
"values",
"in",
"a",
"row",
"."
] | burnash/gspread | python | https://github.com/burnash/gspread/blob/0e8debe208095aeed3e3e7136c2fa5cd74090946/gspread/models.py#L647-L673 | [
"def",
"row_values",
"(",
"self",
",",
"row",
",",
"value_render_option",
"=",
"'FORMATTED_VALUE'",
")",
":",
"range_label",
"=",
"'%s!A%s:%s'",
"%",
"(",
"self",
".",
"title",
",",
"row",
",",
"row",
")",
"data",
"=",
"self",
".",
"spreadsheet",
".",
"v... | 0e8debe208095aeed3e3e7136c2fa5cd74090946 |
train | Worksheet.col_values | Returns a list of all values in column `col`.
Empty cells in this list will be rendered as :const:`None`.
:param col: Column number.
:type col: int
:param value_render_option: (optional) Determines how values should be
rendered in the the output. See... | gspread/models.py | def col_values(self, col, value_render_option='FORMATTED_VALUE'):
"""Returns a list of all values in column `col`.
Empty cells in this list will be rendered as :const:`None`.
:param col: Column number.
:type col: int
:param value_render_option: (optional) Determines how values ... | def col_values(self, col, value_render_option='FORMATTED_VALUE'):
"""Returns a list of all values in column `col`.
Empty cells in this list will be rendered as :const:`None`.
:param col: Column number.
:type col: int
:param value_render_option: (optional) Determines how values ... | [
"Returns",
"a",
"list",
"of",
"all",
"values",
"in",
"column",
"col",
"."
] | burnash/gspread | python | https://github.com/burnash/gspread/blob/0e8debe208095aeed3e3e7136c2fa5cd74090946/gspread/models.py#L675-L705 | [
"def",
"col_values",
"(",
"self",
",",
"col",
",",
"value_render_option",
"=",
"'FORMATTED_VALUE'",
")",
":",
"start_label",
"=",
"rowcol_to_a1",
"(",
"1",
",",
"col",
")",
"range_label",
"=",
"'%s!%s:%s'",
"%",
"(",
"self",
".",
"title",
",",
"start_label",... | 0e8debe208095aeed3e3e7136c2fa5cd74090946 |
train | Worksheet.update_acell | Updates the value of a cell.
:param label: Cell label in A1 notation.
Letter case is ignored.
:type label: str
:param value: New value.
Example::
worksheet.update_acell('A1', '42') | gspread/models.py | def update_acell(self, label, value):
"""Updates the value of a cell.
:param label: Cell label in A1 notation.
Letter case is ignored.
:type label: str
:param value: New value.
Example::
worksheet.update_acell('A1', '42')
"""
... | def update_acell(self, label, value):
"""Updates the value of a cell.
:param label: Cell label in A1 notation.
Letter case is ignored.
:type label: str
:param value: New value.
Example::
worksheet.update_acell('A1', '42')
"""
... | [
"Updates",
"the",
"value",
"of",
"a",
"cell",
"."
] | burnash/gspread | python | https://github.com/burnash/gspread/blob/0e8debe208095aeed3e3e7136c2fa5cd74090946/gspread/models.py#L707-L720 | [
"def",
"update_acell",
"(",
"self",
",",
"label",
",",
"value",
")",
":",
"return",
"self",
".",
"update_cell",
"(",
"*",
"(",
"a1_to_rowcol",
"(",
"label",
")",
")",
",",
"value",
"=",
"value",
")"
] | 0e8debe208095aeed3e3e7136c2fa5cd74090946 |
train | Worksheet.update_cell | Updates the value of a cell.
:param row: Row number.
:type row: int
:param col: Column number.
:type col: int
:param value: New value.
Example::
worksheet.update_cell(1, 1, '42') | gspread/models.py | def update_cell(self, row, col, value):
"""Updates the value of a cell.
:param row: Row number.
:type row: int
:param col: Column number.
:type col: int
:param value: New value.
Example::
worksheet.update_cell(1, 1, '42')
"""
range_... | def update_cell(self, row, col, value):
"""Updates the value of a cell.
:param row: Row number.
:type row: int
:param col: Column number.
:type col: int
:param value: New value.
Example::
worksheet.update_cell(1, 1, '42')
"""
range_... | [
"Updates",
"the",
"value",
"of",
"a",
"cell",
"."
] | burnash/gspread | python | https://github.com/burnash/gspread/blob/0e8debe208095aeed3e3e7136c2fa5cd74090946/gspread/models.py#L722-L748 | [
"def",
"update_cell",
"(",
"self",
",",
"row",
",",
"col",
",",
"value",
")",
":",
"range_label",
"=",
"'%s!%s'",
"%",
"(",
"self",
".",
"title",
",",
"rowcol_to_a1",
"(",
"row",
",",
"col",
")",
")",
"data",
"=",
"self",
".",
"spreadsheet",
".",
"... | 0e8debe208095aeed3e3e7136c2fa5cd74090946 |
train | Worksheet.update_cells | Updates many cells at once.
:param cell_list: List of :class:`Cell` objects to update.
:param value_input_option: (optional) Determines how input data should
be interpreted. See `ValueInputOption`_ in
the Sheets API.
:type ... | gspread/models.py | def update_cells(self, cell_list, value_input_option='RAW'):
"""Updates many cells at once.
:param cell_list: List of :class:`Cell` objects to update.
:param value_input_option: (optional) Determines how input data should
be interpreted. See `ValueInputOption... | def update_cells(self, cell_list, value_input_option='RAW'):
"""Updates many cells at once.
:param cell_list: List of :class:`Cell` objects to update.
:param value_input_option: (optional) Determines how input data should
be interpreted. See `ValueInputOption... | [
"Updates",
"many",
"cells",
"at",
"once",
"."
] | burnash/gspread | python | https://github.com/burnash/gspread/blob/0e8debe208095aeed3e3e7136c2fa5cd74090946/gspread/models.py#L750-L791 | [
"def",
"update_cells",
"(",
"self",
",",
"cell_list",
",",
"value_input_option",
"=",
"'RAW'",
")",
":",
"values_rect",
"=",
"cell_list_to_rect",
"(",
"cell_list",
")",
"start",
"=",
"rowcol_to_a1",
"(",
"min",
"(",
"c",
".",
"row",
"for",
"c",
"in",
"cell... | 0e8debe208095aeed3e3e7136c2fa5cd74090946 |
train | Worksheet.resize | Resizes the worksheet. Specify one of ``rows`` or ``cols``.
:param rows: (optional) New number of rows.
:type rows: int
:param cols: (optional) New number columns.
:type cols: int | gspread/models.py | def resize(self, rows=None, cols=None):
"""Resizes the worksheet. Specify one of ``rows`` or ``cols``.
:param rows: (optional) New number of rows.
:type rows: int
:param cols: (optional) New number columns.
:type cols: int
"""
grid_properties = {}
if row... | def resize(self, rows=None, cols=None):
"""Resizes the worksheet. Specify one of ``rows`` or ``cols``.
:param rows: (optional) New number of rows.
:type rows: int
:param cols: (optional) New number columns.
:type cols: int
"""
grid_properties = {}
if row... | [
"Resizes",
"the",
"worksheet",
".",
"Specify",
"one",
"of",
"rows",
"or",
"cols",
"."
] | burnash/gspread | python | https://github.com/burnash/gspread/blob/0e8debe208095aeed3e3e7136c2fa5cd74090946/gspread/models.py#L793-L828 | [
"def",
"resize",
"(",
"self",
",",
"rows",
"=",
"None",
",",
"cols",
"=",
"None",
")",
":",
"grid_properties",
"=",
"{",
"}",
"if",
"rows",
"is",
"not",
"None",
":",
"grid_properties",
"[",
"'rowCount'",
"]",
"=",
"rows",
"if",
"cols",
"is",
"not",
... | 0e8debe208095aeed3e3e7136c2fa5cd74090946 |
train | Worksheet.update_title | Renames the worksheet.
:param title: A new title.
:type title: str | gspread/models.py | def update_title(self, title):
"""Renames the worksheet.
:param title: A new title.
:type title: str
"""
body = {
'requests': [{
'updateSheetProperties': {
'properties': {
'sheetId': self.id,
... | def update_title(self, title):
"""Renames the worksheet.
:param title: A new title.
:type title: str
"""
body = {
'requests': [{
'updateSheetProperties': {
'properties': {
'sheetId': self.id,
... | [
"Renames",
"the",
"worksheet",
"."
] | burnash/gspread | python | https://github.com/burnash/gspread/blob/0e8debe208095aeed3e3e7136c2fa5cd74090946/gspread/models.py#L830-L852 | [
"def",
"update_title",
"(",
"self",
",",
"title",
")",
":",
"body",
"=",
"{",
"'requests'",
":",
"[",
"{",
"'updateSheetProperties'",
":",
"{",
"'properties'",
":",
"{",
"'sheetId'",
":",
"self",
".",
"id",
",",
"'title'",
":",
"title",
"}",
",",
"'fie... | 0e8debe208095aeed3e3e7136c2fa5cd74090946 |
train | Worksheet.append_row | Adds a row to the worksheet and populates it with values.
Widens the worksheet if there are more values than columns.
:param values: List of values for the new row.
:param value_input_option: (optional) Determines how input data should
be interpreted. See `Va... | gspread/models.py | def append_row(self, values, value_input_option='RAW'):
"""Adds a row to the worksheet and populates it with values.
Widens the worksheet if there are more values than columns.
:param values: List of values for the new row.
:param value_input_option: (optional) Determines how input data... | def append_row(self, values, value_input_option='RAW'):
"""Adds a row to the worksheet and populates it with values.
Widens the worksheet if there are more values than columns.
:param values: List of values for the new row.
:param value_input_option: (optional) Determines how input data... | [
"Adds",
"a",
"row",
"to",
"the",
"worksheet",
"and",
"populates",
"it",
"with",
"values",
".",
"Widens",
"the",
"worksheet",
"if",
"there",
"are",
"more",
"values",
"than",
"columns",
"."
] | burnash/gspread | python | https://github.com/burnash/gspread/blob/0e8debe208095aeed3e3e7136c2fa5cd74090946/gspread/models.py#L872-L893 | [
"def",
"append_row",
"(",
"self",
",",
"values",
",",
"value_input_option",
"=",
"'RAW'",
")",
":",
"params",
"=",
"{",
"'valueInputOption'",
":",
"value_input_option",
"}",
"body",
"=",
"{",
"'values'",
":",
"[",
"values",
"]",
"}",
"return",
"self",
".",... | 0e8debe208095aeed3e3e7136c2fa5cd74090946 |
train | Worksheet.insert_row | Adds a row to the worksheet at the specified index
and populates it with values.
Widens the worksheet if there are more values than columns.
:param values: List of values for the new row.
:param index: (optional) Offset for the newly inserted row.
:type index: int
:para... | gspread/models.py | def insert_row(
self,
values,
index=1,
value_input_option='RAW'
):
"""Adds a row to the worksheet at the specified index
and populates it with values.
Widens the worksheet if there are more values than columns.
:param values: List of values for the n... | def insert_row(
self,
values,
index=1,
value_input_option='RAW'
):
"""Adds a row to the worksheet at the specified index
and populates it with values.
Widens the worksheet if there are more values than columns.
:param values: List of values for the n... | [
"Adds",
"a",
"row",
"to",
"the",
"worksheet",
"at",
"the",
"specified",
"index",
"and",
"populates",
"it",
"with",
"values",
"."
] | burnash/gspread | python | https://github.com/burnash/gspread/blob/0e8debe208095aeed3e3e7136c2fa5cd74090946/gspread/models.py#L895-L945 | [
"def",
"insert_row",
"(",
"self",
",",
"values",
",",
"index",
"=",
"1",
",",
"value_input_option",
"=",
"'RAW'",
")",
":",
"body",
"=",
"{",
"\"requests\"",
":",
"[",
"{",
"\"insertDimension\"",
":",
"{",
"\"range\"",
":",
"{",
"\"sheetId\"",
":",
"self... | 0e8debe208095aeed3e3e7136c2fa5cd74090946 |
train | Worksheet.delete_row | Deletes the row from the worksheet at the specified index.
:param index: Index of a row for deletion.
:type index: int | gspread/models.py | def delete_row(self, index):
""""Deletes the row from the worksheet at the specified index.
:param index: Index of a row for deletion.
:type index: int
"""
body = {
"requests": [{
"deleteDimension": {
"range": {
... | def delete_row(self, index):
""""Deletes the row from the worksheet at the specified index.
:param index: Index of a row for deletion.
:type index: int
"""
body = {
"requests": [{
"deleteDimension": {
"range": {
... | [
"Deletes",
"the",
"row",
"from",
"the",
"worksheet",
"at",
"the",
"specified",
"index",
"."
] | burnash/gspread | python | https://github.com/burnash/gspread/blob/0e8debe208095aeed3e3e7136c2fa5cd74090946/gspread/models.py#L947-L966 | [
"def",
"delete_row",
"(",
"self",
",",
"index",
")",
":",
"body",
"=",
"{",
"\"requests\"",
":",
"[",
"{",
"\"deleteDimension\"",
":",
"{",
"\"range\"",
":",
"{",
"\"sheetId\"",
":",
"self",
".",
"id",
",",
"\"dimension\"",
":",
"\"ROWS\"",
",",
"\"start... | 0e8debe208095aeed3e3e7136c2fa5cd74090946 |
train | Worksheet.find | Finds the first cell matching the query.
:param query: A literal string to match or compiled regular expression.
:type query: str, :py:class:`re.RegexObject` | gspread/models.py | def find(self, query):
"""Finds the first cell matching the query.
:param query: A literal string to match or compiled regular expression.
:type query: str, :py:class:`re.RegexObject`
"""
try:
return self._finder(finditem, query)
except StopIteration:
... | def find(self, query):
"""Finds the first cell matching the query.
:param query: A literal string to match or compiled regular expression.
:type query: str, :py:class:`re.RegexObject`
"""
try:
return self._finder(finditem, query)
except StopIteration:
... | [
"Finds",
"the",
"first",
"cell",
"matching",
"the",
"query",
"."
] | burnash/gspread | python | https://github.com/burnash/gspread/blob/0e8debe208095aeed3e3e7136c2fa5cd74090946/gspread/models.py#L994-L1004 | [
"def",
"find",
"(",
"self",
",",
"query",
")",
":",
"try",
":",
"return",
"self",
".",
"_finder",
"(",
"finditem",
",",
"query",
")",
"except",
"StopIteration",
":",
"raise",
"CellNotFound",
"(",
"query",
")"
] | 0e8debe208095aeed3e3e7136c2fa5cd74090946 |
train | Worksheet.duplicate | Duplicate the sheet.
:param int insert_sheet_index: (optional) The zero-based index
where the new sheet should be inserted.
The index of all sheets after this are
incremented.
:param int... | gspread/models.py | def duplicate(
self,
insert_sheet_index=None,
new_sheet_id=None,
new_sheet_name=None
):
"""Duplicate the sheet.
:param int insert_sheet_index: (optional) The zero-based index
where the new sheet should be inserted.
... | def duplicate(
self,
insert_sheet_index=None,
new_sheet_id=None,
new_sheet_name=None
):
"""Duplicate the sheet.
:param int insert_sheet_index: (optional) The zero-based index
where the new sheet should be inserted.
... | [
"Duplicate",
"the",
"sheet",
"."
] | burnash/gspread | python | https://github.com/burnash/gspread/blob/0e8debe208095aeed3e3e7136c2fa5cd74090946/gspread/models.py#L1028-L1057 | [
"def",
"duplicate",
"(",
"self",
",",
"insert_sheet_index",
"=",
"None",
",",
"new_sheet_id",
"=",
"None",
",",
"new_sheet_name",
"=",
"None",
")",
":",
"return",
"self",
".",
"spreadsheet",
".",
"duplicate_sheet",
"(",
"self",
".",
"id",
",",
"insert_sheet_... | 0e8debe208095aeed3e3e7136c2fa5cd74090946 |
train | numericise | Returns a value that depends on the input string:
- Float if input can be converted to Float
- Integer if input can be converted to integer
- Zero if the input string is empty and empty2zero flag is set
- The same input string, empty or not, otherwise.
Executable examples:
>>> ... | gspread/utils.py | def numericise(value, empty2zero=False, default_blank="", allow_underscores_in_numeric_literals=False):
"""Returns a value that depends on the input string:
- Float if input can be converted to Float
- Integer if input can be converted to integer
- Zero if the input string is empty and empty... | def numericise(value, empty2zero=False, default_blank="", allow_underscores_in_numeric_literals=False):
"""Returns a value that depends on the input string:
- Float if input can be converted to Float
- Integer if input can be converted to integer
- Zero if the input string is empty and empty... | [
"Returns",
"a",
"value",
"that",
"depends",
"on",
"the",
"input",
"string",
":",
"-",
"Float",
"if",
"input",
"can",
"be",
"converted",
"to",
"Float",
"-",
"Integer",
"if",
"input",
"can",
"be",
"converted",
"to",
"integer",
"-",
"Zero",
"if",
"the",
"... | burnash/gspread | python | https://github.com/burnash/gspread/blob/0e8debe208095aeed3e3e7136c2fa5cd74090946/gspread/utils.py#L40-L87 | [
"def",
"numericise",
"(",
"value",
",",
"empty2zero",
"=",
"False",
",",
"default_blank",
"=",
"\"\"",
",",
"allow_underscores_in_numeric_literals",
"=",
"False",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"if",
"\"_\"",
"in",
"value",
"and",
"not",
... | 0e8debe208095aeed3e3e7136c2fa5cd74090946 |
train | numericise_all | Returns a list of numericised values from strings | gspread/utils.py | def numericise_all(input, empty2zero=False, default_blank="", allow_underscores_in_numeric_literals=False):
"""Returns a list of numericised values from strings"""
return [numericise(s, empty2zero, default_blank, allow_underscores_in_numeric_literals) for s in input] | def numericise_all(input, empty2zero=False, default_blank="", allow_underscores_in_numeric_literals=False):
"""Returns a list of numericised values from strings"""
return [numericise(s, empty2zero, default_blank, allow_underscores_in_numeric_literals) for s in input] | [
"Returns",
"a",
"list",
"of",
"numericised",
"values",
"from",
"strings"
] | burnash/gspread | python | https://github.com/burnash/gspread/blob/0e8debe208095aeed3e3e7136c2fa5cd74090946/gspread/utils.py#L90-L92 | [
"def",
"numericise_all",
"(",
"input",
",",
"empty2zero",
"=",
"False",
",",
"default_blank",
"=",
"\"\"",
",",
"allow_underscores_in_numeric_literals",
"=",
"False",
")",
":",
"return",
"[",
"numericise",
"(",
"s",
",",
"empty2zero",
",",
"default_blank",
",",
... | 0e8debe208095aeed3e3e7136c2fa5cd74090946 |
train | rowcol_to_a1 | Translates a row and column cell address to A1 notation.
:param row: The row of the cell to be converted.
Rows start at index 1.
:type row: int, str
:param col: The column of the cell to be converted.
Columns start at index 1.
:type row: int, str
:returns: a string... | gspread/utils.py | def rowcol_to_a1(row, col):
"""Translates a row and column cell address to A1 notation.
:param row: The row of the cell to be converted.
Rows start at index 1.
:type row: int, str
:param col: The column of the cell to be converted.
Columns start at index 1.
:type ro... | def rowcol_to_a1(row, col):
"""Translates a row and column cell address to A1 notation.
:param row: The row of the cell to be converted.
Rows start at index 1.
:type row: int, str
:param col: The column of the cell to be converted.
Columns start at index 1.
:type ro... | [
"Translates",
"a",
"row",
"and",
"column",
"cell",
"address",
"to",
"A1",
"notation",
"."
] | burnash/gspread | python | https://github.com/burnash/gspread/blob/0e8debe208095aeed3e3e7136c2fa5cd74090946/gspread/utils.py#L95-L132 | [
"def",
"rowcol_to_a1",
"(",
"row",
",",
"col",
")",
":",
"row",
"=",
"int",
"(",
"row",
")",
"col",
"=",
"int",
"(",
"col",
")",
"if",
"row",
"<",
"1",
"or",
"col",
"<",
"1",
":",
"raise",
"IncorrectCellLabel",
"(",
"'(%s, %s)'",
"%",
"(",
"row",... | 0e8debe208095aeed3e3e7136c2fa5cd74090946 |
train | a1_to_rowcol | Translates a cell's address in A1 notation to a tuple of integers.
:param label: A cell label in A1 notation, e.g. 'B1'.
Letter case is ignored.
:type label: str
:returns: a tuple containing `row` and `column` numbers. Both indexed
from 1 (one).
Example:
>>> a1_to... | gspread/utils.py | def a1_to_rowcol(label):
"""Translates a cell's address in A1 notation to a tuple of integers.
:param label: A cell label in A1 notation, e.g. 'B1'.
Letter case is ignored.
:type label: str
:returns: a tuple containing `row` and `column` numbers. Both indexed
from 1 (on... | def a1_to_rowcol(label):
"""Translates a cell's address in A1 notation to a tuple of integers.
:param label: A cell label in A1 notation, e.g. 'B1'.
Letter case is ignored.
:type label: str
:returns: a tuple containing `row` and `column` numbers. Both indexed
from 1 (on... | [
"Translates",
"a",
"cell",
"s",
"address",
"in",
"A1",
"notation",
"to",
"a",
"tuple",
"of",
"integers",
"."
] | burnash/gspread | python | https://github.com/burnash/gspread/blob/0e8debe208095aeed3e3e7136c2fa5cd74090946/gspread/utils.py#L135-L162 | [
"def",
"a1_to_rowcol",
"(",
"label",
")",
":",
"m",
"=",
"CELL_ADDR_RE",
".",
"match",
"(",
"label",
")",
"if",
"m",
":",
"column_label",
"=",
"m",
".",
"group",
"(",
"1",
")",
".",
"upper",
"(",
")",
"row",
"=",
"int",
"(",
"m",
".",
"group",
... | 0e8debe208095aeed3e3e7136c2fa5cd74090946 |
train | cast_to_a1_notation | Decorator function casts wrapped arguments to A1 notation
in range method calls. | gspread/utils.py | def cast_to_a1_notation(method):
"""
Decorator function casts wrapped arguments to A1 notation
in range method calls.
"""
@wraps(method)
def wrapper(self, *args, **kwargs):
try:
if len(args):
int(args[0])
# Convert to A1 notation
range... | def cast_to_a1_notation(method):
"""
Decorator function casts wrapped arguments to A1 notation
in range method calls.
"""
@wraps(method)
def wrapper(self, *args, **kwargs):
try:
if len(args):
int(args[0])
# Convert to A1 notation
range... | [
"Decorator",
"function",
"casts",
"wrapped",
"arguments",
"to",
"A1",
"notation",
"in",
"range",
"method",
"calls",
"."
] | burnash/gspread | python | https://github.com/burnash/gspread/blob/0e8debe208095aeed3e3e7136c2fa5cd74090946/gspread/utils.py#L165-L187 | [
"def",
"cast_to_a1_notation",
"(",
"method",
")",
":",
"@",
"wraps",
"(",
"method",
")",
"def",
"wrapper",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"if",
"len",
"(",
"args",
")",
":",
"int",
"(",
"args",
"[",
... | 0e8debe208095aeed3e3e7136c2fa5cd74090946 |
train | wid_to_gid | Calculate gid of a worksheet from its wid. | gspread/utils.py | def wid_to_gid(wid):
"""Calculate gid of a worksheet from its wid."""
widval = wid[1:] if len(wid) > 3 else wid
xorval = 474 if len(wid) > 3 else 31578
return str(int(widval, 36) ^ xorval) | def wid_to_gid(wid):
"""Calculate gid of a worksheet from its wid."""
widval = wid[1:] if len(wid) > 3 else wid
xorval = 474 if len(wid) > 3 else 31578
return str(int(widval, 36) ^ xorval) | [
"Calculate",
"gid",
"of",
"a",
"worksheet",
"from",
"its",
"wid",
"."
] | burnash/gspread | python | https://github.com/burnash/gspread/blob/0e8debe208095aeed3e3e7136c2fa5cd74090946/gspread/utils.py#L202-L206 | [
"def",
"wid_to_gid",
"(",
"wid",
")",
":",
"widval",
"=",
"wid",
"[",
"1",
":",
"]",
"if",
"len",
"(",
"wid",
")",
">",
"3",
"else",
"wid",
"xorval",
"=",
"474",
"if",
"len",
"(",
"wid",
")",
">",
"3",
"else",
"31578",
"return",
"str",
"(",
"... | 0e8debe208095aeed3e3e7136c2fa5cd74090946 |
train | Client.login | Authorize client. | gspread/client.py | def login(self):
"""Authorize client."""
if not self.auth.access_token or \
(hasattr(self.auth, 'access_token_expired') and self.auth.access_token_expired):
import httplib2
http = httplib2.Http()
self.auth.refresh(http)
self.session.headers.u... | def login(self):
"""Authorize client."""
if not self.auth.access_token or \
(hasattr(self.auth, 'access_token_expired') and self.auth.access_token_expired):
import httplib2
http = httplib2.Http()
self.auth.refresh(http)
self.session.headers.u... | [
"Authorize",
"client",
"."
] | burnash/gspread | python | https://github.com/burnash/gspread/blob/0e8debe208095aeed3e3e7136c2fa5cd74090946/gspread/client.py#L44-L55 | [
"def",
"login",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"auth",
".",
"access_token",
"or",
"(",
"hasattr",
"(",
"self",
".",
"auth",
",",
"'access_token_expired'",
")",
"and",
"self",
".",
"auth",
".",
"access_token_expired",
")",
":",
"import",... | 0e8debe208095aeed3e3e7136c2fa5cd74090946 |
train | Client.open | Opens a spreadsheet.
:param title: A title of a spreadsheet.
:type title: str
:returns: a :class:`~gspread.models.Spreadsheet` instance.
If there's more than one spreadsheet with same title the first one
will be opened.
:raises gspread.SpreadsheetNotFound: if no sprea... | gspread/client.py | def open(self, title):
"""Opens a spreadsheet.
:param title: A title of a spreadsheet.
:type title: str
:returns: a :class:`~gspread.models.Spreadsheet` instance.
If there's more than one spreadsheet with same title the first one
will be opened.
:raises gsprea... | def open(self, title):
"""Opens a spreadsheet.
:param title: A title of a spreadsheet.
:type title: str
:returns: a :class:`~gspread.models.Spreadsheet` instance.
If there's more than one spreadsheet with same title the first one
will be opened.
:raises gsprea... | [
"Opens",
"a",
"spreadsheet",
"."
] | burnash/gspread | python | https://github.com/burnash/gspread/blob/0e8debe208095aeed3e3e7136c2fa5cd74090946/gspread/client.py#L102-L131 | [
"def",
"open",
"(",
"self",
",",
"title",
")",
":",
"try",
":",
"properties",
"=",
"finditem",
"(",
"lambda",
"x",
":",
"x",
"[",
"'name'",
"]",
"==",
"title",
",",
"self",
".",
"list_spreadsheet_files",
"(",
")",
")",
"# Drive uses different terminology",... | 0e8debe208095aeed3e3e7136c2fa5cd74090946 |
train | Client.openall | Opens all available spreadsheets.
:param title: (optional) If specified can be used to filter
spreadsheets by title.
:type title: str
:returns: a list of :class:`~gspread.models.Spreadsheet` instances. | gspread/client.py | def openall(self, title=None):
"""Opens all available spreadsheets.
:param title: (optional) If specified can be used to filter
spreadsheets by title.
:type title: str
:returns: a list of :class:`~gspread.models.Spreadsheet` instances.
"""
spreads... | def openall(self, title=None):
"""Opens all available spreadsheets.
:param title: (optional) If specified can be used to filter
spreadsheets by title.
:type title: str
:returns: a list of :class:`~gspread.models.Spreadsheet` instances.
"""
spreads... | [
"Opens",
"all",
"available",
"spreadsheets",
"."
] | burnash/gspread | python | https://github.com/burnash/gspread/blob/0e8debe208095aeed3e3e7136c2fa5cd74090946/gspread/client.py#L164-L179 | [
"def",
"openall",
"(",
"self",
",",
"title",
"=",
"None",
")",
":",
"spreadsheet_files",
"=",
"self",
".",
"list_spreadsheet_files",
"(",
")",
"return",
"[",
"Spreadsheet",
"(",
"self",
",",
"dict",
"(",
"title",
"=",
"x",
"[",
"'name'",
"]",
",",
"*",... | 0e8debe208095aeed3e3e7136c2fa5cd74090946 |
train | Client.create | Creates a new spreadsheet.
:param title: A title of a new spreadsheet.
:type title: str
:returns: a :class:`~gspread.models.Spreadsheet` instance.
.. note::
In order to use this method, you need to add
``https://www.googleapis.com/auth/drive`` to your oAuth scop... | gspread/client.py | def create(self, title):
"""Creates a new spreadsheet.
:param title: A title of a new spreadsheet.
:type title: str
:returns: a :class:`~gspread.models.Spreadsheet` instance.
.. note::
In order to use this method, you need to add
``https://www.googleapis... | def create(self, title):
"""Creates a new spreadsheet.
:param title: A title of a new spreadsheet.
:type title: str
:returns: a :class:`~gspread.models.Spreadsheet` instance.
.. note::
In order to use this method, you need to add
``https://www.googleapis... | [
"Creates",
"a",
"new",
"spreadsheet",
"."
] | burnash/gspread | python | https://github.com/burnash/gspread/blob/0e8debe208095aeed3e3e7136c2fa5cd74090946/gspread/client.py#L181-L215 | [
"def",
"create",
"(",
"self",
",",
"title",
")",
":",
"payload",
"=",
"{",
"'title'",
":",
"title",
",",
"'mimeType'",
":",
"'application/vnd.google-apps.spreadsheet'",
"}",
"r",
"=",
"self",
".",
"request",
"(",
"'post'",
",",
"DRIVE_FILES_API_V2_URL",
",",
... | 0e8debe208095aeed3e3e7136c2fa5cd74090946 |
train | Client.copy | Copies a spreadsheet.
:param file_id: A key of a spreadsheet to copy.
:type title: str
:param title: (optional) A title for the new spreadsheet.
:type title: str
:param copy_permissions: (optional) If True, copy permissions from
original spreadsheet to new sprea... | gspread/client.py | def copy(self, file_id, title=None, copy_permissions=False):
"""Copies a spreadsheet.
:param file_id: A key of a spreadsheet to copy.
:type title: str
:param title: (optional) A title for the new spreadsheet.
:type title: str
:param copy_permissions: (optional) If True... | def copy(self, file_id, title=None, copy_permissions=False):
"""Copies a spreadsheet.
:param file_id: A key of a spreadsheet to copy.
:type title: str
:param title: (optional) A title for the new spreadsheet.
:type title: str
:param copy_permissions: (optional) If True... | [
"Copies",
"a",
"spreadsheet",
"."
] | burnash/gspread | python | https://github.com/burnash/gspread/blob/0e8debe208095aeed3e3e7136c2fa5cd74090946/gspread/client.py#L217-L286 | [
"def",
"copy",
"(",
"self",
",",
"file_id",
",",
"title",
"=",
"None",
",",
"copy_permissions",
"=",
"False",
")",
":",
"url",
"=",
"'{0}/{1}/copy'",
".",
"format",
"(",
"DRIVE_FILES_API_V2_URL",
",",
"file_id",
")",
"payload",
"=",
"{",
"'title'",
":",
... | 0e8debe208095aeed3e3e7136c2fa5cd74090946 |
train | Client.del_spreadsheet | Deletes a spreadsheet.
:param file_id: a spreadsheet ID (aka file ID.)
:type file_id: str | gspread/client.py | def del_spreadsheet(self, file_id):
"""Deletes a spreadsheet.
:param file_id: a spreadsheet ID (aka file ID.)
:type file_id: str
"""
url = '{0}/{1}'.format(
DRIVE_FILES_API_V2_URL,
file_id
)
self.request('delete', url) | def del_spreadsheet(self, file_id):
"""Deletes a spreadsheet.
:param file_id: a spreadsheet ID (aka file ID.)
:type file_id: str
"""
url = '{0}/{1}'.format(
DRIVE_FILES_API_V2_URL,
file_id
)
self.request('delete', url) | [
"Deletes",
"a",
"spreadsheet",
"."
] | burnash/gspread | python | https://github.com/burnash/gspread/blob/0e8debe208095aeed3e3e7136c2fa5cd74090946/gspread/client.py#L288-L299 | [
"def",
"del_spreadsheet",
"(",
"self",
",",
"file_id",
")",
":",
"url",
"=",
"'{0}/{1}'",
".",
"format",
"(",
"DRIVE_FILES_API_V2_URL",
",",
"file_id",
")",
"self",
".",
"request",
"(",
"'delete'",
",",
"url",
")"
] | 0e8debe208095aeed3e3e7136c2fa5cd74090946 |
train | Client.import_csv | Imports data into the first page of the spreadsheet.
:param str data: A CSV string of data.
Example:
.. code::
# Read CSV file contents
content = open('file_to_import.csv', 'r').read()
gc.import_csv(spreadsheet.id, content)
.. note::
... | gspread/client.py | def import_csv(self, file_id, data):
"""Imports data into the first page of the spreadsheet.
:param str data: A CSV string of data.
Example:
.. code::
# Read CSV file contents
content = open('file_to_import.csv', 'r').read()
gc.import_csv(spreadsh... | def import_csv(self, file_id, data):
"""Imports data into the first page of the spreadsheet.
:param str data: A CSV string of data.
Example:
.. code::
# Read CSV file contents
content = open('file_to_import.csv', 'r').read()
gc.import_csv(spreadsh... | [
"Imports",
"data",
"into",
"the",
"first",
"page",
"of",
"the",
"spreadsheet",
"."
] | burnash/gspread | python | https://github.com/burnash/gspread/blob/0e8debe208095aeed3e3e7136c2fa5cd74090946/gspread/client.py#L301-L333 | [
"def",
"import_csv",
"(",
"self",
",",
"file_id",
",",
"data",
")",
":",
"headers",
"=",
"{",
"'Content-Type'",
":",
"'text/csv'",
"}",
"url",
"=",
"'{0}/{1}'",
".",
"format",
"(",
"DRIVE_FILES_UPLOAD_API_V2_URL",
",",
"file_id",
")",
"self",
".",
"request",... | 0e8debe208095aeed3e3e7136c2fa5cd74090946 |
train | Client.list_permissions | Retrieve a list of permissions for a file.
:param file_id: a spreadsheet ID (aka file ID.)
:type file_id: str | gspread/client.py | def list_permissions(self, file_id):
"""Retrieve a list of permissions for a file.
:param file_id: a spreadsheet ID (aka file ID.)
:type file_id: str
"""
url = '{0}/{1}/permissions'.format(DRIVE_FILES_API_V2_URL, file_id)
r = self.request('get', url)
return r.j... | def list_permissions(self, file_id):
"""Retrieve a list of permissions for a file.
:param file_id: a spreadsheet ID (aka file ID.)
:type file_id: str
"""
url = '{0}/{1}/permissions'.format(DRIVE_FILES_API_V2_URL, file_id)
r = self.request('get', url)
return r.j... | [
"Retrieve",
"a",
"list",
"of",
"permissions",
"for",
"a",
"file",
"."
] | burnash/gspread | python | https://github.com/burnash/gspread/blob/0e8debe208095aeed3e3e7136c2fa5cd74090946/gspread/client.py#L335-L345 | [
"def",
"list_permissions",
"(",
"self",
",",
"file_id",
")",
":",
"url",
"=",
"'{0}/{1}/permissions'",
".",
"format",
"(",
"DRIVE_FILES_API_V2_URL",
",",
"file_id",
")",
"r",
"=",
"self",
".",
"request",
"(",
"'get'",
",",
"url",
")",
"return",
"r",
".",
... | 0e8debe208095aeed3e3e7136c2fa5cd74090946 |
train | Client.insert_permission | Creates a new permission for a file.
:param file_id: a spreadsheet ID (aka file ID.)
:type file_id: str
:param value: user or group e-mail address, domain name
or None for 'default' type.
:type value: str, None
:param perm_type: (optional) The account type.... | gspread/client.py | def insert_permission(
self,
file_id,
value,
perm_type,
role,
notify=True,
email_message=None,
with_link=False
):
"""Creates a new permission for a file.
:param file_id: a spreadsheet ID (aka file ID.)
:type file_id: str
... | def insert_permission(
self,
file_id,
value,
perm_type,
role,
notify=True,
email_message=None,
with_link=False
):
"""Creates a new permission for a file.
:param file_id: a spreadsheet ID (aka file ID.)
:type file_id: str
... | [
"Creates",
"a",
"new",
"permission",
"for",
"a",
"file",
"."
] | burnash/gspread | python | https://github.com/burnash/gspread/blob/0e8debe208095aeed3e3e7136c2fa5cd74090946/gspread/client.py#L347-L421 | [
"def",
"insert_permission",
"(",
"self",
",",
"file_id",
",",
"value",
",",
"perm_type",
",",
"role",
",",
"notify",
"=",
"True",
",",
"email_message",
"=",
"None",
",",
"with_link",
"=",
"False",
")",
":",
"url",
"=",
"'{0}/{1}/permissions'",
".",
"format... | 0e8debe208095aeed3e3e7136c2fa5cd74090946 |
train | Client.remove_permission | Deletes a permission from a file.
:param file_id: a spreadsheet ID (aka file ID.)
:type file_id: str
:param permission_id: an ID for the permission.
:type permission_id: str | gspread/client.py | def remove_permission(self, file_id, permission_id):
"""Deletes a permission from a file.
:param file_id: a spreadsheet ID (aka file ID.)
:type file_id: str
:param permission_id: an ID for the permission.
:type permission_id: str
"""
url = '{0}/{1}/permissions/{2... | def remove_permission(self, file_id, permission_id):
"""Deletes a permission from a file.
:param file_id: a spreadsheet ID (aka file ID.)
:type file_id: str
:param permission_id: an ID for the permission.
:type permission_id: str
"""
url = '{0}/{1}/permissions/{2... | [
"Deletes",
"a",
"permission",
"from",
"a",
"file",
"."
] | burnash/gspread | python | https://github.com/burnash/gspread/blob/0e8debe208095aeed3e3e7136c2fa5cd74090946/gspread/client.py#L423-L437 | [
"def",
"remove_permission",
"(",
"self",
",",
"file_id",
",",
"permission_id",
")",
":",
"url",
"=",
"'{0}/{1}/permissions/{2}'",
".",
"format",
"(",
"DRIVE_FILES_API_V2_URL",
",",
"file_id",
",",
"permission_id",
")",
"self",
".",
"request",
"(",
"'delete'",
",... | 0e8debe208095aeed3e3e7136c2fa5cd74090946 |
train | tau_rand_int | A fast (pseudo)-random number generator.
Parameters
----------
state: array of int64, shape (3,)
The internal state of the rng
Returns
-------
A (pseudo)-random int32 value | umap/utils.py | def tau_rand_int(state):
"""A fast (pseudo)-random number generator.
Parameters
----------
state: array of int64, shape (3,)
The internal state of the rng
Returns
-------
A (pseudo)-random int32 value
"""
state[0] = (((state[0] & 4294967294) << 12) & 0xffffffff) ^ (
... | def tau_rand_int(state):
"""A fast (pseudo)-random number generator.
Parameters
----------
state: array of int64, shape (3,)
The internal state of the rng
Returns
-------
A (pseudo)-random int32 value
"""
state[0] = (((state[0] & 4294967294) << 12) & 0xffffffff) ^ (
... | [
"A",
"fast",
"(",
"pseudo",
")",
"-",
"random",
"number",
"generator",
"."
] | lmcinnes/umap | python | https://github.com/lmcinnes/umap/blob/bbb01c03ba49f7bff8f77fd662d00e50d6686c77/umap/utils.py#L12-L34 | [
"def",
"tau_rand_int",
"(",
"state",
")",
":",
"state",
"[",
"0",
"]",
"=",
"(",
"(",
"(",
"state",
"[",
"0",
"]",
"&",
"4294967294",
")",
"<<",
"12",
")",
"&",
"0xffffffff",
")",
"^",
"(",
"(",
"(",
"(",
"state",
"[",
"0",
"]",
"<<",
"13",
... | bbb01c03ba49f7bff8f77fd662d00e50d6686c77 |
train | norm | Compute the (standard l2) norm of a vector.
Parameters
----------
vec: array of shape (dim,)
Returns
-------
The l2 norm of vec. | umap/utils.py | def norm(vec):
"""Compute the (standard l2) norm of a vector.
Parameters
----------
vec: array of shape (dim,)
Returns
-------
The l2 norm of vec.
"""
result = 0.0
for i in range(vec.shape[0]):
result += vec[i] ** 2
return np.sqrt(result) | def norm(vec):
"""Compute the (standard l2) norm of a vector.
Parameters
----------
vec: array of shape (dim,)
Returns
-------
The l2 norm of vec.
"""
result = 0.0
for i in range(vec.shape[0]):
result += vec[i] ** 2
return np.sqrt(result) | [
"Compute",
"the",
"(",
"standard",
"l2",
")",
"norm",
"of",
"a",
"vector",
"."
] | lmcinnes/umap | python | https://github.com/lmcinnes/umap/blob/bbb01c03ba49f7bff8f77fd662d00e50d6686c77/umap/utils.py#L55-L69 | [
"def",
"norm",
"(",
"vec",
")",
":",
"result",
"=",
"0.0",
"for",
"i",
"in",
"range",
"(",
"vec",
".",
"shape",
"[",
"0",
"]",
")",
":",
"result",
"+=",
"vec",
"[",
"i",
"]",
"**",
"2",
"return",
"np",
".",
"sqrt",
"(",
"result",
")"
] | bbb01c03ba49f7bff8f77fd662d00e50d6686c77 |
train | rejection_sample | Generate n_samples many integers from 0 to pool_size such that no
integer is selected twice. The duplication constraint is achieved via
rejection sampling.
Parameters
----------
n_samples: int
The number of random samples to select from the pool
pool_size: int
The size of the t... | umap/utils.py | def rejection_sample(n_samples, pool_size, rng_state):
"""Generate n_samples many integers from 0 to pool_size such that no
integer is selected twice. The duplication constraint is achieved via
rejection sampling.
Parameters
----------
n_samples: int
The number of random samples to sele... | def rejection_sample(n_samples, pool_size, rng_state):
"""Generate n_samples many integers from 0 to pool_size such that no
integer is selected twice. The duplication constraint is achieved via
rejection sampling.
Parameters
----------
n_samples: int
The number of random samples to sele... | [
"Generate",
"n_samples",
"many",
"integers",
"from",
"0",
"to",
"pool_size",
"such",
"that",
"no",
"integer",
"is",
"selected",
"twice",
".",
"The",
"duplication",
"constraint",
"is",
"achieved",
"via",
"rejection",
"sampling",
"."
] | lmcinnes/umap | python | https://github.com/lmcinnes/umap/blob/bbb01c03ba49f7bff8f77fd662d00e50d6686c77/umap/utils.py#L73-L105 | [
"def",
"rejection_sample",
"(",
"n_samples",
",",
"pool_size",
",",
"rng_state",
")",
":",
"result",
"=",
"np",
".",
"empty",
"(",
"n_samples",
",",
"dtype",
"=",
"np",
".",
"int64",
")",
"for",
"i",
"in",
"range",
"(",
"n_samples",
")",
":",
"reject_s... | bbb01c03ba49f7bff8f77fd662d00e50d6686c77 |
train | make_heap | Constructor for the numba enabled heap objects. The heaps are used
for approximate nearest neighbor search, maintaining a list of potential
neighbors sorted by their distance. We also flag if potential neighbors
are newly added to the list or not. Internally this is stored as
a single ndarray; the first... | umap/utils.py | def make_heap(n_points, size):
"""Constructor for the numba enabled heap objects. The heaps are used
for approximate nearest neighbor search, maintaining a list of potential
neighbors sorted by their distance. We also flag if potential neighbors
are newly added to the list or not. Internally this is sto... | def make_heap(n_points, size):
"""Constructor for the numba enabled heap objects. The heaps are used
for approximate nearest neighbor search, maintaining a list of potential
neighbors sorted by their distance. We also flag if potential neighbors
are newly added to the list or not. Internally this is sto... | [
"Constructor",
"for",
"the",
"numba",
"enabled",
"heap",
"objects",
".",
"The",
"heaps",
"are",
"used",
"for",
"approximate",
"nearest",
"neighbor",
"search",
"maintaining",
"a",
"list",
"of",
"potential",
"neighbors",
"sorted",
"by",
"their",
"distance",
".",
... | lmcinnes/umap | python | https://github.com/lmcinnes/umap/blob/bbb01c03ba49f7bff8f77fd662d00e50d6686c77/umap/utils.py#L109-L136 | [
"def",
"make_heap",
"(",
"n_points",
",",
"size",
")",
":",
"result",
"=",
"np",
".",
"zeros",
"(",
"(",
"3",
",",
"int",
"(",
"n_points",
")",
",",
"int",
"(",
"size",
")",
")",
",",
"dtype",
"=",
"np",
".",
"float64",
")",
"result",
"[",
"0",... | bbb01c03ba49f7bff8f77fd662d00e50d6686c77 |
train | siftdown | Restore the heap property for a heap with an out of place element
at position ``elt``. This works with a heap pair where heap1 carries
the weights and heap2 holds the corresponding elements. | umap/utils.py | def siftdown(heap1, heap2, elt):
"""Restore the heap property for a heap with an out of place element
at position ``elt``. This works with a heap pair where heap1 carries
the weights and heap2 holds the corresponding elements."""
while elt * 2 + 1 < heap1.shape[0]:
left_child = elt * 2 + 1
... | def siftdown(heap1, heap2, elt):
"""Restore the heap property for a heap with an out of place element
at position ``elt``. This works with a heap pair where heap1 carries
the weights and heap2 holds the corresponding elements."""
while elt * 2 + 1 < heap1.shape[0]:
left_child = elt * 2 + 1
... | [
"Restore",
"the",
"heap",
"property",
"for",
"a",
"heap",
"with",
"an",
"out",
"of",
"place",
"element",
"at",
"position",
"elt",
".",
"This",
"works",
"with",
"a",
"heap",
"pair",
"where",
"heap1",
"carries",
"the",
"weights",
"and",
"heap2",
"holds",
"... | lmcinnes/umap | python | https://github.com/lmcinnes/umap/blob/bbb01c03ba49f7bff8f77fd662d00e50d6686c77/umap/utils.py#L302-L322 | [
"def",
"siftdown",
"(",
"heap1",
",",
"heap2",
",",
"elt",
")",
":",
"while",
"elt",
"*",
"2",
"+",
"1",
"<",
"heap1",
".",
"shape",
"[",
"0",
"]",
":",
"left_child",
"=",
"elt",
"*",
"2",
"+",
"1",
"right_child",
"=",
"left_child",
"+",
"1",
"... | bbb01c03ba49f7bff8f77fd662d00e50d6686c77 |
train | deheap_sort | Given an array of heaps (of indices and weights), unpack the heap
out to give and array of sorted lists of indices and weights by increasing
weight. This is effectively just the second half of heap sort (the first
half not being required since we already have the data in a heap).
Parameters
-------... | umap/utils.py | def deheap_sort(heap):
"""Given an array of heaps (of indices and weights), unpack the heap
out to give and array of sorted lists of indices and weights by increasing
weight. This is effectively just the second half of heap sort (the first
half not being required since we already have the data in a heap... | def deheap_sort(heap):
"""Given an array of heaps (of indices and weights), unpack the heap
out to give and array of sorted lists of indices and weights by increasing
weight. This is effectively just the second half of heap sort (the first
half not being required since we already have the data in a heap... | [
"Given",
"an",
"array",
"of",
"heaps",
"(",
"of",
"indices",
"and",
"weights",
")",
"unpack",
"the",
"heap",
"out",
"to",
"give",
"and",
"array",
"of",
"sorted",
"lists",
"of",
"indices",
"and",
"weights",
"by",
"increasing",
"weight",
".",
"This",
"is",... | lmcinnes/umap | python | https://github.com/lmcinnes/umap/blob/bbb01c03ba49f7bff8f77fd662d00e50d6686c77/umap/utils.py#L326-L366 | [
"def",
"deheap_sort",
"(",
"heap",
")",
":",
"indices",
"=",
"heap",
"[",
"0",
"]",
"weights",
"=",
"heap",
"[",
"1",
"]",
"for",
"i",
"in",
"range",
"(",
"indices",
".",
"shape",
"[",
"0",
"]",
")",
":",
"ind_heap",
"=",
"indices",
"[",
"i",
"... | bbb01c03ba49f7bff8f77fd662d00e50d6686c77 |
train | smallest_flagged | Search the heap for the smallest element that is
still flagged.
Parameters
----------
heap: array of shape (3, n_samples, n_neighbors)
The heaps to search
row: int
Which of the heaps to search
Returns
-------
index: int
The index of the smallest flagged element... | umap/utils.py | def smallest_flagged(heap, row):
"""Search the heap for the smallest element that is
still flagged.
Parameters
----------
heap: array of shape (3, n_samples, n_neighbors)
The heaps to search
row: int
Which of the heaps to search
Returns
-------
index: int
T... | def smallest_flagged(heap, row):
"""Search the heap for the smallest element that is
still flagged.
Parameters
----------
heap: array of shape (3, n_samples, n_neighbors)
The heaps to search
row: int
Which of the heaps to search
Returns
-------
index: int
T... | [
"Search",
"the",
"heap",
"for",
"the",
"smallest",
"element",
"that",
"is",
"still",
"flagged",
"."
] | lmcinnes/umap | python | https://github.com/lmcinnes/umap/blob/bbb01c03ba49f7bff8f77fd662d00e50d6686c77/umap/utils.py#L370-L405 | [
"def",
"smallest_flagged",
"(",
"heap",
",",
"row",
")",
":",
"ind",
"=",
"heap",
"[",
"0",
",",
"row",
"]",
"dist",
"=",
"heap",
"[",
"1",
",",
"row",
"]",
"flag",
"=",
"heap",
"[",
"2",
",",
"row",
"]",
"min_dist",
"=",
"np",
".",
"inf",
"r... | bbb01c03ba49f7bff8f77fd662d00e50d6686c77 |
train | build_candidates | Build a heap of candidate neighbors for nearest neighbor descent. For
each vertex the candidate neighbors are any current neighbors, and any
vertices that have the vertex as one of their nearest neighbors.
Parameters
----------
current_graph: heap
The current state of the graph for nearest ... | umap/utils.py | def build_candidates(current_graph, n_vertices, n_neighbors, max_candidates, rng_state):
"""Build a heap of candidate neighbors for nearest neighbor descent. For
each vertex the candidate neighbors are any current neighbors, and any
vertices that have the vertex as one of their nearest neighbors.
Param... | def build_candidates(current_graph, n_vertices, n_neighbors, max_candidates, rng_state):
"""Build a heap of candidate neighbors for nearest neighbor descent. For
each vertex the candidate neighbors are any current neighbors, and any
vertices that have the vertex as one of their nearest neighbors.
Param... | [
"Build",
"a",
"heap",
"of",
"candidate",
"neighbors",
"for",
"nearest",
"neighbor",
"descent",
".",
"For",
"each",
"vertex",
"the",
"candidate",
"neighbors",
"are",
"any",
"current",
"neighbors",
"and",
"any",
"vertices",
"that",
"have",
"the",
"vertex",
"as",... | lmcinnes/umap | python | https://github.com/lmcinnes/umap/blob/bbb01c03ba49f7bff8f77fd662d00e50d6686c77/umap/utils.py#L409-L448 | [
"def",
"build_candidates",
"(",
"current_graph",
",",
"n_vertices",
",",
"n_neighbors",
",",
"max_candidates",
",",
"rng_state",
")",
":",
"candidate_neighbors",
"=",
"make_heap",
"(",
"n_vertices",
",",
"max_candidates",
")",
"for",
"i",
"in",
"range",
"(",
"n_... | bbb01c03ba49f7bff8f77fd662d00e50d6686c77 |
train | new_build_candidates | Build a heap of candidate neighbors for nearest neighbor descent. For
each vertex the candidate neighbors are any current neighbors, and any
vertices that have the vertex as one of their nearest neighbors.
Parameters
----------
current_graph: heap
The current state of the graph for nearest ... | umap/utils.py | def new_build_candidates(
current_graph, n_vertices, n_neighbors, max_candidates, rng_state, rho=0.5
): # pragma: no cover
"""Build a heap of candidate neighbors for nearest neighbor descent. For
each vertex the candidate neighbors are any current neighbors, and any
vertices that have the vertex as one... | def new_build_candidates(
current_graph, n_vertices, n_neighbors, max_candidates, rng_state, rho=0.5
): # pragma: no cover
"""Build a heap of candidate neighbors for nearest neighbor descent. For
each vertex the candidate neighbors are any current neighbors, and any
vertices that have the vertex as one... | [
"Build",
"a",
"heap",
"of",
"candidate",
"neighbors",
"for",
"nearest",
"neighbor",
"descent",
".",
"For",
"each",
"vertex",
"the",
"candidate",
"neighbors",
"are",
"any",
"current",
"neighbors",
"and",
"any",
"vertices",
"that",
"have",
"the",
"vertex",
"as",... | lmcinnes/umap | python | https://github.com/lmcinnes/umap/blob/bbb01c03ba49f7bff8f77fd662d00e50d6686c77/umap/utils.py#L452-L503 | [
"def",
"new_build_candidates",
"(",
"current_graph",
",",
"n_vertices",
",",
"n_neighbors",
",",
"max_candidates",
",",
"rng_state",
",",
"rho",
"=",
"0.5",
")",
":",
"# pragma: no cover",
"new_candidate_neighbors",
"=",
"make_heap",
"(",
"n_vertices",
",",
"max_can... | bbb01c03ba49f7bff8f77fd662d00e50d6686c77 |
train | submatrix | Return a submatrix given an orginal matrix and the indices to keep.
Parameters
----------
mat: array, shape (n_samples, n_samples)
Original matrix.
indices_col: array, shape (n_samples, n_neighbors)
Indices to keep. Each row consists of the indices of the columns.
n_neighbors: int... | umap/utils.py | def submatrix(dmat, indices_col, n_neighbors):
"""Return a submatrix given an orginal matrix and the indices to keep.
Parameters
----------
mat: array, shape (n_samples, n_samples)
Original matrix.
indices_col: array, shape (n_samples, n_neighbors)
Indices to keep. Each row consist... | def submatrix(dmat, indices_col, n_neighbors):
"""Return a submatrix given an orginal matrix and the indices to keep.
Parameters
----------
mat: array, shape (n_samples, n_samples)
Original matrix.
indices_col: array, shape (n_samples, n_neighbors)
Indices to keep. Each row consist... | [
"Return",
"a",
"submatrix",
"given",
"an",
"orginal",
"matrix",
"and",
"the",
"indices",
"to",
"keep",
"."
] | lmcinnes/umap | python | https://github.com/lmcinnes/umap/blob/bbb01c03ba49f7bff8f77fd662d00e50d6686c77/umap/utils.py#L507-L531 | [
"def",
"submatrix",
"(",
"dmat",
",",
"indices_col",
",",
"n_neighbors",
")",
":",
"n_samples_transform",
",",
"n_samples_fit",
"=",
"dmat",
".",
"shape",
"submat",
"=",
"np",
".",
"zeros",
"(",
"(",
"n_samples_transform",
",",
"n_neighbors",
")",
",",
"dtyp... | bbb01c03ba49f7bff8f77fd662d00e50d6686c77 |
train | euclidean | Standard euclidean distance.
..math::
D(x, y) = \sqrt{\sum_i (x_i - y_i)^2} | umap/distances.py | def euclidean(x, y):
"""Standard euclidean distance.
..math::
D(x, y) = \sqrt{\sum_i (x_i - y_i)^2}
"""
result = 0.0
for i in range(x.shape[0]):
result += (x[i] - y[i]) ** 2
return np.sqrt(result) | def euclidean(x, y):
"""Standard euclidean distance.
..math::
D(x, y) = \sqrt{\sum_i (x_i - y_i)^2}
"""
result = 0.0
for i in range(x.shape[0]):
result += (x[i] - y[i]) ** 2
return np.sqrt(result) | [
"Standard",
"euclidean",
"distance",
"."
] | lmcinnes/umap | python | https://github.com/lmcinnes/umap/blob/bbb01c03ba49f7bff8f77fd662d00e50d6686c77/umap/distances.py#L12-L21 | [
"def",
"euclidean",
"(",
"x",
",",
"y",
")",
":",
"result",
"=",
"0.0",
"for",
"i",
"in",
"range",
"(",
"x",
".",
"shape",
"[",
"0",
"]",
")",
":",
"result",
"+=",
"(",
"x",
"[",
"i",
"]",
"-",
"y",
"[",
"i",
"]",
")",
"**",
"2",
"return"... | bbb01c03ba49f7bff8f77fd662d00e50d6686c77 |
train | standardised_euclidean | Euclidean distance standardised against a vector of standard
deviations per coordinate.
..math::
D(x, y) = \sqrt{\sum_i \frac{(x_i - y_i)**2}{v_i}} | umap/distances.py | def standardised_euclidean(x, y, sigma=_mock_ones):
"""Euclidean distance standardised against a vector of standard
deviations per coordinate.
..math::
D(x, y) = \sqrt{\sum_i \frac{(x_i - y_i)**2}{v_i}}
"""
result = 0.0
for i in range(x.shape[0]):
result += ((x[i] - y[i]) ** 2) ... | def standardised_euclidean(x, y, sigma=_mock_ones):
"""Euclidean distance standardised against a vector of standard
deviations per coordinate.
..math::
D(x, y) = \sqrt{\sum_i \frac{(x_i - y_i)**2}{v_i}}
"""
result = 0.0
for i in range(x.shape[0]):
result += ((x[i] - y[i]) ** 2) ... | [
"Euclidean",
"distance",
"standardised",
"against",
"a",
"vector",
"of",
"standard",
"deviations",
"per",
"coordinate",
"."
] | lmcinnes/umap | python | https://github.com/lmcinnes/umap/blob/bbb01c03ba49f7bff8f77fd662d00e50d6686c77/umap/distances.py#L25-L36 | [
"def",
"standardised_euclidean",
"(",
"x",
",",
"y",
",",
"sigma",
"=",
"_mock_ones",
")",
":",
"result",
"=",
"0.0",
"for",
"i",
"in",
"range",
"(",
"x",
".",
"shape",
"[",
"0",
"]",
")",
":",
"result",
"+=",
"(",
"(",
"x",
"[",
"i",
"]",
"-",... | bbb01c03ba49f7bff8f77fd662d00e50d6686c77 |
train | manhattan | Manhatten, taxicab, or l1 distance.
..math::
D(x, y) = \sum_i |x_i - y_i| | umap/distances.py | def manhattan(x, y):
"""Manhatten, taxicab, or l1 distance.
..math::
D(x, y) = \sum_i |x_i - y_i|
"""
result = 0.0
for i in range(x.shape[0]):
result += np.abs(x[i] - y[i])
return result | def manhattan(x, y):
"""Manhatten, taxicab, or l1 distance.
..math::
D(x, y) = \sum_i |x_i - y_i|
"""
result = 0.0
for i in range(x.shape[0]):
result += np.abs(x[i] - y[i])
return result | [
"Manhatten",
"taxicab",
"or",
"l1",
"distance",
"."
] | lmcinnes/umap | python | https://github.com/lmcinnes/umap/blob/bbb01c03ba49f7bff8f77fd662d00e50d6686c77/umap/distances.py#L40-L50 | [
"def",
"manhattan",
"(",
"x",
",",
"y",
")",
":",
"result",
"=",
"0.0",
"for",
"i",
"in",
"range",
"(",
"x",
".",
"shape",
"[",
"0",
"]",
")",
":",
"result",
"+=",
"np",
".",
"abs",
"(",
"x",
"[",
"i",
"]",
"-",
"y",
"[",
"i",
"]",
")",
... | bbb01c03ba49f7bff8f77fd662d00e50d6686c77 |
train | chebyshev | Chebyshev or l-infinity distance.
..math::
D(x, y) = \max_i |x_i - y_i| | umap/distances.py | def chebyshev(x, y):
"""Chebyshev or l-infinity distance.
..math::
D(x, y) = \max_i |x_i - y_i|
"""
result = 0.0
for i in range(x.shape[0]):
result = max(result, np.abs(x[i] - y[i]))
return result | def chebyshev(x, y):
"""Chebyshev or l-infinity distance.
..math::
D(x, y) = \max_i |x_i - y_i|
"""
result = 0.0
for i in range(x.shape[0]):
result = max(result, np.abs(x[i] - y[i]))
return result | [
"Chebyshev",
"or",
"l",
"-",
"infinity",
"distance",
"."
] | lmcinnes/umap | python | https://github.com/lmcinnes/umap/blob/bbb01c03ba49f7bff8f77fd662d00e50d6686c77/umap/distances.py#L54-L64 | [
"def",
"chebyshev",
"(",
"x",
",",
"y",
")",
":",
"result",
"=",
"0.0",
"for",
"i",
"in",
"range",
"(",
"x",
".",
"shape",
"[",
"0",
"]",
")",
":",
"result",
"=",
"max",
"(",
"result",
",",
"np",
".",
"abs",
"(",
"x",
"[",
"i",
"]",
"-",
... | bbb01c03ba49f7bff8f77fd662d00e50d6686c77 |
train | minkowski | Minkowski distance.
..math::
D(x, y) = \left(\sum_i |x_i - y_i|^p\right)^{\frac{1}{p}}
This is a general distance. For p=1 it is equivalent to
manhattan distance, for p=2 it is Euclidean distance, and
for p=infinity it is Chebyshev distance. In general it is better
to use the more speciali... | umap/distances.py | def minkowski(x, y, p=2):
"""Minkowski distance.
..math::
D(x, y) = \left(\sum_i |x_i - y_i|^p\right)^{\frac{1}{p}}
This is a general distance. For p=1 it is equivalent to
manhattan distance, for p=2 it is Euclidean distance, and
for p=infinity it is Chebyshev distance. In general it is be... | def minkowski(x, y, p=2):
"""Minkowski distance.
..math::
D(x, y) = \left(\sum_i |x_i - y_i|^p\right)^{\frac{1}{p}}
This is a general distance. For p=1 it is equivalent to
manhattan distance, for p=2 it is Euclidean distance, and
for p=infinity it is Chebyshev distance. In general it is be... | [
"Minkowski",
"distance",
"."
] | lmcinnes/umap | python | https://github.com/lmcinnes/umap/blob/bbb01c03ba49f7bff8f77fd662d00e50d6686c77/umap/distances.py#L68-L83 | [
"def",
"minkowski",
"(",
"x",
",",
"y",
",",
"p",
"=",
"2",
")",
":",
"result",
"=",
"0.0",
"for",
"i",
"in",
"range",
"(",
"x",
".",
"shape",
"[",
"0",
"]",
")",
":",
"result",
"+=",
"(",
"np",
".",
"abs",
"(",
"x",
"[",
"i",
"]",
"-",
... | bbb01c03ba49f7bff8f77fd662d00e50d6686c77 |
train | make_nn_descent | Create a numba accelerated version of nearest neighbor descent
specialised for the given distance metric and metric arguments. Numba
doesn't support higher order functions directly, but we can instead JIT
compile the version of NN-descent for any given metric.
Parameters
----------
dist: functi... | umap/nndescent.py | def make_nn_descent(dist, dist_args):
"""Create a numba accelerated version of nearest neighbor descent
specialised for the given distance metric and metric arguments. Numba
doesn't support higher order functions directly, but we can instead JIT
compile the version of NN-descent for any given metric.
... | def make_nn_descent(dist, dist_args):
"""Create a numba accelerated version of nearest neighbor descent
specialised for the given distance metric and metric arguments. Numba
doesn't support higher order functions directly, but we can instead JIT
compile the version of NN-descent for any given metric.
... | [
"Create",
"a",
"numba",
"accelerated",
"version",
"of",
"nearest",
"neighbor",
"descent",
"specialised",
"for",
"the",
"given",
"distance",
"metric",
"and",
"metric",
"arguments",
".",
"Numba",
"doesn",
"t",
"support",
"higher",
"order",
"functions",
"directly",
... | lmcinnes/umap | python | https://github.com/lmcinnes/umap/blob/bbb01c03ba49f7bff8f77fd662d00e50d6686c77/umap/nndescent.py#L24-L119 | [
"def",
"make_nn_descent",
"(",
"dist",
",",
"dist_args",
")",
":",
"@",
"numba",
".",
"njit",
"(",
"parallel",
"=",
"True",
")",
"def",
"nn_descent",
"(",
"data",
",",
"n_neighbors",
",",
"rng_state",
",",
"max_candidates",
"=",
"50",
",",
"n_iters",
"="... | bbb01c03ba49f7bff8f77fd662d00e50d6686c77 |
train | component_layout | Provide a layout relating the separate connected components. This is done
by taking the centroid of each component and then performing a spectral embedding
of the centroids.
Parameters
----------
data: array of shape (n_samples, n_features)
The source data -- required so we can generate cen... | umap/spectral.py | def component_layout(
data, n_components, component_labels, dim, metric="euclidean", metric_kwds={}
):
"""Provide a layout relating the separate connected components. This is done
by taking the centroid of each component and then performing a spectral embedding
of the centroids.
Parameters
----... | def component_layout(
data, n_components, component_labels, dim, metric="euclidean", metric_kwds={}
):
"""Provide a layout relating the separate connected components. This is done
by taking the centroid of each component and then performing a spectral embedding
of the centroids.
Parameters
----... | [
"Provide",
"a",
"layout",
"relating",
"the",
"separate",
"connected",
"components",
".",
"This",
"is",
"done",
"by",
"taking",
"the",
"centroid",
"of",
"each",
"component",
"and",
"then",
"performing",
"a",
"spectral",
"embedding",
"of",
"the",
"centroids",
".... | lmcinnes/umap | python | https://github.com/lmcinnes/umap/blob/bbb01c03ba49f7bff8f77fd662d00e50d6686c77/umap/spectral.py#L11-L62 | [
"def",
"component_layout",
"(",
"data",
",",
"n_components",
",",
"component_labels",
",",
"dim",
",",
"metric",
"=",
"\"euclidean\"",
",",
"metric_kwds",
"=",
"{",
"}",
")",
":",
"component_centroids",
"=",
"np",
".",
"empty",
"(",
"(",
"n_components",
",",... | bbb01c03ba49f7bff8f77fd662d00e50d6686c77 |
train | multi_component_layout | Specialised layout algorithm for dealing with graphs with many connected components.
This will first fid relative positions for the components by spectrally embedding
their centroids, then spectrally embed each individual connected component positioning
them according to the centroid embeddings. This provid... | umap/spectral.py | def multi_component_layout(
data,
graph,
n_components,
component_labels,
dim,
random_state,
metric="euclidean",
metric_kwds={},
):
"""Specialised layout algorithm for dealing with graphs with many connected components.
This will first fid relative positions for the components by ... | def multi_component_layout(
data,
graph,
n_components,
component_labels,
dim,
random_state,
metric="euclidean",
metric_kwds={},
):
"""Specialised layout algorithm for dealing with graphs with many connected components.
This will first fid relative positions for the components by ... | [
"Specialised",
"layout",
"algorithm",
"for",
"dealing",
"with",
"graphs",
"with",
"many",
"connected",
"components",
".",
"This",
"will",
"first",
"fid",
"relative",
"positions",
"for",
"the",
"components",
"by",
"spectrally",
"embedding",
"their",
"centroids",
"t... | lmcinnes/umap | python | https://github.com/lmcinnes/umap/blob/bbb01c03ba49f7bff8f77fd662d00e50d6686c77/umap/spectral.py#L65-L196 | [
"def",
"multi_component_layout",
"(",
"data",
",",
"graph",
",",
"n_components",
",",
"component_labels",
",",
"dim",
",",
"random_state",
",",
"metric",
"=",
"\"euclidean\"",
",",
"metric_kwds",
"=",
"{",
"}",
",",
")",
":",
"result",
"=",
"np",
".",
"emp... | bbb01c03ba49f7bff8f77fd662d00e50d6686c77 |
train | spectral_layout | Given a graph compute the spectral embedding of the graph. This is
simply the eigenvectors of the laplacian of the graph. Here we use the
normalized laplacian.
Parameters
----------
data: array of shape (n_samples, n_features)
The source data
graph: sparse matrix
The (weighted)... | umap/spectral.py | def spectral_layout(data, graph, dim, random_state, metric="euclidean", metric_kwds={}):
"""Given a graph compute the spectral embedding of the graph. This is
simply the eigenvectors of the laplacian of the graph. Here we use the
normalized laplacian.
Parameters
----------
data: array of shape ... | def spectral_layout(data, graph, dim, random_state, metric="euclidean", metric_kwds={}):
"""Given a graph compute the spectral embedding of the graph. This is
simply the eigenvectors of the laplacian of the graph. Here we use the
normalized laplacian.
Parameters
----------
data: array of shape ... | [
"Given",
"a",
"graph",
"compute",
"the",
"spectral",
"embedding",
"of",
"the",
"graph",
".",
"This",
"is",
"simply",
"the",
"eigenvectors",
"of",
"the",
"laplacian",
"of",
"the",
"graph",
".",
"Here",
"we",
"use",
"the",
"normalized",
"laplacian",
"."
] | lmcinnes/umap | python | https://github.com/lmcinnes/umap/blob/bbb01c03ba49f7bff8f77fd662d00e50d6686c77/umap/spectral.py#L199-L283 | [
"def",
"spectral_layout",
"(",
"data",
",",
"graph",
",",
"dim",
",",
"random_state",
",",
"metric",
"=",
"\"euclidean\"",
",",
"metric_kwds",
"=",
"{",
"}",
")",
":",
"n_samples",
"=",
"graph",
".",
"shape",
"[",
"0",
"]",
"n_components",
",",
"labels",... | bbb01c03ba49f7bff8f77fd662d00e50d6686c77 |
train | sparse_angular_random_projection_split | Given a set of ``indices`` for data points from a sparse data set
presented in csr sparse format as inds, indptr and data, create
a random hyperplane to split the data, returning two arrays indices
that fall on either side of the hyperplane. This is the basis for a
random projection tree, which simply u... | umap/rp_tree.py | def sparse_angular_random_projection_split(inds, indptr, data, indices, rng_state):
"""Given a set of ``indices`` for data points from a sparse data set
presented in csr sparse format as inds, indptr and data, create
a random hyperplane to split the data, returning two arrays indices
that fall on either... | def sparse_angular_random_projection_split(inds, indptr, data, indices, rng_state):
"""Given a set of ``indices`` for data points from a sparse data set
presented in csr sparse format as inds, indptr and data, create
a random hyperplane to split the data, returning two arrays indices
that fall on either... | [
"Given",
"a",
"set",
"of",
"indices",
"for",
"data",
"points",
"from",
"a",
"sparse",
"data",
"set",
"presented",
"in",
"csr",
"sparse",
"format",
"as",
"inds",
"indptr",
"and",
"data",
"create",
"a",
"random",
"hyperplane",
"to",
"split",
"the",
"data",
... | lmcinnes/umap | python | https://github.com/lmcinnes/umap/blob/bbb01c03ba49f7bff8f77fd662d00e50d6686c77/umap/rp_tree.py#L224-L338 | [
"def",
"sparse_angular_random_projection_split",
"(",
"inds",
",",
"indptr",
",",
"data",
",",
"indices",
",",
"rng_state",
")",
":",
"# Select two random points, set the hyperplane between them",
"left_index",
"=",
"tau_rand_int",
"(",
"rng_state",
")",
"%",
"indices",
... | bbb01c03ba49f7bff8f77fd662d00e50d6686c77 |
train | sparse_euclidean_random_projection_split | Given a set of ``indices`` for data points from a sparse data set
presented in csr sparse format as inds, indptr and data, create
a random hyperplane to split the data, returning two arrays indices
that fall on either side of the hyperplane. This is the basis for a
random projection tree, which simply u... | umap/rp_tree.py | def sparse_euclidean_random_projection_split(inds, indptr, data, indices, rng_state):
"""Given a set of ``indices`` for data points from a sparse data set
presented in csr sparse format as inds, indptr and data, create
a random hyperplane to split the data, returning two arrays indices
that fall on eith... | def sparse_euclidean_random_projection_split(inds, indptr, data, indices, rng_state):
"""Given a set of ``indices`` for data points from a sparse data set
presented in csr sparse format as inds, indptr and data, create
a random hyperplane to split the data, returning two arrays indices
that fall on eith... | [
"Given",
"a",
"set",
"of",
"indices",
"for",
"data",
"points",
"from",
"a",
"sparse",
"data",
"set",
"presented",
"in",
"csr",
"sparse",
"format",
"as",
"inds",
"indptr",
"and",
"data",
"create",
"a",
"random",
"hyperplane",
"to",
"split",
"the",
"data",
... | lmcinnes/umap | python | https://github.com/lmcinnes/umap/blob/bbb01c03ba49f7bff8f77fd662d00e50d6686c77/umap/rp_tree.py#L342-L447 | [
"def",
"sparse_euclidean_random_projection_split",
"(",
"inds",
",",
"indptr",
",",
"data",
",",
"indices",
",",
"rng_state",
")",
":",
"# Select two random points, set the hyperplane between them",
"left_index",
"=",
"tau_rand_int",
"(",
"rng_state",
")",
"%",
"indices",... | bbb01c03ba49f7bff8f77fd662d00e50d6686c77 |
train | make_tree | Construct a random projection tree based on ``data`` with leaves
of size at most ``leaf_size``.
Parameters
----------
data: array of shape (n_samples, n_features)
The original data to be split
rng_state: array of int64, shape (3,)
The internal state of the rng
leaf_size: int (opt... | umap/rp_tree.py | def make_tree(data, rng_state, leaf_size=30, angular=False):
"""Construct a random projection tree based on ``data`` with leaves
of size at most ``leaf_size``.
Parameters
----------
data: array of shape (n_samples, n_features)
The original data to be split
rng_state: array of int64, shap... | def make_tree(data, rng_state, leaf_size=30, angular=False):
"""Construct a random projection tree based on ``data`` with leaves
of size at most ``leaf_size``.
Parameters
----------
data: array of shape (n_samples, n_features)
The original data to be split
rng_state: array of int64, shap... | [
"Construct",
"a",
"random",
"projection",
"tree",
"based",
"on",
"data",
"with",
"leaves",
"of",
"size",
"at",
"most",
"leaf_size",
".",
"Parameters",
"----------",
"data",
":",
"array",
"of",
"shape",
"(",
"n_samples",
"n_features",
")",
"The",
"original",
... | lmcinnes/umap | python | https://github.com/lmcinnes/umap/blob/bbb01c03ba49f7bff8f77fd662d00e50d6686c77/umap/rp_tree.py#L534-L577 | [
"def",
"make_tree",
"(",
"data",
",",
"rng_state",
",",
"leaf_size",
"=",
"30",
",",
"angular",
"=",
"False",
")",
":",
"is_sparse",
"=",
"scipy",
".",
"sparse",
".",
"isspmatrix_csr",
"(",
"data",
")",
"indices",
"=",
"np",
".",
"arange",
"(",
"data",... | bbb01c03ba49f7bff8f77fd662d00e50d6686c77 |
train | num_nodes | Determine the number of nodes in a tree | umap/rp_tree.py | def num_nodes(tree):
"""Determine the number of nodes in a tree"""
if tree.is_leaf:
return 1
else:
return 1 + num_nodes(tree.left_child) + num_nodes(tree.right_child) | def num_nodes(tree):
"""Determine the number of nodes in a tree"""
if tree.is_leaf:
return 1
else:
return 1 + num_nodes(tree.left_child) + num_nodes(tree.right_child) | [
"Determine",
"the",
"number",
"of",
"nodes",
"in",
"a",
"tree"
] | lmcinnes/umap | python | https://github.com/lmcinnes/umap/blob/bbb01c03ba49f7bff8f77fd662d00e50d6686c77/umap/rp_tree.py#L580-L585 | [
"def",
"num_nodes",
"(",
"tree",
")",
":",
"if",
"tree",
".",
"is_leaf",
":",
"return",
"1",
"else",
":",
"return",
"1",
"+",
"num_nodes",
"(",
"tree",
".",
"left_child",
")",
"+",
"num_nodes",
"(",
"tree",
".",
"right_child",
")"
] | bbb01c03ba49f7bff8f77fd662d00e50d6686c77 |
train | num_leaves | Determine the number of leaves in a tree | umap/rp_tree.py | def num_leaves(tree):
"""Determine the number of leaves in a tree"""
if tree.is_leaf:
return 1
else:
return num_leaves(tree.left_child) + num_leaves(tree.right_child) | def num_leaves(tree):
"""Determine the number of leaves in a tree"""
if tree.is_leaf:
return 1
else:
return num_leaves(tree.left_child) + num_leaves(tree.right_child) | [
"Determine",
"the",
"number",
"of",
"leaves",
"in",
"a",
"tree"
] | lmcinnes/umap | python | https://github.com/lmcinnes/umap/blob/bbb01c03ba49f7bff8f77fd662d00e50d6686c77/umap/rp_tree.py#L588-L593 | [
"def",
"num_leaves",
"(",
"tree",
")",
":",
"if",
"tree",
".",
"is_leaf",
":",
"return",
"1",
"else",
":",
"return",
"num_leaves",
"(",
"tree",
".",
"left_child",
")",
"+",
"num_leaves",
"(",
"tree",
".",
"right_child",
")"
] | bbb01c03ba49f7bff8f77fd662d00e50d6686c77 |
train | max_sparse_hyperplane_size | Determine the most number on non zeros in a hyperplane entry | umap/rp_tree.py | def max_sparse_hyperplane_size(tree):
"""Determine the most number on non zeros in a hyperplane entry"""
if tree.is_leaf:
return 0
else:
return max(
tree.hyperplane.shape[1],
max_sparse_hyperplane_size(tree.left_child),
max_sparse_hyperplane_size(tree.righ... | def max_sparse_hyperplane_size(tree):
"""Determine the most number on non zeros in a hyperplane entry"""
if tree.is_leaf:
return 0
else:
return max(
tree.hyperplane.shape[1],
max_sparse_hyperplane_size(tree.left_child),
max_sparse_hyperplane_size(tree.righ... | [
"Determine",
"the",
"most",
"number",
"on",
"non",
"zeros",
"in",
"a",
"hyperplane",
"entry"
] | lmcinnes/umap | python | https://github.com/lmcinnes/umap/blob/bbb01c03ba49f7bff8f77fd662d00e50d6686c77/umap/rp_tree.py#L596-L605 | [
"def",
"max_sparse_hyperplane_size",
"(",
"tree",
")",
":",
"if",
"tree",
".",
"is_leaf",
":",
"return",
"0",
"else",
":",
"return",
"max",
"(",
"tree",
".",
"hyperplane",
".",
"shape",
"[",
"1",
"]",
",",
"max_sparse_hyperplane_size",
"(",
"tree",
".",
... | bbb01c03ba49f7bff8f77fd662d00e50d6686c77 |
train | make_forest | Build a random projection forest with ``n_trees``.
Parameters
----------
data
n_neighbors
n_trees
rng_state
angular
Returns
-------
forest: list
A list of random projection trees. | umap/rp_tree.py | def make_forest(data, n_neighbors, n_trees, rng_state, angular=False):
"""Build a random projection forest with ``n_trees``.
Parameters
----------
data
n_neighbors
n_trees
rng_state
angular
Returns
-------
forest: list
A list of random projection trees.
"""
... | def make_forest(data, n_neighbors, n_trees, rng_state, angular=False):
"""Build a random projection forest with ``n_trees``.
Parameters
----------
data
n_neighbors
n_trees
rng_state
angular
Returns
-------
forest: list
A list of random projection trees.
"""
... | [
"Build",
"a",
"random",
"projection",
"forest",
"with",
"n_trees",
"."
] | lmcinnes/umap | python | https://github.com/lmcinnes/umap/blob/bbb01c03ba49f7bff8f77fd662d00e50d6686c77/umap/rp_tree.py#L698-L728 | [
"def",
"make_forest",
"(",
"data",
",",
"n_neighbors",
",",
"n_trees",
",",
"rng_state",
",",
"angular",
"=",
"False",
")",
":",
"result",
"=",
"[",
"]",
"leaf_size",
"=",
"max",
"(",
"10",
",",
"n_neighbors",
")",
"try",
":",
"result",
"=",
"[",
"fl... | bbb01c03ba49f7bff8f77fd662d00e50d6686c77 |
train | rptree_leaf_array | Generate an array of sets of candidate nearest neighbors by
constructing a random projection forest and taking the leaves of all the
trees. Any given tree has leaves that are a set of potential nearest
neighbors. Given enough trees the set of all such leaves gives a good
likelihood of getting a good set... | umap/rp_tree.py | def rptree_leaf_array(rp_forest):
"""Generate an array of sets of candidate nearest neighbors by
constructing a random projection forest and taking the leaves of all the
trees. Any given tree has leaves that are a set of potential nearest
neighbors. Given enough trees the set of all such leaves gives a ... | def rptree_leaf_array(rp_forest):
"""Generate an array of sets of candidate nearest neighbors by
constructing a random projection forest and taking the leaves of all the
trees. Any given tree has leaves that are a set of potential nearest
neighbors. Given enough trees the set of all such leaves gives a ... | [
"Generate",
"an",
"array",
"of",
"sets",
"of",
"candidate",
"nearest",
"neighbors",
"by",
"constructing",
"a",
"random",
"projection",
"forest",
"and",
"taking",
"the",
"leaves",
"of",
"all",
"the",
"trees",
".",
"Any",
"given",
"tree",
"has",
"leaves",
"tha... | lmcinnes/umap | python | https://github.com/lmcinnes/umap/blob/bbb01c03ba49f7bff8f77fd662d00e50d6686c77/umap/rp_tree.py#L731-L764 | [
"def",
"rptree_leaf_array",
"(",
"rp_forest",
")",
":",
"if",
"len",
"(",
"rp_forest",
")",
">",
"0",
":",
"leaf_array",
"=",
"np",
".",
"vstack",
"(",
"[",
"tree",
".",
"indices",
"for",
"tree",
"in",
"rp_forest",
"]",
")",
"else",
":",
"leaf_array",
... | bbb01c03ba49f7bff8f77fd662d00e50d6686c77 |
train | smooth_knn_dist | Compute a continuous version of the distance to the kth nearest
neighbor. That is, this is similar to knn-distance but allows continuous
k values rather than requiring an integral k. In esscence we are simply
computing the distance such that the cardinality of fuzzy set we generate
is k.
Parameters... | umap/umap_.py | def smooth_knn_dist(distances, k, n_iter=64, local_connectivity=1.0, bandwidth=1.0):
"""Compute a continuous version of the distance to the kth nearest
neighbor. That is, this is similar to knn-distance but allows continuous
k values rather than requiring an integral k. In esscence we are simply
computi... | def smooth_knn_dist(distances, k, n_iter=64, local_connectivity=1.0, bandwidth=1.0):
"""Compute a continuous version of the distance to the kth nearest
neighbor. That is, this is similar to knn-distance but allows continuous
k values rather than requiring an integral k. In esscence we are simply
computi... | [
"Compute",
"a",
"continuous",
"version",
"of",
"the",
"distance",
"to",
"the",
"kth",
"nearest",
"neighbor",
".",
"That",
"is",
"this",
"is",
"similar",
"to",
"knn",
"-",
"distance",
"but",
"allows",
"continuous",
"k",
"values",
"rather",
"than",
"requiring"... | lmcinnes/umap | python | https://github.com/lmcinnes/umap/blob/bbb01c03ba49f7bff8f77fd662d00e50d6686c77/umap/umap_.py#L49-L146 | [
"def",
"smooth_knn_dist",
"(",
"distances",
",",
"k",
",",
"n_iter",
"=",
"64",
",",
"local_connectivity",
"=",
"1.0",
",",
"bandwidth",
"=",
"1.0",
")",
":",
"target",
"=",
"np",
".",
"log2",
"(",
"k",
")",
"*",
"bandwidth",
"rho",
"=",
"np",
".",
... | bbb01c03ba49f7bff8f77fd662d00e50d6686c77 |
train | nearest_neighbors | Compute the ``n_neighbors`` nearest points for each data point in ``X``
under ``metric``. This may be exact, but more likely is approximated via
nearest neighbor descent.
Parameters
----------
X: array of shape (n_samples, n_features)
The input data to compute the k-neighbor graph of.
... | umap/umap_.py | def nearest_neighbors(
X, n_neighbors, metric, metric_kwds, angular, random_state, verbose=False
):
"""Compute the ``n_neighbors`` nearest points for each data point in ``X``
under ``metric``. This may be exact, but more likely is approximated via
nearest neighbor descent.
Parameters
----------... | def nearest_neighbors(
X, n_neighbors, metric, metric_kwds, angular, random_state, verbose=False
):
"""Compute the ``n_neighbors`` nearest points for each data point in ``X``
under ``metric``. This may be exact, but more likely is approximated via
nearest neighbor descent.
Parameters
----------... | [
"Compute",
"the",
"n_neighbors",
"nearest",
"points",
"for",
"each",
"data",
"point",
"in",
"X",
"under",
"metric",
".",
"This",
"may",
"be",
"exact",
"but",
"more",
"likely",
"is",
"approximated",
"via",
"nearest",
"neighbor",
"descent",
"."
] | lmcinnes/umap | python | https://github.com/lmcinnes/umap/blob/bbb01c03ba49f7bff8f77fd662d00e50d6686c77/umap/umap_.py#L149-L282 | [
"def",
"nearest_neighbors",
"(",
"X",
",",
"n_neighbors",
",",
"metric",
",",
"metric_kwds",
",",
"angular",
",",
"random_state",
",",
"verbose",
"=",
"False",
")",
":",
"if",
"verbose",
":",
"print",
"(",
"ts",
"(",
")",
",",
"\"Finding Nearest Neighbors\""... | bbb01c03ba49f7bff8f77fd662d00e50d6686c77 |
train | compute_membership_strengths | Construct the membership strength data for the 1-skeleton of each local
fuzzy simplicial set -- this is formed as a sparse matrix where each row is
a local fuzzy simplicial set, with a membership strength for the
1-simplex to each other data point.
Parameters
----------
knn_indices: array of sh... | umap/umap_.py | def compute_membership_strengths(knn_indices, knn_dists, sigmas, rhos):
"""Construct the membership strength data for the 1-skeleton of each local
fuzzy simplicial set -- this is formed as a sparse matrix where each row is
a local fuzzy simplicial set, with a membership strength for the
1-simplex to eac... | def compute_membership_strengths(knn_indices, knn_dists, sigmas, rhos):
"""Construct the membership strength data for the 1-skeleton of each local
fuzzy simplicial set -- this is formed as a sparse matrix where each row is
a local fuzzy simplicial set, with a membership strength for the
1-simplex to eac... | [
"Construct",
"the",
"membership",
"strength",
"data",
"for",
"the",
"1",
"-",
"skeleton",
"of",
"each",
"local",
"fuzzy",
"simplicial",
"set",
"--",
"this",
"is",
"formed",
"as",
"a",
"sparse",
"matrix",
"where",
"each",
"row",
"is",
"a",
"local",
"fuzzy",... | lmcinnes/umap | python | https://github.com/lmcinnes/umap/blob/bbb01c03ba49f7bff8f77fd662d00e50d6686c77/umap/umap_.py#L286-L339 | [
"def",
"compute_membership_strengths",
"(",
"knn_indices",
",",
"knn_dists",
",",
"sigmas",
",",
"rhos",
")",
":",
"n_samples",
"=",
"knn_indices",
".",
"shape",
"[",
"0",
"]",
"n_neighbors",
"=",
"knn_indices",
".",
"shape",
"[",
"1",
"]",
"rows",
"=",
"n... | bbb01c03ba49f7bff8f77fd662d00e50d6686c77 |
train | fuzzy_simplicial_set | Given a set of data X, a neighborhood size, and a measure of distance
compute the fuzzy simplicial set (here represented as a fuzzy graph in
the form of a sparse matrix) associated to the data. This is done by
locally approximating geodesic distance at each point, creating a fuzzy
simplicial set for eac... | umap/umap_.py | def fuzzy_simplicial_set(
X,
n_neighbors,
random_state,
metric,
metric_kwds={},
knn_indices=None,
knn_dists=None,
angular=False,
set_op_mix_ratio=1.0,
local_connectivity=1.0,
verbose=False,
):
"""Given a set of data X, a neighborhood size, and a measure of distance
co... | def fuzzy_simplicial_set(
X,
n_neighbors,
random_state,
metric,
metric_kwds={},
knn_indices=None,
knn_dists=None,
angular=False,
set_op_mix_ratio=1.0,
local_connectivity=1.0,
verbose=False,
):
"""Given a set of data X, a neighborhood size, and a measure of distance
co... | [
"Given",
"a",
"set",
"of",
"data",
"X",
"a",
"neighborhood",
"size",
"and",
"a",
"measure",
"of",
"distance",
"compute",
"the",
"fuzzy",
"simplicial",
"set",
"(",
"here",
"represented",
"as",
"a",
"fuzzy",
"graph",
"in",
"the",
"form",
"of",
"a",
"sparse... | lmcinnes/umap | python | https://github.com/lmcinnes/umap/blob/bbb01c03ba49f7bff8f77fd662d00e50d6686c77/umap/umap_.py#L343-L488 | [
"def",
"fuzzy_simplicial_set",
"(",
"X",
",",
"n_neighbors",
",",
"random_state",
",",
"metric",
",",
"metric_kwds",
"=",
"{",
"}",
",",
"knn_indices",
"=",
"None",
",",
"knn_dists",
"=",
"None",
",",
"angular",
"=",
"False",
",",
"set_op_mix_ratio",
"=",
... | bbb01c03ba49f7bff8f77fd662d00e50d6686c77 |
train | fast_intersection | Under the assumption of categorical distance for the intersecting
simplicial set perform a fast intersection.
Parameters
----------
rows: array
An array of the row of each non-zero in the sparse matrix
representation.
cols: array
An array of the column of each non-zero in t... | umap/umap_.py | def fast_intersection(rows, cols, values, target, unknown_dist=1.0, far_dist=5.0):
"""Under the assumption of categorical distance for the intersecting
simplicial set perform a fast intersection.
Parameters
----------
rows: array
An array of the row of each non-zero in the sparse matrix
... | def fast_intersection(rows, cols, values, target, unknown_dist=1.0, far_dist=5.0):
"""Under the assumption of categorical distance for the intersecting
simplicial set perform a fast intersection.
Parameters
----------
rows: array
An array of the row of each non-zero in the sparse matrix
... | [
"Under",
"the",
"assumption",
"of",
"categorical",
"distance",
"for",
"the",
"intersecting",
"simplicial",
"set",
"perform",
"a",
"fast",
"intersection",
"."
] | lmcinnes/umap | python | https://github.com/lmcinnes/umap/blob/bbb01c03ba49f7bff8f77fd662d00e50d6686c77/umap/umap_.py#L492-L531 | [
"def",
"fast_intersection",
"(",
"rows",
",",
"cols",
",",
"values",
",",
"target",
",",
"unknown_dist",
"=",
"1.0",
",",
"far_dist",
"=",
"5.0",
")",
":",
"for",
"nz",
"in",
"range",
"(",
"rows",
".",
"shape",
"[",
"0",
"]",
")",
":",
"i",
"=",
... | bbb01c03ba49f7bff8f77fd662d00e50d6686c77 |
train | reset_local_connectivity | Reset the local connectivity requirement -- each data sample should
have complete confidence in at least one 1-simplex in the simplicial set.
We can enforce this by locally rescaling confidences, and then remerging the
different local simplicial sets together.
Parameters
----------
simplicial_s... | umap/umap_.py | def reset_local_connectivity(simplicial_set):
"""Reset the local connectivity requirement -- each data sample should
have complete confidence in at least one 1-simplex in the simplicial set.
We can enforce this by locally rescaling confidences, and then remerging the
different local simplicial sets toge... | def reset_local_connectivity(simplicial_set):
"""Reset the local connectivity requirement -- each data sample should
have complete confidence in at least one 1-simplex in the simplicial set.
We can enforce this by locally rescaling confidences, and then remerging the
different local simplicial sets toge... | [
"Reset",
"the",
"local",
"connectivity",
"requirement",
"--",
"each",
"data",
"sample",
"should",
"have",
"complete",
"confidence",
"in",
"at",
"least",
"one",
"1",
"-",
"simplex",
"in",
"the",
"simplicial",
"set",
".",
"We",
"can",
"enforce",
"this",
"by",
... | lmcinnes/umap | python | https://github.com/lmcinnes/umap/blob/bbb01c03ba49f7bff8f77fd662d00e50d6686c77/umap/umap_.py#L535-L559 | [
"def",
"reset_local_connectivity",
"(",
"simplicial_set",
")",
":",
"simplicial_set",
"=",
"normalize",
"(",
"simplicial_set",
",",
"norm",
"=",
"\"max\"",
")",
"transpose",
"=",
"simplicial_set",
".",
"transpose",
"(",
")",
"prod_matrix",
"=",
"simplicial_set",
"... | bbb01c03ba49f7bff8f77fd662d00e50d6686c77 |
train | categorical_simplicial_set_intersection | Combine a fuzzy simplicial set with another fuzzy simplicial set
generated from categorical data using categorical distances. The target
data is assumed to be categorical label data (a vector of labels),
and this will update the fuzzy simplicial set to respect that label data.
TODO: optional category c... | umap/umap_.py | def categorical_simplicial_set_intersection(
simplicial_set, target, unknown_dist=1.0, far_dist=5.0
):
"""Combine a fuzzy simplicial set with another fuzzy simplicial set
generated from categorical data using categorical distances. The target
data is assumed to be categorical label data (a vector of lab... | def categorical_simplicial_set_intersection(
simplicial_set, target, unknown_dist=1.0, far_dist=5.0
):
"""Combine a fuzzy simplicial set with another fuzzy simplicial set
generated from categorical data using categorical distances. The target
data is assumed to be categorical label data (a vector of lab... | [
"Combine",
"a",
"fuzzy",
"simplicial",
"set",
"with",
"another",
"fuzzy",
"simplicial",
"set",
"generated",
"from",
"categorical",
"data",
"using",
"categorical",
"distances",
".",
"The",
"target",
"data",
"is",
"assumed",
"to",
"be",
"categorical",
"label",
"da... | lmcinnes/umap | python | https://github.com/lmcinnes/umap/blob/bbb01c03ba49f7bff8f77fd662d00e50d6686c77/umap/umap_.py#L563-L605 | [
"def",
"categorical_simplicial_set_intersection",
"(",
"simplicial_set",
",",
"target",
",",
"unknown_dist",
"=",
"1.0",
",",
"far_dist",
"=",
"5.0",
")",
":",
"simplicial_set",
"=",
"simplicial_set",
".",
"tocoo",
"(",
")",
"fast_intersection",
"(",
"simplicial_set... | bbb01c03ba49f7bff8f77fd662d00e50d6686c77 |
train | make_epochs_per_sample | Given a set of weights and number of epochs generate the number of
epochs per sample for each weight.
Parameters
----------
weights: array of shape (n_1_simplices)
The weights ofhow much we wish to sample each 1-simplex.
n_epochs: int
The total number of epochs we want to train for... | umap/umap_.py | def make_epochs_per_sample(weights, n_epochs):
"""Given a set of weights and number of epochs generate the number of
epochs per sample for each weight.
Parameters
----------
weights: array of shape (n_1_simplices)
The weights ofhow much we wish to sample each 1-simplex.
n_epochs: int
... | def make_epochs_per_sample(weights, n_epochs):
"""Given a set of weights and number of epochs generate the number of
epochs per sample for each weight.
Parameters
----------
weights: array of shape (n_1_simplices)
The weights ofhow much we wish to sample each 1-simplex.
n_epochs: int
... | [
"Given",
"a",
"set",
"of",
"weights",
"and",
"number",
"of",
"epochs",
"generate",
"the",
"number",
"of",
"epochs",
"per",
"sample",
"for",
"each",
"weight",
"."
] | lmcinnes/umap | python | https://github.com/lmcinnes/umap/blob/bbb01c03ba49f7bff8f77fd662d00e50d6686c77/umap/umap_.py#L632-L651 | [
"def",
"make_epochs_per_sample",
"(",
"weights",
",",
"n_epochs",
")",
":",
"result",
"=",
"-",
"1.0",
"*",
"np",
".",
"ones",
"(",
"weights",
".",
"shape",
"[",
"0",
"]",
",",
"dtype",
"=",
"np",
".",
"float64",
")",
"n_samples",
"=",
"n_epochs",
"*... | bbb01c03ba49f7bff8f77fd662d00e50d6686c77 |
train | rdist | Reduced Euclidean distance.
Parameters
----------
x: array of shape (embedding_dim,)
y: array of shape (embedding_dim,)
Returns
-------
The squared euclidean distance between x and y | umap/umap_.py | def rdist(x, y):
"""Reduced Euclidean distance.
Parameters
----------
x: array of shape (embedding_dim,)
y: array of shape (embedding_dim,)
Returns
-------
The squared euclidean distance between x and y
"""
result = 0.0
for i in range(x.shape[0]):
result += (x[i] - ... | def rdist(x, y):
"""Reduced Euclidean distance.
Parameters
----------
x: array of shape (embedding_dim,)
y: array of shape (embedding_dim,)
Returns
-------
The squared euclidean distance between x and y
"""
result = 0.0
for i in range(x.shape[0]):
result += (x[i] - ... | [
"Reduced",
"Euclidean",
"distance",
"."
] | lmcinnes/umap | python | https://github.com/lmcinnes/umap/blob/bbb01c03ba49f7bff8f77fd662d00e50d6686c77/umap/umap_.py#L677-L693 | [
"def",
"rdist",
"(",
"x",
",",
"y",
")",
":",
"result",
"=",
"0.0",
"for",
"i",
"in",
"range",
"(",
"x",
".",
"shape",
"[",
"0",
"]",
")",
":",
"result",
"+=",
"(",
"x",
"[",
"i",
"]",
"-",
"y",
"[",
"i",
"]",
")",
"**",
"2",
"return",
... | bbb01c03ba49f7bff8f77fd662d00e50d6686c77 |
train | optimize_layout | Improve an embedding using stochastic gradient descent to minimize the
fuzzy set cross entropy between the 1-skeletons of the high dimensional
and low dimensional fuzzy simplicial sets. In practice this is done by
sampling edges based on their membership strength (with the (1-p) terms
coming from negati... | umap/umap_.py | def optimize_layout(
head_embedding,
tail_embedding,
head,
tail,
n_epochs,
n_vertices,
epochs_per_sample,
a,
b,
rng_state,
gamma=1.0,
initial_alpha=1.0,
negative_sample_rate=5.0,
verbose=False,
):
"""Improve an embedding using stochastic gradient descent to mi... | def optimize_layout(
head_embedding,
tail_embedding,
head,
tail,
n_epochs,
n_vertices,
epochs_per_sample,
a,
b,
rng_state,
gamma=1.0,
initial_alpha=1.0,
negative_sample_rate=5.0,
verbose=False,
):
"""Improve an embedding using stochastic gradient descent to mi... | [
"Improve",
"an",
"embedding",
"using",
"stochastic",
"gradient",
"descent",
"to",
"minimize",
"the",
"fuzzy",
"set",
"cross",
"entropy",
"between",
"the",
"1",
"-",
"skeletons",
"of",
"the",
"high",
"dimensional",
"and",
"low",
"dimensional",
"fuzzy",
"simplicia... | lmcinnes/umap | python | https://github.com/lmcinnes/umap/blob/bbb01c03ba49f7bff8f77fd662d00e50d6686c77/umap/umap_.py#L697-L844 | [
"def",
"optimize_layout",
"(",
"head_embedding",
",",
"tail_embedding",
",",
"head",
",",
"tail",
",",
"n_epochs",
",",
"n_vertices",
",",
"epochs_per_sample",
",",
"a",
",",
"b",
",",
"rng_state",
",",
"gamma",
"=",
"1.0",
",",
"initial_alpha",
"=",
"1.0",
... | bbb01c03ba49f7bff8f77fd662d00e50d6686c77 |
train | simplicial_set_embedding | Perform a fuzzy simplicial set embedding, using a specified
initialisation method and then minimizing the fuzzy set cross entropy
between the 1-skeletons of the high and low dimensional fuzzy simplicial
sets.
Parameters
----------
data: array of shape (n_samples, n_features)
The source ... | umap/umap_.py | def simplicial_set_embedding(
data,
graph,
n_components,
initial_alpha,
a,
b,
gamma,
negative_sample_rate,
n_epochs,
init,
random_state,
metric,
metric_kwds,
verbose,
):
"""Perform a fuzzy simplicial set embedding, using a specified
initialisation method a... | def simplicial_set_embedding(
data,
graph,
n_components,
initial_alpha,
a,
b,
gamma,
negative_sample_rate,
n_epochs,
init,
random_state,
metric,
metric_kwds,
verbose,
):
"""Perform a fuzzy simplicial set embedding, using a specified
initialisation method a... | [
"Perform",
"a",
"fuzzy",
"simplicial",
"set",
"embedding",
"using",
"a",
"specified",
"initialisation",
"method",
"and",
"then",
"minimizing",
"the",
"fuzzy",
"set",
"cross",
"entropy",
"between",
"the",
"1",
"-",
"skeletons",
"of",
"the",
"high",
"and",
"low"... | lmcinnes/umap | python | https://github.com/lmcinnes/umap/blob/bbb01c03ba49f7bff8f77fd662d00e50d6686c77/umap/umap_.py#L847-L1003 | [
"def",
"simplicial_set_embedding",
"(",
"data",
",",
"graph",
",",
"n_components",
",",
"initial_alpha",
",",
"a",
",",
"b",
",",
"gamma",
",",
"negative_sample_rate",
",",
"n_epochs",
",",
"init",
",",
"random_state",
",",
"metric",
",",
"metric_kwds",
",",
... | bbb01c03ba49f7bff8f77fd662d00e50d6686c77 |
train | init_transform | Given indices and weights and an original embeddings
initialize the positions of new points relative to the
indices and weights (of their neighbors in the source data).
Parameters
----------
indices: array of shape (n_new_samples, n_neighbors)
The indices of the neighbors of each new sample... | umap/umap_.py | def init_transform(indices, weights, embedding):
"""Given indices and weights and an original embeddings
initialize the positions of new points relative to the
indices and weights (of their neighbors in the source data).
Parameters
----------
indices: array of shape (n_new_samples, n_neighbors)... | def init_transform(indices, weights, embedding):
"""Given indices and weights and an original embeddings
initialize the positions of new points relative to the
indices and weights (of their neighbors in the source data).
Parameters
----------
indices: array of shape (n_new_samples, n_neighbors)... | [
"Given",
"indices",
"and",
"weights",
"and",
"an",
"original",
"embeddings",
"initialize",
"the",
"positions",
"of",
"new",
"points",
"relative",
"to",
"the",
"indices",
"and",
"weights",
"(",
"of",
"their",
"neighbors",
"in",
"the",
"source",
"data",
")",
"... | lmcinnes/umap | python | https://github.com/lmcinnes/umap/blob/bbb01c03ba49f7bff8f77fd662d00e50d6686c77/umap/umap_.py#L1007-L1036 | [
"def",
"init_transform",
"(",
"indices",
",",
"weights",
",",
"embedding",
")",
":",
"result",
"=",
"np",
".",
"zeros",
"(",
"(",
"indices",
".",
"shape",
"[",
"0",
"]",
",",
"embedding",
".",
"shape",
"[",
"1",
"]",
")",
",",
"dtype",
"=",
"np",
... | bbb01c03ba49f7bff8f77fd662d00e50d6686c77 |
train | find_ab_params | Fit a, b params for the differentiable curve used in lower
dimensional fuzzy simplicial complex construction. We want the
smooth curve (from a pre-defined family with simple gradient) that
best matches an offset exponential decay. | umap/umap_.py | def find_ab_params(spread, min_dist):
"""Fit a, b params for the differentiable curve used in lower
dimensional fuzzy simplicial complex construction. We want the
smooth curve (from a pre-defined family with simple gradient) that
best matches an offset exponential decay.
"""
def curve(x, a, b):... | def find_ab_params(spread, min_dist):
"""Fit a, b params for the differentiable curve used in lower
dimensional fuzzy simplicial complex construction. We want the
smooth curve (from a pre-defined family with simple gradient) that
best matches an offset exponential decay.
"""
def curve(x, a, b):... | [
"Fit",
"a",
"b",
"params",
"for",
"the",
"differentiable",
"curve",
"used",
"in",
"lower",
"dimensional",
"fuzzy",
"simplicial",
"complex",
"construction",
".",
"We",
"want",
"the",
"smooth",
"curve",
"(",
"from",
"a",
"pre",
"-",
"defined",
"family",
"with"... | lmcinnes/umap | python | https://github.com/lmcinnes/umap/blob/bbb01c03ba49f7bff8f77fd662d00e50d6686c77/umap/umap_.py#L1039-L1054 | [
"def",
"find_ab_params",
"(",
"spread",
",",
"min_dist",
")",
":",
"def",
"curve",
"(",
"x",
",",
"a",
",",
"b",
")",
":",
"return",
"1.0",
"/",
"(",
"1.0",
"+",
"a",
"*",
"x",
"**",
"(",
"2",
"*",
"b",
")",
")",
"xv",
"=",
"np",
".",
"lins... | bbb01c03ba49f7bff8f77fd662d00e50d6686c77 |
train | UMAP.fit | Fit X into an embedded space.
Optionally use y for supervised dimension reduction.
Parameters
----------
X : array, shape (n_samples, n_features) or (n_samples, n_samples)
If the metric is 'precomputed' X must be a square distance
matrix. Otherwise it contains a... | umap/umap_.py | def fit(self, X, y=None):
"""Fit X into an embedded space.
Optionally use y for supervised dimension reduction.
Parameters
----------
X : array, shape (n_samples, n_features) or (n_samples, n_samples)
If the metric is 'precomputed' X must be a square distance
... | def fit(self, X, y=None):
"""Fit X into an embedded space.
Optionally use y for supervised dimension reduction.
Parameters
----------
X : array, shape (n_samples, n_features) or (n_samples, n_samples)
If the metric is 'precomputed' X must be a square distance
... | [
"Fit",
"X",
"into",
"an",
"embedded",
"space",
"."
] | lmcinnes/umap | python | https://github.com/lmcinnes/umap/blob/bbb01c03ba49f7bff8f77fd662d00e50d6686c77/umap/umap_.py#L1319-L1566 | [
"def",
"fit",
"(",
"self",
",",
"X",
",",
"y",
"=",
"None",
")",
":",
"X",
"=",
"check_array",
"(",
"X",
",",
"dtype",
"=",
"np",
".",
"float32",
",",
"accept_sparse",
"=",
"\"csr\"",
")",
"self",
".",
"_raw_data",
"=",
"X",
"# Handle all the optiona... | bbb01c03ba49f7bff8f77fd662d00e50d6686c77 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.