id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
42,400 | MartinThoma/hwrt | hwrt/utils.py | default_model | def default_model():
"""Get a path for a default value for the model. Start searching in the
current directory."""
project_root = get_project_root()
models_dir = os.path.join(project_root, "models")
curr_dir = os.getcwd()
if os.path.commonprefix([models_dir, curr_dir]) == models_dir and \
... | python | def default_model():
"""Get a path for a default value for the model. Start searching in the
current directory."""
project_root = get_project_root()
models_dir = os.path.join(project_root, "models")
curr_dir = os.getcwd()
if os.path.commonprefix([models_dir, curr_dir]) == models_dir and \
... | [
"def",
"default_model",
"(",
")",
":",
"project_root",
"=",
"get_project_root",
"(",
")",
"models_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"project_root",
",",
"\"models\"",
")",
"curr_dir",
"=",
"os",
".",
"getcwd",
"(",
")",
"if",
"os",
".",
"... | Get a path for a default value for the model. Start searching in the
current directory. | [
"Get",
"a",
"path",
"for",
"a",
"default",
"value",
"for",
"the",
"model",
".",
"Start",
"searching",
"in",
"the",
"current",
"directory",
"."
] | 725c21a3d0f5a30b8492cbc184b3688ceb364e1c | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/utils.py#L379-L390 |
42,401 | MartinThoma/hwrt | hwrt/utils.py | create_adjusted_model_for_percentages | def create_adjusted_model_for_percentages(model_src, model_use):
"""Replace logreg layer by sigmoid to get probabilities."""
# Copy model file
shutil.copyfile(model_src, model_use)
# Adjust model file
with open(model_src) as f:
content = f.read()
content = content.replace("logreg", "sigm... | python | def create_adjusted_model_for_percentages(model_src, model_use):
"""Replace logreg layer by sigmoid to get probabilities."""
# Copy model file
shutil.copyfile(model_src, model_use)
# Adjust model file
with open(model_src) as f:
content = f.read()
content = content.replace("logreg", "sigm... | [
"def",
"create_adjusted_model_for_percentages",
"(",
"model_src",
",",
"model_use",
")",
":",
"# Copy model file",
"shutil",
".",
"copyfile",
"(",
"model_src",
",",
"model_use",
")",
"# Adjust model file",
"with",
"open",
"(",
"model_src",
")",
"as",
"f",
":",
"co... | Replace logreg layer by sigmoid to get probabilities. | [
"Replace",
"logreg",
"layer",
"by",
"sigmoid",
"to",
"get",
"probabilities",
"."
] | 725c21a3d0f5a30b8492cbc184b3688ceb364e1c | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/utils.py#L393-L402 |
42,402 | MartinThoma/hwrt | hwrt/utils.py | create_hdf5 | def create_hdf5(output_filename, feature_count, data):
"""
Create a HDF5 feature files.
Parameters
----------
output_filename : string
name of the HDF5 file that will be created
feature_count : int
dimension of all features combined
data : list of tuples
list of (x, ... | python | def create_hdf5(output_filename, feature_count, data):
"""
Create a HDF5 feature files.
Parameters
----------
output_filename : string
name of the HDF5 file that will be created
feature_count : int
dimension of all features combined
data : list of tuples
list of (x, ... | [
"def",
"create_hdf5",
"(",
"output_filename",
",",
"feature_count",
",",
"data",
")",
":",
"import",
"h5py",
"logging",
".",
"info",
"(",
"\"Start creating of %s hdf file\"",
",",
"output_filename",
")",
"x",
"=",
"[",
"]",
"y",
"=",
"[",
"]",
"for",
"featur... | Create a HDF5 feature files.
Parameters
----------
output_filename : string
name of the HDF5 file that will be created
feature_count : int
dimension of all features combined
data : list of tuples
list of (x, y) tuples, where x is the feature vector of dimension
``fea... | [
"Create",
"a",
"HDF5",
"feature",
"files",
"."
] | 725c21a3d0f5a30b8492cbc184b3688ceb364e1c | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/utils.py#L405-L432 |
42,403 | MartinThoma/hwrt | hwrt/utils.py | load_model | def load_model(model_file):
"""Load a model by its file. This includes the model itself, but also
the preprocessing queue, the feature list and the output semantics.
"""
# Extract tar
with tarfile.open(model_file) as tar:
tarfolder = tempfile.mkdtemp()
tar.extractall(path=tarfolde... | python | def load_model(model_file):
"""Load a model by its file. This includes the model itself, but also
the preprocessing queue, the feature list and the output semantics.
"""
# Extract tar
with tarfile.open(model_file) as tar:
tarfolder = tempfile.mkdtemp()
tar.extractall(path=tarfolde... | [
"def",
"load_model",
"(",
"model_file",
")",
":",
"# Extract tar",
"with",
"tarfile",
".",
"open",
"(",
"model_file",
")",
"as",
"tar",
":",
"tarfolder",
"=",
"tempfile",
".",
"mkdtemp",
"(",
")",
"tar",
".",
"extractall",
"(",
"path",
"=",
"tarfolder",
... | Load a model by its file. This includes the model itself, but also
the preprocessing queue, the feature list and the output semantics. | [
"Load",
"a",
"model",
"by",
"its",
"file",
".",
"This",
"includes",
"the",
"model",
"itself",
"but",
"also",
"the",
"preprocessing",
"queue",
"the",
"feature",
"list",
"and",
"the",
"output",
"semantics",
"."
] | 725c21a3d0f5a30b8492cbc184b3688ceb364e1c | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/utils.py#L448-L482 |
42,404 | MartinThoma/hwrt | hwrt/utils.py | evaluate_model_single_recording_preloaded | def evaluate_model_single_recording_preloaded(preprocessing_queue,
feature_list,
model,
output_semantics,
recording,
... | python | def evaluate_model_single_recording_preloaded(preprocessing_queue,
feature_list,
model,
output_semantics,
recording,
... | [
"def",
"evaluate_model_single_recording_preloaded",
"(",
"preprocessing_queue",
",",
"feature_list",
",",
"model",
",",
"output_semantics",
",",
"recording",
",",
"recording_id",
"=",
"None",
")",
":",
"handwriting",
"=",
"handwritten_data",
".",
"HandwrittenData",
"(",... | Evaluate a model for a single recording, after everything has been loaded.
Parameters
----------
preprocessing_queue : list
List of all preprocessing objects.
feature_list : list
List of all feature objects.
model : dict
Neural network model.
output_semantics : list
... | [
"Evaluate",
"a",
"model",
"for",
"a",
"single",
"recording",
"after",
"everything",
"has",
"been",
"loaded",
"."
] | 725c21a3d0f5a30b8492cbc184b3688ceb364e1c | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/utils.py#L485-L515 |
42,405 | MartinThoma/hwrt | hwrt/utils.py | evaluate_model_single_recording_preloaded_multisymbol | def evaluate_model_single_recording_preloaded_multisymbol(preprocessing_queue,
feature_list,
model,
output_semantics,
... | python | def evaluate_model_single_recording_preloaded_multisymbol(preprocessing_queue,
feature_list,
model,
output_semantics,
... | [
"def",
"evaluate_model_single_recording_preloaded_multisymbol",
"(",
"preprocessing_queue",
",",
"feature_list",
",",
"model",
",",
"output_semantics",
",",
"recording",
")",
":",
"import",
"json",
"import",
"nntoolkit",
".",
"evaluate",
"recording",
"=",
"json",
".",
... | Evaluate a model for a single recording, after everything has been loaded.
Multiple symbols are recognized.
Parameters
----------
preprocessing_queue : list
List of all preprocessing objects.
feature_list : list
List of all feature objects.
model : dict
Neural network mo... | [
"Evaluate",
"a",
"model",
"for",
"a",
"single",
"recording",
"after",
"everything",
"has",
"been",
"loaded",
".",
"Multiple",
"symbols",
"are",
"recognized",
"."
] | 725c21a3d0f5a30b8492cbc184b3688ceb364e1c | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/utils.py#L551-L608 |
42,406 | MartinThoma/hwrt | hwrt/utils.py | evaluate_model_single_recording_multisymbol | def evaluate_model_single_recording_multisymbol(model_file, recording):
"""
Evaluate a model for a single recording where possibly multiple symbols
are.
Parameters
----------
model_file : string
Model file (.tar)
recording :
The handwritten recording.
"""
(preprocess... | python | def evaluate_model_single_recording_multisymbol(model_file, recording):
"""
Evaluate a model for a single recording where possibly multiple symbols
are.
Parameters
----------
model_file : string
Model file (.tar)
recording :
The handwritten recording.
"""
(preprocess... | [
"def",
"evaluate_model_single_recording_multisymbol",
"(",
"model_file",
",",
"recording",
")",
":",
"(",
"preprocessing_queue",
",",
"feature_list",
",",
"model",
",",
"output_semantics",
")",
"=",
"load_model",
"(",
"model_file",
")",
"logging",
".",
"info",
"(",
... | Evaluate a model for a single recording where possibly multiple symbols
are.
Parameters
----------
model_file : string
Model file (.tar)
recording :
The handwritten recording. | [
"Evaluate",
"a",
"model",
"for",
"a",
"single",
"recording",
"where",
"possibly",
"multiple",
"symbols",
"are",
"."
] | 725c21a3d0f5a30b8492cbc184b3688ceb364e1c | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/utils.py#L611-L632 |
42,407 | MartinThoma/hwrt | hwrt/utils.py | evaluate_model | def evaluate_model(recording, model_folder, verbose=False):
"""Evaluate model for a single recording."""
from . import preprocess_dataset
from . import features
for target_folder in get_recognizer_folders(model_folder):
# The source is later than the target. That means we need to
# refr... | python | def evaluate_model(recording, model_folder, verbose=False):
"""Evaluate model for a single recording."""
from . import preprocess_dataset
from . import features
for target_folder in get_recognizer_folders(model_folder):
# The source is later than the target. That means we need to
# refr... | [
"def",
"evaluate_model",
"(",
"recording",
",",
"model_folder",
",",
"verbose",
"=",
"False",
")",
":",
"from",
".",
"import",
"preprocess_dataset",
"from",
".",
"import",
"features",
"for",
"target_folder",
"in",
"get_recognizer_folders",
"(",
"model_folder",
")"... | Evaluate model for a single recording. | [
"Evaluate",
"model",
"for",
"a",
"single",
"recording",
"."
] | 725c21a3d0f5a30b8492cbc184b3688ceb364e1c | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/utils.py#L699-L740 |
42,408 | MartinThoma/hwrt | hwrt/utils.py | get_index2latex | def get_index2latex(model_description):
"""
Get a dictionary that maps indices to LaTeX commands.
Parameters
----------
model_description : string
A model description file that points to a feature folder where an
`index2formula_id.csv` has to be.
Returns
-------
diction... | python | def get_index2latex(model_description):
"""
Get a dictionary that maps indices to LaTeX commands.
Parameters
----------
model_description : string
A model description file that points to a feature folder where an
`index2formula_id.csv` has to be.
Returns
-------
diction... | [
"def",
"get_index2latex",
"(",
"model_description",
")",
":",
"index2latex",
"=",
"{",
"}",
"translation_csv",
"=",
"os",
".",
"path",
".",
"join",
"(",
"get_project_root",
"(",
")",
",",
"model_description",
"[",
"\"data-source\"",
"]",
",",
"\"index2formula_id... | Get a dictionary that maps indices to LaTeX commands.
Parameters
----------
model_description : string
A model description file that points to a feature folder where an
`index2formula_id.csv` has to be.
Returns
-------
dictionary :
Maps indices to LaTeX commands | [
"Get",
"a",
"dictionary",
"that",
"maps",
"indices",
"to",
"LaTeX",
"commands",
"."
] | 725c21a3d0f5a30b8492cbc184b3688ceb364e1c | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/utils.py#L743-L766 |
42,409 | MartinThoma/hwrt | hwrt/utils.py | get_online_symbol_data | def get_online_symbol_data(database_id):
"""Get from the server."""
import pymysql
import pymysql.cursors
cfg = get_database_configuration()
mysql = cfg['mysql_online']
connection = pymysql.connect(host=mysql['host'],
user=mysql['user'],
... | python | def get_online_symbol_data(database_id):
"""Get from the server."""
import pymysql
import pymysql.cursors
cfg = get_database_configuration()
mysql = cfg['mysql_online']
connection = pymysql.connect(host=mysql['host'],
user=mysql['user'],
... | [
"def",
"get_online_symbol_data",
"(",
"database_id",
")",
":",
"import",
"pymysql",
"import",
"pymysql",
".",
"cursors",
"cfg",
"=",
"get_database_configuration",
"(",
")",
"mysql",
"=",
"cfg",
"[",
"'mysql_online'",
"]",
"connection",
"=",
"pymysql",
".",
"conn... | Get from the server. | [
"Get",
"from",
"the",
"server",
"."
] | 725c21a3d0f5a30b8492cbc184b3688ceb364e1c | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/utils.py#L811-L830 |
42,410 | MartinThoma/hwrt | hwrt/utils.py | classify_single_recording | def classify_single_recording(raw_data_json, model_folder, verbose=False):
"""
Get the classification as a list of tuples. The first value is the LaTeX
code, the second value is the probability.
"""
evaluation_file = evaluate_model(raw_data_json, model_folder, verbose)
with open(os.path.join(mod... | python | def classify_single_recording(raw_data_json, model_folder, verbose=False):
"""
Get the classification as a list of tuples. The first value is the LaTeX
code, the second value is the probability.
"""
evaluation_file = evaluate_model(raw_data_json, model_folder, verbose)
with open(os.path.join(mod... | [
"def",
"classify_single_recording",
"(",
"raw_data_json",
",",
"model_folder",
",",
"verbose",
"=",
"False",
")",
":",
"evaluation_file",
"=",
"evaluate_model",
"(",
"raw_data_json",
",",
"model_folder",
",",
"verbose",
")",
"with",
"open",
"(",
"os",
".",
"path... | Get the classification as a list of tuples. The first value is the LaTeX
code, the second value is the probability. | [
"Get",
"the",
"classification",
"as",
"a",
"list",
"of",
"tuples",
".",
"The",
"first",
"value",
"is",
"the",
"LaTeX",
"code",
"the",
"second",
"value",
"is",
"the",
"probability",
"."
] | 725c21a3d0f5a30b8492cbc184b3688ceb364e1c | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/utils.py#L833-L852 |
42,411 | MartinThoma/hwrt | hwrt/utils.py | get_objectlist | def get_objectlist(description, config_key, module):
"""
Take a description and return a list of classes.
Parameters
----------
description : list of dictionaries
Each dictionary has only one entry. The key is the name of a class. The
value of that entry is a list of dictionaries ag... | python | def get_objectlist(description, config_key, module):
"""
Take a description and return a list of classes.
Parameters
----------
description : list of dictionaries
Each dictionary has only one entry. The key is the name of a class. The
value of that entry is a list of dictionaries ag... | [
"def",
"get_objectlist",
"(",
"description",
",",
"config_key",
",",
"module",
")",
":",
"object_list",
"=",
"[",
"]",
"for",
"feature",
"in",
"description",
":",
"for",
"feat",
",",
"params",
"in",
"feature",
".",
"items",
"(",
")",
":",
"feat",
"=",
... | Take a description and return a list of classes.
Parameters
----------
description : list of dictionaries
Each dictionary has only one entry. The key is the name of a class. The
value of that entry is a list of dictionaries again. Those dictionaries
are paramters.
Returns
-... | [
"Take",
"a",
"description",
"and",
"return",
"a",
"list",
"of",
"classes",
"."
] | 725c21a3d0f5a30b8492cbc184b3688ceb364e1c | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/utils.py#L855-L882 |
42,412 | MartinThoma/hwrt | hwrt/utils.py | get_class | def get_class(name, config_key, module):
"""Get the class by its name as a string."""
clsmembers = inspect.getmembers(module, inspect.isclass)
for string_name, act_class in clsmembers:
if string_name == name:
return act_class
# Check if the user has specified a plugin and if the cla... | python | def get_class(name, config_key, module):
"""Get the class by its name as a string."""
clsmembers = inspect.getmembers(module, inspect.isclass)
for string_name, act_class in clsmembers:
if string_name == name:
return act_class
# Check if the user has specified a plugin and if the cla... | [
"def",
"get_class",
"(",
"name",
",",
"config_key",
",",
"module",
")",
":",
"clsmembers",
"=",
"inspect",
".",
"getmembers",
"(",
"module",
",",
"inspect",
".",
"isclass",
")",
"for",
"string_name",
",",
"act_class",
"in",
"clsmembers",
":",
"if",
"string... | Get the class by its name as a string. | [
"Get",
"the",
"class",
"by",
"its",
"name",
"as",
"a",
"string",
"."
] | 725c21a3d0f5a30b8492cbc184b3688ceb364e1c | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/utils.py#L885-L907 |
42,413 | MartinThoma/hwrt | hwrt/utils.py | get_mysql_cfg | def get_mysql_cfg():
"""
Get the appropriate MySQL configuration
"""
environment = get_project_configuration()['environment']
cfg = get_database_configuration()
if environment == 'production':
mysql = cfg['mysql_online']
else:
mysql = cfg['mysql_dev']
return mysql | python | def get_mysql_cfg():
"""
Get the appropriate MySQL configuration
"""
environment = get_project_configuration()['environment']
cfg = get_database_configuration()
if environment == 'production':
mysql = cfg['mysql_online']
else:
mysql = cfg['mysql_dev']
return mysql | [
"def",
"get_mysql_cfg",
"(",
")",
":",
"environment",
"=",
"get_project_configuration",
"(",
")",
"[",
"'environment'",
"]",
"cfg",
"=",
"get_database_configuration",
"(",
")",
"if",
"environment",
"==",
"'production'",
":",
"mysql",
"=",
"cfg",
"[",
"'mysql_onl... | Get the appropriate MySQL configuration | [
"Get",
"the",
"appropriate",
"MySQL",
"configuration"
] | 725c21a3d0f5a30b8492cbc184b3688ceb364e1c | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/utils.py#L926-L936 |
42,414 | MartinThoma/hwrt | hwrt/utils.py | softmax | def softmax(w, t=1.0):
"""Calculate the softmax of a list of numbers w.
Parameters
----------
w : list of numbers
Returns
-------
a list of the same length as w of non-negative numbers
Examples
--------
>>> softmax([0.1, 0.2])
array([ 0.47502081, 0.52497919])
>>> soft... | python | def softmax(w, t=1.0):
"""Calculate the softmax of a list of numbers w.
Parameters
----------
w : list of numbers
Returns
-------
a list of the same length as w of non-negative numbers
Examples
--------
>>> softmax([0.1, 0.2])
array([ 0.47502081, 0.52497919])
>>> soft... | [
"def",
"softmax",
"(",
"w",
",",
"t",
"=",
"1.0",
")",
":",
"w",
"=",
"[",
"Decimal",
"(",
"el",
")",
"for",
"el",
"in",
"w",
"]",
"e",
"=",
"numpy",
".",
"exp",
"(",
"numpy",
".",
"array",
"(",
"w",
")",
"/",
"Decimal",
"(",
"t",
")",
")... | Calculate the softmax of a list of numbers w.
Parameters
----------
w : list of numbers
Returns
-------
a list of the same length as w of non-negative numbers
Examples
--------
>>> softmax([0.1, 0.2])
array([ 0.47502081, 0.52497919])
>>> softmax([-0.1, 0.2])
array([ 0... | [
"Calculate",
"the",
"softmax",
"of",
"a",
"list",
"of",
"numbers",
"w",
"."
] | 725c21a3d0f5a30b8492cbc184b3688ceb364e1c | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/utils.py#L939-L964 |
42,415 | MartinThoma/hwrt | hwrt/utils.py | get_beam_cache_directory | def get_beam_cache_directory():
"""
Get a directory where pickled Beam Data can be stored.
Create that directory, if it doesn't exist.
Returns
-------
str
Path to the directory
"""
home = os.path.expanduser("~")
cache_dir = os.path.join(home, '.hwrt-beam-cache')
if not ... | python | def get_beam_cache_directory():
"""
Get a directory where pickled Beam Data can be stored.
Create that directory, if it doesn't exist.
Returns
-------
str
Path to the directory
"""
home = os.path.expanduser("~")
cache_dir = os.path.join(home, '.hwrt-beam-cache')
if not ... | [
"def",
"get_beam_cache_directory",
"(",
")",
":",
"home",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"\"~\"",
")",
"cache_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"home",
",",
"'.hwrt-beam-cache'",
")",
"if",
"not",
"os",
".",
"path",
".",
... | Get a directory where pickled Beam Data can be stored.
Create that directory, if it doesn't exist.
Returns
-------
str
Path to the directory | [
"Get",
"a",
"directory",
"where",
"pickled",
"Beam",
"Data",
"can",
"be",
"stored",
"."
] | 725c21a3d0f5a30b8492cbc184b3688ceb364e1c | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/utils.py#L967-L982 |
42,416 | MartinThoma/hwrt | hwrt/utils.py | get_beam | def get_beam(secret_uuid):
"""
Get a beam from the session with `secret_uuid`.
Parameters
----------
secret_uuid : str
Returns
-------
The beam object if it exists, otherwise `None`.
"""
beam_dir = get_beam_cache_directory()
beam_filename = os.path.join(beam_dir, secret_uui... | python | def get_beam(secret_uuid):
"""
Get a beam from the session with `secret_uuid`.
Parameters
----------
secret_uuid : str
Returns
-------
The beam object if it exists, otherwise `None`.
"""
beam_dir = get_beam_cache_directory()
beam_filename = os.path.join(beam_dir, secret_uui... | [
"def",
"get_beam",
"(",
"secret_uuid",
")",
":",
"beam_dir",
"=",
"get_beam_cache_directory",
"(",
")",
"beam_filename",
"=",
"os",
".",
"path",
".",
"join",
"(",
"beam_dir",
",",
"secret_uuid",
")",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"beam_filen... | Get a beam from the session with `secret_uuid`.
Parameters
----------
secret_uuid : str
Returns
-------
The beam object if it exists, otherwise `None`. | [
"Get",
"a",
"beam",
"from",
"the",
"session",
"with",
"secret_uuid",
"."
] | 725c21a3d0f5a30b8492cbc184b3688ceb364e1c | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/utils.py#L985-L1004 |
42,417 | MartinThoma/hwrt | hwrt/utils.py | is_valid_uuid | def is_valid_uuid(uuid_to_test, version=4):
"""
Check if uuid_to_test is a valid UUID.
Parameters
----------
uuid_to_test : str
version : {1, 2, 3, 4}
Returns
-------
`True` if uuid_to_test is a valid UUID, otherwise `False`.
Examples
--------
>>> is_valid_uuid('c9bf9e... | python | def is_valid_uuid(uuid_to_test, version=4):
"""
Check if uuid_to_test is a valid UUID.
Parameters
----------
uuid_to_test : str
version : {1, 2, 3, 4}
Returns
-------
`True` if uuid_to_test is a valid UUID, otherwise `False`.
Examples
--------
>>> is_valid_uuid('c9bf9e... | [
"def",
"is_valid_uuid",
"(",
"uuid_to_test",
",",
"version",
"=",
"4",
")",
":",
"try",
":",
"uuid_obj",
"=",
"UUID",
"(",
"uuid_to_test",
",",
"version",
"=",
"version",
")",
"except",
"ValueError",
":",
"return",
"False",
"return",
"str",
"(",
"uuid_obj"... | Check if uuid_to_test is a valid UUID.
Parameters
----------
uuid_to_test : str
version : {1, 2, 3, 4}
Returns
-------
`True` if uuid_to_test is a valid UUID, otherwise `False`.
Examples
--------
>>> is_valid_uuid('c9bf9e57-1685-4c89-bafb-ff5af830be8a')
True
>>> is_val... | [
"Check",
"if",
"uuid_to_test",
"is",
"a",
"valid",
"UUID",
"."
] | 725c21a3d0f5a30b8492cbc184b3688ceb364e1c | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/utils.py#L1016-L1041 |
42,418 | MartinThoma/hwrt | hwrt/partitions.py | prepare_table | def prepare_table(table):
"""Make the table 'symmetric' where the lower left part of the matrix is
the reverse probability
"""
n = len(table)
for i, row in enumerate(table):
assert len(row) == n
for j, el in enumerate(row):
if i == j:
table[i][i] = 0.0
... | python | def prepare_table(table):
"""Make the table 'symmetric' where the lower left part of the matrix is
the reverse probability
"""
n = len(table)
for i, row in enumerate(table):
assert len(row) == n
for j, el in enumerate(row):
if i == j:
table[i][i] = 0.0
... | [
"def",
"prepare_table",
"(",
"table",
")",
":",
"n",
"=",
"len",
"(",
"table",
")",
"for",
"i",
",",
"row",
"in",
"enumerate",
"(",
"table",
")",
":",
"assert",
"len",
"(",
"row",
")",
"==",
"n",
"for",
"j",
",",
"el",
"in",
"enumerate",
"(",
"... | Make the table 'symmetric' where the lower left part of the matrix is
the reverse probability | [
"Make",
"the",
"table",
"symmetric",
"where",
"the",
"lower",
"left",
"part",
"of",
"the",
"matrix",
"is",
"the",
"reverse",
"probability"
] | 725c21a3d0f5a30b8492cbc184b3688ceb364e1c | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/partitions.py#L20-L32 |
42,419 | MartinThoma/hwrt | hwrt/partitions.py | neclusters | def neclusters(l, K):
"""Partition list ``l`` in ``K`` partitions, without empty parts.
>>> l = [0, 1, 2]
>>> list(neclusters(l, 2))
[[[0, 1], [2]], [[1], [0, 2]], [[0], [1, 2]]]
>>> list(neclusters(l, 1))
[[[0, 1, 2]]]
"""
for c in clusters(l, K):
if all(x for x in c):
... | python | def neclusters(l, K):
"""Partition list ``l`` in ``K`` partitions, without empty parts.
>>> l = [0, 1, 2]
>>> list(neclusters(l, 2))
[[[0, 1], [2]], [[1], [0, 2]], [[0], [1, 2]]]
>>> list(neclusters(l, 1))
[[[0, 1, 2]]]
"""
for c in clusters(l, K):
if all(x for x in c):
... | [
"def",
"neclusters",
"(",
"l",
",",
"K",
")",
":",
"for",
"c",
"in",
"clusters",
"(",
"l",
",",
"K",
")",
":",
"if",
"all",
"(",
"x",
"for",
"x",
"in",
"c",
")",
":",
"yield",
"c"
] | Partition list ``l`` in ``K`` partitions, without empty parts.
>>> l = [0, 1, 2]
>>> list(neclusters(l, 2))
[[[0, 1], [2]], [[1], [0, 2]], [[0], [1, 2]]]
>>> list(neclusters(l, 1))
[[[0, 1, 2]]] | [
"Partition",
"list",
"l",
"in",
"K",
"partitions",
"without",
"empty",
"parts",
"."
] | 725c21a3d0f5a30b8492cbc184b3688ceb364e1c | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/partitions.py#L57-L68 |
42,420 | MartinThoma/hwrt | hwrt/partitions.py | all_segmentations | def all_segmentations(l):
"""Get all segmentations of a list ``l``.
This gets bigger fast. See https://oeis.org/A000110
For len(l) = 14 it is 190,899,322
>>> list(all_segmentations([0, 1, 2]))
[[[0, 1, 2]], [[0, 1], [2]], [[1], [0, 2]], [[0], [1, 2]], [[0], [1], [2]]]
"""
for K in range(1... | python | def all_segmentations(l):
"""Get all segmentations of a list ``l``.
This gets bigger fast. See https://oeis.org/A000110
For len(l) = 14 it is 190,899,322
>>> list(all_segmentations([0, 1, 2]))
[[[0, 1, 2]], [[0, 1], [2]], [[1], [0, 2]], [[0], [1, 2]], [[0], [1], [2]]]
"""
for K in range(1... | [
"def",
"all_segmentations",
"(",
"l",
")",
":",
"for",
"K",
"in",
"range",
"(",
"1",
",",
"len",
"(",
"l",
")",
"+",
"1",
")",
":",
"gen",
"=",
"neclusters",
"(",
"l",
",",
"K",
")",
"for",
"el",
"in",
"gen",
":",
"yield",
"el"
] | Get all segmentations of a list ``l``.
This gets bigger fast. See https://oeis.org/A000110
For len(l) = 14 it is 190,899,322
>>> list(all_segmentations([0, 1, 2]))
[[[0, 1, 2]], [[0, 1], [2]], [[1], [0, 2]], [[0], [1, 2]], [[0], [1], [2]]] | [
"Get",
"all",
"segmentations",
"of",
"a",
"list",
"l",
"."
] | 725c21a3d0f5a30b8492cbc184b3688ceb364e1c | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/partitions.py#L71-L84 |
42,421 | MartinThoma/hwrt | hwrt/partitions.py | q | def q(segmentation, s1, s2):
"""Test if ``s1`` and ``s2`` are in the same symbol, given the
``segmentation``.
"""
index1 = find_index(segmentation, s1)
index2 = find_index(segmentation, s2)
return index1 == index2 | python | def q(segmentation, s1, s2):
"""Test if ``s1`` and ``s2`` are in the same symbol, given the
``segmentation``.
"""
index1 = find_index(segmentation, s1)
index2 = find_index(segmentation, s2)
return index1 == index2 | [
"def",
"q",
"(",
"segmentation",
",",
"s1",
",",
"s2",
")",
":",
"index1",
"=",
"find_index",
"(",
"segmentation",
",",
"s1",
")",
"index2",
"=",
"find_index",
"(",
"segmentation",
",",
"s2",
")",
"return",
"index1",
"==",
"index2"
] | Test if ``s1`` and ``s2`` are in the same symbol, given the
``segmentation``. | [
"Test",
"if",
"s1",
"and",
"s2",
"are",
"in",
"the",
"same",
"symbol",
"given",
"the",
"segmentation",
"."
] | 725c21a3d0f5a30b8492cbc184b3688ceb364e1c | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/partitions.py#L105-L111 |
42,422 | MartinThoma/hwrt | hwrt/partitions.py | score_segmentation | def score_segmentation(segmentation, table):
"""Get the score of a segmentation."""
stroke_nr = sum(1 for symbol in segmentation for stroke in symbol)
score = 1
for i in range(stroke_nr):
for j in range(i+1, stroke_nr):
qval = q(segmentation, i, j)
if qval:
... | python | def score_segmentation(segmentation, table):
"""Get the score of a segmentation."""
stroke_nr = sum(1 for symbol in segmentation for stroke in symbol)
score = 1
for i in range(stroke_nr):
for j in range(i+1, stroke_nr):
qval = q(segmentation, i, j)
if qval:
... | [
"def",
"score_segmentation",
"(",
"segmentation",
",",
"table",
")",
":",
"stroke_nr",
"=",
"sum",
"(",
"1",
"for",
"symbol",
"in",
"segmentation",
"for",
"stroke",
"in",
"symbol",
")",
"score",
"=",
"1",
"for",
"i",
"in",
"range",
"(",
"stroke_nr",
")",... | Get the score of a segmentation. | [
"Get",
"the",
"score",
"of",
"a",
"segmentation",
"."
] | 725c21a3d0f5a30b8492cbc184b3688ceb364e1c | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/partitions.py#L140-L151 |
42,423 | MartinThoma/hwrt | hwrt/partitions.py | TopFinder.push | def push(self, element, value):
"""Push an ``element`` into the datastrucutre together with its value
and only save it if it currently is one of the top n elements.
Drop elements if necessary.
"""
insert_pos = 0
for index, el in enumerate(self.tops):
if... | python | def push(self, element, value):
"""Push an ``element`` into the datastrucutre together with its value
and only save it if it currently is one of the top n elements.
Drop elements if necessary.
"""
insert_pos = 0
for index, el in enumerate(self.tops):
if... | [
"def",
"push",
"(",
"self",
",",
"element",
",",
"value",
")",
":",
"insert_pos",
"=",
"0",
"for",
"index",
",",
"el",
"in",
"enumerate",
"(",
"self",
".",
"tops",
")",
":",
"if",
"not",
"self",
".",
"find_min",
"and",
"el",
"[",
"1",
"]",
">=",
... | Push an ``element`` into the datastrucutre together with its value
and only save it if it currently is one of the top n elements.
Drop elements if necessary. | [
"Push",
"an",
"element",
"into",
"the",
"datastrucutre",
"together",
"with",
"its",
"value",
"and",
"only",
"save",
"it",
"if",
"it",
"currently",
"is",
"one",
"of",
"the",
"top",
"n",
"elements",
"."
] | 725c21a3d0f5a30b8492cbc184b3688ceb364e1c | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/partitions.py#L121-L134 |
42,424 | MartinThoma/hwrt | bin/convert.py | _array2cstr | def _array2cstr(arr):
""" Serializes a numpy array to a compressed base64 string """
out = StringIO()
np.save(out, arr)
return b64encode(out.getvalue()) | python | def _array2cstr(arr):
""" Serializes a numpy array to a compressed base64 string """
out = StringIO()
np.save(out, arr)
return b64encode(out.getvalue()) | [
"def",
"_array2cstr",
"(",
"arr",
")",
":",
"out",
"=",
"StringIO",
"(",
")",
"np",
".",
"save",
"(",
"out",
",",
"arr",
")",
"return",
"b64encode",
"(",
"out",
".",
"getvalue",
"(",
")",
")"
] | Serializes a numpy array to a compressed base64 string | [
"Serializes",
"a",
"numpy",
"array",
"to",
"a",
"compressed",
"base64",
"string"
] | 725c21a3d0f5a30b8492cbc184b3688ceb364e1c | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/bin/convert.py#L21-L25 |
42,425 | MartinThoma/hwrt | bin/convert.py | _str2array | def _str2array(d):
""" Reconstructs a numpy array from a plain-text string """
if type(d) == list:
return np.asarray([_str2array(s) for s in d])
ins = StringIO(d)
return np.loadtxt(ins) | python | def _str2array(d):
""" Reconstructs a numpy array from a plain-text string """
if type(d) == list:
return np.asarray([_str2array(s) for s in d])
ins = StringIO(d)
return np.loadtxt(ins) | [
"def",
"_str2array",
"(",
"d",
")",
":",
"if",
"type",
"(",
"d",
")",
"==",
"list",
":",
"return",
"np",
".",
"asarray",
"(",
"[",
"_str2array",
"(",
"s",
")",
"for",
"s",
"in",
"d",
"]",
")",
"ins",
"=",
"StringIO",
"(",
"d",
")",
"return",
... | Reconstructs a numpy array from a plain-text string | [
"Reconstructs",
"a",
"numpy",
"array",
"from",
"a",
"plain",
"-",
"text",
"string"
] | 725c21a3d0f5a30b8492cbc184b3688ceb364e1c | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/bin/convert.py#L28-L33 |
42,426 | MartinThoma/hwrt | bin/convert.py | create_output_semantics | def create_output_semantics(model_folder, outputs):
"""
Create a 'output_semantics.csv' file which contains information what the
output of the single output neurons mean.
Parameters
----------
model_folder : str
folder where the model description file is
outputs : int
number... | python | def create_output_semantics(model_folder, outputs):
"""
Create a 'output_semantics.csv' file which contains information what the
output of the single output neurons mean.
Parameters
----------
model_folder : str
folder where the model description file is
outputs : int
number... | [
"def",
"create_output_semantics",
"(",
"model_folder",
",",
"outputs",
")",
":",
"with",
"open",
"(",
"'output_semantics.csv'",
",",
"'wb'",
")",
"as",
"csvfile",
":",
"model_description_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"model_folder",
",",
"\"... | Create a 'output_semantics.csv' file which contains information what the
output of the single output neurons mean.
Parameters
----------
model_folder : str
folder where the model description file is
outputs : int
number of output neurons | [
"Create",
"a",
"output_semantics",
".",
"csv",
"file",
"which",
"contains",
"information",
"what",
"the",
"output",
"of",
"the",
"single",
"output",
"neurons",
"mean",
"."
] | 725c21a3d0f5a30b8492cbc184b3688ceb364e1c | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/bin/convert.py#L50-L82 |
42,427 | MartinThoma/hwrt | hwrt/datasets/mfrdb.py | elementtree_to_dict | def elementtree_to_dict(element):
"""Convert an xml ElementTree to a dictionary."""
d = dict()
if hasattr(element, 'text') and element.text is not None:
d['text'] = element.text
d.update(element.items()) # element's attributes
for c in list(element): # element's children
if c.tag... | python | def elementtree_to_dict(element):
"""Convert an xml ElementTree to a dictionary."""
d = dict()
if hasattr(element, 'text') and element.text is not None:
d['text'] = element.text
d.update(element.items()) # element's attributes
for c in list(element): # element's children
if c.tag... | [
"def",
"elementtree_to_dict",
"(",
"element",
")",
":",
"d",
"=",
"dict",
"(",
")",
"if",
"hasattr",
"(",
"element",
",",
"'text'",
")",
"and",
"element",
".",
"text",
"is",
"not",
"None",
":",
"d",
"[",
"'text'",
"]",
"=",
"element",
".",
"text",
... | Convert an xml ElementTree to a dictionary. | [
"Convert",
"an",
"xml",
"ElementTree",
"to",
"a",
"dictionary",
"."
] | 725c21a3d0f5a30b8492cbc184b3688ceb364e1c | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/datasets/mfrdb.py#L69-L88 |
42,428 | MartinThoma/hwrt | hwrt/datasets/mfrdb.py | strip_end | def strip_end(text, suffix):
"""Strip `suffix` from the end of `text` if `text` has that suffix."""
if not text.endswith(suffix):
return text
return text[:len(text)-len(suffix)] | python | def strip_end(text, suffix):
"""Strip `suffix` from the end of `text` if `text` has that suffix."""
if not text.endswith(suffix):
return text
return text[:len(text)-len(suffix)] | [
"def",
"strip_end",
"(",
"text",
",",
"suffix",
")",
":",
"if",
"not",
"text",
".",
"endswith",
"(",
"suffix",
")",
":",
"return",
"text",
"return",
"text",
"[",
":",
"len",
"(",
"text",
")",
"-",
"len",
"(",
"suffix",
")",
"]"
] | Strip `suffix` from the end of `text` if `text` has that suffix. | [
"Strip",
"suffix",
"from",
"the",
"end",
"of",
"text",
"if",
"text",
"has",
"that",
"suffix",
"."
] | 725c21a3d0f5a30b8492cbc184b3688ceb364e1c | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/datasets/mfrdb.py#L91-L95 |
42,429 | MartinThoma/hwrt | hwrt/datasets/__init__.py | formula_to_dbid | def formula_to_dbid(formula_str, backslash_fix=False):
"""
Convert a LaTeX formula to the database index.
Parameters
----------
formula_str : string
The formula as LaTeX code.
backslash_fix : boolean
If this is set to true, then it will be checked if the same formula
exi... | python | def formula_to_dbid(formula_str, backslash_fix=False):
"""
Convert a LaTeX formula to the database index.
Parameters
----------
formula_str : string
The formula as LaTeX code.
backslash_fix : boolean
If this is set to true, then it will be checked if the same formula
exi... | [
"def",
"formula_to_dbid",
"(",
"formula_str",
",",
"backslash_fix",
"=",
"False",
")",
":",
"global",
"__formula_to_dbid_cache",
"if",
"__formula_to_dbid_cache",
"is",
"None",
":",
"mysql",
"=",
"utils",
".",
"get_mysql_cfg",
"(",
")",
"connection",
"=",
"pymysql"... | Convert a LaTeX formula to the database index.
Parameters
----------
formula_str : string
The formula as LaTeX code.
backslash_fix : boolean
If this is set to true, then it will be checked if the same formula
exists with a preceeding backslash.
Returns
-------
int :... | [
"Convert",
"a",
"LaTeX",
"formula",
"to",
"the",
"database",
"index",
"."
] | 725c21a3d0f5a30b8492cbc184b3688ceb364e1c | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/datasets/__init__.py#L20-L79 |
42,430 | MartinThoma/hwrt | hwrt/datasets/__init__.py | insert_recording | def insert_recording(hw):
"""Insert recording `hw` into database."""
mysql = utils.get_mysql_cfg()
connection = pymysql.connect(host=mysql['host'],
user=mysql['user'],
passwd=mysql['passwd'],
db=mysql['db'],
... | python | def insert_recording(hw):
"""Insert recording `hw` into database."""
mysql = utils.get_mysql_cfg()
connection = pymysql.connect(host=mysql['host'],
user=mysql['user'],
passwd=mysql['passwd'],
db=mysql['db'],
... | [
"def",
"insert_recording",
"(",
"hw",
")",
":",
"mysql",
"=",
"utils",
".",
"get_mysql_cfg",
"(",
")",
"connection",
"=",
"pymysql",
".",
"connect",
"(",
"host",
"=",
"mysql",
"[",
"'host'",
"]",
",",
"user",
"=",
"mysql",
"[",
"'user'",
"]",
",",
"p... | Insert recording `hw` into database. | [
"Insert",
"recording",
"hw",
"into",
"database",
"."
] | 725c21a3d0f5a30b8492cbc184b3688ceb364e1c | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/datasets/__init__.py#L137-L181 |
42,431 | MartinThoma/hwrt | hwrt/datasets/__init__.py | insert_symbol_mapping | def insert_symbol_mapping(raw_data_id, symbol_id, user_id, strokes):
"""
Insert data into `wm_strokes_to_symbol`.
Parameters
----------
raw_data_id : int
user_id : int
strokes: list of int
"""
mysql = utils.get_mysql_cfg()
connection = pymysql.connect(host=mysql['host'],
... | python | def insert_symbol_mapping(raw_data_id, symbol_id, user_id, strokes):
"""
Insert data into `wm_strokes_to_symbol`.
Parameters
----------
raw_data_id : int
user_id : int
strokes: list of int
"""
mysql = utils.get_mysql_cfg()
connection = pymysql.connect(host=mysql['host'],
... | [
"def",
"insert_symbol_mapping",
"(",
"raw_data_id",
",",
"symbol_id",
",",
"user_id",
",",
"strokes",
")",
":",
"mysql",
"=",
"utils",
".",
"get_mysql_cfg",
"(",
")",
"connection",
"=",
"pymysql",
".",
"connect",
"(",
"host",
"=",
"mysql",
"[",
"'host'",
"... | Insert data into `wm_strokes_to_symbol`.
Parameters
----------
raw_data_id : int
user_id : int
strokes: list of int | [
"Insert",
"data",
"into",
"wm_strokes_to_symbol",
"."
] | 725c21a3d0f5a30b8492cbc184b3688ceb364e1c | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/datasets/__init__.py#L184-L211 |
42,432 | MartinThoma/hwrt | hwrt/analyze_data.py | filter_label | def filter_label(label, replace_by_similar=True):
"""Some labels currently don't work together because of LaTeX naming
clashes. Those will be replaced by simple strings. """
bad_names = ['celsius', 'degree', 'ohm', 'venus', 'mars', 'astrosun',
'fullmoon', 'leftmoon', 'female', 'male', 'c... | python | def filter_label(label, replace_by_similar=True):
"""Some labels currently don't work together because of LaTeX naming
clashes. Those will be replaced by simple strings. """
bad_names = ['celsius', 'degree', 'ohm', 'venus', 'mars', 'astrosun',
'fullmoon', 'leftmoon', 'female', 'male', 'c... | [
"def",
"filter_label",
"(",
"label",
",",
"replace_by_similar",
"=",
"True",
")",
":",
"bad_names",
"=",
"[",
"'celsius'",
",",
"'degree'",
",",
"'ohm'",
",",
"'venus'",
",",
"'mars'",
",",
"'astrosun'",
",",
"'fullmoon'",
",",
"'leftmoon'",
",",
"'female'",... | Some labels currently don't work together because of LaTeX naming
clashes. Those will be replaced by simple strings. | [
"Some",
"labels",
"currently",
"don",
"t",
"work",
"together",
"because",
"of",
"LaTeX",
"naming",
"clashes",
".",
"Those",
"will",
"be",
"replaced",
"by",
"simple",
"strings",
"."
] | 725c21a3d0f5a30b8492cbc184b3688ceb364e1c | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/analyze_data.py#L27-L42 |
42,433 | MartinThoma/hwrt | hwrt/analyze_data.py | analyze_feature | def analyze_feature(raw_datasets, feature, basename="aspect_ratios"):
"""
Apply ``feature`` to all recordings in ``raw_datasets``. Store the results
in two files. One file stores the raw result, the other one groups the
results by symbols and stores the mean, standard deviation and the name of
the s... | python | def analyze_feature(raw_datasets, feature, basename="aspect_ratios"):
"""
Apply ``feature`` to all recordings in ``raw_datasets``. Store the results
in two files. One file stores the raw result, the other one groups the
results by symbols and stores the mean, standard deviation and the name of
the s... | [
"def",
"analyze_feature",
"(",
"raw_datasets",
",",
"feature",
",",
"basename",
"=",
"\"aspect_ratios\"",
")",
":",
"# Prepare files",
"csv_file",
"=",
"dam",
".",
"prepare_file",
"(",
"basename",
"+",
"'.csv'",
")",
"raw_file",
"=",
"dam",
".",
"prepare_file",
... | Apply ``feature`` to all recordings in ``raw_datasets``. Store the results
in two files. One file stores the raw result, the other one groups the
results by symbols and stores the mean, standard deviation and the name of
the symbol as a csv file.
Parameters
----------
raw_datasets : List of dic... | [
"Apply",
"feature",
"to",
"all",
"recordings",
"in",
"raw_datasets",
".",
"Store",
"the",
"results",
"in",
"two",
"files",
".",
"One",
"file",
"stores",
"the",
"raw",
"result",
"the",
"other",
"one",
"groups",
"the",
"results",
"by",
"symbols",
"and",
"sto... | 725c21a3d0f5a30b8492cbc184b3688ceb364e1c | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/analyze_data.py#L45-L90 |
42,434 | MartinThoma/hwrt | hwrt/analyze_data.py | main | def main(handwriting_datasets_file, analyze_features):
"""Start the creation of the wanted metric."""
# Load from pickled file
logging.info("Start loading data '%s' ...", handwriting_datasets_file)
loaded = pickle.load(open(handwriting_datasets_file))
raw_datasets = loaded['handwriting_datasets']
... | python | def main(handwriting_datasets_file, analyze_features):
"""Start the creation of the wanted metric."""
# Load from pickled file
logging.info("Start loading data '%s' ...", handwriting_datasets_file)
loaded = pickle.load(open(handwriting_datasets_file))
raw_datasets = loaded['handwriting_datasets']
... | [
"def",
"main",
"(",
"handwriting_datasets_file",
",",
"analyze_features",
")",
":",
"# Load from pickled file",
"logging",
".",
"info",
"(",
"\"Start loading data '%s' ...\"",
",",
"handwriting_datasets_file",
")",
"loaded",
"=",
"pickle",
".",
"load",
"(",
"open",
"(... | Start the creation of the wanted metric. | [
"Start",
"the",
"creation",
"of",
"the",
"wanted",
"metric",
"."
] | 725c21a3d0f5a30b8492cbc184b3688ceb364e1c | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/analyze_data.py#L93-L122 |
42,435 | MartinThoma/hwrt | hwrt/datasets/mathbrush.py | remove_matching_braces | def remove_matching_braces(latex):
"""
If `latex` is surrounded by matching braces, remove them. They are not
necessary.
Parameters
----------
latex : string
Returns
-------
string
Examples
--------
>>> remove_matching_braces('{2+2}')
'2+2'
>>> remove_matching_... | python | def remove_matching_braces(latex):
"""
If `latex` is surrounded by matching braces, remove them. They are not
necessary.
Parameters
----------
latex : string
Returns
-------
string
Examples
--------
>>> remove_matching_braces('{2+2}')
'2+2'
>>> remove_matching_... | [
"def",
"remove_matching_braces",
"(",
"latex",
")",
":",
"if",
"latex",
".",
"startswith",
"(",
"'{'",
")",
"and",
"latex",
".",
"endswith",
"(",
"'}'",
")",
":",
"opened",
"=",
"1",
"matches",
"=",
"True",
"for",
"char",
"in",
"latex",
"[",
"1",
":"... | If `latex` is surrounded by matching braces, remove them. They are not
necessary.
Parameters
----------
latex : string
Returns
-------
string
Examples
--------
>>> remove_matching_braces('{2+2}')
'2+2'
>>> remove_matching_braces('{2+2')
'{2+2' | [
"If",
"latex",
"is",
"surrounded",
"by",
"matching",
"braces",
"remove",
"them",
".",
"They",
"are",
"not",
"necessary",
"."
] | 725c21a3d0f5a30b8492cbc184b3688ceb364e1c | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/datasets/mathbrush.py#L45-L77 |
42,436 | MartinThoma/hwrt | hwrt/datasets/mathbrush.py | read_folder | def read_folder(folder):
"""Read all files of `folder` and return a list of HandwrittenData
objects.
Parameters
----------
folder : string
Path to a folder
Returns
-------
list :
A list of all .ink files in the given folder.
"""
recordings = []
for filename ... | python | def read_folder(folder):
"""Read all files of `folder` and return a list of HandwrittenData
objects.
Parameters
----------
folder : string
Path to a folder
Returns
-------
list :
A list of all .ink files in the given folder.
"""
recordings = []
for filename ... | [
"def",
"read_folder",
"(",
"folder",
")",
":",
"recordings",
"=",
"[",
"]",
"for",
"filename",
"in",
"glob",
".",
"glob",
"(",
"os",
".",
"path",
".",
"join",
"(",
"folder",
",",
"'*.ink'",
")",
")",
":",
"recording",
"=",
"parse_scg_ink_file",
"(",
... | Read all files of `folder` and return a list of HandwrittenData
objects.
Parameters
----------
folder : string
Path to a folder
Returns
-------
list :
A list of all .ink files in the given folder. | [
"Read",
"all",
"files",
"of",
"folder",
"and",
"return",
"a",
"list",
"of",
"HandwrittenData",
"objects",
"."
] | 725c21a3d0f5a30b8492cbc184b3688ceb364e1c | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/datasets/mathbrush.py#L250-L268 |
42,437 | MartinThoma/hwrt | hwrt/handwritten_data.py | _get_colors | def _get_colors(segmentation):
"""Get a list of colors which is as long as the segmentation.
Parameters
----------
segmentation : list of lists
Returns
-------
list
A list of colors.
"""
symbol_count = len(segmentation)
num_colors = symbol_count
# See http://stacko... | python | def _get_colors(segmentation):
"""Get a list of colors which is as long as the segmentation.
Parameters
----------
segmentation : list of lists
Returns
-------
list
A list of colors.
"""
symbol_count = len(segmentation)
num_colors = symbol_count
# See http://stacko... | [
"def",
"_get_colors",
"(",
"segmentation",
")",
":",
"symbol_count",
"=",
"len",
"(",
"segmentation",
")",
"num_colors",
"=",
"symbol_count",
"# See http://stackoverflow.com/a/20298116/562769",
"color_array",
"=",
"[",
"\"#000000\"",
",",
"\"#FFFF00\"",
",",
"\"#1CE6FF\... | Get a list of colors which is as long as the segmentation.
Parameters
----------
segmentation : list of lists
Returns
-------
list
A list of colors. | [
"Get",
"a",
"list",
"of",
"colors",
"which",
"is",
"as",
"long",
"as",
"the",
"segmentation",
"."
] | 725c21a3d0f5a30b8492cbc184b3688ceb364e1c | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/handwritten_data.py#L352-L401 |
42,438 | MartinThoma/hwrt | hwrt/handwritten_data.py | HandwrittenData.fix_times | def fix_times(self):
"""
Some recordings have wrong times. Fix them so that nothing after
loading a handwritten recording breaks.
"""
pointlist = self.get_pointlist()
times = [point['time'] for stroke in pointlist for point in stroke]
times_min = max(min(times), 0... | python | def fix_times(self):
"""
Some recordings have wrong times. Fix them so that nothing after
loading a handwritten recording breaks.
"""
pointlist = self.get_pointlist()
times = [point['time'] for stroke in pointlist for point in stroke]
times_min = max(min(times), 0... | [
"def",
"fix_times",
"(",
"self",
")",
":",
"pointlist",
"=",
"self",
".",
"get_pointlist",
"(",
")",
"times",
"=",
"[",
"point",
"[",
"'time'",
"]",
"for",
"stroke",
"in",
"pointlist",
"for",
"point",
"in",
"stroke",
"]",
"times_min",
"=",
"max",
"(",
... | Some recordings have wrong times. Fix them so that nothing after
loading a handwritten recording breaks. | [
"Some",
"recordings",
"have",
"wrong",
"times",
".",
"Fix",
"them",
"so",
"that",
"nothing",
"after",
"loading",
"a",
"handwritten",
"recording",
"breaks",
"."
] | 725c21a3d0f5a30b8492cbc184b3688ceb364e1c | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/handwritten_data.py#L43-L57 |
42,439 | MartinThoma/hwrt | hwrt/handwritten_data.py | HandwrittenData.get_pointlist | def get_pointlist(self):
"""
Get a list of lists of tuples from JSON raw data string. Those lists
represent strokes with control points.
Returns
-------
list :
A list of strokes. Each stroke is a list of dictionaries
{'x': 123, 'y': 42, 'time': 13... | python | def get_pointlist(self):
"""
Get a list of lists of tuples from JSON raw data string. Those lists
represent strokes with control points.
Returns
-------
list :
A list of strokes. Each stroke is a list of dictionaries
{'x': 123, 'y': 42, 'time': 13... | [
"def",
"get_pointlist",
"(",
"self",
")",
":",
"try",
":",
"pointlist",
"=",
"json",
".",
"loads",
"(",
"self",
".",
"raw_data_json",
")",
"except",
"Exception",
"as",
"inst",
":",
"logging",
".",
"debug",
"(",
"\"pointStrokeList: strokelistP\"",
")",
"loggi... | Get a list of lists of tuples from JSON raw data string. Those lists
represent strokes with control points.
Returns
-------
list :
A list of strokes. Each stroke is a list of dictionaries
{'x': 123, 'y': 42, 'time': 1337} | [
"Get",
"a",
"list",
"of",
"lists",
"of",
"tuples",
"from",
"JSON",
"raw",
"data",
"string",
".",
"Those",
"lists",
"represent",
"strokes",
"with",
"control",
"points",
"."
] | 725c21a3d0f5a30b8492cbc184b3688ceb364e1c | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/handwritten_data.py#L59-L81 |
42,440 | MartinThoma/hwrt | hwrt/handwritten_data.py | HandwrittenData.get_sorted_pointlist | def get_sorted_pointlist(self):
"""
Make sure that the points and strokes are in order.
Returns
-------
list
A list of all strokes in the recording. Each stroke is represented
as a list of dicts {'time': 123, 'x': 45, 'y': 67}
"""
pointlis... | python | def get_sorted_pointlist(self):
"""
Make sure that the points and strokes are in order.
Returns
-------
list
A list of all strokes in the recording. Each stroke is represented
as a list of dicts {'time': 123, 'x': 45, 'y': 67}
"""
pointlis... | [
"def",
"get_sorted_pointlist",
"(",
"self",
")",
":",
"pointlist",
"=",
"self",
".",
"get_pointlist",
"(",
")",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"pointlist",
")",
")",
":",
"pointlist",
"[",
"i",
"]",
"=",
"sorted",
"(",
"pointlist",
"[",
... | Make sure that the points and strokes are in order.
Returns
-------
list
A list of all strokes in the recording. Each stroke is represented
as a list of dicts {'time': 123, 'x': 45, 'y': 67} | [
"Make",
"sure",
"that",
"the",
"points",
"and",
"strokes",
"are",
"in",
"order",
"."
] | 725c21a3d0f5a30b8492cbc184b3688ceb364e1c | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/handwritten_data.py#L83-L97 |
42,441 | MartinThoma/hwrt | hwrt/handwritten_data.py | HandwrittenData.set_pointlist | def set_pointlist(self, pointlist):
"""Overwrite pointlist.
Parameters
----------
pointlist : a list of strokes; each stroke is a list of points
The inner lists represent strokes. Every stroke consists of points.
Every point is a dictinary with 'x', 'y', 'time'.
... | python | def set_pointlist(self, pointlist):
"""Overwrite pointlist.
Parameters
----------
pointlist : a list of strokes; each stroke is a list of points
The inner lists represent strokes. Every stroke consists of points.
Every point is a dictinary with 'x', 'y', 'time'.
... | [
"def",
"set_pointlist",
"(",
"self",
",",
"pointlist",
")",
":",
"assert",
"type",
"(",
"pointlist",
")",
"is",
"list",
",",
"\"pointlist is not of type list, but %r\"",
"%",
"type",
"(",
"pointlist",
")",
"assert",
"len",
"(",
"pointlist",
")",
">=",
"1",
"... | Overwrite pointlist.
Parameters
----------
pointlist : a list of strokes; each stroke is a list of points
The inner lists represent strokes. Every stroke consists of points.
Every point is a dictinary with 'x', 'y', 'time'. | [
"Overwrite",
"pointlist",
"."
] | 725c21a3d0f5a30b8492cbc184b3688ceb364e1c | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/handwritten_data.py#L99-L113 |
42,442 | MartinThoma/hwrt | hwrt/handwritten_data.py | HandwrittenData.get_bounding_box | def get_bounding_box(self):
""" Get the bounding box of a pointlist. """
pointlist = self.get_pointlist()
# Initialize bounding box parameters to save values
minx, maxx = pointlist[0][0]["x"], pointlist[0][0]["x"]
miny, maxy = pointlist[0][0]["y"], pointlist[0][0]["y"]
m... | python | def get_bounding_box(self):
""" Get the bounding box of a pointlist. """
pointlist = self.get_pointlist()
# Initialize bounding box parameters to save values
minx, maxx = pointlist[0][0]["x"], pointlist[0][0]["x"]
miny, maxy = pointlist[0][0]["y"], pointlist[0][0]["y"]
m... | [
"def",
"get_bounding_box",
"(",
"self",
")",
":",
"pointlist",
"=",
"self",
".",
"get_pointlist",
"(",
")",
"# Initialize bounding box parameters to save values",
"minx",
",",
"maxx",
"=",
"pointlist",
"[",
"0",
"]",
"[",
"0",
"]",
"[",
"\"x\"",
"]",
",",
"p... | Get the bounding box of a pointlist. | [
"Get",
"the",
"bounding",
"box",
"of",
"a",
"pointlist",
"."
] | 725c21a3d0f5a30b8492cbc184b3688ceb364e1c | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/handwritten_data.py#L115-L131 |
42,443 | MartinThoma/hwrt | hwrt/handwritten_data.py | HandwrittenData.get_bitmap | def get_bitmap(self, time=None, size=32, store_path=None):
"""
Get a bitmap of the object at a given instance of time. If time is
`None`,`then the bitmap is generated for the last point in time.
Parameters
----------
time : int or None
size : int
Size... | python | def get_bitmap(self, time=None, size=32, store_path=None):
"""
Get a bitmap of the object at a given instance of time. If time is
`None`,`then the bitmap is generated for the last point in time.
Parameters
----------
time : int or None
size : int
Size... | [
"def",
"get_bitmap",
"(",
"self",
",",
"time",
"=",
"None",
",",
"size",
"=",
"32",
",",
"store_path",
"=",
"None",
")",
":",
"# bitmap_width = int(self.get_width()*size) + 2",
"# bitmap_height = int(self.get_height()*size) + 2",
"img",
"=",
"Image",
".",
"new",
"("... | Get a bitmap of the object at a given instance of time. If time is
`None`,`then the bitmap is generated for the last point in time.
Parameters
----------
time : int or None
size : int
Size in pixels. The resulting bitmap will be (size x size).
store_path : No... | [
"Get",
"a",
"bitmap",
"of",
"the",
"object",
"at",
"a",
"given",
"instance",
"of",
"time",
".",
"If",
"time",
"is",
"None",
"then",
"the",
"bitmap",
"is",
"generated",
"for",
"the",
"last",
"point",
"in",
"time",
"."
] | 725c21a3d0f5a30b8492cbc184b3688ceb364e1c | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/handwritten_data.py#L152-L194 |
42,444 | MartinThoma/hwrt | hwrt/handwritten_data.py | HandwrittenData.preprocessing | def preprocessing(self, algorithms):
"""Apply preprocessing algorithms.
Parameters
----------
algorithms : a list objects
Preprocessing allgorithms which get applied in order.
Examples
--------
>>> import preprocessing
>>> a = HandwrittenData... | python | def preprocessing(self, algorithms):
"""Apply preprocessing algorithms.
Parameters
----------
algorithms : a list objects
Preprocessing allgorithms which get applied in order.
Examples
--------
>>> import preprocessing
>>> a = HandwrittenData... | [
"def",
"preprocessing",
"(",
"self",
",",
"algorithms",
")",
":",
"assert",
"type",
"(",
"algorithms",
")",
"is",
"list",
"for",
"algorithm",
"in",
"algorithms",
":",
"algorithm",
"(",
"self",
")"
] | Apply preprocessing algorithms.
Parameters
----------
algorithms : a list objects
Preprocessing allgorithms which get applied in order.
Examples
--------
>>> import preprocessing
>>> a = HandwrittenData(...)
>>> preprocessing_queue = [(prepro... | [
"Apply",
"preprocessing",
"algorithms",
"."
] | 725c21a3d0f5a30b8492cbc184b3688ceb364e1c | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/handwritten_data.py#L196-L219 |
42,445 | MartinThoma/hwrt | hwrt/handwritten_data.py | HandwrittenData.feature_extraction | def feature_extraction(self, algorithms):
"""Get a list of features.
Every algorithm has to return the features as a list."""
assert type(algorithms) is list
features = []
for algorithm in algorithms:
new_features = algorithm(self)
assert len(new_features... | python | def feature_extraction(self, algorithms):
"""Get a list of features.
Every algorithm has to return the features as a list."""
assert type(algorithms) is list
features = []
for algorithm in algorithms:
new_features = algorithm(self)
assert len(new_features... | [
"def",
"feature_extraction",
"(",
"self",
",",
"algorithms",
")",
":",
"assert",
"type",
"(",
"algorithms",
")",
"is",
"list",
"features",
"=",
"[",
"]",
"for",
"algorithm",
"in",
"algorithms",
":",
"new_features",
"=",
"algorithm",
"(",
"self",
")",
"asse... | Get a list of features.
Every algorithm has to return the features as a list. | [
"Get",
"a",
"list",
"of",
"features",
"."
] | 725c21a3d0f5a30b8492cbc184b3688ceb364e1c | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/handwritten_data.py#L221-L233 |
42,446 | MartinThoma/hwrt | hwrt/handwritten_data.py | HandwrittenData.show | def show(self):
"""Show the data graphically in a new pop-up window."""
# prevent the following error:
# '_tkinter.TclError: no display name and no $DISPLAY environment
# variable'
# import matplotlib
# matplotlib.use('GTK3Agg', warn=False)
import matplotlib.... | python | def show(self):
"""Show the data graphically in a new pop-up window."""
# prevent the following error:
# '_tkinter.TclError: no display name and no $DISPLAY environment
# variable'
# import matplotlib
# matplotlib.use('GTK3Agg', warn=False)
import matplotlib.... | [
"def",
"show",
"(",
"self",
")",
":",
"# prevent the following error:",
"# '_tkinter.TclError: no display name and no $DISPLAY environment",
"# variable'",
"# import matplotlib",
"# matplotlib.use('GTK3Agg', warn=False)",
"import",
"matplotlib",
".",
"pyplot",
"as",
"plt",
"poin... | Show the data graphically in a new pop-up window. | [
"Show",
"the",
"data",
"graphically",
"in",
"a",
"new",
"pop",
"-",
"up",
"window",
"."
] | 725c21a3d0f5a30b8492cbc184b3688ceb364e1c | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/handwritten_data.py#L235-L287 |
42,447 | MartinThoma/hwrt | hwrt/handwritten_data.py | HandwrittenData.count_single_dots | def count_single_dots(self):
"""Count all strokes of this recording that have only a single dot.
"""
pointlist = self.get_pointlist()
single_dots = 0
for stroke in pointlist:
if len(stroke) == 1:
single_dots += 1
return single_dots | python | def count_single_dots(self):
"""Count all strokes of this recording that have only a single dot.
"""
pointlist = self.get_pointlist()
single_dots = 0
for stroke in pointlist:
if len(stroke) == 1:
single_dots += 1
return single_dots | [
"def",
"count_single_dots",
"(",
"self",
")",
":",
"pointlist",
"=",
"self",
".",
"get_pointlist",
"(",
")",
"single_dots",
"=",
"0",
"for",
"stroke",
"in",
"pointlist",
":",
"if",
"len",
"(",
"stroke",
")",
"==",
"1",
":",
"single_dots",
"+=",
"1",
"r... | Count all strokes of this recording that have only a single dot. | [
"Count",
"all",
"strokes",
"of",
"this",
"recording",
"that",
"have",
"only",
"a",
"single",
"dot",
"."
] | 725c21a3d0f5a30b8492cbc184b3688ceb364e1c | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/handwritten_data.py#L289-L297 |
42,448 | MartinThoma/hwrt | hwrt/handwritten_data.py | HandwrittenData.to_single_symbol_list | def to_single_symbol_list(self):
"""
Convert this HandwrittenData object into a list of HandwrittenData
objects. Each element of the list is a single symbol.
Returns
-------
list of HandwrittenData objects
"""
symbol_stream = getattr(self,
... | python | def to_single_symbol_list(self):
"""
Convert this HandwrittenData object into a list of HandwrittenData
objects. Each element of the list is a single symbol.
Returns
-------
list of HandwrittenData objects
"""
symbol_stream = getattr(self,
... | [
"def",
"to_single_symbol_list",
"(",
"self",
")",
":",
"symbol_stream",
"=",
"getattr",
"(",
"self",
",",
"'symbol_stream'",
",",
"[",
"None",
"for",
"symbol",
"in",
"self",
".",
"segmentation",
"]",
")",
"single_symbols",
"=",
"[",
"]",
"pointlist",
"=",
... | Convert this HandwrittenData object into a list of HandwrittenData
objects. Each element of the list is a single symbol.
Returns
-------
list of HandwrittenData objects | [
"Convert",
"this",
"HandwrittenData",
"object",
"into",
"a",
"list",
"of",
"HandwrittenData",
"objects",
".",
"Each",
"element",
"of",
"the",
"list",
"is",
"a",
"single",
"symbol",
"."
] | 725c21a3d0f5a30b8492cbc184b3688ceb364e1c | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/handwritten_data.py#L313-L333 |
42,449 | acsone/setuptools-odoo | setuptools_odoo/git_postversion.py | get_git_postversion | def get_git_postversion(addon_dir):
""" return the addon version number, with a developmental version increment
if there were git commits in the addon_dir after the last version change.
If the last change to the addon correspond to the version number in the
manifest it is used as is for the python pack... | python | def get_git_postversion(addon_dir):
""" return the addon version number, with a developmental version increment
if there were git commits in the addon_dir after the last version change.
If the last change to the addon correspond to the version number in the
manifest it is used as is for the python pack... | [
"def",
"get_git_postversion",
"(",
"addon_dir",
")",
":",
"addon_dir",
"=",
"os",
".",
"path",
".",
"realpath",
"(",
"addon_dir",
")",
"last_version",
"=",
"read_manifest",
"(",
"addon_dir",
")",
".",
"get",
"(",
"'version'",
",",
"'0.0.0'",
")",
"last_versi... | return the addon version number, with a developmental version increment
if there were git commits in the addon_dir after the last version change.
If the last change to the addon correspond to the version number in the
manifest it is used as is for the python package version. Otherwise a
counter is incr... | [
"return",
"the",
"addon",
"version",
"number",
"with",
"a",
"developmental",
"version",
"increment",
"if",
"there",
"were",
"git",
"commits",
"in",
"the",
"addon_dir",
"after",
"the",
"last",
"version",
"change",
"."
] | cc4d7a63cf99fb3651c8c92f66f7dd13bf2afe6b | https://github.com/acsone/setuptools-odoo/blob/cc4d7a63cf99fb3651c8c92f66f7dd13bf2afe6b/setuptools_odoo/git_postversion.py#L82-L134 |
42,450 | acsone/setuptools-odoo | setuptools_odoo/core.py | _get_odoo_version_info | def _get_odoo_version_info(addons_dir, odoo_version_override=None):
""" Detect Odoo version from an addons directory """
odoo_version_info = None
addons = os.listdir(addons_dir)
for addon in addons:
addon_dir = os.path.join(addons_dir, addon)
if is_installable_addon(addon_dir):
... | python | def _get_odoo_version_info(addons_dir, odoo_version_override=None):
""" Detect Odoo version from an addons directory """
odoo_version_info = None
addons = os.listdir(addons_dir)
for addon in addons:
addon_dir = os.path.join(addons_dir, addon)
if is_installable_addon(addon_dir):
... | [
"def",
"_get_odoo_version_info",
"(",
"addons_dir",
",",
"odoo_version_override",
"=",
"None",
")",
":",
"odoo_version_info",
"=",
"None",
"addons",
"=",
"os",
".",
"listdir",
"(",
"addons_dir",
")",
"for",
"addon",
"in",
"addons",
":",
"addon_dir",
"=",
"os",... | Detect Odoo version from an addons directory | [
"Detect",
"Odoo",
"version",
"from",
"an",
"addons",
"directory"
] | cc4d7a63cf99fb3651c8c92f66f7dd13bf2afe6b | https://github.com/acsone/setuptools-odoo/blob/cc4d7a63cf99fb3651c8c92f66f7dd13bf2afe6b/setuptools_odoo/core.py#L78-L95 |
42,451 | acsone/setuptools-odoo | setuptools_odoo/core.py | _get_version | def _get_version(addon_dir, manifest, odoo_version_override=None,
git_post_version=True):
""" Get addon version information from an addon directory """
version = manifest.get('version')
if not version:
warn("No version in manifest in %s" % addon_dir)
version = '0.0.0'
if... | python | def _get_version(addon_dir, manifest, odoo_version_override=None,
git_post_version=True):
""" Get addon version information from an addon directory """
version = manifest.get('version')
if not version:
warn("No version in manifest in %s" % addon_dir)
version = '0.0.0'
if... | [
"def",
"_get_version",
"(",
"addon_dir",
",",
"manifest",
",",
"odoo_version_override",
"=",
"None",
",",
"git_post_version",
"=",
"True",
")",
":",
"version",
"=",
"manifest",
".",
"get",
"(",
"'version'",
")",
"if",
"not",
"version",
":",
"warn",
"(",
"\... | Get addon version information from an addon directory | [
"Get",
"addon",
"version",
"information",
"from",
"an",
"addon",
"directory"
] | cc4d7a63cf99fb3651c8c92f66f7dd13bf2afe6b | https://github.com/acsone/setuptools-odoo/blob/cc4d7a63cf99fb3651c8c92f66f7dd13bf2afe6b/setuptools_odoo/core.py#L98-L120 |
42,452 | acsone/setuptools-odoo | setuptools_odoo/core.py | get_install_requires_odoo_addon | def get_install_requires_odoo_addon(addon_dir,
no_depends=[],
depends_override={},
external_dependencies_override={},
odoo_version_override=None):
""" Get the list of requi... | python | def get_install_requires_odoo_addon(addon_dir,
no_depends=[],
depends_override={},
external_dependencies_override={},
odoo_version_override=None):
""" Get the list of requi... | [
"def",
"get_install_requires_odoo_addon",
"(",
"addon_dir",
",",
"no_depends",
"=",
"[",
"]",
",",
"depends_override",
"=",
"{",
"}",
",",
"external_dependencies_override",
"=",
"{",
"}",
",",
"odoo_version_override",
"=",
"None",
")",
":",
"manifest",
"=",
"rea... | Get the list of requirements for an addon | [
"Get",
"the",
"list",
"of",
"requirements",
"for",
"an",
"addon"
] | cc4d7a63cf99fb3651c8c92f66f7dd13bf2afe6b | https://github.com/acsone/setuptools-odoo/blob/cc4d7a63cf99fb3651c8c92f66f7dd13bf2afe6b/setuptools_odoo/core.py#L193-L208 |
42,453 | acsone/setuptools-odoo | setuptools_odoo/core.py | get_install_requires_odoo_addons | def get_install_requires_odoo_addons(addons_dir,
depends_override={},
external_dependencies_override={},
odoo_version_override=None):
""" Get the list of requirements for a directory containing addons """
... | python | def get_install_requires_odoo_addons(addons_dir,
depends_override={},
external_dependencies_override={},
odoo_version_override=None):
""" Get the list of requirements for a directory containing addons """
... | [
"def",
"get_install_requires_odoo_addons",
"(",
"addons_dir",
",",
"depends_override",
"=",
"{",
"}",
",",
"external_dependencies_override",
"=",
"{",
"}",
",",
"odoo_version_override",
"=",
"None",
")",
":",
"addon_dirs",
"=",
"[",
"]",
"addons",
"=",
"os",
"."... | Get the list of requirements for a directory containing addons | [
"Get",
"the",
"list",
"of",
"requirements",
"for",
"a",
"directory",
"containing",
"addons"
] | cc4d7a63cf99fb3651c8c92f66f7dd13bf2afe6b | https://github.com/acsone/setuptools-odoo/blob/cc4d7a63cf99fb3651c8c92f66f7dd13bf2afe6b/setuptools_odoo/core.py#L211-L232 |
42,454 | dgilland/flask-alchy | flask_alchy.py | Alchy.make_declarative_base | def make_declarative_base(self, metadata=None):
"""Override parent function with alchy's"""
return make_declarative_base(self.session,
Model=self.Model,
metadata=metadata) | python | def make_declarative_base(self, metadata=None):
"""Override parent function with alchy's"""
return make_declarative_base(self.session,
Model=self.Model,
metadata=metadata) | [
"def",
"make_declarative_base",
"(",
"self",
",",
"metadata",
"=",
"None",
")",
":",
"return",
"make_declarative_base",
"(",
"self",
".",
"session",
",",
"Model",
"=",
"self",
".",
"Model",
",",
"metadata",
"=",
"metadata",
")"
] | Override parent function with alchy's | [
"Override",
"parent",
"function",
"with",
"alchy",
"s"
] | 25795bb14513769105e1da419a8f7366040ade42 | https://github.com/dgilland/flask-alchy/blob/25795bb14513769105e1da419a8f7366040ade42/flask_alchy.py#L33-L37 |
42,455 | capless/kev | kev/backends/__init__.py | DocDB.prep_doc | def prep_doc(self, doc_obj):
"""
This method Validates, gets the Python value, checks unique indexes,
gets the db value, and then returns the prepared doc dict object.
Useful for save and backup functions.
@param doc_obj:
@return:
"""
doc = doc_obj._da... | python | def prep_doc(self, doc_obj):
"""
This method Validates, gets the Python value, checks unique indexes,
gets the db value, and then returns the prepared doc dict object.
Useful for save and backup functions.
@param doc_obj:
@return:
"""
doc = doc_obj._da... | [
"def",
"prep_doc",
"(",
"self",
",",
"doc_obj",
")",
":",
"doc",
"=",
"doc_obj",
".",
"_data",
".",
"copy",
"(",
")",
"for",
"key",
",",
"prop",
"in",
"list",
"(",
"doc_obj",
".",
"_base_properties",
".",
"items",
"(",
")",
")",
":",
"prop",
".",
... | This method Validates, gets the Python value, checks unique indexes,
gets the db value, and then returns the prepared doc dict object.
Useful for save and backup functions.
@param doc_obj:
@return: | [
"This",
"method",
"Validates",
"gets",
"the",
"Python",
"value",
"checks",
"unique",
"indexes",
"gets",
"the",
"db",
"value",
"and",
"then",
"returns",
"the",
"prepared",
"doc",
"dict",
"object",
".",
"Useful",
"for",
"save",
"and",
"backup",
"functions",
".... | 902f4d5d89482b2eedcf9a396d57be7083357024 | https://github.com/capless/kev/blob/902f4d5d89482b2eedcf9a396d57be7083357024/kev/backends/__init__.py#L52-L70 |
42,456 | Miserlou/flask-zappa | bin/client.py | apply_zappa_settings | def apply_zappa_settings(zappa_obj, zappa_settings, environment):
'''Load Zappa settings, set defaults if needed, and apply to the Zappa object'''
settings_all = json.load(zappa_settings)
settings = settings_all[environment]
# load defaults for missing options
for key,value in DEFAULT_SETTINGS.ite... | python | def apply_zappa_settings(zappa_obj, zappa_settings, environment):
'''Load Zappa settings, set defaults if needed, and apply to the Zappa object'''
settings_all = json.load(zappa_settings)
settings = settings_all[environment]
# load defaults for missing options
for key,value in DEFAULT_SETTINGS.ite... | [
"def",
"apply_zappa_settings",
"(",
"zappa_obj",
",",
"zappa_settings",
",",
"environment",
")",
":",
"settings_all",
"=",
"json",
".",
"load",
"(",
"zappa_settings",
")",
"settings",
"=",
"settings_all",
"[",
"environment",
"]",
"# load defaults for missing options",... | Load Zappa settings, set defaults if needed, and apply to the Zappa object | [
"Load",
"Zappa",
"settings",
"set",
"defaults",
"if",
"needed",
"and",
"apply",
"to",
"the",
"Zappa",
"object"
] | 18af3c1ff3943d3c7b8b7f96d4ab5f147b9662f8 | https://github.com/Miserlou/flask-zappa/blob/18af3c1ff3943d3c7b8b7f96d4ab5f147b9662f8/bin/client.py#L35-L55 |
42,457 | Miserlou/flask-zappa | bin/client.py | deploy | def deploy(environment, zappa_settings):
""" Package, create and deploy to Lambda."""
print(("Deploying " + environment))
zappa, settings, lambda_name, zip_path = \
_package(environment, zappa_settings)
s3_bucket_name = settings['s3_bucket']
try:
# Load your AWS credentials from ~... | python | def deploy(environment, zappa_settings):
""" Package, create and deploy to Lambda."""
print(("Deploying " + environment))
zappa, settings, lambda_name, zip_path = \
_package(environment, zappa_settings)
s3_bucket_name = settings['s3_bucket']
try:
# Load your AWS credentials from ~... | [
"def",
"deploy",
"(",
"environment",
",",
"zappa_settings",
")",
":",
"print",
"(",
"(",
"\"Deploying \"",
"+",
"environment",
")",
")",
"zappa",
",",
"settings",
",",
"lambda_name",
",",
"zip_path",
"=",
"_package",
"(",
"environment",
",",
"zappa_settings",
... | Package, create and deploy to Lambda. | [
"Package",
"create",
"and",
"deploy",
"to",
"Lambda",
"."
] | 18af3c1ff3943d3c7b8b7f96d4ab5f147b9662f8 | https://github.com/Miserlou/flask-zappa/blob/18af3c1ff3943d3c7b8b7f96d4ab5f147b9662f8/bin/client.py#L128-L175 |
42,458 | Miserlou/flask-zappa | bin/client.py | update | def update(environment, zappa_settings):
""" Update an existing deployment."""
print(("Updating " + environment))
# Package dependencies, and the source code into a zip
zappa, settings, lambda_name, zip_path = \
_package(environment, zappa_settings)
s3_bucket_name = settings['s3_bucket']
... | python | def update(environment, zappa_settings):
""" Update an existing deployment."""
print(("Updating " + environment))
# Package dependencies, and the source code into a zip
zappa, settings, lambda_name, zip_path = \
_package(environment, zappa_settings)
s3_bucket_name = settings['s3_bucket']
... | [
"def",
"update",
"(",
"environment",
",",
"zappa_settings",
")",
":",
"print",
"(",
"(",
"\"Updating \"",
"+",
"environment",
")",
")",
"# Package dependencies, and the source code into a zip",
"zappa",
",",
"settings",
",",
"lambda_name",
",",
"zip_path",
"=",
"_pa... | Update an existing deployment. | [
"Update",
"an",
"existing",
"deployment",
"."
] | 18af3c1ff3943d3c7b8b7f96d4ab5f147b9662f8 | https://github.com/Miserlou/flask-zappa/blob/18af3c1ff3943d3c7b8b7f96d4ab5f147b9662f8/bin/client.py#L181-L218 |
42,459 | Miserlou/flask-zappa | flask_zappa/handler.py | lambda_handler | def lambda_handler(event, context, settings_name="zappa_settings"):
""" An AWS Lambda function which parses specific API Gateway input into a
WSGI request, feeds it to Flask, procceses the Flask response, and returns
that back to the API Gateway.
"""
# Loading settings from a python module
setti... | python | def lambda_handler(event, context, settings_name="zappa_settings"):
""" An AWS Lambda function which parses specific API Gateway input into a
WSGI request, feeds it to Flask, procceses the Flask response, and returns
that back to the API Gateway.
"""
# Loading settings from a python module
setti... | [
"def",
"lambda_handler",
"(",
"event",
",",
"context",
",",
"settings_name",
"=",
"\"zappa_settings\"",
")",
":",
"# Loading settings from a python module",
"settings",
"=",
"importlib",
".",
"import_module",
"(",
"settings_name",
")",
"# The flask-app module",
"app_modul... | An AWS Lambda function which parses specific API Gateway input into a
WSGI request, feeds it to Flask, procceses the Flask response, and returns
that back to the API Gateway. | [
"An",
"AWS",
"Lambda",
"function",
"which",
"parses",
"specific",
"API",
"Gateway",
"input",
"into",
"a",
"WSGI",
"request",
"feeds",
"it",
"to",
"Flask",
"procceses",
"the",
"Flask",
"response",
"and",
"returns",
"that",
"back",
"to",
"the",
"API",
"Gateway... | 18af3c1ff3943d3c7b8b7f96d4ab5f147b9662f8 | https://github.com/Miserlou/flask-zappa/blob/18af3c1ff3943d3c7b8b7f96d4ab5f147b9662f8/flask_zappa/handler.py#L15-L106 |
42,460 | frankban/django-endless-pagination | endless_pagination/views.py | MultipleObjectMixin.get_context_data | def get_context_data(self, **kwargs):
"""Get the context for this view.
Also adds the *page_template* variable in the context.
If the *page_template* is not given as a kwarg of the *as_view*
method then it is generated using app label, model name
(obviously if the list is a que... | python | def get_context_data(self, **kwargs):
"""Get the context for this view.
Also adds the *page_template* variable in the context.
If the *page_template* is not given as a kwarg of the *as_view*
method then it is generated using app label, model name
(obviously if the list is a que... | [
"def",
"get_context_data",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"queryset",
"=",
"kwargs",
".",
"pop",
"(",
"'object_list'",
")",
"page_template",
"=",
"kwargs",
".",
"pop",
"(",
"'page_template'",
",",
"None",
")",
"context_object_name",
"=",
"... | Get the context for this view.
Also adds the *page_template* variable in the context.
If the *page_template* is not given as a kwarg of the *as_view*
method then it is generated using app label, model name
(obviously if the list is a queryset), *self.template_name_suffix*
and *... | [
"Get",
"the",
"context",
"for",
"this",
"view",
"."
] | 4814fe7cf81277efe35e96b88f57cc260a771255 | https://github.com/frankban/django-endless-pagination/blob/4814fe7cf81277efe35e96b88f57cc260a771255/endless_pagination/views.py#L63-L93 |
42,461 | SpockBotMC/SpockBot | spockbot/mcdata/utils.py | clean_var | def clean_var(text):
"""Turn text into a valid python classname or variable"""
text = re_invalid_var.sub('', text)
text = re_invalid_start.sub('', text)
return text | python | def clean_var(text):
"""Turn text into a valid python classname or variable"""
text = re_invalid_var.sub('', text)
text = re_invalid_start.sub('', text)
return text | [
"def",
"clean_var",
"(",
"text",
")",
":",
"text",
"=",
"re_invalid_var",
".",
"sub",
"(",
"''",
",",
"text",
")",
"text",
"=",
"re_invalid_start",
".",
"sub",
"(",
"''",
",",
"text",
")",
"return",
"text"
] | Turn text into a valid python classname or variable | [
"Turn",
"text",
"into",
"a",
"valid",
"python",
"classname",
"or",
"variable"
] | f89911551f18357720034fbaa52837a0d09f66ea | https://github.com/SpockBotMC/SpockBot/blob/f89911551f18357720034fbaa52837a0d09f66ea/spockbot/mcdata/utils.py#L65-L69 |
42,462 | SpockBotMC/SpockBot | spockbot/plugins/tools/task.py | TaskFailed.full_tasktrace | def full_tasktrace(self):
"""
List of all failed tasks caused by this and all previous errors.
Returns:
List[Task]
"""
if self.prev_error:
return self.prev_error.tasktrace + self.tasktrace
else:
return self.tasktrace | python | def full_tasktrace(self):
"""
List of all failed tasks caused by this and all previous errors.
Returns:
List[Task]
"""
if self.prev_error:
return self.prev_error.tasktrace + self.tasktrace
else:
return self.tasktrace | [
"def",
"full_tasktrace",
"(",
"self",
")",
":",
"if",
"self",
".",
"prev_error",
":",
"return",
"self",
".",
"prev_error",
".",
"tasktrace",
"+",
"self",
".",
"tasktrace",
"else",
":",
"return",
"self",
".",
"tasktrace"
] | List of all failed tasks caused by this and all previous errors.
Returns:
List[Task] | [
"List",
"of",
"all",
"failed",
"tasks",
"caused",
"by",
"this",
"and",
"all",
"previous",
"errors",
"."
] | f89911551f18357720034fbaa52837a0d09f66ea | https://github.com/SpockBotMC/SpockBot/blob/f89911551f18357720034fbaa52837a0d09f66ea/spockbot/plugins/tools/task.py#L70-L80 |
42,463 | SpockBotMC/SpockBot | spockbot/vector.py | CartesianVector.dist_sq | def dist_sq(self, other=None):
""" For fast length comparison """
v = self - other if other else self
return sum(map(lambda a: a * a, v)) | python | def dist_sq(self, other=None):
""" For fast length comparison """
v = self - other if other else self
return sum(map(lambda a: a * a, v)) | [
"def",
"dist_sq",
"(",
"self",
",",
"other",
"=",
"None",
")",
":",
"v",
"=",
"self",
"-",
"other",
"if",
"other",
"else",
"self",
"return",
"sum",
"(",
"map",
"(",
"lambda",
"a",
":",
"a",
"*",
"a",
",",
"v",
")",
")"
] | For fast length comparison | [
"For",
"fast",
"length",
"comparison"
] | f89911551f18357720034fbaa52837a0d09f66ea | https://github.com/SpockBotMC/SpockBot/blob/f89911551f18357720034fbaa52837a0d09f66ea/spockbot/vector.py#L119-L122 |
42,464 | SpockBotMC/SpockBot | spockbot/vector.py | Vector3.yaw_pitch | def yaw_pitch(self):
"""
Calculate the yaw and pitch of this vector
"""
if not self:
return YawPitch(0, 0)
ground_distance = math.sqrt(self.x ** 2 + self.z ** 2)
if ground_distance:
alpha1 = -math.asin(self.x / ground_distance) / math.pi * 180
... | python | def yaw_pitch(self):
"""
Calculate the yaw and pitch of this vector
"""
if not self:
return YawPitch(0, 0)
ground_distance = math.sqrt(self.x ** 2 + self.z ** 2)
if ground_distance:
alpha1 = -math.asin(self.x / ground_distance) / math.pi * 180
... | [
"def",
"yaw_pitch",
"(",
"self",
")",
":",
"if",
"not",
"self",
":",
"return",
"YawPitch",
"(",
"0",
",",
"0",
")",
"ground_distance",
"=",
"math",
".",
"sqrt",
"(",
"self",
".",
"x",
"**",
"2",
"+",
"self",
".",
"z",
"**",
"2",
")",
"if",
"gro... | Calculate the yaw and pitch of this vector | [
"Calculate",
"the",
"yaw",
"and",
"pitch",
"of",
"this",
"vector"
] | f89911551f18357720034fbaa52837a0d09f66ea | https://github.com/SpockBotMC/SpockBot/blob/f89911551f18357720034fbaa52837a0d09f66ea/spockbot/vector.py#L204-L228 |
42,465 | SpockBotMC/SpockBot | spockbot/mcdata/windows.py | make_slot_check | def make_slot_check(wanted):
"""
Creates and returns a function that takes a slot
and checks if it matches the wanted item.
Args:
wanted: function(Slot) or Slot or itemID or (itemID, metadata)
"""
if isinstance(wanted, types.FunctionType):
return wanted # just forward the slot ... | python | def make_slot_check(wanted):
"""
Creates and returns a function that takes a slot
and checks if it matches the wanted item.
Args:
wanted: function(Slot) or Slot or itemID or (itemID, metadata)
"""
if isinstance(wanted, types.FunctionType):
return wanted # just forward the slot ... | [
"def",
"make_slot_check",
"(",
"wanted",
")",
":",
"if",
"isinstance",
"(",
"wanted",
",",
"types",
".",
"FunctionType",
")",
":",
"return",
"wanted",
"# just forward the slot check function",
"if",
"isinstance",
"(",
"wanted",
",",
"int",
")",
":",
"item",
",... | Creates and returns a function that takes a slot
and checks if it matches the wanted item.
Args:
wanted: function(Slot) or Slot or itemID or (itemID, metadata) | [
"Creates",
"and",
"returns",
"a",
"function",
"that",
"takes",
"a",
"slot",
"and",
"checks",
"if",
"it",
"matches",
"the",
"wanted",
"item",
"."
] | f89911551f18357720034fbaa52837a0d09f66ea | https://github.com/SpockBotMC/SpockBot/blob/f89911551f18357720034fbaa52837a0d09f66ea/spockbot/mcdata/windows.py#L13-L39 |
42,466 | SpockBotMC/SpockBot | spockbot/mcdata/windows.py | _make_window | def _make_window(window_dict):
"""
Creates a new class for that window and registers it at this module.
"""
cls_name = '%sWindow' % camel_case(str(window_dict['name']))
bases = (Window,)
attrs = {
'__module__': sys.modules[__name__],
'name': str(window_dict['name']),
'inv... | python | def _make_window(window_dict):
"""
Creates a new class for that window and registers it at this module.
"""
cls_name = '%sWindow' % camel_case(str(window_dict['name']))
bases = (Window,)
attrs = {
'__module__': sys.modules[__name__],
'name': str(window_dict['name']),
'inv... | [
"def",
"_make_window",
"(",
"window_dict",
")",
":",
"cls_name",
"=",
"'%sWindow'",
"%",
"camel_case",
"(",
"str",
"(",
"window_dict",
"[",
"'name'",
"]",
")",
")",
"bases",
"=",
"(",
"Window",
",",
")",
"attrs",
"=",
"{",
"'__module__'",
":",
"sys",
"... | Creates a new class for that window and registers it at this module. | [
"Creates",
"a",
"new",
"class",
"for",
"that",
"window",
"and",
"registers",
"it",
"at",
"this",
"module",
"."
] | f89911551f18357720034fbaa52837a0d09f66ea | https://github.com/SpockBotMC/SpockBot/blob/f89911551f18357720034fbaa52837a0d09f66ea/spockbot/mcdata/windows.py#L330-L371 |
42,467 | SpockBotMC/SpockBot | spockbot/mcdata/windows.py | Slot.get_dict | def get_dict(self):
""" Formats the slot for network packing. """
data = {'id': self.item_id}
if self.item_id != constants.INV_ITEMID_EMPTY:
data['damage'] = self.damage
data['amount'] = self.amount
if self.nbt is not None:
data['enchants'] = s... | python | def get_dict(self):
""" Formats the slot for network packing. """
data = {'id': self.item_id}
if self.item_id != constants.INV_ITEMID_EMPTY:
data['damage'] = self.damage
data['amount'] = self.amount
if self.nbt is not None:
data['enchants'] = s... | [
"def",
"get_dict",
"(",
"self",
")",
":",
"data",
"=",
"{",
"'id'",
":",
"self",
".",
"item_id",
"}",
"if",
"self",
".",
"item_id",
"!=",
"constants",
".",
"INV_ITEMID_EMPTY",
":",
"data",
"[",
"'damage'",
"]",
"=",
"self",
".",
"damage",
"data",
"["... | Formats the slot for network packing. | [
"Formats",
"the",
"slot",
"for",
"network",
"packing",
"."
] | f89911551f18357720034fbaa52837a0d09f66ea | https://github.com/SpockBotMC/SpockBot/blob/f89911551f18357720034fbaa52837a0d09f66ea/spockbot/mcdata/windows.py#L75-L83 |
42,468 | SpockBotMC/SpockBot | spockbot/mcdata/windows.py | BaseClick.on_success | def on_success(self, inv_plugin, emit_set_slot):
"""
Called when the click was successful
and should be applied to the inventory.
Args:
inv_plugin (InventoryPlugin): inventory plugin instance
emit_set_slot (func): function to signal a slot change,
... | python | def on_success(self, inv_plugin, emit_set_slot):
"""
Called when the click was successful
and should be applied to the inventory.
Args:
inv_plugin (InventoryPlugin): inventory plugin instance
emit_set_slot (func): function to signal a slot change,
... | [
"def",
"on_success",
"(",
"self",
",",
"inv_plugin",
",",
"emit_set_slot",
")",
":",
"self",
".",
"dirty",
"=",
"set",
"(",
")",
"self",
".",
"apply",
"(",
"inv_plugin",
")",
"for",
"changed_slot",
"in",
"self",
".",
"dirty",
":",
"emit_set_slot",
"(",
... | Called when the click was successful
and should be applied to the inventory.
Args:
inv_plugin (InventoryPlugin): inventory plugin instance
emit_set_slot (func): function to signal a slot change,
should be InventoryPlugin().emit_set_slot | [
"Called",
"when",
"the",
"click",
"was",
"successful",
"and",
"should",
"be",
"applied",
"to",
"the",
"inventory",
"."
] | f89911551f18357720034fbaa52837a0d09f66ea | https://github.com/SpockBotMC/SpockBot/blob/f89911551f18357720034fbaa52837a0d09f66ea/spockbot/mcdata/windows.py#L141-L154 |
42,469 | SpockBotMC/SpockBot | spockbot/mcp/yggdrasil.py | YggdrasilCore.authenticate | def authenticate(self):
"""
Generate an access token using an username and password. Any existing
client token is invalidated if not provided.
Returns:
dict: Response or error dict
"""
endpoint = '/authenticate'
payload = {
'agent': {
... | python | def authenticate(self):
"""
Generate an access token using an username and password. Any existing
client token is invalidated if not provided.
Returns:
dict: Response or error dict
"""
endpoint = '/authenticate'
payload = {
'agent': {
... | [
"def",
"authenticate",
"(",
"self",
")",
":",
"endpoint",
"=",
"'/authenticate'",
"payload",
"=",
"{",
"'agent'",
":",
"{",
"'name'",
":",
"'Minecraft'",
",",
"'version'",
":",
"self",
".",
"ygg_version",
",",
"}",
",",
"'username'",
":",
"self",
".",
"u... | Generate an access token using an username and password. Any existing
client token is invalidated if not provided.
Returns:
dict: Response or error dict | [
"Generate",
"an",
"access",
"token",
"using",
"an",
"username",
"and",
"password",
".",
"Any",
"existing",
"client",
"token",
"is",
"invalidated",
"if",
"not",
"provided",
"."
] | f89911551f18357720034fbaa52837a0d09f66ea | https://github.com/SpockBotMC/SpockBot/blob/f89911551f18357720034fbaa52837a0d09f66ea/spockbot/mcp/yggdrasil.py#L50-L76 |
42,470 | SpockBotMC/SpockBot | spockbot/mcp/yggdrasil.py | YggdrasilCore.validate | def validate(self):
"""
Check if an access token is valid
Returns:
dict: Empty or error dict
"""
endpoint = '/validate'
payload = dict(accessToken=self.access_token)
rep = self._ygg_req(endpoint, payload)
return not bool(rep) | python | def validate(self):
"""
Check if an access token is valid
Returns:
dict: Empty or error dict
"""
endpoint = '/validate'
payload = dict(accessToken=self.access_token)
rep = self._ygg_req(endpoint, payload)
return not bool(rep) | [
"def",
"validate",
"(",
"self",
")",
":",
"endpoint",
"=",
"'/validate'",
"payload",
"=",
"dict",
"(",
"accessToken",
"=",
"self",
".",
"access_token",
")",
"rep",
"=",
"self",
".",
"_ygg_req",
"(",
"endpoint",
",",
"payload",
")",
"return",
"not",
"bool... | Check if an access token is valid
Returns:
dict: Empty or error dict | [
"Check",
"if",
"an",
"access",
"token",
"is",
"valid"
] | f89911551f18357720034fbaa52837a0d09f66ea | https://github.com/SpockBotMC/SpockBot/blob/f89911551f18357720034fbaa52837a0d09f66ea/spockbot/mcp/yggdrasil.py#L143-L154 |
42,471 | SpockBotMC/SpockBot | spockbot/plugins/helpers/inventory.py | InventoryCore.total_stored | def total_stored(self, wanted, slots=None):
"""
Calculates the total number of items of that type
in the current window or given slot range.
Args:
wanted: function(Slot) or Slot or itemID or (itemID, metadata)
"""
if slots is None:
slots = self.wi... | python | def total_stored(self, wanted, slots=None):
"""
Calculates the total number of items of that type
in the current window or given slot range.
Args:
wanted: function(Slot) or Slot or itemID or (itemID, metadata)
"""
if slots is None:
slots = self.wi... | [
"def",
"total_stored",
"(",
"self",
",",
"wanted",
",",
"slots",
"=",
"None",
")",
":",
"if",
"slots",
"is",
"None",
":",
"slots",
"=",
"self",
".",
"window",
".",
"slots",
"wanted",
"=",
"make_slot_check",
"(",
"wanted",
")",
"return",
"sum",
"(",
"... | Calculates the total number of items of that type
in the current window or given slot range.
Args:
wanted: function(Slot) or Slot or itemID or (itemID, metadata) | [
"Calculates",
"the",
"total",
"number",
"of",
"items",
"of",
"that",
"type",
"in",
"the",
"current",
"window",
"or",
"given",
"slot",
"range",
"."
] | f89911551f18357720034fbaa52837a0d09f66ea | https://github.com/SpockBotMC/SpockBot/blob/f89911551f18357720034fbaa52837a0d09f66ea/spockbot/plugins/helpers/inventory.py#L24-L35 |
42,472 | SpockBotMC/SpockBot | spockbot/plugins/helpers/inventory.py | InventoryCore.find_slot | def find_slot(self, wanted, slots=None):
"""
Searches the given slots or, if not given,
active hotbar slot, hotbar, inventory, open window in this order.
Args:
wanted: function(Slot) or Slot or itemID or (itemID, metadata)
Returns:
Optional[Slot]: The fi... | python | def find_slot(self, wanted, slots=None):
"""
Searches the given slots or, if not given,
active hotbar slot, hotbar, inventory, open window in this order.
Args:
wanted: function(Slot) or Slot or itemID or (itemID, metadata)
Returns:
Optional[Slot]: The fi... | [
"def",
"find_slot",
"(",
"self",
",",
"wanted",
",",
"slots",
"=",
"None",
")",
":",
"for",
"slot",
"in",
"self",
".",
"find_slots",
"(",
"wanted",
",",
"slots",
")",
":",
"return",
"slot",
"return",
"None"
] | Searches the given slots or, if not given,
active hotbar slot, hotbar, inventory, open window in this order.
Args:
wanted: function(Slot) or Slot or itemID or (itemID, metadata)
Returns:
Optional[Slot]: The first slot containing the item
or N... | [
"Searches",
"the",
"given",
"slots",
"or",
"if",
"not",
"given",
"active",
"hotbar",
"slot",
"hotbar",
"inventory",
"open",
"window",
"in",
"this",
"order",
"."
] | f89911551f18357720034fbaa52837a0d09f66ea | https://github.com/SpockBotMC/SpockBot/blob/f89911551f18357720034fbaa52837a0d09f66ea/spockbot/plugins/helpers/inventory.py#L37-L51 |
42,473 | SpockBotMC/SpockBot | spockbot/plugins/helpers/inventory.py | InventoryCore.find_slots | def find_slots(self, wanted, slots=None):
"""
Yields all slots containing the item.
Searches the given slots or, if not given,
active hotbar slot, hotbar, inventory, open window in this order.
Args:
wanted: function(Slot) or Slot or itemID or (itemID, metadata)
... | python | def find_slots(self, wanted, slots=None):
"""
Yields all slots containing the item.
Searches the given slots or, if not given,
active hotbar slot, hotbar, inventory, open window in this order.
Args:
wanted: function(Slot) or Slot or itemID or (itemID, metadata)
... | [
"def",
"find_slots",
"(",
"self",
",",
"wanted",
",",
"slots",
"=",
"None",
")",
":",
"if",
"slots",
"is",
"None",
":",
"slots",
"=",
"self",
".",
"inv_slots_preferred",
"+",
"self",
".",
"window",
".",
"window_slots",
"wanted",
"=",
"make_slot_check",
"... | Yields all slots containing the item.
Searches the given slots or, if not given,
active hotbar slot, hotbar, inventory, open window in this order.
Args:
wanted: function(Slot) or Slot or itemID or (itemID, metadata) | [
"Yields",
"all",
"slots",
"containing",
"the",
"item",
".",
"Searches",
"the",
"given",
"slots",
"or",
"if",
"not",
"given",
"active",
"hotbar",
"slot",
"hotbar",
"inventory",
"open",
"window",
"in",
"this",
"order",
"."
] | f89911551f18357720034fbaa52837a0d09f66ea | https://github.com/SpockBotMC/SpockBot/blob/f89911551f18357720034fbaa52837a0d09f66ea/spockbot/plugins/helpers/inventory.py#L53-L68 |
42,474 | SpockBotMC/SpockBot | spockbot/plugins/helpers/inventory.py | InventoryCore.click_slot | def click_slot(self, slot, right=False):
"""
Left-click or right-click the slot.
Args:
slot (Slot): The clicked slot. Can be ``Slot`` instance or integer.
Set to ``inventory.cursor_slot``
for clicking outside the window.
"""
... | python | def click_slot(self, slot, right=False):
"""
Left-click or right-click the slot.
Args:
slot (Slot): The clicked slot. Can be ``Slot`` instance or integer.
Set to ``inventory.cursor_slot``
for clicking outside the window.
"""
... | [
"def",
"click_slot",
"(",
"self",
",",
"slot",
",",
"right",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"slot",
",",
"int",
")",
":",
"slot",
"=",
"self",
".",
"window",
".",
"slots",
"[",
"slot",
"]",
"button",
"=",
"constants",
".",
"INV_BU... | Left-click or right-click the slot.
Args:
slot (Slot): The clicked slot. Can be ``Slot`` instance or integer.
Set to ``inventory.cursor_slot``
for clicking outside the window. | [
"Left",
"-",
"click",
"or",
"right",
"-",
"click",
"the",
"slot",
"."
] | f89911551f18357720034fbaa52837a0d09f66ea | https://github.com/SpockBotMC/SpockBot/blob/f89911551f18357720034fbaa52837a0d09f66ea/spockbot/plugins/helpers/inventory.py#L83-L96 |
42,475 | SpockBotMC/SpockBot | spockbot/plugins/helpers/inventory.py | InventoryCore.drop_slot | def drop_slot(self, slot=None, drop_stack=False):
"""
Drop one or all items of the slot.
Does not wait for confirmation from the server. If you want that,
use a ``Task`` and ``yield inventory.async.drop_slot()`` instead.
If ``slot`` is None, drops the ``cursor_slot`` or, if tha... | python | def drop_slot(self, slot=None, drop_stack=False):
"""
Drop one or all items of the slot.
Does not wait for confirmation from the server. If you want that,
use a ``Task`` and ``yield inventory.async.drop_slot()`` instead.
If ``slot`` is None, drops the ``cursor_slot`` or, if tha... | [
"def",
"drop_slot",
"(",
"self",
",",
"slot",
"=",
"None",
",",
"drop_stack",
"=",
"False",
")",
":",
"if",
"slot",
"is",
"None",
":",
"if",
"self",
".",
"cursor_slot",
".",
"is_empty",
":",
"slot",
"=",
"self",
".",
"active_slot",
"else",
":",
"slot... | Drop one or all items of the slot.
Does not wait for confirmation from the server. If you want that,
use a ``Task`` and ``yield inventory.async.drop_slot()`` instead.
If ``slot`` is None, drops the ``cursor_slot`` or, if that's empty,
the currently held item (``active_slot``).
... | [
"Drop",
"one",
"or",
"all",
"items",
"of",
"the",
"slot",
"."
] | f89911551f18357720034fbaa52837a0d09f66ea | https://github.com/SpockBotMC/SpockBot/blob/f89911551f18357720034fbaa52837a0d09f66ea/spockbot/plugins/helpers/inventory.py#L98-L125 |
42,476 | SpockBotMC/SpockBot | spockbot/plugins/helpers/inventory.py | InventoryCore.inv_slots_preferred | def inv_slots_preferred(self):
"""
List of all available inventory slots in the preferred search order.
Does not include the additional slots from the open window.
1. active slot
2. remainder of the hotbar
3. remainder of the persistent inventory
"""
slot... | python | def inv_slots_preferred(self):
"""
List of all available inventory slots in the preferred search order.
Does not include the additional slots from the open window.
1. active slot
2. remainder of the hotbar
3. remainder of the persistent inventory
"""
slot... | [
"def",
"inv_slots_preferred",
"(",
"self",
")",
":",
"slots",
"=",
"[",
"self",
".",
"active_slot",
"]",
"slots",
".",
"extend",
"(",
"slot",
"for",
"slot",
"in",
"self",
".",
"window",
".",
"hotbar_slots",
"if",
"slot",
"!=",
"self",
".",
"active_slot",... | List of all available inventory slots in the preferred search order.
Does not include the additional slots from the open window.
1. active slot
2. remainder of the hotbar
3. remainder of the persistent inventory | [
"List",
"of",
"all",
"available",
"inventory",
"slots",
"in",
"the",
"preferred",
"search",
"order",
".",
"Does",
"not",
"include",
"the",
"additional",
"slots",
"from",
"the",
"open",
"window",
"."
] | f89911551f18357720034fbaa52837a0d09f66ea | https://github.com/SpockBotMC/SpockBot/blob/f89911551f18357720034fbaa52837a0d09f66ea/spockbot/plugins/helpers/inventory.py#L145-L158 |
42,477 | SpockBotMC/SpockBot | spockbot/plugins/tools/smpmap.py | Dimension.get_block_entity_data | def get_block_entity_data(self, pos_or_x, y=None, z=None):
"""
Access block entity data.
Returns:
BlockEntityData subclass instance or
None if no block entity data is stored for that location.
"""
if None not in (y, z): # x y z supplied
pos_o... | python | def get_block_entity_data(self, pos_or_x, y=None, z=None):
"""
Access block entity data.
Returns:
BlockEntityData subclass instance or
None if no block entity data is stored for that location.
"""
if None not in (y, z): # x y z supplied
pos_o... | [
"def",
"get_block_entity_data",
"(",
"self",
",",
"pos_or_x",
",",
"y",
"=",
"None",
",",
"z",
"=",
"None",
")",
":",
"if",
"None",
"not",
"in",
"(",
"y",
",",
"z",
")",
":",
"# x y z supplied",
"pos_or_x",
"=",
"pos_or_x",
",",
"y",
",",
"z",
"coo... | Access block entity data.
Returns:
BlockEntityData subclass instance or
None if no block entity data is stored for that location. | [
"Access",
"block",
"entity",
"data",
"."
] | f89911551f18357720034fbaa52837a0d09f66ea | https://github.com/SpockBotMC/SpockBot/blob/f89911551f18357720034fbaa52837a0d09f66ea/spockbot/plugins/tools/smpmap.py#L302-L313 |
42,478 | SpockBotMC/SpockBot | spockbot/plugins/tools/smpmap.py | Dimension.set_block_entity_data | def set_block_entity_data(self, pos_or_x, y=None, z=None, data=None):
"""
Update block entity data.
Returns:
Old data if block entity data was already stored for that location,
None otherwise.
"""
if None not in (y, z): # x y z supplied
pos_o... | python | def set_block_entity_data(self, pos_or_x, y=None, z=None, data=None):
"""
Update block entity data.
Returns:
Old data if block entity data was already stored for that location,
None otherwise.
"""
if None not in (y, z): # x y z supplied
pos_o... | [
"def",
"set_block_entity_data",
"(",
"self",
",",
"pos_or_x",
",",
"y",
"=",
"None",
",",
"z",
"=",
"None",
",",
"data",
"=",
"None",
")",
":",
"if",
"None",
"not",
"in",
"(",
"y",
",",
"z",
")",
":",
"# x y z supplied",
"pos_or_x",
"=",
"pos_or_x",
... | Update block entity data.
Returns:
Old data if block entity data was already stored for that location,
None otherwise. | [
"Update",
"block",
"entity",
"data",
"."
] | f89911551f18357720034fbaa52837a0d09f66ea | https://github.com/SpockBotMC/SpockBot/blob/f89911551f18357720034fbaa52837a0d09f66ea/spockbot/plugins/tools/smpmap.py#L315-L328 |
42,479 | mattrobenolt/python-sourcemap | sourcemap/decoder.py | SourceMapDecoder.parse_vlq | def parse_vlq(self, segment):
"""
Parse a string of VLQ-encoded data.
Returns:
a list of integers.
"""
values = []
cur, shift = 0, 0
for c in segment:
val = B64[ord(c)]
# Each character is 6 bits:
# 5 of value and t... | python | def parse_vlq(self, segment):
"""
Parse a string of VLQ-encoded data.
Returns:
a list of integers.
"""
values = []
cur, shift = 0, 0
for c in segment:
val = B64[ord(c)]
# Each character is 6 bits:
# 5 of value and t... | [
"def",
"parse_vlq",
"(",
"self",
",",
"segment",
")",
":",
"values",
"=",
"[",
"]",
"cur",
",",
"shift",
"=",
"0",
",",
"0",
"for",
"c",
"in",
"segment",
":",
"val",
"=",
"B64",
"[",
"ord",
"(",
"c",
")",
"]",
"# Each character is 6 bits:",
"# 5 of... | Parse a string of VLQ-encoded data.
Returns:
a list of integers. | [
"Parse",
"a",
"string",
"of",
"VLQ",
"-",
"encoded",
"data",
"."
] | 8d6969a3ce2c6b139c6e81927beed58ae67e840b | https://github.com/mattrobenolt/python-sourcemap/blob/8d6969a3ce2c6b139c6e81927beed58ae67e840b/sourcemap/decoder.py#L33-L63 |
42,480 | mattrobenolt/python-sourcemap | sourcemap/decoder.py | SourceMapDecoder.decode | def decode(self, source):
"""Decode a source map object into a SourceMapIndex.
The index is keyed on (dst_line, dst_column) for lookups,
and a per row index is kept to help calculate which Token to retrieve.
For example:
A minified source file has two rows and two tokens pe... | python | def decode(self, source):
"""Decode a source map object into a SourceMapIndex.
The index is keyed on (dst_line, dst_column) for lookups,
and a per row index is kept to help calculate which Token to retrieve.
For example:
A minified source file has two rows and two tokens pe... | [
"def",
"decode",
"(",
"self",
",",
"source",
")",
":",
"# According to spec (https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit#heading=h.h7yy76c5il9v)",
"# A SouceMap may be prepended with \")]}'\" to cause a Javascript error.",
"# If the file starts with that ... | Decode a source map object into a SourceMapIndex.
The index is keyed on (dst_line, dst_column) for lookups,
and a per row index is kept to help calculate which Token to retrieve.
For example:
A minified source file has two rows and two tokens per row.
# All parsed toke... | [
"Decode",
"a",
"source",
"map",
"object",
"into",
"a",
"SourceMapIndex",
"."
] | 8d6969a3ce2c6b139c6e81927beed58ae67e840b | https://github.com/mattrobenolt/python-sourcemap/blob/8d6969a3ce2c6b139c6e81927beed58ae67e840b/sourcemap/decoder.py#L65-L195 |
42,481 | mattrobenolt/python-sourcemap | sourcemap/__init__.py | discover | def discover(source):
"Given a JavaScript file, find the sourceMappingURL line"
source = source.splitlines()
# Source maps are only going to exist at either the top or bottom of the document.
# Technically, there isn't anything indicating *where* it should exist, so we
# are generous and assume it's... | python | def discover(source):
"Given a JavaScript file, find the sourceMappingURL line"
source = source.splitlines()
# Source maps are only going to exist at either the top or bottom of the document.
# Technically, there isn't anything indicating *where* it should exist, so we
# are generous and assume it's... | [
"def",
"discover",
"(",
"source",
")",
":",
"source",
"=",
"source",
".",
"splitlines",
"(",
")",
"# Source maps are only going to exist at either the top or bottom of the document.",
"# Technically, there isn't anything indicating *where* it should exist, so we",
"# are generous and a... | Given a JavaScript file, find the sourceMappingURL line | [
"Given",
"a",
"JavaScript",
"file",
"find",
"the",
"sourceMappingURL",
"line"
] | 8d6969a3ce2c6b139c6e81927beed58ae67e840b | https://github.com/mattrobenolt/python-sourcemap/blob/8d6969a3ce2c6b139c6e81927beed58ae67e840b/sourcemap/__init__.py#L25-L43 |
42,482 | cournape/audiolab | pavement.py | clean | def clean():
"""Remove build, dist, egg-info garbage."""
d = ['build', 'dist', 'scikits.audiolab.egg-info', HTML_DESTDIR,
PDF_DESTDIR]
for i in d:
paver.path.path(i).rmtree()
(paver.path.path('docs') / options.sphinx.builddir).rmtree() | python | def clean():
"""Remove build, dist, egg-info garbage."""
d = ['build', 'dist', 'scikits.audiolab.egg-info', HTML_DESTDIR,
PDF_DESTDIR]
for i in d:
paver.path.path(i).rmtree()
(paver.path.path('docs') / options.sphinx.builddir).rmtree() | [
"def",
"clean",
"(",
")",
":",
"d",
"=",
"[",
"'build'",
",",
"'dist'",
",",
"'scikits.audiolab.egg-info'",
",",
"HTML_DESTDIR",
",",
"PDF_DESTDIR",
"]",
"for",
"i",
"in",
"d",
":",
"paver",
".",
"path",
".",
"path",
"(",
"i",
")",
".",
"rmtree",
"("... | Remove build, dist, egg-info garbage. | [
"Remove",
"build",
"dist",
"egg",
"-",
"info",
"garbage",
"."
] | e4918832c1e52b56428c5f3535ddeb9d9daff9ac | https://github.com/cournape/audiolab/blob/e4918832c1e52b56428c5f3535ddeb9d9daff9ac/pavement.py#L96-L103 |
42,483 | linkedin/pyexchange | pyexchange/base/calendar.py | BaseExchangeCalendarEvent.add_attendees | def add_attendees(self, attendees, required=True):
"""
Adds new attendees to the event.
*attendees* can be a list of email addresses or :class:`ExchangeEventAttendee` objects.
"""
new_attendees = self._build_resource_dictionary(attendees, required=required)
for email in new_attendees:
s... | python | def add_attendees(self, attendees, required=True):
"""
Adds new attendees to the event.
*attendees* can be a list of email addresses or :class:`ExchangeEventAttendee` objects.
"""
new_attendees = self._build_resource_dictionary(attendees, required=required)
for email in new_attendees:
s... | [
"def",
"add_attendees",
"(",
"self",
",",
"attendees",
",",
"required",
"=",
"True",
")",
":",
"new_attendees",
"=",
"self",
".",
"_build_resource_dictionary",
"(",
"attendees",
",",
"required",
"=",
"required",
")",
"for",
"email",
"in",
"new_attendees",
":",... | Adds new attendees to the event.
*attendees* can be a list of email addresses or :class:`ExchangeEventAttendee` objects. | [
"Adds",
"new",
"attendees",
"to",
"the",
"event",
"."
] | d568f4edd326adb451b915ddf66cf1a37820e3ca | https://github.com/linkedin/pyexchange/blob/d568f4edd326adb451b915ddf66cf1a37820e3ca/pyexchange/base/calendar.py#L230-L242 |
42,484 | linkedin/pyexchange | pyexchange/base/calendar.py | BaseExchangeCalendarEvent.remove_attendees | def remove_attendees(self, attendees):
"""
Removes attendees from the event.
*attendees* can be a list of email addresses or :class:`ExchangeEventAttendee` objects.
"""
attendees_to_delete = self._build_resource_dictionary(attendees)
for email in attendees_to_delete.keys():
if email in s... | python | def remove_attendees(self, attendees):
"""
Removes attendees from the event.
*attendees* can be a list of email addresses or :class:`ExchangeEventAttendee` objects.
"""
attendees_to_delete = self._build_resource_dictionary(attendees)
for email in attendees_to_delete.keys():
if email in s... | [
"def",
"remove_attendees",
"(",
"self",
",",
"attendees",
")",
":",
"attendees_to_delete",
"=",
"self",
".",
"_build_resource_dictionary",
"(",
"attendees",
")",
"for",
"email",
"in",
"attendees_to_delete",
".",
"keys",
"(",
")",
":",
"if",
"email",
"in",
"sel... | Removes attendees from the event.
*attendees* can be a list of email addresses or :class:`ExchangeEventAttendee` objects. | [
"Removes",
"attendees",
"from",
"the",
"event",
"."
] | d568f4edd326adb451b915ddf66cf1a37820e3ca | https://github.com/linkedin/pyexchange/blob/d568f4edd326adb451b915ddf66cf1a37820e3ca/pyexchange/base/calendar.py#L244-L256 |
42,485 | linkedin/pyexchange | pyexchange/base/calendar.py | BaseExchangeCalendarEvent.add_resources | def add_resources(self, resources):
"""
Adds new resources to the event.
*resources* can be a list of email addresses or :class:`ExchangeEventAttendee` objects.
"""
new_resources = self._build_resource_dictionary(resources)
for key in new_resources:
self._resources[key] = new_resources[k... | python | def add_resources(self, resources):
"""
Adds new resources to the event.
*resources* can be a list of email addresses or :class:`ExchangeEventAttendee` objects.
"""
new_resources = self._build_resource_dictionary(resources)
for key in new_resources:
self._resources[key] = new_resources[k... | [
"def",
"add_resources",
"(",
"self",
",",
"resources",
")",
":",
"new_resources",
"=",
"self",
".",
"_build_resource_dictionary",
"(",
"resources",
")",
"for",
"key",
"in",
"new_resources",
":",
"self",
".",
"_resources",
"[",
"key",
"]",
"=",
"new_resources",... | Adds new resources to the event.
*resources* can be a list of email addresses or :class:`ExchangeEventAttendee` objects. | [
"Adds",
"new",
"resources",
"to",
"the",
"event",
"."
] | d568f4edd326adb451b915ddf66cf1a37820e3ca | https://github.com/linkedin/pyexchange/blob/d568f4edd326adb451b915ddf66cf1a37820e3ca/pyexchange/base/calendar.py#L273-L283 |
42,486 | linkedin/pyexchange | pyexchange/base/calendar.py | BaseExchangeCalendarEvent.remove_resources | def remove_resources(self, resources):
"""
Removes resources from the event.
*resources* can be a list of email addresses or :class:`ExchangeEventAttendee` objects.
"""
resources_to_delete = self._build_resource_dictionary(resources)
for email in resources_to_delete.keys():
if email in s... | python | def remove_resources(self, resources):
"""
Removes resources from the event.
*resources* can be a list of email addresses or :class:`ExchangeEventAttendee` objects.
"""
resources_to_delete = self._build_resource_dictionary(resources)
for email in resources_to_delete.keys():
if email in s... | [
"def",
"remove_resources",
"(",
"self",
",",
"resources",
")",
":",
"resources_to_delete",
"=",
"self",
".",
"_build_resource_dictionary",
"(",
"resources",
")",
"for",
"email",
"in",
"resources_to_delete",
".",
"keys",
"(",
")",
":",
"if",
"email",
"in",
"sel... | Removes resources from the event.
*resources* can be a list of email addresses or :class:`ExchangeEventAttendee` objects. | [
"Removes",
"resources",
"from",
"the",
"event",
"."
] | d568f4edd326adb451b915ddf66cf1a37820e3ca | https://github.com/linkedin/pyexchange/blob/d568f4edd326adb451b915ddf66cf1a37820e3ca/pyexchange/base/calendar.py#L285-L297 |
42,487 | linkedin/pyexchange | pyexchange/base/calendar.py | BaseExchangeCalendarEvent.validate | def validate(self):
""" Validates that all required fields are present """
if not self.start:
raise ValueError("Event has no start date")
if not self.end:
raise ValueError("Event has no end date")
if self.end < self.start:
raise ValueError("Start date is after end date")
if self... | python | def validate(self):
""" Validates that all required fields are present """
if not self.start:
raise ValueError("Event has no start date")
if not self.end:
raise ValueError("Event has no end date")
if self.end < self.start:
raise ValueError("Start date is after end date")
if self... | [
"def",
"validate",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"start",
":",
"raise",
"ValueError",
"(",
"\"Event has no start date\"",
")",
"if",
"not",
"self",
".",
"end",
":",
"raise",
"ValueError",
"(",
"\"Event has no end date\"",
")",
"if",
"self"... | Validates that all required fields are present | [
"Validates",
"that",
"all",
"required",
"fields",
"are",
"present"
] | d568f4edd326adb451b915ddf66cf1a37820e3ca | https://github.com/linkedin/pyexchange/blob/d568f4edd326adb451b915ddf66cf1a37820e3ca/pyexchange/base/calendar.py#L305-L320 |
42,488 | cournape/audiolab | audiolab/soundio/setuphelp.py | info_factory | def info_factory(name, libnames, headers, frameworks=None,
section=None, classname=None):
"""Create a system_info class.
Parameters
----------
name : str
name of the library
libnames : seq
list of libraries to look for
headers : seq
... | python | def info_factory(name, libnames, headers, frameworks=None,
section=None, classname=None):
"""Create a system_info class.
Parameters
----------
name : str
name of the library
libnames : seq
list of libraries to look for
headers : seq
... | [
"def",
"info_factory",
"(",
"name",
",",
"libnames",
",",
"headers",
",",
"frameworks",
"=",
"None",
",",
"section",
"=",
"None",
",",
"classname",
"=",
"None",
")",
":",
"if",
"not",
"classname",
":",
"classname",
"=",
"'%s_info'",
"%",
"name",
"if",
... | Create a system_info class.
Parameters
----------
name : str
name of the library
libnames : seq
list of libraries to look for
headers : seq
list of headers to look for
classname : str
name of the returned class
section : st... | [
"Create",
"a",
"system_info",
"class",
"."
] | e4918832c1e52b56428c5f3535ddeb9d9daff9ac | https://github.com/cournape/audiolab/blob/e4918832c1e52b56428c5f3535ddeb9d9daff9ac/audiolab/soundio/setuphelp.py#L6-L88 |
42,489 | linkedin/pyexchange | pyexchange/exchange2010/__init__.py | Exchange2010CalendarEventList.load_all_details | def load_all_details(self):
"""
This function will execute all the event lookups for known events.
This is intended for use when you want to have a completely populated event entry, including
Organizer & Attendee details.
"""
log.debug(u"Loading all details")
if self.count > 0:
# Now,... | python | def load_all_details(self):
"""
This function will execute all the event lookups for known events.
This is intended for use when you want to have a completely populated event entry, including
Organizer & Attendee details.
"""
log.debug(u"Loading all details")
if self.count > 0:
# Now,... | [
"def",
"load_all_details",
"(",
"self",
")",
":",
"log",
".",
"debug",
"(",
"u\"Loading all details\"",
")",
"if",
"self",
".",
"count",
">",
"0",
":",
"# Now, empty out the events to prevent duplicates!",
"del",
"(",
"self",
".",
"events",
"[",
":",
"]",
")",... | This function will execute all the event lookups for known events.
This is intended for use when you want to have a completely populated event entry, including
Organizer & Attendee details. | [
"This",
"function",
"will",
"execute",
"all",
"the",
"event",
"lookups",
"for",
"known",
"events",
"."
] | d568f4edd326adb451b915ddf66cf1a37820e3ca | https://github.com/linkedin/pyexchange/blob/d568f4edd326adb451b915ddf66cf1a37820e3ca/pyexchange/exchange2010/__init__.py#L154-L174 |
42,490 | cournape/audiolab | audiolab/pysndfile/compat.py | sndfile.seek | def seek(self, offset, whence=0, mode='rw'):
"""similar to python seek function, taking only in account audio data.
:Parameters:
offset : int
the number of frames (eg two samples for stereo files) to move
relatively to position set by whence.
when... | python | def seek(self, offset, whence=0, mode='rw'):
"""similar to python seek function, taking only in account audio data.
:Parameters:
offset : int
the number of frames (eg two samples for stereo files) to move
relatively to position set by whence.
when... | [
"def",
"seek",
"(",
"self",
",",
"offset",
",",
"whence",
"=",
"0",
",",
"mode",
"=",
"'rw'",
")",
":",
"try",
":",
"st",
"=",
"self",
".",
"_sndfile",
".",
"seek",
"(",
"offset",
",",
"whence",
",",
"mode",
")",
"except",
"IOError",
",",
"e",
... | similar to python seek function, taking only in account audio data.
:Parameters:
offset : int
the number of frames (eg two samples for stereo files) to move
relatively to position set by whence.
whence : int
only 0 (beginning), 1 (current)... | [
"similar",
"to",
"python",
"seek",
"function",
"taking",
"only",
"in",
"account",
"audio",
"data",
"."
] | e4918832c1e52b56428c5f3535ddeb9d9daff9ac | https://github.com/cournape/audiolab/blob/e4918832c1e52b56428c5f3535ddeb9d9daff9ac/audiolab/pysndfile/compat.py#L125-L151 |
42,491 | cournape/audiolab | audiolab/pysndfile/compat.py | sndfile.read_frames | def read_frames(self, nframes, dtype=np.float64):
"""Read nframes frames of the file.
:Parameters:
nframes : int
number of frames to read.
dtype : numpy dtype
dtype of the returned array containing read data (see note).
Notes
----... | python | def read_frames(self, nframes, dtype=np.float64):
"""Read nframes frames of the file.
:Parameters:
nframes : int
number of frames to read.
dtype : numpy dtype
dtype of the returned array containing read data (see note).
Notes
----... | [
"def",
"read_frames",
"(",
"self",
",",
"nframes",
",",
"dtype",
"=",
"np",
".",
"float64",
")",
":",
"return",
"self",
".",
"_sndfile",
".",
"read_frames",
"(",
"nframes",
",",
"dtype",
")"
] | Read nframes frames of the file.
:Parameters:
nframes : int
number of frames to read.
dtype : numpy dtype
dtype of the returned array containing read data (see note).
Notes
-----
- read_frames updates the read pointer.
- ... | [
"Read",
"nframes",
"frames",
"of",
"the",
"file",
"."
] | e4918832c1e52b56428c5f3535ddeb9d9daff9ac | https://github.com/cournape/audiolab/blob/e4918832c1e52b56428c5f3535ddeb9d9daff9ac/audiolab/pysndfile/compat.py#L181-L203 |
42,492 | cournape/audiolab | audiolab/pysndfile/compat.py | sndfile.write_frames | def write_frames(self, input, nframes = -1):
"""write data to file.
:Parameters:
input : ndarray
array containing data to write.
nframes : int
number of frames to write.
Notes
-----
- One column is one channel (one row pe... | python | def write_frames(self, input, nframes = -1):
"""write data to file.
:Parameters:
input : ndarray
array containing data to write.
nframes : int
number of frames to write.
Notes
-----
- One column is one channel (one row pe... | [
"def",
"write_frames",
"(",
"self",
",",
"input",
",",
"nframes",
"=",
"-",
"1",
")",
":",
"if",
"nframes",
"==",
"-",
"1",
":",
"if",
"input",
".",
"ndim",
"==",
"1",
":",
"nframes",
"=",
"input",
".",
"size",
"elif",
"input",
".",
"ndim",
"==",... | write data to file.
:Parameters:
input : ndarray
array containing data to write.
nframes : int
number of frames to write.
Notes
-----
- One column is one channel (one row per channel after 0.9)
- updates the write pointer... | [
"write",
"data",
"to",
"file",
"."
] | e4918832c1e52b56428c5f3535ddeb9d9daff9ac | https://github.com/cournape/audiolab/blob/e4918832c1e52b56428c5f3535ddeb9d9daff9ac/audiolab/pysndfile/compat.py#L209-L234 |
42,493 | linkedin/pyexchange | pyexchange/exchange2010/soap_request.py | delete_field | def delete_field(field_uri):
"""
Helper function to request deletion of a field. This is necessary when you want to overwrite values instead of
appending.
<t:DeleteItemField>
<t:FieldURI FieldURI="calendar:Resources"/>
</t:DeleteItemField>
"""
root = T.DeleteItemField(
T.Fiel... | python | def delete_field(field_uri):
"""
Helper function to request deletion of a field. This is necessary when you want to overwrite values instead of
appending.
<t:DeleteItemField>
<t:FieldURI FieldURI="calendar:Resources"/>
</t:DeleteItemField>
"""
root = T.DeleteItemField(
T.Fiel... | [
"def",
"delete_field",
"(",
"field_uri",
")",
":",
"root",
"=",
"T",
".",
"DeleteItemField",
"(",
"T",
".",
"FieldURI",
"(",
"FieldURI",
"=",
"field_uri",
")",
")",
"return",
"root"
] | Helper function to request deletion of a field. This is necessary when you want to overwrite values instead of
appending.
<t:DeleteItemField>
<t:FieldURI FieldURI="calendar:Resources"/>
</t:DeleteItemField> | [
"Helper",
"function",
"to",
"request",
"deletion",
"of",
"a",
"field",
".",
"This",
"is",
"necessary",
"when",
"you",
"want",
"to",
"overwrite",
"values",
"instead",
"of",
"appending",
"."
] | d568f4edd326adb451b915ddf66cf1a37820e3ca | https://github.com/linkedin/pyexchange/blob/d568f4edd326adb451b915ddf66cf1a37820e3ca/pyexchange/exchange2010/soap_request.py#L62-L76 |
42,494 | linkedin/pyexchange | pyexchange/exchange2010/soap_request.py | get_occurrence | def get_occurrence(exchange_id, instance_index, format=u"Default"):
"""
Requests one or more calendar items from the store matching the master & index.
exchange_id is the id for the master event in the Exchange store.
format controls how much data you get back from Exchange. Full docs are here, but acce... | python | def get_occurrence(exchange_id, instance_index, format=u"Default"):
"""
Requests one or more calendar items from the store matching the master & index.
exchange_id is the id for the master event in the Exchange store.
format controls how much data you get back from Exchange. Full docs are here, but acce... | [
"def",
"get_occurrence",
"(",
"exchange_id",
",",
"instance_index",
",",
"format",
"=",
"u\"Default\"",
")",
":",
"root",
"=",
"M",
".",
"GetItem",
"(",
"M",
".",
"ItemShape",
"(",
"T",
".",
"BaseShape",
"(",
"format",
")",
")",
",",
"M",
".",
"ItemIds... | Requests one or more calendar items from the store matching the master & index.
exchange_id is the id for the master event in the Exchange store.
format controls how much data you get back from Exchange. Full docs are here, but acceptible values
are IdOnly, Default, and AllProperties.
GetItem Doc:
... | [
"Requests",
"one",
"or",
"more",
"calendar",
"items",
"from",
"the",
"store",
"matching",
"the",
"master",
"&",
"index",
"."
] | d568f4edd326adb451b915ddf66cf1a37820e3ca | https://github.com/linkedin/pyexchange/blob/d568f4edd326adb451b915ddf66cf1a37820e3ca/pyexchange/exchange2010/soap_request.py#L186-L223 |
42,495 | linkedin/pyexchange | pyexchange/exchange2010/soap_request.py | new_event | def new_event(event):
"""
Requests a new event be created in the store.
http://msdn.microsoft.com/en-us/library/aa564690(v=exchg.140).aspx
<m:CreateItem SendMeetingInvitations="SendToAllAndSaveCopy"
xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:t="htt... | python | def new_event(event):
"""
Requests a new event be created in the store.
http://msdn.microsoft.com/en-us/library/aa564690(v=exchg.140).aspx
<m:CreateItem SendMeetingInvitations="SendToAllAndSaveCopy"
xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:t="htt... | [
"def",
"new_event",
"(",
"event",
")",
":",
"id",
"=",
"T",
".",
"DistinguishedFolderId",
"(",
"Id",
"=",
"event",
".",
"calendar_id",
")",
"if",
"event",
".",
"calendar_id",
"in",
"DISTINGUISHED_IDS",
"else",
"T",
".",
"FolderId",
"(",
"Id",
"=",
"event... | Requests a new event be created in the store.
http://msdn.microsoft.com/en-us/library/aa564690(v=exchg.140).aspx
<m:CreateItem SendMeetingInvitations="SendToAllAndSaveCopy"
xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:t="http://schemas.microsoft.com/exch... | [
"Requests",
"a",
"new",
"event",
"be",
"created",
"in",
"the",
"store",
"."
] | d568f4edd326adb451b915ddf66cf1a37820e3ca | https://github.com/linkedin/pyexchange/blob/d568f4edd326adb451b915ddf66cf1a37820e3ca/pyexchange/exchange2010/soap_request.py#L280-L406 |
42,496 | linkedin/pyexchange | pyexchange/exchange2010/soap_request.py | update_property_node | def update_property_node(node_to_insert, field_uri):
""" Helper function - generates a SetItemField which tells Exchange you want to overwrite the contents of a field."""
root = T.SetItemField(
T.FieldURI(FieldURI=field_uri),
T.CalendarItem(node_to_insert)
)
return root | python | def update_property_node(node_to_insert, field_uri):
""" Helper function - generates a SetItemField which tells Exchange you want to overwrite the contents of a field."""
root = T.SetItemField(
T.FieldURI(FieldURI=field_uri),
T.CalendarItem(node_to_insert)
)
return root | [
"def",
"update_property_node",
"(",
"node_to_insert",
",",
"field_uri",
")",
":",
"root",
"=",
"T",
".",
"SetItemField",
"(",
"T",
".",
"FieldURI",
"(",
"FieldURI",
"=",
"field_uri",
")",
",",
"T",
".",
"CalendarItem",
"(",
"node_to_insert",
")",
")",
"ret... | Helper function - generates a SetItemField which tells Exchange you want to overwrite the contents of a field. | [
"Helper",
"function",
"-",
"generates",
"a",
"SetItemField",
"which",
"tells",
"Exchange",
"you",
"want",
"to",
"overwrite",
"the",
"contents",
"of",
"a",
"field",
"."
] | d568f4edd326adb451b915ddf66cf1a37820e3ca | https://github.com/linkedin/pyexchange/blob/d568f4edd326adb451b915ddf66cf1a37820e3ca/pyexchange/exchange2010/soap_request.py#L465-L471 |
42,497 | hfaran/Tornado-JSON | tornado_json/api_doc_gen.py | _validate_example | def _validate_example(rh, method, example_type):
"""Validates example against schema
:returns: Formatted example if example exists and validates, otherwise None
:raises ValidationError: If example does not validate against the schema
"""
example = getattr(method, example_type + "_example")
sche... | python | def _validate_example(rh, method, example_type):
"""Validates example against schema
:returns: Formatted example if example exists and validates, otherwise None
:raises ValidationError: If example does not validate against the schema
"""
example = getattr(method, example_type + "_example")
sche... | [
"def",
"_validate_example",
"(",
"rh",
",",
"method",
",",
"example_type",
")",
":",
"example",
"=",
"getattr",
"(",
"method",
",",
"example_type",
"+",
"\"_example\"",
")",
"schema",
"=",
"getattr",
"(",
"method",
",",
"example_type",
"+",
"\"_schema\"",
")... | Validates example against schema
:returns: Formatted example if example exists and validates, otherwise None
:raises ValidationError: If example does not validate against the schema | [
"Validates",
"example",
"against",
"schema"
] | 8d8b35ff77f13cb3ab1a606bd2083b26cc69c54f | https://github.com/hfaran/Tornado-JSON/blob/8d8b35ff77f13cb3ab1a606bd2083b26cc69c54f/tornado_json/api_doc_gen.py#L18-L39 |
42,498 | hfaran/Tornado-JSON | tornado_json/api_doc_gen.py | _get_rh_methods | def _get_rh_methods(rh):
"""Yield all HTTP methods in ``rh`` that are decorated
with schema.validate"""
for k, v in vars(rh).items():
if all([
k in HTTP_METHODS,
is_method(v),
hasattr(v, "input_schema")
]):
yield (k, v) | python | def _get_rh_methods(rh):
"""Yield all HTTP methods in ``rh`` that are decorated
with schema.validate"""
for k, v in vars(rh).items():
if all([
k in HTTP_METHODS,
is_method(v),
hasattr(v, "input_schema")
]):
yield (k, v) | [
"def",
"_get_rh_methods",
"(",
"rh",
")",
":",
"for",
"k",
",",
"v",
"in",
"vars",
"(",
"rh",
")",
".",
"items",
"(",
")",
":",
"if",
"all",
"(",
"[",
"k",
"in",
"HTTP_METHODS",
",",
"is_method",
"(",
"v",
")",
",",
"hasattr",
"(",
"v",
",",
... | Yield all HTTP methods in ``rh`` that are decorated
with schema.validate | [
"Yield",
"all",
"HTTP",
"methods",
"in",
"rh",
"that",
"are",
"decorated",
"with",
"schema",
".",
"validate"
] | 8d8b35ff77f13cb3ab1a606bd2083b26cc69c54f | https://github.com/hfaran/Tornado-JSON/blob/8d8b35ff77f13cb3ab1a606bd2083b26cc69c54f/tornado_json/api_doc_gen.py#L42-L51 |
42,499 | hfaran/Tornado-JSON | tornado_json/api_doc_gen.py | _escape_markdown_literals | def _escape_markdown_literals(string):
"""Escape any markdown literals in ``string`` by prepending with \\
:type string: str
:rtype: str
"""
literals = list("\\`*_{}[]()<>#+-.!:|")
escape = lambda c: '\\' + c if c in literals else c
return "".join(map(escape, string)) | python | def _escape_markdown_literals(string):
"""Escape any markdown literals in ``string`` by prepending with \\
:type string: str
:rtype: str
"""
literals = list("\\`*_{}[]()<>#+-.!:|")
escape = lambda c: '\\' + c if c in literals else c
return "".join(map(escape, string)) | [
"def",
"_escape_markdown_literals",
"(",
"string",
")",
":",
"literals",
"=",
"list",
"(",
"\"\\\\`*_{}[]()<>#+-.!:|\"",
")",
"escape",
"=",
"lambda",
"c",
":",
"'\\\\'",
"+",
"c",
"if",
"c",
"in",
"literals",
"else",
"c",
"return",
"\"\"",
".",
"join",
"(... | Escape any markdown literals in ``string`` by prepending with \\
:type string: str
:rtype: str | [
"Escape",
"any",
"markdown",
"literals",
"in",
"string",
"by",
"prepending",
"with",
"\\\\"
] | 8d8b35ff77f13cb3ab1a606bd2083b26cc69c54f | https://github.com/hfaran/Tornado-JSON/blob/8d8b35ff77f13cb3ab1a606bd2083b26cc69c54f/tornado_json/api_doc_gen.py#L86-L94 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.