sequence stringlengths 492 15.9k | code stringlengths 75 8.58k |
|---|---|
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 23; 2, function_name:qteReplaceAppletInLayout; 3, parameters; 3, 4; 3, 5; 3, 11; 3, 18; 4, identifier:self; 5, typed_parameter; 5, 6; 5, 7; 6, identifier:newApplet; 7, type; 7, 8; 8, tuple; 8, 9; 8, 10; 9, identifier:QtmacsApplet; 10, identifier:str; 11, typed_def... | def qteReplaceAppletInLayout(self, newApplet: (QtmacsApplet, str),
oldApplet: (QtmacsApplet, str)=None,
windowObj: QtmacsWindow=None):
if isinstance(oldApplet, str):
oldAppObj = self.qteGetAppletHandle(oldApplet)
else:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:qteRemoveAppletFromLayout; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, typed_parameter; 5, 6; 5, 7; 6, identifier:applet; 7, type; 7, 8; 8, tuple; 8, 9; 8, 10; 9, identifier:QtmacsApplet; 10, identifier:str; 11, block; 11, 12; 11, 34; 11... | def qteRemoveAppletFromLayout(self, applet: (QtmacsApplet, str)):
if isinstance(applet, str):
appletObj = self.qteGetAppletHandle(applet)
else:
appletObj = applet
for window in self._qteWindowList:
split = self._qteFindAppletInSplitter(
appletO... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:qteKillApplet; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, typed_parameter; 5, 6; 5, 7; 6, identifier:appletID; 7, type; 7, 8; 8, identifier:str; 9, block; 9, 10; 9, 24; 9, 49; 9, 64; 9, 70; 9, 78; 9, 96; 9, 122; 9, 135; 9, 149; 9, 158; 9... | def qteKillApplet(self, appletID: str):
ID_list = [_.qteAppletID() for _ in self._qteAppletList]
if appletID not in ID_list:
return
else:
idx = ID_list.index(appletID)
appObj = self._qteAppletList[idx]
if self.qteIsMiniApplet(appObj):
self.... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:qteRunHook; 3, parameters; 3, 4; 3, 5; 3, 9; 4, identifier:self; 5, typed_parameter; 5, 6; 5, 7; 6, identifier:hookName; 7, type; 7, 8; 8, identifier:str; 9, typed_default_parameter; 9, 10; 9, 11; 9, 13; 10, identifier:msgObj; 11, type; 11, 12... | def qteRunHook(self, hookName: str, msgObj: QtmacsMessage=None):
reg = self._qteRegistryHooks
if hookName not in reg:
return
if msgObj is None:
msgObj = QtmacsMessage()
msgObj.setHookName(hookName)
for fun in reg[hookName]:
try:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:qteMacroNameMangling; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:macroCls; 6, block; 6, 7; 6, 20; 6, 35; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:macroName; 10, call; 10, 11; 10, 14; 11, attribu... | def qteMacroNameMangling(self, macroCls):
macroName = re.sub(r"([A-Z])", r'-\1', macroCls.__name__)
if macroName[0] == '-':
macroName = macroName[1:]
return macroName.lower() |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:qteRegisterMacro; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 11; 4, identifier:self; 5, identifier:macroCls; 6, typed_default_parameter; 6, 7; 6, 8; 6, 10; 7, identifier:replaceMacro; 8, type; 8, 9; 9, identifier:bool; 10, False; 11, typed_default_pa... | def qteRegisterMacro(self, macroCls, replaceMacro: bool=False,
macroName: str=None):
if not issubclass(macroCls, QtmacsMacro):
args = ('macroCls', 'class QtmacsMacro', inspect.stack()[0][3])
raise QtmacsArgumentError(*args)
try:
macroObj = mac... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:qteGetMacroObject; 3, parameters; 3, 4; 3, 5; 3, 9; 4, identifier:self; 5, typed_parameter; 5, 6; 5, 7; 6, identifier:macroName; 7, type; 7, 8; 8, identifier:str; 9, typed_parameter; 9, 10; 9, 11; 10, identifier:widgetObj; 11, type; 11, 12; 12... | def qteGetMacroObject(self, macroName: str, widgetObj: QtGui.QWidget):
if hasattr(widgetObj, '_qteAdmin'):
app_signature = widgetObj._qteAdmin.appletSignature
wid_signature = widgetObj._qteAdmin.widgetSignature
if app_signature is None:
msg = 'Applet has no si... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:qteGetAllMacroNames; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, typed_default_parameter; 5, 6; 5, 7; 5, 11; 6, identifier:widgetObj; 7, type; 7, 8; 8, attribute; 8, 9; 8, 10; 9, identifier:QtGui; 10, identifier:QWidget; 11, None; 12, bl... | def qteGetAllMacroNames(self, widgetObj: QtGui.QWidget=None):
macro_list = tuple(self._qteRegistryMacros.keys())
macro_list = [_[0] for _ in macro_list]
macro_list = tuple(set(macro_list))
if widgetObj is None:
return macro_list
else:
macro_list = [self.qt... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:qteBindKeyGlobal; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:keysequence; 6, typed_parameter; 6, 7; 6, 8; 7, identifier:macroName; 8, type; 8, 9; 9, identifier:str; 10, block; 10, 11; 10, 18; 10, 54; 10, 64; 10, 79; 11,... | def qteBindKeyGlobal(self, keysequence, macroName: str):
keysequence = QtmacsKeysequence(keysequence)
if not self.qteIsMacroRegistered(macroName):
msg = 'Cannot globally bind key to unknown macro <b>{}</b>.'
msg = msg.format(macroName)
self.qteLogger.error(msg, stack_... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:qteRegisterApplet; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:cls; 6, typed_default_parameter; 6, 7; 6, 8; 6, 10; 7, identifier:replaceApplet; 8, type; 8, 9; 9, identifier:bool; 10, False; 11, block; 11, 12; 11, 41; 11,... | def qteRegisterApplet(self, cls, replaceApplet: bool=False):
if not issubclass(cls, QtmacsApplet):
args = ('cls', 'class QtmacsApplet', inspect.stack()[0][3])
raise QtmacsArgumentError(*args)
class_name = cls.__name__
if class_name in self._qteRegistryApplets:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:start; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, dictionary_splat_pattern; 5, 6; 6, identifier:kwargs; 7, block; 7, 8; 7, 12; 7, 16; 7, 23; 7, 119; 7, 125; 7, 130; 7, 136; 7, 195; 7, 259; 8, expression_statement; 8, 9; 9, assignment; 9,... | def start(self, **kwargs):
ts = {}
ret = {}
info_parts = {'info', 'get-value', 'get_value'}
for cmd in self.commands:
parser_cmd = self.parser_commands.get(cmd, cmd)
if parser_cmd in kwargs or cmd in kwargs:
kws = kwargs.get(cmd, kwargs.get(parser_... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 26; 2, function_name:app_main; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:experiment; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:last; 10, False; 11, defaul... | def app_main(self, experiment=None, last=False, new=False,
verbose=False, verbosity_level=None, no_modification=False,
match=False):
if match:
patt = re.compile(experiment)
matches = list(filter(patt.search, self.config.experiments))
if len(m... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 28; 2, function_name:configure; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:global_config; 7, False; 8, default_parameter; 8, 9; 8, 10; 9, identifier:project_config;... | def configure(self, global_config=False, project_config=False, ifile=None,
forcing=None, serial=False, nprocs=None, update_from=None,
**kwargs):
if global_config:
d = self.config.global_config
elif project_config:
self.app_main(**kwargs)
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:generate_basic_type_docs; 3, parameters; 3, 4; 3, 5; 4, identifier:fields; 5, identifier:existing_types; 6, block; 6, 7; 6, 133; 6, 137; 6, 325; 6, 347; 6, 354; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:raml_built... | def generate_basic_type_docs(fields, existing_types):
raml_built_in_types = {
"any": {
"parent": None,
},
"time-only": {
"parent": "any",
},
"datetime": {
"parent": "any",
"pale_children": ["timestamp"],
},
"date... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:generate_doc_dict; 3, parameters; 3, 4; 3, 5; 4, identifier:module; 5, identifier:user; 6, block; 6, 7; 6, 16; 6, 27; 6, 34; 6, 50; 6, 54; 6, 98; 6, 105; 6, 121; 7, import_from_statement; 7, 8; 7, 10; 7, 12; 7, 14; 8, dotted_name; 8, 9; 9, iden... | def generate_doc_dict(module, user):
from pale import extract_endpoints, extract_resources, is_pale_module
if not is_pale_module(module):
raise ValueError(
)
module_endpoints = extract_endpoints(module)
ep_doc = { ep._route_name: document_endpoint(ep) for ep \
in module_endpoints }
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:get_driver; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:desired_capabilities; 7, None; 8, block; 8, 9; 8, 15; 8, 26; 8, 33; 8, 41; 8, 45; 8, 333; 8, 371; 8, 380; 9, expression_statement; 9, 10;... | def get_driver(self, desired_capabilities=None):
override_caps = desired_capabilities or {}
desired_capabilities = \
self.config.make_selenium_desired_capabilities()
desired_capabilities.update(override_caps)
browser_string = self.config.browser
chromedriver_version =... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:load; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:typedef; 6, identifier:value; 7, dictionary_splat_pattern; 7, 8; 8, identifier:kwargs; 9, block; 9, 10; 10, try_statement; 10, 11; 10, 20; 10, 33; 11, block; 11, 12;... | def load(self, typedef, value, **kwargs):
try:
bound_type = self.bound_types[typedef]
except KeyError:
raise DeclareException(
"Can't load unknown type {}".format(typedef))
else:
return bound_type["load"](value, **kwargs) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:qteSetLexer; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:lexer; 6, block; 6, 7; 6, 31; 6, 37; 6, 60; 7, if_statement; 7, 8; 7, 22; 8, boolean_operator:and; 8, 9; 8, 13; 9, parenthesized_expression; 9, 10; 10, comparison_operato... | def qteSetLexer(self, lexer):
if (lexer is not None) and (not issubclass(lexer, Qsci.QsciLexer)):
QtmacsOtherError('lexer must be a class object and derived from'
' <b>QsciLexer</b>')
return
self.qteLastLexer = lexer
if lexer is None:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:get_function_args; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:func; 5, default_parameter; 5, 6; 5, 7; 6, identifier:no_self; 7, False; 8, default_parameter; 8, 9; 8, 10; 9, identifier:no_varargs; 10, False; 11, block; 11, 12; 11, 21; 11, 3... | def get_function_args(func, no_self=False, no_varargs=False):
par_dict = signature(func).parameters
pos = lambda x: x.kind == Parameter.VAR_POSITIONAL
kw = lambda x: x.kind == Parameter.VAR_KEYWORD
opts = ["", "*", "**"]
args = [
"{prefix}{arg}".format(prefix=opts[pos(value) + 2 * kw(value)]... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:_close_callable; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:node; 6, default_parameter; 6, 7; 6, 8; 7, identifier:force; 8, False; 9, block; 9, 10; 9, 22; 9, 30; 9, 31; 9, 35; 9, 81; 9, 90; 9, 95; 9, 96; 9, 100; 9, 221; ... | def _close_callable(self, node, force=False):
try:
lineno = node.lineno
except AttributeError:
return
if lineno <= self._processed_line:
return
# code =
name = ""
try:
name = (
node.name
if ha... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:qteRemoveKey; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, typed_parameter; 5, 6; 5, 7; 6, identifier:keysequence; 7, type; 7, 8; 8, identifier:QtmacsKeysequence; 9, block; 9, 10; 9, 14; 9, 18; 9, 26; 9, 47; 9, 68; 9, 77; 10, expression_st... | def qteRemoveKey(self, keysequence: QtmacsKeysequence):
keyMap = self
keyMapRef = keyMap
keysequence = keysequence.toQtKeylist()
for key in keysequence[:-1]:
if key not in keyMap:
return
keyMap = keyMap[key]
if keysequence[-1] not in keyMap... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:find_labels; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:key; 6, default_parameter; 6, 7; 6, 8; 7, identifier:find_in_name; 8, True; 9, default_parameter; 9, 10; 9, 11; 10, identifier:find_in_units; 11, False; 12, ... | def find_labels(self,key,find_in_name=True,find_in_units=False):
if type(key) is str:
found_keys = []
if key.startswith('~'):
for label_no,label in enumerate(self.labels):
if find_in_name and key[1:] in label.name:
found_keys.ap... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:_get_constrained_labels; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:remove_dimensions; 7, False; 8, dictionary_splat_pattern; 8, 9; 9, identifier:kwargs; 10, block; 10, 11; 10, 15; 10, ... | def _get_constrained_labels(self,remove_dimensions=False,**kwargs):
new_labels = []
for label_no,label in enumerate(self.labels):
new_label = LabelDimension(label)
remove = False
for k in kwargs:
if k == label.name:
new_label.max = ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:populate_field_values; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:data; 6, block; 6, 7; 6, 36; 6, 76; 6, 222; 7, if_statement; 7, 8; 7, 14; 8, not_operator; 8, 9; 9, attribute; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, ... | def populate_field_values(self, data):
if not self._meta.case_sensitive_fields:
data = {k.lower(): v for k, v in six.iteritems(data)}
if self._meta.match_fuzzy_keys:
data = {''.join(x for x in k if x in ALPHANUMERIC).lower(): v for k, v in six.iteritems(data)}
for field i... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:build_contact; 3, parameters; 3, 4; 3, 5; 4, identifier:request; 5, default_parameter; 5, 6; 5, 7; 6, identifier:slug; 7, string:""; 8, block; 8, 9; 8, 19; 8, 29; 8, 35; 8, 41; 8, 60; 8, 132; 8, 444; 9, expression_statement; 9, 10; 10, assignme... | def build_contact(request, slug=""):
controller = get_object_or_404(ContactFormController, slug=slug)
site = Site.objects.get_current()
UserModel = get_user_model()
user = request.user
form = ContactForm(request.POST or None, request.FILES or None, controller=controller)
if user.is_authent... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:stop_task; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:task_tag; 6, default_parameter; 6, 7; 6, 8; 7, identifier:stop_dependent; 8, True; 9, default_parameter; 9, 10; 9, 11; 10, identifier:stop_requirements; 11, Fa... | def stop_task(self, task_tag, stop_dependent=True, stop_requirements=False):
task = self.started_tasks(task_registry_id=task_tag)
if task is None:
return
def stop(task_to_stop):
if task_to_stop in self.__started:
if isinstance(task_to_stop, WStoppableTask) is True:
task_to_stop.stop()
self.__st... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:diffs2persistence; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:rev_docs; 5, default_parameter; 5, 6; 5, 7; 6, identifier:window_size; 7, integer:50; 8, default_parameter; 8, 9; 8, 10; 9, identifier:revert_radius; 10, integer:1... | def diffs2persistence(rev_docs, window_size=50, revert_radius=15, sunset=None,
verbose=False):
rev_docs = mwxml.utilities.normalize(rev_docs)
window_size = int(window_size)
revert_radius = int(revert_radius)
sunset = Timestamp(sunset) if sunset is not None \
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 26; 2, function_name:qteAddWidget; 3, parameters; 3, 4; 3, 5; 3, 11; 3, 16; 3, 21; 4, identifier:self; 5, typed_parameter; 5, 6; 5, 7; 6, identifier:widgetObj; 7, type; 7, 8; 8, attribute; 8, 9; 8, 10; 9, identifier:QtGui; 10, identifier:QWidget; 11, typed_default... | def qteAddWidget(self, widgetObj: QtGui.QWidget, isFocusable: bool=True,
widgetSignature: str=None, autoBind: bool=True):
widgetObj._qteAdmin = QtmacsAdminStructure(
self, isFocusable=isFocusable)
widgetObj._qteAdmin.appletID = self._qteAdmin.appletID
widgetObj._... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:qteSetWidgetFocusOrder; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, typed_parameter; 5, 6; 5, 7; 6, identifier:widList; 7, type; 7, 8; 8, identifier:tuple; 9, block; 9, 10; 9, 19; 9, 25; 9, 37; 9, 68; 9, 75; 9, 95; 9, 104; 9, 123; 9, 140;... | def qteSetWidgetFocusOrder(self, widList: tuple):
if len(widList) < 2:
return
self.qteAutoremoveDeletedWidgets()
widList = [_ for _ in widList if _ is not None]
for wid in widList:
if wid not in self._qteAdmin.widgetList:
msg = 'Cannot change focus... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 37; 2, function_name:qteNextWidget; 3, parameters; 3, 4; 3, 5; 3, 10; 3, 17; 3, 22; 3, 27; 3, 32; 4, identifier:self; 5, typed_default_parameter; 5, 6; 5, 7; 5, 9; 6, identifier:numSkip; 7, type; 7, 8; 8, identifier:int; 9, integer:1; 10, typed_default_parameter; ... | def qteNextWidget(self, numSkip: int=1, ofsWidget: QtGui.QWidget=None,
skipVisible: bool=False, skipInvisible: bool=True,
skipFocusable: bool=False,
skipUnfocusable: bool=True):
if not hasattr(ofsWidget, '_qteAdmin') and (ofsWidget is not None):
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:qteMakeWidgetActive; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, typed_parameter; 5, 6; 5, 7; 6, identifier:widgetObj; 7, type; 7, 8; 8, attribute; 8, 9; 8, 10; 9, identifier:QtGui; 10, identifier:QWidget; 11, block; 11, 12; 11, 24; 11, ... | def qteMakeWidgetActive(self, widgetObj: QtGui.QWidget):
if widgetObj is None:
self._qteActiveWidget = None
return
if qteGetAppletFromWidget(widgetObj) is not self:
msg = 'The specified widget is not inside the current applet.'
raise QtmacsOtherError(msg)
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 23; 2, function_name:make_result; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 3, 21; 4, identifier:self; 5, identifier:result_class; 6, default_parameter; 6, 7; 6, 8; 7, identifier:node; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:p... | def make_result(self, result_class, node=None, prev_node=None,
remember=True, key_chunks=None, notify=True, **kwargs):
def canonicalize(node, **kwargs):
return None if node is None else node.canonicalize(**kwargs)
index = self.index
result = result_class(canonical... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_get_class_frame_source; 3, parameters; 3, 4; 4, identifier:class_name; 5, block; 5, 6; 5, 181; 6, for_statement; 6, 7; 6, 8; 6, 13; 7, identifier:frame_info; 8, call; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:inspect; 11, identif... | def _get_class_frame_source(class_name):
for frame_info in inspect.stack():
try:
with open(frame_info[1]) as fp:
src = "".join(fp.readlines()[frame_info[2] - 1 :])
except IOError:
continue
if re.search(r"\bclass\b\s+\b{}\b".format(class_name), src):
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_create_typed_object_meta; 3, parameters; 3, 4; 4, identifier:get_fset; 5, block; 5, 6; 5, 45; 5, 282; 6, function_definition; 6, 7; 6, 8; 6, 12; 7, function_name:_get_fget; 8, parameters; 8, 9; 8, 10; 8, 11; 9, identifier:attr; 10, identifier:... | def _create_typed_object_meta(get_fset):
def _get_fget(attr, private_attr, type_):
def _fget(self):
try:
return getattr(self, private_attr)
except AttributeError:
raise AttributeError(
"'{}' object has no attribute '{}'".format(
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_build_module_db; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 16; 5, 72; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:tdict; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:collect... | def _build_module_db(self):
tdict = collections.defaultdict(lambda: [])
for callable_name, callable_dict in self._exh_obj.callables_db.items():
fname, line_no = callable_dict["code_id"]
cname = (
"{cls_name}.__init__".format(cls_name=callable_name)
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:merge; 3, parameters; 3, 4; 3, 5; 3, 7; 4, identifier:cls; 5, list_splat_pattern; 5, 6; 6, identifier:args; 7, dictionary_splat_pattern; 7, 8; 8, identifier:kwargs; 9, block; 9, 10; 9, 23; 9, 35; 9, 69; 9, 75; 9, 84; 9, 185; 10, expression_stat... | def merge(cls, *args, **kwargs):
newkeys = bool(kwargs.get('newkeys', False))
ignore = kwargs.get('ignore', list())
if len(args) < 1:
raise ValueError('no ents given to Ent.merge()')
elif not all(isinstance(s, Ent) for s in args):
raise ValueError('all positional ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:diff; 3, parameters; 3, 4; 3, 5; 3, 7; 4, identifier:cls; 5, list_splat_pattern; 5, 6; 6, identifier:args; 7, dictionary_splat_pattern; 7, 8; 8, identifier:kwargs; 9, block; 9, 10; 9, 23; 9, 35; 9, 69; 9, 75; 9, 81; 9, 206; 10, expression_state... | def diff(cls, *args, **kwargs):
newkeys = bool(kwargs.get('newkeys', False))
ignore = kwargs.get('ignore', list())
if len(args) < 2:
raise ValueError('less than two ents given to Ent.diff()')
elif not all(isinstance(s, Ent) for s in args):
raise ValueError('all po... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_sorted_keys_items; 3, parameters; 3, 4; 4, identifier:dobj; 5, block; 5, 6; 5, 17; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:keys; 9, call; 9, 10; 9, 11; 10, identifier:sorted; 11, argument_list; 11, 12; 12, call;... | def _sorted_keys_items(dobj):
keys = sorted(dobj.keys())
for key in keys:
yield key, dobj[key] |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:get_or_create_exh_obj; 3, parameters; 3, 4; 3, 7; 3, 10; 4, default_parameter; 4, 5; 4, 6; 5, identifier:full_cname; 6, False; 7, default_parameter; 7, 8; 7, 9; 8, identifier:exclude; 9, None; 10, default_parameter; 10, 11; 10, 12; 11, identif... | def get_or_create_exh_obj(full_cname=False, exclude=None, callables_fname=None):
r
if not hasattr(__builtin__, "_EXH"):
set_exh_obj(
ExHandle(
full_cname=full_cname, exclude=exclude, callables_fname=callables_fname
)
)
return get_exh_obj() |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_property_search; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:fobj; 6, block; 6, 7; 6, 19; 6, 30; 6, 41; 6, 64; 6, 75; 6, 90; 6, 109; 6, 113; 6, 202; 6, 211; 6, 224; 6, 283; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8... | def _property_search(self, fobj):
scontext = fobj.f_locals.get("self", None)
class_obj = scontext.__class__ if scontext is not None else None
if not class_obj:
del fobj, scontext, class_obj
return None
class_props = [
(member_name, member_obj)
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:_execute; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:request; 6, dictionary_splat_pattern; 6, 7; 7, identifier:kwargs; 8, block; 8, 9; 8, 317; 8, 326; 8, 354; 8, 360; 8, 411; 9, try_statement; 9, 10; 9, 117; 9, 177; 9, 2... | def _execute(self, request, **kwargs):
try:
self._create_context(request)
self._authenticate()
context = get_current_context()
self._parse_args()
if hasattr(self, '_before_handlers') and \
isinstance(self._before_handlers, (list, tu... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:add_entity_errors; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:property_name; 6, default_parameter; 6, 7; 6, 8; 7, identifier:direct_errors; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:schema_errors... | def add_entity_errors(
self,
property_name,
direct_errors=None,
schema_errors=None
):
if direct_errors is None and schema_errors is None:
return self
if direct_errors is not None:
if property_name not in self.errors:
self.errors... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:add_collection_errors; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:property_name; 6, default_parameter; 6, 7; 6, 8; 7, identifier:direct_errors; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:collectio... | def add_collection_errors(
self,
property_name,
direct_errors=None,
collection_errors=None
):
if direct_errors is None and collection_errors is None:
return self
if direct_errors is not None:
if type(direct_errors) is not list:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:merge_errors; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:errors_local; 6, identifier:errors_remote; 7, block; 7, 8; 7, 304; 8, for_statement; 8, 9; 8, 10; 8, 11; 9, identifier:prop; 10, identifier:errors_remote; 11, bloc... | def merge_errors(self, errors_local, errors_remote):
for prop in errors_remote:
if prop not in errors_local:
errors_local[prop] = errors_remote[prop]
continue
local = errors_local[prop]
local = local.errors if isinstance(local, Result) else loc... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:cursorPositionChangedEvent; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 14; 5, 22; 5, 30; 5, 41; 5, 48; 5, 59; 5, 84; 5, 92; 5, 103; 5, 161; 5, 179; 5, 188; 5, 196; 5, 202; 5, 210; 6, expression_statement; 6, 7; 7, assignment; 7... | def cursorPositionChangedEvent(self):
qteWidget = self.sender()
tc = qteWidget.textCursor()
origin = tc.position()
qteWidget.cursorPositionChanged.disconnect(
self.cursorPositionChangedEvent)
self.qteRemoveHighlighting(qteWidget)
qteWidget.cursorPositionChange... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:scenarios; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:generate_seed; 7, False; 8, block; 8, 9; 8, 16; 8, 28; 8, 75; 8, 79; 8, 83; 8, 142; 8, 157; 8, 186; 8, 190; 8, 254; 8, 262; 8, 270; 9, exp... | def scenarios(self, generate_seed=False):
seed = prime_numbers(1000)
sweeps_all = self.experiment["sweeps"].keys()
if "combinations" in self.experiment:
if isinstance(self.experiment["combinations"], list):
combinations_in_experiment = {" ": self.experiment["combinati... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:subdict_by_keys; 3, parameters; 3, 4; 3, 5; 4, identifier:dict_obj; 5, identifier:keys; 6, block; 6, 7; 7, return_statement; 7, 8; 8, dictionary_comprehension; 8, 9; 8, 14; 9, pair; 9, 10; 9, 11; 10, identifier:k; 11, subscript; 11, 12; 11, 13;... | def subdict_by_keys(dict_obj, keys):
return {k: dict_obj[k] for k in set(keys).intersection(dict_obj.keys())} |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:deep_merge_dict; 3, parameters; 3, 4; 3, 5; 4, identifier:base; 5, identifier:priority; 6, block; 6, 7; 6, 24; 6, 33; 6, 70; 7, if_statement; 7, 8; 7, 21; 8, boolean_operator:or; 8, 9; 8, 15; 9, not_operator; 9, 10; 10, call; 10, 11; 10, 12; 11... | def deep_merge_dict(base, priority):
if not isinstance(base, dict) or not isinstance(priority, dict):
return priority
result = copy.deepcopy(base)
for key in priority.keys():
if key in base:
result[key] = deep_merge_dict(base[key], priority[key])
else:
result[... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:norm_int_dict; 3, parameters; 3, 4; 4, identifier:int_dict; 5, block; 5, 6; 5, 14; 5, 25; 5, 39; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:norm_dict; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identi... | def norm_int_dict(int_dict):
norm_dict = int_dict.copy()
val_sum = sum(norm_dict.values())
for key in norm_dict:
norm_dict[key] = norm_dict[key] / val_sum
return norm_dict |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:sum_num_dicts; 3, parameters; 3, 4; 3, 5; 4, identifier:dicts; 5, default_parameter; 5, 6; 5, 7; 6, identifier:normalize; 7, False; 8, block; 8, 9; 8, 13; 8, 37; 8, 45; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identif... | def sum_num_dicts(dicts, normalize=False):
sum_dict = {}
for dicti in dicts:
for key in dicti:
sum_dict[key] = sum_dict.get(key, 0) + dicti[key]
if normalize:
return norm_int_dict(sum_dict)
return sum_dict |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:reverse_dict; 3, parameters; 3, 4; 4, identifier:dict_obj; 5, block; 5, 6; 5, 10; 5, 29; 5, 47; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:new_dict; 9, dictionary; 10, for_statement; 10, 11; 10, 12; 10, 13; 11, iden... | def reverse_dict(dict_obj):
new_dict = {}
for key in dict_obj:
add_to_dict_val_set(dict_obj=new_dict, key=dict_obj[key], val=key)
for key in new_dict:
new_dict[key] = sorted(new_dict[key], reverse=False)
return new_dict |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:flatten_dict; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:dict_obj; 5, default_parameter; 5, 6; 5, 7; 6, identifier:separator; 7, string:'.'; 8, default_parameter; 8, 9; 8, 10; 9, identifier:flatten_lists; 10, False; 11, block; 11, 12; 11, ... | def flatten_dict(dict_obj, separator='.', flatten_lists=False):
reducer = _get_key_reducer(separator)
flat = {}
def _flatten_key_val(key, val, parent):
flat_key = reducer(parent, key)
try:
_flatten(val, flat_key)
except TypeError:
flat[flat_key] = val
def ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:key_value_nested_generator; 3, parameters; 3, 4; 4, identifier:dict_obj; 5, block; 5, 6; 6, for_statement; 6, 7; 6, 10; 6, 15; 7, pattern_list; 7, 8; 7, 9; 8, identifier:key; 9, identifier:value; 10, call; 10, 11; 10, 14; 11, attribute; 11, 12;... | def key_value_nested_generator(dict_obj):
for key, value in dict_obj.items():
if isinstance(value, dict):
for key, value in key_value_nested_generator(value):
yield key, value
else:
yield key, value |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:key_tuple_value_nested_generator; 3, parameters; 3, 4; 4, identifier:dict_obj; 5, block; 5, 6; 6, for_statement; 6, 7; 6, 10; 6, 15; 7, pattern_list; 7, 8; 7, 9; 8, identifier:key; 9, identifier:value; 10, call; 10, 11; 10, 14; 11, attribute; 1... | def key_tuple_value_nested_generator(dict_obj):
for key, value in dict_obj.items():
if isinstance(value, dict):
for nested_key, value in key_tuple_value_nested_generator(value):
yield tuple([key]) + nested_key, value
else:
yield tuple([key]), value |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:release_lock; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:verbose; 7, identifier:VERBOSE; 8, default_parameter; 8, 9; 8, 10; 9, identifier:raiseError; 10, identifier:RAISE_ERROR; 11, blo... | def release_lock(self, verbose=VERBOSE, raiseError=RAISE_ERROR):
if not os.path.isfile(self.__lockPath):
released = True
code = 0
else:
try:
with open(self.__lockPath, 'rb') as fd:
lock = fd.readlines()
except Except... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:guess_codec; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:file; 5, default_parameter; 5, 6; 5, 7; 6, identifier:errors; 7, string:"strict"; 8, default_parameter; 8, 9; 8, 10; 9, identifier:require_char; 10, False; 11, block; 11, 12; 11, 19; ... | def guess_codec(file, errors="strict", require_char=False):
gedcom_char_to_codec = {
'ansel': 'gedcom',
}
bom_codec = check_bom(file)
bom_size = file.tell()
codec = bom_codec or 'gedcom'
while True:
line = file.readline()
if not line:
raise IOError("Unexpected... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:read_record; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:offset; 6, block; 6, 7; 6, 15; 6, 19; 6, 23; 6, 161; 6, 214; 7, expression_statement; 7, 8; 8, call; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:_log; 11, ide... | def read_record(self, offset):
_log.debug("in read_record(%s)", offset)
stack = []
reclevel = None
for gline in self.gedcom_lines(offset):
_log.debug(" read_record, gline: %s", gline)
level = gline.level
if reclevel is None:
reclevel... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_make_record; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:parent; 6, identifier:gline; 7, block; 7, 8; 7, 68; 7, 74; 7, 99; 7, 141; 7, 153; 8, if_statement; 8, 9; 8, 18; 9, boolean_operator:and; 9, 10; 9, 11; 10, identifi... | def _make_record(self, parent, gline):
if parent and gline.tag in ("CONT", "CONC"):
if parent.tag != "BLOB":
value = gline.value
if gline.tag == "CONT":
value = b"\n" + (value or b"")
if value is not None:
parent... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:parse; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:cls; 5, identifier:gvid; 6, default_parameter; 6, 7; 6, 8; 7, identifier:exception; 8, True; 9, block; 9, 10; 9, 25; 9, 34; 9, 57; 9, 143; 9, 182; 9, 193; 9, 210; 9, 218; 9, 224; 9, 245; 9, ... | def parse(cls, gvid, exception=True):
if gvid == 'invalid':
return cls.get_class('null')(0)
if not bool(gvid):
return None
if not isinstance(gvid, six.string_types):
raise TypeError("Can't parse; not a string. Got a '{}' ".format(type(gvid)))
try:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:filter_pastdate; 3, parameters; 3, 4; 3, 5; 4, identifier:string; 5, default_parameter; 5, 6; 5, 7; 6, identifier:default; 7, None; 8, block; 8, 9; 8, 19; 8, 29; 8, 53; 8, 73; 8, 116; 8, 172; 8, 178; 9, if_statement; 9, 10; 9, 16; 10, boolean_o... | def filter_pastdate(string, default=None):
if not string and default is not None:
return default
today = datetime.date.today()
try:
parts = map(int, re.split('\D+', string))
except ValueError:
raise InvalidInputError("invalid date; use format: DD [MM [YYYY]]")
if len(parts) <... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:get_rooms; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:lid; 6, default_parameter; 6, 7; 6, 8; 7, identifier:start; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:end; 11, None; 12, block; 12, 13; 12, 1... | def get_rooms(self, lid, start=None, end=None):
range_str = "availability"
if start:
start_datetime = datetime.datetime.combine(datetime.datetime.strptime(start, "%Y-%m-%d").date(), datetime.datetime.min.time())
range_str += "=" + start
if end and not start == end:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 28; 2, function_name:reconstruct_ancestral_states; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 3, 16; 3, 19; 3, 22; 3, 25; 4, identifier:tree; 5, identifier:character; 6, identifier:states; 7, default_parameter; 7, 8; 7, 9; 8, identifier:prediction_method... | def reconstruct_ancestral_states(tree, character, states, prediction_method=MPPA, model=F81,
params=None, avg_br_len=None, num_nodes=None, num_tips=None,
force_joint=True):
logging.getLogger('pastml').debug('ACR settings for {}:\n\tMethod:\t{}{}.'
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:acr; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 4, identifier:tree; 5, identifier:df; 6, default_parameter; 6, 7; 6, 8; 7, identifier:prediction_method; 8, identifier:MPPA; 9, default_parameter; 9, 10; 9, 11; 10, identifier:model; 11... | def acr(tree, df, prediction_method=MPPA, model=F81, column2parameters=None, force_joint=True):
for c in df.columns:
df[c] = df[c].apply(lambda _: '' if pd.isna(_) else _.encode('ASCII', 'replace').decode())
columns = preannotate_tree(df, tree)
name_tree(tree)
collapse_zero_branches(tree, featur... |
0, module; 0, 1; 0, 169; 0, 176; 0, 207; 0, 219; 1, function_definition; 1, 2; 1, 3; 1, 7; 1, 159; 2, function_name:export_bert; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:data; 5, identifier:electrodes; 6, identifier:filename; 7, ERROR; 7, 8; 7, 41; 7, 49; 7, 61; 7, 64; 7, 65; 8, if_statement; 8, 9; 8, 13; 9, call... | def export_bert(data, electrodes, filename):
if has_multiple_timesteps(data):
for i, timestep in enumerate(split_timesteps(data)):
export_bert(timestep, electrodes,
filename.replace(".", "_%.3d." % i))
f = open(filename, 'w')
f.write("%d\n" % len(electrodes))
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_sort_dd_skips; 3, parameters; 3, 4; 3, 5; 4, identifier:configs; 5, identifier:dd_indices_all; 6, block; 6, 7; 6, 26; 6, 44; 6, 53; 6, 70; 6, 74; 6, 101; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:config_current_s... | def _sort_dd_skips(configs, dd_indices_all):
config_current_skips = np.abs(configs[:, 1] - configs[:, 0])
if np.all(np.isnan(config_current_skips)):
return {0: []}
available_skips_raw = np.unique(config_current_skips)
available_skips = available_skips_raw[
~np.isnan(available_skips_raw)
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:get_label; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:parameter; 5, identifier:ptype; 6, default_parameter; 6, 7; 6, 8; 7, identifier:flavor; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:mpl; 11, None; 12, block; 12, 1... | def get_label(parameter, ptype, flavor=None, mpl=None):
if flavor is not None:
if flavor not in ('latex', 'mathml'):
raise Exception('flavor not recognized: {}'.format(flavor))
else:
if mpl is None:
raise Exception('either the flavor or mpl must be provided')
rend... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:convert; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:input_format; 5, identifier:output_format; 6, identifier:data; 7, default_parameter; 7, 8; 7, 9; 8, identifier:one_spectrum; 9, False; 10, block; 10, 11; 10, 18; 10, 33; 10, 48; 10,... | def convert(input_format, output_format, data, one_spectrum=False):
if input_format == output_format:
return data
if input_format not in from_converters:
raise KeyError('Input format {0} not known!'.format(input_format))
if output_format not in to_converters:
raise KeyError('Output f... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:plot_ps_extra; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:dataobj; 5, identifier:key; 6, dictionary_splat_pattern; 6, 7; 7, identifier:kwargs; 8, block; 8, 9; 8, 30; 8, 59; 8, 105; 8, 114; 8, 127; 8, 136; 8, 150; 8, 156; 8, 164; 8, 187; 8, ... | def plot_ps_extra(dataobj, key, **kwargs):
if isinstance(dataobj, pd.DataFrame):
df_raw = dataobj
else:
df_raw = dataobj.data
if kwargs.get('subquery', False):
df = df_raw.query(kwargs.get('subquery'))
else:
df = df_raw
def fancyfy(axes, N):
for ax in axes[0:-... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:plot_pseudodepths; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 4, identifier:configs; 5, identifier:nr_electrodes; 6, default_parameter; 6, 7; 6, 8; 7, identifier:spacing; 8, integer:1; 9, default_parameter; 9, 10; 9, 11; 10, i... | def plot_pseudodepths(configs, nr_electrodes, spacing=1, grid=None,
ctypes=None, dd_merge=False, **kwargs):
pseudo_d_functions = {
'dd': _pseudodepths_dd_simple,
'schlumberger': _pseudodepths_schlumberger,
'wenner': _pseudodepths_wenner,
}
titles = {
'dd... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:complete; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:uio; 6, default_parameter; 6, 7; 6, 8; 7, identifier:dropped; 8, False; 9, block; 9, 10; 9, 19; 10, if_statement; 10, 11; 10, 17; 11, boolean_operator:and; 11, 12; 11,... | def complete(self, uio, dropped=False):
if self.dropped and not dropped:
return
for end in ['src', 'dst']:
if getattr(self, end):
continue
uio.show('\nEnter ' + end + ' for transaction:')
uio.show('')
uio.show(self.summary())
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 27; 2, function_name:gen_dipole_dipole; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 3, 21; 3, 24; 4, identifier:self; 5, identifier:skipc; 6, default_parameter; 6, 7; 6, 8; 7, identifier:skipv; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, ident... | def gen_dipole_dipole(self,
skipc,
skipv=None,
stepc=1,
stepv=1,
nr_voltage_dipoles=10,
before_current=False,
start_skip=0,
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:split_into_normal_and_reciprocal; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:pad; 7, False; 8, default_parameter; 8, 9; 8, 10; 9, identifier:return_indices; 10, False; 11, block; 11, 12... | def split_into_normal_and_reciprocal(self, pad=False,
return_indices=False):
configs = np.hstack((np.sort(self.configs[:, 0:2], axis=1),
np.sort(self.configs[:, 2:4], axis=1)))
ab_min = configs[:, 0]
mn_min = configs[:, 2]
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:gen_reciprocals; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:append; 7, False; 8, block; 8, 9; 8, 27; 8, 53; 8, 79; 8, 108; 8, 114; 8, 132; 9, expression_statement; 9, 10; 10, assignment; 10, 1... | def gen_reciprocals(self, append=False):
reciprocals = self.configs.copy()[:, ::-1]
reciprocals[:, 0:2] = np.sort(reciprocals[:, 0:2], axis=1)
reciprocals[:, 2:4] = np.sort(reciprocals[:, 2:4], axis=1)
ind = np.lexsort((reciprocals[:, 3], reciprocals[:, 2],
reci... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:gen_configs_permutate; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:self; 5, identifier:injections_raw; 6, default_parameter; 6, 7; 6, 8; 7, identifier:only_same_dipole_length; 8, False; 9, default_parameter; 9, 10; 9, 11; 10, i... | def gen_configs_permutate(self,
injections_raw,
only_same_dipole_length=False,
ignore_crossed_dipoles=False,
silent=False):
injections = np.atleast_2d(injections_raw).astype(int)
N = i... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:to_pg_scheme; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:container; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:positions; 10, None; 11, block; 11, 12; 11, 26; 11, 42; 11,... | def to_pg_scheme(self, container=None, positions=None):
if container is None and positions is None:
raise Exception('electrode positions are required for BERT export')
if container is not None and container.electrodes is None:
raise Exception('container does not contain electrode... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:try_sending; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:msg; 6, identifier:timeout_secs; 7, identifier:max_attempts; 8, block; 8, 9; 8, 20; 8, 31; 8, 35; 9, if_statement; 9, 10; 9, 13; 10, comparison_operator:is; 1... | async def try_sending(self,msg,timeout_secs, max_attempts):
if timeout_secs is None:
timeout_secs = self.timeout
if max_attempts is None:
max_attempts = self.retry_count
attempts = 0
while attempts < max_attempts:
if msg.seq_num not in self.message: re... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:apply_correction_factors; 3, parameters; 3, 4; 3, 5; 4, identifier:df; 5, identifier:correction_file; 6, block; 6, 7; 6, 158; 6, 184; 6, 210; 6, 222; 6, 230; 6, 243; 6, 406; 7, if_statement; 7, 8; 7, 15; 7, 34; 8, call; 8, 9; 8, 10; 9, identifi... | def apply_correction_factors(df, correction_file):
if isinstance(correction_file, (list, tuple)):
corr_data_raw = np.vstack(
[np.loadtxt(x) for x in correction_file]
)
else:
corr_data_raw = np.loadtxt(correction_file)
if corr_data_raw.shape[1] == 3:
A = (c... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:alter_zero_tip_allowed_states; 3, parameters; 3, 4; 3, 5; 4, identifier:tree; 5, identifier:feature; 6, block; 6, 7; 6, 14; 6, 22; 6, 62; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:zero_parent2tips; 10, call; 10, 1... | def alter_zero_tip_allowed_states(tree, feature):
zero_parent2tips = defaultdict(list)
allowed_state_feature = get_personalized_feature_name(feature, ALLOWED_STATES)
for tip in tree:
if tip.dist == 0:
state = getattr(tip, feature, None)
if state is not None and state != '':
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:choose_ancestral_states_mppa; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:tree; 5, identifier:feature; 6, identifier:states; 7, default_parameter; 7, 8; 7, 9; 8, identifier:force_joint; 9, True; 10, block; 10, 11; 10, 19; 10, 27; 10, ... | def choose_ancestral_states_mppa(tree, feature, states, force_joint=True):
lh_feature = get_personalized_feature_name(feature, LH)
allowed_state_feature = get_personalized_feature_name(feature, ALLOWED_STATES)
joint_state_feature = get_personalized_feature_name(feature, JOINT_STATE)
n = len(states)
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:parse; 3, parameters; 3, 4; 4, identifier:text; 5, block; 5, 6; 5, 18; 5, 22; 5, 26; 5, 209; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:fixed_text; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifie... | def parse(text):
fixed_text = validate.fix_string_case(utf(text))
output = []
cur_end = 0
for cur, i in enumerate(fixed_text):
try:
i.encode('utf-8')
except UnicodeDecodeError:
uni_pass = False
else:
uni_pass = True
match = {'matched': ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:process_match; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:match; 5, identifier:fixed_text; 6, identifier:cur; 7, identifier:cur_end; 8, block; 8, 9; 8, 13; 8, 32; 8, 68; 8, 280; 9, expression_statement; 9, 10; 10, assignment; 10, 11; ... | def process_match(match, fixed_text, cur, cur_end):
replace = True
if match['type'] == 'prefix':
chk = cur - 1
else:
chk = cur_end
if match['scope'].startswith('!'):
scope = match['scope'][1:]
negative = True
else:
scope = match['scope']
negative = Fal... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:scatter_norrec; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:filename; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:individual; 10, False; 11, block; 11, 12; 11, 22; 11, 26; ... | def scatter_norrec(self, filename=None, individual=False):
std_diff_labels = {
'r': 'rdiff',
'rpha': 'rphadiff',
}
diff_labels = std_diff_labels
labels_to_use = {}
for key, item in diff_labels.items():
if key in self.data.columns and item in se... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:get_spectrum; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:nr_id; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:abmn; 10, None; 11, default_parameter; 11, 12; 11, 13; 1... | def get_spectrum(self, nr_id=None, abmn=None, plot_filename=None):
assert nr_id is None or abmn is None
if abmn is not None:
subdata = self.data.query(
'a == {} and b == {} and m == {} and n == {}'.format(*abmn)
).sort_values('frequency')
if subdata.sh... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:import_bin; 3, parameters; 3, 4; 3, 5; 4, identifier:filename; 5, dictionary_splat_pattern; 5, 6; 6, identifier:kwargs; 7, block; 7, 8; 7, 17; 7, 27; 7, 58; 7, 188; 7, 214; 7, 229; 7, 241; 7, 249; 7, 257; 7, 265; 7, 273; 7, 281; 7, 289; 7, 297;... | def import_bin(filename, **kwargs):
metadata, data_raw = _import_bin(filename)
skip_rows = kwargs.get('skip_rows', 0)
if skip_rows > 0:
data_raw.drop(data_raw.index[range(0, skip_rows)], inplace=True)
data_raw = data_raw.reset_index()
if kwargs.get('check_meas_nums', True):
if da... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 43; 2, function_name:datoms; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 3, 29; 3, 32; 3, 35; 3, 38; 3, 41; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:index; 7, string:'aevt'; 8, default_parameter; 8, 9; 8, 1... | def datoms(self, index='aevt', e='', a='', v='',
limit=0, offset=0, chunk=100,
start='', end='', since='', as_of='', history='', **kwargs):
assert index in ['aevt','eavt','avet','vaet'], "non-existant index"
data = {'index': index,
'a': ':{0}'.format(... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:add; 3, parameters; 3, 4; 3, 5; 3, 7; 4, identifier:self; 5, list_splat_pattern; 5, 6; 6, identifier:args; 7, dictionary_splat_pattern; 7, 8; 8, identifier:kwargs; 9, block; 9, 10; 9, 17; 9, 30; 9, 147; 9, 149; 9, 172; 9, 174; 9, 203; 9, 205; 9... | def add(self, *args, **kwargs):
assert self.resp is None, "Transaction already committed"
entity, av_pairs, args = None, [], list(args)
if len(args):
if isinstance(args[0], (int, long)):
" first arg is an entity or tempid"
entity = E(args[0], tx=self)
elif isinstance(args[0], E)... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:parsimonious_acr; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, identifier:tree; 5, identifier:character; 6, identifier:prediction_method; 7, identifier:states; 8, identifier:num_nodes; 9, identifier:num_tips; 10, block; 10, 11; 10, 18... | def parsimonious_acr(tree, character, prediction_method, states, num_nodes, num_tips):
initialise_parsimonious_states(tree, character, states)
uppass(tree, character)
results = []
result = {STATES: states, NUM_NODES: num_nodes, NUM_TIPS: num_tips}
logger = logging.getLogger('pastml')
def process... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:load_seit_data; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:directory; 5, default_parameter; 5, 6; 5, 7; 6, identifier:frequency_file; 7, string:'frequencies.dat'; 8, default_parameter; 8, 9; 8, 10; 9, identifier:data_prefix; 10, str... | def load_seit_data(directory, frequency_file='frequencies.dat',
data_prefix='volt_', **kwargs):
frequencies = np.loadtxt(directory + os.sep + frequency_file)
data_files = sorted(glob(directory + os.sep + data_prefix + '*'))
if frequencies.size != len(data_files):
raise Exception(
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:parse_date; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:date; 6, block; 6, 7; 6, 30; 6, 67; 7, if_statement; 7, 8; 7, 13; 8, comparison_operator:is; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:self; 11, identifier:d... | def parse_date(self, date):
if self.date_format is not None:
return datetime.datetime.strptime(date, self.date_format).date()
if re.match('\d{8}$', date):
return datetime.date(*map(int, (date[:4], date[4:6], date[6:])))
try:
parts = date_delim.split(date, 2)
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:commit; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:if_match; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:wait; 10, True; 11, default_parameter; 11, 12; 11, 13; 12, ... | def commit(self, if_match=None, wait=True, timeout=None):
if not self._changes:
LOG.debug("No changes available for %s: %s",
self.__class__.__name__, self.resource_id)
return
LOG.debug("Apply all the changes on the current %s: %s",
self.__c... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:plot_histograms; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:ertobj; 5, identifier:keys; 6, dictionary_splat_pattern; 6, 7; 7, identifier:kwargs; 8, block; 8, 9; 8, 30; 8, 44; 8, 56; 8, 60; 8, 70; 8, 124; 8, 414; 8, 423; 9, if_statement; 9, ... | def plot_histograms(ertobj, keys, **kwargs):
if isinstance(ertobj, pd.DataFrame):
df = ertobj
else:
df = ertobj.data
if df.shape[0] == 0:
raise Exception('No data present, cannot plot')
if isinstance(keys, str):
keys = [keys, ]
figures = {}
merge_figs = kwargs.get... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:plot_histograms_extra_dims; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:dataobj; 5, identifier:keys; 6, dictionary_splat_pattern; 6, 7; 7, identifier:kwargs; 8, block; 8, 9; 8, 30; 8, 59; 8, 63; 8, 100; 8, 104; 8, 111; 8, 121; 8, 145; 8, 155... | def plot_histograms_extra_dims(dataobj, keys, **kwargs):
if isinstance(dataobj, pd.DataFrame):
df_raw = dataobj
else:
df_raw = dataobj.data
if kwargs.get('subquery', False):
df = df_raw.query(kwargs.get('subquery'))
else:
df = df_raw
split_timestamps = True
if spl... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 24; 2, function_name:request; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 3, 16; 3, 19; 3, 22; 4, identifier:self; 5, identifier:method; 6, identifier:url; 7, default_parameter; 7, 8; 7, 9; 8, identifier:params; 9, None; 10, default_parameter; 10, 11; 10,... | async def request(self, method, url, params=None, headers=None,
data=None, json=None, token_refresh_attempts=2,
**kwargs):
if all([data, json]):
msg = ('"data" and "json" request parameters can not be used '
'at the same time')
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:unflatten; 3, parameters; 3, 4; 3, 5; 4, identifier:processed; 5, identifier:merge_rules; 6, block; 6, 7; 6, 13; 6, 179; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:unflattened; 10, call; 10, 11; 10, 12; 11, identif... | def unflatten(processed, merge_rules):
unflattened = OrderedDict()
for key in processed:
current_node = unflattened
for end, part in enumerate(key, 1):
if isinstance(part, IdValue):
for node in current_node:
if isinstance(node, IdDict) and node.ide... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:translate; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 10; 5, 105; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:translations; 9, list:[]; 10, for_statement; 10, 11; 10, 12; 10, 15; 11, identifier:lang;... | def translate(self):
translations = []
for lang in settings.LANGUAGES:
if lang[0] == self._get_default_language():
continue
if self.translatable_slug is not None:
if self.translatable_slug not in self.translatable_fields:
self.t... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:set_translation; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:lang; 6, identifier:field; 7, identifier:text; 8, block; 8, 9; 8, 13; 8, 32; 8, 45; 8, 51; 8, 57; 8, 86; 8, 129; 8, 139; 8, 147; 8, 159; 9, expression_sta... | def set_translation(self, lang, field, text):
auto_slug_obj = None
if lang == self._get_default_language():
raise CanNotTranslate(
_('You are not supposed to translate the default language. '
'Use the model fields for translations in default language')
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:jsonify; 3, parameters; 3, 4; 3, 5; 3, 9; 4, identifier:o; 5, default_parameter; 5, 6; 5, 7; 6, identifier:max_depth; 7, unary_operator:-; 7, 8; 8, integer:1; 9, default_parameter; 9, 10; 9, 11; 10, identifier:parse_enums; 11, identifier:PARSE... | def jsonify(o, max_depth=-1, parse_enums=PARSE_KEEP):
if max_depth == 0:
return o
max_depth -= 1
if isinstance(o, dict):
keyattrs = getattr(o.__class__, '_altnames', {})
def _getter(key, value):
key = keyattrs.get(key, key)
other = getattr(o, key, value)
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:b58encode; 3, parameters; 3, 4; 3, 5; 4, identifier:val; 5, default_parameter; 5, 6; 5, 7; 6, identifier:charset; 7, identifier:DEFAULT_CHARSET; 8, block; 8, 9; 8, 63; 8, 85; 8, 101; 8, 108; 8, 121; 8, 128; 8, 137; 8, 144; 8, 152; 8, 174; 8, 18... | def b58encode(val, charset=DEFAULT_CHARSET):
def _b58encode_int(int_, default=bytes([charset[0]])):
if not int_ and default:
return default
output = b''
while int_:
int_, idx = divmod(int_, base)
output = charset[idx:idx+1] + output
return output
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:m2m_callback; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 4, identifier:sender; 5, identifier:instance; 6, identifier:action; 7, identifier:reverse; 8, identifier:model; 9, identifier:pk_set; 10, identifier:using; 11, dict... | def m2m_callback(sender, instance, action, reverse, model, pk_set, using, **kwargs):
if validate_instance(instance) and settings.AUTOMATED_LOGGING['to_database']:
if action in ["post_add", 'post_remove']:
modification = [model.objects.get(pk=x) for x in pk_set]
if 'al_chl' in instanc... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:normalize_allele_name; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:raw_allele; 5, default_parameter; 5, 6; 5, 7; 6, identifier:omit_dra1; 7, False; 8, default_parameter; 8, 9; 8, 10; 9, identifier:infer_class2_pair; 10, True; 11, block; 11,... | def normalize_allele_name(raw_allele, omit_dra1=False, infer_class2_pair=True):
cache_key = (raw_allele, omit_dra1, infer_class2_pair)
if cache_key in _normalized_allele_cache:
return _normalized_allele_cache[cache_key]
parsed_alleles = parse_classi_or_classii_allele_name(
raw_allele, infer_... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.