sequence stringlengths 492 15.9k | code stringlengths 75 8.58k |
|---|---|
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:Debounce; 3, parameters; 3, 4; 4, default_parameter; 4, 5; 4, 6; 5, identifier:threshold; 6, integer:100; 7, block; 7, 8; 7, 12; 7, 16; 7, 174; 8, expression_statement; 8, 9; 9, augmented_assignment:*=; 9, 10; 9, 11; 10, identifier:threshold; 1... | def Debounce(threshold=100):
threshold *= 1000
max_tick = 0xFFFFFFFF
class _decorated(object):
def __init__(self, pigpio_cb):
self._fn = pigpio_cb
self.last = 0
self.is_method = False
def __call__(self, *args, **kwargs):
if self.is_method:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:fit; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 4, identifier:self; 5, identifier:target_type; 6, identifier:target; 7, default_parameter; 7, 8; 7, 9; 8, identifier:adjust_thickness; 9, False; 10, default_parameter; 10, 11; 10, 12; 1... | def fit(self,
target_type,
target,
adjust_thickness=False,
adjust_site_atten=False,
adjust_source_vel=False):
density = self.profile.density
nl = len(density)
slowness = self.profile.slowness
thickness = self.profile.thickness
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:build_recipe_input; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:ob; 6, identifier:dal; 7, block; 7, 8; 7, 12; 7, 16; 7, 20; 7, 157; 7, 166; 7, 172; 7, 212; 7, 261; 7, 331; 8, expression_statement; 8, 9; 9, assignment; 9, ... | def build_recipe_input(self, ob, dal):
result = {}
ob_query_skip = False
ob_query_field = 'obresult'
if isinstance(ob, ObservingBlock):
import numina.types.obsresult as obtype
for key, req in self.requirements().items():
if isinstance(req.type, obt... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:subsets_of_fileinfo_from_txt; 3, parameters; 3, 4; 4, identifier:filename; 5, block; 5, 6; 5, 26; 5, 49; 5, 53; 5, 57; 5, 61; 5, 65; 5, 69; 5, 73; 5, 77; 5, 290; 5, 299; 6, if_statement; 6, 7; 6, 16; 7, not_operator; 7, 8; 8, call; 8, 9; 8, 14;... | def subsets_of_fileinfo_from_txt(filename):
if not os.path.isfile(filename):
raise ValueError("File " + filename + " not found!")
with open(filename) as f:
file_content = f.read().splitlines()
dict_of_subsets_of_fileinfo = {}
label = None
sublist_of_fileinfo = []
idict = 0
if... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:verify_refresh; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:request; 6, block; 6, 7; 6, 18; 6, 27; 6, 37; 6, 67; 6, 76; 6, 88; 6, 123; 6, 179; 7, if_statement; 7, 8; 7, 12; 8, not_operator; 8, 9; 9, attribute; 9, 10; 9, 11; 10,... | def verify_refresh(self, request):
if not self.allow_refresh:
raise InvalidTokenError('Token refresh is disabled')
token = self.get_jwt(request)
if token is None:
raise InvalidTokenError('Token not found')
try:
claims_set = self.decode_jwt(
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:get_default_terminal; 3, parameters; 3, 4; 3, 7; 4, default_parameter; 4, 5; 4, 6; 5, identifier:environ; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:fallback; 9, identifier:_UNSPECIFIED; 10, block; 10, 11; 10, 22; 10, 31; 10, 35;... | def get_default_terminal(environ=None, fallback=_UNSPECIFIED):
if environ is None:
environ = os.environ
if "PIAS_OPT_TERMINAL" in environ:
return environ["PIAS_OPT_TERMINAL"]
terminals = []
colorterm = environ.get("COLORTERM")
for filename in (colorterm, "gnome-terminal", "konsole", ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:bitset; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 11; 3, 14; 4, identifier:name; 5, identifier:members; 6, default_parameter; 6, 7; 6, 8; 7, identifier:base; 8, attribute; 8, 9; 8, 10; 9, identifier:bases; 10, identifier:BitSet; 11, default_paramete... | def bitset(name, members, base=bases.BitSet, list=False, tuple=False):
if not name:
raise ValueError('empty bitset name: %r' % name)
if not hasattr(members, '__getitem__') or not hasattr(members, '__len__'):
raise ValueError('non-sequence bitset members: %r' % members)
if not len(members):
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_split_refextract_authors_str; 3, parameters; 3, 4; 4, identifier:authors_str; 5, block; 5, 6; 5, 25; 5, 29; 5, 33; 5, 144; 5, 154; 5, 182; 5, 202; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:author_seq; 9, generator... | def _split_refextract_authors_str(authors_str):
author_seq = (x.strip() for x in RE_SPLIT_AUTH.split(authors_str) if x)
res = []
current = ''
for author in author_seq:
if not isinstance(author, six.text_type):
author = six.text_type(author.decode('utf8', 'ignore'))
author = r... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 30; 2, function_name:query; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 3, 21; 3, 24; 3, 27; 4, identifier:pattern_path; 5, identifier:dict_; 6, default_parameter; 6, 7; 6, 8; 7, identifier:max_length; 8, None; 9, default_parameter; 9, 10; 9, 11; 1... | def query(pattern_path, dict_, max_length=None, strip=False,
case_sensitive=False, unique=False, deduplicate=False,
string_transformations=None, hyperlink=False,
return_multiple_columns=False):
if string_transformations is None:
string_transformations = []
if max_length:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:get_reactions; 3, parameters; 3, 4; 3, 7; 3, 10; 3, 13; 4, default_parameter; 4, 5; 4, 6; 5, identifier:columns; 6, string:'all'; 7, default_parameter; 7, 8; 7, 9; 8, identifier:n_results; 9, integer:20; 10, default_parameter; 10, 11; 10, 12; ... | def get_reactions(columns='all', n_results=20, write_db=False, **kwargs):
if write_db or columns == 'all':
columns = all_columns['reactions']
queries = {}
for key, value in kwargs.items():
key = map_column_names(key)
if key == 'distinct':
if value in [True, 'True', 'true'... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:extract_atoms; 3, parameters; 3, 4; 4, identifier:molecule; 5, block; 5, 6; 5, 13; 5, 24; 5, 28; 5, 107; 5, 156; 5, 233; 6, if_statement; 6, 7; 6, 10; 7, comparison_operator:==; 7, 8; 7, 9; 8, identifier:molecule; 9, string:''; 10, block; 10, 1... | def extract_atoms(molecule):
if molecule == '':
return molecule
try:
return float(molecule)
except BaseException:
pass
atoms = ''
if not molecule[0].isalpha():
i = 0
while not molecule[i].isalpha():
i += 1
prefactor = float(molecule[:i])
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:check_reaction; 3, parameters; 3, 4; 3, 5; 4, identifier:reactants; 5, identifier:products; 6, block; 6, 7; 6, 32; 6, 57; 6, 68; 6, 79; 6, 86; 6, 93; 6, 97; 6, 101; 6, 136; 6, 160; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, i... | def check_reaction(reactants, products):
reactant_list = [reactant.split('@')[0].strip(
'star').strip('gas') for reactant in reactants]
product_list = [product.split('@')[0].strip(
'star').strip('gas') for product in products]
reactant_atoms = [extract_atoms(reactant) for reactant in reactan... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 32; 2, function_name:fowler_array; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 3, 29; 4, identifier:fowlerdata; 5, default_parameter; 5, 6; 5, 7; 6, identifier:ti; 7, float:0.0; 8, default_parameter; 8, 9; 8, 10; 9, identifier:ts; 10... | def fowler_array(fowlerdata, ti=0.0, ts=0.0, gain=1.0, ron=1.0,
badpixels=None, dtype='float64',
saturation=65631, blank=0, normalize=False):
import numina.array._nirproc as _nirproc
if gain <= 0:
raise ValueError("invalid parameter, gain <= 0.0")
if ron <= 0:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:reactions; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:columns; 5, identifier:n_results; 6, identifier:write_db; 7, identifier:queries; 8, block; 8, 9; 8, 96; 8, 107; 8, 126; 8, 130; 8, 134; 8, 138; 8, 160; 8, 173; 9, if_statement; 9, ... | def reactions(columns, n_results, write_db, queries):
if not isinstance(queries, dict):
query_dict = {}
for q in queries:
key, value = q.split('=')
if key == 'distinct':
if value in ['True', 'true']:
query_dict.update({key: True})
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:publications; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:columns; 5, identifier:n_results; 6, identifier:queries; 7, block; 7, 8; 7, 95; 7, 110; 7, 130; 7, 134; 7, 138; 7, 248; 7, 261; 8, if_statement; 8, 9; 8, 15; 9, not_operator; 9, 10; 1... | def publications(columns, n_results, queries):
if not isinstance(queries, dict):
query_dict = {}
for q in queries:
key, value = q.split('=')
if key == 'distinct':
if value in ['True', 'true']:
query_dict.update({key: True})
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:make_folders; 3, parameters; 3, 4; 3, 5; 4, identifier:template; 5, identifier:custom_base; 6, block; 6, 7; 6, 24; 6, 34; 6, 54; 6, 62; 6, 68; 6, 129; 6, 251; 6, 335; 6, 346; 7, function_definition; 7, 8; 7, 9; 7, 12; 8, function_name:dict_repr... | def make_folders(template, custom_base):
def dict_representer(dumper, data):
return dumper.represent_dict(data.items())
Dumper.add_representer(collections.OrderedDict, dict_representer)
if custom_base is None:
custom_base = os.path.abspath(os.path.curdir)
template = custom_base + '/' + t... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:opensignals_hierarchy; 3, parameters; 3, 4; 3, 7; 3, 10; 4, default_parameter; 4, 5; 4, 6; 5, identifier:root; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:update; 9, False; 10, default_parameter; 10, 11; 10, 12; 11, identifier:clo... | def opensignals_hierarchy(root=None, update=False, clone=False):
if root is None:
root = os.getcwd()
categories = list(NOTEBOOK_KEYS.keys())
current_dir = root + "\\opensignalstools_environment"
if not os.path.isdir(current_dir):
os.makedirs(current_dir)
for var in ["images", "styles... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_generate_notebook_by_tag_body; 3, parameters; 3, 4; 3, 5; 4, identifier:notebook_object; 5, identifier:dict_by_tag; 6, block; 6, 7; 6, 18; 6, 24; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:tag_keys; 10, call; 10, ... | def _generate_notebook_by_tag_body(notebook_object, dict_by_tag):
tag_keys = list(dict_by_tag.keys())
tag_keys.sort()
for tag in tag_keys:
if tag.lower() not in SIGNAL_TYPE_LIST:
markdown_cell = group_tag_code.TAG_TABLE_HEADER
markdown_cell = markdown_cell.replace("Tag i", ta... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_preprocess_params; 3, parameters; 3, 4; 3, 5; 4, identifier:cls; 5, identifier:kwargs; 6, block; 6, 7; 6, 248; 7, for_statement; 7, 8; 7, 11; 7, 16; 8, pattern_list; 8, 9; 8, 10; 9, identifier:attr; 10, identifier:val; 11, call; 11, 12; 11, 15... | def _preprocess_params(cls, kwargs):
for attr, val in kwargs.items():
if cls.is_the_primary_key(attr) and cls._prevent_primary_key_initialization_:
del kwargs[attr]
continue
if val == "":
kwargs[attr] = None
continue
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:add_all; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:cls; 5, identifier:models; 6, default_parameter; 6, 7; 6, 8; 7, identifier:commit; 8, True; 9, default_parameter; 9, 10; 9, 11; 10, identifier:check_type; 11, False; 12, block; 12, ... | def add_all(cls, models, commit=True, check_type=False):
if check_type:
for model in models:
if not isinstance(model, cls):
raise ValueError('%s is not of type %s' (model, cls))
if None in models:
cls.session.add_all([m for m in models if m is ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:peakdelta; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:v; 5, identifier:delta; 6, default_parameter; 6, 7; 6, 8; 7, identifier:x; 8, None; 9, block; 9, 10; 9, 14; 9, 18; 9, 33; 9, 40; 9, 58; 9, 72; 9, 84; 9, 93; 9, 101; 9, 105; 9, 216; 10, e... | def peakdelta(v, delta, x=None):
maxtab = []
mintab = []
if x is None:
x = arange(len(v))
v = asarray(v)
if len(v) != len(x):
sys.exit('Input vectors v and x must have same length')
if not isscalar(delta):
sys.exit('Input argument delta must be a scalar')
if delta <=... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:parse_datetime; 3, parameters; 3, 4; 4, identifier:value; 5, block; 5, 6; 5, 13; 5, 69; 5, 82; 5, 91; 6, if_statement; 6, 7; 6, 10; 7, comparison_operator:is; 7, 8; 7, 9; 8, identifier:value; 9, None; 10, block; 10, 11; 11, return_statement; 11... | def parse_datetime(value):
if value is None:
return None
def _get_fixed_timezone(offset):
if isinstance(offset, timedelta):
offset = offset.seconds // 60
sign = '-' if offset < 0 else '+'
hhmm = '%02d%02d' % divmod(abs(offset), 60)
name = sign + hhmm
r... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:add_property_grid_widget; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 4, identifier:self; 5, identifier:part_instance; 6, default_parameter; 6, 7; 6, 8; 7, identifier:max_height; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identi... | def add_property_grid_widget(self, part_instance, max_height=None, custom_title=False, show_headers=True,
show_columns=None):
height = max_height
if isinstance(part_instance, Part):
part_instance_id = part_instance.id
elif isinstance(part_instance, te... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_generate_data_for_format; 3, parameters; 3, 4; 4, identifier:fmt; 5, block; 5, 6; 5, 10; 5, 14; 5, 216; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:data; 9, dictionary; 10, expression_statement; 10, 11; 11, assignme... | def _generate_data_for_format(fmt):
data = {}
free_size_start = False
for literal_text, field_name, format_spec, conversion in formatter.parse(fmt):
if literal_text:
free_size_start = False
if not field_name:
free_size_start = False
continue
if not... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:relocate_model; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:part; 5, identifier:target_parent; 6, default_parameter; 6, 7; 6, 8; 7, identifier:name; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:include_children; 11, Tru... | def relocate_model(part, target_parent, name=None, include_children=True):
if target_parent.id in get_illegal_targets(part, include={part.id}):
raise IllegalArgumentError('cannot relocate part "{}" under target parent "{}", because the target is part of '
'its descendants'... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:relocate_instance; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:part; 5, identifier:target_parent; 6, default_parameter; 6, 7; 6, 8; 7, identifier:name; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:include_children; 11, ... | def relocate_instance(part, target_parent, name=None, include_children=True):
if not name:
name = "CLONE - {}".format(part.name)
part_model = part.model()
target_parent_model = target_parent.model()
relocate_model(part=part_model, target_parent=target_parent_model, name=part_model.name,
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:move_part_instance; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 4, identifier:part_instance; 5, identifier:target_parent; 6, identifier:part_model; 7, default_parameter; 7, 8; 7, 9; 8, identifier:name; 9, None; 10, default_parameter; 10, 11;... | def move_part_instance(part_instance, target_parent, part_model, name=None, include_children=True):
if not name:
name = part_instance.name
moved_model = get_mapping_dictionary()[part_model.id]
if moved_model.multiplicity == Multiplicity.ONE:
moved_instance = moved_model.instances(parent_id=t... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:update_part_with_properties; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:part_instance; 5, identifier:moved_instance; 6, default_parameter; 6, 7; 6, 8; 7, identifier:name; 8, None; 9, block; 9, 10; 9, 16; 9, 180; 9, 201; 10, expression_state... | def update_part_with_properties(part_instance, moved_instance, name=None):
properties_id_dict = dict()
for prop_instance in part_instance.properties:
if prop_instance._json_data['property_type'] == PropertyType.ATTACHMENT_VALUE:
moved_prop = get_mapping_dictionary()[prop_instance.id]
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:_checkup; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 4, identifier:peaks; 5, identifier:ecg_integrated; 6, identifier:sample_rate; 7, identifier:rr_buffer; 8, identifier:spk1; 9, identifier:npk1; 10, identifier:threshold; 11, bl... | def _checkup(peaks, ecg_integrated, sample_rate, rr_buffer, spk1, npk1, threshold):
peaks_amp = [ecg_integrated[peak] for peak in peaks]
definitive_peaks = []
for i, peak in enumerate(peaks):
amp = peaks_amp[i]
if amp > threshold:
definitive_peaks, spk1, rr_buffer = _acceptpeak(p... |
0, module; 0, 1; 0, 175; 0, 182; 0, 197; 0, 206; 0, 213; 0, 220; 0, 237; 0, 291; 0, 305; 0, 309; 0, 317; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:create_napp; 3, parameters; 3, 4; 3, 5; 4, identifier:cls; 5, default_parameter; 5, 6; 5, 7; 6, identifier:meta_package; 7, False; 8, block; 8, 9; 8, 15; 8,... | def create_napp(cls, meta_package=False):
templates_path = SKEL_PATH / 'napp-structure/username/napp'
ui_templates_path = os.path.join(templates_path, 'ui')
username = None
napp_name = None
print('--------------------------------------------------------------')
print('Wel... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:match_app_version; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:app; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:label; 10, None; 11, default_parameter; 11, 12... | def match_app_version(self, app=None, label=None, version=None, default=False):
if not app or not label and not (app and label):
target_app = [a for a in self.app_versions if a.get('app') == app or a.get('label') == label]
if not target_app and not isinstance(default, bool):
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:activities; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:name; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:pk; 10, None; 11, default_parameter; 11, 12; 11, 13;... | def activities(self, name=None, pk=None, scope=None, **kwargs):
request_params = {
'id': pk,
'name': name,
'scope': scope
}
if self.match_app_version(label='wim', version='>=2.0.0', default=False):
request_params.update(API_EXTRA_PARAMS['activity']... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 36; 2, function_name:parts; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 19; 3, 22; 3, 25; 3, 28; 3, 31; 3, 34; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:name; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:pk; 10, None; 1... | def parts(self,
name=None,
pk=None,
model=None,
category=Category.INSTANCE,
bucket=None,
parent=None,
activity=None,
limit=None,
batch=100,
**kwargs):
if limit and limit < ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 24; 2, function_name:create_property; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 15; 3, 18; 3, 21; 4, identifier:self; 5, identifier:model; 6, identifier:name; 7, default_parameter; 7, 8; 7, 9; 8, identifier:description; 9, None; 10, default_parameter; 10, 1... | def create_property(self, model, name, description=None, property_type=PropertyType.CHAR_VALUE, default_value=None,
unit=None, options=None):
if model.category != Category.MODEL:
raise IllegalArgumentError("The model should be of category MODEL")
if not property_type.... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:set_sort; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:request; 6, block; 6, 7; 6, 23; 6, 56; 6, 76; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:sort_request; 10, call; 10, 11; 10, 16; 11, attribute;... | def set_sort(self, request):
sort_request = request.GET.get(self.sort_parameter, self.default_sort)
if sort_request.startswith('-'):
sort_order = '-'
sort_field = sort_request.split('-')[1]
else:
sort_order = ''
sort_field = sort_request
if... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_next_sort_string; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:field; 6, block; 6, 7; 6, 43; 7, if_statement; 7, 8; 7, 13; 7, 24; 8, comparison_operator:==; 8, 9; 8, 10; 9, identifier:field; 10, attribute; 10, 11; 10, 12; 11... | def get_next_sort_string(self, field):
if field == self.sort_field:
next_sort = self.toggle_sort_order() + field
else:
default_order_for_field = \
self._allowed_sort_fields[field]['default_direction']
next_sort = default_order_for_field + field
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_sort_indicator; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:field; 6, block; 6, 7; 6, 11; 6, 33; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:indicator; 10, string:''; 11, if_statement; 11, 12; 1... | def get_sort_indicator(self, field):
indicator = ''
if field == self.sort_field:
indicator = 'sort-asc'
if self.sort_order == '-':
indicator = 'sort-desc'
return indicator |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:get_basic_sort_link; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:request; 6, identifier:field; 7, block; 7, 8; 7, 16; 7, 25; 7, 64; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:query_string; ... | def get_basic_sort_link(self, request, field):
query_string = self.get_querystring()
sort_string = self.get_next_sort_string(field)
if sort_string:
sort_link = request.path + '?' + sort_string
if query_string:
sort_link += '&' + query_string
else:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 24; 2, function_name:download_as_pdf; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 16; 3, 21; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:target_dir; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:pdf_filename; 10, None; 11, defaul... | def download_as_pdf(self, target_dir=None, pdf_filename=None, paper_size=PaperSize.A4,
paper_orientation=PaperOrientation.PORTRAIT, include_appendices=False):
if not pdf_filename:
pdf_filename = self.name + '.pdf'
if not pdf_filename.endswith('.pdf'):
pdf_... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 30; 2, function_name:get_project; 3, parameters; 3, 4; 3, 7; 3, 10; 3, 13; 3, 16; 3, 19; 3, 22; 3, 25; 4, default_parameter; 4, 5; 4, 6; 5, identifier:url; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:username; 9, None; 10, default_parameter; 10, 11; 1... | def get_project(url=None, username=None, password=None, token=None, scope=None, scope_id=None,
env_filename=None, status=ScopeStatus.ACTIVE):
if env.bool(kecenv.KECHAIN_FORCE_ENV_USE, default=False):
if not os.getenv(kecenv.KECHAIN_URL):
raise ClientError(
"Error:... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:options; 3, parameters; 3, 4; 4, identifier:cls; 5, block; 5, 6; 6, return_statement; 6, 7; 7, call; 7, 8; 7, 9; 8, identifier:sorted; 9, generator_expression; 9, 10; 9, 13; 9, 24; 10, tuple; 10, 11; 10, 12; 11, identifier:value; 12, identifier... | def options(cls):
return sorted((value, name) for (name, value) in cls.__dict__.items() if not name.startswith('__')) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:edit; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:name; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:description; 10, None; 11, default_parameter; 11, 12; 11, ... | def edit(self, name=None, description=None, version=None, **kwargs):
update_dict = {'id': self.id}
if name:
if not isinstance(name, str):
raise IllegalArgumentError("name should be provided as a string")
update_dict.update({'name': name})
if description:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:children; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, dictionary_splat_pattern; 5, 6; 6, identifier:kwargs; 7, block; 7, 8; 8, if_statement; 8, 9; 8, 11; 8, 47; 9, not_operator; 9, 10; 10, identifier:kwargs; 11, block; 11, 12; 11, 43; 12,... | def children(self, **kwargs):
if not kwargs:
if not self._cached_children:
self._cached_children = list(self._client.parts(parent=self.id, category=self.category))
return self._cached_children
else:
return self._client.parts(parent=self.id, category=se... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:update; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:name; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:update_dict; 10, None; 11, default_parameter; 11, 12; 11... | def update(self, name=None, update_dict=None, bulk=True, **kwargs):
action = 'bulk_update_properties'
request_body = dict()
for prop_name_or_id, property_value in update_dict.items():
if is_uuid(prop_name_or_id):
request_body[prop_name_or_id] = property_value
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:add_with_properties; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 4, identifier:self; 5, identifier:model; 6, default_parameter; 6, 7; 6, 8; 7, identifier:name; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:update_dict; 1... | def add_with_properties(self, model, name=None, update_dict=None, bulk=True, **kwargs):
if self.category != Category.INSTANCE:
raise APIError("Part should be of category INSTANCE")
name = name or model.name
action = 'new_instance_with_properties'
properties_update_dict = dict... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:move; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:self; 5, identifier:target_parent; 6, default_parameter; 6, 7; 6, 8; 7, identifier:name; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:include_children; 11, True; ... | def move(self, target_parent, name=None, include_children=True, include_instances=True):
if not name:
name = self.name
if self.category == Category.MODEL and target_parent.category == Category.MODEL:
moved_model = relocate_model(part=self, target_parent=target_parent, name=name,
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 69; 2, function_name:plot; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 15; 3, 18; 3, 21; 3, 24; 3, 27; 3, 30; 3, 33; 3, 36; 3, 39; 3, 42; 3, 45; 3, 48; 3, 51; 3, 54; 3, 57; 3, 60; 3, 63; 3, 66; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:wor... | def plot(self, workflow=None, view=True, depth=-1, name=NONE, comment=NONE,
format=NONE, engine=NONE, encoding=NONE, graph_attr=NONE,
node_attr=NONE, edge_attr=NONE, body=NONE, node_styles=NONE,
node_data=NONE, node_function=NONE, edge_data=NONE, max_lines=NONE,
max_w... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:lookup_url; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:url; 6, identifier:klass; 7, default_parameter; 7, 8; 7, 9; 8, identifier:module; 9, None; 10, block; 10, 11; 10, 13; 10, 23; 10, 30; 11, expression_statement... | def lookup_url(self, url, klass, module=None):
'''
Gets a proxy reference to the actor indicated by the URL in the
parameters. It can be a local reference or a remote direction to
another host.
This method can be called remotely synchronously.
:param srt. url: address tha... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:prepare_rapid_streamflow; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:path_to_rapid_qout; 6, identifier:connection_list_file; 7, block; 7, 8; 7, 21; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifi... | def prepare_rapid_streamflow(self, path_to_rapid_qout, connection_list_file):
ihg_filename = '{0}.ihg'.format(self.project_manager.name)
with tmp_chdir(self.project_manager.project_directory):
time_index_range = []
with RAPIDDataset(path_to_rapid_qout, out_tzinfo=self.tz) as qout... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:stencil; 3, parameters; 3, 4; 4, dictionary_splat_pattern; 4, 5; 5, identifier:kwargs; 6, block; 6, 7; 6, 16; 6, 25; 6, 34; 6, 73; 6, 87; 6, 107; 6, 130; 6, 145; 6, 156; 6, 344; 6, 354; 6, 373; 6, 382; 6, 400; 7, expression_statement; 7, 8; 8, ... | def stencil(**kwargs):
alnfile = kwargs.get('alnfile')
gtypefile = kwargs.get('gtypefile')
grpfile = kwargs.get('grpfile')
if grpfile is None:
grpfile2chk = os.path.join(DATA_DIR, 'ref.gene2transcripts.tsv')
if os.path.exists(grpfile2chk):
grpfile = grpfile2chk
else:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:split_tracks; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:lat; 5, identifier:lon; 6, list_splat_pattern; 6, 7; 7, identifier:args; 8, block; 8, 9; 8, 11; 8, 15; 8, 29; 8, 40; 8, 316; 8, 353; 9, expression_statement; 9, 10; 10, string:'''assu... | def split_tracks(lat,lon,*args):
'''assumes eastward motion'''
tracks = []
lt,ln = [lat[0]],[lon[0]]
zz = [[z[0]] for z in args]
for i in range(1,len(lon)):
lt.append(lat[i])
for z,a in zip(zz,args):
z.append(a[i])
d1 = abs(lon[... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:find_loaders; 3, parameters; 3, 4; 3, 5; 4, identifier:scheme; 5, default_parameter; 5, 6; 5, 7; 6, identifier:protocols; 7, None; 8, block; 8, 9; 8, 14; 8, 30; 8, 38; 8, 48; 8, 98; 8, 125; 8, 135; 8, 155; 9, expression_statement; 9, 10; 10, as... | def find_loaders(scheme, protocols=None):
matching_groups = ['plaster.loader_factory']
if protocols:
matching_groups += [
'plaster.{0}_loader_factory'.format(proto)
for proto in protocols
]
scheme = scheme.lower()
parts = scheme.split('+', 1)
if len(parts) == ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:combine_dicts; 3, parameters; 3, 4; 3, 6; 3, 9; 4, list_splat_pattern; 4, 5; 5, identifier:dicts; 6, default_parameter; 6, 7; 6, 8; 7, identifier:copy; 8, False; 9, default_parameter; 9, 10; 9, 11; 10, identifier:base; 11, None; 12, block; 12,... | def combine_dicts(*dicts, copy=False, base=None):
if len(dicts) == 1 and base is None:
cd = dicts[0].copy()
else:
cd = {} if base is None else base
for d in dicts:
if d:
cd.update(d)
return {k: _copy.deepcopy(v) for k, v in cd.items()} if copy else cd |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:kk_dict; 3, parameters; 3, 4; 3, 6; 4, list_splat_pattern; 4, 5; 5, identifier:kk; 6, dictionary_splat_pattern; 6, 7; 7, identifier:adict; 8, block; 8, 9; 8, 62; 9, for_statement; 9, 10; 9, 11; 9, 12; 10, identifier:k; 11, identifier:kk; 12, bl... | def kk_dict(*kk, **adict):
for k in kk:
if isinstance(k, dict):
if not set(k).isdisjoint(adict):
raise ValueError('keyword argument repeated')
adict.update(k)
elif k in adict:
raise ValueError('keyword argument repeated')
else:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:map_dict; 3, parameters; 3, 4; 3, 5; 3, 7; 3, 10; 4, identifier:key_map; 5, list_splat_pattern; 5, 6; 6, identifier:dicts; 7, default_parameter; 7, 8; 7, 9; 8, identifier:copy; 9, False; 10, default_parameter; 10, 11; 10, 12; 11, identifier:ba... | def map_dict(key_map, *dicts, copy=False, base=None):
it = combine_dicts(*dicts).items()
get = key_map.get
return combine_dicts({get(k, k): v for k, v in it}, copy=copy, base=base) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:map_list; 3, parameters; 3, 4; 3, 5; 3, 7; 3, 10; 4, identifier:key_map; 5, list_splat_pattern; 5, 6; 6, identifier:inputs; 7, default_parameter; 7, 8; 7, 9; 8, identifier:copy; 9, False; 10, default_parameter; 10, 11; 10, 12; 11, identifier:b... | def map_list(key_map, *inputs, copy=False, base=None):
d = {} if base is None else base
for m, v in zip(key_map, inputs):
if isinstance(m, dict):
map_dict(m, v, base=d)
elif isinstance(m, list):
map_list(m, *v, base=d)
else:
d[m] = v
return combine... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:selector; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:keys; 5, identifier:dictionary; 6, default_parameter; 6, 7; 6, 8; 7, identifier:copy; 8, False; 9, default_parameter; 9, 10; 9, 11; 10, identifier:output_type; 11, string:'d... | def selector(keys, dictionary, copy=False, output_type='dict',
allow_miss=False):
if not allow_miss:
def check(key):
return True
else:
def check(key):
return key in dictionary
if output_type == 'list':
res = [dictionary[k] for k in keys if check(k... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:difference; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, list_splat_pattern; 5, 6; 6, identifier:others; 7, block; 7, 8; 7, 10; 7, 18; 7, 24; 7, 30; 7, 92; 7, 98; 8, expression_statement; 8, 9; 9, identifier:r; 10, expression_statement; 10... | def difference(self, *others):
r
result = self.__copy__()
_elements = result._elements
_total = result._total
for other in map(self._as_multiset, others):
for element, multiplicity in other.items():
if element in _elements:
old_mult... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:union; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, list_splat_pattern; 5, 6; 6, identifier:others; 7, block; 7, 8; 7, 10; 7, 18; 7, 24; 7, 30; 7, 77; 7, 83; 8, expression_statement; 8, 9; 9, identifier:r; 10, expression_statement; 10, 11;... | def union(self, *others):
r
result = self.__copy__()
_elements = result._elements
_total = result._total
for other in map(self._as_mapping, others):
for element, multiplicity in other.items():
old_multiplicity = _elements.get(element, 0)
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:intersection; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, list_splat_pattern; 5, 6; 6, identifier:others; 7, block; 7, 8; 7, 10; 7, 18; 7, 24; 7, 30; 7, 95; 7, 101; 8, expression_statement; 8, 9; 9, identifier:r; 10, expression_statement;... | def intersection(self, *others):
r
result = self.__copy__()
_elements = result._elements
_total = result._total
for other in map(self._as_mapping, others):
for element, multiplicity in list(_elements.items()):
new_multiplicity = other.get(element, 0)
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:symmetric_difference; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:other; 6, block; 6, 7; 6, 9; 6, 18; 6, 26; 6, 30; 6, 36; 6, 42; 6, 48; 6, 68; 6, 121; 6, 127; 7, expression_statement; 7, 8; 8, identifier:r; 9, expression_state... | def symmetric_difference(self, other):
r
other = self._as_multiset(other)
result = self.__class__()
_total = 0
_elements = result._elements
self_elements = self._elements
other_elements = other._elements
dist_elements = set(self_elements.keys()) | set(othe... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:times; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:factor; 6, block; 6, 7; 6, 18; 6, 28; 6, 36; 6, 42; 6, 52; 6, 58; 7, if_statement; 7, 8; 7, 11; 8, comparison_operator:==; 8, 9; 8, 10; 9, identifier:factor; 10, integer:0; 11,... | def times(self, factor):
if factor == 0:
return self.__class__()
if factor < 0:
raise ValueError('The factor must no be negative.')
result = self.__copy__()
_elements = result._elements
for element in _elements:
_elements[element] *= factor
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:union_update; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, list_splat_pattern; 5, 6; 6, identifier:others; 7, block; 7, 8; 7, 10; 7, 16; 7, 22; 7, 69; 8, expression_statement; 8, 9; 9, identifier:r; 10, expression_statement; 10, 11; 11, as... | def union_update(self, *others):
r
_elements = self._elements
_total = self._total
for other in map(self._as_mapping, others):
for element, multiplicity in other.items():
old_multiplicity = _elements.get(element, 0)
if multiplicity > old_multip... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:intersection_update; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, list_splat_pattern; 5, 6; 6, identifier:others; 7, block; 7, 8; 7, 10; 8, expression_statement; 8, 9; 9, identifier:r; 10, for_statement; 10, 11; 10, 12; 10, 19; 11, identif... | def intersection_update(self, *others):
r
for other in map(self._as_mapping, others):
for element, current_count in list(self.items()):
multiplicity = other.get(element, 0)
if multiplicity < current_count:
self[element] = multiplicity |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:difference_update; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, list_splat_pattern; 5, 6; 6, identifier:others; 7, block; 7, 8; 7, 10; 8, expression_statement; 8, 9; 9, identifier:r; 10, for_statement; 10, 11; 10, 12; 10, 19; 11, identifie... | def difference_update(self, *others):
r
for other in map(self._as_multiset, others):
for element, multiplicity in other.items():
self.discard(element, multiplicity) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:symmetric_difference_update; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:other; 6, block; 6, 7; 6, 9; 6, 18; 6, 38; 7, expression_statement; 7, 8; 8, identifier:r; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12;... | def symmetric_difference_update(self, other):
r
other = self._as_multiset(other)
elements = set(self.distinct_elements()) | set(other.distinct_elements())
for element in elements:
multiplicity = self[element]
other_count = other[element]
self[element] ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:times_update; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:factor; 6, block; 6, 7; 7, if_statement; 7, 8; 7, 11; 7, 17; 7, 28; 8, comparison_operator:<; 8, 9; 8, 10; 9, identifier:factor; 10, integer:0; 11, block; 11, 12; 12, ra... | def times_update(self, factor):
if factor < 0:
raise ValueError("The factor must not be negative.")
elif factor == 0:
self.clear()
else:
_elements = self._elements
for element in _elements:
_elements[element] *= factor
s... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:add; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:element; 6, default_parameter; 6, 7; 6, 8; 7, identifier:multiplicity; 8, integer:1; 9, block; 9, 10; 9, 20; 9, 28; 10, if_statement; 10, 11; 10, 14; 11, comparison_operato... | def add(self, element, multiplicity=1):
if multiplicity < 1:
raise ValueError("Multiplicity must be positive")
self._elements[element] += multiplicity
self._total += multiplicity |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:remove; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:element; 6, default_parameter; 6, 7; 6, 8; 7, identifier:multiplicity; 8, None; 9, block; 9, 10; 9, 16; 9, 23; 9, 33; 9, 79; 10, expression_statement; 10, 11; 11, assign... | def remove(self, element, multiplicity=None):
_elements = self._elements
if element not in _elements:
raise KeyError
old_multiplicity = _elements.get(element, 0)
if multiplicity is None or multiplicity >= old_multiplicity:
del _elements[element]
self._... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:discard; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:element; 6, default_parameter; 6, 7; 6, 8; 7, identifier:multiplicity; 8, None; 9, block; 9, 10; 9, 16; 10, expression_statement; 10, 11; 11, assignment; 11, 12; 11, 13... | def discard(self, element, multiplicity=None):
_elements = self._elements
if element in _elements:
old_multiplicity = _elements[element]
if multiplicity is None or multiplicity >= old_multiplicity:
del _elements[element]
self._total -= old_multipli... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:async_thread; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 10; 4, identifier:sol; 5, identifier:args; 6, identifier:node_attr; 7, identifier:node_id; 8, list_splat_pattern; 8, 9; 9, identifier:a; 10, dictionary_splat_pattern; 10, 11; 11, id... | def async_thread(sol, args, node_attr, node_id, *a, **kw):
executor = _get_executor(_executor_name(kw.get('executor', False), sol.dsp))
if not executor:
return sol._evaluate_node(args, node_attr, node_id, *a, **kw)
futures = args
if node_attr['type'] == 'data' and (
node_attr['wait_i... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:pivot; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:table; 5, identifier:left; 6, identifier:top; 7, identifier:value; 8, block; 8, 9; 8, 13; 8, 17; 8, 21; 8, 115; 8, 155; 8, 162; 8, 169; 8, 173; 8, 230; 9, expression_statement; 9, 10; ... | def pivot(table, left, top, value):
rs = {}
ysort = []
xsort = []
for row in table:
yaxis = tuple([row[c] for c in left])
if yaxis not in ysort: ysort.append(yaxis)
xaxis = tuple([row[c] for c in top])
if xaxis not in xsort: xsort.append(xaxis)
try:
rs... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:download_hrrr_for_gssha; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 11; 3, 14; 3, 17; 4, identifier:main_directory; 5, identifier:forecast_start_date_string; 6, identifier:forecast_start_hour_string; 7, default_parameter; 7, 8; 7, 9; 8, identif... | def download_hrrr_for_gssha(main_directory,
forecast_start_date_string,
forecast_start_hour_string,
leftlon=-180, rightlon=180,
toplat=90,bottomlat=-90):
out_directory = path.join(main_directory, forecast... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_convert_data_to_hourly; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:gssha_data_var; 6, block; 6, 7; 6, 30; 6, 39; 6, 43; 6, 392; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:time_step_hours; 10, bin... | def _convert_data_to_hourly(self, gssha_data_var):
time_step_hours = np.diff(self.data.time)[0]/np.timedelta64(1, 'h')
calc_function = self._get_calc_function(gssha_data_var)
resampled_data = None
if time_step_hours < 1:
resampled_data = self.data.resample('1H', dim='time',
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:get_sub_dsp; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:nodes_bunch; 6, default_parameter; 6, 7; 6, 8; 7, identifier:edges_bunch; 8, None; 9, block; 9, 10; 9, 27; 9, 49; 9, 63; 9, 77; 9, 85; 9, 122; 9, 137; 9, 173; 9, 17... | def get_sub_dsp(self, nodes_bunch, edges_bunch=None):
nodes_bunch = [self.get_node(u)[1][0] for u in nodes_bunch]
sub_dsp = self.copy_structure(
dmap=self.dmap.subgraph(nodes_bunch).copy()
)
nodes, dmap_out_degree = sub_dsp.nodes, sub_dsp.dmap.out_degree
dmap_dv, dmap... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:blue; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:memo; 7, None; 8, block; 8, 9; 8, 18; 8, 27; 8, 35; 8, 45; 8, 75; 8, 81; 8, 90; 8, 106; 8, 144; 8, 301; 9, expression_statement; 9, 10; 10, ass... | def blue(self, memo=None):
memo = {} if memo is None else memo
if self in memo:
return memo[self]
from .utils.dsp import map_list
from .utils.blue import BlueDispatcher, _parent_blue
memo[self] = blue = BlueDispatcher(
executor=self.executor, name=self.nam... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:findOutlet; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:shapefile_path; 6, block; 6, 7; 6, 12; 6, 21; 6, 30; 6, 38; 6, 46; 6, 53; 6, 63; 6, 72; 6, 80; 6, 87; 6, 98; 6, 106; 6, 117; 6, 125; 6, 145; 6, 151; 6, 155; 6, 351; 6, 361... | def findOutlet(self, shapefile_path):
check_watershed_boundary_geometry(shapefile_path)
shapefile = ogr.Open(shapefile_path)
source_layer = shapefile.GetLayer(0)
source_lyr_proj = source_layer.GetSpatialRef()
osr_geographic_proj = osr.SpatialReference()
osr_geographic_pro... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:_write; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:session; 6, identifier:openFile; 7, identifier:replaceParamFile; 8, block; 8, 9; 8, 15; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identif... | def _write(self, session, openFile, replaceParamFile):
events = self.precipEvents
for event in events:
openFile.write('EVENT "%s"\nNRGAG %s\nNRPDS %s\n' % (event.description, event.nrGag, event.nrPds))
if event.nrGag > 0:
values = event.values
valL... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:valueWritePreprocessor; 3, parameters; 3, 4; 3, 5; 4, identifier:valueString; 5, default_parameter; 5, 6; 5, 7; 6, identifier:replaceParamsFile; 7, None; 8, block; 8, 9; 8, 26; 8, 30; 8, 90; 9, if_statement; 9, 10; 9, 16; 10, comparison_operato... | def valueWritePreprocessor(valueString, replaceParamsFile=None):
if type(valueString) is bool:
log.warning("Only numerical variable types can be handled by the valueReadPreprocessor function.")
return valueString
variableString = valueString
if replaceParamsFile is not None:
if varia... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:_createGsshaPyObjects; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 4, identifier:self; 5, identifier:mapTables; 6, identifier:indexMaps; 7, identifier:replaceParamFile; 8, identifier:directory; 9, identifier:session; 10, i... | def _createGsshaPyObjects(self, mapTables, indexMaps, replaceParamFile, directory, session, spatial, spatialReferenceID):
for mt in mapTables:
try:
if mt['indexMapName'] is not None:
indexMaps[mt['indexMapName']]
mapTable = MapTable(name=mt['name']... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:_valuePivot; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:self; 5, identifier:session; 6, identifier:mapTable; 7, identifier:contaminant; 8, identifier:replaceParaFile; 9, block; 9, 10; 9, 60; 9, 65; 9, 81; 9, 85; 9, 89; 9, 345; 9... | def _valuePivot(self, session, mapTable, contaminant, replaceParaFile):
indexes = session.query(MTIndex). \
join(MTValue.index). \
filter(MTValue.mapTable == mapTable). \
filter(MTValue.contaminant == contaminant). \
order_by(MTIndex.index). \
all()
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:addRoughnessMapFromLandUse; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 11; 4, identifier:self; 5, identifier:name; 6, identifier:session; 7, identifier:land_use_grid; 8, default_parameter; 8, 9; 8, 10; 9, identifier:land_use_to_roughness_... | def addRoughnessMapFromLandUse(self, name,
session,
land_use_grid,
land_use_to_roughness_table=None,
land_use_grid_id=None,
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:result; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:timeout; 7, None; 8, block; 8, 9; 8, 19; 8, 29; 8, 102; 8, 184; 8, 196; 8, 262; 8, 272; 9, expression_statement; 9, 10; 10, assignment; 10, 1... | def result(self, timeout=None):
it, exceptions, future_lists = [], [], []
from concurrent.futures import Future, wait as wait_fut
def update(fut, data, key):
if isinstance(fut, Future):
it.append((fut, data, key))
elif isinstance(fut, AsyncList) and fut no... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:_set_data_node_output; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 11; 4, identifier:self; 5, identifier:node_id; 6, identifier:node_attr; 7, identifier:no_call; 8, default_parameter; 8, 9; 8, 10; 9, identifier:next_nds; 10, None; 11, dict... | def _set_data_node_output(self, node_id, node_attr, no_call, next_nds=None,
**kw):
est, wait_in = self._get_node_estimations(node_attr, node_id)
if not no_call:
if node_id is PLOT:
est = est.copy()
est[PLOT] = {'value': {'obj': se... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:_set_function_node_output; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 11; 4, identifier:self; 5, identifier:node_id; 6, identifier:node_attr; 7, identifier:no_call; 8, default_parameter; 8, 9; 8, 10; 9, identifier:next_nds; 10, None; 11, ... | def _set_function_node_output(self, node_id, node_attr, no_call,
next_nds=None, **kw):
o_nds, dist = node_attr['outputs'], self.dist
output_nodes = next_nds or set(self._succ[node_id]).difference(dist)
if not output_nodes:
self.workflow.remove_node(n... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 19; 2, function_name:_add_initial_value; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 3, 16; 4, identifier:self; 5, identifier:data_id; 6, identifier:value; 7, default_parameter; 7, 8; 7, 9; 8, identifier:initial_dist; 9, float:0.0; 10, default_parameter; ... | def _add_initial_value(self, data_id, value, initial_dist=0.0,
fringe=None, check_cutoff=None, no_call=None):
nodes, seen, edge_weight = self.nodes, self.seen, self._edge_length
wf_remove_edge, check_wait_in = self._wf_remove_edge, self.check_wait_in
wf_add_edge, dsp_i... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:_see_node; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:self; 5, identifier:node_id; 6, identifier:fringe; 7, identifier:dist; 8, default_parameter; 8, 9; 8, 10; 9, identifier:w_wait_in; 10, integer:0; 11, block; 11, 12; 11, 24; ... | def _see_node(self, node_id, fringe, dist, w_wait_in=0):
seen, dists = self.seen, self.dist
wait_in = self.nodes[node_id]['wait_inputs']
self._update_meeting(node_id, dist)
if self.check_wait_in(wait_in, node_id):
pass
elif node_id in dists:
if dist < dist... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:tick; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:events; 6, block; 6, 7; 6, 13; 6, 71; 6, 274; 6, 278; 6, 402; 7, expression_statement; 7, 8; 8, call; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:self; 11, identifie... | def tick(self, events):
self.add_new_threads()
if self.drag_sprite:
(mx, my) = self.screen.get_mouse_pos()
(ox, oy) = self.drag_offset
new_position = (mx + ox, my + oy)
if self.drag_sprite.position != new_position:
self.has_dragged = True
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:evaluate; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:s; 6, identifier:value; 7, default_parameter; 7, 8; 7, 9; 8, identifier:insert; 9, None; 10, block; 10, 11; 10, 20; 10, 29; 10, 208; 10, 414; 11, assert_stateme... | def evaluate(self, s, value, insert=None):
assert not isinstance(value, kurt.Script)
if insert and insert.unevaluated:
return value
if isinstance(value, kurt.Block):
if value.type.shape == "hat":
return []
if value.type not in self.COMMANDS:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:_write; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:session; 6, identifier:openFile; 7, identifier:maskMap; 8, block; 8, 9; 8, 13; 8, 20; 8, 80; 8, 94; 8, 108; 8, 122; 8, 136; 8, 140; 8, 200; 8, 269; 9, expression_s... | def _write(self, session, openFile, maskMap):
FIRST_VALUE_INDEX = 12
openFile.write('DATASET\r\n')
if self.type == self.SCALAR_TYPE:
openFile.write('OBJTYPE {0}\r\n'.format(self.objectType))
openFile.write('BEGSCL\r\n')
elif self.type == self.VECTOR_TYPE:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:get_batch; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:sentences; 5, identifier:token_dict; 6, default_parameter; 6, 7; 6, 8; 7, identifier:ignore_case; 8, False; 9, default_parameter; 9, 10; 9, 11; 10, identifier:unk_index; 11... | def get_batch(sentences,
token_dict,
ignore_case=False,
unk_index=1,
eos_index=2):
batch_size = len(sentences)
max_sentence_len = max(map(len, sentences))
inputs = [[0] * max_sentence_len for _ in range(batch_size)]
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:get_gene_info; 3, parameters; 3, 4; 3, 7; 4, default_parameter; 4, 5; 4, 6; 5, identifier:ensembl_ids; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:hgnc_symbols; 9, None; 10, block; 10, 11; 10, 24; 10, 37; 10, 41; 10, 45; 10, 134; ... | def get_gene_info(ensembl_ids=None, hgnc_symbols=None):
uniq_ensembl_ids = set(ensembl_id for ensembl_id in (ensembl_ids or []))
uniq_hgnc_symbols = set(hgnc_symbol for hgnc_symbol in (hgnc_symbols or []))
genes = []
gene_data = []
if uniq_ensembl_ids:
for ensembl_id in uniq_ensembl_ids:
... |
0, module; 0, 1; 0, 13; 0, 17; 0, 29; 0, 33; 0, 42; 0, 46; 0, 60; 0, 109; 0, 121; 0, 135; 0, 146; 0, 150; 0, 376; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:parse_mapping; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:map_path; 6, default_parameter; 6, 7; 6, 8; 7, identifier:... | def parse_mapping(self, map_path, source=None, dotfiles=None):
include_re = r
include_re = re.compile(include_re, re.I)
mapping_re = r
mapping_re = re.compile(mapping_re)
filename = None
map_path = path.realpath(path.expanduser(map_path))
if path.isfile(map_path):
fil... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_add_compounds; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:variant_obj; 6, identifier:info_dict; 7, block; 7, 8; 7, 12; 7, 21; 7, 106; 7, 123; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:co... | def _add_compounds(self, variant_obj, info_dict):
compound_list = []
compound_entry = info_dict.get('Compounds')
if compound_entry:
for family_annotation in compound_entry.split(','):
compounds = family_annotation.split(':')[-1].split('|')
for compound... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:dump_xml; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:props; 5, identifier:fp; 6, default_parameter; 6, 7; 6, 8; 7, identifier:comment; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:encoding; 11, string:'UTF-8'; 1... | def dump_xml(props, fp, comment=None, encoding='UTF-8', sort_keys=False):
fp = codecs.lookup(encoding).streamwriter(fp, errors='xmlcharrefreplace')
print('<?xml version="1.0" encoding={0} standalone="no"?>'
.format(quoteattr(encoding)), file=fp)
for s in _stream_xml(props, comment, sort_keys):
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:dumps_xml; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:props; 5, default_parameter; 5, 6; 5, 7; 6, identifier:comment; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:sort_keys; 10, False; 11, block; 11, 12; 12, return_statement; ... | def dumps_xml(props, comment=None, sort_keys=False):
return ''.join(s + '\n' for s in _stream_xml(props, comment, sort_keys)) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:gene_list; 3, parameters; 3, 4; 4, default_parameter; 4, 5; 4, 6; 5, identifier:list_id; 6, None; 7, block; 7, 8; 7, 24; 7, 76; 7, 130; 7, 267; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:all_case_ids; 11, list_co... | def gene_list(list_id=None):
all_case_ids = [case.case_id for case in app.db.cases()]
if list_id:
genelist_obj = app.db.gene_list(list_id)
case_ids = [case.case_id for case in app.db.cases()
if case not in genelist_obj.cases]
if genelist_obj is None:
retur... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_functarguments; 3, parameters; 3, 4; 4, identifier:func; 5, block; 5, 6; 5, 15; 5, 75; 5, 91; 5, 97; 5, 101; 5, 108; 5, 153; 5, 288; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:argspec; 9, call; 9, 10; 9, 13; 10,... | def get_functarguments(func):
argspec = inspect.getargspec(func)
if argspec.defaults is not None:
args = argspec.args[:-len(argspec.defaults)]
kwargs = dict(
zip(argspec.args[-len(argspec.defaults):], argspec.defaults))
else:
args = argspec.args
kwargs = {}
if... |
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; 3, 8; 4, identifier:ctx; 5, identifier:variant_source; 6, identifier:family_file; 7, identifier:family_type; 8, identifier:root; 9, block; 9, 10; 9, 32; 9, 55; 9, 67; 9, 79; 9, 91; 9, 115; 9, 139; 9,... | def load(ctx, variant_source, family_file, family_type, root):
root = root or ctx.obj.get('root') or os.path.expanduser("~/.puzzle")
if os.path.isfile(root):
logger.error("'root' can't be a file")
ctx.abort()
logger.info("Root directory is: {}".format(root))
db_path = os.path.join(root, ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:toposort; 3, parameters; 3, 4; 3, 5; 4, identifier:graph; 5, default_parameter; 5, 6; 5, 7; 6, identifier:pick_first; 7, string:'head'; 8, block; 8, 9; 8, 13; 8, 54; 8, 59; 8, 63; 8, 69; 8, 155; 8, 173; 9, expression_statement; 9, 10; 10, assig... | def toposort(graph, pick_first='head'):
in_deg = {}
for node, next_nodes in six.iteritems(graph):
for next_node in [next_nodes.head_node, next_nodes.update_node]:
if next_node is None:
continue
in_deg[next_node] = in_deg.get(next_node, 0) + 1
stk = [FIRST]
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.