sequence stringlengths 492 15.9k | code stringlengths 75 8.58k |
|---|---|
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_serve_runs; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:request; 6, block; 6, 7; 6, 99; 7, if_statement; 7, 8; 7, 11; 7, 39; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:_db_connection_provider; 11, block; 11,... | def _serve_runs(self, request):
if self._db_connection_provider:
db = self._db_connection_provider()
cursor = db.execute('''
SELECT
run_name,
started_time IS NULL as started_time_nulls_last,
started_time
FROM Runs
ORDER BY started_time_nulls_last, st... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_fetch_events_files_on_disk; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 21; 5, 36; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:all_files; 9, call; 9, 10; 9, 17; 10, attribute; 10, 11; 10, 16; 11, att... | def _fetch_events_files_on_disk(self):
all_files = tf.io.gfile.listdir(self._events_directory)
relevant_files = [
file_name for file_name in all_files
if _DEBUGGER_EVENTS_FILE_NAME_REGEX.match(file_name)
]
return sorted(relevant_files, key=self._obtain_file_index) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:Cleanse; 3, parameters; 3, 4; 3, 5; 4, identifier:obj; 5, default_parameter; 5, 6; 5, 7; 6, identifier:encoding; 7, string:'utf-8'; 8, block; 8, 9; 9, if_statement; 9, 10; 9, 15; 9, 18; 9, 53; 9, 70; 9, 89; 9, 109; 9, 138; 10, call; 10, 11; 10,... | def Cleanse(obj, encoding='utf-8'):
if isinstance(obj, int):
return obj
elif isinstance(obj, float):
if obj == _INFINITY:
return 'Infinity'
elif obj == _NEGATIVE_INFINITY:
return '-Infinity'
elif math.isnan(obj):
return 'NaN'
else:
return obj
elif isinstance(obj, bytes)... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_sort; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:session_groups; 6, block; 6, 7; 6, 21; 7, expression_statement; 7, 8; 8, call; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:session_groups; 11, identifier:sort; 12, ... | def _sort(self, session_groups):
session_groups.sort(key=operator.attrgetter('name'))
for col_param, extractor in reversed(list(zip(self._request.col_params,
self._extractors))):
if col_param.order == api_pb2.ORDER_UNSPECIFIED:
continue
if co... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sort; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:search; 6, block; 6, 7; 6, 24; 7, if_statement; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:_sort; 11, block; 11, 12; 12, expression_statement; 12... | def sort(self, search):
if self._sort:
search = search.sort(*self._sort)
return search |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:competitions_list; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:group; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:category; 10, None; 11, default_param... | def competitions_list(self,
group=None,
category=None,
sort_by=None,
page=1,
search=None):
valid_groups = ['general', 'entered', 'inClass']
if group and group not in valid_gr... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 23; 2, function_name:competitions_list_cli; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:group; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:category; 10, None; 11, de... | def competitions_list_cli(self,
group=None,
category=None,
sort_by=None,
page=1,
search=None,
csv_display=False):
competitions = sel... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 32; 2, function_name:dataset_list; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 3, 29; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sort_by; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:size; 10, No... | def dataset_list(self,
sort_by=None,
size=None,
file_type=None,
license_name=None,
tag_ids=None,
search=None,
user=None,
mine=False,
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 35; 2, function_name:dataset_list_cli; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 3, 29; 3, 32; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sort_by; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:s... | def dataset_list_cli(self,
sort_by=None,
size=None,
file_type=None,
license_name=None,
tag_ids=None,
search=None,
user=None,
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 41; 2, function_name:kernels_list; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 3, 29; 3, 32; 3, 35; 3, 38; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:page; 7, integer:1; 8, default_parameter; 8, 9; 8, 10; 9, ... | def kernels_list(self,
page=1,
page_size=20,
dataset=None,
competition=None,
parent_kernel=None,
search=None,
mine=False,
user=None,
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 2, function_name:_get_salt_params; 3, parameters; 4, block; 4, 5; 4, 7; 4, 15; 4, 23; 4, 27; 4, 189; 5, expression_statement; 5, 6; 6, string:'''
Try to get all sort of parameters for Server Density server info.
NOTE: Missing publicDNS and publicIPs par... | def _get_salt_params():
'''
Try to get all sort of parameters for Server Density server info.
NOTE: Missing publicDNS and publicIPs parameters. There might be way of
getting them with salt-cloud.
'''
all_stats = __salt__['status.all_status']()
all_grains = __salt__['grains.items']()
para... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:zcard; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:key; 5, default_parameter; 5, 6; 5, 7; 6, identifier:host; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:port; 10, None; 11, default_parameter; 11, 12; 11, 13; 12,... | def zcard(key, host=None, port=None, db=None, password=None):
'''
Get the length of a sorted set in Redis
CLI Example:
.. code-block:: bash
salt '*' redis.zcard foo_sorted
'''
server = _connect(host, port, db, password)
return server.zcard(key) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 19; 2, function_name:zrange; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 3, 16; 4, identifier:key; 5, identifier:start; 6, identifier:stop; 7, default_parameter; 7, 8; 7, 9; 8, identifier:host; 9, None; 10, default_parameter; 10, 11; 10, 12; 11, identifie... | def zrange(key, start, stop, host=None, port=None, db=None, password=None):
'''
Get a range of values from a sorted set in Redis by index
CLI Example:
.. code-block:: bash
salt '*' redis.zrange foo_sorted 0 10
'''
server = _connect(host, port, db, password)
return server.zrange(key, ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 19; 2, function_name:get_list; 3, parameters; 3, 4; 3, 7; 3, 10; 3, 13; 3, 16; 4, default_parameter; 4, 5; 4, 6; 5, identifier:list_type; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:search_term; 9, None; 10, default_parameter; 10, 11; 10, 12; 11, iden... | def get_list(list_type=None,
search_term=None,
page=None,
page_size=None,
sort_by=None):
'''
Returns a list of domains for the particular user as a list of objects
offset by ``page`` length of ``page_size``
list_type : ALL
One of ``ALL``, ``EXP... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_sort_policy; 3, parameters; 3, 4; 4, identifier:doc; 5, block; 5, 6; 5, 8; 5, 57; 6, expression_statement; 6, 7; 7, string:'''
List-type sub-items in policies don't happen to be order-sensitive, but
compare operations will render them ... | def _sort_policy(doc):
'''
List-type sub-items in policies don't happen to be order-sensitive, but
compare operations will render them unequal, leading to non-idempotent
state runs. We'll sort any list-type subitems before comparison to reduce
the likelihood of false negatives.
'''
if isins... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_resolve_datacenter; 3, parameters; 3, 4; 3, 5; 4, identifier:dc; 5, identifier:pillarenv; 6, block; 6, 7; 6, 9; 6, 17; 6, 40; 6, 51; 6, 59; 6, 82; 6, 133; 7, expression_statement; 7, 8; 8, string:'''
If ``dc`` is a string - return it as is... | def _resolve_datacenter(dc, pillarenv):
'''
If ``dc`` is a string - return it as is.
If it's a dict then sort it in descending order by key length and try
to use keys as RegEx patterns to match against ``pillarenv``.
The value for matched pattern should be a string (that can use
``str.format`` s... |
0, module; 0, 1; 1, ERROR; 1, 2; 1, 169; 1, 176; 2, function_definition; 2, 3; 2, 4; 2, 9; 3, function_name:read_conf; 4, parameters; 4, 5; 4, 6; 5, identifier:conf_file; 6, default_parameter; 6, 7; 6, 8; 7, identifier:out_format; 8, string:'simple'; 9, block; 9, 10; 9, 12; 9, 16; 9, 20; 10, expression_statement; 10, 1... | def read_conf(conf_file, out_format='simple'):
'''
Read in an LXC configuration file. By default returns a simple, unsorted
dict, but can also return a more detailed structure including blank lines
and comments.
out_format:
set to 'simple' if you need the old and unsupported behavior.
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:sort_top_targets; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:top; 6, identifier:orders; 7, block; 7, 8; 7, 10; 7, 19; 7, 61; 8, expression_statement; 8, 9; 9, string:'''
Returns the sorted high data from the merg... | def sort_top_targets(self, top, orders):
'''
Returns the sorted high data from the merged top files
'''
sorted_top = collections.defaultdict(OrderedDict)
for saltenv, targets in six.iteritems(top):
sorted_targets = sorted(targets,
key=lambda target... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 47; 2, function_name:subvolume_list; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 3, 29; 3, 32; 3, 35; 3, 38; 3, 41; 3, 44; 4, identifier:path; 5, default_parameter; 5, 6; 5, 7; 6, identifier:parent_id; 7, False; 8, default_parameter;... | def subvolume_list(path, parent_id=False, absolute=False,
ogeneration=False, generation=False,
subvolumes=False, uuid=False, parent_uuid=False,
sent_subvolume_uuid=False, snapshots=False,
readonly=False, deleted=False, generation_cmp=None,
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:diff; 3, parameters; 3, 4; 3, 6; 4, list_splat_pattern; 4, 5; 5, identifier:args; 6, dictionary_splat_pattern; 6, 7; 7, identifier:kwargs; 8, block; 8, 9; 8, 11; 8, 14; 8, 24; 8, 28; 8, 237; 9, expression_statement; 9, 10; 10, string:'''
Re... | def diff(*args, **kwargs):
'''
Return the DIFFERENCE of the result sets returned by each matching minion
pool
.. versionadded:: 2014.7.0
These pools are determined from the aggregated and sorted results of
a salt command.
This command displays the "diffs" as a series of 2-way differences --
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:_get_pool_results; 3, parameters; 3, 4; 3, 6; 4, list_splat_pattern; 4, 5; 5, identifier:args; 6, dictionary_splat_pattern; 6, 7; 7, identifier:kwargs; 8, block; 8, 9; 8, 11; 8, 14; 8, 20; 8, 26; 8, 30; 8, 40; 8, 46; 8, 56; 8, 67; 8, 94; 8, 107... | def _get_pool_results(*args, **kwargs):
'''
A helper function which returns a dictionary of minion pools along with
their matching result sets.
Useful for developing other "survey style" functions.
Optionally accepts a "survey_sort=up" or "survey_sort=down" kwargs for
specifying sort order.
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:list_; 3, parameters; 3, 4; 3, 7; 4, default_parameter; 4, 5; 4, 6; 5, identifier:name; 6, None; 7, dictionary_splat_pattern; 7, 8; 8, identifier:kwargs; 9, block; 9, 10; 9, 12; 9, 18; 9, 28; 9, 45; 9, 57; 9, 65; 9, 70; 9, 74; 9, 90; 9, 118; 9,... | def list_(name=None, **kwargs):
'''
Return a list of all datasets or a specified dataset on the system and the
values of their used, available, referenced, and mountpoint properties.
name : string
name of dataset, volume, or snapshot
recursive : boolean
recursively list children
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:list_users; 3, parameters; 3, 4; 4, default_parameter; 4, 5; 4, 6; 5, identifier:order_by; 6, string:'id'; 7, block; 7, 8; 7, 10; 7, 14; 7, 28; 7, 37; 7, 45; 7, 114; 8, expression_statement; 8, 9; 9, string:'''
Show all users for this compa... | def list_users(order_by='id'):
'''
Show all users for this company.
CLI Example:
salt myminion bamboohr.list_users
By default, the return data will be keyed by ID. However, it can be ordered
by any other field. Keep in mind that if the field that is chosen contains
duplicate values (i.e.... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:key_value; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:minion_id; 5, identifier:pillar; 6, default_parameter; 6, 7; 6, 8; 7, identifier:pillar_key; 8, string:'redis_pillar'; 9, block; 9, 10; 9, 12; 9, 21; 9, 134; 10, expression_statement; 10... | def key_value(minion_id,
pillar,
pillar_key='redis_pillar'):
'''
Looks for key in redis matching minion_id, returns a structure based on the
data type of the redis key. String for string type, dict for hash type and
lists for lists, sets and sorted sets.
pillar_key
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_cmp_version; 3, parameters; 3, 4; 3, 5; 4, identifier:item1; 5, identifier:item2; 6, block; 6, 7; 6, 9; 6, 16; 6, 23; 6, 31; 6, 38; 7, expression_statement; 7, 8; 8, string:'''
Compare function for package version sorting
'''; 9, expre... | def _cmp_version(item1, item2):
'''
Compare function for package version sorting
'''
vers1 = _LooseVersion(item1)
vers2 = _LooseVersion(item2)
if vers1 < vers2:
return -1
if vers1 > vers2:
return 1
return 0 |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:list_snapshots; 3, parameters; 3, 4; 3, 7; 4, default_parameter; 4, 5; 4, 6; 5, identifier:config_path; 6, identifier:_DEFAULT_CONFIG_PATH; 7, default_parameter; 7, 8; 7, 9; 8, identifier:sort_by_time; 9, False; 10, block; 10, 11; 10, 13; 10, ... | def list_snapshots(config_path=_DEFAULT_CONFIG_PATH, sort_by_time=False):
'''
Get a list of all the existing snapshots.
:param str config_path: The path to the configuration file for the aptly instance.
:param bool sort_by_time: Whether to sort by creation time instead of by name.
:return: A list of... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:render_value; 3, parameters; 3, 4; 4, identifier:value; 5, block; 5, 6; 6, if_statement; 6, 7; 6, 12; 6, 30; 6, 74; 7, call; 7, 8; 7, 9; 8, identifier:isinstance; 9, argument_list; 9, 10; 9, 11; 10, identifier:value; 11, identifier:list; 12, bl... | def render_value(value):
if isinstance(value, list):
return '[' + ', '.join(render_value(v) for v in value) + ']'
elif isinstance(value, dict):
return (
'{' +
', '.join('{k!r}: {v}'.format(
k=k, v=render_value(v)) for k, v in sorted(value.items())) +
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_sort_schema; 3, parameters; 3, 4; 4, identifier:schema; 5, block; 5, 6; 6, if_statement; 6, 7; 6, 12; 6, 69; 6, 117; 7, call; 7, 8; 7, 9; 8, identifier:isinstance; 9, argument_list; 9, 10; 9, 11; 10, identifier:schema; 11, identifier:dict; 12,... | def _sort_schema(schema):
if isinstance(schema, dict):
for k, v in sorted(schema.items()):
if isinstance(v, dict):
yield k, OrderedDict(_sort_schema(v))
elif isinstance(v, list):
yield k, list(_sort_schema(v))
else:
yield k,... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:_sort_handlers; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:cls; 5, identifier:signals; 6, identifier:handlers; 7, identifier:configs; 8, block; 8, 9; 8, 78; 8, 87; 8, 94; 8, 144; 8, 180; 9, function_definition; 9, 10; 9, 11; 9, 14; 10... | def _sort_handlers(cls, signals, handlers, configs):
def macro_precedence_sorter(flags, hname):
data = configs[hname]
topdown_sort = SignalOptions.SORT_TOPDOWN in flags
if topdown_sort:
level = levels_count - 1 - data['level']
else:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:_radixPass; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:a; 5, identifier:b; 6, identifier:r; 7, identifier:n; 8, identifier:K; 9, block; 9, 10; 9, 24; 9, 41; 9, 45; 9, 70; 10, expression_statement; 10, 11; 11, assignment; 11, 12;... | def _radixPass(a, b, r, n, K):
c = _array("i", [0] * (K + 1))
for i in range(n):
c[r[a[i]]] += 1
sum = 0
for i in range(K + 1):
t = c[i]
c[i] = sum
sum += t
for a_i in a[:n]:
b[c[r[a_i]]] = a_i
c[r[a_i]] += 1 |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:save_yaml; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:dictionary; 5, identifier:path; 6, default_parameter; 6, 7; 6, 8; 7, identifier:pretty; 8, False; 9, default_parameter; 9, 10; 9, 11; 10, identifier:sortkeys; 11, False; 12, block... | def save_yaml(dictionary, path, pretty=False, sortkeys=False):
if sortkeys:
dictionary = dict(dictionary)
with open(path, 'w') as f:
if pretty:
pyaml.dump(dictionary, f)
else:
yaml.dump(dictionary, f, default_flow_style=None, Dumper=yamlloader.ordereddict.CDumper) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:save_json; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:dictionary; 5, identifier:path; 6, default_parameter; 6, 7; 6, 8; 7, identifier:pretty; 8, False; 9, default_parameter; 9, 10; 9, 11; 10, identifier:sortkeys; 11, False; 12, block... | def save_json(dictionary, path, pretty=False, sortkeys=False):
with open(path, 'w') as f:
if pretty:
indent = 2
separators = (',', ': ')
else:
indent = None
separators = (', ', ': ')
json.dump(dictionary, f, indent=indent, sort_keys=sortkeys, s... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:save_json; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:val; 5, default_parameter; 5, 6; 5, 7; 6, identifier:pretty; 7, False; 8, default_parameter; 8, 9; 8, 10; 9, identifier:sort; 10, True; 11, default_parameter; 11, 12; 11, 13; 12,... | def save_json(val, pretty=False, sort=True, encoder=None):
if encoder is None:
encoder = DateTimeEncoder
if pretty:
data = json.dumps(
val,
indent=4,
separators=(',', ': '),
sort_keys=sort,
cls=encoder
)
else:
data =... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 19; 2, function_name:revdocs2reverts; 3, parameters; 3, 4; 3, 5; 3, 10; 3, 13; 3, 16; 4, identifier:rev_docs; 5, default_parameter; 5, 6; 5, 7; 6, identifier:radius; 7, attribute; 7, 8; 7, 9; 8, identifier:defaults; 9, identifier:RADIUS; 10, default_parameter; 10,... | def revdocs2reverts(rev_docs, radius=defaults.RADIUS, use_sha1=False,
resort=False, verbose=False):
page_rev_docs = groupby(rev_docs, lambda rd: rd.get('page'))
for page_doc, rev_docs in page_rev_docs:
if verbose:
sys.stderr.write(page_doc.get('title') + ": ")
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:dsort; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:fname; 5, identifier:order; 6, default_parameter; 6, 7; 6, 8; 7, identifier:has_header; 8, True; 9, default_parameter; 9, 10; 9, 11; 10, identifier:frow; 11, integer:0; 12, def... | def dsort(fname, order, has_header=True, frow=0, ofname=None):
r
ofname = fname if ofname is None else ofname
obj = CsvFile(fname=fname, has_header=has_header, frow=frow)
obj.dsort(order)
obj.write(fname=ofname, header=has_header, append=False) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:dsort; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:order; 6, block; 6, 7; 6, 9; 6, 21; 6, 40; 6, 60; 6, 64; 6, 111; 7, expression_statement; 7, 8; 8, identifier:r; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12;... | def dsort(self, order):
r
order = order if isinstance(order, list) else [order]
norder = [{item: "A"} if not isinstance(item, dict) else item for item in order]
self._in_header([list(item.keys())[0] for item in norder])
clist = []
for nitem in norder:
for key,... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 30; 2, function_name:get_points_and_weights; 3, parameters; 3, 4; 3, 17; 3, 21; 3, 24; 3, 27; 4, default_parameter; 4, 5; 4, 6; 5, identifier:w_func; 6, lambda; 6, 7; 6, 9; 7, lambda_parameters; 7, 8; 8, identifier:x; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; ... | def get_points_and_weights(w_func=lambda x : np.ones(x.shape),
left=-1.0, right=1.0, num_points=5, n=4096):
dx = (float(right)-left)/n
z = np.hstack(np.linspace(left+0.5*dx, right-0.5*dx, n))
w = dx*w_func(z)
(a, b) = discrete_gautschi(z, w, num_points)
alpha = a
beta = np.sqrt(b)
J =... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:apply_to; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:x; 6, default_parameter; 6, 7; 6, 8; 7, identifier:columns; 8, False; 9, block; 9, 10; 9, 51; 10, if_statement; 10, 11; 10, 37; 11, boolean_operator:and; 11, 12; 11, 3... | def apply_to(self, x, columns=False):
if isinstance(x, np.ndarray) and len(x.shape) == 2 and x.shape[0] == 3 and columns:
return x + self.t.reshape((3,1))
if isinstance(x, np.ndarray) and (x.shape == (3, ) or (len(x.shape) == 2 and x.shape[1] == 3)) and not columns:
return x + se... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:apply_to; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:x; 6, default_parameter; 6, 7; 6, 8; 7, identifier:columns; 8, False; 9, block; 9, 10; 9, 48; 10, if_statement; 10, 11; 10, 37; 11, boolean_operator:and; 11, 12; 11, 3... | def apply_to(self, x, columns=False):
if isinstance(x, np.ndarray) and len(x.shape) == 2 and x.shape[0] == 3 and columns:
return np.dot(self.r, x)
if isinstance(x, np.ndarray) and (x.shape == (3, ) or (len(x.shape) == 2 and x.shape[1] == 3)) and not columns:
return np.dot(x, self... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:canonical_order; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 46; 5, 99; 5, 108; 5, 142; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:starting_vertex; 9, subscript; 9, 10; 9, 44; 10, call; 10, 11; 10, 1... | def canonical_order(self):
starting_vertex = max(
(
-len(self.equivalent_vertices[vertex]),
self.get_vertex_string(vertex),
self.vertex_fingerprints[vertex].tobytes(),
vertex
) for vertex in self.central_vertices
)[-... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:get_subgraph; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:subvertices; 6, default_parameter; 6, 7; 6, 8; 7, identifier:normalize; 8, False; 9, block; 9, 10; 9, 261; 10, if_statement; 10, 11; 10, 12; 10, 192; 11, identifie... | def get_subgraph(self, subvertices, normalize=False):
if normalize:
revorder = dict((j, i) for i, j in enumerate(subvertices))
new_edges = []
old_edge_indexes = []
for counter, (i, j) in enumerate(self.edges):
new_i = revorder.get(i)
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_closed_cycles; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 10; 5, 23; 5, 44; 5, 48; 5, 154; 5, 160; 5, 173; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:closed_cycles; 9, list:[]; 10, expression_st... | def get_closed_cycles(self):
closed_cycles = []
todo = set(self.forward.keys())
if todo != set(self.forward.values()):
raise GraphError("The subject and pattern graph must have the same "
"numbering.")
current_vertex = None
while len(todo)... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sorted_exists; 3, parameters; 3, 4; 3, 5; 4, identifier:values; 5, identifier:x; 6, block; 6, 7; 6, 15; 6, 23; 6, 34; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:i; 10, call; 10, 11; 10, 12; 11, identifier:bisect_le... | def sorted_exists(values, x):
i = bisect_left(values, x)
j = bisect_right(values, x)
exists = x in values[i:j]
return exists, i |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sorted_index; 3, parameters; 3, 4; 3, 5; 4, identifier:values; 5, identifier:x; 6, block; 6, 7; 6, 15; 6, 23; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:i; 10, call; 10, 11; 10, 12; 11, identifier:bisect_left; 12, ... | def sorted_index(values, x):
i = bisect_left(values, x)
j = bisect_right(values, x)
return values[i:j].index(x) + i |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort_index; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 15; 5, 45; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:sort; 9, call; 9, 10; 9, 11; 10, identifier:sorted_list_indexes; 11, argument_list; 11, 1... | def sort_index(self):
sort = sorted_list_indexes(self._index)
self._index = blist([self._index[x] for x in sort]) if self._blist else [self._index[x] for x in sort]
self._data = blist([self._data[x] for x in sort]) if self._blist else [self._data[x] for x in sort] |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_add_missing_rows; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:indexes; 6, block; 6, 7; 6, 21; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:new_indexes; 10, list_comprehension; 10, 11; 10, 12; 10, 15... | def _add_missing_rows(self, indexes):
new_indexes = [x for x in indexes if x not in self._index]
for x in new_indexes:
self._add_row(x) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_insert_missing_rows; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:indexes; 6, block; 6, 7; 6, 21; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:new_indexes; 10, list_comprehension; 10, 11; 10, 12; 10,... | def _insert_missing_rows(self, indexes):
new_indexes = [x for x in indexes if x not in self._index]
for x in new_indexes:
self._insert_row(bisect_left(self._index, x), x) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:append_row; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:index; 6, identifier:value; 7, block; 7, 8; 7, 20; 7, 29; 8, if_statement; 8, 9; 8, 14; 9, comparison_operator:in; 9, 10; 9, 11; 10, identifier:index; 11, attribute;... | def append_row(self, index, value):
if index in self._index:
raise IndexError('index already in Series')
self._index.append(index)
self._data.append(value) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:append_rows; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:indexes; 6, identifier:values; 7, block; 7, 8; 7, 24; 7, 32; 7, 51; 7, 60; 8, if_statement; 8, 9; 8, 18; 9, comparison_operator:!=; 9, 10; 9, 14; 10, call; 10, 11; ... | def append_rows(self, indexes, values):
if len(values) != len(indexes):
raise ValueError('length of values is not equal to length of indexes')
combined_index = self._index + indexes
if len(set(combined_index)) != len(combined_index):
raise IndexError('duplicate indexes in... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_sort_columns; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:columns_list; 6, block; 6, 7; 6, 41; 6, 56; 6, 86; 7, if_statement; 7, 8; 7, 35; 8, not_operator; 8, 9; 9, parenthesized_expression; 9, 10; 10, boolean_operator:and; 10... | def _sort_columns(self, columns_list):
if not (all([x in columns_list for x in self._columns]) and all([x in self._columns for x in columns_list])):
raise ValueError(
'columns_list must be all in current columns, and all current columns must be in columns_list')
new_sort = [s... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:append_row; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:index; 6, identifier:values; 7, default_parameter; 7, 8; 7, 9; 8, identifier:new_cols; 9, True; 10, block; 10, 11; 10, 23; 10, 44; 10, 53; 11, if_statement; 1... | def append_row(self, index, values, new_cols=True):
if index in self._index:
raise IndexError('index already in DataFrame')
if new_cols:
for col in values:
if col not in self._columns:
self._add_column(col)
self._index.append(index)
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:append_rows; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:indexes; 6, identifier:values; 7, default_parameter; 7, 8; 7, 9; 8, identifier:new_cols; 9, True; 10, block; 10, 11; 10, 35; 10, 43; 10, 62; 10, 83; 10, 92; ... | def append_rows(self, indexes, values, new_cols=True):
for column in values:
if len(values[column]) > len(indexes):
raise ValueError('length of %s column in values is longer than indexes' % column)
combined_index = self._index + indexes
if len(set(combined_index)) != ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort_index; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 15; 5, 45; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:sort; 9, call; 9, 10; 9, 11; 10, identifier:sorted_list_indexes; 11, argument_list; 11, 1... | def sort_index(self):
sort = sorted_list_indexes(self._index)
self._index = blist([self._index[x] for x in sort]) if self._blist else [self._index[x] for x in sort]
for c in range(len(self._data)):
self._data[c] = blist([self._data[c][i] for i in sort]) if self._blist else [self._dat... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 2, function_name:tags; 3, parameters; 4, block; 4, 5; 5, return_statement; 5, 6; 6, call; 6, 7; 6, 27; 7, attribute; 7, 8; 7, 26; 8, call; 8, 9; 8, 25; 9, attribute; 9, 10; 9, 24; 10, attribute; 10, 11; 10, 23; 11, call; 11, 12; 11, 15; 12, attribute; 12, 13; 1... | def tags():
return shell.run(
'git tag --sort=v:refname',
capture=True,
never_pretend=True
).stdout.strip().splitlines() |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 90; 1, 92; 2, function_name:search; 3, parameters; 3, 4; 3, 5; 3, 10; 3, 15; 3, 20; 3, 25; 3, 30; 3, 35; 3, 40; 3, 45; 3, 50; 3, 55; 3, 60; 3, 65; 3, 70; 3, 75; 3, 80; 3, 85; 4, identifier:self; 5, typed_default_parameter; 5, 6; 5, 7; 5, 9; 6, identifier:token; 7,... | def search(
self,
token: dict = None,
query: str = "",
bbox: list = None,
poly: str = None,
georel: str = None,
order_by: str = "_created",
order_dir: str = "desc",
page_size: int = 100,
offset: int = 0,
share: str = None,
s... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 60; 1, 62; 2, function_name:keywords; 3, parameters; 3, 4; 3, 5; 3, 10; 3, 15; 3, 20; 3, 25; 3, 30; 3, 35; 3, 40; 3, 45; 3, 50; 3, 55; 4, identifier:self; 5, typed_default_parameter; 5, 6; 5, 7; 5, 9; 6, identifier:token; 7, type; 7, 8; 8, identifier:dict; 9, None... | def keywords(
self,
token: dict = None,
thez_id: str = "1616597fbc4348c8b11ef9d59cf594c8",
query: str = "",
offset: int = 0,
order_by: str = "text",
order_dir: str = "desc",
page_size: int = 20,
specific_md: list = [],
specific_tag: list = ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_field_sort_name; 3, parameters; 3, 4; 3, 5; 4, identifier:cls; 5, identifier:name; 6, block; 6, 7; 6, 51; 7, if_statement; 7, 8; 7, 17; 8, call; 8, 9; 8, 10; 9, identifier:isinstance; 10, argument_list; 10, 11; 10, 16; 11, subscript; 11, 12; 1... | def _field_sort_name(cls, name):
if isinstance(cls.__dict__[name], DateItemField):
name = re.sub('year', 'date0', name)
name = re.sub('month', 'date1', name)
name = re.sub('day', 'date2', name)
return name |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sorted_fields; 3, parameters; 3, 4; 4, identifier:cls; 5, block; 5, 6; 6, for_statement; 6, 7; 6, 8; 6, 21; 7, identifier:property; 8, call; 8, 9; 8, 10; 9, identifier:sorted; 10, argument_list; 10, 11; 10, 16; 11, call; 11, 12; 11, 15; 12, att... | def sorted_fields(cls):
for property in sorted(cls.fields(), key=cls._field_sort_name):
yield property |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:set_vassals_wrapper_params; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:wrapper; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:overrides; 10, None; 11, default_paramet... | def set_vassals_wrapper_params(self, wrapper=None, overrides=None, fallbacks=None):
self._set('emperor-wrapper', wrapper)
self._set('emperor-wrapper-override', overrides, multi=True)
self._set('emperor-wrapper-fallback', fallbacks, multi=True)
return self._section |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:add_query_parameters_to_url; 3, parameters; 3, 4; 3, 5; 4, identifier:url; 5, identifier:query_parameters; 6, block; 6, 7; 6, 18; 6, 31; 6, 38; 6, 44; 6, 63; 6, 75; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:url_pa... | def add_query_parameters_to_url(url, query_parameters):
url_parts = urllib.parse.urlparse(url)
qs_args = urllib.parse.parse_qs(url_parts[4])
qs_args.update(query_parameters)
sorted_qs_args = OrderedDict()
for k in sorted(qs_args.keys()):
sorted_qs_args[k] = qs_args[k]
new_qs = urllib.par... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:merge; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:elements; 6, block; 6, 7; 6, 9; 6, 14; 6, 22; 6, 48; 7, expression_statement; 7, 8; 8, string:''' Merges all scraping results to a list sorted by frequency of occurrence. '''; ... | def merge(self, elements):
''' Merges all scraping results to a list sorted by frequency of occurrence. '''
from collections import Counter
from lltk.utils import list2tuple, tuple2list
merged = tuple2list([value for value, count in Counter(list2tuple(list(elements))).most_common()])
return merged |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:in1d_sorted; 3, parameters; 3, 4; 3, 5; 4, identifier:ar1; 5, identifier:ar2; 6, block; 6, 7; 6, 26; 6, 35; 6, 46; 7, if_statement; 7, 8; 7, 23; 8, boolean_operator:or; 8, 9; 8, 16; 9, comparison_operator:==; 9, 10; 9, 15; 10, subscript; 10, 11... | def in1d_sorted(ar1, ar2):
if ar1.shape[0] == 0 or ar2.shape[0] == 0:
return []
inds = ar2.searchsorted(ar1)
inds[inds == len(ar2)] = 0
return ar2[inds] == ar1 |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:get_parameter_value_from_file_names; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:files; 5, default_parameter; 5, 6; 5, 7; 6, identifier:parameters; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:unique; 10, False; 11, defa... | def get_parameter_value_from_file_names(files, parameters=None, unique=False, sort=True):
logging.debug('Get the parameter: ' + str(parameters) + ' values from the file names of ' + str(len(files)) + ' files')
files_dict = collections.OrderedDict()
if parameters is None:
return files_dict
if isi... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 19; 2, function_name:get_data_file_names_from_scan_base; 3, parameters; 3, 4; 3, 5; 3, 13; 3, 16; 4, identifier:scan_base; 5, default_parameter; 5, 6; 5, 7; 6, identifier:filter_str; 7, list:['_analyzed.h5', '_interpreted.h5', '_cut.h5', '_result.h5', '_hists.h5']... | def get_data_file_names_from_scan_base(scan_base, filter_str=['_analyzed.h5', '_interpreted.h5', '_cut.h5', '_result.h5', '_hists.h5'], sort_by_time=True, meta_data_v2=True):
data_files = []
if scan_base is None:
return data_files
if isinstance(scan_base, basestring):
scan_base = [scan_base]... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:get_parameter_from_files; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:files; 5, default_parameter; 5, 6; 5, 7; 6, identifier:parameters; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:unique; 10, False; 11, default_paramet... | def get_parameter_from_files(files, parameters=None, unique=False, sort=True):
''' Takes a list of files, searches for the parameter name in the file name and in the file.
Returns a ordered dict with the file name in the first dimension and the corresponding parameter values in the second.
If a scan paramet... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:reduce_sorted_to_intersect; 3, parameters; 3, 4; 3, 5; 4, identifier:ar1; 5, identifier:ar2; 6, block; 6, 7; 6, 20; 6, 33; 6, 40; 6, 46; 6, 53; 6, 59; 6, 82; 6, 93; 6, 104; 6, 115; 6, 126; 6, 135; 6, 144; 6, 165; 6, 186; 7, expression_statement... | def reduce_sorted_to_intersect(ar1, ar2):
ar1 = np.asarray(ar1).ravel()
ar2 = np.asarray(ar2).ravel()
ar1_biggest_value = ar1[-1]
ar1_smallest_value = ar1[0]
ar2_biggest_value = ar2[-1]
ar2_smallest_value = ar2[0]
if ar1_biggest_value < ar2_smallest_value or ar1_smallest_value > ar2_biggest_... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:get_hits_in_events; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:hits_array; 5, identifier:events; 6, default_parameter; 6, 7; 6, 8; 7, identifier:assume_sorted; 8, True; 9, default_parameter; 9, 10; 9, 11; 10, identifier:condition; 11... | def get_hits_in_events(hits_array, events, assume_sorted=True, condition=None):
'''Selects the hits that occurred in events and optional selection criterion.
If a event range can be defined use the get_data_in_event_range function. It is much faster.
Parameters
----------
hits_array : numpy.arra... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:natsorted; 3, parameters; 3, 4; 3, 5; 4, identifier:seq; 5, default_parameter; 5, 6; 5, 7; 6, identifier:cmp; 7, identifier:natcmp; 8, block; 8, 9; 8, 11; 8, 14; 8, 23; 8, 29; 9, expression_statement; 9, 10; 10, string:"Returns a copy of seq, s... | def natsorted(seq, cmp=natcmp):
"Returns a copy of seq, sorted by natural string sort."
import copy
temp = copy.copy(seq)
natsort(temp, cmp)
return temp |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:sort2groups; 3, parameters; 3, 4; 3, 5; 4, identifier:array; 5, default_parameter; 5, 6; 5, 7; 6, identifier:gpat; 7, list:['_R1','_R2']; 7, 8; 7, 9; 8, string:'_R1'; 9, string:'_R2'; 10, block; 10, 11; 10, 22; 10, 26; 10, 62; 11, expression_s... | def sort2groups(array, gpat=['_R1','_R2']):
groups = [REGroup(gp) for gp in gpat]
unmatched = []
for item in array:
matched = False
for m in groups:
if m.match(item):
matched = True
break
if not matched: unmatched.append(item)
return [sorted(m.list) for m i... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:sort_and_distribute; 3, parameters; 3, 4; 3, 5; 4, identifier:array; 5, default_parameter; 5, 6; 5, 7; 6, identifier:splits; 7, integer:2; 8, block; 8, 9; 8, 24; 8, 37; 8, 44; 8, 69; 8, 77; 8, 111; 9, if_statement; 9, 10; 9, 18; 10, not_operato... | def sort_and_distribute(array, splits=2):
if not isinstance(array, (list,tuple)): raise TypeError("array must be a list")
if not isinstance(splits, int): raise TypeError("splits must be an integer")
remaining = sorted(array)
if sys.version_info < (3, 0):
myrange = xrange(splits)
else:
myrange... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:sort; 3, parameters; 3, 4; 3, 5; 3, 9; 4, identifier:self; 5, typed_parameter; 5, 6; 5, 7; 6, identifier:section; 7, type; 7, 8; 8, identifier:int; 9, default_parameter; 9, 10; 9, 11; 10, identifier:order; 11, None; 12, block; 12, 13; 12, 21; ... | def sort(self, section: int, order=None):
attr = self.header[section]
old_i, old_sort = self.sort_state
self.beginResetModel()
if section == old_i:
self.collection.sort(attr, not old_sort)
self.sort_state = (section, not old_sort)
else:
self.co... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:set_collection; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:collection; 6, block; 6, 7; 6, 13; 6, 19; 6, 28; 7, expression_statement; 7, 8; 8, call; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:self; 11, identifier:b... | def set_collection(self, collection):
self.beginResetModel()
self.collection = collection
self.sort_state = (-1, False)
self.endResetModel() |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:copy; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:items; 7, None; 8, block; 8, 9; 9, return_statement; 9, 10; 10, call; 10, 11; 10, 12; 11, identifier:NGram; 12, argument_list; 12, 13; 12, 19; ... | def copy(self, items=None):
return NGram(items if items is not None else self,
self.threshold, self.warp, self._key,
self.N, self._pad_len, self._pad_char) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:items_sharing_ngrams; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:query; 6, block; 6, 7; 6, 11; 6, 15; 6, 89; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:shared; 10, dictionary; 11, expression_state... | def items_sharing_ngrams(self, query):
shared = {}
remaining = {}
for ngram in self.split(query):
try:
for match, count in self._grams[ngram].items():
remaining.setdefault(ngram, {}).setdefault(match, count)
if remaining[ngram][... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:searchitem; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:item; 6, default_parameter; 6, 7; 6, 8; 7, identifier:threshold; 8, None; 9, block; 9, 10; 10, return_statement; 10, 11; 11, call; 11, 12; 11, 15; 12, attribute; 12,... | def searchitem(self, item, threshold=None):
return self.search(self.key(item), threshold) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:search; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:query; 6, default_parameter; 6, 7; 6, 8; 7, identifier:threshold; 8, None; 9, block; 9, 10; 9, 21; 9, 25; 9, 97; 9, 114; 10, expression_statement; 10, 11; 11, assignment... | def search(self, query, threshold=None):
threshold = threshold if threshold is not None else self.threshold
results = []
for match, samegrams in self.items_sharing_ngrams(query).items():
allgrams = (len(self.pad(query))
+ self.length[match] - (2 * self.N) - sa... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:clear; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 16; 5, 22; 6, expression_statement; 6, 7; 7, call; 7, 8; 7, 15; 8, attribute; 8, 9; 8, 14; 9, call; 9, 10; 9, 11; 10, identifier:super; 11, argument_list; 11, 12; 11, 13; 12, id... | def clear(self):
super(NGram, self).clear()
self._grams = {}
self.length = {} |
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; 8, return_statement; 8, 9; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:self; 12, identifier:copy; ... | def union(self, *others):
return self.copy(super(NGram, self).union(*others)) |
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; 7, return_statement; 7, 8; 8, call; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:self; 11, identifier:copy; 12, argument_list; ... | def symmetric_difference(self, other):
return self.copy(super(NGram, self).symmetric_difference(other)) |
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, 20; 6, 27; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:intersection; 10, call; 10, 11; 10, 18; 11, ... | def symmetric_difference_update(self, other):
intersection = super(NGram, self).intersection(other)
self.update(other)
self.difference_update(intersection) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 38; 2, function_name:download; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 3, 29; 3, 32; 3, 35; 4, identifier:directory; 5, default_parameter; 5, 6; 5, 7; 6, identifier:master_token; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, ide... | def download(directory, master_token=None, member=None, access_token=None,
source=None, project_data=False, max_size='128m', verbose=False,
debug=False, memberlist=None, excludelist=None,
id_filename=False):
set_log_level(debug, verbose)
if (memberlist or excludelist) and ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:sort; 3, parameters; 3, 4; 3, 5; 3, 7; 4, identifier:self; 5, list_splat_pattern; 5, 6; 6, identifier:columns; 7, dictionary_splat_pattern; 7, 8; 8, identifier:options; 9, block; 9, 10; 9, 22; 9, 116; 9, 129; 10, expression_statement; 10, 11; 1... | def sort(self, *columns, **options):
sorts = self.meta.setdefault('sort', [])
for column in columns:
if isinstance(column, Column):
identifier = column.id
elif isinstance(column, utils.basestring):
descending = column.startswith('-') or options.get... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:getList; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:aspList; 6, block; 6, 7; 6, 23; 6, 39; 6, 55; 6, 63; 6, 78; 6, 86; 6, 102; 6, 118; 6, 128; 6, 132; 6, 204; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, ident... | def getList(self, aspList):
objects = self._elements(self.SIG_OBJECTS, self.N, [0])
houses = self._elements(self.SIG_HOUSES, self.N, [0])
angles = self._elements(self.SIG_ANGLES, self.N, [0])
significators = objects + houses + angles
objects = self._elements(self.SIG_OBJECTS, sel... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:knt2mlt; 3, parameters; 3, 4; 4, identifier:t; 5, block; 5, 6; 5, 15; 5, 27; 5, 31; 5, 35; 5, 76; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:t; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:np... | def knt2mlt(t):
t = np.atleast_1d(t)
if t.ndim > 1:
raise ValueError("t must be a list or a rank-1 array")
out = []
e = None
for k in range(t.shape[0]):
if t[k] != e:
e = t[k]
count = 0
else:
count += 1
out.append(count)
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:get_gallery; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:section; 7, string:'hot'; 8, default_parameter; 8, 9; 8, 10; 9, identifier:sort; 10, string:'viral'; 11, def... | def get_gallery(self, section='hot', sort='viral', window='day',
show_viral=True, limit=None):
url = (self._base_url + "/3/gallery/{}/{}/{}/{}?showViral="
"{}".format(section, sort, window, '{}', show_viral))
resp = self._send_request(url, limit=limit)
return [... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:find_neighbors; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, identifier:neighbors; 5, identifier:coords; 6, identifier:I; 7, identifier:source_files; 8, identifier:f; 9, identifier:sides; 10, block; 10, 11; 10, 85; 11, for_statement; ... | def find_neighbors(neighbors, coords, I, source_files, f, sides):
for i, c1 in enumerate(coords):
me = source_files[I[i]]
if neighbors[me][sides[0]] != '':
continue
for j, c2 in enumerate(coords):
if f(c1, c2):
neigh = source_files[I[j]]
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:sortrows; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:a; 5, default_parameter; 5, 6; 5, 7; 6, identifier:i; 7, integer:0; 8, default_parameter; 8, 9; 8, 10; 9, identifier:index_out; 10, False; 11, default_parameter; 11, 12; 11, 13; 1... | def sortrows(a, i=0, index_out=False, recurse=True):
I = np.argsort(a[:, i])
a = a[I, :]
if recurse & (len(a[0]) > i + 1):
for b in np.unique(a[:, i]):
ids = a[:, i] == b
colids = range(i) + range(i+1, len(a[0]))
a[np.ix_(ids, colids)], I2 = sortrows(a[np.ix_(ids,... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:my_notes; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:start_index; 7, integer:0; 8, default_parameter; 8, 9; 8, 10; 9, identifier:limit; 10, integer:100; 11, default... | def my_notes(self, start_index=0, limit=100, get_all=False, sort_by='loanId', sort_dir='asc'):
index = start_index
notes = {
'loans': [],
'total': 0,
'result': 'success'
}
while True:
payload = {
'sortBy': sort_by,
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:blacken; 3, parameters; 3, 4; 4, identifier:c; 5, block; 5, 6; 5, 35; 5, 53; 5, 63; 5, 75; 6, if_statement; 6, 7; 6, 14; 7, not_operator; 7, 8; 8, call; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:PYTHON; 11, identifier:startswith; ... | def blacken(c):
if not PYTHON.startswith("3.6"):
msg = "Not blackening, since Python {} != Python 3.6".format(PYTHON)
print(msg, file=sys.stderr)
return
config = c.config.get("travis", {}).get("black", {})
version = config.get("version", "18.5b0")
c.run("pip install black=={}".fo... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_versions_from_changelog; 3, parameters; 3, 4; 4, identifier:changelog; 5, block; 5, 6; 5, 24; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:versions; 9, list_comprehension; 9, 10; 9, 14; 9, 17; 10, call; 10, 11; 10, 1... | def _versions_from_changelog(changelog):
versions = [Version(x) for x in changelog if BUGFIX_RELEASE_RE.match(x)]
return sorted(versions) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_get_tags; 3, parameters; 3, 4; 4, identifier:c; 5, block; 5, 6; 5, 10; 5, 49; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:tags_; 9, list:[]; 10, for_statement; 10, 11; 10, 12; 10, 32; 11, identifier:tagstr; 12, call... | def _get_tags(c):
tags_ = []
for tagstr in c.run("git tag", hide=True).stdout.strip().split("\n"):
try:
tags_.append(Version(tagstr))
except ValueError:
pass
return sorted(tags_) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sortForSameExpTime; 3, parameters; 3, 4; 3, 5; 4, identifier:expTimes; 5, identifier:img_paths; 6, block; 6, 7; 6, 9; 6, 13; 6, 43; 6, 57; 7, expression_statement; 7, 8; 8, string:'''
return image paths sorted for same exposure time
'... | def sortForSameExpTime(expTimes, img_paths):
'''
return image paths sorted for same exposure time
'''
d = {}
for e, i in zip(expTimes, img_paths):
if e not in d:
d[e] = []
d[e].append(i)
d = OrderedDict(sorted(d.items()))
return list(d.keys()), list(d.val... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:actionnames; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 10; 5, 53; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:actions; 9, list:[]; 10, for_statement; 10, 11; 10, 12; 10, 22; 11, identifier:service_n... | def actionnames(self):
actions = []
for service_name in sorted(self.services.keys()):
action_names = self.services[service_name].actions.keys()
for action_name in sorted(action_names):
actions.append((service_name, action_name))
return actions |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:lookup_field_orderable; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:field; 6, block; 6, 7; 7, try_statement; 7, 8; 7, 22; 8, block; 8, 9; 8, 20; 9, expression_statement; 9, 10; 10, call; 10, 11; 10, 18; 11, attribute; 11, 12; 1... | def lookup_field_orderable(self, field):
try:
self.model._meta.get_field_by_name(field)
return True
except Exception:
return False |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:run; 3, parameters; 3, 4; 3, 5; 4, identifier:files; 5, identifier:temp_folder; 6, block; 6, 7; 6, 17; 6, 24; 7, try_statement; 7, 8; 7, 12; 8, block; 8, 9; 9, import_statement; 9, 10; 10, dotted_name; 10, 11; 11, identifier:isort; 12, except_c... | def run(files, temp_folder):
try:
import isort
except ImportError:
return NO_ISORT_MSG
py_files = filter_python_files(files)
return bash('isort -df --quiet {0}'.format(' '.join(py_files))).value() |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:keys; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:key; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:reverse; 10, False; 11, block; 11, 12; 11, 33; 12, expression_statement; ... | def keys(self, key=None, reverse=False):
ks = sorted(list(dict.keys(self)), key=key, reverse=reverse)
return ks |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:lazy_map; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:data_processor; 5, identifier:data_generator; 6, default_parameter; 6, 7; 6, 8; 7, identifier:n_cpus; 8, integer:1; 9, default_parameter; 9, 10; 9, 11; 10, identifier:stepsize; 11,... | def lazy_map(data_processor, data_generator, n_cpus=1, stepsize=None):
if not n_cpus:
n_cpus = mp.cpu_count()
elif n_cpus < 0:
n_cpus = mp.cpu_count() - n_cpus
if stepsize is None:
stepsize = n_cpus
results = []
with mp.Pool(processes=n_cpus) as p:
while True:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:lazy_imap; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:data_processor; 5, identifier:data_generator; 6, default_parameter; 6, 7; 6, 8; 7, identifier:n_cpus; 8, integer:1; 9, default_parameter; 9, 10; 9, 11; 10, identifier:stepsize; 11... | def lazy_imap(data_processor, data_generator, n_cpus=1, stepsize=None):
if not n_cpus:
n_cpus = mp.cpu_count()
elif n_cpus < 0:
n_cpus = mp.cpu_count() - n_cpus
if stepsize is None:
stepsize = n_cpus
with mp.Pool(processes=n_cpus) as p:
while True:
r = p.map(d... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:get_dummy_thread; 3, parameters; 3, 4; 3, 5; 4, identifier:nsamples; 5, dictionary_splat_pattern; 5, 6; 6, identifier:kwargs; 7, block; 7, 8; 7, 18; 7, 28; 7, 41; 7, 51; 7, 64; 7, 78; 7, 133; 7, 147; 7, 166; 8, expression_statement; 8, 9; 9, as... | def get_dummy_thread(nsamples, **kwargs):
seed = kwargs.pop('seed', False)
ndim = kwargs.pop('ndim', 2)
logl_start = kwargs.pop('logl_start', -np.inf)
logl_range = kwargs.pop('logl_range', 1)
if kwargs:
raise TypeError('Unexpected **kwargs: {0}'.format(kwargs))
if seed is not False:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:get_dummy_run; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:nthread; 5, identifier:nsamples; 6, dictionary_splat_pattern; 6, 7; 7, identifier:kwargs; 8, block; 8, 9; 8, 19; 8, 29; 8, 42; 8, 52; 8, 65; 8, 69; 8, 83; 8, 87; 8, 116; 8, 133; 8, 1... | def get_dummy_run(nthread, nsamples, **kwargs):
seed = kwargs.pop('seed', False)
ndim = kwargs.pop('ndim', 2)
logl_start = kwargs.pop('logl_start', -np.inf)
logl_range = kwargs.pop('logl_range', 1)
if kwargs:
raise TypeError('Unexpected **kwargs: {0}'.format(kwargs))
threads = []
if ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.