repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 3
values | summary stringlengths 4 350 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
shaypal5/strct | strct/dicts/_dict.py | safe_nested_val | def safe_nested_val(key_tuple, dict_obj, default_value=None):
"""Return a value from nested dicts by the order of the given keys tuple.
Parameters
----------
key_tuple : tuple
The keys to use for extraction, in order.
dict_obj : dict
The outer-most dict to extract from.
default_... | python | def safe_nested_val(key_tuple, dict_obj, default_value=None):
"""Return a value from nested dicts by the order of the given keys tuple.
Parameters
----------
key_tuple : tuple
The keys to use for extraction, in order.
dict_obj : dict
The outer-most dict to extract from.
default_... | [
"def",
"safe_nested_val",
"(",
"key_tuple",
",",
"dict_obj",
",",
"default_value",
"=",
"None",
")",
":",
"try",
":",
"return",
"get_nested_val",
"(",
"key_tuple",
",",
"dict_obj",
")",
"except",
"(",
"KeyError",
",",
"IndexError",
",",
"TypeError",
")",
":"... | Return a value from nested dicts by the order of the given keys tuple.
Parameters
----------
key_tuple : tuple
The keys to use for extraction, in order.
dict_obj : dict
The outer-most dict to extract from.
default_value : object, default None
The value to return when no matc... | [
"Return",
"a",
"value",
"from",
"nested",
"dicts",
"by",
"the",
"order",
"of",
"the",
"given",
"keys",
"tuple",
"."
] | f3a301692d052ddb79331230b3c00625db1d83fc | https://github.com/shaypal5/strct/blob/f3a301692d052ddb79331230b3c00625db1d83fc/strct/dicts/_dict.py#L96-L128 | train | Return a value from nested dicts by the given keys tuple. |
shaypal5/strct | strct/dicts/_dict.py | put_nested_val | def put_nested_val(dict_obj, key_tuple, value):
"""Put a value into nested dicts by the order of the given keys tuple.
Any missing intermediate dicts are created.
Parameters
----------
dict_obj : dict
The outer-most dict to put in.
key_tuple : tuple
The keys to use for putting,... | python | def put_nested_val(dict_obj, key_tuple, value):
"""Put a value into nested dicts by the order of the given keys tuple.
Any missing intermediate dicts are created.
Parameters
----------
dict_obj : dict
The outer-most dict to put in.
key_tuple : tuple
The keys to use for putting,... | [
"def",
"put_nested_val",
"(",
"dict_obj",
",",
"key_tuple",
",",
"value",
")",
":",
"current_dict",
"=",
"dict_obj",
"for",
"key",
"in",
"key_tuple",
"[",
":",
"-",
"1",
"]",
":",
"try",
":",
"current_dict",
"=",
"current_dict",
"[",
"key",
"]",
"except"... | Put a value into nested dicts by the order of the given keys tuple.
Any missing intermediate dicts are created.
Parameters
----------
dict_obj : dict
The outer-most dict to put in.
key_tuple : tuple
The keys to use for putting, in order.
value : object
The value to put.... | [
"Put",
"a",
"value",
"into",
"nested",
"dicts",
"by",
"the",
"order",
"of",
"the",
"given",
"keys",
"tuple",
"."
] | f3a301692d052ddb79331230b3c00625db1d83fc | https://github.com/shaypal5/strct/blob/f3a301692d052ddb79331230b3c00625db1d83fc/strct/dicts/_dict.py#L131-L168 | train | Put a value into nested dicts by the order of the given keys tuple. |
shaypal5/strct | strct/dicts/_dict.py | get_alternative_nested_val | def get_alternative_nested_val(key_tuple, dict_obj):
"""Return a value from nested dicts by any path in the given keys tuple.
Parameters
---------
key_tuple : tuple
Describe all possible paths for extraction.
dict_obj : dict
The outer-most dict to extract from.
Returns
----... | python | def get_alternative_nested_val(key_tuple, dict_obj):
"""Return a value from nested dicts by any path in the given keys tuple.
Parameters
---------
key_tuple : tuple
Describe all possible paths for extraction.
dict_obj : dict
The outer-most dict to extract from.
Returns
----... | [
"def",
"get_alternative_nested_val",
"(",
"key_tuple",
",",
"dict_obj",
")",
":",
"# print('key_tuple: {}'.format(key_tuple))",
"# print('dict_obj: {}'.format(dict_obj))",
"top_keys",
"=",
"key_tuple",
"[",
"0",
"]",
"if",
"isinstance",
"(",
"key_tuple",
"[",
"0",
"]",
... | Return a value from nested dicts by any path in the given keys tuple.
Parameters
---------
key_tuple : tuple
Describe all possible paths for extraction.
dict_obj : dict
The outer-most dict to extract from.
Returns
-------
value : object
The extracted value, if exist... | [
"Return",
"a",
"value",
"from",
"nested",
"dicts",
"by",
"any",
"path",
"in",
"the",
"given",
"keys",
"tuple",
"."
] | f3a301692d052ddb79331230b3c00625db1d83fc | https://github.com/shaypal5/strct/blob/f3a301692d052ddb79331230b3c00625db1d83fc/strct/dicts/_dict.py#L198-L230 | train | Get a value from nested dicts by any path in the given keys tuple. |
shaypal5/strct | strct/dicts/_dict.py | subdict_by_keys | def subdict_by_keys(dict_obj, keys):
"""Returns a sub-dict composed solely of the given keys.
Parameters
----------
dict_obj : dict
The dict to create a sub-dict from.
keys : list of str
The keys to keep in the sub-dict. Keys not present in the given dict
will be ignored.
... | python | def subdict_by_keys(dict_obj, keys):
"""Returns a sub-dict composed solely of the given keys.
Parameters
----------
dict_obj : dict
The dict to create a sub-dict from.
keys : list of str
The keys to keep in the sub-dict. Keys not present in the given dict
will be ignored.
... | [
"def",
"subdict_by_keys",
"(",
"dict_obj",
",",
"keys",
")",
":",
"return",
"{",
"k",
":",
"dict_obj",
"[",
"k",
"]",
"for",
"k",
"in",
"set",
"(",
"keys",
")",
".",
"intersection",
"(",
"dict_obj",
".",
"keys",
"(",
")",
")",
"}"
] | Returns a sub-dict composed solely of the given keys.
Parameters
----------
dict_obj : dict
The dict to create a sub-dict from.
keys : list of str
The keys to keep in the sub-dict. Keys not present in the given dict
will be ignored.
Returns
-------
dict
A su... | [
"Returns",
"a",
"sub",
"-",
"dict",
"composed",
"solely",
"of",
"the",
"given",
"keys",
"."
] | f3a301692d052ddb79331230b3c00625db1d83fc | https://github.com/shaypal5/strct/blob/f3a301692d052ddb79331230b3c00625db1d83fc/strct/dicts/_dict.py#L289-L312 | train | Returns a sub - dict composed solely of the given keys. |
shaypal5/strct | strct/dicts/_dict.py | increment_dict_val | def increment_dict_val(dict_obj, key, value, zero_value=0):
"""Increments the value mapped by the given key by the given val.
If the key is missing from the dict, the given mapping is added.
Parameters
----------
dict_obj : dict
The dict to increment a value in.
key : object
The... | python | def increment_dict_val(dict_obj, key, value, zero_value=0):
"""Increments the value mapped by the given key by the given val.
If the key is missing from the dict, the given mapping is added.
Parameters
----------
dict_obj : dict
The dict to increment a value in.
key : object
The... | [
"def",
"increment_dict_val",
"(",
"dict_obj",
",",
"key",
",",
"value",
",",
"zero_value",
"=",
"0",
")",
":",
"dict_obj",
"[",
"key",
"]",
"=",
"dict_obj",
".",
"get",
"(",
"key",
",",
"zero_value",
")",
"+",
"value"
] | Increments the value mapped by the given key by the given val.
If the key is missing from the dict, the given mapping is added.
Parameters
----------
dict_obj : dict
The dict to increment a value in.
key : object
The key whose value is to be incremented.
value : object
T... | [
"Increments",
"the",
"value",
"mapped",
"by",
"the",
"given",
"key",
"by",
"the",
"given",
"val",
".",
"If",
"the",
"key",
"is",
"missing",
"from",
"the",
"dict",
"the",
"given",
"mapping",
"is",
"added",
"."
] | f3a301692d052ddb79331230b3c00625db1d83fc | https://github.com/shaypal5/strct/blob/f3a301692d052ddb79331230b3c00625db1d83fc/strct/dicts/_dict.py#L315-L343 | train | Increments the value mapped by the given key by the given val. |
shaypal5/strct | strct/dicts/_dict.py | increment_nested_val | def increment_nested_val(dict_obj, key_tuple, value, zero_value=0):
"""Increments the value mapped by the given key by the given val.
If the key is missing from the dict, the given mapping is added.
Parameters
----------
dict_obj : dict
The outer-most dict to increment a value in.
key_t... | python | def increment_nested_val(dict_obj, key_tuple, value, zero_value=0):
"""Increments the value mapped by the given key by the given val.
If the key is missing from the dict, the given mapping is added.
Parameters
----------
dict_obj : dict
The outer-most dict to increment a value in.
key_t... | [
"def",
"increment_nested_val",
"(",
"dict_obj",
",",
"key_tuple",
",",
"value",
",",
"zero_value",
"=",
"0",
")",
":",
"inc_val",
"=",
"value",
"+",
"safe_nested_val",
"(",
"key_tuple",
"=",
"key_tuple",
",",
"dict_obj",
"=",
"dict_obj",
",",
"default_value",
... | Increments the value mapped by the given key by the given val.
If the key is missing from the dict, the given mapping is added.
Parameters
----------
dict_obj : dict
The outer-most dict to increment a value in.
key_tuple : tuple
The keys mapping to the nested value to increment, in ... | [
"Increments",
"the",
"value",
"mapped",
"by",
"the",
"given",
"key",
"by",
"the",
"given",
"val",
".",
"If",
"the",
"key",
"is",
"missing",
"from",
"the",
"dict",
"the",
"given",
"mapping",
"is",
"added",
"."
] | f3a301692d052ddb79331230b3c00625db1d83fc | https://github.com/shaypal5/strct/blob/f3a301692d052ddb79331230b3c00625db1d83fc/strct/dicts/_dict.py#L346-L383 | train | Increments the value mapped by the given key by the given val. |
shaypal5/strct | strct/dicts/_dict.py | add_to_dict_val_set | def add_to_dict_val_set(dict_obj, key, val):
"""Adds the given val to the set mapped by the given key.
If the key is missing from the dict, the given mapping is added.
Example
-------
>>> dict_obj = {'a': set([1, 2])}
>>> add_to_dict_val_set(dict_obj, 'a', 2)
>>> print(dict_obj['a'])
{1... | python | def add_to_dict_val_set(dict_obj, key, val):
"""Adds the given val to the set mapped by the given key.
If the key is missing from the dict, the given mapping is added.
Example
-------
>>> dict_obj = {'a': set([1, 2])}
>>> add_to_dict_val_set(dict_obj, 'a', 2)
>>> print(dict_obj['a'])
{1... | [
"def",
"add_to_dict_val_set",
"(",
"dict_obj",
",",
"key",
",",
"val",
")",
":",
"try",
":",
"dict_obj",
"[",
"key",
"]",
".",
"add",
"(",
"val",
")",
"except",
"KeyError",
":",
"dict_obj",
"[",
"key",
"]",
"=",
"set",
"(",
"[",
"val",
"]",
")"
] | Adds the given val to the set mapped by the given key.
If the key is missing from the dict, the given mapping is added.
Example
-------
>>> dict_obj = {'a': set([1, 2])}
>>> add_to_dict_val_set(dict_obj, 'a', 2)
>>> print(dict_obj['a'])
{1, 2}
>>> add_to_dict_val_set(dict_obj, 'a', 3)
... | [
"Adds",
"the",
"given",
"val",
"to",
"the",
"set",
"mapped",
"by",
"the",
"given",
"key",
".",
"If",
"the",
"key",
"is",
"missing",
"from",
"the",
"dict",
"the",
"given",
"mapping",
"is",
"added",
"."
] | f3a301692d052ddb79331230b3c00625db1d83fc | https://github.com/shaypal5/strct/blob/f3a301692d052ddb79331230b3c00625db1d83fc/strct/dicts/_dict.py#L386-L403 | train | Adds the given val to the set mapped by the given key. |
shaypal5/strct | strct/dicts/_dict.py | add_many_to_dict_val_set | def add_many_to_dict_val_set(dict_obj, key, val_list):
"""Adds the given value list to the set mapped by the given key.
If the key is missing from the dict, the given mapping is added.
Example
-------
>>> dict_obj = {'a': set([1, 2])}
>>> add_many_to_dict_val_set(dict_obj, 'a', [2, 3])
>>> ... | python | def add_many_to_dict_val_set(dict_obj, key, val_list):
"""Adds the given value list to the set mapped by the given key.
If the key is missing from the dict, the given mapping is added.
Example
-------
>>> dict_obj = {'a': set([1, 2])}
>>> add_many_to_dict_val_set(dict_obj, 'a', [2, 3])
>>> ... | [
"def",
"add_many_to_dict_val_set",
"(",
"dict_obj",
",",
"key",
",",
"val_list",
")",
":",
"try",
":",
"dict_obj",
"[",
"key",
"]",
".",
"update",
"(",
"val_list",
")",
"except",
"KeyError",
":",
"dict_obj",
"[",
"key",
"]",
"=",
"set",
"(",
"val_list",
... | Adds the given value list to the set mapped by the given key.
If the key is missing from the dict, the given mapping is added.
Example
-------
>>> dict_obj = {'a': set([1, 2])}
>>> add_many_to_dict_val_set(dict_obj, 'a', [2, 3])
>>> print(dict_obj['a'])
{1, 2, 3}
>>> add_many_to_dict_va... | [
"Adds",
"the",
"given",
"value",
"list",
"to",
"the",
"set",
"mapped",
"by",
"the",
"given",
"key",
".",
"If",
"the",
"key",
"is",
"missing",
"from",
"the",
"dict",
"the",
"given",
"mapping",
"is",
"added",
"."
] | f3a301692d052ddb79331230b3c00625db1d83fc | https://github.com/shaypal5/strct/blob/f3a301692d052ddb79331230b3c00625db1d83fc/strct/dicts/_dict.py#L406-L423 | train | Adds the given value list to the set mapped by the given key. |
shaypal5/strct | strct/dicts/_dict.py | add_many_to_dict_val_list | def add_many_to_dict_val_list(dict_obj, key, val_list):
"""Adds the given value list to the list mapped by the given key.
If the key is missing from the dict, the given mapping is added.
Example
-------
>>> dict_obj = {'a': [1, 2]}
>>> add_many_to_dict_val_list(dict_obj, 'a', [2, 3])
>>> pr... | python | def add_many_to_dict_val_list(dict_obj, key, val_list):
"""Adds the given value list to the list mapped by the given key.
If the key is missing from the dict, the given mapping is added.
Example
-------
>>> dict_obj = {'a': [1, 2]}
>>> add_many_to_dict_val_list(dict_obj, 'a', [2, 3])
>>> pr... | [
"def",
"add_many_to_dict_val_list",
"(",
"dict_obj",
",",
"key",
",",
"val_list",
")",
":",
"try",
":",
"dict_obj",
"[",
"key",
"]",
".",
"extend",
"(",
"val_list",
")",
"except",
"KeyError",
":",
"dict_obj",
"[",
"key",
"]",
"=",
"list",
"(",
"val_list"... | Adds the given value list to the list mapped by the given key.
If the key is missing from the dict, the given mapping is added.
Example
-------
>>> dict_obj = {'a': [1, 2]}
>>> add_many_to_dict_val_list(dict_obj, 'a', [2, 3])
>>> print(dict_obj['a'])
[1, 2, 2, 3]
>>> add_many_to_dict_va... | [
"Adds",
"the",
"given",
"value",
"list",
"to",
"the",
"list",
"mapped",
"by",
"the",
"given",
"key",
".",
"If",
"the",
"key",
"is",
"missing",
"from",
"the",
"dict",
"the",
"given",
"mapping",
"is",
"added",
"."
] | f3a301692d052ddb79331230b3c00625db1d83fc | https://github.com/shaypal5/strct/blob/f3a301692d052ddb79331230b3c00625db1d83fc/strct/dicts/_dict.py#L426-L443 | train | Adds the given value list to the list mapped by the given key. |
shaypal5/strct | strct/dicts/_dict.py | get_keys_of_max_n | def get_keys_of_max_n(dict_obj, n):
"""Returns the keys that maps to the top n max values in the given dict.
Example:
--------
>>> dict_obj = {'a':2, 'b':1, 'c':5}
>>> get_keys_of_max_n(dict_obj, 2)
['a', 'c']
"""
return sorted([
item[0]
for item in sorted(
d... | python | def get_keys_of_max_n(dict_obj, n):
"""Returns the keys that maps to the top n max values in the given dict.
Example:
--------
>>> dict_obj = {'a':2, 'b':1, 'c':5}
>>> get_keys_of_max_n(dict_obj, 2)
['a', 'c']
"""
return sorted([
item[0]
for item in sorted(
d... | [
"def",
"get_keys_of_max_n",
"(",
"dict_obj",
",",
"n",
")",
":",
"return",
"sorted",
"(",
"[",
"item",
"[",
"0",
"]",
"for",
"item",
"in",
"sorted",
"(",
"dict_obj",
".",
"items",
"(",
")",
",",
"key",
"=",
"lambda",
"item",
":",
"item",
"[",
"1",
... | Returns the keys that maps to the top n max values in the given dict.
Example:
--------
>>> dict_obj = {'a':2, 'b':1, 'c':5}
>>> get_keys_of_max_n(dict_obj, 2)
['a', 'c'] | [
"Returns",
"the",
"keys",
"that",
"maps",
"to",
"the",
"top",
"n",
"max",
"values",
"in",
"the",
"given",
"dict",
"."
] | f3a301692d052ddb79331230b3c00625db1d83fc | https://github.com/shaypal5/strct/blob/f3a301692d052ddb79331230b3c00625db1d83fc/strct/dicts/_dict.py#L459-L473 | train | Returns the keys that maps to the top n max values in the given dict. |
shaypal5/strct | strct/dicts/_dict.py | deep_merge_dict | def deep_merge_dict(base, priority):
"""Recursively merges the two given dicts into a single dict.
Treating base as the the initial point of the resulting merged dict,
and considering the nested dictionaries as trees, they are merged os:
1. Every path to every leaf in priority would be represented in t... | python | def deep_merge_dict(base, priority):
"""Recursively merges the two given dicts into a single dict.
Treating base as the the initial point of the resulting merged dict,
and considering the nested dictionaries as trees, they are merged os:
1. Every path to every leaf in priority would be represented in t... | [
"def",
"deep_merge_dict",
"(",
"base",
",",
"priority",
")",
":",
"if",
"not",
"isinstance",
"(",
"base",
",",
"dict",
")",
"or",
"not",
"isinstance",
"(",
"priority",
",",
"dict",
")",
":",
"return",
"priority",
"result",
"=",
"copy",
".",
"deepcopy",
... | Recursively merges the two given dicts into a single dict.
Treating base as the the initial point of the resulting merged dict,
and considering the nested dictionaries as trees, they are merged os:
1. Every path to every leaf in priority would be represented in the result.
2. Subtrees of base are overw... | [
"Recursively",
"merges",
"the",
"two",
"given",
"dicts",
"into",
"a",
"single",
"dict",
"."
] | f3a301692d052ddb79331230b3c00625db1d83fc | https://github.com/shaypal5/strct/blob/f3a301692d052ddb79331230b3c00625db1d83fc/strct/dicts/_dict.py#L539-L578 | train | Recursively merges two dicts into a single dict. |
shaypal5/strct | strct/dicts/_dict.py | norm_int_dict | def norm_int_dict(int_dict):
"""Normalizes values in the given dict with int values.
Parameters
----------
int_dict : list
A dict object mapping each key to an int value.
Returns
-------
dict
A dict where each key is mapped to its relative part in the sum of
all dic... | python | def norm_int_dict(int_dict):
"""Normalizes values in the given dict with int values.
Parameters
----------
int_dict : list
A dict object mapping each key to an int value.
Returns
-------
dict
A dict where each key is mapped to its relative part in the sum of
all dic... | [
"def",
"norm_int_dict",
"(",
"int_dict",
")",
":",
"norm_dict",
"=",
"int_dict",
".",
"copy",
"(",
")",
"val_sum",
"=",
"sum",
"(",
"norm_dict",
".",
"values",
"(",
")",
")",
"for",
"key",
"in",
"norm_dict",
":",
"norm_dict",
"[",
"key",
"]",
"=",
"n... | Normalizes values in the given dict with int values.
Parameters
----------
int_dict : list
A dict object mapping each key to an int value.
Returns
-------
dict
A dict where each key is mapped to its relative part in the sum of
all dict values.
Example
-------
... | [
"Normalizes",
"values",
"in",
"the",
"given",
"dict",
"with",
"int",
"values",
"."
] | f3a301692d052ddb79331230b3c00625db1d83fc | https://github.com/shaypal5/strct/blob/f3a301692d052ddb79331230b3c00625db1d83fc/strct/dicts/_dict.py#L581-L606 | train | Normalizes values in the given dict with int values. |
shaypal5/strct | strct/dicts/_dict.py | sum_num_dicts | def sum_num_dicts(dicts, normalize=False):
"""Sums the given dicts into a single dict mapping each key to the sum
of its mappings in all given dicts.
Parameters
----------
dicts : list
A list of dict objects mapping each key to an numeric value.
normalize : bool, default False
I... | python | def sum_num_dicts(dicts, normalize=False):
"""Sums the given dicts into a single dict mapping each key to the sum
of its mappings in all given dicts.
Parameters
----------
dicts : list
A list of dict objects mapping each key to an numeric value.
normalize : bool, default False
I... | [
"def",
"sum_num_dicts",
"(",
"dicts",
",",
"normalize",
"=",
"False",
")",
":",
"sum_dict",
"=",
"{",
"}",
"for",
"dicti",
"in",
"dicts",
":",
"for",
"key",
"in",
"dicti",
":",
"sum_dict",
"[",
"key",
"]",
"=",
"sum_dict",
".",
"get",
"(",
"key",
"... | Sums the given dicts into a single dict mapping each key to the sum
of its mappings in all given dicts.
Parameters
----------
dicts : list
A list of dict objects mapping each key to an numeric value.
normalize : bool, default False
Indicated whether to normalize all values by value ... | [
"Sums",
"the",
"given",
"dicts",
"into",
"a",
"single",
"dict",
"mapping",
"each",
"key",
"to",
"the",
"sum",
"of",
"its",
"mappings",
"in",
"all",
"given",
"dicts",
"."
] | f3a301692d052ddb79331230b3c00625db1d83fc | https://github.com/shaypal5/strct/blob/f3a301692d052ddb79331230b3c00625db1d83fc/strct/dicts/_dict.py#L609-L643 | train | Sums the given dicts into a single dict mapping each key to the sum of its mappings in all given dicts. |
shaypal5/strct | strct/dicts/_dict.py | sum_dicts | def sum_dicts(dicts, normalize=False):
"""Sums the given dicts into a single dict mapping each numberic-valued
key to the sum of its mappings in all given dicts. Keys mapping to
non-numeric values retain the last value (by the given order).
Parameters
----------
dicts : list
A list of d... | python | def sum_dicts(dicts, normalize=False):
"""Sums the given dicts into a single dict mapping each numberic-valued
key to the sum of its mappings in all given dicts. Keys mapping to
non-numeric values retain the last value (by the given order).
Parameters
----------
dicts : list
A list of d... | [
"def",
"sum_dicts",
"(",
"dicts",
",",
"normalize",
"=",
"False",
")",
":",
"sum_dict",
"=",
"{",
"}",
"for",
"dicti",
"in",
"dicts",
":",
"for",
"key",
"in",
"dicti",
":",
"val",
"=",
"dicti",
"[",
"key",
"]",
"if",
"isinstance",
"(",
"val",
",",
... | Sums the given dicts into a single dict mapping each numberic-valued
key to the sum of its mappings in all given dicts. Keys mapping to
non-numeric values retain the last value (by the given order).
Parameters
----------
dicts : list
A list of dict objects mapping each key to an numeric val... | [
"Sums",
"the",
"given",
"dicts",
"into",
"a",
"single",
"dict",
"mapping",
"each",
"numberic",
"-",
"valued",
"key",
"to",
"the",
"sum",
"of",
"its",
"mappings",
"in",
"all",
"given",
"dicts",
".",
"Keys",
"mapping",
"to",
"non",
"-",
"numeric",
"values"... | f3a301692d052ddb79331230b3c00625db1d83fc | https://github.com/shaypal5/strct/blob/f3a301692d052ddb79331230b3c00625db1d83fc/strct/dicts/_dict.py#L646-L674 | train | Sums the given dicts into a single dict mapping each numberic - valued
key to the sum of its mappings in all given dicts. |
shaypal5/strct | strct/dicts/_dict.py | reverse_dict | def reverse_dict(dict_obj):
"""Reverse a dict, so each value in it maps to a sorted list of its keys.
Parameters
----------
dict_obj : dict
A key-value dict.
Returns
-------
dict
A dict where each value maps to a sorted list of all the unique keys
that mapped to it.... | python | def reverse_dict(dict_obj):
"""Reverse a dict, so each value in it maps to a sorted list of its keys.
Parameters
----------
dict_obj : dict
A key-value dict.
Returns
-------
dict
A dict where each value maps to a sorted list of all the unique keys
that mapped to it.... | [
"def",
"reverse_dict",
"(",
"dict_obj",
")",
":",
"new_dict",
"=",
"{",
"}",
"for",
"key",
"in",
"dict_obj",
":",
"add_to_dict_val_set",
"(",
"dict_obj",
"=",
"new_dict",
",",
"key",
"=",
"dict_obj",
"[",
"key",
"]",
",",
"val",
"=",
"key",
")",
"for",... | Reverse a dict, so each value in it maps to a sorted list of its keys.
Parameters
----------
dict_obj : dict
A key-value dict.
Returns
-------
dict
A dict where each value maps to a sorted list of all the unique keys
that mapped to it.
Example
-------
>>> d... | [
"Reverse",
"a",
"dict",
"so",
"each",
"value",
"in",
"it",
"maps",
"to",
"a",
"sorted",
"list",
"of",
"its",
"keys",
"."
] | f3a301692d052ddb79331230b3c00625db1d83fc | https://github.com/shaypal5/strct/blob/f3a301692d052ddb79331230b3c00625db1d83fc/strct/dicts/_dict.py#L677-L702 | train | Reverse a dict so each value in it maps to a sorted list of its keys. |
shaypal5/strct | strct/dicts/_dict.py | reverse_dict_partial | def reverse_dict_partial(dict_obj):
"""Reverse a dict, so each value in it maps to one of its keys.
Parameters
----------
dict_obj : dict
A key-value dict.
Returns
-------
dict
A dict where each value maps to the key that mapped to it.
Example
-------
>>> dicti... | python | def reverse_dict_partial(dict_obj):
"""Reverse a dict, so each value in it maps to one of its keys.
Parameters
----------
dict_obj : dict
A key-value dict.
Returns
-------
dict
A dict where each value maps to the key that mapped to it.
Example
-------
>>> dicti... | [
"def",
"reverse_dict_partial",
"(",
"dict_obj",
")",
":",
"new_dict",
"=",
"{",
"}",
"for",
"key",
"in",
"dict_obj",
":",
"new_dict",
"[",
"dict_obj",
"[",
"key",
"]",
"]",
"=",
"key",
"return",
"new_dict"
] | Reverse a dict, so each value in it maps to one of its keys.
Parameters
----------
dict_obj : dict
A key-value dict.
Returns
-------
dict
A dict where each value maps to the key that mapped to it.
Example
-------
>>> dicti = {'a': 1, 'b': 3}
>>> reverse_dict_pa... | [
"Reverse",
"a",
"dict",
"so",
"each",
"value",
"in",
"it",
"maps",
"to",
"one",
"of",
"its",
"keys",
"."
] | f3a301692d052ddb79331230b3c00625db1d83fc | https://github.com/shaypal5/strct/blob/f3a301692d052ddb79331230b3c00625db1d83fc/strct/dicts/_dict.py#L705-L727 | train | Reverse a dict so each value in it maps to one of its keys. |
shaypal5/strct | strct/dicts/_dict.py | reverse_list_valued_dict | def reverse_list_valued_dict(dict_obj):
"""Reverse a list-valued dict, so each element in a list maps to its key.
Parameters
----------
dict_obj : dict
A dict where each key maps to a list of unique values. Values are
assumed to be unique across the entire dict, on not just per-list.
... | python | def reverse_list_valued_dict(dict_obj):
"""Reverse a list-valued dict, so each element in a list maps to its key.
Parameters
----------
dict_obj : dict
A dict where each key maps to a list of unique values. Values are
assumed to be unique across the entire dict, on not just per-list.
... | [
"def",
"reverse_list_valued_dict",
"(",
"dict_obj",
")",
":",
"new_dict",
"=",
"{",
"}",
"for",
"key",
"in",
"dict_obj",
":",
"for",
"element",
"in",
"dict_obj",
"[",
"key",
"]",
":",
"new_dict",
"[",
"element",
"]",
"=",
"key",
"return",
"new_dict"
] | Reverse a list-valued dict, so each element in a list maps to its key.
Parameters
----------
dict_obj : dict
A dict where each key maps to a list of unique values. Values are
assumed to be unique across the entire dict, on not just per-list.
Returns
-------
dict
A dict ... | [
"Reverse",
"a",
"list",
"-",
"valued",
"dict",
"so",
"each",
"element",
"in",
"a",
"list",
"maps",
"to",
"its",
"key",
"."
] | f3a301692d052ddb79331230b3c00625db1d83fc | https://github.com/shaypal5/strct/blob/f3a301692d052ddb79331230b3c00625db1d83fc/strct/dicts/_dict.py#L730-L755 | train | Reverse a list - valued dict so each element in a list maps to its key. |
shaypal5/strct | strct/dicts/_dict.py | flatten_dict | def flatten_dict(dict_obj, separator='.', flatten_lists=False):
"""Flattens the given dict into a single-level dict with flattend keys.
Parameters
----------
dict_obj : dict
A possibly nested dict.
separator : str, optional
The character to use as a separator between keys. Defaults ... | python | def flatten_dict(dict_obj, separator='.', flatten_lists=False):
"""Flattens the given dict into a single-level dict with flattend keys.
Parameters
----------
dict_obj : dict
A possibly nested dict.
separator : str, optional
The character to use as a separator between keys. Defaults ... | [
"def",
"flatten_dict",
"(",
"dict_obj",
",",
"separator",
"=",
"'.'",
",",
"flatten_lists",
"=",
"False",
")",
":",
"reducer",
"=",
"_get_key_reducer",
"(",
"separator",
")",
"flat",
"=",
"{",
"}",
"def",
"_flatten_key_val",
"(",
"key",
",",
"val",
",",
... | Flattens the given dict into a single-level dict with flattend keys.
Parameters
----------
dict_obj : dict
A possibly nested dict.
separator : str, optional
The character to use as a separator between keys. Defaults to '.'.
flatten_lists : bool, optional
If True, list values... | [
"Flattens",
"the",
"given",
"dict",
"into",
"a",
"single",
"-",
"level",
"dict",
"with",
"flattend",
"keys",
"."
] | f3a301692d052ddb79331230b3c00625db1d83fc | https://github.com/shaypal5/strct/blob/f3a301692d052ddb79331230b3c00625db1d83fc/strct/dicts/_dict.py#L766-L812 | train | Flattens the given dict into a single - level dict with flattend keys. |
shaypal5/strct | strct/dicts/_dict.py | pprint_int_dict | def pprint_int_dict(int_dict, indent=4, descending=False):
"""Prints the given dict with int values in a nice way.
Parameters
----------
int_dict : list
A dict object mapping each key to an int value.
"""
sorted_tup = sorted(int_dict.items(), key=lambda x: x[1])
if descending:
... | python | def pprint_int_dict(int_dict, indent=4, descending=False):
"""Prints the given dict with int values in a nice way.
Parameters
----------
int_dict : list
A dict object mapping each key to an int value.
"""
sorted_tup = sorted(int_dict.items(), key=lambda x: x[1])
if descending:
... | [
"def",
"pprint_int_dict",
"(",
"int_dict",
",",
"indent",
"=",
"4",
",",
"descending",
"=",
"False",
")",
":",
"sorted_tup",
"=",
"sorted",
"(",
"int_dict",
".",
"items",
"(",
")",
",",
"key",
"=",
"lambda",
"x",
":",
"x",
"[",
"1",
"]",
")",
"if",... | Prints the given dict with int values in a nice way.
Parameters
----------
int_dict : list
A dict object mapping each key to an int value. | [
"Prints",
"the",
"given",
"dict",
"with",
"int",
"values",
"in",
"a",
"nice",
"way",
"."
] | f3a301692d052ddb79331230b3c00625db1d83fc | https://github.com/shaypal5/strct/blob/f3a301692d052ddb79331230b3c00625db1d83fc/strct/dicts/_dict.py#L815-L829 | train | Prints the given dict with int values in a nice way. |
shaypal5/strct | strct/dicts/_dict.py | key_value_nested_generator | def key_value_nested_generator(dict_obj):
"""Recursively iterate over key-value pairs of nested dictionaries.
Parameters
----------
dict_obj : dict
The outer-most dict to iterate on.
Returns
-------
generator
A generator over key-value pairs in all nested dictionaries.
... | python | def key_value_nested_generator(dict_obj):
"""Recursively iterate over key-value pairs of nested dictionaries.
Parameters
----------
dict_obj : dict
The outer-most dict to iterate on.
Returns
-------
generator
A generator over key-value pairs in all nested dictionaries.
... | [
"def",
"key_value_nested_generator",
"(",
"dict_obj",
")",
":",
"for",
"key",
",",
"value",
"in",
"dict_obj",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"dict",
")",
":",
"for",
"key",
",",
"value",
"in",
"key_value_nested_generato... | Recursively iterate over key-value pairs of nested dictionaries.
Parameters
----------
dict_obj : dict
The outer-most dict to iterate on.
Returns
-------
generator
A generator over key-value pairs in all nested dictionaries.
Example
-------
>>> dicti = {'a': 1, 'b'... | [
"Recursively",
"iterate",
"over",
"key",
"-",
"value",
"pairs",
"of",
"nested",
"dictionaries",
"."
] | f3a301692d052ddb79331230b3c00625db1d83fc | https://github.com/shaypal5/strct/blob/f3a301692d052ddb79331230b3c00625db1d83fc/strct/dicts/_dict.py#L850-L874 | train | Recursively iterate over key - value pairs of nested dictionaries. |
shaypal5/strct | strct/dicts/_dict.py | key_tuple_value_nested_generator | def key_tuple_value_nested_generator(dict_obj):
"""Recursively iterate over key-tuple-value pairs of nested dictionaries.
Parameters
----------
dict_obj : dict
The outer-most dict to iterate on.
Returns
-------
generator
A generator over key-tuple-value pairs in all nested ... | python | def key_tuple_value_nested_generator(dict_obj):
"""Recursively iterate over key-tuple-value pairs of nested dictionaries.
Parameters
----------
dict_obj : dict
The outer-most dict to iterate on.
Returns
-------
generator
A generator over key-tuple-value pairs in all nested ... | [
"def",
"key_tuple_value_nested_generator",
"(",
"dict_obj",
")",
":",
"for",
"key",
",",
"value",
"in",
"dict_obj",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"dict",
")",
":",
"for",
"nested_key",
",",
"value",
"in",
"key_tuple_va... | Recursively iterate over key-tuple-value pairs of nested dictionaries.
Parameters
----------
dict_obj : dict
The outer-most dict to iterate on.
Returns
-------
generator
A generator over key-tuple-value pairs in all nested dictionaries.
Example
-------
>>> dicti = ... | [
"Recursively",
"iterate",
"over",
"key",
"-",
"tuple",
"-",
"value",
"pairs",
"of",
"nested",
"dictionaries",
"."
] | f3a301692d052ddb79331230b3c00625db1d83fc | https://github.com/shaypal5/strct/blob/f3a301692d052ddb79331230b3c00625db1d83fc/strct/dicts/_dict.py#L877-L901 | train | Recursively iterate over key - tuple - value pairs of nested dictionaries. |
weijia/djangoautoconf | djangoautoconf/model_utils/model_duplicator.py | get_duplicated_model | def get_duplicated_model(class_inst, new_class_name):
"""
Duplicate the model fields from class_inst to new_class_name, example:
NewClass = get_duplicated_model(OldClass, "NewClass")
:param class_inst:
:param new_class_name:
:return:
"""
# Ref: http://www.cnblogs.com/Jerryshome/archive/2... | python | def get_duplicated_model(class_inst, new_class_name):
"""
Duplicate the model fields from class_inst to new_class_name, example:
NewClass = get_duplicated_model(OldClass, "NewClass")
:param class_inst:
:param new_class_name:
:return:
"""
# Ref: http://www.cnblogs.com/Jerryshome/archive/2... | [
"def",
"get_duplicated_model",
"(",
"class_inst",
",",
"new_class_name",
")",
":",
"# Ref: http://www.cnblogs.com/Jerryshome/archive/2012/12/21/2827492.html",
"# get caller stack frame",
"# caller_frame = inspect.currentframe()",
"caller_frame_record",
"=",
"inspect",
".",
"stack",
"... | Duplicate the model fields from class_inst to new_class_name, example:
NewClass = get_duplicated_model(OldClass, "NewClass")
:param class_inst:
:param new_class_name:
:return: | [
"Duplicate",
"the",
"model",
"fields",
"from",
"class_inst",
"to",
"new_class_name",
"example",
":",
"NewClass",
"=",
"get_duplicated_model",
"(",
"OldClass",
"NewClass",
")",
":",
"param",
"class_inst",
":",
":",
"param",
"new_class_name",
":",
":",
"return",
"... | b7dbda2287ed8cb9de6d02cb3abaaa1c36b1ced0 | https://github.com/weijia/djangoautoconf/blob/b7dbda2287ed8cb9de6d02cb3abaaa1c36b1ced0/djangoautoconf/model_utils/model_duplicator.py#L11-L26 | train | Get the duplicated model from class_inst to new_class_name |
weijia/djangoautoconf | djangoautoconf/model_utils/model_duplicator.py | ModelDuplicator.get_duplicated_model | def get_duplicated_model(self, class_inst, new_class_name):
"""
Duplicate the model fields from class_inst to new_class_name, example:
NewClass = get_duplicated_model(OldClass, "NewClass")
:param class_inst:
:param new_class_name:
:return:
"""
# Ref: http:... | python | def get_duplicated_model(self, class_inst, new_class_name):
"""
Duplicate the model fields from class_inst to new_class_name, example:
NewClass = get_duplicated_model(OldClass, "NewClass")
:param class_inst:
:param new_class_name:
:return:
"""
# Ref: http:... | [
"def",
"get_duplicated_model",
"(",
"self",
",",
"class_inst",
",",
"new_class_name",
")",
":",
"# Ref: http://www.cnblogs.com/Jerryshome/archive/2012/12/21/2827492.html",
"attr_dict",
"=",
"{",
"'__module__'",
":",
"self",
".",
"module_name",
"}",
"for",
"field",
"in",
... | Duplicate the model fields from class_inst to new_class_name, example:
NewClass = get_duplicated_model(OldClass, "NewClass")
:param class_inst:
:param new_class_name:
:return: | [
"Duplicate",
"the",
"model",
"fields",
"from",
"class_inst",
"to",
"new_class_name",
"example",
":",
"NewClass",
"=",
"get_duplicated_model",
"(",
"OldClass",
"NewClass",
")",
":",
"param",
"class_inst",
":",
":",
"param",
"new_class_name",
":",
":",
"return",
"... | b7dbda2287ed8cb9de6d02cb3abaaa1c36b1ced0 | https://github.com/weijia/djangoautoconf/blob/b7dbda2287ed8cb9de6d02cb3abaaa1c36b1ced0/djangoautoconf/model_utils/model_duplicator.py#L58-L81 | train | Returns a new model class that is duplicated from the given class_inst to the given new_class_name. |
cloudbase/python-hnvclient | hnv/config/client.py | HVNOptions.register | def register(self):
"""Register the current options to the global ConfigOpts object."""
group = cfg.OptGroup(
self.group_name,
title="HNV (Hyper-V Network Virtualization) Options")
self._config.register_group(group)
self._config.register_opts(self._options, group=... | python | def register(self):
"""Register the current options to the global ConfigOpts object."""
group = cfg.OptGroup(
self.group_name,
title="HNV (Hyper-V Network Virtualization) Options")
self._config.register_group(group)
self._config.register_opts(self._options, group=... | [
"def",
"register",
"(",
"self",
")",
":",
"group",
"=",
"cfg",
".",
"OptGroup",
"(",
"self",
".",
"group_name",
",",
"title",
"=",
"\"HNV (Hyper-V Network Virtualization) Options\"",
")",
"self",
".",
"_config",
".",
"register_group",
"(",
"group",
")",
"self"... | Register the current options to the global ConfigOpts object. | [
"Register",
"the",
"current",
"options",
"to",
"the",
"global",
"ConfigOpts",
"object",
"."
] | b019452af01db22629809b8930357a2ebf6494be | https://github.com/cloudbase/python-hnvclient/blob/b019452af01db22629809b8930357a2ebf6494be/hnv/config/client.py#L68-L74 | train | Register the current options to the global ConfigOpts object. |
shexSpec/grammar | parsers/python/pyshexc/parser_impl/shex_node_expression_parser.py | ShexNodeExpressionParser.visitNodeConstraintLiteral | def visitNodeConstraintLiteral(self, ctx: ShExDocParser.NodeConstraintLiteralContext):
""" nodeConstraint: KW_LITERAL xsFacet* # nodeConstraintLiteral """
self.nodeconstraint.nodeKind = 'literal'
self.visitChildren(ctx) | python | def visitNodeConstraintLiteral(self, ctx: ShExDocParser.NodeConstraintLiteralContext):
""" nodeConstraint: KW_LITERAL xsFacet* # nodeConstraintLiteral """
self.nodeconstraint.nodeKind = 'literal'
self.visitChildren(ctx) | [
"def",
"visitNodeConstraintLiteral",
"(",
"self",
",",
"ctx",
":",
"ShExDocParser",
".",
"NodeConstraintLiteralContext",
")",
":",
"self",
".",
"nodeconstraint",
".",
"nodeKind",
"=",
"'literal'",
"self",
".",
"visitChildren",
"(",
"ctx",
")"
] | nodeConstraint: KW_LITERAL xsFacet* # nodeConstraintLiteral | [
"nodeConstraint",
":",
"KW_LITERAL",
"xsFacet",
"*",
"#",
"nodeConstraintLiteral"
] | 4497cd1f73fa6703bca6e2cb53ba9c120f22e48c | https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/shex_node_expression_parser.py#L46-L49 | train | visitNodeConstraintLiteral - > nodeConstraint |
shexSpec/grammar | parsers/python/pyshexc/parser_impl/shex_node_expression_parser.py | ShexNodeExpressionParser.visitNodeConstraintNonLiteral | def visitNodeConstraintNonLiteral(self, ctx: ShExDocParser.NodeConstraintNonLiteralContext):
""" nodeConstraint: nonLiteralKind stringFacet* # nodeConstraintNonLiteral """
self.nodeconstraint.nodeKind = 'iri' if ctx.nonLiteralKind().KW_IRI() \
else 'bnode' if ctx.nonLiteralKind().KW_BNODE()... | python | def visitNodeConstraintNonLiteral(self, ctx: ShExDocParser.NodeConstraintNonLiteralContext):
""" nodeConstraint: nonLiteralKind stringFacet* # nodeConstraintNonLiteral """
self.nodeconstraint.nodeKind = 'iri' if ctx.nonLiteralKind().KW_IRI() \
else 'bnode' if ctx.nonLiteralKind().KW_BNODE()... | [
"def",
"visitNodeConstraintNonLiteral",
"(",
"self",
",",
"ctx",
":",
"ShExDocParser",
".",
"NodeConstraintNonLiteralContext",
")",
":",
"self",
".",
"nodeconstraint",
".",
"nodeKind",
"=",
"'iri'",
"if",
"ctx",
".",
"nonLiteralKind",
"(",
")",
".",
"KW_IRI",
"(... | nodeConstraint: nonLiteralKind stringFacet* # nodeConstraintNonLiteral | [
"nodeConstraint",
":",
"nonLiteralKind",
"stringFacet",
"*",
"#",
"nodeConstraintNonLiteral"
] | 4497cd1f73fa6703bca6e2cb53ba9c120f22e48c | https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/shex_node_expression_parser.py#L51-L57 | train | Set nodeConstraint. nodeKind if any |
shexSpec/grammar | parsers/python/pyshexc/parser_impl/shex_node_expression_parser.py | ShexNodeExpressionParser.visitNodeConstraintDatatype | def visitNodeConstraintDatatype(self, ctx: ShExDocParser.NodeConstraintDatatypeContext):
""" nodeConstraint: datatype xsFacet* # nodeConstraintDatatype """
self.nodeconstraint.datatype = self.context.iri_to_iriref(ctx.datatype().iri())
self.visitChildren(ctx) | python | def visitNodeConstraintDatatype(self, ctx: ShExDocParser.NodeConstraintDatatypeContext):
""" nodeConstraint: datatype xsFacet* # nodeConstraintDatatype """
self.nodeconstraint.datatype = self.context.iri_to_iriref(ctx.datatype().iri())
self.visitChildren(ctx) | [
"def",
"visitNodeConstraintDatatype",
"(",
"self",
",",
"ctx",
":",
"ShExDocParser",
".",
"NodeConstraintDatatypeContext",
")",
":",
"self",
".",
"nodeconstraint",
".",
"datatype",
"=",
"self",
".",
"context",
".",
"iri_to_iriref",
"(",
"ctx",
".",
"datatype",
"... | nodeConstraint: datatype xsFacet* # nodeConstraintDatatype | [
"nodeConstraint",
":",
"datatype",
"xsFacet",
"*",
"#",
"nodeConstraintDatatype"
] | 4497cd1f73fa6703bca6e2cb53ba9c120f22e48c | https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/shex_node_expression_parser.py#L59-L62 | train | visit nodeConstraintDatatype |
shexSpec/grammar | parsers/python/pyshexc/parser_impl/shex_node_expression_parser.py | ShexNodeExpressionParser.visitNodeConstraintValueSet | def visitNodeConstraintValueSet(self, ctx: ShExDocParser.NodeConstraintValueSetContext):
""" nodeConstraint: valueSet xsFacet* #nodeConstraintValueSet """
self.nodeconstraint.values = []
self.visitChildren(ctx) | python | def visitNodeConstraintValueSet(self, ctx: ShExDocParser.NodeConstraintValueSetContext):
""" nodeConstraint: valueSet xsFacet* #nodeConstraintValueSet """
self.nodeconstraint.values = []
self.visitChildren(ctx) | [
"def",
"visitNodeConstraintValueSet",
"(",
"self",
",",
"ctx",
":",
"ShExDocParser",
".",
"NodeConstraintValueSetContext",
")",
":",
"self",
".",
"nodeconstraint",
".",
"values",
"=",
"[",
"]",
"self",
".",
"visitChildren",
"(",
"ctx",
")"
] | nodeConstraint: valueSet xsFacet* #nodeConstraintValueSet | [
"nodeConstraint",
":",
"valueSet",
"xsFacet",
"*",
"#nodeConstraintValueSet"
] | 4497cd1f73fa6703bca6e2cb53ba9c120f22e48c | https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/shex_node_expression_parser.py#L64-L67 | train | Set node constraint values. |
shexSpec/grammar | parsers/python/pyshexc/parser_impl/shex_node_expression_parser.py | ShexNodeExpressionParser.visitValueSetValue | def visitValueSetValue(self, ctx: ShExDocParser.ValueSetValueContext):
""" valueSetValue: iriRange | literalRange | languageRange |
'.' (iriExclusion+ | literalExclusion+ | languageExclusion+) """
if ctx.iriRange() or ctx.literalRange() or ctx.languageRange():
self.visitChildren... | python | def visitValueSetValue(self, ctx: ShExDocParser.ValueSetValueContext):
""" valueSetValue: iriRange | literalRange | languageRange |
'.' (iriExclusion+ | literalExclusion+ | languageExclusion+) """
if ctx.iriRange() or ctx.literalRange() or ctx.languageRange():
self.visitChildren... | [
"def",
"visitValueSetValue",
"(",
"self",
",",
"ctx",
":",
"ShExDocParser",
".",
"ValueSetValueContext",
")",
":",
"if",
"ctx",
".",
"iriRange",
"(",
")",
"or",
"ctx",
".",
"literalRange",
"(",
")",
"or",
"ctx",
".",
"languageRange",
"(",
")",
":",
"self... | valueSetValue: iriRange | literalRange | languageRange |
'.' (iriExclusion+ | literalExclusion+ | languageExclusion+) | [
"valueSetValue",
":",
"iriRange",
"|",
"literalRange",
"|",
"languageRange",
"|",
".",
"(",
"iriExclusion",
"+",
"|",
"literalExclusion",
"+",
"|",
"languageExclusion",
"+",
")"
] | 4497cd1f73fa6703bca6e2cb53ba9c120f22e48c | https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/shex_node_expression_parser.py#L69-L84 | train | Set valueSetValue. |
shexSpec/grammar | parsers/python/pyshexc/parser_impl/shex_node_expression_parser.py | ShexNodeExpressionParser.visitIriRange | def visitIriRange(self, ctx: ShExDocParser.IriRangeContext):
""" iriRange: iri (STEM_MARK iriExclusion*)? """
baseiri = self.context.iri_to_iriref(ctx.iri())
if not ctx.STEM_MARK():
vsvalue = baseiri # valueSetValue = objectValue / objectValue = IRI
else:
... | python | def visitIriRange(self, ctx: ShExDocParser.IriRangeContext):
""" iriRange: iri (STEM_MARK iriExclusion*)? """
baseiri = self.context.iri_to_iriref(ctx.iri())
if not ctx.STEM_MARK():
vsvalue = baseiri # valueSetValue = objectValue / objectValue = IRI
else:
... | [
"def",
"visitIriRange",
"(",
"self",
",",
"ctx",
":",
"ShExDocParser",
".",
"IriRangeContext",
")",
":",
"baseiri",
"=",
"self",
".",
"context",
".",
"iri_to_iriref",
"(",
"ctx",
".",
"iri",
"(",
")",
")",
"if",
"not",
"ctx",
".",
"STEM_MARK",
"(",
")"... | iriRange: iri (STEM_MARK iriExclusion*)? | [
"iriRange",
":",
"iri",
"(",
"STEM_MARK",
"iriExclusion",
"*",
")",
"?"
] | 4497cd1f73fa6703bca6e2cb53ba9c120f22e48c | https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/shex_node_expression_parser.py#L86-L97 | train | visitIriRange : Add a value to nodeconstraint |
shexSpec/grammar | parsers/python/pyshexc/parser_impl/shex_node_expression_parser.py | ShexNodeExpressionParser._literal_exclusions | def _literal_exclusions(self, stem: LiteralStemRange,
exclusions: List[ShExDocParser.LiteralExclusionContext]) -> None:
""" ShExC: literalExclusion = '-' literal STEM_MARK?
ShExJ: exclusions: [STRING|LiteralStem +]
literalStem: {stem:STRING}
"""... | python | def _literal_exclusions(self, stem: LiteralStemRange,
exclusions: List[ShExDocParser.LiteralExclusionContext]) -> None:
""" ShExC: literalExclusion = '-' literal STEM_MARK?
ShExJ: exclusions: [STRING|LiteralStem +]
literalStem: {stem:STRING}
"""... | [
"def",
"_literal_exclusions",
"(",
"self",
",",
"stem",
":",
"LiteralStemRange",
",",
"exclusions",
":",
"List",
"[",
"ShExDocParser",
".",
"LiteralExclusionContext",
"]",
")",
"->",
"None",
":",
"for",
"excl",
"in",
"exclusions",
":",
"excl_literal_v",
"=",
"... | ShExC: literalExclusion = '-' literal STEM_MARK?
ShExJ: exclusions: [STRING|LiteralStem +]
literalStem: {stem:STRING} | [
"ShExC",
":",
"literalExclusion",
"=",
"-",
"literal",
"STEM_MARK?",
"ShExJ",
":",
"exclusions",
":",
"[",
"STRING|LiteralStem",
"+",
"]",
"literalStem",
":",
"{",
"stem",
":",
"STRING",
"}"
] | 4497cd1f73fa6703bca6e2cb53ba9c120f22e48c | https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/shex_node_expression_parser.py#L121-L129 | train | Adds literal exclusion to the stem. |
shexSpec/grammar | parsers/python/pyshexc/parser_impl/shex_node_expression_parser.py | ShexNodeExpressionParser.visitLanguageRange | def visitLanguageRange(self, ctx: ShExDocParser.LanguageRangeContext):
""" ShExC: languageRange : LANGTAG (STEM_MARK languagExclusion*)?
ShExJ: valueSetValue = objectValue | LanguageStem | LanguageStemRange """
baselang = ctx.LANGTAG().getText()
if not ctx.STEM_MARK(): ... | python | def visitLanguageRange(self, ctx: ShExDocParser.LanguageRangeContext):
""" ShExC: languageRange : LANGTAG (STEM_MARK languagExclusion*)?
ShExJ: valueSetValue = objectValue | LanguageStem | LanguageStemRange """
baselang = ctx.LANGTAG().getText()
if not ctx.STEM_MARK(): ... | [
"def",
"visitLanguageRange",
"(",
"self",
",",
"ctx",
":",
"ShExDocParser",
".",
"LanguageRangeContext",
")",
":",
"baselang",
"=",
"ctx",
".",
"LANGTAG",
"(",
")",
".",
"getText",
"(",
")",
"if",
"not",
"ctx",
".",
"STEM_MARK",
"(",
")",
":",
"# valueSe... | ShExC: languageRange : LANGTAG (STEM_MARK languagExclusion*)?
ShExJ: valueSetValue = objectValue | LanguageStem | LanguageStemRange | [
"ShExC",
":",
"languageRange",
":",
"LANGTAG",
"(",
"STEM_MARK",
"languagExclusion",
"*",
")",
"?",
"ShExJ",
":",
"valueSetValue",
"=",
"objectValue",
"|",
"LanguageStem",
"|",
"LanguageStemRange"
] | 4497cd1f73fa6703bca6e2cb53ba9c120f22e48c | https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/shex_node_expression_parser.py#L131-L144 | train | Visit a LanguageRange node. |
shexSpec/grammar | parsers/python/pyshexc/parser_impl/shex_node_expression_parser.py | ShexNodeExpressionParser._language_exclusions | def _language_exclusions(stem: LanguageStemRange,
exclusions: List[ShExDocParser.LanguageExclusionContext]) -> None:
""" languageExclusion = '-' LANGTAG STEM_MARK?"""
for excl in exclusions:
excl_langtag = LANGTAG(excl.LANGTAG().getText()[1:])
stem.ex... | python | def _language_exclusions(stem: LanguageStemRange,
exclusions: List[ShExDocParser.LanguageExclusionContext]) -> None:
""" languageExclusion = '-' LANGTAG STEM_MARK?"""
for excl in exclusions:
excl_langtag = LANGTAG(excl.LANGTAG().getText()[1:])
stem.ex... | [
"def",
"_language_exclusions",
"(",
"stem",
":",
"LanguageStemRange",
",",
"exclusions",
":",
"List",
"[",
"ShExDocParser",
".",
"LanguageExclusionContext",
"]",
")",
"->",
"None",
":",
"for",
"excl",
"in",
"exclusions",
":",
"excl_langtag",
"=",
"LANGTAG",
"(",... | languageExclusion = '-' LANGTAG STEM_MARK? | [
"languageExclusion",
"=",
"-",
"LANGTAG",
"STEM_MARK?"
] | 4497cd1f73fa6703bca6e2cb53ba9c120f22e48c | https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/shex_node_expression_parser.py#L147-L152 | train | Add language exclusion to the stem. |
shexSpec/grammar | parsers/python/pyshexc/parser_impl/shex_node_expression_parser.py | ShexNodeExpressionParser.visitStringFacet | def visitStringFacet(self, ctx: ShExDocParser.StringFacetContext):
""" stringFacet: stringLength INTEGER | REGEXP REGEXP_FLAGS
stringLength: KW_LENGTH | KW_MINLENGTH | KW_MAXLENGTH """
if ctx.stringLength():
slen = jsg.Integer(ctx.INTEGER().getText())
if ctx.stringLen... | python | def visitStringFacet(self, ctx: ShExDocParser.StringFacetContext):
""" stringFacet: stringLength INTEGER | REGEXP REGEXP_FLAGS
stringLength: KW_LENGTH | KW_MINLENGTH | KW_MAXLENGTH """
if ctx.stringLength():
slen = jsg.Integer(ctx.INTEGER().getText())
if ctx.stringLen... | [
"def",
"visitStringFacet",
"(",
"self",
",",
"ctx",
":",
"ShExDocParser",
".",
"StringFacetContext",
")",
":",
"if",
"ctx",
".",
"stringLength",
"(",
")",
":",
"slen",
"=",
"jsg",
".",
"Integer",
"(",
"ctx",
".",
"INTEGER",
"(",
")",
".",
"getText",
"(... | stringFacet: stringLength INTEGER | REGEXP REGEXP_FLAGS
stringLength: KW_LENGTH | KW_MINLENGTH | KW_MAXLENGTH | [
"stringFacet",
":",
"stringLength",
"INTEGER",
"|",
"REGEXP",
"REGEXP_FLAGS",
"stringLength",
":",
"KW_LENGTH",
"|",
"KW_MINLENGTH",
"|",
"KW_MAXLENGTH"
] | 4497cd1f73fa6703bca6e2cb53ba9c120f22e48c | https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/shex_node_expression_parser.py#L154-L169 | train | visitStringFacet : returns a stringFacet node |
shexSpec/grammar | parsers/python/pyshexc/parser_impl/shex_node_expression_parser.py | ShexNodeExpressionParser.visitNumericFacet | def visitNumericFacet(self, ctx: ShExDocParser.NumericFacetContext):
""" numericFacet: numericRange numericLiteral | numericLength INTEGER
numericRange: KW_MINEXCLUSIVE | KW_MININCLUSIVE | KW_MAXEXCLUSIVE | KW_MAXINCLUSIVE
numericLength: KW_TOTALDIGITS | KW_FRACTIONDIGITS """
if... | python | def visitNumericFacet(self, ctx: ShExDocParser.NumericFacetContext):
""" numericFacet: numericRange numericLiteral | numericLength INTEGER
numericRange: KW_MINEXCLUSIVE | KW_MININCLUSIVE | KW_MAXEXCLUSIVE | KW_MAXINCLUSIVE
numericLength: KW_TOTALDIGITS | KW_FRACTIONDIGITS """
if... | [
"def",
"visitNumericFacet",
"(",
"self",
",",
"ctx",
":",
"ShExDocParser",
".",
"NumericFacetContext",
")",
":",
"if",
"ctx",
".",
"numericRange",
"(",
")",
":",
"numlit",
"=",
"self",
".",
"context",
".",
"numeric_literal_to_type",
"(",
"ctx",
".",
"numeric... | numericFacet: numericRange numericLiteral | numericLength INTEGER
numericRange: KW_MINEXCLUSIVE | KW_MININCLUSIVE | KW_MAXEXCLUSIVE | KW_MAXINCLUSIVE
numericLength: KW_TOTALDIGITS | KW_FRACTIONDIGITS | [
"numericFacet",
":",
"numericRange",
"numericLiteral",
"|",
"numericLength",
"INTEGER",
"numericRange",
":",
"KW_MINEXCLUSIVE",
"|",
"KW_MININCLUSIVE",
"|",
"KW_MAXEXCLUSIVE",
"|",
"KW_MAXINCLUSIVE",
"numericLength",
":",
"KW_TOTALDIGITS",
"|",
"KW_FRACTIONDIGITS"
] | 4497cd1f73fa6703bca6e2cb53ba9c120f22e48c | https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/shex_node_expression_parser.py#L171-L190 | train | visit numericFacet returns a nodeconstraint for numericFacet |
gtaylor/django-athumb | athumb/pial/engines/base.py | EngineBase.create_thumbnail | def create_thumbnail(self, image, geometry,
upscale=True, crop=None, colorspace='RGB'):
"""
This serves as a really basic example of a thumbnailing method. You
may want to implement your own logic, but this will work for
simple cases.
:param Image image:... | python | def create_thumbnail(self, image, geometry,
upscale=True, crop=None, colorspace='RGB'):
"""
This serves as a really basic example of a thumbnailing method. You
may want to implement your own logic, but this will work for
simple cases.
:param Image image:... | [
"def",
"create_thumbnail",
"(",
"self",
",",
"image",
",",
"geometry",
",",
"upscale",
"=",
"True",
",",
"crop",
"=",
"None",
",",
"colorspace",
"=",
"'RGB'",
")",
":",
"image",
"=",
"self",
".",
"colorspace",
"(",
"image",
",",
"colorspace",
")",
"ima... | This serves as a really basic example of a thumbnailing method. You
may want to implement your own logic, but this will work for
simple cases.
:param Image image: This is your engine's ``Image`` object. For
PIL it's PIL.Image.
:param tuple geometry: Geometry of the image in ... | [
"This",
"serves",
"as",
"a",
"really",
"basic",
"example",
"of",
"a",
"thumbnailing",
"method",
".",
"You",
"may",
"want",
"to",
"implement",
"your",
"own",
"logic",
"but",
"this",
"will",
"work",
"for",
"simple",
"cases",
"."
] | 69261ace0dff81e33156a54440874456a7b38dfb | https://github.com/gtaylor/django-athumb/blob/69261ace0dff81e33156a54440874456a7b38dfb/athumb/pial/engines/base.py#L17-L42 | train | This method creates a thumbnail of the image. |
gtaylor/django-athumb | athumb/pial/engines/base.py | EngineBase.scale | def scale(self, image, geometry, upscale, crop):
"""
Given an image, scales the image down (or up, if ``upscale`` equates
to a boolean ``True``).
:param Image image: This is your engine's ``Image`` object. For
PIL it's PIL.Image.
:param tuple geometry: Geometry of th... | python | def scale(self, image, geometry, upscale, crop):
"""
Given an image, scales the image down (or up, if ``upscale`` equates
to a boolean ``True``).
:param Image image: This is your engine's ``Image`` object. For
PIL it's PIL.Image.
:param tuple geometry: Geometry of th... | [
"def",
"scale",
"(",
"self",
",",
"image",
",",
"geometry",
",",
"upscale",
",",
"crop",
")",
":",
"x_image",
",",
"y_image",
"=",
"map",
"(",
"float",
",",
"self",
".",
"get_image_size",
"(",
"image",
")",
")",
"# Calculate scaling factor.",
"factors",
... | Given an image, scales the image down (or up, if ``upscale`` equates
to a boolean ``True``).
:param Image image: This is your engine's ``Image`` object. For
PIL it's PIL.Image.
:param tuple geometry: Geometry of the image in the format of (x,y).
:returns: The scaled image. T... | [
"Given",
"an",
"image",
"scales",
"the",
"image",
"down",
"(",
"or",
"up",
"if",
"upscale",
"equates",
"to",
"a",
"boolean",
"True",
")",
"."
] | 69261ace0dff81e33156a54440874456a7b38dfb | https://github.com/gtaylor/django-athumb/blob/69261ace0dff81e33156a54440874456a7b38dfb/athumb/pial/engines/base.py#L58-L79 | train | Scales the image down or up. |
gtaylor/django-athumb | athumb/pial/engines/base.py | EngineBase.crop | def crop(self, image, geometry, crop):
"""
Crops the given ``image``, with dimensions specified in ``geometry``,
according to the value(s) in ``crop``. Returns the cropped image.
:param Image image: This is your engine's ``Image`` object. For
PIL it's PIL.Image.
:par... | python | def crop(self, image, geometry, crop):
"""
Crops the given ``image``, with dimensions specified in ``geometry``,
according to the value(s) in ``crop``. Returns the cropped image.
:param Image image: This is your engine's ``Image`` object. For
PIL it's PIL.Image.
:par... | [
"def",
"crop",
"(",
"self",
",",
"image",
",",
"geometry",
",",
"crop",
")",
":",
"if",
"not",
"crop",
":",
"return",
"image",
"x_image",
",",
"y_image",
"=",
"self",
".",
"get_image_size",
"(",
"image",
")",
"x_offset",
",",
"y_offset",
"=",
"parse_cr... | Crops the given ``image``, with dimensions specified in ``geometry``,
according to the value(s) in ``crop``. Returns the cropped image.
:param Image image: This is your engine's ``Image`` object. For
PIL it's PIL.Image.
:param tuple geometry: Geometry of the image in the format of (... | [
"Crops",
"the",
"given",
"image",
"with",
"dimensions",
"specified",
"in",
"geometry",
"according",
"to",
"the",
"value",
"(",
"s",
")",
"in",
"crop",
".",
"Returns",
"the",
"cropped",
"image",
"."
] | 69261ace0dff81e33156a54440874456a7b38dfb | https://github.com/gtaylor/django-athumb/blob/69261ace0dff81e33156a54440874456a7b38dfb/athumb/pial/engines/base.py#L81-L104 | train | Crops the given image according to the value in crop. |
gtaylor/django-athumb | athumb/pial/engines/base.py | EngineBase.write | def write(self, image, dest_fobj, quality=95, format=None):
"""
Wrapper for ``_write``
:param Image image: This is your engine's ``Image`` object. For
PIL it's PIL.Image.
:keyword int quality: A quality level as a percent. The lower, the
higher the compression, t... | python | def write(self, image, dest_fobj, quality=95, format=None):
"""
Wrapper for ``_write``
:param Image image: This is your engine's ``Image`` object. For
PIL it's PIL.Image.
:keyword int quality: A quality level as a percent. The lower, the
higher the compression, t... | [
"def",
"write",
"(",
"self",
",",
"image",
",",
"dest_fobj",
",",
"quality",
"=",
"95",
",",
"format",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"format",
",",
"basestring",
")",
"and",
"format",
".",
"lower",
"(",
")",
"==",
"'jpg'",
":",
"#... | Wrapper for ``_write``
:param Image image: This is your engine's ``Image`` object. For
PIL it's PIL.Image.
:keyword int quality: A quality level as a percent. The lower, the
higher the compression, the worse the artifacts.
:keyword str format: The format to save to. If o... | [
"Wrapper",
"for",
"_write"
] | 69261ace0dff81e33156a54440874456a7b38dfb | https://github.com/gtaylor/django-athumb/blob/69261ace0dff81e33156a54440874456a7b38dfb/athumb/pial/engines/base.py#L106-L125 | train | Wrapper for _write method that writes the image to dest_fobj. |
gtaylor/django-athumb | athumb/pial/engines/base.py | EngineBase.get_image_ratio | def get_image_ratio(self, image):
"""
Calculates the image ratio (X to Y).
:param Image image: This is your engine's ``Image`` object. For
PIL it's PIL.Image.
:rtype: float
:returns: The X to Y ratio of your image's dimensions.
"""
x, y = self.get_ima... | python | def get_image_ratio(self, image):
"""
Calculates the image ratio (X to Y).
:param Image image: This is your engine's ``Image`` object. For
PIL it's PIL.Image.
:rtype: float
:returns: The X to Y ratio of your image's dimensions.
"""
x, y = self.get_ima... | [
"def",
"get_image_ratio",
"(",
"self",
",",
"image",
")",
":",
"x",
",",
"y",
"=",
"self",
".",
"get_image_size",
"(",
"image",
")",
"return",
"float",
"(",
"x",
")",
"/",
"y"
] | Calculates the image ratio (X to Y).
:param Image image: This is your engine's ``Image`` object. For
PIL it's PIL.Image.
:rtype: float
:returns: The X to Y ratio of your image's dimensions. | [
"Calculates",
"the",
"image",
"ratio",
"(",
"X",
"to",
"Y",
")",
"."
] | 69261ace0dff81e33156a54440874456a7b38dfb | https://github.com/gtaylor/django-athumb/blob/69261ace0dff81e33156a54440874456a7b38dfb/athumb/pial/engines/base.py#L127-L137 | train | Calculates the image ratio. |
GearPlug/payu-python | payu/tokenization.py | Tokenization.create_single_token | def create_single_token(self, *, payer_id, name, identification_number, payment_method, number, expiration_date):
"""
Using this feature you can register a customer’s credit card data and get a token sequential number.
Args:
payer_id:
name:
identification_num... | python | def create_single_token(self, *, payer_id, name, identification_number, payment_method, number, expiration_date):
"""
Using this feature you can register a customer’s credit card data and get a token sequential number.
Args:
payer_id:
name:
identification_num... | [
"def",
"create_single_token",
"(",
"self",
",",
"*",
",",
"payer_id",
",",
"name",
",",
"identification_number",
",",
"payment_method",
",",
"number",
",",
"expiration_date",
")",
":",
"payload",
"=",
"{",
"\"language\"",
":",
"self",
".",
"client",
".",
"la... | Using this feature you can register a customer’s credit card data and get a token sequential number.
Args:
payer_id:
name:
identification_number:
payment_method:
number:
expiration_date:
Returns: | [
"Using",
"this",
"feature",
"you",
"can",
"register",
"a",
"customer’s",
"credit",
"card",
"data",
"and",
"get",
"a",
"token",
"sequential",
"number",
"."
] | 47ec5c9fc89f1f89a53ec0a68c84f358bbe3394e | https://github.com/GearPlug/payu-python/blob/47ec5c9fc89f1f89a53ec0a68c84f358bbe3394e/payu/tokenization.py#L12-L44 | train | This method creates a single token in the customer s credit card store. |
GearPlug/payu-python | payu/tokenization.py | Tokenization.get_tokens | def get_tokens(self, *, payer_id, credit_card_token_id, start_date, end_date):
"""
With this functionality you can query previously the Credit Cards Token.
Args:
payer_id:
credit_card_token_id:
start_date:
end_date:
Returns:
"""
... | python | def get_tokens(self, *, payer_id, credit_card_token_id, start_date, end_date):
"""
With this functionality you can query previously the Credit Cards Token.
Args:
payer_id:
credit_card_token_id:
start_date:
end_date:
Returns:
"""
... | [
"def",
"get_tokens",
"(",
"self",
",",
"*",
",",
"payer_id",
",",
"credit_card_token_id",
",",
"start_date",
",",
"end_date",
")",
":",
"payload",
"=",
"{",
"\"language\"",
":",
"self",
".",
"client",
".",
"language",
".",
"value",
",",
"\"command\"",
":",... | With this functionality you can query previously the Credit Cards Token.
Args:
payer_id:
credit_card_token_id:
start_date:
end_date:
Returns: | [
"With",
"this",
"functionality",
"you",
"can",
"query",
"previously",
"the",
"Credit",
"Cards",
"Token",
"."
] | 47ec5c9fc89f1f89a53ec0a68c84f358bbe3394e | https://github.com/GearPlug/payu-python/blob/47ec5c9fc89f1f89a53ec0a68c84f358bbe3394e/payu/tokenization.py#L294-L322 | train | This method is used to query the Credit Cards Token for a given payer. |
GearPlug/payu-python | payu/tokenization.py | Tokenization.remove_token | def remove_token(self, *, payer_id, credit_card_token_id):
"""
This feature allows you to delete a tokenized credit card register.
Args:
payer_id:
credit_card_token_id:
Returns:
"""
payload = {
"language": self.client.language.value,... | python | def remove_token(self, *, payer_id, credit_card_token_id):
"""
This feature allows you to delete a tokenized credit card register.
Args:
payer_id:
credit_card_token_id:
Returns:
"""
payload = {
"language": self.client.language.value,... | [
"def",
"remove_token",
"(",
"self",
",",
"*",
",",
"payer_id",
",",
"credit_card_token_id",
")",
":",
"payload",
"=",
"{",
"\"language\"",
":",
"self",
".",
"client",
".",
"language",
".",
"value",
",",
"\"command\"",
":",
"PaymentCommand",
".",
"REMOVE_TOKE... | This feature allows you to delete a tokenized credit card register.
Args:
payer_id:
credit_card_token_id:
Returns: | [
"This",
"feature",
"allows",
"you",
"to",
"delete",
"a",
"tokenized",
"credit",
"card",
"register",
"."
] | 47ec5c9fc89f1f89a53ec0a68c84f358bbe3394e | https://github.com/GearPlug/payu-python/blob/47ec5c9fc89f1f89a53ec0a68c84f358bbe3394e/payu/tokenization.py#L324-L348 | train | This feature allows you to delete a tokenized credit card register. |
bachiraoun/pylocker | Locker.py | Locker.set_file_path | def set_file_path(self, filePath):
"""
Set the file path that needs to be locked.
:Parameters:
#. filePath (None, path): The file that needs to be locked. When given and a lock
is acquired, the file will be automatically opened for writing or reading
de... | python | def set_file_path(self, filePath):
"""
Set the file path that needs to be locked.
:Parameters:
#. filePath (None, path): The file that needs to be locked. When given and a lock
is acquired, the file will be automatically opened for writing or reading
de... | [
"def",
"set_file_path",
"(",
"self",
",",
"filePath",
")",
":",
"if",
"filePath",
"is",
"not",
"None",
":",
"assert",
"isinstance",
"(",
"filePath",
",",
"basestring",
")",
",",
"\"filePath must be None or string\"",
"filePath",
"=",
"str",
"(",
"filePath",
")... | Set the file path that needs to be locked.
:Parameters:
#. filePath (None, path): The file that needs to be locked. When given and a lock
is acquired, the file will be automatically opened for writing or reading
depending on the given mode. If None is given, the locker... | [
"Set",
"the",
"file",
"path",
"that",
"needs",
"to",
"be",
"locked",
"."
] | a542e5ec2204f5a01d67f1d73ce68d3f4eb05d8b | https://github.com/bachiraoun/pylocker/blob/a542e5ec2204f5a01d67f1d73ce68d3f4eb05d8b/Locker.py#L308-L321 | train | Sets the file path that needs to be locked. |
bachiraoun/pylocker | Locker.py | Locker.set_lock_pass | def set_lock_pass(self, lockPass):
"""
Set the locking pass
:Parameters:
#. lockPass (string): The locking pass.
"""
assert isinstance(lockPass, basestring), "lockPass must be string"
lockPass = str(lockPass)
assert '\n' not in lockPass, "lockPass mus... | python | def set_lock_pass(self, lockPass):
"""
Set the locking pass
:Parameters:
#. lockPass (string): The locking pass.
"""
assert isinstance(lockPass, basestring), "lockPass must be string"
lockPass = str(lockPass)
assert '\n' not in lockPass, "lockPass mus... | [
"def",
"set_lock_pass",
"(",
"self",
",",
"lockPass",
")",
":",
"assert",
"isinstance",
"(",
"lockPass",
",",
"basestring",
")",
",",
"\"lockPass must be string\"",
"lockPass",
"=",
"str",
"(",
"lockPass",
")",
"assert",
"'\\n'",
"not",
"in",
"lockPass",
",",
... | Set the locking pass
:Parameters:
#. lockPass (string): The locking pass. | [
"Set",
"the",
"locking",
"pass"
] | a542e5ec2204f5a01d67f1d73ce68d3f4eb05d8b | https://github.com/bachiraoun/pylocker/blob/a542e5ec2204f5a01d67f1d73ce68d3f4eb05d8b/Locker.py#L323-L333 | train | Sets the locking pass for the current locale. |
bachiraoun/pylocker | Locker.py | Locker.set_lock_path | def set_lock_path(self, lockPath):
"""
Set the managing lock file path.
:Parameters:
#. lockPath (None, path): The locking file path. If None is given the locking file
will be automatically created to '.lock' in the filePath directory. If
filePath is No... | python | def set_lock_path(self, lockPath):
"""
Set the managing lock file path.
:Parameters:
#. lockPath (None, path): The locking file path. If None is given the locking file
will be automatically created to '.lock' in the filePath directory. If
filePath is No... | [
"def",
"set_lock_path",
"(",
"self",
",",
"lockPath",
")",
":",
"if",
"lockPath",
"is",
"not",
"None",
":",
"assert",
"isinstance",
"(",
"lockPath",
",",
"basestring",
")",
",",
"\"lockPath must be None or string\"",
"lockPath",
"=",
"str",
"(",
"lockPath",
")... | Set the managing lock file path.
:Parameters:
#. lockPath (None, path): The locking file path. If None is given the locking file
will be automatically created to '.lock' in the filePath directory. If
filePath is None, '.lock' will be created in the current working dire... | [
"Set",
"the",
"managing",
"lock",
"file",
"path",
"."
] | a542e5ec2204f5a01d67f1d73ce68d3f4eb05d8b | https://github.com/bachiraoun/pylocker/blob/a542e5ec2204f5a01d67f1d73ce68d3f4eb05d8b/Locker.py#L335-L352 | train | Sets the managing lock file path. |
bachiraoun/pylocker | Locker.py | Locker.set_timeout | def set_timeout(self, timeout):
"""
set the timeout limit.
:Parameters:
#. timeout (number): The maximum delay or time allowed to successfully set the
lock. When timeout is exhausted before successfully setting the lock,
the lock ends up not acquired.
... | python | def set_timeout(self, timeout):
"""
set the timeout limit.
:Parameters:
#. timeout (number): The maximum delay or time allowed to successfully set the
lock. When timeout is exhausted before successfully setting the lock,
the lock ends up not acquired.
... | [
"def",
"set_timeout",
"(",
"self",
",",
"timeout",
")",
":",
"try",
":",
"timeout",
"=",
"float",
"(",
"timeout",
")",
"assert",
"timeout",
">=",
"0",
"assert",
"timeout",
">=",
"self",
".",
"__wait",
"except",
":",
"raise",
"Exception",
"(",
"'timeout m... | set the timeout limit.
:Parameters:
#. timeout (number): The maximum delay or time allowed to successfully set the
lock. When timeout is exhausted before successfully setting the lock,
the lock ends up not acquired. | [
"set",
"the",
"timeout",
"limit",
"."
] | a542e5ec2204f5a01d67f1d73ce68d3f4eb05d8b | https://github.com/bachiraoun/pylocker/blob/a542e5ec2204f5a01d67f1d73ce68d3f4eb05d8b/Locker.py#L354-L369 | train | Sets the timeout for the current lock. |
bachiraoun/pylocker | Locker.py | Locker.set_wait | def set_wait(self, wait):
"""
set the waiting time.
:Parameters:
#. wait (number): The time delay between each attempt to lock. By default it's
set to 0 to keeping the aquiring mechanism trying to acquire the lock without
losing any time waiting. Settin... | python | def set_wait(self, wait):
"""
set the waiting time.
:Parameters:
#. wait (number): The time delay between each attempt to lock. By default it's
set to 0 to keeping the aquiring mechanism trying to acquire the lock without
losing any time waiting. Settin... | [
"def",
"set_wait",
"(",
"self",
",",
"wait",
")",
":",
"try",
":",
"wait",
"=",
"float",
"(",
"wait",
")",
"assert",
"wait",
">=",
"0",
"except",
":",
"raise",
"Exception",
"(",
"'wait must be a positive number'",
")",
"self",
".",
"__wait",
"=",
"wait"
... | set the waiting time.
:Parameters:
#. wait (number): The time delay between each attempt to lock. By default it's
set to 0 to keeping the aquiring mechanism trying to acquire the lock without
losing any time waiting. Setting wait to a higher value suchs as 0.05 seconds... | [
"set",
"the",
"waiting",
"time",
"."
] | a542e5ec2204f5a01d67f1d73ce68d3f4eb05d8b | https://github.com/bachiraoun/pylocker/blob/a542e5ec2204f5a01d67f1d73ce68d3f4eb05d8b/Locker.py#L371-L388 | train | set the waiting time. |
bachiraoun/pylocker | Locker.py | Locker.set_dead_lock | def set_dead_lock(self, deadLock):
"""
Set the dead lock time.
:Parameters:
#. deadLock (number): The time delay judging if the lock was left out mistakenly
after a system crash or other unexpected reasons. Normally Locker is stable
and takes care of no... | python | def set_dead_lock(self, deadLock):
"""
Set the dead lock time.
:Parameters:
#. deadLock (number): The time delay judging if the lock was left out mistakenly
after a system crash or other unexpected reasons. Normally Locker is stable
and takes care of no... | [
"def",
"set_dead_lock",
"(",
"self",
",",
"deadLock",
")",
":",
"try",
":",
"deadLock",
"=",
"float",
"(",
"deadLock",
")",
"assert",
"deadLock",
">=",
"0",
"except",
":",
"raise",
"Exception",
"(",
"'deadLock must be a positive number'",
")",
"self",
".",
"... | Set the dead lock time.
:Parameters:
#. deadLock (number): The time delay judging if the lock was left out mistakenly
after a system crash or other unexpected reasons. Normally Locker is stable
and takes care of not leaving any locking file hanging even it crashes or i... | [
"Set",
"the",
"dead",
"lock",
"time",
"."
] | a542e5ec2204f5a01d67f1d73ce68d3f4eb05d8b | https://github.com/bachiraoun/pylocker/blob/a542e5ec2204f5a01d67f1d73ce68d3f4eb05d8b/Locker.py#L390-L405 | train | Sets the dead lock time. |
bachiraoun/pylocker | Locker.py | Locker.acquire_lock | def acquire_lock(self, verbose=VERBOSE, raiseError=RAISE_ERROR):
"""
Try to acquire the lock.
:Parameters:
#. verbose (bool): Whether to be verbose about errors when encountered
#. raiseError (bool): Whether to raise error exception when encountered
:Returns:
... | python | def acquire_lock(self, verbose=VERBOSE, raiseError=RAISE_ERROR):
"""
Try to acquire the lock.
:Parameters:
#. verbose (bool): Whether to be verbose about errors when encountered
#. raiseError (bool): Whether to raise error exception when encountered
:Returns:
... | [
"def",
"acquire_lock",
"(",
"self",
",",
"verbose",
"=",
"VERBOSE",
",",
"raiseError",
"=",
"RAISE_ERROR",
")",
":",
"#### ON WINDOWS MUST LOOK INTO THAT IN ORDER TO GET RID OF os.rename",
"#### http://code.activestate.com/recipes/577794-win32-named-mutex-class-for-system-wide-mutex/",... | Try to acquire the lock.
:Parameters:
#. verbose (bool): Whether to be verbose about errors when encountered
#. raiseError (bool): Whether to raise error exception when encountered
:Returns:
#. result (boolean): Whether the lock is succesfully acquired.
... | [
"Try",
"to",
"acquire",
"the",
"lock",
"."
] | a542e5ec2204f5a01d67f1d73ce68d3f4eb05d8b | https://github.com/bachiraoun/pylocker/blob/a542e5ec2204f5a01d67f1d73ce68d3f4eb05d8b/Locker.py#L407-L538 | train | Attempts to acquire the lock for the current object. |
bachiraoun/pylocker | Locker.py | Locker.release_lock | def release_lock(self, verbose=VERBOSE, raiseError=RAISE_ERROR):
"""
Release the lock when set and close file descriptor if opened.
:Parameters:
#. verbose (bool): Whether to be verbose about errors when encountered
#. raiseError (bool): Whether to raise error exception ... | python | def release_lock(self, verbose=VERBOSE, raiseError=RAISE_ERROR):
"""
Release the lock when set and close file descriptor if opened.
:Parameters:
#. verbose (bool): Whether to be verbose about errors when encountered
#. raiseError (bool): Whether to raise error exception ... | [
"def",
"release_lock",
"(",
"self",
",",
"verbose",
"=",
"VERBOSE",
",",
"raiseError",
"=",
"RAISE_ERROR",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"self",
".",
"__lockPath",
")",
":",
"released",
"=",
"True",
"code",
"=",
"0",
"... | Release the lock when set and close file descriptor if opened.
:Parameters:
#. verbose (bool): Whether to be verbose about errors when encountered
#. raiseError (bool): Whether to raise error exception when encountered
:Returns:
#. result (boolean): Whether the lock... | [
"Release",
"the",
"lock",
"when",
"set",
"and",
"close",
"file",
"descriptor",
"if",
"opened",
"."
] | a542e5ec2204f5a01d67f1d73ce68d3f4eb05d8b | https://github.com/bachiraoun/pylocker/blob/a542e5ec2204f5a01d67f1d73ce68d3f4eb05d8b/Locker.py#L541-L614 | train | Release the lock when set and close file descriptor if opened. |
geophysics-ubonn/reda | lib/reda/containers/ERT.py | Importers.import_syscal_bin | def import_syscal_bin(self, filename, **kwargs):
"""Syscal import
timestep: int or :class:`datetime.datetime`
if provided use this value to set the 'timestep' column of the
produced dataframe. Default: 0
"""
timestep = kwargs.get('timestep', None)
if 'ti... | python | def import_syscal_bin(self, filename, **kwargs):
"""Syscal import
timestep: int or :class:`datetime.datetime`
if provided use this value to set the 'timestep' column of the
produced dataframe. Default: 0
"""
timestep = kwargs.get('timestep', None)
if 'ti... | [
"def",
"import_syscal_bin",
"(",
"self",
",",
"filename",
",",
"*",
"*",
"kwargs",
")",
":",
"timestep",
"=",
"kwargs",
".",
"get",
"(",
"'timestep'",
",",
"None",
")",
"if",
"'timestep'",
"in",
"kwargs",
":",
"del",
"(",
"kwargs",
"[",
"'timestep'",
"... | Syscal import
timestep: int or :class:`datetime.datetime`
if provided use this value to set the 'timestep' column of the
produced dataframe. Default: 0 | [
"Syscal",
"import"
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/containers/ERT.py#L71-L92 | train | Imports the Syscal bin file and adds it to the current container. |
geophysics-ubonn/reda | lib/reda/containers/ERT.py | Importers.import_bert | def import_bert(self, filename, **kwargs):
"""BERT .ohm file import"""
timestep = kwargs.get('timestep', None)
if 'timestep' in kwargs:
del (kwargs['timestep'])
self.logger.info('Unified data format (BERT/pyGIMLi) file import')
with LogDataChanges(self, filter_action... | python | def import_bert(self, filename, **kwargs):
"""BERT .ohm file import"""
timestep = kwargs.get('timestep', None)
if 'timestep' in kwargs:
del (kwargs['timestep'])
self.logger.info('Unified data format (BERT/pyGIMLi) file import')
with LogDataChanges(self, filter_action... | [
"def",
"import_bert",
"(",
"self",
",",
"filename",
",",
"*",
"*",
"kwargs",
")",
":",
"timestep",
"=",
"kwargs",
".",
"get",
"(",
"'timestep'",
",",
"None",
")",
"if",
"'timestep'",
"in",
"kwargs",
":",
"del",
"(",
"kwargs",
"[",
"'timestep'",
"]",
... | BERT .ohm file import | [
"BERT",
".",
"ohm",
"file",
"import"
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/containers/ERT.py#L118-L135 | train | Import BERT OHM file into a container. |
geophysics-ubonn/reda | lib/reda/containers/ERT.py | ERT.to_ip | def to_ip(self):
"""Return of copy of the data inside a TDIP container
"""
if 'chargeability' in self.data.columns:
tdip = reda.TDIP(data=self.data)
else:
raise Exception('Missing column "chargeability"')
return tdip | python | def to_ip(self):
"""Return of copy of the data inside a TDIP container
"""
if 'chargeability' in self.data.columns:
tdip = reda.TDIP(data=self.data)
else:
raise Exception('Missing column "chargeability"')
return tdip | [
"def",
"to_ip",
"(",
"self",
")",
":",
"if",
"'chargeability'",
"in",
"self",
".",
"data",
".",
"columns",
":",
"tdip",
"=",
"reda",
".",
"TDIP",
"(",
"data",
"=",
"self",
".",
"data",
")",
"else",
":",
"raise",
"Exception",
"(",
"'Missing column \"cha... | Return of copy of the data inside a TDIP container | [
"Return",
"of",
"copy",
"of",
"the",
"data",
"inside",
"a",
"TDIP",
"container"
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/containers/ERT.py#L189-L196 | train | Return a copy of the data inside a TDIP container |
geophysics-ubonn/reda | lib/reda/containers/ERT.py | ERT.sub_filter | def sub_filter(self, subset, filter, inplace=True):
"""Apply a filter to subset of the data
Examples
--------
::
.subquery(
'timestep == 2',
'R > 4',
)
"""
# build the full query
full_query = ''.join(('no... | python | def sub_filter(self, subset, filter, inplace=True):
"""Apply a filter to subset of the data
Examples
--------
::
.subquery(
'timestep == 2',
'R > 4',
)
"""
# build the full query
full_query = ''.join(('no... | [
"def",
"sub_filter",
"(",
"self",
",",
"subset",
",",
"filter",
",",
"inplace",
"=",
"True",
")",
":",
"# build the full query",
"full_query",
"=",
"''",
".",
"join",
"(",
"(",
"'not ('",
",",
"subset",
",",
"') or not ('",
",",
"filter",
",",
"')'",
")"... | Apply a filter to subset of the data
Examples
--------
::
.subquery(
'timestep == 2',
'R > 4',
) | [
"Apply",
"a",
"filter",
"to",
"subset",
"of",
"the",
"data"
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/containers/ERT.py#L216-L234 | train | Apply a filter to subset of the data. |
geophysics-ubonn/reda | lib/reda/containers/ERT.py | ERT.filter | def filter(self, query, inplace=True):
"""Use a query statement to filter data. Note that you specify the data
to be removed!
Parameters
----------
query : string
The query string to be evaluated. Is directly provided to
pandas.DataFrame.query
inp... | python | def filter(self, query, inplace=True):
"""Use a query statement to filter data. Note that you specify the data
to be removed!
Parameters
----------
query : string
The query string to be evaluated. Is directly provided to
pandas.DataFrame.query
inp... | [
"def",
"filter",
"(",
"self",
",",
"query",
",",
"inplace",
"=",
"True",
")",
":",
"with",
"LogDataChanges",
"(",
"self",
",",
"filter_action",
"=",
"'filter'",
",",
"filter_query",
"=",
"query",
")",
":",
"result",
"=",
"self",
".",
"data",
".",
"quer... | Use a query statement to filter data. Note that you specify the data
to be removed!
Parameters
----------
query : string
The query string to be evaluated. Is directly provided to
pandas.DataFrame.query
inplace : bool
if True, change the contai... | [
"Use",
"a",
"query",
"statement",
"to",
"filter",
"data",
".",
"Note",
"that",
"you",
"specify",
"the",
"data",
"to",
"be",
"removed!"
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/containers/ERT.py#L236-L259 | train | Use a query statement to filter the data for the specified log entry. |
geophysics-ubonn/reda | lib/reda/containers/ERT.py | ERT.compute_K_analytical | def compute_K_analytical(self, spacing):
"""Compute geometrical factors over the homogeneous half-space with a
constant electrode spacing
"""
K = redaK.compute_K_analytical(self.data, spacing=spacing)
self.data = redaK.apply_K(self.data, K)
redafixK.fix_sign_with_K(self.d... | python | def compute_K_analytical(self, spacing):
"""Compute geometrical factors over the homogeneous half-space with a
constant electrode spacing
"""
K = redaK.compute_K_analytical(self.data, spacing=spacing)
self.data = redaK.apply_K(self.data, K)
redafixK.fix_sign_with_K(self.d... | [
"def",
"compute_K_analytical",
"(",
"self",
",",
"spacing",
")",
":",
"K",
"=",
"redaK",
".",
"compute_K_analytical",
"(",
"self",
".",
"data",
",",
"spacing",
"=",
"spacing",
")",
"self",
".",
"data",
"=",
"redaK",
".",
"apply_K",
"(",
"self",
".",
"d... | Compute geometrical factors over the homogeneous half-space with a
constant electrode spacing | [
"Compute",
"geometrical",
"factors",
"over",
"the",
"homogeneous",
"half",
"-",
"space",
"with",
"a",
"constant",
"electrode",
"spacing"
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/containers/ERT.py#L261-L267 | train | Compute geometrical factors over the homogeneous half - space with electrode spacing |
geophysics-ubonn/reda | lib/reda/containers/ERT.py | ERT.compute_reciprocal_errors | def compute_reciprocal_errors(self, key="r"):
r"""
Compute reciprocal erros following LaBrecque et al. (1996) according
to:
.. math::
\epsilon = \left|\frac{2(|R_n| - |R_r|)}{|R_n| + |R_r|}\right|
Parameters
----------
key : str
Paramete... | python | def compute_reciprocal_errors(self, key="r"):
r"""
Compute reciprocal erros following LaBrecque et al. (1996) according
to:
.. math::
\epsilon = \left|\frac{2(|R_n| - |R_r|)}{|R_n| + |R_r|}\right|
Parameters
----------
key : str
Paramete... | [
"def",
"compute_reciprocal_errors",
"(",
"self",
",",
"key",
"=",
"\"r\"",
")",
":",
"# Assign norrec ids if not already present",
"if",
"\"id\"",
"not",
"in",
"self",
".",
"data",
".",
"keys",
"(",
")",
":",
"self",
".",
"data",
"=",
"assign_norrec_to_df",
"(... | r"""
Compute reciprocal erros following LaBrecque et al. (1996) according
to:
.. math::
\epsilon = \left|\frac{2(|R_n| - |R_r|)}{|R_n| + |R_r|}\right|
Parameters
----------
key : str
Parameter to calculate the reciprocal error for (default is "r... | [
"r",
"Compute",
"reciprocal",
"erros",
"following",
"LaBrecque",
"et",
"al",
".",
"(",
"1996",
")",
"according",
"to",
":"
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/containers/ERT.py#L269-L326 | train | r Compute the reciprocal error for a specific entry in the current tree. |
geophysics-ubonn/reda | lib/reda/containers/ERT.py | ERT.pseudosection | def pseudosection(self, column='r', filename=None, log10=False, **kwargs):
"""Plot a pseudosection of the given column. Note that this function
only works with dipole-dipole data at the moment.
Parameters
----------
column : string, optional
Column to plot into the p... | python | def pseudosection(self, column='r', filename=None, log10=False, **kwargs):
"""Plot a pseudosection of the given column. Note that this function
only works with dipole-dipole data at the moment.
Parameters
----------
column : string, optional
Column to plot into the p... | [
"def",
"pseudosection",
"(",
"self",
",",
"column",
"=",
"'r'",
",",
"filename",
"=",
"None",
",",
"log10",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"fig",
",",
"ax",
",",
"cb",
"=",
"PS",
".",
"plot_pseudosection_type2",
"(",
"self",
".",
... | Plot a pseudosection of the given column. Note that this function
only works with dipole-dipole data at the moment.
Parameters
----------
column : string, optional
Column to plot into the pseudosection, default: r
filename : string, optional
if not None, ... | [
"Plot",
"a",
"pseudosection",
"of",
"the",
"given",
"column",
".",
"Note",
"that",
"this",
"function",
"only",
"works",
"with",
"dipole",
"-",
"dipole",
"data",
"at",
"the",
"moment",
"."
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/containers/ERT.py#L328-L358 | train | Plot a pseudosection of the given column. |
geophysics-ubonn/reda | lib/reda/containers/ERT.py | ERT.histogram | def histogram(self, column='r', filename=None, log10=False, **kwargs):
"""Plot a histogram of one data column"""
return_dict = HS.plot_histograms(self.data, column)
if filename is not None:
return_dict['all'].savefig(filename, dpi=300)
return return_dict | python | def histogram(self, column='r', filename=None, log10=False, **kwargs):
"""Plot a histogram of one data column"""
return_dict = HS.plot_histograms(self.data, column)
if filename is not None:
return_dict['all'].savefig(filename, dpi=300)
return return_dict | [
"def",
"histogram",
"(",
"self",
",",
"column",
"=",
"'r'",
",",
"filename",
"=",
"None",
",",
"log10",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"return_dict",
"=",
"HS",
".",
"plot_histograms",
"(",
"self",
".",
"data",
",",
"column",
")",
... | Plot a histogram of one data column | [
"Plot",
"a",
"histogram",
"of",
"one",
"data",
"column"
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/containers/ERT.py#L360-L365 | train | Plot a histogram of one data column |
geophysics-ubonn/reda | lib/reda/containers/ERT.py | ERT.delete_measurements | def delete_measurements(self, row_or_rows):
"""Delete one or more measurements by index of the DataFrame.
Resets the DataFrame index.
Parameters
----------
row_or_rows : int or list of ints
Row numbers (starting with zero) of the data DataFrame (ert.data)
... | python | def delete_measurements(self, row_or_rows):
"""Delete one or more measurements by index of the DataFrame.
Resets the DataFrame index.
Parameters
----------
row_or_rows : int or list of ints
Row numbers (starting with zero) of the data DataFrame (ert.data)
... | [
"def",
"delete_measurements",
"(",
"self",
",",
"row_or_rows",
")",
":",
"self",
".",
"data",
".",
"drop",
"(",
"self",
".",
"data",
".",
"index",
"[",
"row_or_rows",
"]",
",",
"inplace",
"=",
"True",
")",
"self",
".",
"data",
"=",
"self",
".",
"data... | Delete one or more measurements by index of the DataFrame.
Resets the DataFrame index.
Parameters
----------
row_or_rows : int or list of ints
Row numbers (starting with zero) of the data DataFrame (ert.data)
to delete
Returns
-------
N... | [
"Delete",
"one",
"or",
"more",
"measurements",
"by",
"index",
"of",
"the",
"DataFrame",
"."
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/containers/ERT.py#L371-L388 | train | Delete one or more measurements by index of the DataFrame. |
geophysics-ubonn/reda | lib/reda/containers/ERT.py | ERT.to_configs | def to_configs(self):
"""Return a config object that contains the measurement configurations
(a,b,m,n) from the data
Returns
-------
config_obj : reda.ConfigManager
"""
config_obj = reda.configs.configManager.ConfigManager()
config_obj.add_to_configs(self... | python | def to_configs(self):
"""Return a config object that contains the measurement configurations
(a,b,m,n) from the data
Returns
-------
config_obj : reda.ConfigManager
"""
config_obj = reda.configs.configManager.ConfigManager()
config_obj.add_to_configs(self... | [
"def",
"to_configs",
"(",
"self",
")",
":",
"config_obj",
"=",
"reda",
".",
"configs",
".",
"configManager",
".",
"ConfigManager",
"(",
")",
"config_obj",
".",
"add_to_configs",
"(",
"self",
".",
"data",
"[",
"[",
"'a'",
",",
"'b'",
",",
"'m'",
",",
"'... | Return a config object that contains the measurement configurations
(a,b,m,n) from the data
Returns
-------
config_obj : reda.ConfigManager | [
"Return",
"a",
"config",
"object",
"that",
"contains",
"the",
"measurement",
"configurations",
"(",
"a",
"b",
"m",
"n",
")",
"from",
"the",
"data"
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/containers/ERT.py#L390-L400 | train | Return a config object that contains the measurement configurations
|
gtaylor/django-athumb | athumb/pial/engines/pil_engine.py | PILEngine.get_image | def get_image(self, source):
"""
Given a file-like object, loads it up into a PIL.Image object
and returns it.
:param file source: A file-like object to load the image from.
:rtype: PIL.Image
:returns: The loaded image.
"""
buf = StringIO(source.read())
... | python | def get_image(self, source):
"""
Given a file-like object, loads it up into a PIL.Image object
and returns it.
:param file source: A file-like object to load the image from.
:rtype: PIL.Image
:returns: The loaded image.
"""
buf = StringIO(source.read())
... | [
"def",
"get_image",
"(",
"self",
",",
"source",
")",
":",
"buf",
"=",
"StringIO",
"(",
"source",
".",
"read",
"(",
")",
")",
"return",
"Image",
".",
"open",
"(",
"buf",
")"
] | Given a file-like object, loads it up into a PIL.Image object
and returns it.
:param file source: A file-like object to load the image from.
:rtype: PIL.Image
:returns: The loaded image. | [
"Given",
"a",
"file",
"-",
"like",
"object",
"loads",
"it",
"up",
"into",
"a",
"PIL",
".",
"Image",
"object",
"and",
"returns",
"it",
"."
] | 69261ace0dff81e33156a54440874456a7b38dfb | https://github.com/gtaylor/django-athumb/blob/69261ace0dff81e33156a54440874456a7b38dfb/athumb/pial/engines/pil_engine.py#L13-L23 | train | Loads an image from a file - like object and returns it. |
gtaylor/django-athumb | athumb/pial/engines/pil_engine.py | PILEngine.is_valid_image | def is_valid_image(self, raw_data):
"""
Checks if the supplied raw data is valid image data.
:param str raw_data: A string representation of the image data.
:rtype: bool
:returns: ``True`` if ``raw_data`` is valid, ``False`` if not.
"""
buf = StringIO(raw_data)
... | python | def is_valid_image(self, raw_data):
"""
Checks if the supplied raw data is valid image data.
:param str raw_data: A string representation of the image data.
:rtype: bool
:returns: ``True`` if ``raw_data`` is valid, ``False`` if not.
"""
buf = StringIO(raw_data)
... | [
"def",
"is_valid_image",
"(",
"self",
",",
"raw_data",
")",
":",
"buf",
"=",
"StringIO",
"(",
"raw_data",
")",
"try",
":",
"trial_image",
"=",
"Image",
".",
"open",
"(",
"buf",
")",
"trial_image",
".",
"verify",
"(",
")",
"except",
"Exception",
":",
"#... | Checks if the supplied raw data is valid image data.
:param str raw_data: A string representation of the image data.
:rtype: bool
:returns: ``True`` if ``raw_data`` is valid, ``False`` if not. | [
"Checks",
"if",
"the",
"supplied",
"raw",
"data",
"is",
"valid",
"image",
"data",
"."
] | 69261ace0dff81e33156a54440874456a7b38dfb | https://github.com/gtaylor/django-athumb/blob/69261ace0dff81e33156a54440874456a7b38dfb/athumb/pial/engines/pil_engine.py#L35-L50 | train | Checks if the supplied raw data is valid image data. |
gtaylor/django-athumb | athumb/pial/engines/pil_engine.py | PILEngine._colorspace | def _colorspace(self, image, colorspace):
"""
Sets the image's colorspace. This is typical 'RGB' or 'GRAY', but
may be other things, depending on your choice of Engine.
:param PIL.Image image: The image whose colorspace to adjust.
:param str colorspace: One of either 'RGB' or 'G... | python | def _colorspace(self, image, colorspace):
"""
Sets the image's colorspace. This is typical 'RGB' or 'GRAY', but
may be other things, depending on your choice of Engine.
:param PIL.Image image: The image whose colorspace to adjust.
:param str colorspace: One of either 'RGB' or 'G... | [
"def",
"_colorspace",
"(",
"self",
",",
"image",
",",
"colorspace",
")",
":",
"if",
"colorspace",
"==",
"'RGB'",
":",
"if",
"image",
".",
"mode",
"==",
"'RGBA'",
":",
"# RGBA is just RGB + Alpha",
"return",
"image",
"if",
"image",
".",
"mode",
"==",
"'P'",... | Sets the image's colorspace. This is typical 'RGB' or 'GRAY', but
may be other things, depending on your choice of Engine.
:param PIL.Image image: The image whose colorspace to adjust.
:param str colorspace: One of either 'RGB' or 'GRAY'.
:rtype: PIL.Image
:returns: The colorspa... | [
"Sets",
"the",
"image",
"s",
"colorspace",
".",
"This",
"is",
"typical",
"RGB",
"or",
"GRAY",
"but",
"may",
"be",
"other",
"things",
"depending",
"on",
"your",
"choice",
"of",
"Engine",
"."
] | 69261ace0dff81e33156a54440874456a7b38dfb | https://github.com/gtaylor/django-athumb/blob/69261ace0dff81e33156a54440874456a7b38dfb/athumb/pial/engines/pil_engine.py#L52-L71 | train | Sets the image s colorspace. |
gtaylor/django-athumb | athumb/pial/engines/pil_engine.py | PILEngine._get_raw_data | def _get_raw_data(self, image, format, quality):
"""
Returns the raw data from the Image, which can be directly written
to a something, be it a file-like object or a database.
:param PIL.Image image: The image to get the raw data for.
:param str format: The format to save to. If... | python | def _get_raw_data(self, image, format, quality):
"""
Returns the raw data from the Image, which can be directly written
to a something, be it a file-like object or a database.
:param PIL.Image image: The image to get the raw data for.
:param str format: The format to save to. If... | [
"def",
"_get_raw_data",
"(",
"self",
",",
"image",
",",
"format",
",",
"quality",
")",
":",
"ImageFile",
".",
"MAXBLOCK",
"=",
"1024",
"*",
"1024",
"buf",
"=",
"StringIO",
"(",
")",
"try",
":",
"# ptimize makes the encoder do a second pass over the image, if",
"... | Returns the raw data from the Image, which can be directly written
to a something, be it a file-like object or a database.
:param PIL.Image image: The image to get the raw data for.
:param str format: The format to save to. If this value is ``None``,
PIL will attempt to guess. You'r... | [
"Returns",
"the",
"raw",
"data",
"from",
"the",
"Image",
"which",
"can",
"be",
"directly",
"written",
"to",
"a",
"something",
"be",
"it",
"a",
"file",
"-",
"like",
"object",
"or",
"a",
"database",
"."
] | 69261ace0dff81e33156a54440874456a7b38dfb | https://github.com/gtaylor/django-athumb/blob/69261ace0dff81e33156a54440874456a7b38dfb/athumb/pial/engines/pil_engine.py#L101-L134 | train | Returns the raw data from the image which can be directly written
to a file - like object or a database. |
YosaiProject/yosai_alchemystore | yosai_alchemystore/conf/create_populate_db.py | get_permissions_query | def get_permissions_query(session, identifier_s):
"""
:type identifier_s: list
"""
thedomain = case([(Domain.name == None, '*')], else_=Domain.name)
theaction = case([(Action.name == None, '*')], else_=Action.name)
theresource = case([(Resource.name == None, '*')], else_=Resource.name)
acti... | python | def get_permissions_query(session, identifier_s):
"""
:type identifier_s: list
"""
thedomain = case([(Domain.name == None, '*')], else_=Domain.name)
theaction = case([(Action.name == None, '*')], else_=Action.name)
theresource = case([(Resource.name == None, '*')], else_=Resource.name)
acti... | [
"def",
"get_permissions_query",
"(",
"session",
",",
"identifier_s",
")",
":",
"thedomain",
"=",
"case",
"(",
"[",
"(",
"Domain",
".",
"name",
"==",
"None",
",",
"'*'",
")",
"]",
",",
"else_",
"=",
"Domain",
".",
"name",
")",
"theaction",
"=",
"case",
... | :type identifier_s: list | [
":",
"type",
"identifier_s",
":",
"list"
] | 6479c159ab2ac357e6b70cdd71a2d673279e86bb | https://github.com/YosaiProject/yosai_alchemystore/blob/6479c159ab2ac357e6b70cdd71a2d673279e86bb/yosai_alchemystore/conf/create_populate_db.py#L158-L178 | train | Get all permissions for a given list of identifiers. |
digidotcom/python-wvalib | wva/stream.py | WVAEventStream.emit_event | def emit_event(self, event):
"""Emit the specified event (notify listeners)"""
with self._lock:
listeners = list(self._event_listeners)
for cb in list(self._event_listeners):
# noinspection PyBroadException
try:
cb(event)
except:
... | python | def emit_event(self, event):
"""Emit the specified event (notify listeners)"""
with self._lock:
listeners = list(self._event_listeners)
for cb in list(self._event_listeners):
# noinspection PyBroadException
try:
cb(event)
except:
... | [
"def",
"emit_event",
"(",
"self",
",",
"event",
")",
":",
"with",
"self",
".",
"_lock",
":",
"listeners",
"=",
"list",
"(",
"self",
".",
"_event_listeners",
")",
"for",
"cb",
"in",
"list",
"(",
"self",
".",
"_event_listeners",
")",
":",
"# noinspection P... | Emit the specified event (notify listeners) | [
"Emit",
"the",
"specified",
"event",
"(",
"notify",
"listeners",
")"
] | 4252735e2775f80ebaffd813fbe84046d26906b3 | https://github.com/digidotcom/python-wvalib/blob/4252735e2775f80ebaffd813fbe84046d26906b3/wva/stream.py#L36-L47 | train | Emit an event. |
digidotcom/python-wvalib | wva/stream.py | WVAEventStream.enable | def enable(self):
"""Enable the stream thread
This operation will ensure that the thread that is responsible
for connecting to the WVA and triggering event callbacks is started.
This thread will continue to run and do what it needs to do to
maintain a connection to the WVA.
... | python | def enable(self):
"""Enable the stream thread
This operation will ensure that the thread that is responsible
for connecting to the WVA and triggering event callbacks is started.
This thread will continue to run and do what it needs to do to
maintain a connection to the WVA.
... | [
"def",
"enable",
"(",
"self",
")",
":",
"with",
"self",
".",
"_lock",
":",
"if",
"self",
".",
"_event_listener_thread",
"is",
"None",
":",
"self",
".",
"_event_listener_thread",
"=",
"WVAEventListenerThread",
"(",
"self",
",",
"self",
".",
"_http_client",
")... | Enable the stream thread
This operation will ensure that the thread that is responsible
for connecting to the WVA and triggering event callbacks is started.
This thread will continue to run and do what it needs to do to
maintain a connection to the WVA.
The status of the thread... | [
"Enable",
"the",
"stream",
"thread"
] | 4252735e2775f80ebaffd813fbe84046d26906b3 | https://github.com/digidotcom/python-wvalib/blob/4252735e2775f80ebaffd813fbe84046d26906b3/wva/stream.py#L49-L62 | train | Enable the stream thread
This operation will ensure that the thread that is responsible
is connected to the WVA and that the event listener thread is started. |
digidotcom/python-wvalib | wva/stream.py | WVAEventStream.disable | def disable(self):
"""Disconnect from the event stream"""
with self._lock:
if self._event_listener_thread is not None:
self._event_listener_thread.stop()
self._event_listener_thread = None | python | def disable(self):
"""Disconnect from the event stream"""
with self._lock:
if self._event_listener_thread is not None:
self._event_listener_thread.stop()
self._event_listener_thread = None | [
"def",
"disable",
"(",
"self",
")",
":",
"with",
"self",
".",
"_lock",
":",
"if",
"self",
".",
"_event_listener_thread",
"is",
"not",
"None",
":",
"self",
".",
"_event_listener_thread",
".",
"stop",
"(",
")",
"self",
".",
"_event_listener_thread",
"=",
"No... | Disconnect from the event stream | [
"Disconnect",
"from",
"the",
"event",
"stream"
] | 4252735e2775f80ebaffd813fbe84046d26906b3 | https://github.com/digidotcom/python-wvalib/blob/4252735e2775f80ebaffd813fbe84046d26906b3/wva/stream.py#L64-L69 | train | Disconnect from the event stream |
digidotcom/python-wvalib | wva/stream.py | WVAEventStream.get_status | def get_status(self):
"""Get the current status of the event stream system
The status will be one of the following:
- EVENT_STREAM_STATE_STOPPED: if the stream thread has not been enabled
- EVENT_STREAM_STATE_CONNECTING: the stream thread is running and
attempting to establ... | python | def get_status(self):
"""Get the current status of the event stream system
The status will be one of the following:
- EVENT_STREAM_STATE_STOPPED: if the stream thread has not been enabled
- EVENT_STREAM_STATE_CONNECTING: the stream thread is running and
attempting to establ... | [
"def",
"get_status",
"(",
"self",
")",
":",
"with",
"self",
".",
"_lock",
":",
"if",
"self",
".",
"_event_listener_thread",
"is",
"None",
":",
"return",
"EVENT_STREAM_STATE_DISABLED",
"else",
":",
"return",
"self",
".",
"_event_listener_thread",
".",
"get_state"... | Get the current status of the event stream system
The status will be one of the following:
- EVENT_STREAM_STATE_STOPPED: if the stream thread has not been enabled
- EVENT_STREAM_STATE_CONNECTING: the stream thread is running and
attempting to establish a connection to the WVA to re... | [
"Get",
"the",
"current",
"status",
"of",
"the",
"event",
"stream",
"system"
] | 4252735e2775f80ebaffd813fbe84046d26906b3 | https://github.com/digidotcom/python-wvalib/blob/4252735e2775f80ebaffd813fbe84046d26906b3/wva/stream.py#L71-L88 | train | Get the current status of the event stream system. |
digidotcom/python-wvalib | wva/stream.py | WVAEventListenerThread._parse_one_event | def _parse_one_event(self):
"""Parse the stream buffer and return either a single event or None"""
# WVA includes \r\n between messages which the parser doesn't like, so we
# throw away any data before a opening brace
try:
open_brace_idx = self._buf.index('{')
except ... | python | def _parse_one_event(self):
"""Parse the stream buffer and return either a single event or None"""
# WVA includes \r\n between messages which the parser doesn't like, so we
# throw away any data before a opening brace
try:
open_brace_idx = self._buf.index('{')
except ... | [
"def",
"_parse_one_event",
"(",
"self",
")",
":",
"# WVA includes \\r\\n between messages which the parser doesn't like, so we",
"# throw away any data before a opening brace",
"try",
":",
"open_brace_idx",
"=",
"self",
".",
"_buf",
".",
"index",
"(",
"'{'",
")",
"except",
... | Parse the stream buffer and return either a single event or None | [
"Parse",
"the",
"stream",
"buffer",
"and",
"return",
"either",
"a",
"single",
"event",
"or",
"None"
] | 4252735e2775f80ebaffd813fbe84046d26906b3 | https://github.com/digidotcom/python-wvalib/blob/4252735e2775f80ebaffd813fbe84046d26906b3/wva/stream.py#L144-L161 | train | Parse the stream buffer and return either a single event or None |
andy-z/ged4py | ged4py/parser.py | guess_codec | def guess_codec(file, errors="strict", require_char=False):
"""Look at file contents and guess its correct encoding.
File must be open in binary mode and positioned at offset 0. If BOM
record is present then it is assumed to be UTF-8 or UTF-16 encoded
file. GEDCOM header is searched for CHAR record and... | python | def guess_codec(file, errors="strict", require_char=False):
"""Look at file contents and guess its correct encoding.
File must be open in binary mode and positioned at offset 0. If BOM
record is present then it is assumed to be UTF-8 or UTF-16 encoded
file. GEDCOM header is searched for CHAR record and... | [
"def",
"guess_codec",
"(",
"file",
",",
"errors",
"=",
"\"strict\"",
",",
"require_char",
"=",
"False",
")",
":",
"# mapping of gedcom character set specifiers to Python encoding names",
"gedcom_char_to_codec",
"=",
"{",
"'ansel'",
":",
"'gedcom'",
",",
"}",
"# check BO... | Look at file contents and guess its correct encoding.
File must be open in binary mode and positioned at offset 0. If BOM
record is present then it is assumed to be UTF-8 or UTF-16 encoded
file. GEDCOM header is searched for CHAR record and encoding name
is extracted from it, if BOM record is present t... | [
"Look",
"at",
"file",
"contents",
"and",
"guess",
"its",
"correct",
"encoding",
"."
] | d0e0cceaadf0a84cbf052705e3c27303b12e1757 | https://github.com/andy-z/ged4py/blob/d0e0cceaadf0a84cbf052705e3c27303b12e1757/ged4py/parser.py#L60-L129 | train | Look at file contents and guess its correct encoding. |
andy-z/ged4py | ged4py/parser.py | GedcomReader.dialect | def dialect(self):
"""File dialect as one of model.DIALECT_* constants
"""
if self._dialect is None:
self._dialect = model.DIALECT_DEFAULT
if self.header:
source = self.header.sub_tag("SOUR")
if source:
if source.value =... | python | def dialect(self):
"""File dialect as one of model.DIALECT_* constants
"""
if self._dialect is None:
self._dialect = model.DIALECT_DEFAULT
if self.header:
source = self.header.sub_tag("SOUR")
if source:
if source.value =... | [
"def",
"dialect",
"(",
"self",
")",
":",
"if",
"self",
".",
"_dialect",
"is",
"None",
":",
"self",
".",
"_dialect",
"=",
"model",
".",
"DIALECT_DEFAULT",
"if",
"self",
".",
"header",
":",
"source",
"=",
"self",
".",
"header",
".",
"sub_tag",
"(",
"\"... | File dialect as one of model.DIALECT_* constants | [
"File",
"dialect",
"as",
"one",
"of",
"model",
".",
"DIALECT_",
"*",
"constants"
] | d0e0cceaadf0a84cbf052705e3c27303b12e1757 | https://github.com/andy-z/ged4py/blob/d0e0cceaadf0a84cbf052705e3c27303b12e1757/ged4py/parser.py#L223-L237 | train | Return the file dialect as one of model. DIALECT_* constants
|
andy-z/ged4py | ged4py/parser.py | GedcomReader.gedcom_lines | def gedcom_lines(self, offset):
"""Generator method for *gedcom lines*.
GEDCOM line grammar is defined in Chapter 1 of GEDCOM standard, it
consists of the level number, optional reference ID, tag name, and
optional value separated by spaces. Chaper 1 is pure grammar level,
it do... | python | def gedcom_lines(self, offset):
"""Generator method for *gedcom lines*.
GEDCOM line grammar is defined in Chapter 1 of GEDCOM standard, it
consists of the level number, optional reference ID, tag name, and
optional value separated by spaces. Chaper 1 is pure grammar level,
it do... | [
"def",
"gedcom_lines",
"(",
"self",
",",
"offset",
")",
":",
"self",
".",
"_file",
".",
"seek",
"(",
"offset",
")",
"prev_gline",
"=",
"None",
"while",
"True",
":",
"offset",
"=",
"self",
".",
"_file",
".",
"tell",
"(",
")",
"line",
"=",
"self",
".... | Generator method for *gedcom lines*.
GEDCOM line grammar is defined in Chapter 1 of GEDCOM standard, it
consists of the level number, optional reference ID, tag name, and
optional value separated by spaces. Chaper 1 is pure grammar level,
it does not assign any semantics to tags or leve... | [
"Generator",
"method",
"for",
"*",
"gedcom",
"lines",
"*",
"."
] | d0e0cceaadf0a84cbf052705e3c27303b12e1757 | https://github.com/andy-z/ged4py/blob/d0e0cceaadf0a84cbf052705e3c27303b12e1757/ged4py/parser.py#L243-L317 | train | Generator method for gedcom_lines. |
andy-z/ged4py | ged4py/parser.py | GedcomReader.records0 | def records0(self, tag=None):
"""Iterator over all level=0 records.
:param str tag: If ``None`` is given (default) then return all level=0
records, otherwise return level=0 records with the given tag.
"""
_log.debug("in records0")
for offset, xtag in self.index0:
... | python | def records0(self, tag=None):
"""Iterator over all level=0 records.
:param str tag: If ``None`` is given (default) then return all level=0
records, otherwise return level=0 records with the given tag.
"""
_log.debug("in records0")
for offset, xtag in self.index0:
... | [
"def",
"records0",
"(",
"self",
",",
"tag",
"=",
"None",
")",
":",
"_log",
".",
"debug",
"(",
"\"in records0\"",
")",
"for",
"offset",
",",
"xtag",
"in",
"self",
".",
"index0",
":",
"_log",
".",
"debug",
"(",
"\" records0: offset: %s; xtag: %s\"",
",",
... | Iterator over all level=0 records.
:param str tag: If ``None`` is given (default) then return all level=0
records, otherwise return level=0 records with the given tag. | [
"Iterator",
"over",
"all",
"level",
"=",
"0",
"records",
"."
] | d0e0cceaadf0a84cbf052705e3c27303b12e1757 | https://github.com/andy-z/ged4py/blob/d0e0cceaadf0a84cbf052705e3c27303b12e1757/ged4py/parser.py#L319-L329 | train | Iterator over all level = 0 records. |
andy-z/ged4py | ged4py/parser.py | GedcomReader.read_record | def read_record(self, offset):
"""Read next complete record from a file starting at given position.
Reads the record at given position and all its sub-records. Stops
reading at EOF or next record with the same or higher (smaller) level
number. File position after return from this method... | python | def read_record(self, offset):
"""Read next complete record from a file starting at given position.
Reads the record at given position and all its sub-records. Stops
reading at EOF or next record with the same or higher (smaller) level
number. File position after return from this method... | [
"def",
"read_record",
"(",
"self",
",",
"offset",
")",
":",
"_log",
".",
"debug",
"(",
"\"in read_record(%s)\"",
",",
"offset",
")",
"stack",
"=",
"[",
"]",
"# stores per-level current records",
"reclevel",
"=",
"None",
"for",
"gline",
"in",
"self",
".",
"ge... | Read next complete record from a file starting at given position.
Reads the record at given position and all its sub-records. Stops
reading at EOF or next record with the same or higher (smaller) level
number. File position after return from this method is not specified,
re-position fil... | [
"Read",
"next",
"complete",
"record",
"from",
"a",
"file",
"starting",
"at",
"given",
"position",
"."
] | d0e0cceaadf0a84cbf052705e3c27303b12e1757 | https://github.com/andy-z/ged4py/blob/d0e0cceaadf0a84cbf052705e3c27303b12e1757/ged4py/parser.py#L331-L388 | train | Reads next complete record from a file starting at given position. |
andy-z/ged4py | ged4py/parser.py | GedcomReader._make_record | def _make_record(self, parent, gline):
"""Process next record.
This method created new record from the line read from file if
needed and/or updates its parent record. If the parent record tag
is ``BLOB`` and new record tag is ``CONT`` then record is skipped
entirely and None is ... | python | def _make_record(self, parent, gline):
"""Process next record.
This method created new record from the line read from file if
needed and/or updates its parent record. If the parent record tag
is ``BLOB`` and new record tag is ``CONT`` then record is skipped
entirely and None is ... | [
"def",
"_make_record",
"(",
"self",
",",
"parent",
",",
"gline",
")",
":",
"if",
"parent",
"and",
"gline",
".",
"tag",
"in",
"(",
"\"CONT\"",
",",
"\"CONC\"",
")",
":",
"# concatenate, only for non-BLOBs",
"if",
"parent",
".",
"tag",
"!=",
"\"BLOB\"",
":",... | Process next record.
This method created new record from the line read from file if
needed and/or updates its parent record. If the parent record tag
is ``BLOB`` and new record tag is ``CONT`` then record is skipped
entirely and None is returned. Otherwise if new record tag is ``CONT``
... | [
"Process",
"next",
"record",
"."
] | d0e0cceaadf0a84cbf052705e3c27303b12e1757 | https://github.com/andy-z/ged4py/blob/d0e0cceaadf0a84cbf052705e3c27303b12e1757/ged4py/parser.py#L390-L436 | train | This method creates a new record from the line read from file if needed and updates its parent record. |
newfies-dialer/python-msspeak | msspeak/command_line.py | validate_options | def validate_options(subscription_key, text):
"""
Perform sanity checks on threshold values
"""
if not subscription_key or len(subscription_key) == 0:
print 'Error: Warning the option subscription_key should contain a string.'
print USAGE
sys.exit(3)
if not text or len(text) ... | python | def validate_options(subscription_key, text):
"""
Perform sanity checks on threshold values
"""
if not subscription_key or len(subscription_key) == 0:
print 'Error: Warning the option subscription_key should contain a string.'
print USAGE
sys.exit(3)
if not text or len(text) ... | [
"def",
"validate_options",
"(",
"subscription_key",
",",
"text",
")",
":",
"if",
"not",
"subscription_key",
"or",
"len",
"(",
"subscription_key",
")",
"==",
"0",
":",
"print",
"'Error: Warning the option subscription_key should contain a string.'",
"print",
"USAGE",
"sy... | Perform sanity checks on threshold values | [
"Perform",
"sanity",
"checks",
"on",
"threshold",
"values"
] | 106475122be73df152865c4fe6e9388caf974085 | https://github.com/newfies-dialer/python-msspeak/blob/106475122be73df152865c4fe6e9388caf974085/msspeak/command_line.py#L40-L51 | train | Perform sanity checks on threshold values
|
newfies-dialer/python-msspeak | msspeak/command_line.py | main | def main():
"""
Parse options and process text to Microsoft Translate
"""
# Parse arguments
parser = OptionParser()
parser.add_option('-n', '--subscription_key', dest='subscription_key',
help='subscription_key for authentication')
parser.add_option('-t', '--text', dest... | python | def main():
"""
Parse options and process text to Microsoft Translate
"""
# Parse arguments
parser = OptionParser()
parser.add_option('-n', '--subscription_key', dest='subscription_key',
help='subscription_key for authentication')
parser.add_option('-t', '--text', dest... | [
"def",
"main",
"(",
")",
":",
"# Parse arguments",
"parser",
"=",
"OptionParser",
"(",
")",
"parser",
".",
"add_option",
"(",
"'-n'",
",",
"'--subscription_key'",
",",
"dest",
"=",
"'subscription_key'",
",",
"help",
"=",
"'subscription_key for authentication'",
")... | Parse options and process text to Microsoft Translate | [
"Parse",
"options",
"and",
"process",
"text",
"to",
"Microsoft",
"Translate"
] | 106475122be73df152865c4fe6e9388caf974085 | https://github.com/newfies-dialer/python-msspeak/blob/106475122be73df152865c4fe6e9388caf974085/msspeak/command_line.py#L54-L99 | train | Main function for Microsoft Translate
|
digidotcom/python-wvalib | wva/vehicle.py | VehicleDataElement.sample | def sample(self):
"""Get the current value of this vehicle data element
The returned value will be a namedtuple with 'value' and
'timestamp' elements. Example::
speed_el = wva.get_vehicle_data_element('VehicleSpeed')
for i in xrange(10):
speed = speed_e... | python | def sample(self):
"""Get the current value of this vehicle data element
The returned value will be a namedtuple with 'value' and
'timestamp' elements. Example::
speed_el = wva.get_vehicle_data_element('VehicleSpeed')
for i in xrange(10):
speed = speed_e... | [
"def",
"sample",
"(",
"self",
")",
":",
"# Response: {'VehicleSpeed': {'timestamp': '2015-03-20T18:00:49Z', 'value': 223.368515}}",
"data",
"=",
"self",
".",
"_http_client",
".",
"get",
"(",
"\"vehicle/data/{}\"",
".",
"format",
"(",
"self",
".",
"name",
")",
")",
"["... | Get the current value of this vehicle data element
The returned value will be a namedtuple with 'value' and
'timestamp' elements. Example::
speed_el = wva.get_vehicle_data_element('VehicleSpeed')
for i in xrange(10):
speed = speed_el.sample()
pr... | [
"Get",
"the",
"current",
"value",
"of",
"this",
"vehicle",
"data",
"element"
] | 4252735e2775f80ebaffd813fbe84046d26906b3 | https://github.com/digidotcom/python-wvalib/blob/4252735e2775f80ebaffd813fbe84046d26906b3/wva/vehicle.py#L20-L36 | train | Get the current value of this vehicle data element. |
gtaylor/django-athumb | athumb/backends/s3boto.py | S3BotoStorage._get_host | def _get_host(self, region):
"""
Returns correctly formatted host. Accepted formats:
* simple region name, eg 'us-west-1' (see list in AWS_REGIONS)
* full host name, eg 's3-us-west-1.amazonaws.com'.
"""
if 'us-east-1' in region:
return 's3.amazonaws.c... | python | def _get_host(self, region):
"""
Returns correctly formatted host. Accepted formats:
* simple region name, eg 'us-west-1' (see list in AWS_REGIONS)
* full host name, eg 's3-us-west-1.amazonaws.com'.
"""
if 'us-east-1' in region:
return 's3.amazonaws.c... | [
"def",
"_get_host",
"(",
"self",
",",
"region",
")",
":",
"if",
"'us-east-1'",
"in",
"region",
":",
"return",
"'s3.amazonaws.com'",
"elif",
"region",
"in",
"AWS_REGIONS",
":",
"return",
"'s3-%s.amazonaws.com'",
"%",
"region",
"elif",
"region",
"and",
"not",
"R... | Returns correctly formatted host. Accepted formats:
* simple region name, eg 'us-west-1' (see list in AWS_REGIONS)
* full host name, eg 's3-us-west-1.amazonaws.com'. | [
"Returns",
"correctly",
"formatted",
"host",
".",
"Accepted",
"formats",
":"
] | 69261ace0dff81e33156a54440874456a7b38dfb | https://github.com/gtaylor/django-athumb/blob/69261ace0dff81e33156a54440874456a7b38dfb/athumb/backends/s3boto.py#L112-L126 | train | Returns correctly formatted host name for the given region. |
gtaylor/django-athumb | athumb/backends/s3boto.py | S3BotoStorage._get_or_create_bucket | def _get_or_create_bucket(self, name):
"""Retrieves a bucket if it exists, otherwise creates it."""
try:
return self.connection.get_bucket(name)
except S3ResponseError, e:
if AUTO_CREATE_BUCKET:
return self.connection.create_bucket(name)
raise ... | python | def _get_or_create_bucket(self, name):
"""Retrieves a bucket if it exists, otherwise creates it."""
try:
return self.connection.get_bucket(name)
except S3ResponseError, e:
if AUTO_CREATE_BUCKET:
return self.connection.create_bucket(name)
raise ... | [
"def",
"_get_or_create_bucket",
"(",
"self",
",",
"name",
")",
":",
"try",
":",
"return",
"self",
".",
"connection",
".",
"get_bucket",
"(",
"name",
")",
"except",
"S3ResponseError",
",",
"e",
":",
"if",
"AUTO_CREATE_BUCKET",
":",
"return",
"self",
".",
"c... | Retrieves a bucket if it exists, otherwise creates it. | [
"Retrieves",
"a",
"bucket",
"if",
"it",
"exists",
"otherwise",
"creates",
"it",
"."
] | 69261ace0dff81e33156a54440874456a7b38dfb | https://github.com/gtaylor/django-athumb/blob/69261ace0dff81e33156a54440874456a7b38dfb/athumb/backends/s3boto.py#L128-L137 | train | Retrieves a bucket if it exists otherwise creates it. |
gtaylor/django-athumb | athumb/backends/s3boto.py | S3BotoStorage._compress_content | def _compress_content(self, content):
"""Gzip a given string."""
zbuf = StringIO()
zfile = GzipFile(mode='wb', compresslevel=6, fileobj=zbuf)
zfile.write(content.read())
zfile.close()
content.file = zbuf
return content | python | def _compress_content(self, content):
"""Gzip a given string."""
zbuf = StringIO()
zfile = GzipFile(mode='wb', compresslevel=6, fileobj=zbuf)
zfile.write(content.read())
zfile.close()
content.file = zbuf
return content | [
"def",
"_compress_content",
"(",
"self",
",",
"content",
")",
":",
"zbuf",
"=",
"StringIO",
"(",
")",
"zfile",
"=",
"GzipFile",
"(",
"mode",
"=",
"'wb'",
",",
"compresslevel",
"=",
"6",
",",
"fileobj",
"=",
"zbuf",
")",
"zfile",
".",
"write",
"(",
"c... | Gzip a given string. | [
"Gzip",
"a",
"given",
"string",
"."
] | 69261ace0dff81e33156a54440874456a7b38dfb | https://github.com/gtaylor/django-athumb/blob/69261ace0dff81e33156a54440874456a7b38dfb/athumb/backends/s3boto.py#L143-L150 | train | Gzip a given string. |
gtaylor/django-athumb | athumb/backends/s3boto.py | S3BotoStorage_AllPublic.url | def url(self, name):
"""
Since we assume all public storage with no authorization keys, we can
just simply dump out a URL rather than having to query S3 for new keys.
"""
name = urllib.quote_plus(self._clean_name(name), safe='/')
if self.bucket_cname:
return ... | python | def url(self, name):
"""
Since we assume all public storage with no authorization keys, we can
just simply dump out a URL rather than having to query S3 for new keys.
"""
name = urllib.quote_plus(self._clean_name(name), safe='/')
if self.bucket_cname:
return ... | [
"def",
"url",
"(",
"self",
",",
"name",
")",
":",
"name",
"=",
"urllib",
".",
"quote_plus",
"(",
"self",
".",
"_clean_name",
"(",
"name",
")",
",",
"safe",
"=",
"'/'",
")",
"if",
"self",
".",
"bucket_cname",
":",
"return",
"\"http://%s/%s\"",
"%",
"(... | Since we assume all public storage with no authorization keys, we can
just simply dump out a URL rather than having to query S3 for new keys. | [
"Since",
"we",
"assume",
"all",
"public",
"storage",
"with",
"no",
"authorization",
"keys",
"we",
"can",
"just",
"simply",
"dump",
"out",
"a",
"URL",
"rather",
"than",
"having",
"to",
"query",
"S3",
"for",
"new",
"keys",
"."
] | 69261ace0dff81e33156a54440874456a7b38dfb | https://github.com/gtaylor/django-athumb/blob/69261ace0dff81e33156a54440874456a7b38dfb/athumb/backends/s3boto.py#L260-L272 | train | Return the URL for the given key. |
pennlabs/penn-sdk-python | penn/dining.py | normalize_weekly | def normalize_weekly(data):
"""Normalization for dining menu data"""
if "tblMenu" not in data["result_data"]["Document"]:
data["result_data"]["Document"]["tblMenu"] = []
if isinstance(data["result_data"]["Document"]["tblMenu"], dict):
data["result_data"]["Document"]["tblMenu"] = [data["resul... | python | def normalize_weekly(data):
"""Normalization for dining menu data"""
if "tblMenu" not in data["result_data"]["Document"]:
data["result_data"]["Document"]["tblMenu"] = []
if isinstance(data["result_data"]["Document"]["tblMenu"], dict):
data["result_data"]["Document"]["tblMenu"] = [data["resul... | [
"def",
"normalize_weekly",
"(",
"data",
")",
":",
"if",
"\"tblMenu\"",
"not",
"in",
"data",
"[",
"\"result_data\"",
"]",
"[",
"\"Document\"",
"]",
":",
"data",
"[",
"\"result_data\"",
"]",
"[",
"\"Document\"",
"]",
"[",
"\"tblMenu\"",
"]",
"=",
"[",
"]",
... | Normalization for dining menu data | [
"Normalization",
"for",
"dining",
"menu",
"data"
] | 31ff12c20d69438d63bc7a796f83ce4f4c828396 | https://github.com/pennlabs/penn-sdk-python/blob/31ff12c20d69438d63bc7a796f83ce4f4c828396/penn/dining.py#L29-L46 | train | Normalizes for dining menu data |
pennlabs/penn-sdk-python | penn/dining.py | get_meals | def get_meals(v2_response, building_id):
"""Extract meals into old format from a DiningV2 JSON response"""
result_data = v2_response["result_data"]
meals = []
day_parts = result_data["days"][0]["cafes"][building_id]["dayparts"][0]
for meal in day_parts:
stations = []
for station in m... | python | def get_meals(v2_response, building_id):
"""Extract meals into old format from a DiningV2 JSON response"""
result_data = v2_response["result_data"]
meals = []
day_parts = result_data["days"][0]["cafes"][building_id]["dayparts"][0]
for meal in day_parts:
stations = []
for station in m... | [
"def",
"get_meals",
"(",
"v2_response",
",",
"building_id",
")",
":",
"result_data",
"=",
"v2_response",
"[",
"\"result_data\"",
"]",
"meals",
"=",
"[",
"]",
"day_parts",
"=",
"result_data",
"[",
"\"days\"",
"]",
"[",
"0",
"]",
"[",
"\"cafes\"",
"]",
"[",
... | Extract meals into old format from a DiningV2 JSON response | [
"Extract",
"meals",
"into",
"old",
"format",
"from",
"a",
"DiningV2",
"JSON",
"response"
] | 31ff12c20d69438d63bc7a796f83ce4f4c828396 | https://github.com/pennlabs/penn-sdk-python/blob/31ff12c20d69438d63bc7a796f83ce4f4c828396/penn/dining.py#L49-L82 | train | Extract meals from a DiningV2 JSON response |
pennlabs/penn-sdk-python | penn/dining.py | DiningV2.menu | def menu(self, venue_id, date):
"""Get the menu for the venue corresponding to venue_id,
on date.
:param venue_id:
A string representing the id of a venue, e.g. "abc".
:param date:
A string representing the date of a venue's menu, e.g. "2015-09-20".
>>> com... | python | def menu(self, venue_id, date):
"""Get the menu for the venue corresponding to venue_id,
on date.
:param venue_id:
A string representing the id of a venue, e.g. "abc".
:param date:
A string representing the date of a venue's menu, e.g. "2015-09-20".
>>> com... | [
"def",
"menu",
"(",
"self",
",",
"venue_id",
",",
"date",
")",
":",
"query",
"=",
"\"&date=\"",
"+",
"date",
"response",
"=",
"self",
".",
"_request",
"(",
"V2_ENDPOINTS",
"[",
"'MENUS'",
"]",
"+",
"venue_id",
"+",
"query",
")",
"return",
"response"
] | Get the menu for the venue corresponding to venue_id,
on date.
:param venue_id:
A string representing the id of a venue, e.g. "abc".
:param date:
A string representing the date of a venue's menu, e.g. "2015-09-20".
>>> commons_menu = din.menu("593", "2015-09-20") | [
"Get",
"the",
"menu",
"for",
"the",
"venue",
"corresponding",
"to",
"venue_id",
"on",
"date",
"."
] | 31ff12c20d69438d63bc7a796f83ce4f4c828396 | https://github.com/pennlabs/penn-sdk-python/blob/31ff12c20d69438d63bc7a796f83ce4f4c828396/penn/dining.py#L117-L131 | train | Get the menu for the venue corresponding to venue_id on date. |
pennlabs/penn-sdk-python | penn/dining.py | Dining.venues | def venues(self):
"""Get a list of all venue objects.
>>> venues = din.venues()
"""
response = self._request(V2_ENDPOINTS['VENUES'])
# Normalize `dateHours` to array
for venue in response["result_data"]["document"]["venue"]:
if venue.get("id") in VENUE_NAME... | python | def venues(self):
"""Get a list of all venue objects.
>>> venues = din.venues()
"""
response = self._request(V2_ENDPOINTS['VENUES'])
# Normalize `dateHours` to array
for venue in response["result_data"]["document"]["venue"]:
if venue.get("id") in VENUE_NAME... | [
"def",
"venues",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"_request",
"(",
"V2_ENDPOINTS",
"[",
"'VENUES'",
"]",
")",
"# Normalize `dateHours` to array",
"for",
"venue",
"in",
"response",
"[",
"\"result_data\"",
"]",
"[",
"\"document\"",
"]",
"[",
... | Get a list of all venue objects.
>>> venues = din.venues() | [
"Get",
"a",
"list",
"of",
"all",
"venue",
"objects",
"."
] | 31ff12c20d69438d63bc7a796f83ce4f4c828396 | https://github.com/pennlabs/penn-sdk-python/blob/31ff12c20d69438d63bc7a796f83ce4f4c828396/penn/dining.py#L157-L173 | train | Get a list of all venue objects. |
pennlabs/penn-sdk-python | penn/dining.py | Dining.menu_daily | def menu_daily(self, building_id):
"""Get a menu object corresponding to the daily menu for the
venue with building_id.
:param building_id:
A string representing the id of a building, e.g. "abc".
>>> commons_today = din.menu_daily("593")
"""
today = str(datet... | python | def menu_daily(self, building_id):
"""Get a menu object corresponding to the daily menu for the
venue with building_id.
:param building_id:
A string representing the id of a building, e.g. "abc".
>>> commons_today = din.menu_daily("593")
"""
today = str(datet... | [
"def",
"menu_daily",
"(",
"self",
",",
"building_id",
")",
":",
"today",
"=",
"str",
"(",
"datetime",
".",
"date",
".",
"today",
"(",
")",
")",
"v2_response",
"=",
"DiningV2",
"(",
"self",
".",
"bearer",
",",
"self",
".",
"token",
")",
".",
"menu",
... | Get a menu object corresponding to the daily menu for the
venue with building_id.
:param building_id:
A string representing the id of a building, e.g. "abc".
>>> commons_today = din.menu_daily("593") | [
"Get",
"a",
"menu",
"object",
"corresponding",
"to",
"the",
"daily",
"menu",
"for",
"the",
"venue",
"with",
"building_id",
"."
] | 31ff12c20d69438d63bc7a796f83ce4f4c828396 | https://github.com/pennlabs/penn-sdk-python/blob/31ff12c20d69438d63bc7a796f83ce4f4c828396/penn/dining.py#L175-L194 | train | Get a daily menu for the given building_id. |
pennlabs/penn-sdk-python | penn/dining.py | Dining.menu_weekly | def menu_weekly(self, building_id):
"""Get an array of menu objects corresponding to the weekly menu for the
venue with building_id.
:param building_id:
A string representing the id of a building, e.g. "abc".
>>> commons_week = din.menu_weekly("593")
"""
din... | python | def menu_weekly(self, building_id):
"""Get an array of menu objects corresponding to the weekly menu for the
venue with building_id.
:param building_id:
A string representing the id of a building, e.g. "abc".
>>> commons_week = din.menu_weekly("593")
"""
din... | [
"def",
"menu_weekly",
"(",
"self",
",",
"building_id",
")",
":",
"din",
"=",
"DiningV2",
"(",
"self",
".",
"bearer",
",",
"self",
".",
"token",
")",
"response",
"=",
"{",
"'result_data'",
":",
"{",
"'Document'",
":",
"{",
"}",
"}",
"}",
"days",
"=",
... | Get an array of menu objects corresponding to the weekly menu for the
venue with building_id.
:param building_id:
A string representing the id of a building, e.g. "abc".
>>> commons_week = din.menu_weekly("593") | [
"Get",
"an",
"array",
"of",
"menu",
"objects",
"corresponding",
"to",
"the",
"weekly",
"menu",
"for",
"the",
"venue",
"with",
"building_id",
"."
] | 31ff12c20d69438d63bc7a796f83ce4f4c828396 | https://github.com/pennlabs/penn-sdk-python/blob/31ff12c20d69438d63bc7a796f83ce4f4c828396/penn/dining.py#L196-L218 | train | Return an array of menu objects corresponding to the weekly menu for the given building_id. |
bendmorris/python-geocode | geocode.py | latlon | def latlon(location, throttle=0.5, center=True, round_digits=2):
'''Look up the latitude/longitude coordinates of a given location using the
Google Maps API. The result is cached to avoid redundant API requests.
throttle: send at most one request in this many seconds
center: return the center of th... | python | def latlon(location, throttle=0.5, center=True, round_digits=2):
'''Look up the latitude/longitude coordinates of a given location using the
Google Maps API. The result is cached to avoid redundant API requests.
throttle: send at most one request in this many seconds
center: return the center of th... | [
"def",
"latlon",
"(",
"location",
",",
"throttle",
"=",
"0.5",
",",
"center",
"=",
"True",
",",
"round_digits",
"=",
"2",
")",
":",
"global",
"last_read",
"if",
"isinstance",
"(",
"location",
",",
"list",
")",
":",
"return",
"map",
"(",
"lambda",
"x",
... | Look up the latitude/longitude coordinates of a given location using the
Google Maps API. The result is cached to avoid redundant API requests.
throttle: send at most one request in this many seconds
center: return the center of the region; if False, returns the region
(lat1, lon1, lat2, lo... | [
"Look",
"up",
"the",
"latitude",
"/",
"longitude",
"coordinates",
"of",
"a",
"given",
"location",
"using",
"the",
"Google",
"Maps",
"API",
".",
"The",
"result",
"is",
"cached",
"to",
"avoid",
"redundant",
"API",
"requests",
".",
"throttle",
":",
"send",
"a... | 0f722545abcaf4a02d621ca07271a1c831164afd | https://github.com/bendmorris/python-geocode/blob/0f722545abcaf4a02d621ca07271a1c831164afd/geocode.py#L32-L88 | train | Look up the latitude and longitude coordinates of a given location using the Google Maps API. |
geophysics-ubonn/reda | lib/reda/containers/TDIP.py | TDIP.plot_decay_curve | def plot_decay_curve(self, filename=None, index_nor=None, index_rec=None,
nr_id=None, abmn=None,
return_fig=False):
"""Plot decay curve
Input scheme: We recognize three ways to specify the quadrupoles to
plot (in descending priority):
... | python | def plot_decay_curve(self, filename=None, index_nor=None, index_rec=None,
nr_id=None, abmn=None,
return_fig=False):
"""Plot decay curve
Input scheme: We recognize three ways to specify the quadrupoles to
plot (in descending priority):
... | [
"def",
"plot_decay_curve",
"(",
"self",
",",
"filename",
"=",
"None",
",",
"index_nor",
"=",
"None",
",",
"index_rec",
"=",
"None",
",",
"nr_id",
"=",
"None",
",",
"abmn",
"=",
"None",
",",
"return_fig",
"=",
"False",
")",
":",
"def",
"get_indices_for_id... | Plot decay curve
Input scheme: We recognize three ways to specify the quadrupoles to
plot (in descending priority):
1) indices for normal/reciprocal
2) by specifying the id
3) by specifying abmn (note that here the exact quadrupole must be
present. Fo... | [
"Plot",
"decay",
"curve"
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/containers/TDIP.py#L41-L172 | train | Plot the decay curve for the current language. |
geophysics-ubonn/reda | lib/reda/containers/TDIP.py | TDIP.to_cr | def to_cr(self):
"""Convert container to a complex resistivity container, using the
CPA-conversion.
Kemna, 2000
COMPLEX RESISTIVITY COPPER MlNERALlZATlONt SPECTRA OF PORPHYRY
Van Voorhis, G. D.; Nelson, P. H.; Drake, T. L.
Geophysics (1973 Jan 1) 38 (1): 49-60.
... | python | def to_cr(self):
"""Convert container to a complex resistivity container, using the
CPA-conversion.
Kemna, 2000
COMPLEX RESISTIVITY COPPER MlNERALlZATlONt SPECTRA OF PORPHYRY
Van Voorhis, G. D.; Nelson, P. H.; Drake, T. L.
Geophysics (1973 Jan 1) 38 (1): 49-60.
... | [
"def",
"to_cr",
"(",
"self",
")",
":",
"data_new",
"=",
"self",
".",
"data",
".",
"copy",
"(",
")",
"data_new",
"[",
"'rpha'",
"]",
"=",
"-",
"1.5",
"*",
"data_new",
"[",
"'chargeability'",
"]",
"# now that we have magnitude and phase, compute the impedance Zt",... | Convert container to a complex resistivity container, using the
CPA-conversion.
Kemna, 2000
COMPLEX RESISTIVITY COPPER MlNERALlZATlONt SPECTRA OF PORPHYRY
Van Voorhis, G. D.; Nelson, P. H.; Drake, T. L.
Geophysics (1973 Jan 1) 38 (1): 49-60.
Application of complex resi... | [
"Convert",
"container",
"to",
"a",
"complex",
"resistivity",
"container",
"using",
"the",
"CPA",
"-",
"conversion",
"."
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/containers/TDIP.py#L174-L200 | train | Convert the current state of the object to a complex resistivity container. |
frasertweedale/ledgertools | ltlib/config.py | apply | def apply(filter):
"""Manufacture decorator that filters return value with given function.
``filter``:
Callable that takes a single parameter.
"""
def decorator(callable):
return lambda *args, **kwargs: filter(callable(*args, **kwargs))
return decorator | python | def apply(filter):
"""Manufacture decorator that filters return value with given function.
``filter``:
Callable that takes a single parameter.
"""
def decorator(callable):
return lambda *args, **kwargs: filter(callable(*args, **kwargs))
return decorator | [
"def",
"apply",
"(",
"filter",
")",
":",
"def",
"decorator",
"(",
"callable",
")",
":",
"return",
"lambda",
"*",
"args",
",",
"*",
"*",
"kwargs",
":",
"filter",
"(",
"callable",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
")",
"return",
"decora... | Manufacture decorator that filters return value with given function.
``filter``:
Callable that takes a single parameter. | [
"Manufacture",
"decorator",
"that",
"filters",
"return",
"value",
"with",
"given",
"function",
"."
] | a695f8667d72253e5448693c12f0282d09902aaa | https://github.com/frasertweedale/ledgertools/blob/a695f8667d72253e5448693c12f0282d09902aaa/ltlib/config.py#L22-L30 | train | Manufacture decorator that filters return value with given function. |
frasertweedale/ledgertools | ltlib/config.py | format_outpat | def format_outpat(outpat, xn):
"""
Format an outpat for the given transaction.
Format the given output filename pattern. The pattern should
be a format string with any combination of the following named
fields:
``year``
The year of the transaction.
``month``
The month of the t... | python | def format_outpat(outpat, xn):
"""
Format an outpat for the given transaction.
Format the given output filename pattern. The pattern should
be a format string with any combination of the following named
fields:
``year``
The year of the transaction.
``month``
The month of the t... | [
"def",
"format_outpat",
"(",
"outpat",
",",
"xn",
")",
":",
"return",
"outpat",
".",
"format",
"(",
"year",
"=",
"str",
"(",
"xn",
".",
"date",
".",
"year",
")",
",",
"month",
"=",
"'{:02}'",
".",
"format",
"(",
"xn",
".",
"date",
".",
"month",
"... | Format an outpat for the given transaction.
Format the given output filename pattern. The pattern should
be a format string with any combination of the following named
fields:
``year``
The year of the transaction.
``month``
The month of the transaction, with leading zero for
sin... | [
"Format",
"an",
"outpat",
"for",
"the",
"given",
"transaction",
"."
] | a695f8667d72253e5448693c12f0282d09902aaa | https://github.com/frasertweedale/ledgertools/blob/a695f8667d72253e5448693c12f0282d09902aaa/ltlib/config.py#L33-L60 | train | Formats an output filename pattern for the given transaction. |
frasertweedale/ledgertools | ltlib/config.py | Config.get | def get(self, name, acc=None, default=None):
"""Return the named config for the given account.
If an account is given, first checks the account space for the name.
If no account given, or if the name not found in the account space,
look for the name in the global config space. If still... | python | def get(self, name, acc=None, default=None):
"""Return the named config for the given account.
If an account is given, first checks the account space for the name.
If no account given, or if the name not found in the account space,
look for the name in the global config space. If still... | [
"def",
"get",
"(",
"self",
",",
"name",
",",
"acc",
"=",
"None",
",",
"default",
"=",
"None",
")",
":",
"if",
"acc",
"in",
"self",
".",
"data",
"[",
"'accounts'",
"]",
"and",
"name",
"in",
"self",
".",
"data",
"[",
"'accounts'",
"]",
"[",
"acc",
... | Return the named config for the given account.
If an account is given, first checks the account space for the name.
If no account given, or if the name not found in the account space,
look for the name in the global config space. If still not found,
return the default, if given, otherw... | [
"Return",
"the",
"named",
"config",
"for",
"the",
"given",
"account",
"."
] | a695f8667d72253e5448693c12f0282d09902aaa | https://github.com/frasertweedale/ledgertools/blob/a695f8667d72253e5448693c12f0282d09902aaa/ltlib/config.py#L84-L96 | train | Return the named config for the given account. |
frasertweedale/ledgertools | ltlib/config.py | Config.outdir | def outdir(self, acc=None):
"""Return the outdir for the given account.
Attempts to create the directory if it does not exist.
"""
rootdir = self.rootdir()
outdir = self.get('outdir', acc=acc)
dir = os.path.join(rootdir, outdir) if rootdir and outdir else None
if... | python | def outdir(self, acc=None):
"""Return the outdir for the given account.
Attempts to create the directory if it does not exist.
"""
rootdir = self.rootdir()
outdir = self.get('outdir', acc=acc)
dir = os.path.join(rootdir, outdir) if rootdir and outdir else None
if... | [
"def",
"outdir",
"(",
"self",
",",
"acc",
"=",
"None",
")",
":",
"rootdir",
"=",
"self",
".",
"rootdir",
"(",
")",
"outdir",
"=",
"self",
".",
"get",
"(",
"'outdir'",
",",
"acc",
"=",
"acc",
")",
"dir",
"=",
"os",
".",
"path",
".",
"join",
"(",... | Return the outdir for the given account.
Attempts to create the directory if it does not exist. | [
"Return",
"the",
"outdir",
"for",
"the",
"given",
"account",
"."
] | a695f8667d72253e5448693c12f0282d09902aaa | https://github.com/frasertweedale/ledgertools/blob/a695f8667d72253e5448693c12f0282d09902aaa/ltlib/config.py#L104-L114 | train | Return the outdir for the given account. |
frasertweedale/ledgertools | ltlib/config.py | Config.outpat | def outpat(self, acc=None):
"""
Determine the full outfile pattern for the given account.
Return None if not specified.
"""
outdir = self.outdir(acc)
outpat = self.get('outpat', acc=acc)
return os.path.join(outdir, outpat) if outdir and outpat else None | python | def outpat(self, acc=None):
"""
Determine the full outfile pattern for the given account.
Return None if not specified.
"""
outdir = self.outdir(acc)
outpat = self.get('outpat', acc=acc)
return os.path.join(outdir, outpat) if outdir and outpat else None | [
"def",
"outpat",
"(",
"self",
",",
"acc",
"=",
"None",
")",
":",
"outdir",
"=",
"self",
".",
"outdir",
"(",
"acc",
")",
"outpat",
"=",
"self",
".",
"get",
"(",
"'outpat'",
",",
"acc",
"=",
"acc",
")",
"return",
"os",
".",
"path",
".",
"join",
"... | Determine the full outfile pattern for the given account.
Return None if not specified. | [
"Determine",
"the",
"full",
"outfile",
"pattern",
"for",
"the",
"given",
"account",
"."
] | a695f8667d72253e5448693c12f0282d09902aaa | https://github.com/frasertweedale/ledgertools/blob/a695f8667d72253e5448693c12f0282d09902aaa/ltlib/config.py#L116-L124 | train | Determines the full outfile pattern for the given account. |
frasertweedale/ledgertools | ltlib/config.py | Config.rulesdir | def rulesdir(self, acc=None):
"""
Determine the rulesdir for the given account.
Return None if not specified.
"""
rootdir = self.rootdir()
rulesdir = self.get('rulesdir', acc=acc, default=[])
return os.path.join(rootdir, rulesdir) \
if rootdir and rul... | python | def rulesdir(self, acc=None):
"""
Determine the rulesdir for the given account.
Return None if not specified.
"""
rootdir = self.rootdir()
rulesdir = self.get('rulesdir', acc=acc, default=[])
return os.path.join(rootdir, rulesdir) \
if rootdir and rul... | [
"def",
"rulesdir",
"(",
"self",
",",
"acc",
"=",
"None",
")",
":",
"rootdir",
"=",
"self",
".",
"rootdir",
"(",
")",
"rulesdir",
"=",
"self",
".",
"get",
"(",
"'rulesdir'",
",",
"acc",
"=",
"acc",
",",
"default",
"=",
"[",
"]",
")",
"return",
"os... | Determine the rulesdir for the given account.
Return None if not specified. | [
"Determine",
"the",
"rulesdir",
"for",
"the",
"given",
"account",
"."
] | a695f8667d72253e5448693c12f0282d09902aaa | https://github.com/frasertweedale/ledgertools/blob/a695f8667d72253e5448693c12f0282d09902aaa/ltlib/config.py#L127-L136 | train | Return the rulesdir for the given account. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.