repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
coderholic/pyradio | pyradio/config.py | PyRadioStations._playlist_format_changed | def _playlist_format_changed(self):
""" Check if we have new or old format
and report if format has changed
Format type can change by editing encoding,
deleting a non-utf-8 station etc.
"""
new_format = False
for n in self.stations:
if n[2... | python | def _playlist_format_changed(self):
""" Check if we have new or old format
and report if format has changed
Format type can change by editing encoding,
deleting a non-utf-8 station etc.
"""
new_format = False
for n in self.stations:
if n[2... | [
"def",
"_playlist_format_changed",
"(",
"self",
")",
":",
"new_format",
"=",
"False",
"for",
"n",
"in",
"self",
".",
"stations",
":",
"if",
"n",
"[",
"2",
"]",
"!=",
"''",
":",
"new_format",
"=",
"True",
"break",
"if",
"self",
".",
"new_format",
"==",
... | Check if we have new or old format
and report if format has changed
Format type can change by editing encoding,
deleting a non-utf-8 station etc. | [
"Check",
"if",
"we",
"have",
"new",
"or",
"old",
"format",
"and",
"report",
"if",
"format",
"has",
"changed"
] | c5219d350bccbccd49dbd627c1f886a952ea1963 | https://github.com/coderholic/pyradio/blob/c5219d350bccbccd49dbd627c1f886a952ea1963/pyradio/config.py#L241-L256 | train |
coderholic/pyradio | pyradio/config.py | PyRadioStations.save_playlist_file | def save_playlist_file(self, stationFile=''):
""" Save a playlist
Create a txt file and write stations in it.
Then rename it to final target
return 0: All ok
-1: Error writing file
-2: Error renaming file
"""
if self._playlist_format_... | python | def save_playlist_file(self, stationFile=''):
""" Save a playlist
Create a txt file and write stations in it.
Then rename it to final target
return 0: All ok
-1: Error writing file
-2: Error renaming file
"""
if self._playlist_format_... | [
"def",
"save_playlist_file",
"(",
"self",
",",
"stationFile",
"=",
"''",
")",
":",
"if",
"self",
".",
"_playlist_format_changed",
"(",
")",
":",
"self",
".",
"dirty_playlist",
"=",
"True",
"self",
".",
"new_format",
"=",
"not",
"self",
".",
"new_format",
"... | Save a playlist
Create a txt file and write stations in it.
Then rename it to final target
return 0: All ok
-1: Error writing file
-2: Error renaming file | [
"Save",
"a",
"playlist",
"Create",
"a",
"txt",
"file",
"and",
"write",
"stations",
"in",
"it",
".",
"Then",
"rename",
"it",
"to",
"final",
"target"
] | c5219d350bccbccd49dbd627c1f886a952ea1963 | https://github.com/coderholic/pyradio/blob/c5219d350bccbccd49dbd627c1f886a952ea1963/pyradio/config.py#L258-L306 | train |
coderholic/pyradio | pyradio/config.py | PyRadioStations._bytes_to_human | def _bytes_to_human(self, B):
''' Return the given bytes as a human friendly KB, MB, GB, or TB string '''
KB = float(1024)
MB = float(KB ** 2) # 1,048,576
GB = float(KB ** 3) # 1,073,741,824
TB = float(KB ** 4) # 1,099,511,627,776
if B < KB:
return '{0} B'.fo... | python | def _bytes_to_human(self, B):
''' Return the given bytes as a human friendly KB, MB, GB, or TB string '''
KB = float(1024)
MB = float(KB ** 2) # 1,048,576
GB = float(KB ** 3) # 1,073,741,824
TB = float(KB ** 4) # 1,099,511,627,776
if B < KB:
return '{0} B'.fo... | [
"def",
"_bytes_to_human",
"(",
"self",
",",
"B",
")",
":",
"KB",
"=",
"float",
"(",
"1024",
")",
"MB",
"=",
"float",
"(",
"KB",
"**",
"2",
")",
"# 1,048,576",
"GB",
"=",
"float",
"(",
"KB",
"**",
"3",
")",
"# 1,073,741,824",
"TB",
"=",
"float",
"... | Return the given bytes as a human friendly KB, MB, GB, or TB string | [
"Return",
"the",
"given",
"bytes",
"as",
"a",
"human",
"friendly",
"KB",
"MB",
"GB",
"or",
"TB",
"string"
] | c5219d350bccbccd49dbd627c1f886a952ea1963 | https://github.com/coderholic/pyradio/blob/c5219d350bccbccd49dbd627c1f886a952ea1963/pyradio/config.py#L321-L338 | train |
coderholic/pyradio | pyradio/config.py | PyRadioStations.append_station | def append_station(self, params, stationFile=''):
""" Append a station to csv file
return 0: All ok
-2 - playlist not found
-3 - negative number specified
-4 - number not found
-5: Error writing file
-6: Error... | python | def append_station(self, params, stationFile=''):
""" Append a station to csv file
return 0: All ok
-2 - playlist not found
-3 - negative number specified
-4 - number not found
-5: Error writing file
-6: Error... | [
"def",
"append_station",
"(",
"self",
",",
"params",
",",
"stationFile",
"=",
"''",
")",
":",
"if",
"self",
".",
"new_format",
":",
"if",
"stationFile",
":",
"st_file",
"=",
"stationFile",
"else",
":",
"st_file",
"=",
"self",
".",
"stations_file",
"st_file... | Append a station to csv file
return 0: All ok
-2 - playlist not found
-3 - negative number specified
-4 - number not found
-5: Error writing file
-6: Error renaming file | [
"Append",
"a",
"station",
"to",
"csv",
"file"
] | c5219d350bccbccd49dbd627c1f886a952ea1963 | https://github.com/coderholic/pyradio/blob/c5219d350bccbccd49dbd627c1f886a952ea1963/pyradio/config.py#L340-L375 | train |
coderholic/pyradio | pyradio/config.py | PyRadioConfig._check_config_file | def _check_config_file(self, usr):
''' Make sure a config file exists in the config dir '''
package_config_file = path.join(path.dirname(__file__), 'config')
user_config_file = path.join(usr, 'config')
''' restore config from bck file '''
if path.exists(user_config_file + '.rest... | python | def _check_config_file(self, usr):
''' Make sure a config file exists in the config dir '''
package_config_file = path.join(path.dirname(__file__), 'config')
user_config_file = path.join(usr, 'config')
''' restore config from bck file '''
if path.exists(user_config_file + '.rest... | [
"def",
"_check_config_file",
"(",
"self",
",",
"usr",
")",
":",
"package_config_file",
"=",
"path",
".",
"join",
"(",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"'config'",
")",
"user_config_file",
"=",
"path",
".",
"join",
"(",
"usr",
",",
"'con... | Make sure a config file exists in the config dir | [
"Make",
"sure",
"a",
"config",
"file",
"exists",
"in",
"the",
"config",
"dir"
] | c5219d350bccbccd49dbd627c1f886a952ea1963 | https://github.com/coderholic/pyradio/blob/c5219d350bccbccd49dbd627c1f886a952ea1963/pyradio/config.py#L566-L581 | train |
coderholic/pyradio | pyradio/config.py | PyRadioConfig.save_config | def save_config(self):
""" Save config file
Creates config.restore (back up file)
Returns:
-1: Error saving config
0: Config saved successfully
1: Config not saved (not modified"""
if not self.opts['dirty_config'][1]:
... | python | def save_config(self):
""" Save config file
Creates config.restore (back up file)
Returns:
-1: Error saving config
0: Config saved successfully
1: Config not saved (not modified"""
if not self.opts['dirty_config'][1]:
... | [
"def",
"save_config",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"opts",
"[",
"'dirty_config'",
"]",
"[",
"1",
"]",
":",
"if",
"logger",
".",
"isEnabledFor",
"(",
"logging",
".",
"INFO",
")",
":",
"logger",
".",
"info",
"(",
"'Config not saved (n... | Save config file
Creates config.restore (back up file)
Returns:
-1: Error saving config
0: Config saved successfully
1: Config not saved (not modified | [
"Save",
"config",
"file"
] | c5219d350bccbccd49dbd627c1f886a952ea1963 | https://github.com/coderholic/pyradio/blob/c5219d350bccbccd49dbd627c1f886a952ea1963/pyradio/config.py#L639-L773 | train |
coderholic/pyradio | pyradio/radio.py | PyRadio.ctrl_c_handler | def ctrl_c_handler(self, signum, frame):
self.ctrl_c_pressed = True
if self._cnf.dirty_playlist:
""" Try to auto save playlist on exit
Do not check result!!! """
self.saveCurrentPlaylist()
""" Try to auto save config on exit
Do not check result... | python | def ctrl_c_handler(self, signum, frame):
self.ctrl_c_pressed = True
if self._cnf.dirty_playlist:
""" Try to auto save playlist on exit
Do not check result!!! """
self.saveCurrentPlaylist()
""" Try to auto save config on exit
Do not check result... | [
"def",
"ctrl_c_handler",
"(",
"self",
",",
"signum",
",",
"frame",
")",
":",
"self",
".",
"ctrl_c_pressed",
"=",
"True",
"if",
"self",
".",
"_cnf",
".",
"dirty_playlist",
":",
"\"\"\" Try to auto save playlist on exit\n Do not check result!!! \"\"\"",
"se... | Try to auto save config on exit
Do not check result!!! | [
"Try",
"to",
"auto",
"save",
"config",
"on",
"exit",
"Do",
"not",
"check",
"result!!!"
] | c5219d350bccbccd49dbd627c1f886a952ea1963 | https://github.com/coderholic/pyradio/blob/c5219d350bccbccd49dbd627c1f886a952ea1963/pyradio/radio.py#L432-L440 | train |
coderholic/pyradio | pyradio/radio.py | PyRadio._goto_playing_station | def _goto_playing_station(self, changing_playlist=False):
""" make sure playing station is visible """
if (self.player.isPlaying() or self.operation_mode == PLAYLIST_MODE) and \
(self.selection != self.playing or changing_playlist):
if changing_playlist:
self.star... | python | def _goto_playing_station(self, changing_playlist=False):
""" make sure playing station is visible """
if (self.player.isPlaying() or self.operation_mode == PLAYLIST_MODE) and \
(self.selection != self.playing or changing_playlist):
if changing_playlist:
self.star... | [
"def",
"_goto_playing_station",
"(",
"self",
",",
"changing_playlist",
"=",
"False",
")",
":",
"if",
"(",
"self",
".",
"player",
".",
"isPlaying",
"(",
")",
"or",
"self",
".",
"operation_mode",
"==",
"PLAYLIST_MODE",
")",
"and",
"(",
"self",
".",
"selectio... | make sure playing station is visible | [
"make",
"sure",
"playing",
"station",
"is",
"visible"
] | c5219d350bccbccd49dbd627c1f886a952ea1963 | https://github.com/coderholic/pyradio/blob/c5219d350bccbccd49dbd627c1f886a952ea1963/pyradio/radio.py#L442-L468 | train |
coderholic/pyradio | pyradio/radio.py | PyRadio.setStation | def setStation(self, number):
""" Select the given station number """
# If we press up at the first station, we go to the last one
# and if we press down on the last one we go back to the first one.
if number < 0:
number = len(self.stations) - 1
elif number >= len(sel... | python | def setStation(self, number):
""" Select the given station number """
# If we press up at the first station, we go to the last one
# and if we press down on the last one we go back to the first one.
if number < 0:
number = len(self.stations) - 1
elif number >= len(sel... | [
"def",
"setStation",
"(",
"self",
",",
"number",
")",
":",
"# If we press up at the first station, we go to the last one",
"# and if we press down on the last one we go back to the first one.",
"if",
"number",
"<",
"0",
":",
"number",
"=",
"len",
"(",
"self",
".",
"stations... | Select the given station number | [
"Select",
"the",
"given",
"station",
"number"
] | c5219d350bccbccd49dbd627c1f886a952ea1963 | https://github.com/coderholic/pyradio/blob/c5219d350bccbccd49dbd627c1f886a952ea1963/pyradio/radio.py#L489-L504 | train |
coderholic/pyradio | pyradio/radio.py | PyRadio._format_playlist_line | def _format_playlist_line(self, lineNum, pad, station):
""" format playlist line so that if fills self.maxX """
line = "{0}. {1}".format(str(lineNum + self.startPos + 1).rjust(pad), station[0])
f_data = ' [{0}, {1}]'.format(station[2], station[1])
if version_info < (3, 0):
if... | python | def _format_playlist_line(self, lineNum, pad, station):
""" format playlist line so that if fills self.maxX """
line = "{0}. {1}".format(str(lineNum + self.startPos + 1).rjust(pad), station[0])
f_data = ' [{0}, {1}]'.format(station[2], station[1])
if version_info < (3, 0):
if... | [
"def",
"_format_playlist_line",
"(",
"self",
",",
"lineNum",
",",
"pad",
",",
"station",
")",
":",
"line",
"=",
"\"{0}. {1}\"",
".",
"format",
"(",
"str",
"(",
"lineNum",
"+",
"self",
".",
"startPos",
"+",
"1",
")",
".",
"rjust",
"(",
"pad",
")",
","... | format playlist line so that if fills self.maxX | [
"format",
"playlist",
"line",
"so",
"that",
"if",
"fills",
"self",
".",
"maxX"
] | c5219d350bccbccd49dbd627c1f886a952ea1963 | https://github.com/coderholic/pyradio/blob/c5219d350bccbccd49dbd627c1f886a952ea1963/pyradio/radio.py#L772-L805 | train |
coderholic/pyradio | pyradio/config_window.py | PyRadioSelectEncodings._resize | def _resize(self, init=False):
col, row = self._selection_to_col_row(self.selection)
if not (self.startPos <= row <= self.startPos + self.list_maxY - 1):
while row > self.startPos:
self.startPos += 1
while row < self.startPos + self.list_maxY - 1:
... | python | def _resize(self, init=False):
col, row = self._selection_to_col_row(self.selection)
if not (self.startPos <= row <= self.startPos + self.list_maxY - 1):
while row > self.startPos:
self.startPos += 1
while row < self.startPos + self.list_maxY - 1:
... | [
"def",
"_resize",
"(",
"self",
",",
"init",
"=",
"False",
")",
":",
"col",
",",
"row",
"=",
"self",
".",
"_selection_to_col_row",
"(",
"self",
".",
"selection",
")",
"if",
"not",
"(",
"self",
".",
"startPos",
"<=",
"row",
"<=",
"self",
".",
"startPos... | if the selection at the end of the list,
try to scroll down | [
"if",
"the",
"selection",
"at",
"the",
"end",
"of",
"the",
"list",
"try",
"to",
"scroll",
"down"
] | c5219d350bccbccd49dbd627c1f886a952ea1963 | https://github.com/coderholic/pyradio/blob/c5219d350bccbccd49dbd627c1f886a952ea1963/pyradio/config_window.py#L745-L760 | train |
coderholic/pyradio | pyradio/simple_curses_widgets.py | SimpleCursesLineEdit._get_char | def _get_char(self, win, char):
def get_check_next_byte():
char = win.getch()
if 128 <= char <= 191:
return char
else:
raise UnicodeError
bytes = []
if char <= 127:
# 1 bytes
bytes.append(char)
#... | python | def _get_char(self, win, char):
def get_check_next_byte():
char = win.getch()
if 128 <= char <= 191:
return char
else:
raise UnicodeError
bytes = []
if char <= 127:
# 1 bytes
bytes.append(char)
#... | [
"def",
"_get_char",
"(",
"self",
",",
"win",
",",
"char",
")",
":",
"def",
"get_check_next_byte",
"(",
")",
":",
"char",
"=",
"win",
".",
"getch",
"(",
")",
"if",
"128",
"<=",
"char",
"<=",
"191",
":",
"return",
"char",
"else",
":",
"raise",
"Unico... | no zero byte allowed | [
"no",
"zero",
"byte",
"allowed"
] | c5219d350bccbccd49dbd627c1f886a952ea1963 | https://github.com/coderholic/pyradio/blob/c5219d350bccbccd49dbd627c1f886a952ea1963/pyradio/simple_curses_widgets.py#L342-L380 | train |
coderholic/pyradio | pyradio/edit.py | PyRadioSearch._get_history_next | def _get_history_next(self):
""" callback function for key down """
if self._has_history:
ret = self._input_history.return_history(1)
self.string = ret
self._curs_pos = len(ret) | python | def _get_history_next(self):
""" callback function for key down """
if self._has_history:
ret = self._input_history.return_history(1)
self.string = ret
self._curs_pos = len(ret) | [
"def",
"_get_history_next",
"(",
"self",
")",
":",
"if",
"self",
".",
"_has_history",
":",
"ret",
"=",
"self",
".",
"_input_history",
".",
"return_history",
"(",
"1",
")",
"self",
".",
"string",
"=",
"ret",
"self",
".",
"_curs_pos",
"=",
"len",
"(",
"r... | callback function for key down | [
"callback",
"function",
"for",
"key",
"down"
] | c5219d350bccbccd49dbd627c1f886a952ea1963 | https://github.com/coderholic/pyradio/blob/c5219d350bccbccd49dbd627c1f886a952ea1963/pyradio/edit.py#L49-L54 | train |
bids-standard/pybids | bids/analysis/analysis.py | apply_transformations | def apply_transformations(collection, transformations, select=None):
''' Apply all transformations to the variables in the collection.
Args:
transformations (list): List of transformations to apply.
select (list): Optional list of names of variables to retain after all
transformatio... | python | def apply_transformations(collection, transformations, select=None):
''' Apply all transformations to the variables in the collection.
Args:
transformations (list): List of transformations to apply.
select (list): Optional list of names of variables to retain after all
transformatio... | [
"def",
"apply_transformations",
"(",
"collection",
",",
"transformations",
",",
"select",
"=",
"None",
")",
":",
"for",
"t",
"in",
"transformations",
":",
"kwargs",
"=",
"dict",
"(",
"t",
")",
"func",
"=",
"kwargs",
".",
"pop",
"(",
"'name'",
")",
"cols"... | Apply all transformations to the variables in the collection.
Args:
transformations (list): List of transformations to apply.
select (list): Optional list of names of variables to retain after all
transformations are applied. | [
"Apply",
"all",
"transformations",
"to",
"the",
"variables",
"in",
"the",
"collection",
"."
] | 30d924ce770622bda0e390d613a8da42a2a20c32 | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/analysis/analysis.py#L489-L513 | train |
bids-standard/pybids | bids/analysis/analysis.py | Analysis.setup | def setup(self, steps=None, drop_na=False, **kwargs):
''' Set up the sequence of steps for analysis.
Args:
steps (list): Optional list of steps to set up. Each element
must be either an int giving the index of the step in the
JSON config block list, or a str ... | python | def setup(self, steps=None, drop_na=False, **kwargs):
''' Set up the sequence of steps for analysis.
Args:
steps (list): Optional list of steps to set up. Each element
must be either an int giving the index of the step in the
JSON config block list, or a str ... | [
"def",
"setup",
"(",
"self",
",",
"steps",
"=",
"None",
",",
"drop_na",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"# In the beginning, there was nothing",
"input_nodes",
"=",
"None",
"# Use inputs from model, and update with kwargs",
"selectors",
"=",
"self",... | Set up the sequence of steps for analysis.
Args:
steps (list): Optional list of steps to set up. Each element
must be either an int giving the index of the step in the
JSON config block list, or a str giving the (unique) name of
the step, as specified... | [
"Set",
"up",
"the",
"sequence",
"of",
"steps",
"for",
"analysis",
"."
] | 30d924ce770622bda0e390d613a8da42a2a20c32 | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/analysis/analysis.py#L62-L90 | train |
bids-standard/pybids | bids/analysis/analysis.py | Step.setup | def setup(self, input_nodes=None, drop_na=False, **kwargs):
''' Set up the Step and construct the design matrix.
Args:
input_nodes (list): Optional list of Node objects produced by
the preceding Step in the analysis. If None, uses any inputs
passed in at Step... | python | def setup(self, input_nodes=None, drop_na=False, **kwargs):
''' Set up the Step and construct the design matrix.
Args:
input_nodes (list): Optional list of Node objects produced by
the preceding Step in the analysis. If None, uses any inputs
passed in at Step... | [
"def",
"setup",
"(",
"self",
",",
"input_nodes",
"=",
"None",
",",
"drop_na",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"output_nodes",
"=",
"[",
"]",
"input_nodes",
"=",
"input_nodes",
"or",
"self",
".",
"input_nodes",
"or",
"[",
... | Set up the Step and construct the design matrix.
Args:
input_nodes (list): Optional list of Node objects produced by
the preceding Step in the analysis. If None, uses any inputs
passed in at Step initialization.
drop_na (bool): Boolean indicating whether ... | [
"Set",
"up",
"the",
"Step",
"and",
"construct",
"the",
"design",
"matrix",
"."
] | 30d924ce770622bda0e390d613a8da42a2a20c32 | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/analysis/analysis.py#L168-L218 | train |
bids-standard/pybids | bids/reports/utils.py | get_slice_info | def get_slice_info(slice_times):
"""
Extract slice order from slice timing info.
TODO: Be more specific with slice orders.
Currently anything where there's some kind of skipping is interpreted as
interleaved of some kind.
Parameters
----------
slice_times : array-like
A list of... | python | def get_slice_info(slice_times):
"""
Extract slice order from slice timing info.
TODO: Be more specific with slice orders.
Currently anything where there's some kind of skipping is interpreted as
interleaved of some kind.
Parameters
----------
slice_times : array-like
A list of... | [
"def",
"get_slice_info",
"(",
"slice_times",
")",
":",
"# Slice order",
"slice_times",
"=",
"remove_duplicates",
"(",
"slice_times",
")",
"slice_order",
"=",
"sorted",
"(",
"range",
"(",
"len",
"(",
"slice_times",
")",
")",
",",
"key",
"=",
"lambda",
"k",
":... | Extract slice order from slice timing info.
TODO: Be more specific with slice orders.
Currently anything where there's some kind of skipping is interpreted as
interleaved of some kind.
Parameters
----------
slice_times : array-like
A list of slice times in seconds or milliseconds or wh... | [
"Extract",
"slice",
"order",
"from",
"slice",
"timing",
"info",
"."
] | 30d924ce770622bda0e390d613a8da42a2a20c32 | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/reports/utils.py#L70-L104 | train |
bids-standard/pybids | bids/reports/utils.py | get_sizestr | def get_sizestr(img):
"""
Extract and reformat voxel size, matrix size, field of view, and number of
slices into pretty strings.
Parameters
----------
img : :obj:`nibabel.Nifti1Image`
Image from scan from which to derive parameters.
Returns
-------
n_slices : :obj:`int`
... | python | def get_sizestr(img):
"""
Extract and reformat voxel size, matrix size, field of view, and number of
slices into pretty strings.
Parameters
----------
img : :obj:`nibabel.Nifti1Image`
Image from scan from which to derive parameters.
Returns
-------
n_slices : :obj:`int`
... | [
"def",
"get_sizestr",
"(",
"img",
")",
":",
"n_x",
",",
"n_y",
",",
"n_slices",
"=",
"img",
".",
"shape",
"[",
":",
"3",
"]",
"import",
"numpy",
"as",
"np",
"voxel_dims",
"=",
"np",
".",
"array",
"(",
"img",
".",
"header",
".",
"get_zooms",
"(",
... | Extract and reformat voxel size, matrix size, field of view, and number of
slices into pretty strings.
Parameters
----------
img : :obj:`nibabel.Nifti1Image`
Image from scan from which to derive parameters.
Returns
-------
n_slices : :obj:`int`
Number of slices.
voxel_s... | [
"Extract",
"and",
"reformat",
"voxel",
"size",
"matrix",
"size",
"field",
"of",
"view",
"and",
"number",
"of",
"slices",
"into",
"pretty",
"strings",
"."
] | 30d924ce770622bda0e390d613a8da42a2a20c32 | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/reports/utils.py#L138-L166 | train |
bids-standard/pybids | bids/layout/layout.py | add_config_paths | def add_config_paths(**kwargs):
""" Add to the pool of available configuration files for BIDSLayout.
Args:
kwargs: dictionary specifying where to find additional config files.
Keys are names, values are paths to the corresponding .json file.
Example:
> add_config_paths(my_confi... | python | def add_config_paths(**kwargs):
""" Add to the pool of available configuration files for BIDSLayout.
Args:
kwargs: dictionary specifying where to find additional config files.
Keys are names, values are paths to the corresponding .json file.
Example:
> add_config_paths(my_confi... | [
"def",
"add_config_paths",
"(",
"*",
"*",
"kwargs",
")",
":",
"for",
"k",
",",
"path",
"in",
"kwargs",
".",
"items",
"(",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"path",
")",
":",
"raise",
"ValueError",
"(",
"'Configuration file... | Add to the pool of available configuration files for BIDSLayout.
Args:
kwargs: dictionary specifying where to find additional config files.
Keys are names, values are paths to the corresponding .json file.
Example:
> add_config_paths(my_config='/path/to/config')
> layout = ... | [
"Add",
"to",
"the",
"pool",
"of",
"available",
"configuration",
"files",
"for",
"BIDSLayout",
"."
] | 30d924ce770622bda0e390d613a8da42a2a20c32 | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/layout/layout.py#L77-L97 | train |
bids-standard/pybids | bids/layout/layout.py | BIDSLayout.add_derivatives | def add_derivatives(self, path, **kwargs):
''' Add BIDS-Derivatives datasets to tracking.
Args:
path (str, list): One or more paths to BIDS-Derivatives datasets.
Each path can point to either a derivatives/ directory
containing one more more pipeline director... | python | def add_derivatives(self, path, **kwargs):
''' Add BIDS-Derivatives datasets to tracking.
Args:
path (str, list): One or more paths to BIDS-Derivatives datasets.
Each path can point to either a derivatives/ directory
containing one more more pipeline director... | [
"def",
"add_derivatives",
"(",
"self",
",",
"path",
",",
"*",
"*",
"kwargs",
")",
":",
"paths",
"=",
"listify",
"(",
"path",
")",
"deriv_dirs",
"=",
"[",
"]",
"# Collect all paths that contain a dataset_description.json",
"def",
"check_for_description",
"(",
"dir"... | Add BIDS-Derivatives datasets to tracking.
Args:
path (str, list): One or more paths to BIDS-Derivatives datasets.
Each path can point to either a derivatives/ directory
containing one more more pipeline directories, or to a single
pipeline directory ... | [
"Add",
"BIDS",
"-",
"Derivatives",
"datasets",
"to",
"tracking",
"."
] | 30d924ce770622bda0e390d613a8da42a2a20c32 | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/layout/layout.py#L352-L418 | train |
bids-standard/pybids | bids/layout/layout.py | BIDSLayout.get_file | def get_file(self, filename, scope='all'):
''' Returns the BIDSFile object with the specified path.
Args:
filename (str): The path of the file to retrieve. Must be either
an absolute path, or relative to the root of this BIDSLayout.
scope (str, list): Scope of th... | python | def get_file(self, filename, scope='all'):
''' Returns the BIDSFile object with the specified path.
Args:
filename (str): The path of the file to retrieve. Must be either
an absolute path, or relative to the root of this BIDSLayout.
scope (str, list): Scope of th... | [
"def",
"get_file",
"(",
"self",
",",
"filename",
",",
"scope",
"=",
"'all'",
")",
":",
"filename",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"root",
",",
"filename",
")",
")",
"layouts",
"=",
"... | Returns the BIDSFile object with the specified path.
Args:
filename (str): The path of the file to retrieve. Must be either
an absolute path, or relative to the root of this BIDSLayout.
scope (str, list): Scope of the search space. If passed, only
BIDSLay... | [
"Returns",
"the",
"BIDSFile",
"object",
"with",
"the",
"specified",
"path",
"."
] | 30d924ce770622bda0e390d613a8da42a2a20c32 | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/layout/layout.py#L600-L617 | train |
bids-standard/pybids | bids/layout/layout.py | BIDSLayout.get_collections | def get_collections(self, level, types=None, variables=None, merge=False,
sampling_rate=None, skip_empty=False, **kwargs):
"""Return one or more variable Collections in the BIDS project.
Args:
level (str): The level of analysis to return variables for. Must be
... | python | def get_collections(self, level, types=None, variables=None, merge=False,
sampling_rate=None, skip_empty=False, **kwargs):
"""Return one or more variable Collections in the BIDS project.
Args:
level (str): The level of analysis to return variables for. Must be
... | [
"def",
"get_collections",
"(",
"self",
",",
"level",
",",
"types",
"=",
"None",
",",
"variables",
"=",
"None",
",",
"merge",
"=",
"False",
",",
"sampling_rate",
"=",
"None",
",",
"skip_empty",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
... | Return one or more variable Collections in the BIDS project.
Args:
level (str): The level of analysis to return variables for. Must be
one of 'run', 'session', 'subject', or 'dataset'.
types (str, list): Types of variables to retrieve. All valid values
reflec... | [
"Return",
"one",
"or",
"more",
"variable",
"Collections",
"in",
"the",
"BIDS",
"project",
"."
] | 30d924ce770622bda0e390d613a8da42a2a20c32 | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/layout/layout.py#L619-L648 | train |
bids-standard/pybids | bids/layout/layout.py | BIDSLayout.get_metadata | def get_metadata(self, path, include_entities=False, **kwargs):
"""Return metadata found in JSON sidecars for the specified file.
Args:
path (str): Path to the file to get metadata for.
include_entities (bool): If True, all available entities extracted
from the f... | python | def get_metadata(self, path, include_entities=False, **kwargs):
"""Return metadata found in JSON sidecars for the specified file.
Args:
path (str): Path to the file to get metadata for.
include_entities (bool): If True, all available entities extracted
from the f... | [
"def",
"get_metadata",
"(",
"self",
",",
"path",
",",
"include_entities",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"f",
"=",
"self",
".",
"get_file",
"(",
"path",
")",
"# For querying efficiency, store metadata in the MetadataIndex cache",
"self",
".",
"... | Return metadata found in JSON sidecars for the specified file.
Args:
path (str): Path to the file to get metadata for.
include_entities (bool): If True, all available entities extracted
from the filename (rather than JSON sidecars) are included in
the ret... | [
"Return",
"metadata",
"found",
"in",
"JSON",
"sidecars",
"for",
"the",
"specified",
"file",
"."
] | 30d924ce770622bda0e390d613a8da42a2a20c32 | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/layout/layout.py#L650-L684 | train |
bids-standard/pybids | bids/layout/layout.py | BIDSLayout.get_bval | def get_bval(self, path, **kwargs):
""" Get bval file for passed path. """
result = self.get_nearest(path, extensions='bval', suffix='dwi',
all_=True, **kwargs)
return listify(result)[0] | python | def get_bval(self, path, **kwargs):
""" Get bval file for passed path. """
result = self.get_nearest(path, extensions='bval', suffix='dwi',
all_=True, **kwargs)
return listify(result)[0] | [
"def",
"get_bval",
"(",
"self",
",",
"path",
",",
"*",
"*",
"kwargs",
")",
":",
"result",
"=",
"self",
".",
"get_nearest",
"(",
"path",
",",
"extensions",
"=",
"'bval'",
",",
"suffix",
"=",
"'dwi'",
",",
"all_",
"=",
"True",
",",
"*",
"*",
"kwargs"... | Get bval file for passed path. | [
"Get",
"bval",
"file",
"for",
"passed",
"path",
"."
] | 30d924ce770622bda0e390d613a8da42a2a20c32 | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/layout/layout.py#L794-L798 | train |
bids-standard/pybids | bids/layout/layout.py | BIDSLayout.copy_files | def copy_files(self, files=None, path_patterns=None, symbolic_links=True,
root=None, conflicts='fail', **kwargs):
"""
Copies one or more BIDSFiles to new locations defined by each
BIDSFile's entities and the specified path_patterns.
Args:
files (list): Opt... | python | def copy_files(self, files=None, path_patterns=None, symbolic_links=True,
root=None, conflicts='fail', **kwargs):
"""
Copies one or more BIDSFiles to new locations defined by each
BIDSFile's entities and the specified path_patterns.
Args:
files (list): Opt... | [
"def",
"copy_files",
"(",
"self",
",",
"files",
"=",
"None",
",",
"path_patterns",
"=",
"None",
",",
"symbolic_links",
"=",
"True",
",",
"root",
"=",
"None",
",",
"conflicts",
"=",
"'fail'",
",",
"*",
"*",
"kwargs",
")",
":",
"_files",
"=",
"self",
"... | Copies one or more BIDSFiles to new locations defined by each
BIDSFile's entities and the specified path_patterns.
Args:
files (list): Optional list of BIDSFile objects to write out. If
none provided, use files from running a get() query using
remaining **kwa... | [
"Copies",
"one",
"or",
"more",
"BIDSFiles",
"to",
"new",
"locations",
"defined",
"by",
"each",
"BIDSFile",
"s",
"entities",
"and",
"the",
"specified",
"path_patterns",
"."
] | 30d924ce770622bda0e390d613a8da42a2a20c32 | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/layout/layout.py#L950-L981 | train |
bids-standard/pybids | bids/layout/layout.py | MetadataIndex.index_file | def index_file(self, f, overwrite=False):
"""Index metadata for the specified file.
Args:
f (BIDSFile, str): A BIDSFile or path to an indexed file.
overwrite (bool): If True, forces reindexing of the file even if
an entry already exists.
"""
if is... | python | def index_file(self, f, overwrite=False):
"""Index metadata for the specified file.
Args:
f (BIDSFile, str): A BIDSFile or path to an indexed file.
overwrite (bool): If True, forces reindexing of the file even if
an entry already exists.
"""
if is... | [
"def",
"index_file",
"(",
"self",
",",
"f",
",",
"overwrite",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"f",
",",
"six",
".",
"string_types",
")",
":",
"f",
"=",
"self",
".",
"layout",
".",
"get_file",
"(",
"f",
")",
"if",
"f",
".",
"path"... | Index metadata for the specified file.
Args:
f (BIDSFile, str): A BIDSFile or path to an indexed file.
overwrite (bool): If True, forces reindexing of the file even if
an entry already exists. | [
"Index",
"metadata",
"for",
"the",
"specified",
"file",
"."
] | 30d924ce770622bda0e390d613a8da42a2a20c32 | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/layout/layout.py#L1036-L1059 | train |
bids-standard/pybids | bids/layout/layout.py | MetadataIndex.search | def search(self, files=None, defined_fields=None, **kwargs):
"""Search files in the layout by metadata fields.
Args:
files (list): Optional list of names of files to search. If None,
all files in the layout are scanned.
defined_fields (list): Optional list of nam... | python | def search(self, files=None, defined_fields=None, **kwargs):
"""Search files in the layout by metadata fields.
Args:
files (list): Optional list of names of files to search. If None,
all files in the layout are scanned.
defined_fields (list): Optional list of nam... | [
"def",
"search",
"(",
"self",
",",
"files",
"=",
"None",
",",
"defined_fields",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"defined_fields",
"is",
"None",
":",
"defined_fields",
"=",
"[",
"]",
"all_keys",
"=",
"set",
"(",
"defined_fields",
"... | Search files in the layout by metadata fields.
Args:
files (list): Optional list of names of files to search. If None,
all files in the layout are scanned.
defined_fields (list): Optional list of names of fields that must
be defined in the JSON sidecar in... | [
"Search",
"files",
"in",
"the",
"layout",
"by",
"metadata",
"fields",
"."
] | 30d924ce770622bda0e390d613a8da42a2a20c32 | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/layout/layout.py#L1080-L1136 | train |
bids-standard/pybids | bids/analysis/auto_model.py | auto_model | def auto_model(layout, scan_length=None, one_vs_rest=False):
'''Create a simple default model for each of the tasks in a BIDSLayout.
Contrasts each trial type against all other trial types and trial types
at the run level and then uses t-tests at each other level present to
aggregate these results up.
... | python | def auto_model(layout, scan_length=None, one_vs_rest=False):
'''Create a simple default model for each of the tasks in a BIDSLayout.
Contrasts each trial type against all other trial types and trial types
at the run level and then uses t-tests at each other level present to
aggregate these results up.
... | [
"def",
"auto_model",
"(",
"layout",
",",
"scan_length",
"=",
"None",
",",
"one_vs_rest",
"=",
"False",
")",
":",
"base_name",
"=",
"split",
"(",
"layout",
".",
"root",
")",
"[",
"-",
"1",
"]",
"tasks",
"=",
"layout",
".",
"entities",
"[",
"'task'",
"... | Create a simple default model for each of the tasks in a BIDSLayout.
Contrasts each trial type against all other trial types and trial types
at the run level and then uses t-tests at each other level present to
aggregate these results up.
Args:
layout (BIDSLayout) A BIDSLayout instance
... | [
"Create",
"a",
"simple",
"default",
"model",
"for",
"each",
"of",
"the",
"tasks",
"in",
"a",
"BIDSLayout",
".",
"Contrasts",
"each",
"trial",
"type",
"against",
"all",
"other",
"trial",
"types",
"and",
"trial",
"types",
"at",
"the",
"run",
"level",
"and",
... | 30d924ce770622bda0e390d613a8da42a2a20c32 | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/analysis/auto_model.py#L19-L122 | train |
bids-standard/pybids | bids/variables/variables.py | SimpleVariable.split | def split(self, grouper):
''' Split the current SparseRunVariable into multiple columns.
Args:
grouper (iterable): list to groupby, where each unique value will
be taken as the name of the resulting column.
Returns:
A list of SparseRunVariables, one per ... | python | def split(self, grouper):
''' Split the current SparseRunVariable into multiple columns.
Args:
grouper (iterable): list to groupby, where each unique value will
be taken as the name of the resulting column.
Returns:
A list of SparseRunVariables, one per ... | [
"def",
"split",
"(",
"self",
",",
"grouper",
")",
":",
"data",
"=",
"self",
".",
"to_df",
"(",
"condition",
"=",
"True",
",",
"entities",
"=",
"True",
")",
"data",
"=",
"data",
".",
"drop",
"(",
"'condition'",
",",
"axis",
"=",
"1",
")",
"subsets",... | Split the current SparseRunVariable into multiple columns.
Args:
grouper (iterable): list to groupby, where each unique value will
be taken as the name of the resulting column.
Returns:
A list of SparseRunVariables, one per unique value in the
groupe... | [
"Split",
"the",
"current",
"SparseRunVariable",
"into",
"multiple",
"columns",
"."
] | 30d924ce770622bda0e390d613a8da42a2a20c32 | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/variables/variables.py#L240-L260 | train |
bids-standard/pybids | bids/variables/variables.py | SimpleVariable.select_rows | def select_rows(self, rows):
''' Truncate internal arrays to keep only the specified rows.
Args:
rows (array): An integer or boolean array identifying the indices
of rows to keep.
'''
self.values = self.values.iloc[rows]
self.index = self.index.iloc[r... | python | def select_rows(self, rows):
''' Truncate internal arrays to keep only the specified rows.
Args:
rows (array): An integer or boolean array identifying the indices
of rows to keep.
'''
self.values = self.values.iloc[rows]
self.index = self.index.iloc[r... | [
"def",
"select_rows",
"(",
"self",
",",
"rows",
")",
":",
"self",
".",
"values",
"=",
"self",
".",
"values",
".",
"iloc",
"[",
"rows",
"]",
"self",
".",
"index",
"=",
"self",
".",
"index",
".",
"iloc",
"[",
"rows",
",",
":",
"]",
"for",
"prop",
... | Truncate internal arrays to keep only the specified rows.
Args:
rows (array): An integer or boolean array identifying the indices
of rows to keep. | [
"Truncate",
"internal",
"arrays",
"to",
"keep",
"only",
"the",
"specified",
"rows",
"."
] | 30d924ce770622bda0e390d613a8da42a2a20c32 | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/variables/variables.py#L269-L280 | train |
bids-standard/pybids | bids/variables/variables.py | DenseRunVariable.split | def split(self, grouper):
'''Split the current DenseRunVariable into multiple columns.
Parameters
----------
grouper : :obj:`pandas.DataFrame`
Binary DF specifying the design matrix to use for splitting. Number
of rows must match current ``DenseRunVariable``; a n... | python | def split(self, grouper):
'''Split the current DenseRunVariable into multiple columns.
Parameters
----------
grouper : :obj:`pandas.DataFrame`
Binary DF specifying the design matrix to use for splitting. Number
of rows must match current ``DenseRunVariable``; a n... | [
"def",
"split",
"(",
"self",
",",
"grouper",
")",
":",
"values",
"=",
"grouper",
".",
"values",
"*",
"self",
".",
"values",
".",
"values",
"df",
"=",
"pd",
".",
"DataFrame",
"(",
"values",
",",
"columns",
"=",
"grouper",
".",
"columns",
")",
"return"... | Split the current DenseRunVariable into multiple columns.
Parameters
----------
grouper : :obj:`pandas.DataFrame`
Binary DF specifying the design matrix to use for splitting. Number
of rows must match current ``DenseRunVariable``; a new ``DenseRunVariable``
w... | [
"Split",
"the",
"current",
"DenseRunVariable",
"into",
"multiple",
"columns",
"."
] | 30d924ce770622bda0e390d613a8da42a2a20c32 | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/variables/variables.py#L393-L414 | train |
bids-standard/pybids | bids/variables/variables.py | DenseRunVariable._build_entity_index | def _build_entity_index(self, run_info, sampling_rate):
''' Build the entity index from run information. '''
index = []
interval = int(round(1000. / sampling_rate))
_timestamps = []
for run in run_info:
reps = int(math.ceil(run.duration * sampling_rate))
... | python | def _build_entity_index(self, run_info, sampling_rate):
''' Build the entity index from run information. '''
index = []
interval = int(round(1000. / sampling_rate))
_timestamps = []
for run in run_info:
reps = int(math.ceil(run.duration * sampling_rate))
... | [
"def",
"_build_entity_index",
"(",
"self",
",",
"run_info",
",",
"sampling_rate",
")",
":",
"index",
"=",
"[",
"]",
"interval",
"=",
"int",
"(",
"round",
"(",
"1000.",
"/",
"sampling_rate",
")",
")",
"_timestamps",
"=",
"[",
"]",
"for",
"run",
"in",
"r... | Build the entity index from run information. | [
"Build",
"the",
"entity",
"index",
"from",
"run",
"information",
"."
] | 30d924ce770622bda0e390d613a8da42a2a20c32 | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/variables/variables.py#L416-L430 | train |
bids-standard/pybids | bids/variables/variables.py | DenseRunVariable.resample | def resample(self, sampling_rate, inplace=False, kind='linear'):
'''Resample the Variable to the specified sampling rate.
Parameters
----------
sampling_rate : :obj:`int`, :obj:`float`
Target sampling rate (in Hz).
inplace : :obj:`bool`, optional
If True,... | python | def resample(self, sampling_rate, inplace=False, kind='linear'):
'''Resample the Variable to the specified sampling rate.
Parameters
----------
sampling_rate : :obj:`int`, :obj:`float`
Target sampling rate (in Hz).
inplace : :obj:`bool`, optional
If True,... | [
"def",
"resample",
"(",
"self",
",",
"sampling_rate",
",",
"inplace",
"=",
"False",
",",
"kind",
"=",
"'linear'",
")",
":",
"if",
"not",
"inplace",
":",
"var",
"=",
"self",
".",
"clone",
"(",
")",
"var",
".",
"resample",
"(",
"sampling_rate",
",",
"T... | Resample the Variable to the specified sampling rate.
Parameters
----------
sampling_rate : :obj:`int`, :obj:`float`
Target sampling rate (in Hz).
inplace : :obj:`bool`, optional
If True, performs resampling in-place. If False, returns a resampled
cop... | [
"Resample",
"the",
"Variable",
"to",
"the",
"specified",
"sampling",
"rate",
"."
] | 30d924ce770622bda0e390d613a8da42a2a20c32 | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/variables/variables.py#L432-L469 | train |
bids-standard/pybids | bids/variables/variables.py | DenseRunVariable.to_df | def to_df(self, condition=True, entities=True, timing=True, sampling_rate=None):
'''Convert to a DataFrame, with columns for name and entities.
Parameters
----------
condition : :obj:`bool`
If True, adds a column for condition name, and names the amplitude
column... | python | def to_df(self, condition=True, entities=True, timing=True, sampling_rate=None):
'''Convert to a DataFrame, with columns for name and entities.
Parameters
----------
condition : :obj:`bool`
If True, adds a column for condition name, and names the amplitude
column... | [
"def",
"to_df",
"(",
"self",
",",
"condition",
"=",
"True",
",",
"entities",
"=",
"True",
",",
"timing",
"=",
"True",
",",
"sampling_rate",
"=",
"None",
")",
":",
"if",
"sampling_rate",
"not",
"in",
"(",
"None",
",",
"self",
".",
"sampling_rate",
")",
... | Convert to a DataFrame, with columns for name and entities.
Parameters
----------
condition : :obj:`bool`
If True, adds a column for condition name, and names the amplitude
column 'amplitude'. If False, returns just onset, duration, and
amplitude, and gives t... | [
"Convert",
"to",
"a",
"DataFrame",
"with",
"columns",
"for",
"name",
"and",
"entities",
"."
] | 30d924ce770622bda0e390d613a8da42a2a20c32 | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/variables/variables.py#L471-L495 | train |
bids-standard/pybids | bids/variables/entities.py | NodeIndex.get_collections | def get_collections(self, unit, names=None, merge=False,
sampling_rate=None, **entities):
''' Retrieve variable data for a specified level in the Dataset.
Args:
unit (str): The unit of analysis to return variables for. Must be
one of 'run', 'session',... | python | def get_collections(self, unit, names=None, merge=False,
sampling_rate=None, **entities):
''' Retrieve variable data for a specified level in the Dataset.
Args:
unit (str): The unit of analysis to return variables for. Must be
one of 'run', 'session',... | [
"def",
"get_collections",
"(",
"self",
",",
"unit",
",",
"names",
"=",
"None",
",",
"merge",
"=",
"False",
",",
"sampling_rate",
"=",
"None",
",",
"*",
"*",
"entities",
")",
":",
"nodes",
"=",
"self",
".",
"get_nodes",
"(",
"unit",
",",
"entities",
"... | Retrieve variable data for a specified level in the Dataset.
Args:
unit (str): The unit of analysis to return variables for. Must be
one of 'run', 'session', 'subject', or 'dataset'.
names (list): Optional list of variables names to return. If
None, all a... | [
"Retrieve",
"variable",
"data",
"for",
"a",
"specified",
"level",
"in",
"the",
"Dataset",
"."
] | 30d924ce770622bda0e390d613a8da42a2a20c32 | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/variables/entities.py#L65-L118 | train |
bids-standard/pybids | bids/variables/entities.py | NodeIndex.get_or_create_node | def get_or_create_node(self, level, entities, *args, **kwargs):
''' Retrieves a child Node based on the specified criteria, creating a
new Node if necessary.
Args:
entities (dict): Dictionary of entities specifying which Node to
return.
args, kwargs: Opti... | python | def get_or_create_node(self, level, entities, *args, **kwargs):
''' Retrieves a child Node based on the specified criteria, creating a
new Node if necessary.
Args:
entities (dict): Dictionary of entities specifying which Node to
return.
args, kwargs: Opti... | [
"def",
"get_or_create_node",
"(",
"self",
",",
"level",
",",
"entities",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"result",
"=",
"self",
".",
"get_nodes",
"(",
"level",
",",
"entities",
")",
"if",
"result",
":",
"if",
"len",
"(",
"result"... | Retrieves a child Node based on the specified criteria, creating a
new Node if necessary.
Args:
entities (dict): Dictionary of entities specifying which Node to
return.
args, kwargs: Optional positional or named arguments to pass onto
class-specif... | [
"Retrieves",
"a",
"child",
"Node",
"based",
"on",
"the",
"specified",
"criteria",
"creating",
"a",
"new",
"Node",
"if",
"necessary",
"."
] | 30d924ce770622bda0e390d613a8da42a2a20c32 | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/variables/entities.py#L160-L198 | train |
bids-standard/pybids | bids/variables/kollekshuns.py | merge_collections | def merge_collections(collections, force_dense=False, sampling_rate='auto'):
''' Merge two or more collections at the same level of analysis.
Args:
collections (list): List of Collections to merge.
sampling_rate (int, str): Sampling rate to use if it becomes necessary
to resample De... | python | def merge_collections(collections, force_dense=False, sampling_rate='auto'):
''' Merge two or more collections at the same level of analysis.
Args:
collections (list): List of Collections to merge.
sampling_rate (int, str): Sampling rate to use if it becomes necessary
to resample De... | [
"def",
"merge_collections",
"(",
"collections",
",",
"force_dense",
"=",
"False",
",",
"sampling_rate",
"=",
"'auto'",
")",
":",
"if",
"len",
"(",
"listify",
"(",
"collections",
")",
")",
"==",
"1",
":",
"return",
"collections",
"levels",
"=",
"set",
"(",
... | Merge two or more collections at the same level of analysis.
Args:
collections (list): List of Collections to merge.
sampling_rate (int, str): Sampling rate to use if it becomes necessary
to resample DenseRunVariables. Either an integer or 'auto' (see
merge_variables docstri... | [
"Merge",
"two",
"or",
"more",
"collections",
"at",
"the",
"same",
"level",
"of",
"analysis",
"."
] | 30d924ce770622bda0e390d613a8da42a2a20c32 | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/variables/kollekshuns.py#L354-L390 | train |
bids-standard/pybids | bids/variables/kollekshuns.py | BIDSVariableCollection.merge_variables | def merge_variables(variables, **kwargs):
''' Concatenates Variables along row axis.
Args:
variables (list): List of Variables to merge. Variables can have
different names (and all Variables that share a name will be
concatenated together).
Returns:
... | python | def merge_variables(variables, **kwargs):
''' Concatenates Variables along row axis.
Args:
variables (list): List of Variables to merge. Variables can have
different names (and all Variables that share a name will be
concatenated together).
Returns:
... | [
"def",
"merge_variables",
"(",
"variables",
",",
"*",
"*",
"kwargs",
")",
":",
"var_dict",
"=",
"OrderedDict",
"(",
")",
"for",
"v",
"in",
"variables",
":",
"if",
"v",
".",
"name",
"not",
"in",
"var_dict",
":",
"var_dict",
"[",
"v",
".",
"name",
"]",... | Concatenates Variables along row axis.
Args:
variables (list): List of Variables to merge. Variables can have
different names (and all Variables that share a name will be
concatenated together).
Returns:
A list of Variables. | [
"Concatenates",
"Variables",
"along",
"row",
"axis",
"."
] | 30d924ce770622bda0e390d613a8da42a2a20c32 | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/variables/kollekshuns.py#L69-L86 | train |
bids-standard/pybids | bids/variables/kollekshuns.py | BIDSVariableCollection.to_df | def to_df(self, variables=None, format='wide', fillna=np.nan, **kwargs):
''' Merge variables into a single pandas DataFrame.
Args:
variables (list): Optional list of column names to retain; if None,
all variables are returned.
format (str): Whether to return a Da... | python | def to_df(self, variables=None, format='wide', fillna=np.nan, **kwargs):
''' Merge variables into a single pandas DataFrame.
Args:
variables (list): Optional list of column names to retain; if None,
all variables are returned.
format (str): Whether to return a Da... | [
"def",
"to_df",
"(",
"self",
",",
"variables",
"=",
"None",
",",
"format",
"=",
"'wide'",
",",
"fillna",
"=",
"np",
".",
"nan",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"variables",
"is",
"None",
":",
"variables",
"=",
"list",
"(",
"self",
".",
"... | Merge variables into a single pandas DataFrame.
Args:
variables (list): Optional list of column names to retain; if None,
all variables are returned.
format (str): Whether to return a DataFrame in 'wide' or 'long'
format. In 'wide' format, each row is def... | [
"Merge",
"variables",
"into",
"a",
"single",
"pandas",
"DataFrame",
"."
] | 30d924ce770622bda0e390d613a8da42a2a20c32 | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/variables/kollekshuns.py#L88-L128 | train |
bids-standard/pybids | bids/variables/kollekshuns.py | BIDSVariableCollection.from_df | def from_df(cls, data, entities=None, source='contrast'):
''' Create a Collection from a pandas DataFrame.
Args:
df (DataFrame): The DataFrame to convert to a Collection. Each
column will be converted to a SimpleVariable.
entities (DataFrame): An optional second ... | python | def from_df(cls, data, entities=None, source='contrast'):
''' Create a Collection from a pandas DataFrame.
Args:
df (DataFrame): The DataFrame to convert to a Collection. Each
column will be converted to a SimpleVariable.
entities (DataFrame): An optional second ... | [
"def",
"from_df",
"(",
"cls",
",",
"data",
",",
"entities",
"=",
"None",
",",
"source",
"=",
"'contrast'",
")",
":",
"variables",
"=",
"[",
"]",
"for",
"col",
"in",
"data",
".",
"columns",
":",
"_data",
"=",
"pd",
".",
"DataFrame",
"(",
"data",
"["... | Create a Collection from a pandas DataFrame.
Args:
df (DataFrame): The DataFrame to convert to a Collection. Each
column will be converted to a SimpleVariable.
entities (DataFrame): An optional second DataFrame containing
entity information.
s... | [
"Create",
"a",
"Collection",
"from",
"a",
"pandas",
"DataFrame",
"."
] | 30d924ce770622bda0e390d613a8da42a2a20c32 | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/variables/kollekshuns.py#L131-L150 | train |
bids-standard/pybids | bids/variables/kollekshuns.py | BIDSVariableCollection.clone | def clone(self):
''' Returns a shallow copy of the current instance, except that all
variables are deep-cloned.
'''
clone = copy(self)
clone.variables = {k: v.clone() for (k, v) in self.variables.items()}
return clone | python | def clone(self):
''' Returns a shallow copy of the current instance, except that all
variables are deep-cloned.
'''
clone = copy(self)
clone.variables = {k: v.clone() for (k, v) in self.variables.items()}
return clone | [
"def",
"clone",
"(",
"self",
")",
":",
"clone",
"=",
"copy",
"(",
"self",
")",
"clone",
".",
"variables",
"=",
"{",
"k",
":",
"v",
".",
"clone",
"(",
")",
"for",
"(",
"k",
",",
"v",
")",
"in",
"self",
".",
"variables",
".",
"items",
"(",
")",... | Returns a shallow copy of the current instance, except that all
variables are deep-cloned. | [
"Returns",
"a",
"shallow",
"copy",
"of",
"the",
"current",
"instance",
"except",
"that",
"all",
"variables",
"are",
"deep",
"-",
"cloned",
"."
] | 30d924ce770622bda0e390d613a8da42a2a20c32 | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/variables/kollekshuns.py#L152-L158 | train |
bids-standard/pybids | bids/variables/kollekshuns.py | BIDSVariableCollection._index_entities | def _index_entities(self):
''' Sets current instance's entities based on the existing index.
Note: Only entity key/value pairs common to all rows in all contained
Variables are returned. E.g., if a Collection contains Variables
extracted from runs 1, 2 and 3 from subject '01', t... | python | def _index_entities(self):
''' Sets current instance's entities based on the existing index.
Note: Only entity key/value pairs common to all rows in all contained
Variables are returned. E.g., if a Collection contains Variables
extracted from runs 1, 2 and 3 from subject '01', t... | [
"def",
"_index_entities",
"(",
"self",
")",
":",
"all_ents",
"=",
"pd",
".",
"DataFrame",
".",
"from_records",
"(",
"[",
"v",
".",
"entities",
"for",
"v",
"in",
"self",
".",
"variables",
".",
"values",
"(",
")",
"]",
")",
"constant",
"=",
"all_ents",
... | Sets current instance's entities based on the existing index.
Note: Only entity key/value pairs common to all rows in all contained
Variables are returned. E.g., if a Collection contains Variables
extracted from runs 1, 2 and 3 from subject '01', the returned dict
will be {'... | [
"Sets",
"current",
"instance",
"s",
"entities",
"based",
"on",
"the",
"existing",
"index",
"."
] | 30d924ce770622bda0e390d613a8da42a2a20c32 | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/variables/kollekshuns.py#L164-L181 | train |
bids-standard/pybids | bids/variables/kollekshuns.py | BIDSVariableCollection.match_variables | def match_variables(self, pattern, return_type='name'):
''' Return columns whose names match the provided regex pattern.
Args:
pattern (str): A regex pattern to match all variable names against.
return_type (str): What to return. Must be one of:
'name': Returns a... | python | def match_variables(self, pattern, return_type='name'):
''' Return columns whose names match the provided regex pattern.
Args:
pattern (str): A regex pattern to match all variable names against.
return_type (str): What to return. Must be one of:
'name': Returns a... | [
"def",
"match_variables",
"(",
"self",
",",
"pattern",
",",
"return_type",
"=",
"'name'",
")",
":",
"pattern",
"=",
"re",
".",
"compile",
"(",
"pattern",
")",
"vars_",
"=",
"[",
"v",
"for",
"v",
"in",
"self",
".",
"variables",
".",
"values",
"(",
")"... | Return columns whose names match the provided regex pattern.
Args:
pattern (str): A regex pattern to match all variable names against.
return_type (str): What to return. Must be one of:
'name': Returns a list of names of matching variables.
'variable': Re... | [
"Return",
"columns",
"whose",
"names",
"match",
"the",
"provided",
"regex",
"pattern",
"."
] | 30d924ce770622bda0e390d613a8da42a2a20c32 | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/variables/kollekshuns.py#L196-L209 | train |
bids-standard/pybids | bids/variables/kollekshuns.py | BIDSRunVariableCollection.to_df | def to_df(self, variables=None, format='wide', sparse=True,
sampling_rate=None, include_sparse=True, include_dense=True,
**kwargs):
''' Merge columns into a single pandas DataFrame.
Args:
variables (list): Optional list of variable names to retain;
... | python | def to_df(self, variables=None, format='wide', sparse=True,
sampling_rate=None, include_sparse=True, include_dense=True,
**kwargs):
''' Merge columns into a single pandas DataFrame.
Args:
variables (list): Optional list of variable names to retain;
... | [
"def",
"to_df",
"(",
"self",
",",
"variables",
"=",
"None",
",",
"format",
"=",
"'wide'",
",",
"sparse",
"=",
"True",
",",
"sampling_rate",
"=",
"None",
",",
"include_sparse",
"=",
"True",
",",
"include_dense",
"=",
"True",
",",
"*",
"*",
"kwargs",
")"... | Merge columns into a single pandas DataFrame.
Args:
variables (list): Optional list of variable names to retain;
if None, all variables are written out.
format (str): Whether to return a DataFrame in 'wide' or 'long'
format. In 'wide' format, each row is ... | [
"Merge",
"columns",
"into",
"a",
"single",
"pandas",
"DataFrame",
"."
] | 30d924ce770622bda0e390d613a8da42a2a20c32 | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/variables/kollekshuns.py#L290-L351 | train |
bids-standard/pybids | bids/analysis/transformations/munge.py | Rename._transform | def _transform(self, var):
''' Rename happens automatically in the base class, so all we need to
do is unset the original variable in the collection. '''
self.collection.variables.pop(var.name)
return var.values | python | def _transform(self, var):
''' Rename happens automatically in the base class, so all we need to
do is unset the original variable in the collection. '''
self.collection.variables.pop(var.name)
return var.values | [
"def",
"_transform",
"(",
"self",
",",
"var",
")",
":",
"self",
".",
"collection",
".",
"variables",
".",
"pop",
"(",
"var",
".",
"name",
")",
"return",
"var",
".",
"values"
] | Rename happens automatically in the base class, so all we need to
do is unset the original variable in the collection. | [
"Rename",
"happens",
"automatically",
"in",
"the",
"base",
"class",
"so",
"all",
"we",
"need",
"to",
"do",
"is",
"unset",
"the",
"original",
"variable",
"in",
"the",
"collection",
"."
] | 30d924ce770622bda0e390d613a8da42a2a20c32 | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/analysis/transformations/munge.py#L215-L219 | train |
bids-standard/pybids | bids/layout/writing.py | replace_entities | def replace_entities(entities, pattern):
"""
Replaces all entity names in a given pattern with the corresponding
values provided by entities.
Args:
entities (dict): A dictionary mapping entity names to entity values.
pattern (str): A path pattern that contains entity names denoted
... | python | def replace_entities(entities, pattern):
"""
Replaces all entity names in a given pattern with the corresponding
values provided by entities.
Args:
entities (dict): A dictionary mapping entity names to entity values.
pattern (str): A path pattern that contains entity names denoted
... | [
"def",
"replace_entities",
"(",
"entities",
",",
"pattern",
")",
":",
"ents",
"=",
"re",
".",
"findall",
"(",
"r'\\{(.*?)\\}'",
",",
"pattern",
")",
"new_path",
"=",
"pattern",
"for",
"ent",
"in",
"ents",
":",
"match",
"=",
"re",
".",
"search",
"(",
"r... | Replaces all entity names in a given pattern with the corresponding
values provided by entities.
Args:
entities (dict): A dictionary mapping entity names to entity values.
pattern (str): A path pattern that contains entity names denoted
by curly braces. Optional portions denoted by ... | [
"Replaces",
"all",
"entity",
"names",
"in",
"a",
"given",
"pattern",
"with",
"the",
"corresponding",
"values",
"provided",
"by",
"entities",
"."
] | 30d924ce770622bda0e390d613a8da42a2a20c32 | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/layout/writing.py#L16-L55 | train |
bids-standard/pybids | bids/layout/writing.py | write_contents_to_file | def write_contents_to_file(path, contents=None, link_to=None,
content_mode='text', root=None, conflicts='fail'):
"""
Uses provided filename patterns to write contents to a new path, given
a corresponding entity map.
Args:
path (str): Destination path of the desired co... | python | def write_contents_to_file(path, contents=None, link_to=None,
content_mode='text', root=None, conflicts='fail'):
"""
Uses provided filename patterns to write contents to a new path, given
a corresponding entity map.
Args:
path (str): Destination path of the desired co... | [
"def",
"write_contents_to_file",
"(",
"path",
",",
"contents",
"=",
"None",
",",
"link_to",
"=",
"None",
",",
"content_mode",
"=",
"'text'",
",",
"root",
"=",
"None",
",",
"conflicts",
"=",
"'fail'",
")",
":",
"if",
"root",
"is",
"None",
"and",
"not",
... | Uses provided filename patterns to write contents to a new path, given
a corresponding entity map.
Args:
path (str): Destination path of the desired contents.
contents (str): Raw text or binary encoded string of contents to write
to the new path.
link_to (str): Optional path... | [
"Uses",
"provided",
"filename",
"patterns",
"to",
"write",
"contents",
"to",
"a",
"new",
"path",
"given",
"a",
"corresponding",
"entity",
"map",
"."
] | 30d924ce770622bda0e390d613a8da42a2a20c32 | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/layout/writing.py#L109-L177 | train |
bids-standard/pybids | bids/reports/report.py | BIDSReport.generate | def generate(self, **kwargs):
"""Generate the methods section.
Parameters
----------
task_converter : :obj:`dict`, optional
A dictionary with information for converting task names from BIDS
filename format to human-readable strings.
Returns
-----... | python | def generate(self, **kwargs):
"""Generate the methods section.
Parameters
----------
task_converter : :obj:`dict`, optional
A dictionary with information for converting task names from BIDS
filename format to human-readable strings.
Returns
-----... | [
"def",
"generate",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"descriptions",
"=",
"[",
"]",
"subjs",
"=",
"self",
".",
"layout",
".",
"get_subjects",
"(",
"*",
"*",
"kwargs",
")",
"kwargs",
"=",
"{",
"k",
":",
"v",
"for",
"k",
",",
"v",
"... | Generate the methods section.
Parameters
----------
task_converter : :obj:`dict`, optional
A dictionary with information for converting task names from BIDS
filename format to human-readable strings.
Returns
-------
counter : :obj:`collections.Co... | [
"Generate",
"the",
"methods",
"section",
"."
] | 30d924ce770622bda0e390d613a8da42a2a20c32 | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/reports/report.py#L53-L92 | train |
bids-standard/pybids | bids/reports/report.py | BIDSReport._report_subject | def _report_subject(self, subject, **kwargs):
"""Write a report for a single subject.
Parameters
----------
subject : :obj:`str`
Subject ID.
Attributes
----------
layout : :obj:`bids.layout.BIDSLayout`
Layout object for a BIDS dataset.
... | python | def _report_subject(self, subject, **kwargs):
"""Write a report for a single subject.
Parameters
----------
subject : :obj:`str`
Subject ID.
Attributes
----------
layout : :obj:`bids.layout.BIDSLayout`
Layout object for a BIDS dataset.
... | [
"def",
"_report_subject",
"(",
"self",
",",
"subject",
",",
"*",
"*",
"kwargs",
")",
":",
"description_list",
"=",
"[",
"]",
"# Remove sess from kwargs if provided, else set sess as all available",
"sessions",
"=",
"kwargs",
".",
"pop",
"(",
"'session'",
",",
"self"... | Write a report for a single subject.
Parameters
----------
subject : :obj:`str`
Subject ID.
Attributes
----------
layout : :obj:`bids.layout.BIDSLayout`
Layout object for a BIDS dataset.
config : :obj:`dict`
Configuration info... | [
"Write",
"a",
"report",
"for",
"a",
"single",
"subject",
"."
] | 30d924ce770622bda0e390d613a8da42a2a20c32 | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/reports/report.py#L94-L147 | train |
bids-standard/pybids | bids/analysis/hrf.py | _gamma_difference_hrf | def _gamma_difference_hrf(tr, oversampling=50, time_length=32., onset=0.,
delay=6, undershoot=16., dispersion=1.,
u_dispersion=1., ratio=0.167):
""" Compute an hrf as the difference of two gamma functions
Parameters
----------
tr : float
scan... | python | def _gamma_difference_hrf(tr, oversampling=50, time_length=32., onset=0.,
delay=6, undershoot=16., dispersion=1.,
u_dispersion=1., ratio=0.167):
""" Compute an hrf as the difference of two gamma functions
Parameters
----------
tr : float
scan... | [
"def",
"_gamma_difference_hrf",
"(",
"tr",
",",
"oversampling",
"=",
"50",
",",
"time_length",
"=",
"32.",
",",
"onset",
"=",
"0.",
",",
"delay",
"=",
"6",
",",
"undershoot",
"=",
"16.",
",",
"dispersion",
"=",
"1.",
",",
"u_dispersion",
"=",
"1.",
","... | Compute an hrf as the difference of two gamma functions
Parameters
----------
tr : float
scan repeat time, in seconds
oversampling : int, optional (default=16)
temporal oversampling factor
time_length : float, optional (default=32)
hrf kernel length, in seconds
onset... | [
"Compute",
"an",
"hrf",
"as",
"the",
"difference",
"of",
"two",
"gamma",
"functions"
] | 30d924ce770622bda0e390d613a8da42a2a20c32 | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/analysis/hrf.py#L13-L61 | train |
bids-standard/pybids | bids/analysis/hrf.py | spm_hrf | def spm_hrf(tr, oversampling=50, time_length=32., onset=0.):
""" Implementation of the SPM hrf model
Parameters
----------
tr : float
scan repeat time, in seconds
oversampling : int, optional
temporal oversampling factor
time_length : float, optional
hrf kernel length,... | python | def spm_hrf(tr, oversampling=50, time_length=32., onset=0.):
""" Implementation of the SPM hrf model
Parameters
----------
tr : float
scan repeat time, in seconds
oversampling : int, optional
temporal oversampling factor
time_length : float, optional
hrf kernel length,... | [
"def",
"spm_hrf",
"(",
"tr",
",",
"oversampling",
"=",
"50",
",",
"time_length",
"=",
"32.",
",",
"onset",
"=",
"0.",
")",
":",
"return",
"_gamma_difference_hrf",
"(",
"tr",
",",
"oversampling",
",",
"time_length",
",",
"onset",
")"
] | Implementation of the SPM hrf model
Parameters
----------
tr : float
scan repeat time, in seconds
oversampling : int, optional
temporal oversampling factor
time_length : float, optional
hrf kernel length, in seconds
onset : float, optional
hrf onset time, in s... | [
"Implementation",
"of",
"the",
"SPM",
"hrf",
"model"
] | 30d924ce770622bda0e390d613a8da42a2a20c32 | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/analysis/hrf.py#L64-L86 | train |
bids-standard/pybids | bids/analysis/hrf.py | glover_hrf | def glover_hrf(tr, oversampling=50, time_length=32., onset=0.):
""" Implementation of the Glover hrf model
Parameters
----------
tr : float
scan repeat time, in seconds
oversampling : int, optional
temporal oversampling factor
time_length : float, optional
hrf kernel l... | python | def glover_hrf(tr, oversampling=50, time_length=32., onset=0.):
""" Implementation of the Glover hrf model
Parameters
----------
tr : float
scan repeat time, in seconds
oversampling : int, optional
temporal oversampling factor
time_length : float, optional
hrf kernel l... | [
"def",
"glover_hrf",
"(",
"tr",
",",
"oversampling",
"=",
"50",
",",
"time_length",
"=",
"32.",
",",
"onset",
"=",
"0.",
")",
":",
"return",
"_gamma_difference_hrf",
"(",
"tr",
",",
"oversampling",
",",
"time_length",
",",
"onset",
",",
"delay",
"=",
"6"... | Implementation of the Glover hrf model
Parameters
----------
tr : float
scan repeat time, in seconds
oversampling : int, optional
temporal oversampling factor
time_length : float, optional
hrf kernel length, in seconds
onset : float, optional
onset of the resp... | [
"Implementation",
"of",
"the",
"Glover",
"hrf",
"model"
] | 30d924ce770622bda0e390d613a8da42a2a20c32 | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/analysis/hrf.py#L89-L113 | train |
bids-standard/pybids | bids/analysis/hrf.py | spm_dispersion_derivative | def spm_dispersion_derivative(tr, oversampling=50, time_length=32., onset=0.):
"""Implementation of the SPM dispersion derivative hrf model
Parameters
----------
tr: float
scan repeat time, in seconds
oversampling: int, optional
temporal oversampling factor in seconds
time_len... | python | def spm_dispersion_derivative(tr, oversampling=50, time_length=32., onset=0.):
"""Implementation of the SPM dispersion derivative hrf model
Parameters
----------
tr: float
scan repeat time, in seconds
oversampling: int, optional
temporal oversampling factor in seconds
time_len... | [
"def",
"spm_dispersion_derivative",
"(",
"tr",
",",
"oversampling",
"=",
"50",
",",
"time_length",
"=",
"32.",
",",
"onset",
"=",
"0.",
")",
":",
"dd",
"=",
".01",
"dhrf",
"=",
"1.",
"/",
"dd",
"*",
"(",
"-",
"_gamma_difference_hrf",
"(",
"tr",
",",
... | Implementation of the SPM dispersion derivative hrf model
Parameters
----------
tr: float
scan repeat time, in seconds
oversampling: int, optional
temporal oversampling factor in seconds
time_length: float, optional
hrf kernel length, in seconds
onset : float, optiona... | [
"Implementation",
"of",
"the",
"SPM",
"dispersion",
"derivative",
"hrf",
"model"
] | 30d924ce770622bda0e390d613a8da42a2a20c32 | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/analysis/hrf.py#L169-L196 | train |
bids-standard/pybids | bids/analysis/hrf.py | glover_dispersion_derivative | def glover_dispersion_derivative(tr, oversampling=50, time_length=32.,
onset=0.):
"""Implementation of the Glover dispersion derivative hrf model
Parameters
----------
tr: float
scan repeat time, in seconds
oversampling: int, optional
temporal overs... | python | def glover_dispersion_derivative(tr, oversampling=50, time_length=32.,
onset=0.):
"""Implementation of the Glover dispersion derivative hrf model
Parameters
----------
tr: float
scan repeat time, in seconds
oversampling: int, optional
temporal overs... | [
"def",
"glover_dispersion_derivative",
"(",
"tr",
",",
"oversampling",
"=",
"50",
",",
"time_length",
"=",
"32.",
",",
"onset",
"=",
"0.",
")",
":",
"dd",
"=",
".01",
"dhrf",
"=",
"1.",
"/",
"dd",
"*",
"(",
"-",
"_gamma_difference_hrf",
"(",
"tr",
",",... | Implementation of the Glover dispersion derivative hrf model
Parameters
----------
tr: float
scan repeat time, in seconds
oversampling: int, optional
temporal oversampling factor in seconds
time_length: float, optional
hrf kernel length, in seconds
onset : float, opti... | [
"Implementation",
"of",
"the",
"Glover",
"dispersion",
"derivative",
"hrf",
"model"
] | 30d924ce770622bda0e390d613a8da42a2a20c32 | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/analysis/hrf.py#L199-L230 | train |
bids-standard/pybids | bids/analysis/hrf.py | _sample_condition | def _sample_condition(exp_condition, frame_times, oversampling=50,
min_onset=-24):
"""Make a possibly oversampled event regressor from condition information.
Parameters
----------
exp_condition : arraylike of shape (3, n_events)
yields description of events for this conditi... | python | def _sample_condition(exp_condition, frame_times, oversampling=50,
min_onset=-24):
"""Make a possibly oversampled event regressor from condition information.
Parameters
----------
exp_condition : arraylike of shape (3, n_events)
yields description of events for this conditi... | [
"def",
"_sample_condition",
"(",
"exp_condition",
",",
"frame_times",
",",
"oversampling",
"=",
"50",
",",
"min_onset",
"=",
"-",
"24",
")",
":",
"# Find the high-resolution frame_times",
"n",
"=",
"frame_times",
".",
"size",
"min_onset",
"=",
"float",
"(",
"min... | Make a possibly oversampled event regressor from condition information.
Parameters
----------
exp_condition : arraylike of shape (3, n_events)
yields description of events for this condition as a
(onsets, durations, amplitudes) triplet
frame_times : array of shape(n_scans)
samp... | [
"Make",
"a",
"possibly",
"oversampled",
"event",
"regressor",
"from",
"condition",
"information",
"."
] | 30d924ce770622bda0e390d613a8da42a2a20c32 | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/analysis/hrf.py#L233-L295 | train |
bids-standard/pybids | bids/analysis/hrf.py | _resample_regressor | def _resample_regressor(hr_regressor, hr_frame_times, frame_times):
""" this function sub-samples the regressors at frame times
Parameters
----------
hr_regressor : array of shape(n_samples),
the regressor time course sampled at high temporal resolution
hr_frame_times : array of shape(n_sa... | python | def _resample_regressor(hr_regressor, hr_frame_times, frame_times):
""" this function sub-samples the regressors at frame times
Parameters
----------
hr_regressor : array of shape(n_samples),
the regressor time course sampled at high temporal resolution
hr_frame_times : array of shape(n_sa... | [
"def",
"_resample_regressor",
"(",
"hr_regressor",
",",
"hr_frame_times",
",",
"frame_times",
")",
":",
"from",
"scipy",
".",
"interpolate",
"import",
"interp1d",
"f",
"=",
"interp1d",
"(",
"hr_frame_times",
",",
"hr_regressor",
")",
"return",
"f",
"(",
"frame_t... | this function sub-samples the regressors at frame times
Parameters
----------
hr_regressor : array of shape(n_samples),
the regressor time course sampled at high temporal resolution
hr_frame_times : array of shape(n_samples),
the corresponding time stamps
frame_times: array of sha... | [
"this",
"function",
"sub",
"-",
"samples",
"the",
"regressors",
"at",
"frame",
"times"
] | 30d924ce770622bda0e390d613a8da42a2a20c32 | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/analysis/hrf.py#L298-L319 | train |
bids-standard/pybids | bids/analysis/hrf.py | _orthogonalize | def _orthogonalize(X):
""" Orthogonalize every column of design `X` w.r.t preceding columns
Parameters
----------
X: array of shape(n, p)
the data to be orthogonalized
Returns
-------
X: array of shape(n, p)
the data after orthogonalization
Notes
-----
X is chang... | python | def _orthogonalize(X):
""" Orthogonalize every column of design `X` w.r.t preceding columns
Parameters
----------
X: array of shape(n, p)
the data to be orthogonalized
Returns
-------
X: array of shape(n, p)
the data after orthogonalization
Notes
-----
X is chang... | [
"def",
"_orthogonalize",
"(",
"X",
")",
":",
"if",
"X",
".",
"size",
"==",
"X",
".",
"shape",
"[",
"0",
"]",
":",
"return",
"X",
"from",
"scipy",
".",
"linalg",
"import",
"pinv",
",",
"norm",
"for",
"i",
"in",
"range",
"(",
"1",
",",
"X",
".",
... | Orthogonalize every column of design `X` w.r.t preceding columns
Parameters
----------
X: array of shape(n, p)
the data to be orthogonalized
Returns
-------
X: array of shape(n, p)
the data after orthogonalization
Notes
-----
X is changed in place. The columns are no... | [
"Orthogonalize",
"every",
"column",
"of",
"design",
"X",
"w",
".",
"r",
".",
"t",
"preceding",
"columns"
] | 30d924ce770622bda0e390d613a8da42a2a20c32 | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/analysis/hrf.py#L322-L345 | train |
bids-standard/pybids | bids/analysis/hrf.py | _regressor_names | def _regressor_names(con_name, hrf_model, fir_delays=None):
""" Returns a list of regressor names, computed from con-name and hrf type
Parameters
----------
con_name: string
identifier of the condition
hrf_model: string or None,
hrf model chosen
fir_delays: 1D array_like, optio... | python | def _regressor_names(con_name, hrf_model, fir_delays=None):
""" Returns a list of regressor names, computed from con-name and hrf type
Parameters
----------
con_name: string
identifier of the condition
hrf_model: string or None,
hrf model chosen
fir_delays: 1D array_like, optio... | [
"def",
"_regressor_names",
"(",
"con_name",
",",
"hrf_model",
",",
"fir_delays",
"=",
"None",
")",
":",
"if",
"hrf_model",
"in",
"[",
"'glover'",
",",
"'spm'",
",",
"None",
"]",
":",
"return",
"[",
"con_name",
"]",
"elif",
"hrf_model",
"in",
"[",
"\"glov... | Returns a list of regressor names, computed from con-name and hrf type
Parameters
----------
con_name: string
identifier of the condition
hrf_model: string or None,
hrf model chosen
fir_delays: 1D array_like, optional,
Delays used in case of an FIR model
Returns
--... | [
"Returns",
"a",
"list",
"of",
"regressor",
"names",
"computed",
"from",
"con",
"-",
"name",
"and",
"hrf",
"type"
] | 30d924ce770622bda0e390d613a8da42a2a20c32 | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/analysis/hrf.py#L348-L375 | train |
bids-standard/pybids | bids/analysis/hrf.py | _hrf_kernel | def _hrf_kernel(hrf_model, tr, oversampling=50, fir_delays=None):
""" Given the specification of the hemodynamic model and time parameters,
return the list of matching kernels
Parameters
----------
hrf_model : string or None,
identifier of the hrf model
tr : float
the repetitio... | python | def _hrf_kernel(hrf_model, tr, oversampling=50, fir_delays=None):
""" Given the specification of the hemodynamic model and time parameters,
return the list of matching kernels
Parameters
----------
hrf_model : string or None,
identifier of the hrf model
tr : float
the repetitio... | [
"def",
"_hrf_kernel",
"(",
"hrf_model",
",",
"tr",
",",
"oversampling",
"=",
"50",
",",
"fir_delays",
"=",
"None",
")",
":",
"acceptable_hrfs",
"=",
"[",
"'spm'",
",",
"'spm + derivative'",
",",
"'spm + derivative + dispersion'",
",",
"'fir'",
",",
"'glover'",
... | Given the specification of the hemodynamic model and time parameters,
return the list of matching kernels
Parameters
----------
hrf_model : string or None,
identifier of the hrf model
tr : float
the repetition time in seconds
oversampling : int, optional
temporal overs... | [
"Given",
"the",
"specification",
"of",
"the",
"hemodynamic",
"model",
"and",
"time",
"parameters",
"return",
"the",
"list",
"of",
"matching",
"kernels"
] | 30d924ce770622bda0e390d613a8da42a2a20c32 | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/analysis/hrf.py#L378-L432 | train |
bids-standard/pybids | bids/analysis/hrf.py | compute_regressor | def compute_regressor(exp_condition, hrf_model, frame_times, con_id='cond',
oversampling=50, fir_delays=None, min_onset=-24):
""" This is the main function to convolve regressors with hrf model
Parameters
----------
exp_condition : array-like of shape (3, n_events)
yields ... | python | def compute_regressor(exp_condition, hrf_model, frame_times, con_id='cond',
oversampling=50, fir_delays=None, min_onset=-24):
""" This is the main function to convolve regressors with hrf model
Parameters
----------
exp_condition : array-like of shape (3, n_events)
yields ... | [
"def",
"compute_regressor",
"(",
"exp_condition",
",",
"hrf_model",
",",
"frame_times",
",",
"con_id",
"=",
"'cond'",
",",
"oversampling",
"=",
"50",
",",
"fir_delays",
"=",
"None",
",",
"min_onset",
"=",
"-",
"24",
")",
":",
"# this is the average tr in this se... | This is the main function to convolve regressors with hrf model
Parameters
----------
exp_condition : array-like of shape (3, n_events)
yields description of events for this condition as a
(onsets, durations, amplitudes) triplet
hrf_model : {'spm', 'spm + derivative', 'spm + derivative... | [
"This",
"is",
"the",
"main",
"function",
"to",
"convolve",
"regressors",
"with",
"hrf",
"model"
] | 30d924ce770622bda0e390d613a8da42a2a20c32 | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/analysis/hrf.py#L435-L516 | train |
bids-standard/pybids | bids/utils.py | matches_entities | def matches_entities(obj, entities, strict=False):
''' Checks whether an object's entities match the input. '''
if strict and set(obj.entities.keys()) != set(entities.keys()):
return False
comm_ents = list(set(obj.entities.keys()) & set(entities.keys()))
for k in comm_ents:
current = ob... | python | def matches_entities(obj, entities, strict=False):
''' Checks whether an object's entities match the input. '''
if strict and set(obj.entities.keys()) != set(entities.keys()):
return False
comm_ents = list(set(obj.entities.keys()) & set(entities.keys()))
for k in comm_ents:
current = ob... | [
"def",
"matches_entities",
"(",
"obj",
",",
"entities",
",",
"strict",
"=",
"False",
")",
":",
"if",
"strict",
"and",
"set",
"(",
"obj",
".",
"entities",
".",
"keys",
"(",
")",
")",
"!=",
"set",
"(",
"entities",
".",
"keys",
"(",
")",
")",
":",
"... | Checks whether an object's entities match the input. | [
"Checks",
"whether",
"an",
"object",
"s",
"entities",
"match",
"the",
"input",
"."
] | 30d924ce770622bda0e390d613a8da42a2a20c32 | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/utils.py#L12-L26 | train |
bids-standard/pybids | bids/utils.py | check_path_matches_patterns | def check_path_matches_patterns(path, patterns):
''' Check if the path matches at least one of the provided patterns. '''
path = os.path.abspath(path)
for patt in patterns:
if isinstance(patt, six.string_types):
if path == patt:
return True
elif patt.search(path):... | python | def check_path_matches_patterns(path, patterns):
''' Check if the path matches at least one of the provided patterns. '''
path = os.path.abspath(path)
for patt in patterns:
if isinstance(patt, six.string_types):
if path == patt:
return True
elif patt.search(path):... | [
"def",
"check_path_matches_patterns",
"(",
"path",
",",
"patterns",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"path",
")",
"for",
"patt",
"in",
"patterns",
":",
"if",
"isinstance",
"(",
"patt",
",",
"six",
".",
"string_types",
")",
... | Check if the path matches at least one of the provided patterns. | [
"Check",
"if",
"the",
"path",
"matches",
"at",
"least",
"one",
"of",
"the",
"provided",
"patterns",
"."
] | 30d924ce770622bda0e390d613a8da42a2a20c32 | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/utils.py#L91-L100 | train |
bids-standard/pybids | bids/layout/core.py | Entity.count | def count(self, files=False):
""" Returns a count of unique values or files.
Args:
files (bool): When True, counts all files mapped to the Entity.
When False, counts all unique values.
Returns: an int.
"""
return len(self.files) if files else len(self... | python | def count(self, files=False):
""" Returns a count of unique values or files.
Args:
files (bool): When True, counts all files mapped to the Entity.
When False, counts all unique values.
Returns: an int.
"""
return len(self.files) if files else len(self... | [
"def",
"count",
"(",
"self",
",",
"files",
"=",
"False",
")",
":",
"return",
"len",
"(",
"self",
".",
"files",
")",
"if",
"files",
"else",
"len",
"(",
"self",
".",
"unique",
"(",
")",
")"
] | Returns a count of unique values or files.
Args:
files (bool): When True, counts all files mapped to the Entity.
When False, counts all unique values.
Returns: an int. | [
"Returns",
"a",
"count",
"of",
"unique",
"values",
"or",
"files",
"."
] | 30d924ce770622bda0e390d613a8da42a2a20c32 | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/layout/core.py#L147-L155 | train |
bids-standard/pybids | bids/reports/parsing.py | general_acquisition_info | def general_acquisition_info(metadata):
"""
General sentence on data acquisition. Should be first sentence in MRI data
acquisition section.
Parameters
----------
metadata : :obj:`dict`
The metadata for the dataset.
Returns
-------
out_str : :obj:`str`
Output string ... | python | def general_acquisition_info(metadata):
"""
General sentence on data acquisition. Should be first sentence in MRI data
acquisition section.
Parameters
----------
metadata : :obj:`dict`
The metadata for the dataset.
Returns
-------
out_str : :obj:`str`
Output string ... | [
"def",
"general_acquisition_info",
"(",
"metadata",
")",
":",
"out_str",
"=",
"(",
"'MR data were acquired using a {tesla}-Tesla {manu} {model} '",
"'MRI scanner.'",
")",
"out_str",
"=",
"out_str",
".",
"format",
"(",
"tesla",
"=",
"metadata",
".",
"get",
"(",
"'Magne... | General sentence on data acquisition. Should be first sentence in MRI data
acquisition section.
Parameters
----------
metadata : :obj:`dict`
The metadata for the dataset.
Returns
-------
out_str : :obj:`str`
Output string with scanner information. | [
"General",
"sentence",
"on",
"data",
"acquisition",
".",
"Should",
"be",
"first",
"sentence",
"in",
"MRI",
"data",
"acquisition",
"section",
"."
] | 30d924ce770622bda0e390d613a8da42a2a20c32 | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/reports/parsing.py#L22-L44 | train |
bids-standard/pybids | bids/reports/parsing.py | parse_niftis | def parse_niftis(layout, niftis, subj, config, **kwargs):
"""
Loop through niftis in a BIDSLayout and generate the appropriate description
type for each scan. Compile all of the descriptions into a list.
Parameters
----------
layout : :obj:`bids.layout.BIDSLayout`
Layout object for a BI... | python | def parse_niftis(layout, niftis, subj, config, **kwargs):
"""
Loop through niftis in a BIDSLayout and generate the appropriate description
type for each scan. Compile all of the descriptions into a list.
Parameters
----------
layout : :obj:`bids.layout.BIDSLayout`
Layout object for a BI... | [
"def",
"parse_niftis",
"(",
"layout",
",",
"niftis",
",",
"subj",
",",
"config",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"=",
"{",
"k",
":",
"v",
"for",
"k",
",",
"v",
"in",
"kwargs",
".",
"items",
"(",
")",
"if",
"v",
"is",
"not",
"None",... | Loop through niftis in a BIDSLayout and generate the appropriate description
type for each scan. Compile all of the descriptions into a list.
Parameters
----------
layout : :obj:`bids.layout.BIDSLayout`
Layout object for a BIDS dataset.
niftis : :obj:`list` or :obj:`grabbit.core.File`
... | [
"Loop",
"through",
"niftis",
"in",
"a",
"BIDSLayout",
"and",
"generate",
"the",
"appropriate",
"description",
"type",
"for",
"each",
"scan",
".",
"Compile",
"all",
"of",
"the",
"descriptions",
"into",
"a",
"list",
"."
] | 30d924ce770622bda0e390d613a8da42a2a20c32 | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/reports/parsing.py#L407-L479 | train |
Microsoft/ApplicationInsights-Python | applicationinsights/TelemetryClient.py | TelemetryClient.track_exception | def track_exception(self, type=None, value=None, tb=None, properties=None, measurements=None):
""" Send information about a single exception that occurred in the application.
Args:
type (Type). the type of the exception that was thrown.\n
value (:class:`Exception`). the exceptio... | python | def track_exception(self, type=None, value=None, tb=None, properties=None, measurements=None):
""" Send information about a single exception that occurred in the application.
Args:
type (Type). the type of the exception that was thrown.\n
value (:class:`Exception`). the exceptio... | [
"def",
"track_exception",
"(",
"self",
",",
"type",
"=",
"None",
",",
"value",
"=",
"None",
",",
"tb",
"=",
"None",
",",
"properties",
"=",
"None",
",",
"measurements",
"=",
"None",
")",
":",
"if",
"not",
"type",
"or",
"not",
"value",
"or",
"not",
... | Send information about a single exception that occurred in the application.
Args:
type (Type). the type of the exception that was thrown.\n
value (:class:`Exception`). the exception that the client wants to send.\n
tb (:class:`Traceback`). the traceback information as return... | [
"Send",
"information",
"about",
"a",
"single",
"exception",
"that",
"occurred",
"in",
"the",
"application",
"."
] | 8452ab7126f9bb6964637d4aa1258c2af17563d6 | https://github.com/Microsoft/ApplicationInsights-Python/blob/8452ab7126f9bb6964637d4aa1258c2af17563d6/applicationinsights/TelemetryClient.py#L82-L126 | train |
Microsoft/ApplicationInsights-Python | applicationinsights/TelemetryClient.py | TelemetryClient.track_event | def track_event(self, name, properties=None, measurements=None):
""" Send information about a single event that has occurred in the context of the application.
Args:
name (str). the data to associate to this event.\n
properties (dict). the set of custom properties the client wan... | python | def track_event(self, name, properties=None, measurements=None):
""" Send information about a single event that has occurred in the context of the application.
Args:
name (str). the data to associate to this event.\n
properties (dict). the set of custom properties the client wan... | [
"def",
"track_event",
"(",
"self",
",",
"name",
",",
"properties",
"=",
"None",
",",
"measurements",
"=",
"None",
")",
":",
"data",
"=",
"channel",
".",
"contracts",
".",
"EventData",
"(",
")",
"data",
".",
"name",
"=",
"name",
"or",
"NULL_CONSTANT_STRIN... | Send information about a single event that has occurred in the context of the application.
Args:
name (str). the data to associate to this event.\n
properties (dict). the set of custom properties the client wants attached to this data item. (defaults to: None)\n
measurements... | [
"Send",
"information",
"about",
"a",
"single",
"event",
"that",
"has",
"occurred",
"in",
"the",
"context",
"of",
"the",
"application",
"."
] | 8452ab7126f9bb6964637d4aa1258c2af17563d6 | https://github.com/Microsoft/ApplicationInsights-Python/blob/8452ab7126f9bb6964637d4aa1258c2af17563d6/applicationinsights/TelemetryClient.py#L128-L143 | train |
Microsoft/ApplicationInsights-Python | applicationinsights/TelemetryClient.py | TelemetryClient.track_metric | def track_metric(self, name, value, type=None, count=None, min=None, max=None, std_dev=None, properties=None):
"""Send information about a single metric data point that was captured for the application.
Args:
name (str). the name of the metric that was captured.\n
value (float).... | python | def track_metric(self, name, value, type=None, count=None, min=None, max=None, std_dev=None, properties=None):
"""Send information about a single metric data point that was captured for the application.
Args:
name (str). the name of the metric that was captured.\n
value (float).... | [
"def",
"track_metric",
"(",
"self",
",",
"name",
",",
"value",
",",
"type",
"=",
"None",
",",
"count",
"=",
"None",
",",
"min",
"=",
"None",
",",
"max",
"=",
"None",
",",
"std_dev",
"=",
"None",
",",
"properties",
"=",
"None",
")",
":",
"dataPoint"... | Send information about a single metric data point that was captured for the application.
Args:
name (str). the name of the metric that was captured.\n
value (float). the value of the metric that was captured.\n
type (:class:`channel.contracts.DataPointType`). the type of the... | [
"Send",
"information",
"about",
"a",
"single",
"metric",
"data",
"point",
"that",
"was",
"captured",
"for",
"the",
"application",
"."
] | 8452ab7126f9bb6964637d4aa1258c2af17563d6 | https://github.com/Microsoft/ApplicationInsights-Python/blob/8452ab7126f9bb6964637d4aa1258c2af17563d6/applicationinsights/TelemetryClient.py#L145-L172 | train |
Microsoft/ApplicationInsights-Python | applicationinsights/TelemetryClient.py | TelemetryClient.track_trace | def track_trace(self, name, properties=None, severity=None):
"""Sends a single trace statement.
Args:
name (str). the trace statement.\n
properties (dict). the set of custom properties the client wants attached to this data item. (defaults to: None)\n
severity (str).... | python | def track_trace(self, name, properties=None, severity=None):
"""Sends a single trace statement.
Args:
name (str). the trace statement.\n
properties (dict). the set of custom properties the client wants attached to this data item. (defaults to: None)\n
severity (str).... | [
"def",
"track_trace",
"(",
"self",
",",
"name",
",",
"properties",
"=",
"None",
",",
"severity",
"=",
"None",
")",
":",
"data",
"=",
"channel",
".",
"contracts",
".",
"MessageData",
"(",
")",
"data",
".",
"message",
"=",
"name",
"or",
"NULL_CONSTANT_STRI... | Sends a single trace statement.
Args:
name (str). the trace statement.\n
properties (dict). the set of custom properties the client wants attached to this data item. (defaults to: None)\n
severity (str). the severity level of this trace, one of DEBUG, INFO, WARNING, ERROR, C... | [
"Sends",
"a",
"single",
"trace",
"statement",
"."
] | 8452ab7126f9bb6964637d4aa1258c2af17563d6 | https://github.com/Microsoft/ApplicationInsights-Python/blob/8452ab7126f9bb6964637d4aa1258c2af17563d6/applicationinsights/TelemetryClient.py#L175-L190 | train |
Microsoft/ApplicationInsights-Python | applicationinsights/TelemetryClient.py | TelemetryClient.track_request | def track_request(self, name, url, success, start_time=None, duration=None, response_code=None, http_method=None, properties=None, measurements=None, request_id=None):
"""Sends a single request that was captured for the application.
Args:
name (str). the name for this request. All requests ... | python | def track_request(self, name, url, success, start_time=None, duration=None, response_code=None, http_method=None, properties=None, measurements=None, request_id=None):
"""Sends a single request that was captured for the application.
Args:
name (str). the name for this request. All requests ... | [
"def",
"track_request",
"(",
"self",
",",
"name",
",",
"url",
",",
"success",
",",
"start_time",
"=",
"None",
",",
"duration",
"=",
"None",
",",
"response_code",
"=",
"None",
",",
"http_method",
"=",
"None",
",",
"properties",
"=",
"None",
",",
"measurem... | Sends a single request that was captured for the application.
Args:
name (str). the name for this request. All requests with the same name will be grouped together.\n
url (str). the actual URL for this request (to show in individual request instances).\n
success (bool). true... | [
"Sends",
"a",
"single",
"request",
"that",
"was",
"captured",
"for",
"the",
"application",
"."
] | 8452ab7126f9bb6964637d4aa1258c2af17563d6 | https://github.com/Microsoft/ApplicationInsights-Python/blob/8452ab7126f9bb6964637d4aa1258c2af17563d6/applicationinsights/TelemetryClient.py#L193-L222 | train |
Microsoft/ApplicationInsights-Python | applicationinsights/TelemetryClient.py | TelemetryClient.track_dependency | def track_dependency(self, name, data, type=None, target=None, duration=None, success=None, result_code=None, properties=None, measurements=None, dependency_id=None):
"""Sends a single dependency telemetry that was captured for the application.
Args:
name (str). the name of the command init... | python | def track_dependency(self, name, data, type=None, target=None, duration=None, success=None, result_code=None, properties=None, measurements=None, dependency_id=None):
"""Sends a single dependency telemetry that was captured for the application.
Args:
name (str). the name of the command init... | [
"def",
"track_dependency",
"(",
"self",
",",
"name",
",",
"data",
",",
"type",
"=",
"None",
",",
"target",
"=",
"None",
",",
"duration",
"=",
"None",
",",
"success",
"=",
"None",
",",
"result_code",
"=",
"None",
",",
"properties",
"=",
"None",
",",
"... | Sends a single dependency telemetry that was captured for the application.
Args:
name (str). the name of the command initiated with this dependency call. Low cardinality value. Examples are stored procedure name and URL path template.\n
data (str). the command initiated by this dependen... | [
"Sends",
"a",
"single",
"dependency",
"telemetry",
"that",
"was",
"captured",
"for",
"the",
"application",
"."
] | 8452ab7126f9bb6964637d4aa1258c2af17563d6 | https://github.com/Microsoft/ApplicationInsights-Python/blob/8452ab7126f9bb6964637d4aa1258c2af17563d6/applicationinsights/TelemetryClient.py#L224-L253 | train |
Microsoft/ApplicationInsights-Python | applicationinsights/django/common.py | dummy_client | def dummy_client(reason):
"""Creates a dummy channel so even if we're not logging telemetry, we can still send
along the real object to things that depend on it to exist"""
sender = applicationinsights.channel.NullSender()
queue = applicationinsights.channel.SynchronousQueue(sender)
channel = appli... | python | def dummy_client(reason):
"""Creates a dummy channel so even if we're not logging telemetry, we can still send
along the real object to things that depend on it to exist"""
sender = applicationinsights.channel.NullSender()
queue = applicationinsights.channel.SynchronousQueue(sender)
channel = appli... | [
"def",
"dummy_client",
"(",
"reason",
")",
":",
"sender",
"=",
"applicationinsights",
".",
"channel",
".",
"NullSender",
"(",
")",
"queue",
"=",
"applicationinsights",
".",
"channel",
".",
"SynchronousQueue",
"(",
"sender",
")",
"channel",
"=",
"applicationinsig... | Creates a dummy channel so even if we're not logging telemetry, we can still send
along the real object to things that depend on it to exist | [
"Creates",
"a",
"dummy",
"channel",
"so",
"even",
"if",
"we",
"re",
"not",
"logging",
"telemetry",
"we",
"can",
"still",
"send",
"along",
"the",
"real",
"object",
"to",
"things",
"that",
"depend",
"on",
"it",
"to",
"exist"
] | 8452ab7126f9bb6964637d4aa1258c2af17563d6 | https://github.com/Microsoft/ApplicationInsights-Python/blob/8452ab7126f9bb6964637d4aa1258c2af17563d6/applicationinsights/django/common.py#L75-L82 | train |
Microsoft/ApplicationInsights-Python | applicationinsights/exceptions/enable.py | enable | def enable(instrumentation_key, *args, **kwargs):
"""Enables the automatic collection of unhandled exceptions. Captured exceptions will be sent to the Application
Insights service before being re-thrown. Multiple calls to this function with different instrumentation keys result
in multiple instances being s... | python | def enable(instrumentation_key, *args, **kwargs):
"""Enables the automatic collection of unhandled exceptions. Captured exceptions will be sent to the Application
Insights service before being re-thrown. Multiple calls to this function with different instrumentation keys result
in multiple instances being s... | [
"def",
"enable",
"(",
"instrumentation_key",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"instrumentation_key",
":",
"raise",
"Exception",
"(",
"'Instrumentation key was required but not provided'",
")",
"global",
"original_excepthook",
"global",... | Enables the automatic collection of unhandled exceptions. Captured exceptions will be sent to the Application
Insights service before being re-thrown. Multiple calls to this function with different instrumentation keys result
in multiple instances being submitted, one for each key.
.. code:: python
... | [
"Enables",
"the",
"automatic",
"collection",
"of",
"unhandled",
"exceptions",
".",
"Captured",
"exceptions",
"will",
"be",
"sent",
"to",
"the",
"Application",
"Insights",
"service",
"before",
"being",
"re",
"-",
"thrown",
".",
"Multiple",
"calls",
"to",
"this",
... | 8452ab7126f9bb6964637d4aa1258c2af17563d6 | https://github.com/Microsoft/ApplicationInsights-Python/blob/8452ab7126f9bb6964637d4aa1258c2af17563d6/applicationinsights/exceptions/enable.py#L8-L35 | train |
Microsoft/ApplicationInsights-Python | applicationinsights/flask/ext.py | AppInsights.init_app | def init_app(self, app):
"""
Initializes the extension for the provided Flask application.
Args:
app (flask.Flask). the Flask application for which to initialize the extension.
"""
self._key = app.config.get(CONF_KEY) or getenv(CONF_KEY)
if not self._key:
... | python | def init_app(self, app):
"""
Initializes the extension for the provided Flask application.
Args:
app (flask.Flask). the Flask application for which to initialize the extension.
"""
self._key = app.config.get(CONF_KEY) or getenv(CONF_KEY)
if not self._key:
... | [
"def",
"init_app",
"(",
"self",
",",
"app",
")",
":",
"self",
".",
"_key",
"=",
"app",
".",
"config",
".",
"get",
"(",
"CONF_KEY",
")",
"or",
"getenv",
"(",
"CONF_KEY",
")",
"if",
"not",
"self",
".",
"_key",
":",
"return",
"self",
".",
"_endpoint_u... | Initializes the extension for the provided Flask application.
Args:
app (flask.Flask). the Flask application for which to initialize the extension. | [
"Initializes",
"the",
"extension",
"for",
"the",
"provided",
"Flask",
"application",
"."
] | 8452ab7126f9bb6964637d4aa1258c2af17563d6 | https://github.com/Microsoft/ApplicationInsights-Python/blob/8452ab7126f9bb6964637d4aa1258c2af17563d6/applicationinsights/flask/ext.py#L87-L107 | train |
Microsoft/ApplicationInsights-Python | applicationinsights/flask/ext.py | AppInsights._init_request_logging | def _init_request_logging(self, app):
"""
Sets up request logging unless ``APPINSIGHTS_DISABLE_REQUEST_LOGGING``
is set in the Flask config.
Args:
app (flask.Flask). the Flask application for which to initialize the extension.
"""
enabled = not app.config.get... | python | def _init_request_logging(self, app):
"""
Sets up request logging unless ``APPINSIGHTS_DISABLE_REQUEST_LOGGING``
is set in the Flask config.
Args:
app (flask.Flask). the Flask application for which to initialize the extension.
"""
enabled = not app.config.get... | [
"def",
"_init_request_logging",
"(",
"self",
",",
"app",
")",
":",
"enabled",
"=",
"not",
"app",
".",
"config",
".",
"get",
"(",
"CONF_DISABLE_REQUEST_LOGGING",
",",
"False",
")",
"if",
"not",
"enabled",
":",
"return",
"self",
".",
"_requests_middleware",
"=... | Sets up request logging unless ``APPINSIGHTS_DISABLE_REQUEST_LOGGING``
is set in the Flask config.
Args:
app (flask.Flask). the Flask application for which to initialize the extension. | [
"Sets",
"up",
"request",
"logging",
"unless",
"APPINSIGHTS_DISABLE_REQUEST_LOGGING",
"is",
"set",
"in",
"the",
"Flask",
"config",
"."
] | 8452ab7126f9bb6964637d4aa1258c2af17563d6 | https://github.com/Microsoft/ApplicationInsights-Python/blob/8452ab7126f9bb6964637d4aa1258c2af17563d6/applicationinsights/flask/ext.py#L119-L135 | train |
Microsoft/ApplicationInsights-Python | applicationinsights/flask/ext.py | AppInsights._init_trace_logging | def _init_trace_logging(self, app):
"""
Sets up trace logging unless ``APPINSIGHTS_DISABLE_TRACE_LOGGING`` is
set in the Flask config.
Args:
app (flask.Flask). the Flask application for which to initialize the extension.
"""
enabled = not app.config.get(CONF_... | python | def _init_trace_logging(self, app):
"""
Sets up trace logging unless ``APPINSIGHTS_DISABLE_TRACE_LOGGING`` is
set in the Flask config.
Args:
app (flask.Flask). the Flask application for which to initialize the extension.
"""
enabled = not app.config.get(CONF_... | [
"def",
"_init_trace_logging",
"(",
"self",
",",
"app",
")",
":",
"enabled",
"=",
"not",
"app",
".",
"config",
".",
"get",
"(",
"CONF_DISABLE_TRACE_LOGGING",
",",
"False",
")",
"if",
"not",
"enabled",
":",
"return",
"self",
".",
"_trace_log_handler",
"=",
"... | Sets up trace logging unless ``APPINSIGHTS_DISABLE_TRACE_LOGGING`` is
set in the Flask config.
Args:
app (flask.Flask). the Flask application for which to initialize the extension. | [
"Sets",
"up",
"trace",
"logging",
"unless",
"APPINSIGHTS_DISABLE_TRACE_LOGGING",
"is",
"set",
"in",
"the",
"Flask",
"config",
"."
] | 8452ab7126f9bb6964637d4aa1258c2af17563d6 | https://github.com/Microsoft/ApplicationInsights-Python/blob/8452ab7126f9bb6964637d4aa1258c2af17563d6/applicationinsights/flask/ext.py#L137-L153 | train |
Microsoft/ApplicationInsights-Python | applicationinsights/flask/ext.py | AppInsights._init_exception_logging | def _init_exception_logging(self, app):
"""
Sets up exception logging unless ``APPINSIGHTS_DISABLE_EXCEPTION_LOGGING``
is set in the Flask config.
Args:
app (flask.Flask). the Flask application for which to initialize the extension.
"""
enabled = not app.conf... | python | def _init_exception_logging(self, app):
"""
Sets up exception logging unless ``APPINSIGHTS_DISABLE_EXCEPTION_LOGGING``
is set in the Flask config.
Args:
app (flask.Flask). the Flask application for which to initialize the extension.
"""
enabled = not app.conf... | [
"def",
"_init_exception_logging",
"(",
"self",
",",
"app",
")",
":",
"enabled",
"=",
"not",
"app",
".",
"config",
".",
"get",
"(",
"CONF_DISABLE_EXCEPTION_LOGGING",
",",
"False",
")",
"if",
"not",
"enabled",
":",
"return",
"exception_telemetry_client",
"=",
"T... | Sets up exception logging unless ``APPINSIGHTS_DISABLE_EXCEPTION_LOGGING``
is set in the Flask config.
Args:
app (flask.Flask). the Flask application for which to initialize the extension. | [
"Sets",
"up",
"exception",
"logging",
"unless",
"APPINSIGHTS_DISABLE_EXCEPTION_LOGGING",
"is",
"set",
"in",
"the",
"Flask",
"config",
"."
] | 8452ab7126f9bb6964637d4aa1258c2af17563d6 | https://github.com/Microsoft/ApplicationInsights-Python/blob/8452ab7126f9bb6964637d4aa1258c2af17563d6/applicationinsights/flask/ext.py#L155-L183 | train |
Microsoft/ApplicationInsights-Python | applicationinsights/flask/ext.py | AppInsights.flush | def flush(self):
"""Flushes the queued up telemetry to the service.
"""
if self._requests_middleware:
self._requests_middleware.flush()
if self._trace_log_handler:
self._trace_log_handler.flush()
if self._exception_telemetry_client:
self._exc... | python | def flush(self):
"""Flushes the queued up telemetry to the service.
"""
if self._requests_middleware:
self._requests_middleware.flush()
if self._trace_log_handler:
self._trace_log_handler.flush()
if self._exception_telemetry_client:
self._exc... | [
"def",
"flush",
"(",
"self",
")",
":",
"if",
"self",
".",
"_requests_middleware",
":",
"self",
".",
"_requests_middleware",
".",
"flush",
"(",
")",
"if",
"self",
".",
"_trace_log_handler",
":",
"self",
".",
"_trace_log_handler",
".",
"flush",
"(",
")",
"if... | Flushes the queued up telemetry to the service. | [
"Flushes",
"the",
"queued",
"up",
"telemetry",
"to",
"the",
"service",
"."
] | 8452ab7126f9bb6964637d4aa1258c2af17563d6 | https://github.com/Microsoft/ApplicationInsights-Python/blob/8452ab7126f9bb6964637d4aa1258c2af17563d6/applicationinsights/flask/ext.py#L185-L195 | train |
Microsoft/ApplicationInsights-Python | applicationinsights/channel/QueueBase.py | QueueBase.get | def get(self):
"""Gets a single item from the queue and returns it. If the queue is empty, this method will return None.
Returns:
:class:`contracts.Envelope`. a telemetry envelope object or None if the queue is empty.
"""
try:
item = self._queue.get_nowait()
... | python | def get(self):
"""Gets a single item from the queue and returns it. If the queue is empty, this method will return None.
Returns:
:class:`contracts.Envelope`. a telemetry envelope object or None if the queue is empty.
"""
try:
item = self._queue.get_nowait()
... | [
"def",
"get",
"(",
"self",
")",
":",
"try",
":",
"item",
"=",
"self",
".",
"_queue",
".",
"get_nowait",
"(",
")",
"except",
"(",
"Empty",
",",
"PersistEmpty",
")",
":",
"return",
"None",
"if",
"self",
".",
"_persistence_path",
":",
"self",
".",
"_que... | Gets a single item from the queue and returns it. If the queue is empty, this method will return None.
Returns:
:class:`contracts.Envelope`. a telemetry envelope object or None if the queue is empty. | [
"Gets",
"a",
"single",
"item",
"from",
"the",
"queue",
"and",
"returns",
"it",
".",
"If",
"the",
"queue",
"is",
"empty",
"this",
"method",
"will",
"return",
"None",
"."
] | 8452ab7126f9bb6964637d4aa1258c2af17563d6 | https://github.com/Microsoft/ApplicationInsights-Python/blob/8452ab7126f9bb6964637d4aa1258c2af17563d6/applicationinsights/channel/QueueBase.py#L92-L106 | train |
Microsoft/ApplicationInsights-Python | applicationinsights/logging/LoggingHandler.py | enable | def enable(instrumentation_key, *args, **kwargs):
"""Enables the Application Insights logging handler for the root logger for the supplied instrumentation key.
Multiple calls to this function with different instrumentation keys result in multiple handler instances.
.. code:: python
import logging
... | python | def enable(instrumentation_key, *args, **kwargs):
"""Enables the Application Insights logging handler for the root logger for the supplied instrumentation key.
Multiple calls to this function with different instrumentation keys result in multiple handler instances.
.. code:: python
import logging
... | [
"def",
"enable",
"(",
"instrumentation_key",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"instrumentation_key",
":",
"raise",
"Exception",
"(",
"'Instrumentation key was required but not provided'",
")",
"if",
"instrumentation_key",
"in",
"enab... | Enables the Application Insights logging handler for the root logger for the supplied instrumentation key.
Multiple calls to this function with different instrumentation keys result in multiple handler instances.
.. code:: python
import logging
from applicationinsights.logging import enable
... | [
"Enables",
"the",
"Application",
"Insights",
"logging",
"handler",
"for",
"the",
"root",
"logger",
"for",
"the",
"supplied",
"instrumentation",
"key",
".",
"Multiple",
"calls",
"to",
"this",
"function",
"with",
"different",
"instrumentation",
"keys",
"result",
"in... | 8452ab7126f9bb6964637d4aa1258c2af17563d6 | https://github.com/Microsoft/ApplicationInsights-Python/blob/8452ab7126f9bb6964637d4aa1258c2af17563d6/applicationinsights/logging/LoggingHandler.py#L10-L61 | train |
Microsoft/ApplicationInsights-Python | applicationinsights/channel/AsynchronousSender.py | AsynchronousSender.start | def start(self):
"""Starts a new sender thread if none is not already there
"""
with self._lock_send_remaining_time:
if self._send_remaining_time <= 0.0:
local_send_interval = self._send_interval
if self._send_interval < 0.1:
local_... | python | def start(self):
"""Starts a new sender thread if none is not already there
"""
with self._lock_send_remaining_time:
if self._send_remaining_time <= 0.0:
local_send_interval = self._send_interval
if self._send_interval < 0.1:
local_... | [
"def",
"start",
"(",
"self",
")",
":",
"with",
"self",
".",
"_lock_send_remaining_time",
":",
"if",
"self",
".",
"_send_remaining_time",
"<=",
"0.0",
":",
"local_send_interval",
"=",
"self",
".",
"_send_interval",
"if",
"self",
".",
"_send_interval",
"<",
"0.1... | Starts a new sender thread if none is not already there | [
"Starts",
"a",
"new",
"sender",
"thread",
"if",
"none",
"is",
"not",
"already",
"there"
] | 8452ab7126f9bb6964637d4aa1258c2af17563d6 | https://github.com/Microsoft/ApplicationInsights-Python/blob/8452ab7126f9bb6964637d4aa1258c2af17563d6/applicationinsights/channel/AsynchronousSender.py#L76-L89 | train |
Microsoft/ApplicationInsights-Python | applicationinsights/channel/TelemetryContext.py | device_initialize | def device_initialize(self):
""" The device initializer used to assign special properties to all device context objects"""
existing_device_initialize(self)
self.type = 'Other'
self.id = platform.node()
self.os_version = platform.version()
self.locale = locale.getdefaultlocale()[0] | python | def device_initialize(self):
""" The device initializer used to assign special properties to all device context objects"""
existing_device_initialize(self)
self.type = 'Other'
self.id = platform.node()
self.os_version = platform.version()
self.locale = locale.getdefaultlocale()[0] | [
"def",
"device_initialize",
"(",
"self",
")",
":",
"existing_device_initialize",
"(",
"self",
")",
"self",
".",
"type",
"=",
"'Other'",
"self",
".",
"id",
"=",
"platform",
".",
"node",
"(",
")",
"self",
".",
"os_version",
"=",
"platform",
".",
"version",
... | The device initializer used to assign special properties to all device context objects | [
"The",
"device",
"initializer",
"used",
"to",
"assign",
"special",
"properties",
"to",
"all",
"device",
"context",
"objects"
] | 8452ab7126f9bb6964637d4aa1258c2af17563d6 | https://github.com/Microsoft/ApplicationInsights-Python/blob/8452ab7126f9bb6964637d4aa1258c2af17563d6/applicationinsights/channel/TelemetryContext.py#L8-L14 | train |
hyperledger/indy-crypto | wrappers/python/indy_crypto/bls.py | Bls.sign | def sign(message: bytes, sign_key: SignKey) -> Signature:
"""
Signs the message and returns signature.
:param: message - Message to sign
:param: sign_key - Sign key
:return: Signature
"""
logger = logging.getLogger(__name__)
logger.debug("Bls::sign: >>> ... | python | def sign(message: bytes, sign_key: SignKey) -> Signature:
"""
Signs the message and returns signature.
:param: message - Message to sign
:param: sign_key - Sign key
:return: Signature
"""
logger = logging.getLogger(__name__)
logger.debug("Bls::sign: >>> ... | [
"def",
"sign",
"(",
"message",
":",
"bytes",
",",
"sign_key",
":",
"SignKey",
")",
"->",
"Signature",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"logger",
".",
"debug",
"(",
"\"Bls::sign: >>> message: %r, sign_key: %r\"",
",",
"mess... | Signs the message and returns signature.
:param: message - Message to sign
:param: sign_key - Sign key
:return: Signature | [
"Signs",
"the",
"message",
"and",
"returns",
"signature",
"."
] | 1675e29a2a5949b44899553d3d128335cf7a61b3 | https://github.com/hyperledger/indy-crypto/blob/1675e29a2a5949b44899553d3d128335cf7a61b3/wrappers/python/indy_crypto/bls.py#L229-L250 | train |
hyperledger/indy-crypto | wrappers/python/indy_crypto/bls.py | Bls.verify | def verify(signature: Signature, message: bytes, ver_key: VerKey, gen: Generator) -> bool:
"""
Verifies the message signature and returns true - if signature valid or false otherwise.
:param: signature - Signature to verify
:param: message - Message to verify
:param: ver_key - V... | python | def verify(signature: Signature, message: bytes, ver_key: VerKey, gen: Generator) -> bool:
"""
Verifies the message signature and returns true - if signature valid or false otherwise.
:param: signature - Signature to verify
:param: message - Message to verify
:param: ver_key - V... | [
"def",
"verify",
"(",
"signature",
":",
"Signature",
",",
"message",
":",
"bytes",
",",
"ver_key",
":",
"VerKey",
",",
"gen",
":",
"Generator",
")",
"->",
"bool",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"logger",
".",
"de... | Verifies the message signature and returns true - if signature valid or false otherwise.
:param: signature - Signature to verify
:param: message - Message to verify
:param: ver_key - Verification key
:param: gen - Generator point
:return: true if signature valid | [
"Verifies",
"the",
"message",
"signature",
"and",
"returns",
"true",
"-",
"if",
"signature",
"valid",
"or",
"false",
"otherwise",
"."
] | 1675e29a2a5949b44899553d3d128335cf7a61b3 | https://github.com/hyperledger/indy-crypto/blob/1675e29a2a5949b44899553d3d128335cf7a61b3/wrappers/python/indy_crypto/bls.py#L253-L278 | train |
hyperledger/indy-crypto | wrappers/python/indy_crypto/bls.py | Bls.verify_pop | def verify_pop(pop: ProofOfPossession, ver_key: VerKey, gen: Generator) -> bool:
"""
Verifies the proof of possession and returns true - if signature valid or false otherwise.
:param: pop - Proof of possession
:param: ver_key - Verification key
:param: gen - Generator point
... | python | def verify_pop(pop: ProofOfPossession, ver_key: VerKey, gen: Generator) -> bool:
"""
Verifies the proof of possession and returns true - if signature valid or false otherwise.
:param: pop - Proof of possession
:param: ver_key - Verification key
:param: gen - Generator point
... | [
"def",
"verify_pop",
"(",
"pop",
":",
"ProofOfPossession",
",",
"ver_key",
":",
"VerKey",
",",
"gen",
":",
"Generator",
")",
"->",
"bool",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"logger",
".",
"debug",
"(",
"\"Bls::verify_po... | Verifies the proof of possession and returns true - if signature valid or false otherwise.
:param: pop - Proof of possession
:param: ver_key - Verification key
:param: gen - Generator point
:return: true if signature valid | [
"Verifies",
"the",
"proof",
"of",
"possession",
"and",
"returns",
"true",
"-",
"if",
"signature",
"valid",
"or",
"false",
"otherwise",
"."
] | 1675e29a2a5949b44899553d3d128335cf7a61b3 | https://github.com/hyperledger/indy-crypto/blob/1675e29a2a5949b44899553d3d128335cf7a61b3/wrappers/python/indy_crypto/bls.py#L281-L306 | train |
hyperledger/indy-crypto | wrappers/python/indy_crypto/bls.py | Bls.verify_multi_sig | def verify_multi_sig(multi_sig: MultiSignature, message: bytes, ver_keys: [VerKey], gen: Generator) -> bool:
"""
Verifies the message multi signature and returns true - if signature valid or false otherwise.
:param: multi_sig - Multi signature to verify
:param: message - Message to veri... | python | def verify_multi_sig(multi_sig: MultiSignature, message: bytes, ver_keys: [VerKey], gen: Generator) -> bool:
"""
Verifies the message multi signature and returns true - if signature valid or false otherwise.
:param: multi_sig - Multi signature to verify
:param: message - Message to veri... | [
"def",
"verify_multi_sig",
"(",
"multi_sig",
":",
"MultiSignature",
",",
"message",
":",
"bytes",
",",
"ver_keys",
":",
"[",
"VerKey",
"]",
",",
"gen",
":",
"Generator",
")",
"->",
"bool",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
... | Verifies the message multi signature and returns true - if signature valid or false otherwise.
:param: multi_sig - Multi signature to verify
:param: message - Message to verify
:param: ver_keys - List of verification keys
:param: gen - Generator point
:return: true if multi sign... | [
"Verifies",
"the",
"message",
"multi",
"signature",
"and",
"returns",
"true",
"-",
"if",
"signature",
"valid",
"or",
"false",
"otherwise",
"."
] | 1675e29a2a5949b44899553d3d128335cf7a61b3 | https://github.com/hyperledger/indy-crypto/blob/1675e29a2a5949b44899553d3d128335cf7a61b3/wrappers/python/indy_crypto/bls.py#L309-L340 | train |
nephila/djangocms-blog | djangocms_blog/admin.py | PostAdmin.get_urls | def get_urls(self):
"""
Customize the modeladmin urls
"""
urls = [
url(r'^publish/([0-9]+)/$', self.admin_site.admin_view(self.publish_post),
name='djangocms_blog_publish_article'),
]
urls.extend(super(PostAdmin, self).get_urls())
retur... | python | def get_urls(self):
"""
Customize the modeladmin urls
"""
urls = [
url(r'^publish/([0-9]+)/$', self.admin_site.admin_view(self.publish_post),
name='djangocms_blog_publish_article'),
]
urls.extend(super(PostAdmin, self).get_urls())
retur... | [
"def",
"get_urls",
"(",
"self",
")",
":",
"urls",
"=",
"[",
"url",
"(",
"r'^publish/([0-9]+)/$'",
",",
"self",
".",
"admin_site",
".",
"admin_view",
"(",
"self",
".",
"publish_post",
")",
",",
"name",
"=",
"'djangocms_blog_publish_article'",
")",
",",
"]",
... | Customize the modeladmin urls | [
"Customize",
"the",
"modeladmin",
"urls"
] | 3fdfbd4ba48947df0ee4c6d42e3a1c812b6dd95d | https://github.com/nephila/djangocms-blog/blob/3fdfbd4ba48947df0ee4c6d42e3a1c812b6dd95d/djangocms_blog/admin.py#L224-L233 | train |
nephila/djangocms-blog | djangocms_blog/admin.py | PostAdmin.publish_post | def publish_post(self, request, pk):
"""
Admin view to publish a single post
:param request: request
:param pk: primary key of the post to publish
:return: Redirect to the post itself (if found) or fallback urls
"""
language = get_language_from_request(request, c... | python | def publish_post(self, request, pk):
"""
Admin view to publish a single post
:param request: request
:param pk: primary key of the post to publish
:return: Redirect to the post itself (if found) or fallback urls
"""
language = get_language_from_request(request, c... | [
"def",
"publish_post",
"(",
"self",
",",
"request",
",",
"pk",
")",
":",
"language",
"=",
"get_language_from_request",
"(",
"request",
",",
"check_path",
"=",
"True",
")",
"try",
":",
"post",
"=",
"Post",
".",
"objects",
".",
"get",
"(",
"pk",
"=",
"in... | Admin view to publish a single post
:param request: request
:param pk: primary key of the post to publish
:return: Redirect to the post itself (if found) or fallback urls | [
"Admin",
"view",
"to",
"publish",
"a",
"single",
"post"
] | 3fdfbd4ba48947df0ee4c6d42e3a1c812b6dd95d | https://github.com/nephila/djangocms-blog/blob/3fdfbd4ba48947df0ee4c6d42e3a1c812b6dd95d/djangocms_blog/admin.py#L247-L265 | train |
nephila/djangocms-blog | djangocms_blog/admin.py | PostAdmin.has_restricted_sites | def has_restricted_sites(self, request):
"""
Whether the current user has permission on one site only
:param request: current request
:return: boolean: user has permission on only one site
"""
sites = self.get_restricted_sites(request)
return sites and sites.coun... | python | def has_restricted_sites(self, request):
"""
Whether the current user has permission on one site only
:param request: current request
:return: boolean: user has permission on only one site
"""
sites = self.get_restricted_sites(request)
return sites and sites.coun... | [
"def",
"has_restricted_sites",
"(",
"self",
",",
"request",
")",
":",
"sites",
"=",
"self",
".",
"get_restricted_sites",
"(",
"request",
")",
"return",
"sites",
"and",
"sites",
".",
"count",
"(",
")",
"==",
"1"
] | Whether the current user has permission on one site only
:param request: current request
:return: boolean: user has permission on only one site | [
"Whether",
"the",
"current",
"user",
"has",
"permission",
"on",
"one",
"site",
"only"
] | 3fdfbd4ba48947df0ee4c6d42e3a1c812b6dd95d | https://github.com/nephila/djangocms-blog/blob/3fdfbd4ba48947df0ee4c6d42e3a1c812b6dd95d/djangocms_blog/admin.py#L267-L275 | train |
nephila/djangocms-blog | djangocms_blog/admin.py | PostAdmin.get_restricted_sites | def get_restricted_sites(self, request):
"""
The sites on which the user has permission on.
To return the permissions, the method check for the ``get_sites``
method on the user instance (e.g.: ``return request.user.get_sites()``)
which must return the queryset of enabled sites.
... | python | def get_restricted_sites(self, request):
"""
The sites on which the user has permission on.
To return the permissions, the method check for the ``get_sites``
method on the user instance (e.g.: ``return request.user.get_sites()``)
which must return the queryset of enabled sites.
... | [
"def",
"get_restricted_sites",
"(",
"self",
",",
"request",
")",
":",
"try",
":",
"return",
"request",
".",
"user",
".",
"get_sites",
"(",
")",
"except",
"AttributeError",
":",
"# pragma: no cover",
"return",
"Site",
".",
"objects",
".",
"none",
"(",
")"
] | The sites on which the user has permission on.
To return the permissions, the method check for the ``get_sites``
method on the user instance (e.g.: ``return request.user.get_sites()``)
which must return the queryset of enabled sites.
If the attribute does not exists, the user is conside... | [
"The",
"sites",
"on",
"which",
"the",
"user",
"has",
"permission",
"on",
"."
] | 3fdfbd4ba48947df0ee4c6d42e3a1c812b6dd95d | https://github.com/nephila/djangocms-blog/blob/3fdfbd4ba48947df0ee4c6d42e3a1c812b6dd95d/djangocms_blog/admin.py#L277-L293 | train |
nephila/djangocms-blog | djangocms_blog/admin.py | PostAdmin.get_fieldsets | def get_fieldsets(self, request, obj=None):
"""
Customize the fieldsets according to the app settings
:param request: request
:param obj: post
:return: fieldsets configuration
"""
app_config_default = self._app_config_select(request, obj)
if app_config_de... | python | def get_fieldsets(self, request, obj=None):
"""
Customize the fieldsets according to the app settings
:param request: request
:param obj: post
:return: fieldsets configuration
"""
app_config_default = self._app_config_select(request, obj)
if app_config_de... | [
"def",
"get_fieldsets",
"(",
"self",
",",
"request",
",",
"obj",
"=",
"None",
")",
":",
"app_config_default",
"=",
"self",
".",
"_app_config_select",
"(",
"request",
",",
"obj",
")",
"if",
"app_config_default",
"is",
"None",
"and",
"request",
".",
"method",
... | Customize the fieldsets according to the app settings
:param request: request
:param obj: post
:return: fieldsets configuration | [
"Customize",
"the",
"fieldsets",
"according",
"to",
"the",
"app",
"settings"
] | 3fdfbd4ba48947df0ee4c6d42e3a1c812b6dd95d | https://github.com/nephila/djangocms-blog/blob/3fdfbd4ba48947df0ee4c6d42e3a1c812b6dd95d/djangocms_blog/admin.py#L302-L342 | train |
nephila/djangocms-blog | djangocms_blog/admin.py | BlogConfigAdmin.save_model | def save_model(self, request, obj, form, change):
"""
Clear menu cache when changing menu structure
"""
if 'config.menu_structure' in form.changed_data:
from menus.menu_pool import menu_pool
menu_pool.clear(all=True)
return super(BlogConfigAdmin, self).sav... | python | def save_model(self, request, obj, form, change):
"""
Clear menu cache when changing menu structure
"""
if 'config.menu_structure' in form.changed_data:
from menus.menu_pool import menu_pool
menu_pool.clear(all=True)
return super(BlogConfigAdmin, self).sav... | [
"def",
"save_model",
"(",
"self",
",",
"request",
",",
"obj",
",",
"form",
",",
"change",
")",
":",
"if",
"'config.menu_structure'",
"in",
"form",
".",
"changed_data",
":",
"from",
"menus",
".",
"menu_pool",
"import",
"menu_pool",
"menu_pool",
".",
"clear",
... | Clear menu cache when changing menu structure | [
"Clear",
"menu",
"cache",
"when",
"changing",
"menu",
"structure"
] | 3fdfbd4ba48947df0ee4c6d42e3a1c812b6dd95d | https://github.com/nephila/djangocms-blog/blob/3fdfbd4ba48947df0ee4c6d42e3a1c812b6dd95d/djangocms_blog/admin.py#L453-L460 | train |
nephila/djangocms-blog | djangocms_blog/cms_wizards.py | PostWizardForm.clean_slug | def clean_slug(self):
"""
Generate a valid slug, in case the given one is taken
"""
source = self.cleaned_data.get('slug', '')
lang_choice = self.language_code
if not source:
source = slugify(self.cleaned_data.get('title', ''))
qs = Post._default_manag... | python | def clean_slug(self):
"""
Generate a valid slug, in case the given one is taken
"""
source = self.cleaned_data.get('slug', '')
lang_choice = self.language_code
if not source:
source = slugify(self.cleaned_data.get('title', ''))
qs = Post._default_manag... | [
"def",
"clean_slug",
"(",
"self",
")",
":",
"source",
"=",
"self",
".",
"cleaned_data",
".",
"get",
"(",
"'slug'",
",",
"''",
")",
"lang_choice",
"=",
"self",
".",
"language_code",
"if",
"not",
"source",
":",
"source",
"=",
"slugify",
"(",
"self",
".",... | Generate a valid slug, in case the given one is taken | [
"Generate",
"a",
"valid",
"slug",
"in",
"case",
"the",
"given",
"one",
"is",
"taken"
] | 3fdfbd4ba48947df0ee4c6d42e3a1c812b6dd95d | https://github.com/nephila/djangocms-blog/blob/3fdfbd4ba48947df0ee4c6d42e3a1c812b6dd95d/djangocms_blog/cms_wizards.py#L55-L70 | train |
nephila/djangocms-blog | djangocms_blog/managers.py | TaggedFilterItem.tagged | def tagged(self, other_model=None, queryset=None):
"""
Restituisce una queryset di elementi del model taggati,
o con gli stessi tag di un model o un queryset
"""
tags = self._taglist(other_model, queryset)
return self.get_queryset().filter(tags__in=tags).distinct() | python | def tagged(self, other_model=None, queryset=None):
"""
Restituisce una queryset di elementi del model taggati,
o con gli stessi tag di un model o un queryset
"""
tags = self._taglist(other_model, queryset)
return self.get_queryset().filter(tags__in=tags).distinct() | [
"def",
"tagged",
"(",
"self",
",",
"other_model",
"=",
"None",
",",
"queryset",
"=",
"None",
")",
":",
"tags",
"=",
"self",
".",
"_taglist",
"(",
"other_model",
",",
"queryset",
")",
"return",
"self",
".",
"get_queryset",
"(",
")",
".",
"filter",
"(",
... | Restituisce una queryset di elementi del model taggati,
o con gli stessi tag di un model o un queryset | [
"Restituisce",
"una",
"queryset",
"di",
"elementi",
"del",
"model",
"taggati",
"o",
"con",
"gli",
"stessi",
"tag",
"di",
"un",
"model",
"o",
"un",
"queryset"
] | 3fdfbd4ba48947df0ee4c6d42e3a1c812b6dd95d | https://github.com/nephila/djangocms-blog/blob/3fdfbd4ba48947df0ee4c6d42e3a1c812b6dd95d/djangocms_blog/managers.py#L16-L22 | train |
nephila/djangocms-blog | djangocms_blog/managers.py | TaggedFilterItem._taglist | def _taglist(self, other_model=None, queryset=None):
"""
Restituisce una lista di id di tag comuni al model corrente e al model
o queryset passati come argomento
"""
from taggit.models import TaggedItem
filter = None
if queryset is not None:
filter = s... | python | def _taglist(self, other_model=None, queryset=None):
"""
Restituisce una lista di id di tag comuni al model corrente e al model
o queryset passati come argomento
"""
from taggit.models import TaggedItem
filter = None
if queryset is not None:
filter = s... | [
"def",
"_taglist",
"(",
"self",
",",
"other_model",
"=",
"None",
",",
"queryset",
"=",
"None",
")",
":",
"from",
"taggit",
".",
"models",
"import",
"TaggedItem",
"filter",
"=",
"None",
"if",
"queryset",
"is",
"not",
"None",
":",
"filter",
"=",
"set",
"... | Restituisce una lista di id di tag comuni al model corrente e al model
o queryset passati come argomento | [
"Restituisce",
"una",
"lista",
"di",
"id",
"di",
"tag",
"comuni",
"al",
"model",
"corrente",
"e",
"al",
"model",
"o",
"queryset",
"passati",
"come",
"argomento"
] | 3fdfbd4ba48947df0ee4c6d42e3a1c812b6dd95d | https://github.com/nephila/djangocms-blog/blob/3fdfbd4ba48947df0ee4c6d42e3a1c812b6dd95d/djangocms_blog/managers.py#L24-L45 | train |
nephila/djangocms-blog | djangocms_blog/managers.py | TaggedFilterItem.tag_list | def tag_list(self, other_model=None, queryset=None):
"""
Restituisce un queryset di tag comuni al model corrente e
al model o queryset passati come argomento
"""
from taggit.models import Tag
return Tag.objects.filter(id__in=self._taglist(other_model, queryset)) | python | def tag_list(self, other_model=None, queryset=None):
"""
Restituisce un queryset di tag comuni al model corrente e
al model o queryset passati come argomento
"""
from taggit.models import Tag
return Tag.objects.filter(id__in=self._taglist(other_model, queryset)) | [
"def",
"tag_list",
"(",
"self",
",",
"other_model",
"=",
"None",
",",
"queryset",
"=",
"None",
")",
":",
"from",
"taggit",
".",
"models",
"import",
"Tag",
"return",
"Tag",
".",
"objects",
".",
"filter",
"(",
"id__in",
"=",
"self",
".",
"_taglist",
"(",... | Restituisce un queryset di tag comuni al model corrente e
al model o queryset passati come argomento | [
"Restituisce",
"un",
"queryset",
"di",
"tag",
"comuni",
"al",
"model",
"corrente",
"e",
"al",
"model",
"o",
"queryset",
"passati",
"come",
"argomento"
] | 3fdfbd4ba48947df0ee4c6d42e3a1c812b6dd95d | https://github.com/nephila/djangocms-blog/blob/3fdfbd4ba48947df0ee4c6d42e3a1c812b6dd95d/djangocms_blog/managers.py#L47-L53 | train |
nephila/djangocms-blog | djangocms_blog/liveblog/consumers.py | liveblog_connect | def liveblog_connect(message, apphook, lang, post):
"""
Connect users to the group of the given post according to the given language
Return with an error message if a post cannot be found
:param message: channel connect message
:param apphook: apphook config namespace
:param lang: language
... | python | def liveblog_connect(message, apphook, lang, post):
"""
Connect users to the group of the given post according to the given language
Return with an error message if a post cannot be found
:param message: channel connect message
:param apphook: apphook config namespace
:param lang: language
... | [
"def",
"liveblog_connect",
"(",
"message",
",",
"apphook",
",",
"lang",
",",
"post",
")",
":",
"try",
":",
"post",
"=",
"Post",
".",
"objects",
".",
"namespace",
"(",
"apphook",
")",
".",
"language",
"(",
"lang",
")",
".",
"active_translations",
"(",
"... | Connect users to the group of the given post according to the given language
Return with an error message if a post cannot be found
:param message: channel connect message
:param apphook: apphook config namespace
:param lang: language
:param post: post slug | [
"Connect",
"users",
"to",
"the",
"group",
"of",
"the",
"given",
"post",
"according",
"to",
"the",
"given",
"language"
] | 3fdfbd4ba48947df0ee4c6d42e3a1c812b6dd95d | https://github.com/nephila/djangocms-blog/blob/3fdfbd4ba48947df0ee4c6d42e3a1c812b6dd95d/djangocms_blog/liveblog/consumers.py#L11-L30 | train |
nephila/djangocms-blog | djangocms_blog/liveblog/consumers.py | liveblog_disconnect | def liveblog_disconnect(message, apphook, lang, post):
"""
Disconnect users to the group of the given post according to the given language
Return with an error message if a post cannot be found
:param message: channel connect message
:param apphook: apphook config namespace
:param lang: langua... | python | def liveblog_disconnect(message, apphook, lang, post):
"""
Disconnect users to the group of the given post according to the given language
Return with an error message if a post cannot be found
:param message: channel connect message
:param apphook: apphook config namespace
:param lang: langua... | [
"def",
"liveblog_disconnect",
"(",
"message",
",",
"apphook",
",",
"lang",
",",
"post",
")",
":",
"try",
":",
"post",
"=",
"Post",
".",
"objects",
".",
"namespace",
"(",
"apphook",
")",
".",
"language",
"(",
"lang",
")",
".",
"active_translations",
"(",
... | Disconnect users to the group of the given post according to the given language
Return with an error message if a post cannot be found
:param message: channel connect message
:param apphook: apphook config namespace
:param lang: language
:param post: post slug | [
"Disconnect",
"users",
"to",
"the",
"group",
"of",
"the",
"given",
"post",
"according",
"to",
"the",
"given",
"language"
] | 3fdfbd4ba48947df0ee4c6d42e3a1c812b6dd95d | https://github.com/nephila/djangocms-blog/blob/3fdfbd4ba48947df0ee4c6d42e3a1c812b6dd95d/djangocms_blog/liveblog/consumers.py#L33-L51 | train |
tchellomello/python-amcrest | src/amcrest/video.py | Video.video_in_option | def video_in_option(self, param, profile='Day'):
"""
Return video input option.
Params:
param - parameter, such as 'DayNightColor'
profile - 'Day', 'Night' or 'Normal'
"""
if profile == 'Day':
field = param
else:
field = '{... | python | def video_in_option(self, param, profile='Day'):
"""
Return video input option.
Params:
param - parameter, such as 'DayNightColor'
profile - 'Day', 'Night' or 'Normal'
"""
if profile == 'Day':
field = param
else:
field = '{... | [
"def",
"video_in_option",
"(",
"self",
",",
"param",
",",
"profile",
"=",
"'Day'",
")",
":",
"if",
"profile",
"==",
"'Day'",
":",
"field",
"=",
"param",
"else",
":",
"field",
"=",
"'{}Options.{}'",
".",
"format",
"(",
"profile",
",",
"param",
")",
"ret... | Return video input option.
Params:
param - parameter, such as 'DayNightColor'
profile - 'Day', 'Night' or 'Normal' | [
"Return",
"video",
"input",
"option",
"."
] | ed842139e234de2eaf6ee8fb480214711cde1249 | https://github.com/tchellomello/python-amcrest/blob/ed842139e234de2eaf6ee8fb480214711cde1249/src/amcrest/video.py#L132-L146 | train |
tchellomello/python-amcrest | src/amcrest/http.py | Http._generate_token | def _generate_token(self):
"""Create authentation to use with requests."""
session = self.get_session()
url = self.__base_url('magicBox.cgi?action=getMachineName')
try:
# try old basic method
auth = requests.auth.HTTPBasicAuth(self._user, self._password)
... | python | def _generate_token(self):
"""Create authentation to use with requests."""
session = self.get_session()
url = self.__base_url('magicBox.cgi?action=getMachineName')
try:
# try old basic method
auth = requests.auth.HTTPBasicAuth(self._user, self._password)
... | [
"def",
"_generate_token",
"(",
"self",
")",
":",
"session",
"=",
"self",
".",
"get_session",
"(",
")",
"url",
"=",
"self",
".",
"__base_url",
"(",
"'magicBox.cgi?action=getMachineName'",
")",
"try",
":",
"# try old basic method",
"auth",
"=",
"requests",
".",
... | Create authentation to use with requests. | [
"Create",
"authentation",
"to",
"use",
"with",
"requests",
"."
] | ed842139e234de2eaf6ee8fb480214711cde1249 | https://github.com/tchellomello/python-amcrest/blob/ed842139e234de2eaf6ee8fb480214711cde1249/src/amcrest/http.py#L73-L99 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.