sequence stringlengths 1.19k 35k | code stringlengths 75 8.58k |
|---|---|
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '23']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'qteReplaceAppletInLayout'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '11', '18']}; {'id': '4', 'type': 'identifier', ... | def qteReplaceAppletInLayout(self, newApplet: (QtmacsApplet, str),
oldApplet: (QtmacsApplet, str)=None,
windowObj: QtmacsWindow=None):
if isinstance(oldApplet, str):
oldAppObj = self.qteGetAppletHandle(oldApplet)
else:
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'qteRemoveAppletFromLayout'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children':... | 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... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'qteKillApplet'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | 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.... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'qteRunHook'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | 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:
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'qteMacroNameMangling'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], '... | def qteMacroNameMangling(self, macroCls):
macroName = re.sub(r"([A-Z])", r'-\1', macroCls.__name__)
if macroName[0] == '-':
macroName = macroName[1:]
return macroName.lower() |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '16']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'qteRegisterMacro'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '11']}; {'id': '4', 'type': 'identifier', 'children... | 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... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'qteGetMacroObject'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '9']}; {'id': '4', 'type': 'identifier', 'children': []... | 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... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'qteGetAllMacroNames'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], '... | 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... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'qteBindKeyGlobal'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [],... | 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_... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'qteRegisterApplet'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': []... | 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:
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'start'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}... | 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_... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '26']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'app_main'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17', '20', '23']}; {'id': '4', 'type': 'identi... | 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... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '28']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'configure'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17', '20', '23', '26']}; {'id': '4', 'type': ... | 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)
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'generate_basic_type_docs'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [... | 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... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'generate_doc_dict'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'val... | 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 }
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_driver'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's... | 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 =... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | 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) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'qteSetLexer'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | 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:
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_function_args'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': []... | 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)]... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_close_callable'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], '... | 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... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'qteRemoveKey'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | 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... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_labels'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [],... | 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... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_constrained_labels'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'childre... | 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 = ... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'populate_field_values'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], ... | 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... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'build_contact'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | 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... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'stop_task'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], '... | 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... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '17']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'diffs2persistence'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14']}; {'id': '4', 'type': 'identifier', 'c... | 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 \
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '26']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'qteAddWidget'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '11', '16', '21']}; {'id': '4', 'type': 'identifier', 'child... | 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._... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'qteSetWidgetFocusOrder'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [],... | 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... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '37']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'qteNextWidget'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '10', '17', '22', '27', '32']}; {'id': '4', 'type': 'identi... | 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):
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'qteMakeWidgetActive'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], '... | 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)
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '23']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'make_result'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15', '18', '21']}; {'id': '4', 'type': 'iden... | 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... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_class_frame_source'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | 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):
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_create_typed_object_meta'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], '... | 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(
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_build_module_db'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | 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)
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'merge'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'c... | 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 ... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'diff'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cl... | 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... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_sorted_keys_items'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | def _sorted_keys_items(dobj):
keys = sorted(dobj.keys())
for key in keys:
yield key, dobj[key] |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_or_create_exh_obj'}, {'id': '3', 'type': 'parameters', 'children': ['4', '7', '10']}; {'id': '4', 'type': 'default_parameter', 'c... | 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() |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_property_search'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | 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)
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_execute'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | 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... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_entity_errors'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children... | 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... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_collection_errors'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'chil... | 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:
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'merge_errors'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'val... | 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... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cursorPositionChangedEvent'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], ... | def cursorPositionChangedEvent(self):
qteWidget = self.sender()
tc = qteWidget.textCursor()
origin = tc.position()
qteWidget.cursorPositionChanged.disconnect(
self.cursorPositionChangedEvent)
self.qteRemoveHighlighting(qteWidget)
qteWidget.cursorPositionChange... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'scenarios'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se... | 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... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'subdict_by_keys'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | def subdict_by_keys(dict_obj, keys):
return {k: dict_obj[k] for k in set(keys).intersection(dict_obj.keys())} |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'deep_merge_dict'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | 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[... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'norm_int_dict'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'int... | 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 |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sum_num_dicts'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | 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 |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'reverse_dict'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'dict... | 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 |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'flatten_dict'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | 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 ... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'key_value_nested_generator'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], ... | 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 |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'key_tuple_value_nested_generator'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children'... | 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 |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'release_lock'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | 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... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'guess_codec'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'val... | 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... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'read_record'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | 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... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_make_record'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'val... | 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... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'c... | 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:
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'filter_pastdate'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | 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) <... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_rooms'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], '... | 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:
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '28']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'reconstruct_ancestral_states'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10', '13', '16', '19', '22', '25'... | 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{}{}.'
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '18']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'acr'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15']}; {'id': '4', 'type': 'identifier', 'children':... | 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... |
{'id': '0', 'type': 'module', 'children': ['1', '169', '176', '207', '219']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7', '159']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'export_bert'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': ... | 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))
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_sort_dd_skips'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | 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)
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_label'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], '... | 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... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'convert'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | 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... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'plot_ps_extra'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | 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:-... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '20']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'plot_pseudodepths'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15', '18']}; {'id': '4', 'type': 'iden... | 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... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'complete'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | 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())
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '27']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'gen_dipole_dipole'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15', '18', '21', '24']}; {'id': '4', '... | def gen_dipole_dipole(self,
skipc,
skipv=None,
stepc=1,
stepv=1,
nr_voltage_dipoles=10,
before_current=False,
start_skip=0,
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'split_into_normal_and_reciprocal'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier',... | 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]
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'gen_reciprocals'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | 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... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'gen_configs_permutate'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12']}; {'id': '4', 'type': 'identifier',... | 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... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to_pg_scheme'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | 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... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'try_sending'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], ... | 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... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'apply_correction_factors'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [... | 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... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'alter_zero_tip_allowed_states'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'childre... | 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 != '':
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'choose_ancestral_states_mppa'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier'... | 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)
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'text'}, {'i... | 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': ... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'process_match'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': []... | 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... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'scatter_norrec'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], '... | 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... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_spectrum'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': [... | 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... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'import_bin'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'f... | 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... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '43']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'datoms'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17', '20', '23', '26', '29', '32', '35', '38', '... | 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(... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel... | 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)... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parsimonious_acr'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9']}; {'id': '4', 'type': 'identifier', ... | 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... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_seit_data'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children':... | 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(
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_date'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's... | 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)
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'commit'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | 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... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'plot_histograms'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], '... | 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... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'plot_histograms_extra_dims'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'child... | 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... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '24']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'request'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10', '13', '16', '19', '22']}; {'id': '4', 'type': 'id... | 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')
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'unflatten'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'pr... | 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... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'translate'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'},... | 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... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'set_translation'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': ... | 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')
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'jsonify'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | 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)
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'b58encode'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'va... | 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
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'm2m_callback'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '10', '11']}; {'id': '4', 'type': 'ident... | 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... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'normalize_allele_name'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children'... | 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.