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
47,500
scot-dev/scot
scot/plotting.py
plot_whiteness
def plot_whiteness(var, h, repeats=1000, axis=None): """ Draw distribution of the Portmanteu whiteness test. Parameters ---------- var : :class:`~scot.var.VARBase`-like object Vector autoregressive model (VAR) object whose residuals are tested for whiteness. h : int Maximum lag to i...
python
def plot_whiteness(var, h, repeats=1000, axis=None): """ Draw distribution of the Portmanteu whiteness test. Parameters ---------- var : :class:`~scot.var.VARBase`-like object Vector autoregressive model (VAR) object whose residuals are tested for whiteness. h : int Maximum lag to i...
[ "def", "plot_whiteness", "(", "var", ",", "h", ",", "repeats", "=", "1000", ",", "axis", "=", "None", ")", ":", "pr", ",", "q0", ",", "q", "=", "var", ".", "test_whiteness", "(", "h", ",", "repeats", ",", "True", ")", "if", "axis", "is", "None", ...
Draw distribution of the Portmanteu whiteness test. Parameters ---------- var : :class:`~scot.var.VARBase`-like object Vector autoregressive model (VAR) object whose residuals are tested for whiteness. h : int Maximum lag to include in the test. repeats : int, optional Numbe...
[ "Draw", "distribution", "of", "the", "Portmanteu", "whiteness", "test", "." ]
48598b79d4400dad893b134cd2194715511facda
https://github.com/scot-dev/scot/blob/48598b79d4400dad893b134cd2194715511facda/scot/plotting.py#L626-L664
47,501
scot-dev/scot
scot/xvschema.py
singletrial
def singletrial(num_trials, skipstep=1): """ Single-trial cross-validation schema Use one trial for training, all others for testing. Parameters ---------- num_trials : int Total number of trials skipstep : int only use every `skipstep` trial for training Returns -----...
python
def singletrial(num_trials, skipstep=1): """ Single-trial cross-validation schema Use one trial for training, all others for testing. Parameters ---------- num_trials : int Total number of trials skipstep : int only use every `skipstep` trial for training Returns -----...
[ "def", "singletrial", "(", "num_trials", ",", "skipstep", "=", "1", ")", ":", "for", "t", "in", "range", "(", "0", ",", "num_trials", ",", "skipstep", ")", ":", "trainset", "=", "[", "t", "]", "testset", "=", "[", "i", "for", "i", "in", "range", ...
Single-trial cross-validation schema Use one trial for training, all others for testing. Parameters ---------- num_trials : int Total number of trials skipstep : int only use every `skipstep` trial for training Returns ------- gen : generator object the generat...
[ "Single", "-", "trial", "cross", "-", "validation", "schema" ]
48598b79d4400dad893b134cd2194715511facda
https://github.com/scot-dev/scot/blob/48598b79d4400dad893b134cd2194715511facda/scot/xvschema.py#L14-L36
47,502
scot-dev/scot
scot/xvschema.py
splitset
def splitset(num_trials, skipstep=None): """ Split-set cross validation Use half the trials for training, and the other half for testing. Then repeat the other way round. Parameters ---------- num_trials : int Total number of trials skipstep : int unused Returns --...
python
def splitset(num_trials, skipstep=None): """ Split-set cross validation Use half the trials for training, and the other half for testing. Then repeat the other way round. Parameters ---------- num_trials : int Total number of trials skipstep : int unused Returns --...
[ "def", "splitset", "(", "num_trials", ",", "skipstep", "=", "None", ")", ":", "split", "=", "num_trials", "//", "2", "a", "=", "list", "(", "range", "(", "0", ",", "split", ")", ")", "b", "=", "list", "(", "range", "(", "split", ",", "num_trials", ...
Split-set cross validation Use half the trials for training, and the other half for testing. Then repeat the other way round. Parameters ---------- num_trials : int Total number of trials skipstep : int unused Returns ------- gen : generator object the gene...
[ "Split", "-", "set", "cross", "validation" ]
48598b79d4400dad893b134cd2194715511facda
https://github.com/scot-dev/scot/blob/48598b79d4400dad893b134cd2194715511facda/scot/xvschema.py#L64-L87
47,503
scot-dev/scot
scot/ooapi.py
Workspace.set_data
def set_data(self, data, cl=None, time_offset=0): """ Assign data to the workspace. This function assigns a new data set to the workspace. Doing so invalidates currently fitted VAR models, connectivity estimates, and activations. Parameters ---------- data : array-like,...
python
def set_data(self, data, cl=None, time_offset=0): """ Assign data to the workspace. This function assigns a new data set to the workspace. Doing so invalidates currently fitted VAR models, connectivity estimates, and activations. Parameters ---------- data : array-like,...
[ "def", "set_data", "(", "self", ",", "data", ",", "cl", "=", "None", ",", "time_offset", "=", "0", ")", ":", "self", ".", "data_", "=", "atleast_3d", "(", "data", ")", "self", ".", "cl_", "=", "np", ".", "asarray", "(", "cl", "if", "cl", "is", ...
Assign data to the workspace. This function assigns a new data set to the workspace. Doing so invalidates currently fitted VAR models, connectivity estimates, and activations. Parameters ---------- data : array-like, shape = [n_trials, n_channels, n_samples] or [n_channels, n_s...
[ "Assign", "data", "to", "the", "workspace", "." ]
48598b79d4400dad893b134cd2194715511facda
https://github.com/scot-dev/scot/blob/48598b79d4400dad893b134cd2194715511facda/scot/ooapi.py#L168-L200
47,504
scot-dev/scot
scot/ooapi.py
Workspace.set_used_labels
def set_used_labels(self, labels): """ Specify which trials to use in subsequent analysis steps. This function masks trials based on their class labels. Parameters ---------- labels : list of class labels Marks all trials that have a label that is in the `labels` li...
python
def set_used_labels(self, labels): """ Specify which trials to use in subsequent analysis steps. This function masks trials based on their class labels. Parameters ---------- labels : list of class labels Marks all trials that have a label that is in the `labels` li...
[ "def", "set_used_labels", "(", "self", ",", "labels", ")", ":", "mask", "=", "np", ".", "zeros", "(", "self", ".", "cl_", ".", "size", ",", "dtype", "=", "bool", ")", "for", "l", "in", "labels", ":", "mask", "=", "np", ".", "logical_or", "(", "ma...
Specify which trials to use in subsequent analysis steps. This function masks trials based on their class labels. Parameters ---------- labels : list of class labels Marks all trials that have a label that is in the `labels` list for further processing. Returns ...
[ "Specify", "which", "trials", "to", "use", "in", "subsequent", "analysis", "steps", "." ]
48598b79d4400dad893b134cd2194715511facda
https://github.com/scot-dev/scot/blob/48598b79d4400dad893b134cd2194715511facda/scot/ooapi.py#L202-L221
47,505
scot-dev/scot
scot/ooapi.py
Workspace.remove_sources
def remove_sources(self, sources): """ Remove sources from the decomposition. This function removes sources from the decomposition. Doing so invalidates currently fitted VAR models and connectivity estimates. Parameters ---------- sources : {slice, int, array of ints} ...
python
def remove_sources(self, sources): """ Remove sources from the decomposition. This function removes sources from the decomposition. Doing so invalidates currently fitted VAR models and connectivity estimates. Parameters ---------- sources : {slice, int, array of ints} ...
[ "def", "remove_sources", "(", "self", ",", "sources", ")", ":", "if", "self", ".", "unmixing_", "is", "None", "or", "self", ".", "mixing_", "is", "None", ":", "raise", "RuntimeError", "(", "\"No sources available (run do_mvarica first)\"", ")", "self", ".", "m...
Remove sources from the decomposition. This function removes sources from the decomposition. Doing so invalidates currently fitted VAR models and connectivity estimates. Parameters ---------- sources : {slice, int, array of ints} Indices of components to remove. ...
[ "Remove", "sources", "from", "the", "decomposition", "." ]
48598b79d4400dad893b134cd2194715511facda
https://github.com/scot-dev/scot/blob/48598b79d4400dad893b134cd2194715511facda/scot/ooapi.py#L341-L373
47,506
scot-dev/scot
scot/ooapi.py
Workspace.keep_sources
def keep_sources(self, keep): """Keep only the specified sources in the decomposition. """ if self.unmixing_ is None or self.mixing_ is None: raise RuntimeError("No sources available (run do_mvarica first)") n_sources = self.mixing_.shape[0] self.remove_sources(np.set...
python
def keep_sources(self, keep): """Keep only the specified sources in the decomposition. """ if self.unmixing_ is None or self.mixing_ is None: raise RuntimeError("No sources available (run do_mvarica first)") n_sources = self.mixing_.shape[0] self.remove_sources(np.set...
[ "def", "keep_sources", "(", "self", ",", "keep", ")", ":", "if", "self", ".", "unmixing_", "is", "None", "or", "self", ".", "mixing_", "is", "None", ":", "raise", "RuntimeError", "(", "\"No sources available (run do_mvarica first)\"", ")", "n_sources", "=", "s...
Keep only the specified sources in the decomposition.
[ "Keep", "only", "the", "specified", "sources", "in", "the", "decomposition", "." ]
48598b79d4400dad893b134cd2194715511facda
https://github.com/scot-dev/scot/blob/48598b79d4400dad893b134cd2194715511facda/scot/ooapi.py#L375-L382
47,507
scot-dev/scot
scot/ooapi.py
Workspace.fit_var
def fit_var(self): """ Fit a VAR model to the source activations. Returns ------- self : Workspace The Workspace object. Raises ------ RuntimeError If the :class:`Workspace` instance does not contain source activations. """ ...
python
def fit_var(self): """ Fit a VAR model to the source activations. Returns ------- self : Workspace The Workspace object. Raises ------ RuntimeError If the :class:`Workspace` instance does not contain source activations. """ ...
[ "def", "fit_var", "(", "self", ")", ":", "if", "self", ".", "activations_", "is", "None", ":", "raise", "RuntimeError", "(", "\"VAR fitting requires source activations (run do_mvarica first)\"", ")", "self", ".", "var_", ".", "fit", "(", "data", "=", "self", "."...
Fit a VAR model to the source activations. Returns ------- self : Workspace The Workspace object. Raises ------ RuntimeError If the :class:`Workspace` instance does not contain source activations.
[ "Fit", "a", "VAR", "model", "to", "the", "source", "activations", "." ]
48598b79d4400dad893b134cd2194715511facda
https://github.com/scot-dev/scot/blob/48598b79d4400dad893b134cd2194715511facda/scot/ooapi.py#L384-L401
47,508
scot-dev/scot
scot/ooapi.py
Workspace.get_connectivity
def get_connectivity(self, measure_name, plot=False): """ Calculate spectral connectivity measure. Parameters ---------- measure_name : str Name of the connectivity measure to calculate. See :class:`Connectivity` for supported measures. plot : {False, None, Figure ob...
python
def get_connectivity(self, measure_name, plot=False): """ Calculate spectral connectivity measure. Parameters ---------- measure_name : str Name of the connectivity measure to calculate. See :class:`Connectivity` for supported measures. plot : {False, None, Figure ob...
[ "def", "get_connectivity", "(", "self", ",", "measure_name", ",", "plot", "=", "False", ")", ":", "if", "self", ".", "connectivity_", "is", "None", ":", "raise", "RuntimeError", "(", "\"Connectivity requires a VAR model (run do_mvarica or fit_var first)\"", ")", "cm",...
Calculate spectral connectivity measure. Parameters ---------- measure_name : str Name of the connectivity measure to calculate. See :class:`Connectivity` for supported measures. plot : {False, None, Figure object}, optional Whether and where to plot the connecti...
[ "Calculate", "spectral", "connectivity", "measure", "." ]
48598b79d4400dad893b134cd2194715511facda
https://github.com/scot-dev/scot/blob/48598b79d4400dad893b134cd2194715511facda/scot/ooapi.py#L422-L470
47,509
scot-dev/scot
scot/ooapi.py
Workspace.get_surrogate_connectivity
def get_surrogate_connectivity(self, measure_name, repeats=100, plot=False, random_state=None): """ Calculate spectral connectivity measure under the assumption of no actual connectivity. Repeatedly samples connectivity from phase-randomized data. This provides estimates of the connectivity dis...
python
def get_surrogate_connectivity(self, measure_name, repeats=100, plot=False, random_state=None): """ Calculate spectral connectivity measure under the assumption of no actual connectivity. Repeatedly samples connectivity from phase-randomized data. This provides estimates of the connectivity dis...
[ "def", "get_surrogate_connectivity", "(", "self", ",", "measure_name", ",", "repeats", "=", "100", ",", "plot", "=", "False", ",", "random_state", "=", "None", ")", ":", "cs", "=", "surrogate_connectivity", "(", "measure_name", ",", "self", ".", "activations_"...
Calculate spectral connectivity measure under the assumption of no actual connectivity. Repeatedly samples connectivity from phase-randomized data. This provides estimates of the connectivity distribution if there was no causal structure in the data. Parameters ---------- measu...
[ "Calculate", "spectral", "connectivity", "measure", "under", "the", "assumption", "of", "no", "actual", "connectivity", "." ]
48598b79d4400dad893b134cd2194715511facda
https://github.com/scot-dev/scot/blob/48598b79d4400dad893b134cd2194715511facda/scot/ooapi.py#L472-L515
47,510
scot-dev/scot
scot/ooapi.py
Workspace.get_bootstrap_connectivity
def get_bootstrap_connectivity(self, measure_names, repeats=100, num_samples=None, plot=False, random_state=None): """ Calculate bootstrap estimates of spectral connectivity measures. Bootstrapping is performed on trial level. Parameters ---------- measure_names : {str, list of...
python
def get_bootstrap_connectivity(self, measure_names, repeats=100, num_samples=None, plot=False, random_state=None): """ Calculate bootstrap estimates of spectral connectivity measures. Bootstrapping is performed on trial level. Parameters ---------- measure_names : {str, list of...
[ "def", "get_bootstrap_connectivity", "(", "self", ",", "measure_names", ",", "repeats", "=", "100", ",", "num_samples", "=", "None", ",", "plot", "=", "False", ",", "random_state", "=", "None", ")", ":", "if", "num_samples", "is", "None", ":", "num_samples",...
Calculate bootstrap estimates of spectral connectivity measures. Bootstrapping is performed on trial level. Parameters ---------- measure_names : {str, list of str} Name(s) of the connectivity measure(s) to calculate. See :class:`Connectivity` for supported measures. ...
[ "Calculate", "bootstrap", "estimates", "of", "spectral", "connectivity", "measures", "." ]
48598b79d4400dad893b134cd2194715511facda
https://github.com/scot-dev/scot/blob/48598b79d4400dad893b134cd2194715511facda/scot/ooapi.py#L517-L571
47,511
scot-dev/scot
scot/ooapi.py
Workspace.plot_source_topos
def plot_source_topos(self, common_scale=None): """ Plot topography of the Source decomposition. Parameters ---------- common_scale : float, optional If set to None, each topoplot's color axis is scaled individually. Otherwise specifies the percentile (1-99) of v...
python
def plot_source_topos(self, common_scale=None): """ Plot topography of the Source decomposition. Parameters ---------- common_scale : float, optional If set to None, each topoplot's color axis is scaled individually. Otherwise specifies the percentile (1-99) of v...
[ "def", "plot_source_topos", "(", "self", ",", "common_scale", "=", "None", ")", ":", "if", "self", ".", "unmixing_", "is", "None", "and", "self", ".", "mixing_", "is", "None", ":", "raise", "RuntimeError", "(", "\"No sources available (run do_mvarica first)\"", ...
Plot topography of the Source decomposition. Parameters ---------- common_scale : float, optional If set to None, each topoplot's color axis is scaled individually. Otherwise specifies the percentile (1-99) of values in all plot. This value is taken as the maximum color ...
[ "Plot", "topography", "of", "the", "Source", "decomposition", "." ]
48598b79d4400dad893b134cd2194715511facda
https://github.com/scot-dev/scot/blob/48598b79d4400dad893b134cd2194715511facda/scot/ooapi.py#L765-L779
47,512
scot-dev/scot
scot/ooapi.py
Workspace.plot_connectivity_topos
def plot_connectivity_topos(self, fig=None): """ Plot scalp projections of the sources. This function only plots the topos. Use in combination with connectivity plotting. Parameters ---------- fig : {None, Figure object}, optional Where to plot the topos. f set to *...
python
def plot_connectivity_topos(self, fig=None): """ Plot scalp projections of the sources. This function only plots the topos. Use in combination with connectivity plotting. Parameters ---------- fig : {None, Figure object}, optional Where to plot the topos. f set to *...
[ "def", "plot_connectivity_topos", "(", "self", ",", "fig", "=", "None", ")", ":", "self", ".", "_prepare_plots", "(", "True", ",", "False", ")", "if", "self", ".", "plot_outside_topo", ":", "fig", "=", "self", ".", "plotting", ".", "plot_connectivity_topos",...
Plot scalp projections of the sources. This function only plots the topos. Use in combination with connectivity plotting. Parameters ---------- fig : {None, Figure object}, optional Where to plot the topos. f set to **None**, a new figure is created. Otherwise plot into the...
[ "Plot", "scalp", "projections", "of", "the", "sources", "." ]
48598b79d4400dad893b134cd2194715511facda
https://github.com/scot-dev/scot/blob/48598b79d4400dad893b134cd2194715511facda/scot/ooapi.py#L781-L802
47,513
scot-dev/scot
scot/ooapi.py
Workspace.plot_connectivity_surrogate
def plot_connectivity_surrogate(self, measure_name, repeats=100, fig=None): """ Plot spectral connectivity measure under the assumption of no actual connectivity. Repeatedly samples connectivity from phase-randomized data. This provides estimates of the connectivity distribution if there was no...
python
def plot_connectivity_surrogate(self, measure_name, repeats=100, fig=None): """ Plot spectral connectivity measure under the assumption of no actual connectivity. Repeatedly samples connectivity from phase-randomized data. This provides estimates of the connectivity distribution if there was no...
[ "def", "plot_connectivity_surrogate", "(", "self", ",", "measure_name", ",", "repeats", "=", "100", ",", "fig", "=", "None", ")", ":", "cb", "=", "self", ".", "get_surrogate_connectivity", "(", "measure_name", ",", "repeats", ")", "self", ".", "_prepare_plots"...
Plot spectral connectivity measure under the assumption of no actual connectivity. Repeatedly samples connectivity from phase-randomized data. This provides estimates of the connectivity distribution if there was no causal structure in the data. Parameters ---------- measure_na...
[ "Plot", "spectral", "connectivity", "measure", "under", "the", "assumption", "of", "no", "actual", "connectivity", "." ]
48598b79d4400dad893b134cd2194715511facda
https://github.com/scot-dev/scot/blob/48598b79d4400dad893b134cd2194715511facda/scot/ooapi.py#L804-L833
47,514
scot-dev/scot
scot/parallel.py
parallel_loop
def parallel_loop(func, n_jobs=1, verbose=1): """run loops in parallel, if joblib is available. Parameters ---------- func : function function to be executed in parallel n_jobs : int | None Number of jobs. If set to None, do not attempt to use joblib. verbose : int verbo...
python
def parallel_loop(func, n_jobs=1, verbose=1): """run loops in parallel, if joblib is available. Parameters ---------- func : function function to be executed in parallel n_jobs : int | None Number of jobs. If set to None, do not attempt to use joblib. verbose : int verbo...
[ "def", "parallel_loop", "(", "func", ",", "n_jobs", "=", "1", ",", "verbose", "=", "1", ")", ":", "if", "n_jobs", ":", "try", ":", "from", "joblib", "import", "Parallel", ",", "delayed", "except", "ImportError", ":", "try", ":", "from", "sklearn", ".",...
run loops in parallel, if joblib is available. Parameters ---------- func : function function to be executed in parallel n_jobs : int | None Number of jobs. If set to None, do not attempt to use joblib. verbose : int verbosity level Notes ----- Execution of the ...
[ "run", "loops", "in", "parallel", "if", "joblib", "is", "available", "." ]
48598b79d4400dad893b134cd2194715511facda
https://github.com/scot-dev/scot/blob/48598b79d4400dad893b134cd2194715511facda/scot/parallel.py#L8-L43
47,515
kolypto/py-good
good/voluptuous.py
_convert_errors
def _convert_errors(func): """ Decorator to convert throws errors to Voluptuous format.""" cast_Invalid = lambda e: Invalid( u"{message}, expected {expected}".format( message=e.message, expected=e.expected) if e.expected != u'-none-' else e.message, e.path, ...
python
def _convert_errors(func): """ Decorator to convert throws errors to Voluptuous format.""" cast_Invalid = lambda e: Invalid( u"{message}, expected {expected}".format( message=e.message, expected=e.expected) if e.expected != u'-none-' else e.message, e.path, ...
[ "def", "_convert_errors", "(", "func", ")", ":", "cast_Invalid", "=", "lambda", "e", ":", "Invalid", "(", "u\"{message}, expected {expected}\"", ".", "format", "(", "message", "=", "e", ".", "message", ",", "expected", "=", "e", ".", "expected", ")", "if", ...
Decorator to convert throws errors to Voluptuous format.
[ "Decorator", "to", "convert", "throws", "errors", "to", "Voluptuous", "format", "." ]
192ef19e79f6fd95c1cbd7c378a3074c7ad7a6d4
https://github.com/kolypto/py-good/blob/192ef19e79f6fd95c1cbd7c378a3074c7ad7a6d4/good/voluptuous.py#L45-L66
47,516
kolypto/py-good
good/schema/markers.py
Marker.on_compiled
def on_compiled(self, name=None, key_schema=None, value_schema=None, as_mapping_key=None): """ When CompiledSchema compiles this marker, it sets informational values onto it. Note that arguments may be provided in two incomplete sets, e.g. (name, key_schema, None) and then (None, None, value_sc...
python
def on_compiled(self, name=None, key_schema=None, value_schema=None, as_mapping_key=None): """ When CompiledSchema compiles this marker, it sets informational values onto it. Note that arguments may be provided in two incomplete sets, e.g. (name, key_schema, None) and then (None, None, value_sc...
[ "def", "on_compiled", "(", "self", ",", "name", "=", "None", ",", "key_schema", "=", "None", ",", "value_schema", "=", "None", ",", "as_mapping_key", "=", "None", ")", ":", "if", "self", ".", "name", "is", "None", ":", "self", ".", "name", "=", "name...
When CompiledSchema compiles this marker, it sets informational values onto it. Note that arguments may be provided in two incomplete sets, e.g. (name, key_schema, None) and then (None, None, value_schema). Thus, all assignments must be handled individually. It is possible that a marke...
[ "When", "CompiledSchema", "compiles", "this", "marker", "it", "sets", "informational", "values", "onto", "it", "." ]
192ef19e79f6fd95c1cbd7c378a3074c7ad7a6d4
https://github.com/kolypto/py-good/blob/192ef19e79f6fd95c1cbd7c378a3074c7ad7a6d4/good/schema/markers.py#L90-L119
47,517
openearth/bmi-python
bmi/runner.py
colorlogs
def colorlogs(format="short"): """Append a rainbow logging handler and a formatter to the root logger""" try: from rainbow_logging_handler import RainbowLoggingHandler import sys # setup `RainbowLoggingHandler` logger = logging.root # same as default if format == ...
python
def colorlogs(format="short"): """Append a rainbow logging handler and a formatter to the root logger""" try: from rainbow_logging_handler import RainbowLoggingHandler import sys # setup `RainbowLoggingHandler` logger = logging.root # same as default if format == ...
[ "def", "colorlogs", "(", "format", "=", "\"short\"", ")", ":", "try", ":", "from", "rainbow_logging_handler", "import", "RainbowLoggingHandler", "import", "sys", "# setup `RainbowLoggingHandler`", "logger", "=", "logging", ".", "root", "# same as default", "if", "form...
Append a rainbow logging handler and a formatter to the root logger
[ "Append", "a", "rainbow", "logging", "handler", "and", "a", "formatter", "to", "the", "root", "logger" ]
2f53f24d45515eb0711c2d28ddd6c1582045248f
https://github.com/openearth/bmi-python/blob/2f53f24d45515eb0711c2d28ddd6c1582045248f/bmi/runner.py#L30-L49
47,518
openearth/bmi-python
bmi/runner.py
main
def main(): """main bmi runner program""" arguments = docopt.docopt(__doc__, version=__version__) colorlogs() # Read input file file wrapper = BMIWrapper( engine=arguments['<engine>'], configfile=arguments['<config>'] or '' ) # add logger if required if not arguments[...
python
def main(): """main bmi runner program""" arguments = docopt.docopt(__doc__, version=__version__) colorlogs() # Read input file file wrapper = BMIWrapper( engine=arguments['<engine>'], configfile=arguments['<config>'] or '' ) # add logger if required if not arguments[...
[ "def", "main", "(", ")", ":", "arguments", "=", "docopt", ".", "docopt", "(", "__doc__", ",", "version", "=", "__version__", ")", "colorlogs", "(", ")", "# Read input file file", "wrapper", "=", "BMIWrapper", "(", "engine", "=", "arguments", "[", "'<engine>'...
main bmi runner program
[ "main", "bmi", "runner", "program" ]
2f53f24d45515eb0711c2d28ddd6c1582045248f
https://github.com/openearth/bmi-python/blob/2f53f24d45515eb0711c2d28ddd6c1582045248f/bmi/runner.py#L82-L126
47,519
insomnia-lab/libreant
conf/defaults.py
get_def_conf
def get_def_conf(): '''return default configurations as simple dict''' ret = dict() for k,v in defConf.items(): ret[k] = v[0] return ret
python
def get_def_conf(): '''return default configurations as simple dict''' ret = dict() for k,v in defConf.items(): ret[k] = v[0] return ret
[ "def", "get_def_conf", "(", ")", ":", "ret", "=", "dict", "(", ")", "for", "k", ",", "v", "in", "defConf", ".", "items", "(", ")", ":", "ret", "[", "k", "]", "=", "v", "[", "0", "]", "return", "ret" ]
return default configurations as simple dict
[ "return", "default", "configurations", "as", "simple", "dict" ]
55d529435baf4c05a86b8341899e9f5e14e50245
https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/conf/defaults.py#L21-L26
47,520
iamjarret/pystockfish
pystockfish.py
Match.move
def move(self): """ Advance game by single move, if possible. @return: logical indicator if move was performed. """ if len(self.moves) == MAX_MOVES: return False elif len(self.moves) % 2: active_engine = self.black_engine active_engine...
python
def move(self): """ Advance game by single move, if possible. @return: logical indicator if move was performed. """ if len(self.moves) == MAX_MOVES: return False elif len(self.moves) % 2: active_engine = self.black_engine active_engine...
[ "def", "move", "(", "self", ")", ":", "if", "len", "(", "self", ".", "moves", ")", "==", "MAX_MOVES", ":", "return", "False", "elif", "len", "(", "self", ".", "moves", ")", "%", "2", ":", "active_engine", "=", "self", ".", "black_engine", "active_eng...
Advance game by single move, if possible. @return: logical indicator if move was performed.
[ "Advance", "game", "by", "single", "move", "if", "possible", "." ]
ae34a4b4d29c577c888b72691fcf0cb5a89b1792
https://github.com/iamjarret/pystockfish/blob/ae34a4b4d29c577c888b72691fcf0cb5a89b1792/pystockfish.py#L54-L90
47,521
iamjarret/pystockfish
pystockfish.py
Engine.bestmove
def bestmove(self): """ Get proposed best move for current position. @return: dictionary with 'move', 'ponder', 'info' containing best move's UCI notation, ponder value and info dictionary. """ self.go() last_info = "" while True: text = self....
python
def bestmove(self): """ Get proposed best move for current position. @return: dictionary with 'move', 'ponder', 'info' containing best move's UCI notation, ponder value and info dictionary. """ self.go() last_info = "" while True: text = self....
[ "def", "bestmove", "(", "self", ")", ":", "self", ".", "go", "(", ")", "last_info", "=", "\"\"", "while", "True", ":", "text", "=", "self", ".", "stdout", ".", "readline", "(", ")", ".", "strip", "(", ")", "split_text", "=", "text", ".", "split", ...
Get proposed best move for current position. @return: dictionary with 'move', 'ponder', 'info' containing best move's UCI notation, ponder value and info dictionary.
[ "Get", "proposed", "best", "move", "for", "current", "position", "." ]
ae34a4b4d29c577c888b72691fcf0cb5a89b1792
https://github.com/iamjarret/pystockfish/blob/ae34a4b4d29c577c888b72691fcf0cb5a89b1792/pystockfish.py#L213-L232
47,522
iamjarret/pystockfish
pystockfish.py
Engine._bestmove_get_info
def _bestmove_get_info(text): """ Parse stockfish evaluation output as dictionary. Examples of input: "info depth 2 seldepth 3 multipv 1 score cp -656 nodes 43 nps 43000 tbhits 0 \ time 1 pv g7g6 h3g3 g6f7" "info depth 10 seldepth 12 multipv 1 score mate 5 nodes 2378 n...
python
def _bestmove_get_info(text): """ Parse stockfish evaluation output as dictionary. Examples of input: "info depth 2 seldepth 3 multipv 1 score cp -656 nodes 43 nps 43000 tbhits 0 \ time 1 pv g7g6 h3g3 g6f7" "info depth 10 seldepth 12 multipv 1 score mate 5 nodes 2378 n...
[ "def", "_bestmove_get_info", "(", "text", ")", ":", "result_dict", "=", "Engine", ".", "_get_info_pv", "(", "text", ")", "result_dict", ".", "update", "(", "Engine", ".", "_get_info_score", "(", "text", ")", ")", "single_value_fields", "=", "[", "'depth'", "...
Parse stockfish evaluation output as dictionary. Examples of input: "info depth 2 seldepth 3 multipv 1 score cp -656 nodes 43 nps 43000 tbhits 0 \ time 1 pv g7g6 h3g3 g6f7" "info depth 10 seldepth 12 multipv 1 score mate 5 nodes 2378 nps 1189000 tbhits 0 \ time 2 pv h3g3 g6f7 ...
[ "Parse", "stockfish", "evaluation", "output", "as", "dictionary", "." ]
ae34a4b4d29c577c888b72691fcf0cb5a89b1792
https://github.com/iamjarret/pystockfish/blob/ae34a4b4d29c577c888b72691fcf0cb5a89b1792/pystockfish.py#L235-L254
47,523
iamjarret/pystockfish
pystockfish.py
Engine.isready
def isready(self): """ Used to synchronize the python engine object with the back-end engine. Sends 'isready' and waits for 'readyok.' """ self.put('isready') while True: text = self.stdout.readline().strip() if text == 'readyok': return t...
python
def isready(self): """ Used to synchronize the python engine object with the back-end engine. Sends 'isready' and waits for 'readyok.' """ self.put('isready') while True: text = self.stdout.readline().strip() if text == 'readyok': return t...
[ "def", "isready", "(", "self", ")", ":", "self", ".", "put", "(", "'isready'", ")", "while", "True", ":", "text", "=", "self", ".", "stdout", ".", "readline", "(", ")", ".", "strip", "(", ")", "if", "text", "==", "'readyok'", ":", "return", "text" ...
Used to synchronize the python engine object with the back-end engine. Sends 'isready' and waits for 'readyok.'
[ "Used", "to", "synchronize", "the", "python", "engine", "object", "with", "the", "back", "-", "end", "engine", ".", "Sends", "isready", "and", "waits", "for", "readyok", "." ]
ae34a4b4d29c577c888b72691fcf0cb5a89b1792
https://github.com/iamjarret/pystockfish/blob/ae34a4b4d29c577c888b72691fcf0cb5a89b1792/pystockfish.py#L289-L297
47,524
chaoss/grimoirelab-manuscripts
manuscripts2/metrics/github_prs.py
project_activity
def project_activity(index, start, end): """Compute the metrics for the project activity section of the enriched github pull requests index. Returns a dictionary containing a "metric" key. This key contains the metrics for this section. :param index: index object :param start: start date to ge...
python
def project_activity(index, start, end): """Compute the metrics for the project activity section of the enriched github pull requests index. Returns a dictionary containing a "metric" key. This key contains the metrics for this section. :param index: index object :param start: start date to ge...
[ "def", "project_activity", "(", "index", ",", "start", ",", "end", ")", ":", "results", "=", "{", "\"metrics\"", ":", "[", "SubmittedPRs", "(", "index", ",", "start", ",", "end", ")", ",", "ClosedPRs", "(", "index", ",", "start", ",", "end", ")", "]"...
Compute the metrics for the project activity section of the enriched github pull requests index. Returns a dictionary containing a "metric" key. This key contains the metrics for this section. :param index: index object :param start: start date to get the data from :param end: end date to get ...
[ "Compute", "the", "metrics", "for", "the", "project", "activity", "section", "of", "the", "enriched", "github", "pull", "requests", "index", "." ]
94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9
https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts2/metrics/github_prs.py#L234-L252
47,525
chaoss/grimoirelab-manuscripts
manuscripts2/metrics/github_prs.py
DaysToClosePRMedian.aggregations
def aggregations(self): """Get the single valued aggregations with respect to the previous time interval.""" prev_month_start = get_prev_month(self.end, self.query.interval_) self.query.since(prev_month_start) agg = super().aggregations() if agg is None: agg ...
python
def aggregations(self): """Get the single valued aggregations with respect to the previous time interval.""" prev_month_start = get_prev_month(self.end, self.query.interval_) self.query.since(prev_month_start) agg = super().aggregations() if agg is None: agg ...
[ "def", "aggregations", "(", "self", ")", ":", "prev_month_start", "=", "get_prev_month", "(", "self", ".", "end", ",", "self", ".", "query", ".", "interval_", ")", "self", ".", "query", ".", "since", "(", "prev_month_start", ")", "agg", "=", "super", "("...
Get the single valued aggregations with respect to the previous time interval.
[ "Get", "the", "single", "valued", "aggregations", "with", "respect", "to", "the", "previous", "time", "interval", "." ]
94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9
https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts2/metrics/github_prs.py#L110-L119
47,526
chaoss/grimoirelab-manuscripts
manuscripts2/metrics/github_prs.py
BMIPR.timeseries
def timeseries(self, dataframe=False): """Get BMIPR as a time series.""" closed_timeseries = self.closed.timeseries(dataframe=dataframe) opened_timeseries = self.opened.timeseries(dataframe=dataframe) return calculate_bmi(closed_timeseries, opened_timeseries)
python
def timeseries(self, dataframe=False): """Get BMIPR as a time series.""" closed_timeseries = self.closed.timeseries(dataframe=dataframe) opened_timeseries = self.opened.timeseries(dataframe=dataframe) return calculate_bmi(closed_timeseries, opened_timeseries)
[ "def", "timeseries", "(", "self", ",", "dataframe", "=", "False", ")", ":", "closed_timeseries", "=", "self", ".", "closed", ".", "timeseries", "(", "dataframe", "=", "dataframe", ")", "opened_timeseries", "=", "self", ".", "opened", ".", "timeseries", "(", ...
Get BMIPR as a time series.
[ "Get", "BMIPR", "as", "a", "time", "series", "." ]
94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9
https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts2/metrics/github_prs.py#L201-L206
47,527
chaoss/grimoirelab-manuscripts
manuscripts/metrics/metrics.py
Metrics.get_query
def get_query(self, evolutionary=False): """ Basic query to get the metric values :param evolutionary: if True the metric values time series is returned. If False the aggregated metric value. :return: the DSL query to be sent to Elasticsearch """ if not evolutionary: ...
python
def get_query(self, evolutionary=False): """ Basic query to get the metric values :param evolutionary: if True the metric values time series is returned. If False the aggregated metric value. :return: the DSL query to be sent to Elasticsearch """ if not evolutionary: ...
[ "def", "get_query", "(", "self", ",", "evolutionary", "=", "False", ")", ":", "if", "not", "evolutionary", ":", "interval", "=", "None", "offset", "=", "None", "else", ":", "interval", "=", "self", ".", "interval", "offset", "=", "self", ".", "offset", ...
Basic query to get the metric values :param evolutionary: if True the metric values time series is returned. If False the aggregated metric value. :return: the DSL query to be sent to Elasticsearch
[ "Basic", "query", "to", "get", "the", "metric", "values" ]
94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9
https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts/metrics/metrics.py#L103-L130
47,528
chaoss/grimoirelab-manuscripts
manuscripts/metrics/metrics.py
Metrics.get_list
def get_list(self): """ Extract from a DSL aggregated response the values for each bucket :return: a list with the values in a DSL aggregated response """ field = self.FIELD_NAME query = ElasticQuery.get_agg(field=field, date_field=se...
python
def get_list(self): """ Extract from a DSL aggregated response the values for each bucket :return: a list with the values in a DSL aggregated response """ field = self.FIELD_NAME query = ElasticQuery.get_agg(field=field, date_field=se...
[ "def", "get_list", "(", "self", ")", ":", "field", "=", "self", ".", "FIELD_NAME", "query", "=", "ElasticQuery", ".", "get_agg", "(", "field", "=", "field", ",", "date_field", "=", "self", ".", "FIELD_DATE", ",", "start", "=", "self", ".", "start", ","...
Extract from a DSL aggregated response the values for each bucket :return: a list with the values in a DSL aggregated response
[ "Extract", "from", "a", "DSL", "aggregated", "response", "the", "values", "for", "each", "bucket" ]
94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9
https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts/metrics/metrics.py#L132-L150
47,529
chaoss/grimoirelab-manuscripts
manuscripts/metrics/metrics.py
Metrics.get_metrics_data
def get_metrics_data(self, query): """ Get the metrics data from Elasticsearch given a DSL query :param query: query to be sent to Elasticsearch :return: a dict with the results of executing the query """ if self.es_url.startswith("http"): url = self.es_url ...
python
def get_metrics_data(self, query): """ Get the metrics data from Elasticsearch given a DSL query :param query: query to be sent to Elasticsearch :return: a dict with the results of executing the query """ if self.es_url.startswith("http"): url = self.es_url ...
[ "def", "get_metrics_data", "(", "self", ",", "query", ")", ":", "if", "self", ".", "es_url", ".", "startswith", "(", "\"http\"", ")", ":", "url", "=", "self", ".", "es_url", "else", ":", "url", "=", "'http://'", "+", "self", ".", "es_url", "es", "=",...
Get the metrics data from Elasticsearch given a DSL query :param query: query to be sent to Elasticsearch :return: a dict with the results of executing the query
[ "Get", "the", "metrics", "data", "from", "Elasticsearch", "given", "a", "DSL", "query" ]
94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9
https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts/metrics/metrics.py#L152-L173
47,530
chaoss/grimoirelab-manuscripts
manuscripts/metrics/metrics.py
Metrics.get_ts
def get_ts(self): """ Returns a time series of a specific class A timeseries consists of a unixtime date, labels, some other fields and the data of the specific instantiated class metric per interval. This is built on a hash table. :return: a list with a time series wit...
python
def get_ts(self): """ Returns a time series of a specific class A timeseries consists of a unixtime date, labels, some other fields and the data of the specific instantiated class metric per interval. This is built on a hash table. :return: a list with a time series wit...
[ "def", "get_ts", "(", "self", ")", ":", "query", "=", "self", ".", "get_query", "(", "True", ")", "res", "=", "self", ".", "get_metrics_data", "(", "query", ")", "# Time to convert it to our grimoire timeseries format", "ts", "=", "{", "\"date\"", ":", "[", ...
Returns a time series of a specific class A timeseries consists of a unixtime date, labels, some other fields and the data of the specific instantiated class metric per interval. This is built on a hash table. :return: a list with a time series with the values of the metric
[ "Returns", "a", "time", "series", "of", "a", "specific", "class" ]
94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9
https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts/metrics/metrics.py#L175-L210
47,531
chaoss/grimoirelab-manuscripts
manuscripts/metrics/metrics.py
Metrics.get_agg
def get_agg(self): """ Returns the aggregated value for the metric :return: the value of the metric """ """ Returns an aggregated value """ query = self.get_query(False) res = self.get_metrics_data(query) # We need to extract the data from the JSON res ...
python
def get_agg(self): """ Returns the aggregated value for the metric :return: the value of the metric """ """ Returns an aggregated value """ query = self.get_query(False) res = self.get_metrics_data(query) # We need to extract the data from the JSON res ...
[ "def", "get_agg", "(", "self", ")", ":", "\"\"\" Returns an aggregated value \"\"\"", "query", "=", "self", ".", "get_query", "(", "False", ")", "res", "=", "self", ".", "get_metrics_data", "(", "query", ")", "# We need to extract the data from the JSON res", "# If we...
Returns the aggregated value for the metric :return: the value of the metric
[ "Returns", "the", "aggregated", "value", "for", "the", "metric" ]
94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9
https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts/metrics/metrics.py#L212-L237
47,532
chaoss/grimoirelab-manuscripts
manuscripts/metrics/metrics.py
Metrics.get_trend
def get_trend(self): """ Get the trend for the last two metric values using the interval defined in the metric :return: a tuple with the metric value for the last interval and the trend percentage between the last two intervals """ """ """ # TODO: We j...
python
def get_trend(self): """ Get the trend for the last two metric values using the interval defined in the metric :return: a tuple with the metric value for the last interval and the trend percentage between the last two intervals """ """ """ # TODO: We j...
[ "def", "get_trend", "(", "self", ")", ":", "\"\"\" \"\"\"", "# TODO: We just need the last two periods, not the full ts", "ts", "=", "self", ".", "get_ts", "(", ")", "last", "=", "ts", "[", "'value'", "]", "[", "len", "(", "ts", "[", "'value'", "]", ")", "-...
Get the trend for the last two metric values using the interval defined in the metric :return: a tuple with the metric value for the last interval and the trend percentage between the last two intervals
[ "Get", "the", "trend", "for", "the", "last", "two", "metric", "values", "using", "the", "interval", "defined", "in", "the", "metric" ]
94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9
https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts/metrics/metrics.py#L239-L263
47,533
insomnia-lab/libreant
presets/presetManager.py
PresetManager._load_preset
def _load_preset(self, path): ''' load, validate and store a single preset file''' try: with open(path, 'r') as f: presetBody = json.load(f) except IOError as e: raise PresetException("IOError: " + e.strerror) except ValueError as e: r...
python
def _load_preset(self, path): ''' load, validate and store a single preset file''' try: with open(path, 'r') as f: presetBody = json.load(f) except IOError as e: raise PresetException("IOError: " + e.strerror) except ValueError as e: r...
[ "def", "_load_preset", "(", "self", ",", "path", ")", ":", "try", ":", "with", "open", "(", "path", ",", "'r'", ")", "as", "f", ":", "presetBody", "=", "json", ".", "load", "(", "f", ")", "except", "IOError", "as", "e", ":", "raise", "PresetExcepti...
load, validate and store a single preset file
[ "load", "validate", "and", "store", "a", "single", "preset", "file" ]
55d529435baf4c05a86b8341899e9f5e14e50245
https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/presets/presetManager.py#L81-L103
47,534
insomnia-lab/libreant
presets/presetManager.py
Preset.validate
def validate(self, data): ''' Checks if `data` respects this preset specification It will check that every required property is present and for every property type it will make some specific control. ''' for prop in self.properties: if prop.id in data: ...
python
def validate(self, data): ''' Checks if `data` respects this preset specification It will check that every required property is present and for every property type it will make some specific control. ''' for prop in self.properties: if prop.id in data: ...
[ "def", "validate", "(", "self", ",", "data", ")", ":", "for", "prop", "in", "self", ".", "properties", ":", "if", "prop", ".", "id", "in", "data", ":", "if", "prop", ".", "type", "==", "'string'", ":", "if", "not", "isinstance", "(", "data", "[", ...
Checks if `data` respects this preset specification It will check that every required property is present and for every property type it will make some specific control.
[ "Checks", "if", "data", "respects", "this", "preset", "specification" ]
55d529435baf4c05a86b8341899e9f5e14e50245
https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/presets/presetManager.py#L221-L240
47,535
insomnia-lab/libreant
webant/util.py
requestedFormat
def requestedFormat(request,acceptedFormat): """Return the response format requested by client Client could specify requested format using: (options are processed in this order) - `format` field in http request - `Accept` header in http request Example: ...
python
def requestedFormat(request,acceptedFormat): """Return the response format requested by client Client could specify requested format using: (options are processed in this order) - `format` field in http request - `Accept` header in http request Example: ...
[ "def", "requestedFormat", "(", "request", ",", "acceptedFormat", ")", ":", "if", "'format'", "in", "request", ".", "args", ":", "fieldFormat", "=", "request", ".", "args", ".", "get", "(", "'format'", ")", "if", "fieldFormat", "not", "in", "acceptedFormat", ...
Return the response format requested by client Client could specify requested format using: (options are processed in this order) - `format` field in http request - `Accept` header in http request Example: chooseFormat(request, ['text/html','application/json'...
[ "Return", "the", "response", "format", "requested", "by", "client" ]
55d529435baf4c05a86b8341899e9f5e14e50245
https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/webant/util.py#L18-L40
47,536
insomnia-lab/libreant
webant/util.py
routes_collector
def routes_collector(gatherer): """Decorator utility to collect flask routes in a dictionary. This function together with :func:`add_routes` provides an easy way to split flask routes declaration in multiple modules. :param gatherer: dict in which will be collected routes The decorator provided b...
python
def routes_collector(gatherer): """Decorator utility to collect flask routes in a dictionary. This function together with :func:`add_routes` provides an easy way to split flask routes declaration in multiple modules. :param gatherer: dict in which will be collected routes The decorator provided b...
[ "def", "routes_collector", "(", "gatherer", ")", ":", "def", "hatFunc", "(", "rule", ",", "*", "*", "options", ")", ":", "def", "decorator", "(", "f", ")", ":", "rule_dict", "=", "{", "'rule'", ":", "rule", ",", "'view_func'", ":", "f", "}", "rule_di...
Decorator utility to collect flask routes in a dictionary. This function together with :func:`add_routes` provides an easy way to split flask routes declaration in multiple modules. :param gatherer: dict in which will be collected routes The decorator provided by this function should be used as the ...
[ "Decorator", "utility", "to", "collect", "flask", "routes", "in", "a", "dictionary", "." ]
55d529435baf4c05a86b8341899e9f5e14e50245
https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/webant/util.py#L53-L81
47,537
insomnia-lab/libreant
webant/util.py
add_routes
def add_routes(fapp, routes, prefix=""): """Batch routes registering Register routes to a blueprint/flask_app previously collected with :func:`routes_collector`. :param fapp: bluprint or flask_app to whom attach new routes. :param routes: dict of routes collected by :func:`routes_collector` :p...
python
def add_routes(fapp, routes, prefix=""): """Batch routes registering Register routes to a blueprint/flask_app previously collected with :func:`routes_collector`. :param fapp: bluprint or flask_app to whom attach new routes. :param routes: dict of routes collected by :func:`routes_collector` :p...
[ "def", "add_routes", "(", "fapp", ",", "routes", ",", "prefix", "=", "\"\"", ")", ":", "for", "r", "in", "routes", ":", "r", "[", "'rule'", "]", "=", "prefix", "+", "r", "[", "'rule'", "]", "fapp", ".", "add_url_rule", "(", "*", "*", "r", ")" ]
Batch routes registering Register routes to a blueprint/flask_app previously collected with :func:`routes_collector`. :param fapp: bluprint or flask_app to whom attach new routes. :param routes: dict of routes collected by :func:`routes_collector` :param prefix: url prefix under which register all...
[ "Batch", "routes", "registering" ]
55d529435baf4c05a86b8341899e9f5e14e50245
https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/webant/util.py#L84-L96
47,538
insomnia-lab/libreant
webant/util.py
get_centered_pagination
def get_centered_pagination(current, total, visible=5): ''' Return the range of pages to render in a pagination menu. The current page is always kept in the middle except for the edge cases. Reeturns a dict { prev, first, current, last, next } :param current: the curre...
python
def get_centered_pagination(current, total, visible=5): ''' Return the range of pages to render in a pagination menu. The current page is always kept in the middle except for the edge cases. Reeturns a dict { prev, first, current, last, next } :param current: the curre...
[ "def", "get_centered_pagination", "(", "current", ",", "total", ",", "visible", "=", "5", ")", ":", "inc", "=", "visible", "/", "2", "first", "=", "current", "-", "inc", "last", "=", "current", "+", "inc", "if", "(", "total", "<=", "visible", ")", ":...
Return the range of pages to render in a pagination menu. The current page is always kept in the middle except for the edge cases. Reeturns a dict { prev, first, current, last, next } :param current: the current page :param total: total number of pages available ...
[ "Return", "the", "range", "of", "pages", "to", "render", "in", "a", "pagination", "menu", "." ]
55d529435baf4c05a86b8341899e9f5e14e50245
https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/webant/util.py#L99-L128
47,539
SiLab-Bonn/pylandau
examples/mpv_fwhm.py
fwhm
def fwhm(x, y, k=10): # http://stackoverflow.com/questions/10582795/finding-the-full-width-half-maximum-of-a-peak """ Determine full-with-half-maximum of a peaked set of points, x and y. Assumes that there is only one peak present in the datasset. The function uses a spline interpolation of order k. ...
python
def fwhm(x, y, k=10): # http://stackoverflow.com/questions/10582795/finding-the-full-width-half-maximum-of-a-peak """ Determine full-with-half-maximum of a peaked set of points, x and y. Assumes that there is only one peak present in the datasset. The function uses a spline interpolation of order k. ...
[ "def", "fwhm", "(", "x", ",", "y", ",", "k", "=", "10", ")", ":", "# http://stackoverflow.com/questions/10582795/finding-the-full-width-half-maximum-of-a-peak", "class", "MultiplePeaks", "(", "Exception", ")", ":", "pass", "class", "NoPeaksFound", "(", "Exception", ")...
Determine full-with-half-maximum of a peaked set of points, x and y. Assumes that there is only one peak present in the datasset. The function uses a spline interpolation of order k.
[ "Determine", "full", "-", "with", "-", "half", "-", "maximum", "of", "a", "peaked", "set", "of", "points", "x", "and", "y", "." ]
3095af4ce5ab29685f6c8cd3830f8035521be1c6
https://github.com/SiLab-Bonn/pylandau/blob/3095af4ce5ab29685f6c8cd3830f8035521be1c6/examples/mpv_fwhm.py#L8-L33
47,540
snowblink14/smatch
smatch.py
main
def main(arguments): """ Main function of smatch score calculation """ global verbose global veryVerbose global iteration_num global single_score global pr_flag global match_triple_dict # set the iteration number # total iteration number = restart number + 1 iteration_num...
python
def main(arguments): """ Main function of smatch score calculation """ global verbose global veryVerbose global iteration_num global single_score global pr_flag global match_triple_dict # set the iteration number # total iteration number = restart number + 1 iteration_num...
[ "def", "main", "(", "arguments", ")", ":", "global", "verbose", "global", "veryVerbose", "global", "iteration_num", "global", "single_score", "global", "pr_flag", "global", "match_triple_dict", "# set the iteration number", "# total iteration number = restart number + 1", "it...
Main function of smatch score calculation
[ "Main", "function", "of", "smatch", "score", "calculation" ]
ad7e6553a3d52e469b2eef69d7716c87a67eedac
https://github.com/snowblink14/smatch/blob/ad7e6553a3d52e469b2eef69d7716c87a67eedac/smatch.py#L820-L853
47,541
insomnia-lab/libreant
archivant/archivant.py
Archivant.normalize_volume
def normalize_volume(volume): '''convert volume metadata from es to archivant format This function makes side effect on input volume output example:: { 'id': 'AU0paPZOMZchuDv1iDv8', 'type': 'volume', 'metadata': {'_language': '...
python
def normalize_volume(volume): '''convert volume metadata from es to archivant format This function makes side effect on input volume output example:: { 'id': 'AU0paPZOMZchuDv1iDv8', 'type': 'volume', 'metadata': {'_language': '...
[ "def", "normalize_volume", "(", "volume", ")", ":", "res", "=", "dict", "(", ")", "res", "[", "'type'", "]", "=", "'volume'", "res", "[", "'id'", "]", "=", "volume", "[", "'_id'", "]", "if", "'_score'", "in", "volume", ":", "res", "[", "'score'", "...
convert volume metadata from es to archivant format This function makes side effect on input volume output example:: { 'id': 'AU0paPZOMZchuDv1iDv8', 'type': 'volume', 'metadata': {'_language': 'en', 'key1': ...
[ "convert", "volume", "metadata", "from", "es", "to", "archivant", "format" ]
55d529435baf4c05a86b8341899e9f5e14e50245
https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/archivant/archivant.py#L81-L125
47,542
insomnia-lab/libreant
archivant/archivant.py
Archivant.normalize_attachment
def normalize_attachment(attachment): ''' Convert attachment metadata from es to archivant format This function makes side effect on input attachment ''' res = dict() res['type'] = 'attachment' res['id'] = attachment['id'] del(attachment['id']) res['u...
python
def normalize_attachment(attachment): ''' Convert attachment metadata from es to archivant format This function makes side effect on input attachment ''' res = dict() res['type'] = 'attachment' res['id'] = attachment['id'] del(attachment['id']) res['u...
[ "def", "normalize_attachment", "(", "attachment", ")", ":", "res", "=", "dict", "(", ")", "res", "[", "'type'", "]", "=", "'attachment'", "res", "[", "'id'", "]", "=", "attachment", "[", "'id'", "]", "del", "(", "attachment", "[", "'id'", "]", ")", "...
Convert attachment metadata from es to archivant format This function makes side effect on input attachment
[ "Convert", "attachment", "metadata", "from", "es", "to", "archivant", "format" ]
55d529435baf4c05a86b8341899e9f5e14e50245
https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/archivant/archivant.py#L128-L140
47,543
insomnia-lab/libreant
archivant/archivant.py
Archivant.denormalize_volume
def denormalize_volume(volume): '''convert volume metadata from archivant to es format''' id = volume.get('id', None) res = dict() res.update(volume['metadata']) denorm_attachments = list() for a in volume['attachments']: denorm_attachments.append(Archivant.de...
python
def denormalize_volume(volume): '''convert volume metadata from archivant to es format''' id = volume.get('id', None) res = dict() res.update(volume['metadata']) denorm_attachments = list() for a in volume['attachments']: denorm_attachments.append(Archivant.de...
[ "def", "denormalize_volume", "(", "volume", ")", ":", "id", "=", "volume", ".", "get", "(", "'id'", ",", "None", ")", "res", "=", "dict", "(", ")", "res", ".", "update", "(", "volume", "[", "'metadata'", "]", ")", "denorm_attachments", "=", "list", "...
convert volume metadata from archivant to es format
[ "convert", "volume", "metadata", "from", "archivant", "to", "es", "format" ]
55d529435baf4c05a86b8341899e9f5e14e50245
https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/archivant/archivant.py#L143-L152
47,544
insomnia-lab/libreant
archivant/archivant.py
Archivant.denormalize_attachment
def denormalize_attachment(attachment): '''convert attachment metadata from archivant to es format''' res = dict() ext = ['id', 'url'] for k in ext: if k in attachment['metadata']: raise ValueError("metadata section could not contain special key '{}'".format(k...
python
def denormalize_attachment(attachment): '''convert attachment metadata from archivant to es format''' res = dict() ext = ['id', 'url'] for k in ext: if k in attachment['metadata']: raise ValueError("metadata section could not contain special key '{}'".format(k...
[ "def", "denormalize_attachment", "(", "attachment", ")", ":", "res", "=", "dict", "(", ")", "ext", "=", "[", "'id'", ",", "'url'", "]", "for", "k", "in", "ext", ":", "if", "k", "in", "attachment", "[", "'metadata'", "]", ":", "raise", "ValueError", "...
convert attachment metadata from archivant to es format
[ "convert", "attachment", "metadata", "from", "archivant", "to", "es", "format" ]
55d529435baf4c05a86b8341899e9f5e14e50245
https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/archivant/archivant.py#L155-L164
47,545
insomnia-lab/libreant
archivant/archivant.py
Archivant.iter_all_volumes
def iter_all_volumes(self): '''iterate over all stored volumes''' for raw_volume in self._db.iterate_all(): v = self.normalize_volume(raw_volume) del v['score'] yield v
python
def iter_all_volumes(self): '''iterate over all stored volumes''' for raw_volume in self._db.iterate_all(): v = self.normalize_volume(raw_volume) del v['score'] yield v
[ "def", "iter_all_volumes", "(", "self", ")", ":", "for", "raw_volume", "in", "self", ".", "_db", ".", "iterate_all", "(", ")", ":", "v", "=", "self", ".", "normalize_volume", "(", "raw_volume", ")", "del", "v", "[", "'score'", "]", "yield", "v" ]
iterate over all stored volumes
[ "iterate", "over", "all", "stored", "volumes" ]
55d529435baf4c05a86b8341899e9f5e14e50245
https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/archivant/archivant.py#L179-L184
47,546
insomnia-lab/libreant
archivant/archivant.py
Archivant.delete_attachments
def delete_attachments(self, volumeID, attachmentsID): ''' delete attachments from a volume ''' log.debug("deleting attachments from volume '{}': {}".format(volumeID, attachmentsID)) rawVolume = self._req_raw_volume(volumeID) insID = [a['id'] for a in rawVolume['_source']['_attachments']...
python
def delete_attachments(self, volumeID, attachmentsID): ''' delete attachments from a volume ''' log.debug("deleting attachments from volume '{}': {}".format(volumeID, attachmentsID)) rawVolume = self._req_raw_volume(volumeID) insID = [a['id'] for a in rawVolume['_source']['_attachments']...
[ "def", "delete_attachments", "(", "self", ",", "volumeID", ",", "attachmentsID", ")", ":", "log", ".", "debug", "(", "\"deleting attachments from volume '{}': {}\"", ".", "format", "(", "volumeID", ",", "attachmentsID", ")", ")", "rawVolume", "=", "self", ".", "...
delete attachments from a volume
[ "delete", "attachments", "from", "a", "volume" ]
55d529435baf4c05a86b8341899e9f5e14e50245
https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/archivant/archivant.py#L203-L214
47,547
insomnia-lab/libreant
archivant/archivant.py
Archivant.insert_attachments
def insert_attachments(self, volumeID, attachments): ''' add attachments to an already existing volume ''' log.debug("adding new attachments to volume '{}': {}".format(volumeID, attachments)) if not attachments: return rawVolume = self._req_raw_volume(volumeID) attsID...
python
def insert_attachments(self, volumeID, attachments): ''' add attachments to an already existing volume ''' log.debug("adding new attachments to volume '{}': {}".format(volumeID, attachments)) if not attachments: return rawVolume = self._req_raw_volume(volumeID) attsID...
[ "def", "insert_attachments", "(", "self", ",", "volumeID", ",", "attachments", ")", ":", "log", ".", "debug", "(", "\"adding new attachments to volume '{}': {}\"", ".", "format", "(", "volumeID", ",", "attachments", ")", ")", "if", "not", "attachments", ":", "re...
add attachments to an already existing volume
[ "add", "attachments", "to", "an", "already", "existing", "volume" ]
55d529435baf4c05a86b8341899e9f5e14e50245
https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/archivant/archivant.py#L223-L239
47,548
insomnia-lab/libreant
archivant/archivant.py
Archivant.insert_volume
def insert_volume(self, metadata, attachments=[]): '''Insert a new volume Returns the ID of the added volume `metadata` must be a dict containg metadata of the volume:: { "_language" : "it", # language of the metadata "key1" : "value1", # attribute ...
python
def insert_volume(self, metadata, attachments=[]): '''Insert a new volume Returns the ID of the added volume `metadata` must be a dict containg metadata of the volume:: { "_language" : "it", # language of the metadata "key1" : "value1", # attribute ...
[ "def", "insert_volume", "(", "self", ",", "metadata", ",", "attachments", "=", "[", "]", ")", ":", "log", ".", "debug", "(", "\"adding new volume:\\n\\tdata: {}\\n\\tfiles: {}\"", ".", "format", "(", "metadata", ",", "attachments", ")", ")", "requiredFields", "=...
Insert a new volume Returns the ID of the added volume `metadata` must be a dict containg metadata of the volume:: { "_language" : "it", # language of the metadata "key1" : "value1", # attribute "key2" : "value2", ... ...
[ "Insert", "a", "new", "volume" ]
55d529435baf4c05a86b8341899e9f5e14e50245
https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/archivant/archivant.py#L241-L292
47,549
insomnia-lab/libreant
archivant/archivant.py
Archivant._assemble_attachment
def _assemble_attachment(self, file, metadata): ''' store file and return a dict containing assembled metadata param `file` must be a path or a File Object param `metadata` must be a dict: { "name" : "nome_buffo.ext" # name of the file (extensi...
python
def _assemble_attachment(self, file, metadata): ''' store file and return a dict containing assembled metadata param `file` must be a path or a File Object param `metadata` must be a dict: { "name" : "nome_buffo.ext" # name of the file (extensi...
[ "def", "_assemble_attachment", "(", "self", ",", "file", ",", "metadata", ")", ":", "res", "=", "dict", "(", ")", "if", "isinstance", "(", "file", ",", "basestring", ")", "and", "os", ".", "path", ".", "isfile", "(", "file", ")", ":", "res", "[", "...
store file and return a dict containing assembled metadata param `file` must be a path or a File Object param `metadata` must be a dict: { "name" : "nome_buffo.ext" # name of the file (extension included) [optional if a path was given] ...
[ "store", "file", "and", "return", "a", "dict", "containing", "assembled", "metadata" ]
55d529435baf4c05a86b8341899e9f5e14e50245
https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/archivant/archivant.py#L294-L338
47,550
insomnia-lab/libreant
archivant/archivant.py
Archivant.update_volume
def update_volume(self, volumeID, metadata): '''update existing volume metadata the given metadata will substitute the old one ''' log.debug('updating volume metadata: {}'.format(volumeID)) rawVolume = self._req_raw_volume(volumeID) normalized = self.normalize_volume(r...
python
def update_volume(self, volumeID, metadata): '''update existing volume metadata the given metadata will substitute the old one ''' log.debug('updating volume metadata: {}'.format(volumeID)) rawVolume = self._req_raw_volume(volumeID) normalized = self.normalize_volume(r...
[ "def", "update_volume", "(", "self", ",", "volumeID", ",", "metadata", ")", ":", "log", ".", "debug", "(", "'updating volume metadata: {}'", ".", "format", "(", "volumeID", ")", ")", "rawVolume", "=", "self", ".", "_req_raw_volume", "(", "volumeID", ")", "no...
update existing volume metadata the given metadata will substitute the old one
[ "update", "existing", "volume", "metadata", "the", "given", "metadata", "will", "substitute", "the", "old", "one" ]
55d529435baf4c05a86b8341899e9f5e14e50245
https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/archivant/archivant.py#L340-L349
47,551
insomnia-lab/libreant
archivant/archivant.py
Archivant.update_attachment
def update_attachment(self, volumeID, attachmentID, metadata): '''update an existing attachment the given metadata dict will be merged with the old one. only the following fields could be updated: [name, mime, notes, download_count] ''' log.debug('updating metadata of at...
python
def update_attachment(self, volumeID, attachmentID, metadata): '''update an existing attachment the given metadata dict will be merged with the old one. only the following fields could be updated: [name, mime, notes, download_count] ''' log.debug('updating metadata of at...
[ "def", "update_attachment", "(", "self", ",", "volumeID", ",", "attachmentID", ",", "metadata", ")", ":", "log", ".", "debug", "(", "'updating metadata of attachment {} from volume {}'", ".", "format", "(", "attachmentID", ",", "volumeID", ")", ")", "modifiable_fiel...
update an existing attachment the given metadata dict will be merged with the old one. only the following fields could be updated: [name, mime, notes, download_count]
[ "update", "an", "existing", "attachment" ]
55d529435baf4c05a86b8341899e9f5e14e50245
https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/archivant/archivant.py#L351-L377
47,552
insomnia-lab/libreant
archivant/archivant.py
Archivant.dangling_files
def dangling_files(self): '''iterate over fsdb files no more attached to any volume''' for fid in self._fsdb: if not self._db.file_is_attached('fsdb:///' + fid): yield fid
python
def dangling_files(self): '''iterate over fsdb files no more attached to any volume''' for fid in self._fsdb: if not self._db.file_is_attached('fsdb:///' + fid): yield fid
[ "def", "dangling_files", "(", "self", ")", ":", "for", "fid", "in", "self", ".", "_fsdb", ":", "if", "not", "self", ".", "_db", ".", "file_is_attached", "(", "'fsdb:///'", "+", "fid", ")", ":", "yield", "fid" ]
iterate over fsdb files no more attached to any volume
[ "iterate", "over", "fsdb", "files", "no", "more", "attached", "to", "any", "volume" ]
55d529435baf4c05a86b8341899e9f5e14e50245
https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/archivant/archivant.py#L386-L390
47,553
pricingassistant/mongokat
mongokat/_bson/__init__.py
_get_string
def _get_string(data, position, obj_end, dummy): """Decode a BSON string to python unicode string.""" length = _UNPACK_INT(data[position:position + 4])[0] position += 4 if length < 1 or obj_end - position < length: raise InvalidBSON("invalid string length") end = position + length - 1 if...
python
def _get_string(data, position, obj_end, dummy): """Decode a BSON string to python unicode string.""" length = _UNPACK_INT(data[position:position + 4])[0] position += 4 if length < 1 or obj_end - position < length: raise InvalidBSON("invalid string length") end = position + length - 1 if...
[ "def", "_get_string", "(", "data", ",", "position", ",", "obj_end", ",", "dummy", ")", ":", "length", "=", "_UNPACK_INT", "(", "data", "[", "position", ":", "position", "+", "4", "]", ")", "[", "0", "]", "position", "+=", "4", "if", "length", "<", ...
Decode a BSON string to python unicode string.
[ "Decode", "a", "BSON", "string", "to", "python", "unicode", "string", "." ]
61eaf4bc1c4cc359c6f9592ec97b9a04d9561411
https://github.com/pricingassistant/mongokat/blob/61eaf4bc1c4cc359c6f9592ec97b9a04d9561411/mongokat/_bson/__init__.py#L115-L124
47,554
pricingassistant/mongokat
mongokat/_bson/__init__.py
_get_regex
def _get_regex(data, position, dummy0, dummy1): """Decode a BSON regex to bson.regex.Regex or a python pattern object.""" pattern, position = _get_c_string(data, position) bson_flags, position = _get_c_string(data, position) bson_re = Regex(pattern, bson_flags) return bson_re, position
python
def _get_regex(data, position, dummy0, dummy1): """Decode a BSON regex to bson.regex.Regex or a python pattern object.""" pattern, position = _get_c_string(data, position) bson_flags, position = _get_c_string(data, position) bson_re = Regex(pattern, bson_flags) return bson_re, position
[ "def", "_get_regex", "(", "data", ",", "position", ",", "dummy0", ",", "dummy1", ")", ":", "pattern", ",", "position", "=", "_get_c_string", "(", "data", ",", "position", ")", "bson_flags", ",", "position", "=", "_get_c_string", "(", "data", ",", "position...
Decode a BSON regex to bson.regex.Regex or a python pattern object.
[ "Decode", "a", "BSON", "regex", "to", "bson", ".", "regex", ".", "Regex", "or", "a", "python", "pattern", "object", "." ]
61eaf4bc1c4cc359c6f9592ec97b9a04d9561411
https://github.com/pricingassistant/mongokat/blob/61eaf4bc1c4cc359c6f9592ec97b9a04d9561411/mongokat/_bson/__init__.py#L240-L245
47,555
pricingassistant/mongokat
mongokat/_bson/__init__.py
_encode_mapping
def _encode_mapping(name, value, check_keys, opts): """Encode a mapping type.""" data = b"".join([_element_to_bson(key, val, check_keys, opts) for key, val in iteritems(value)]) return b"\x03" + name + _PACK_INT(len(data) + 5) + data + b"\x00"
python
def _encode_mapping(name, value, check_keys, opts): """Encode a mapping type.""" data = b"".join([_element_to_bson(key, val, check_keys, opts) for key, val in iteritems(value)]) return b"\x03" + name + _PACK_INT(len(data) + 5) + data + b"\x00"
[ "def", "_encode_mapping", "(", "name", ",", "value", ",", "check_keys", ",", "opts", ")", ":", "data", "=", "b\"\"", ".", "join", "(", "[", "_element_to_bson", "(", "key", ",", "val", ",", "check_keys", ",", "opts", ")", "for", "key", ",", "val", "in...
Encode a mapping type.
[ "Encode", "a", "mapping", "type", "." ]
61eaf4bc1c4cc359c6f9592ec97b9a04d9561411
https://github.com/pricingassistant/mongokat/blob/61eaf4bc1c4cc359c6f9592ec97b9a04d9561411/mongokat/_bson/__init__.py#L430-L434
47,556
pricingassistant/mongokat
mongokat/_bson/__init__.py
_encode_code
def _encode_code(name, value, dummy, opts): """Encode bson.code.Code.""" cstring = _make_c_string(value) cstrlen = len(cstring) if not value.scope: return b"\x0D" + name + _PACK_INT(cstrlen) + cstring scope = _dict_to_bson(value.scope, False, opts, False) full_length = _PACK_INT(8 + cstr...
python
def _encode_code(name, value, dummy, opts): """Encode bson.code.Code.""" cstring = _make_c_string(value) cstrlen = len(cstring) if not value.scope: return b"\x0D" + name + _PACK_INT(cstrlen) + cstring scope = _dict_to_bson(value.scope, False, opts, False) full_length = _PACK_INT(8 + cstr...
[ "def", "_encode_code", "(", "name", ",", "value", ",", "dummy", ",", "opts", ")", ":", "cstring", "=", "_make_c_string", "(", "value", ")", "cstrlen", "=", "len", "(", "cstring", ")", "if", "not", "value", ".", "scope", ":", "return", "b\"\\x0D\"", "+"...
Encode bson.code.Code.
[ "Encode", "bson", ".", "code", ".", "Code", "." ]
61eaf4bc1c4cc359c6f9592ec97b9a04d9561411
https://github.com/pricingassistant/mongokat/blob/61eaf4bc1c4cc359c6f9592ec97b9a04d9561411/mongokat/_bson/__init__.py#L551-L559
47,557
insomnia-lab/libreant
users/models.py
Capability.simToReg
def simToReg(self, sim): """Convert simplified domain expression to regular expression""" # remove initial slash if present res = re.sub('^/', '', sim) res = re.sub('/$', '', res) return '^/?' + re.sub('\*', '[^/]+', res) + '/?$'
python
def simToReg(self, sim): """Convert simplified domain expression to regular expression""" # remove initial slash if present res = re.sub('^/', '', sim) res = re.sub('/$', '', res) return '^/?' + re.sub('\*', '[^/]+', res) + '/?$'
[ "def", "simToReg", "(", "self", ",", "sim", ")", ":", "# remove initial slash if present", "res", "=", "re", ".", "sub", "(", "'^/'", ",", "''", ",", "sim", ")", "res", "=", "re", ".", "sub", "(", "'/$'", ",", "''", ",", "res", ")", "return", "'^/?...
Convert simplified domain expression to regular expression
[ "Convert", "simplified", "domain", "expression", "to", "regular", "expression" ]
55d529435baf4c05a86b8341899e9f5e14e50245
https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/users/models.py#L61-L66
47,558
insomnia-lab/libreant
users/models.py
Capability.match
def match(self, dom, act): """ Check if the given `domain` and `act` are allowed by this capability """ return self.match_domain(dom) and self.match_action(act)
python
def match(self, dom, act): """ Check if the given `domain` and `act` are allowed by this capability """ return self.match_domain(dom) and self.match_action(act)
[ "def", "match", "(", "self", ",", "dom", ",", "act", ")", ":", "return", "self", ".", "match_domain", "(", "dom", ")", "and", "self", ".", "match_action", "(", "act", ")" ]
Check if the given `domain` and `act` are allowed by this capability
[ "Check", "if", "the", "given", "domain", "and", "act", "are", "allowed", "by", "this", "capability" ]
55d529435baf4c05a86b8341899e9f5e14e50245
https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/users/models.py#L81-L86
47,559
insomnia-lab/libreant
users/models.py
Action.to_list
def to_list(self): '''convert an actions bitmask into a list of action strings''' res = [] for a in self.__class__.ACTIONS: aBit = self.__class__.action_bitmask(a) if ((self & aBit) == aBit): res.append(a) return res
python
def to_list(self): '''convert an actions bitmask into a list of action strings''' res = [] for a in self.__class__.ACTIONS: aBit = self.__class__.action_bitmask(a) if ((self & aBit) == aBit): res.append(a) return res
[ "def", "to_list", "(", "self", ")", ":", "res", "=", "[", "]", "for", "a", "in", "self", ".", "__class__", ".", "ACTIONS", ":", "aBit", "=", "self", ".", "__class__", ".", "action_bitmask", "(", "a", ")", "if", "(", "(", "self", "&", "aBit", ")",...
convert an actions bitmask into a list of action strings
[ "convert", "an", "actions", "bitmask", "into", "a", "list", "of", "action", "strings" ]
55d529435baf4c05a86b8341899e9f5e14e50245
https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/users/models.py#L115-L122
47,560
insomnia-lab/libreant
users/models.py
Action.from_list
def from_list(cls, actions): '''convert list of actions into the corresponding bitmask''' bitmask = 0 for a in actions: bitmask |= cls.action_bitmask(a) return Action(bitmask)
python
def from_list(cls, actions): '''convert list of actions into the corresponding bitmask''' bitmask = 0 for a in actions: bitmask |= cls.action_bitmask(a) return Action(bitmask)
[ "def", "from_list", "(", "cls", ",", "actions", ")", ":", "bitmask", "=", "0", "for", "a", "in", "actions", ":", "bitmask", "|=", "cls", ".", "action_bitmask", "(", "a", ")", "return", "Action", "(", "bitmask", ")" ]
convert list of actions into the corresponding bitmask
[ "convert", "list", "of", "actions", "into", "the", "corresponding", "bitmask" ]
55d529435baf4c05a86b8341899e9f5e14e50245
https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/users/models.py#L125-L130
47,561
chaoss/grimoirelab-manuscripts
manuscripts2/utils.py
str_val
def str_val(val): """ Format the value of a metric value to a string :param val: number to be formatted :return: a string with the formatted value """ str_val = val if val is None: str_val = "NA" elif type(val) == float: str_val = '%0.2f' % val else: str_val ...
python
def str_val(val): """ Format the value of a metric value to a string :param val: number to be formatted :return: a string with the formatted value """ str_val = val if val is None: str_val = "NA" elif type(val) == float: str_val = '%0.2f' % val else: str_val ...
[ "def", "str_val", "(", "val", ")", ":", "str_val", "=", "val", "if", "val", "is", "None", ":", "str_val", "=", "\"NA\"", "elif", "type", "(", "val", ")", "==", "float", ":", "str_val", "=", "'%0.2f'", "%", "val", "else", ":", "str_val", "=", "str",...
Format the value of a metric value to a string :param val: number to be formatted :return: a string with the formatted value
[ "Format", "the", "value", "of", "a", "metric", "value", "to", "a", "string" ]
94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9
https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts2/utils.py#L43-L57
47,562
insomnia-lab/libreant
cli/__init__.py
load_cfg
def load_cfg(path, envvar_prefix='LIBREANT_', debug=False): '''wrapper of config_utils.load_configs''' try: return load_configs(envvar_prefix, path=path) except Exception as e: if debug: raise else: die(str(e))
python
def load_cfg(path, envvar_prefix='LIBREANT_', debug=False): '''wrapper of config_utils.load_configs''' try: return load_configs(envvar_prefix, path=path) except Exception as e: if debug: raise else: die(str(e))
[ "def", "load_cfg", "(", "path", ",", "envvar_prefix", "=", "'LIBREANT_'", ",", "debug", "=", "False", ")", ":", "try", ":", "return", "load_configs", "(", "envvar_prefix", ",", "path", "=", "path", ")", "except", "Exception", "as", "e", ":", "if", "debug...
wrapper of config_utils.load_configs
[ "wrapper", "of", "config_utils", ".", "load_configs" ]
55d529435baf4c05a86b8341899e9f5e14e50245
https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/cli/__init__.py#L17-L25
47,563
chaoss/grimoirelab-manuscripts
setup.py
files_in_subdir
def files_in_subdir(dir, subdir): """Find all files in a directory.""" paths = [] for (path, dirs, files) in os.walk(os.path.join(dir, subdir)): for file in files: paths.append(os.path.relpath(os.path.join(path, file), dir)) return paths
python
def files_in_subdir(dir, subdir): """Find all files in a directory.""" paths = [] for (path, dirs, files) in os.walk(os.path.join(dir, subdir)): for file in files: paths.append(os.path.relpath(os.path.join(path, file), dir)) return paths
[ "def", "files_in_subdir", "(", "dir", ",", "subdir", ")", ":", "paths", "=", "[", "]", "for", "(", "path", ",", "dirs", ",", "files", ")", "in", "os", ".", "walk", "(", "os", ".", "path", ".", "join", "(", "dir", ",", "subdir", ")", ")", ":", ...
Find all files in a directory.
[ "Find", "all", "files", "in", "a", "directory", "." ]
94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9
https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/setup.py#L49-L55
47,564
chaoss/grimoirelab-manuscripts
manuscripts2/metrics/git.py
overview
def overview(index, start, end): """Compute metrics in the overview section for enriched git indexes. Returns a dictionary. Each key in the dictionary is the name of a metric, the value is the value of that metric. Value can be a complex object (eg, a time series). :param index: index object :...
python
def overview(index, start, end): """Compute metrics in the overview section for enriched git indexes. Returns a dictionary. Each key in the dictionary is the name of a metric, the value is the value of that metric. Value can be a complex object (eg, a time series). :param index: index object :...
[ "def", "overview", "(", "index", ",", "start", ",", "end", ")", ":", "results", "=", "{", "\"activity_metrics\"", ":", "[", "Commits", "(", "index", ",", "start", ",", "end", ")", "]", ",", "\"author_metrics\"", ":", "[", "Authors", "(", "index", ",", ...
Compute metrics in the overview section for enriched git indexes. Returns a dictionary. Each key in the dictionary is the name of a metric, the value is the value of that metric. Value can be a complex object (eg, a time series). :param index: index object :param start: start date to get the data ...
[ "Compute", "metrics", "in", "the", "overview", "section", "for", "enriched", "git", "indexes", "." ]
94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9
https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts2/metrics/git.py#L145-L166
47,565
chaoss/grimoirelab-manuscripts
manuscripts2/metrics/git.py
project_activity
def project_activity(index, start, end): """Compute the metrics for the project activity section of the enriched git index. Returns a dictionary containing a "metric" key. This key contains the metrics for this section. :param index: index object :param start: start date to get the data from ...
python
def project_activity(index, start, end): """Compute the metrics for the project activity section of the enriched git index. Returns a dictionary containing a "metric" key. This key contains the metrics for this section. :param index: index object :param start: start date to get the data from ...
[ "def", "project_activity", "(", "index", ",", "start", ",", "end", ")", ":", "results", "=", "{", "\"metrics\"", ":", "[", "Commits", "(", "index", ",", "start", ",", "end", ")", ",", "Authors", "(", "index", ",", "start", ",", "end", ")", "]", "}"...
Compute the metrics for the project activity section of the enriched git index. Returns a dictionary containing a "metric" key. This key contains the metrics for this section. :param index: index object :param start: start date to get the data from :param end: end date to get the data upto ...
[ "Compute", "the", "metrics", "for", "the", "project", "activity", "section", "of", "the", "enriched", "git", "index", "." ]
94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9
https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts2/metrics/git.py#L169-L187
47,566
chaoss/grimoirelab-manuscripts
manuscripts2/metrics/git.py
project_community
def project_community(index, start, end): """Compute the metrics for the project community section of the enriched git index. Returns a dictionary containing "author_metrics", "people_top_metrics" and "orgs_top_metrics" as the keys and the related Metrics as the values. :param index: index object ...
python
def project_community(index, start, end): """Compute the metrics for the project community section of the enriched git index. Returns a dictionary containing "author_metrics", "people_top_metrics" and "orgs_top_metrics" as the keys and the related Metrics as the values. :param index: index object ...
[ "def", "project_community", "(", "index", ",", "start", ",", "end", ")", ":", "results", "=", "{", "\"author_metrics\"", ":", "[", "Authors", "(", "index", ",", "start", ",", "end", ")", "]", ",", "\"people_top_metrics\"", ":", "[", "Authors", "(", "inde...
Compute the metrics for the project community section of the enriched git index. Returns a dictionary containing "author_metrics", "people_top_metrics" and "orgs_top_metrics" as the keys and the related Metrics as the values. :param index: index object :param start: start date to get the data from...
[ "Compute", "the", "metrics", "for", "the", "project", "community", "section", "of", "the", "enriched", "git", "index", "." ]
94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9
https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts2/metrics/git.py#L190-L209
47,567
chaoss/grimoirelab-manuscripts
manuscripts2/metrics/git.py
Authors.aggregations
def aggregations(self): """ Override parent method. Obtain list of the terms and their corresponding values using "terms" aggregations for the previous time period. :returns: a data frame containing terms and their corresponding values """ prev_month_start = get_prev_mo...
python
def aggregations(self): """ Override parent method. Obtain list of the terms and their corresponding values using "terms" aggregations for the previous time period. :returns: a data frame containing terms and their corresponding values """ prev_month_start = get_prev_mo...
[ "def", "aggregations", "(", "self", ")", ":", "prev_month_start", "=", "get_prev_month", "(", "self", ".", "end", ",", "self", ".", "query", ".", "interval_", ")", "self", ".", "query", ".", "since", "(", "prev_month_start", ")", "self", ".", "query", "....
Override parent method. Obtain list of the terms and their corresponding values using "terms" aggregations for the previous time period. :returns: a data frame containing terms and their corresponding values
[ "Override", "parent", "method", ".", "Obtain", "list", "of", "the", "terms", "and", "their", "corresponding", "values", "using", "terms", "aggregations", "for", "the", "previous", "time", "period", "." ]
94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9
https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts2/metrics/git.py#L94-L105
47,568
chaoss/grimoirelab-manuscripts
manuscripts2/metrics/github_issues.py
project_activity
def project_activity(index, start, end): """Compute the metrics for the project activity section of the enriched github issues index. Returns a dictionary containing a "metric" key. This key contains the metrics for this section. :param index: index object :param start: start date to get the d...
python
def project_activity(index, start, end): """Compute the metrics for the project activity section of the enriched github issues index. Returns a dictionary containing a "metric" key. This key contains the metrics for this section. :param index: index object :param start: start date to get the d...
[ "def", "project_activity", "(", "index", ",", "start", ",", "end", ")", ":", "results", "=", "{", "\"metrics\"", ":", "[", "OpenedIssues", "(", "index", ",", "start", ",", "end", ")", ",", "ClosedIssues", "(", "index", ",", "start", ",", "end", ")", ...
Compute the metrics for the project activity section of the enriched github issues index. Returns a dictionary containing a "metric" key. This key contains the metrics for this section. :param index: index object :param start: start date to get the data from :param end: end date to get the dat...
[ "Compute", "the", "metrics", "for", "the", "project", "activity", "section", "of", "the", "enriched", "github", "issues", "index", "." ]
94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9
https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts2/metrics/github_issues.py#L243-L261
47,569
chaoss/grimoirelab-manuscripts
manuscripts2/metrics/github_issues.py
BMI.aggregations
def aggregations(self): """Get the aggregation value for BMI with respect to the previous time interval.""" prev_month_start = get_prev_month(self.end, self.closed.query.interval_) self.closed.query.since(prev_month_start, ...
python
def aggregations(self): """Get the aggregation value for BMI with respect to the previous time interval.""" prev_month_start = get_prev_month(self.end, self.closed.query.interval_) self.closed.query.since(prev_month_start, ...
[ "def", "aggregations", "(", "self", ")", ":", "prev_month_start", "=", "get_prev_month", "(", "self", ".", "end", ",", "self", ".", "closed", ".", "query", ".", "interval_", ")", "self", ".", "closed", ".", "query", ".", "since", "(", "prev_month_start", ...
Get the aggregation value for BMI with respect to the previous time interval.
[ "Get", "the", "aggregation", "value", "for", "BMI", "with", "respect", "to", "the", "previous", "time", "interval", "." ]
94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9
https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts2/metrics/github_issues.py#L193-L208
47,570
openearth/bmi-python
bmi/wrapper.py
c_log
def c_log(level, message): """python logger to be called from fortran""" c_level = level level = LEVELS_F2PY[c_level] logger.log(level, message)
python
def c_log(level, message): """python logger to be called from fortran""" c_level = level level = LEVELS_F2PY[c_level] logger.log(level, message)
[ "def", "c_log", "(", "level", ",", "message", ")", ":", "c_level", "=", "level", "level", "=", "LEVELS_F2PY", "[", "c_level", "]", "logger", ".", "log", "(", "level", ",", "message", ")" ]
python logger to be called from fortran
[ "python", "logger", "to", "be", "called", "from", "fortran" ]
2f53f24d45515eb0711c2d28ddd6c1582045248f
https://github.com/openearth/bmi-python/blob/2f53f24d45515eb0711c2d28ddd6c1582045248f/bmi/wrapper.py#L79-L83
47,571
openearth/bmi-python
bmi/wrapper.py
struct2dict
def struct2dict(struct): """convert a ctypes structure to a dictionary""" return {x: getattr(struct, x) for x in dict(struct._fields_).keys()}
python
def struct2dict(struct): """convert a ctypes structure to a dictionary""" return {x: getattr(struct, x) for x in dict(struct._fields_).keys()}
[ "def", "struct2dict", "(", "struct", ")", ":", "return", "{", "x", ":", "getattr", "(", "struct", ",", "x", ")", "for", "x", "in", "dict", "(", "struct", ".", "_fields_", ")", ".", "keys", "(", ")", "}" ]
convert a ctypes structure to a dictionary
[ "convert", "a", "ctypes", "structure", "to", "a", "dictionary" ]
2f53f24d45515eb0711c2d28ddd6c1582045248f
https://github.com/openearth/bmi-python/blob/2f53f24d45515eb0711c2d28ddd6c1582045248f/bmi/wrapper.py#L113-L115
47,572
openearth/bmi-python
bmi/wrapper.py
structs2records
def structs2records(structs): """convert one or more structs and generate dictionaries""" try: n = len(structs) except TypeError: # no array yield struct2dict(structs) # just 1 return for i in range(n): struct = structs[i] yield struct2dict(struct)
python
def structs2records(structs): """convert one or more structs and generate dictionaries""" try: n = len(structs) except TypeError: # no array yield struct2dict(structs) # just 1 return for i in range(n): struct = structs[i] yield struct2dict(struct)
[ "def", "structs2records", "(", "structs", ")", ":", "try", ":", "n", "=", "len", "(", "structs", ")", "except", "TypeError", ":", "# no array", "yield", "struct2dict", "(", "structs", ")", "# just 1", "return", "for", "i", "in", "range", "(", "n", ")", ...
convert one or more structs and generate dictionaries
[ "convert", "one", "or", "more", "structs", "and", "generate", "dictionaries" ]
2f53f24d45515eb0711c2d28ddd6c1582045248f
https://github.com/openearth/bmi-python/blob/2f53f24d45515eb0711c2d28ddd6c1582045248f/bmi/wrapper.py#L118-L129
47,573
openearth/bmi-python
bmi/wrapper.py
structs2pandas
def structs2pandas(structs): """convert ctypes structure or structure array to pandas data frame""" try: import pandas records = list(structs2records(structs)) df = pandas.DataFrame.from_records(records) # TODO: do this for string columns, for now just for id # How can we...
python
def structs2pandas(structs): """convert ctypes structure or structure array to pandas data frame""" try: import pandas records = list(structs2records(structs)) df = pandas.DataFrame.from_records(records) # TODO: do this for string columns, for now just for id # How can we...
[ "def", "structs2pandas", "(", "structs", ")", ":", "try", ":", "import", "pandas", "records", "=", "list", "(", "structs2records", "(", "structs", ")", ")", "df", "=", "pandas", ".", "DataFrame", ".", "from_records", "(", "records", ")", "# TODO: do this for...
convert ctypes structure or structure array to pandas data frame
[ "convert", "ctypes", "structure", "or", "structure", "array", "to", "pandas", "data", "frame" ]
2f53f24d45515eb0711c2d28ddd6c1582045248f
https://github.com/openearth/bmi-python/blob/2f53f24d45515eb0711c2d28ddd6c1582045248f/bmi/wrapper.py#L132-L146
47,574
openearth/bmi-python
bmi/wrapper.py
wrap
def wrap(func): """Return wrapped function with type conversion and sanity checks. """ @functools.wraps(func, assigned=('restype', 'argtypes')) def wrapped(*args): if len(args) != len(func.argtypes): logger.warn("{} {} not of same length", args, func.argtypes)...
python
def wrap(func): """Return wrapped function with type conversion and sanity checks. """ @functools.wraps(func, assigned=('restype', 'argtypes')) def wrapped(*args): if len(args) != len(func.argtypes): logger.warn("{} {} not of same length", args, func.argtypes)...
[ "def", "wrap", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ",", "assigned", "=", "(", "'restype'", ",", "'argtypes'", ")", ")", "def", "wrapped", "(", "*", "args", ")", ":", "if", "len", "(", "args", ")", "!=", "len", "(",...
Return wrapped function with type conversion and sanity checks.
[ "Return", "wrapped", "function", "with", "type", "conversion", "and", "sanity", "checks", "." ]
2f53f24d45515eb0711c2d28ddd6c1582045248f
https://github.com/openearth/bmi-python/blob/2f53f24d45515eb0711c2d28ddd6c1582045248f/bmi/wrapper.py#L149-L176
47,575
openearth/bmi-python
bmi/wrapper.py
BMIWrapper._libname
def _libname(self): """Return platform-specific modelf90 shared library name.""" prefix = 'lib' suffix = '.so' if platform.system() == 'Darwin': suffix = '.dylib' if platform.system() == 'Windows': prefix = '' suffix = '.dll' return pre...
python
def _libname(self): """Return platform-specific modelf90 shared library name.""" prefix = 'lib' suffix = '.so' if platform.system() == 'Darwin': suffix = '.dylib' if platform.system() == 'Windows': prefix = '' suffix = '.dll' return pre...
[ "def", "_libname", "(", "self", ")", ":", "prefix", "=", "'lib'", "suffix", "=", "'.so'", "if", "platform", ".", "system", "(", ")", "==", "'Darwin'", ":", "suffix", "=", "'.dylib'", "if", "platform", ".", "system", "(", ")", "==", "'Windows'", ":", ...
Return platform-specific modelf90 shared library name.
[ "Return", "platform", "-", "specific", "modelf90", "shared", "library", "name", "." ]
2f53f24d45515eb0711c2d28ddd6c1582045248f
https://github.com/openearth/bmi-python/blob/2f53f24d45515eb0711c2d28ddd6c1582045248f/bmi/wrapper.py#L252-L261
47,576
openearth/bmi-python
bmi/wrapper.py
BMIWrapper._library_path
def _library_path(self): """Return full path to the shared library. A couple of regular unix paths like ``/usr/lib/`` is searched by default. If your library is not in one of those, set a ``LD_LIBRARY_PATH`` environment variable to the directory with your shared library. ...
python
def _library_path(self): """Return full path to the shared library. A couple of regular unix paths like ``/usr/lib/`` is searched by default. If your library is not in one of those, set a ``LD_LIBRARY_PATH`` environment variable to the directory with your shared library. ...
[ "def", "_library_path", "(", "self", ")", ":", "# engine is an existing library name", "# TODO change add directory to library path", "if", "os", ".", "path", ".", "isfile", "(", "self", ".", "engine", ")", ":", "return", "self", ".", "engine", "pathname", "=", "'...
Return full path to the shared library. A couple of regular unix paths like ``/usr/lib/`` is searched by default. If your library is not in one of those, set a ``LD_LIBRARY_PATH`` environment variable to the directory with your shared library. If the library cannot be found, a ...
[ "Return", "full", "path", "to", "the", "shared", "library", "." ]
2f53f24d45515eb0711c2d28ddd6c1582045248f
https://github.com/openearth/bmi-python/blob/2f53f24d45515eb0711c2d28ddd6c1582045248f/bmi/wrapper.py#L263-L307
47,577
openearth/bmi-python
bmi/wrapper.py
BMIWrapper._load_library
def _load_library(self): """Return the fortran library, loaded with """ path = self._library_path() logger.info("Loading library from path {}".format(path)) library_dir = os.path.dirname(path) if platform.system() == 'Windows': import win32api olddir = os....
python
def _load_library(self): """Return the fortran library, loaded with """ path = self._library_path() logger.info("Loading library from path {}".format(path)) library_dir = os.path.dirname(path) if platform.system() == 'Windows': import win32api olddir = os....
[ "def", "_load_library", "(", "self", ")", ":", "path", "=", "self", ".", "_library_path", "(", ")", "logger", ".", "info", "(", "\"Loading library from path {}\"", ".", "format", "(", "path", ")", ")", "library_dir", "=", "os", ".", "path", ".", "dirname",...
Return the fortran library, loaded with
[ "Return", "the", "fortran", "library", "loaded", "with" ]
2f53f24d45515eb0711c2d28ddd6c1582045248f
https://github.com/openearth/bmi-python/blob/2f53f24d45515eb0711c2d28ddd6c1582045248f/bmi/wrapper.py#L309-L325
47,578
openearth/bmi-python
bmi/wrapper.py
BMIWrapper.finalize
def finalize(self): """Shutdown the library and clean up the model. Note that the Fortran library's cleanup code is not up to snuff yet, so the cleanup is not perfect. Note also that the working directory is changed back to the original one. """ self.library.finalize.ar...
python
def finalize(self): """Shutdown the library and clean up the model. Note that the Fortran library's cleanup code is not up to snuff yet, so the cleanup is not perfect. Note also that the working directory is changed back to the original one. """ self.library.finalize.ar...
[ "def", "finalize", "(", "self", ")", ":", "self", ".", "library", ".", "finalize", ".", "argtypes", "=", "[", "]", "self", ".", "library", ".", "finalize", ".", "restype", "=", "c_int", "ierr", "=", "wrap", "(", "self", ".", "library", ".", "finalize...
Shutdown the library and clean up the model. Note that the Fortran library's cleanup code is not up to snuff yet, so the cleanup is not perfect. Note also that the working directory is changed back to the original one.
[ "Shutdown", "the", "library", "and", "clean", "up", "the", "model", "." ]
2f53f24d45515eb0711c2d28ddd6c1582045248f
https://github.com/openearth/bmi-python/blob/2f53f24d45515eb0711c2d28ddd6c1582045248f/bmi/wrapper.py#L364-L381
47,579
openearth/bmi-python
bmi/wrapper.py
BMIWrapper.get_var_count
def get_var_count(self): """ Return number of variables """ n = c_int() self.library.get_var_count.argtypes = [POINTER(c_int)] self.library.get_var_count(byref(n)) return n.value
python
def get_var_count(self): """ Return number of variables """ n = c_int() self.library.get_var_count.argtypes = [POINTER(c_int)] self.library.get_var_count(byref(n)) return n.value
[ "def", "get_var_count", "(", "self", ")", ":", "n", "=", "c_int", "(", ")", "self", ".", "library", ".", "get_var_count", ".", "argtypes", "=", "[", "POINTER", "(", "c_int", ")", "]", "self", ".", "library", ".", "get_var_count", "(", "byref", "(", "...
Return number of variables
[ "Return", "number", "of", "variables" ]
2f53f24d45515eb0711c2d28ddd6c1582045248f
https://github.com/openearth/bmi-python/blob/2f53f24d45515eb0711c2d28ddd6c1582045248f/bmi/wrapper.py#L400-L407
47,580
openearth/bmi-python
bmi/wrapper.py
BMIWrapper.inq_compound_field
def inq_compound_field(self, name, index): """ Lookup the type,rank and shape of a compound field """ typename = create_string_buffer(name) index = c_int(index + 1) fieldname = create_string_buffer(MAXSTRLEN) fieldtype = create_string_buffer(MAXSTRLEN) ran...
python
def inq_compound_field(self, name, index): """ Lookup the type,rank and shape of a compound field """ typename = create_string_buffer(name) index = c_int(index + 1) fieldname = create_string_buffer(MAXSTRLEN) fieldtype = create_string_buffer(MAXSTRLEN) ran...
[ "def", "inq_compound_field", "(", "self", ",", "name", ",", "index", ")", ":", "typename", "=", "create_string_buffer", "(", "name", ")", "index", "=", "c_int", "(", "index", "+", "1", ")", "fieldname", "=", "create_string_buffer", "(", "MAXSTRLEN", ")", "...
Lookup the type,rank and shape of a compound field
[ "Lookup", "the", "type", "rank", "and", "shape", "of", "a", "compound", "field" ]
2f53f24d45515eb0711c2d28ddd6c1582045248f
https://github.com/openearth/bmi-python/blob/2f53f24d45515eb0711c2d28ddd6c1582045248f/bmi/wrapper.py#L440-L470
47,581
openearth/bmi-python
bmi/wrapper.py
BMIWrapper.make_compound_ctype
def make_compound_ctype(self, varname): """ Create a ctypes type that corresponds to a compound type in memory. """ # look up the type name compoundname = self.get_var_type(varname) nfields = self.inq_compound(compoundname) # for all the fields look up the type, ...
python
def make_compound_ctype(self, varname): """ Create a ctypes type that corresponds to a compound type in memory. """ # look up the type name compoundname = self.get_var_type(varname) nfields = self.inq_compound(compoundname) # for all the fields look up the type, ...
[ "def", "make_compound_ctype", "(", "self", ",", "varname", ")", ":", "# look up the type name", "compoundname", "=", "self", ".", "get_var_type", "(", "varname", ")", "nfields", "=", "self", ".", "inq_compound", "(", "compoundname", ")", "# for all the fields look u...
Create a ctypes type that corresponds to a compound type in memory.
[ "Create", "a", "ctypes", "type", "that", "corresponds", "to", "a", "compound", "type", "in", "memory", "." ]
2f53f24d45515eb0711c2d28ddd6c1582045248f
https://github.com/openearth/bmi-python/blob/2f53f24d45515eb0711c2d28ddd6c1582045248f/bmi/wrapper.py#L472-L504
47,582
openearth/bmi-python
bmi/wrapper.py
BMIWrapper.get_var_rank
def get_var_rank(self, name): """ Return array rank or 0 for scalar. """ name = create_string_buffer(name) rank = c_int() self.library.get_var_rank.argtypes = [c_char_p, POINTER(c_int)] self.library.get_var_rank.restype = None self.library.get_var_rank(nam...
python
def get_var_rank(self, name): """ Return array rank or 0 for scalar. """ name = create_string_buffer(name) rank = c_int() self.library.get_var_rank.argtypes = [c_char_p, POINTER(c_int)] self.library.get_var_rank.restype = None self.library.get_var_rank(nam...
[ "def", "get_var_rank", "(", "self", ",", "name", ")", ":", "name", "=", "create_string_buffer", "(", "name", ")", "rank", "=", "c_int", "(", ")", "self", ".", "library", ".", "get_var_rank", ".", "argtypes", "=", "[", "c_char_p", ",", "POINTER", "(", "...
Return array rank or 0 for scalar.
[ "Return", "array", "rank", "or", "0", "for", "scalar", "." ]
2f53f24d45515eb0711c2d28ddd6c1582045248f
https://github.com/openearth/bmi-python/blob/2f53f24d45515eb0711c2d28ddd6c1582045248f/bmi/wrapper.py#L506-L515
47,583
openearth/bmi-python
bmi/wrapper.py
BMIWrapper.get_var_shape
def get_var_shape(self, name): """ Return shape of the array. """ rank = self.get_var_rank(name) name = create_string_buffer(name) arraytype = ndpointer(dtype='int32', ndim=1, shape=(MAXDIMS, ), ...
python
def get_var_shape(self, name): """ Return shape of the array. """ rank = self.get_var_rank(name) name = create_string_buffer(name) arraytype = ndpointer(dtype='int32', ndim=1, shape=(MAXDIMS, ), ...
[ "def", "get_var_shape", "(", "self", ",", "name", ")", ":", "rank", "=", "self", ".", "get_var_rank", "(", "name", ")", "name", "=", "create_string_buffer", "(", "name", ")", "arraytype", "=", "ndpointer", "(", "dtype", "=", "'int32'", ",", "ndim", "=", ...
Return shape of the array.
[ "Return", "shape", "of", "the", "array", "." ]
2f53f24d45515eb0711c2d28ddd6c1582045248f
https://github.com/openearth/bmi-python/blob/2f53f24d45515eb0711c2d28ddd6c1582045248f/bmi/wrapper.py#L517-L530
47,584
openearth/bmi-python
bmi/wrapper.py
BMIWrapper.get_start_time
def get_start_time(self): """ returns start time """ start_time = c_double() self.library.get_start_time.argtypes = [POINTER(c_double)] self.library.get_start_time.restype = None self.library.get_start_time(byref(start_time)) return start_time.value
python
def get_start_time(self): """ returns start time """ start_time = c_double() self.library.get_start_time.argtypes = [POINTER(c_double)] self.library.get_start_time.restype = None self.library.get_start_time(byref(start_time)) return start_time.value
[ "def", "get_start_time", "(", "self", ")", ":", "start_time", "=", "c_double", "(", ")", "self", ".", "library", ".", "get_start_time", ".", "argtypes", "=", "[", "POINTER", "(", "c_double", ")", "]", "self", ".", "library", ".", "get_start_time", ".", "...
returns start time
[ "returns", "start", "time" ]
2f53f24d45515eb0711c2d28ddd6c1582045248f
https://github.com/openearth/bmi-python/blob/2f53f24d45515eb0711c2d28ddd6c1582045248f/bmi/wrapper.py#L532-L540
47,585
openearth/bmi-python
bmi/wrapper.py
BMIWrapper.get_end_time
def get_end_time(self): """ returns end time of simulation """ end_time = c_double() self.library.get_end_time.argtypes = [POINTER(c_double)] self.library.get_end_time.restype = None self.library.get_end_time(byref(end_time)) return end_time.value
python
def get_end_time(self): """ returns end time of simulation """ end_time = c_double() self.library.get_end_time.argtypes = [POINTER(c_double)] self.library.get_end_time.restype = None self.library.get_end_time(byref(end_time)) return end_time.value
[ "def", "get_end_time", "(", "self", ")", ":", "end_time", "=", "c_double", "(", ")", "self", ".", "library", ".", "get_end_time", ".", "argtypes", "=", "[", "POINTER", "(", "c_double", ")", "]", "self", ".", "library", ".", "get_end_time", ".", "restype"...
returns end time of simulation
[ "returns", "end", "time", "of", "simulation" ]
2f53f24d45515eb0711c2d28ddd6c1582045248f
https://github.com/openearth/bmi-python/blob/2f53f24d45515eb0711c2d28ddd6c1582045248f/bmi/wrapper.py#L542-L550
47,586
openearth/bmi-python
bmi/wrapper.py
BMIWrapper.get_current_time
def get_current_time(self): """ returns current time of simulation """ current_time = c_double() self.library.get_current_time.argtypes = [POINTER(c_double)] self.library.get_current_time.restype = None self.library.get_current_time(byref(current_time)) re...
python
def get_current_time(self): """ returns current time of simulation """ current_time = c_double() self.library.get_current_time.argtypes = [POINTER(c_double)] self.library.get_current_time.restype = None self.library.get_current_time(byref(current_time)) re...
[ "def", "get_current_time", "(", "self", ")", ":", "current_time", "=", "c_double", "(", ")", "self", ".", "library", ".", "get_current_time", ".", "argtypes", "=", "[", "POINTER", "(", "c_double", ")", "]", "self", ".", "library", ".", "get_current_time", ...
returns current time of simulation
[ "returns", "current", "time", "of", "simulation" ]
2f53f24d45515eb0711c2d28ddd6c1582045248f
https://github.com/openearth/bmi-python/blob/2f53f24d45515eb0711c2d28ddd6c1582045248f/bmi/wrapper.py#L552-L560
47,587
openearth/bmi-python
bmi/wrapper.py
BMIWrapper.get_time_step
def get_time_step(self): """ returns current time step of simulation """ time_step = c_double() self.library.get_time_step.argtypes = [POINTER(c_double)] self.library.get_time_step.restype = None self.library.get_time_step(byref(time_step)) return time_ste...
python
def get_time_step(self): """ returns current time step of simulation """ time_step = c_double() self.library.get_time_step.argtypes = [POINTER(c_double)] self.library.get_time_step.restype = None self.library.get_time_step(byref(time_step)) return time_ste...
[ "def", "get_time_step", "(", "self", ")", ":", "time_step", "=", "c_double", "(", ")", "self", ".", "library", ".", "get_time_step", ".", "argtypes", "=", "[", "POINTER", "(", "c_double", ")", "]", "self", ".", "library", ".", "get_time_step", ".", "rest...
returns current time step of simulation
[ "returns", "current", "time", "step", "of", "simulation" ]
2f53f24d45515eb0711c2d28ddd6c1582045248f
https://github.com/openearth/bmi-python/blob/2f53f24d45515eb0711c2d28ddd6c1582045248f/bmi/wrapper.py#L562-L570
47,588
openearth/bmi-python
bmi/wrapper.py
BMIWrapper.get_var
def get_var(self, name): """Return an nd array from model library""" # How many dimensions. rank = self.get_var_rank(name) # The shape array is fixed size shape = np.empty((MAXDIMS, ), dtype='int32', order='F') shape = self.get_var_shape(name) # there should be no...
python
def get_var(self, name): """Return an nd array from model library""" # How many dimensions. rank = self.get_var_rank(name) # The shape array is fixed size shape = np.empty((MAXDIMS, ), dtype='int32', order='F') shape = self.get_var_shape(name) # there should be no...
[ "def", "get_var", "(", "self", ",", "name", ")", ":", "# How many dimensions.", "rank", "=", "self", ".", "get_var_rank", "(", "name", ")", "# The shape array is fixed size", "shape", "=", "np", ".", "empty", "(", "(", "MAXDIMS", ",", ")", ",", "dtype", "=...
Return an nd array from model library
[ "Return", "an", "nd", "array", "from", "model", "library" ]
2f53f24d45515eb0711c2d28ddd6c1582045248f
https://github.com/openearth/bmi-python/blob/2f53f24d45515eb0711c2d28ddd6c1582045248f/bmi/wrapper.py#L572-L617
47,589
openearth/bmi-python
bmi/wrapper.py
BMIWrapper.set_logger
def set_logger(self, logger): """subscribe to fortran log messages""" # we don't expect anything back try: self.library.set_logger.restype = None except AttributeError: logger.warn("Tried to set logger but method is not implemented in %s", self.engine) ...
python
def set_logger(self, logger): """subscribe to fortran log messages""" # we don't expect anything back try: self.library.set_logger.restype = None except AttributeError: logger.warn("Tried to set logger but method is not implemented in %s", self.engine) ...
[ "def", "set_logger", "(", "self", ",", "logger", ")", ":", "# we don't expect anything back", "try", ":", "self", ".", "library", ".", "set_logger", ".", "restype", "=", "None", "except", "AttributeError", ":", "logger", ".", "warn", "(", "\"Tried to set logger ...
subscribe to fortran log messages
[ "subscribe", "to", "fortran", "log", "messages" ]
2f53f24d45515eb0711c2d28ddd6c1582045248f
https://github.com/openearth/bmi-python/blob/2f53f24d45515eb0711c2d28ddd6c1582045248f/bmi/wrapper.py#L686-L699
47,590
openearth/bmi-python
bmi/wrapper.py
BMIWrapper.set_current_time
def set_current_time(self, current_time): """ sets current time of simulation """ current_time = c_double(current_time) try: self.library.set_current_time.argtypes = [POINTER(c_double)] self.library.set_current_time.restype = None self.library....
python
def set_current_time(self, current_time): """ sets current time of simulation """ current_time = c_double(current_time) try: self.library.set_current_time.argtypes = [POINTER(c_double)] self.library.set_current_time.restype = None self.library....
[ "def", "set_current_time", "(", "self", ",", "current_time", ")", ":", "current_time", "=", "c_double", "(", "current_time", ")", "try", ":", "self", ".", "library", ".", "set_current_time", ".", "argtypes", "=", "[", "POINTER", "(", "c_double", ")", "]", ...
sets current time of simulation
[ "sets", "current", "time", "of", "simulation" ]
2f53f24d45515eb0711c2d28ddd6c1582045248f
https://github.com/openearth/bmi-python/blob/2f53f24d45515eb0711c2d28ddd6c1582045248f/bmi/wrapper.py#L701-L711
47,591
insomnia-lab/libreant
libreantdb/api.py
DB.setup_db
def setup_db(self, wait_for_ready=True): ''' Create and configure index If `wait_for_ready` is True, this function will block until status for `self.index_name` will be `yellow` ''' if self.es.indices.exists(self.index_name): try: self.update...
python
def setup_db(self, wait_for_ready=True): ''' Create and configure index If `wait_for_ready` is True, this function will block until status for `self.index_name` will be `yellow` ''' if self.es.indices.exists(self.index_name): try: self.update...
[ "def", "setup_db", "(", "self", ",", "wait_for_ready", "=", "True", ")", ":", "if", "self", ".", "es", ".", "indices", ".", "exists", "(", "self", ".", "index_name", ")", ":", "try", ":", "self", ".", "update_mappings", "(", ")", "except", "MappingsExc...
Create and configure index If `wait_for_ready` is True, this function will block until status for `self.index_name` will be `yellow`
[ "Create", "and", "configure", "index" ]
55d529435baf4c05a86b8341899e9f5e14e50245
https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/libreantdb/api.py#L148-L169
47,592
insomnia-lab/libreant
libreantdb/api.py
DB.create_index
def create_index(self, indexname=None, index_conf=None): ''' Create the index Create the index with given configuration. If `indexname` is provided it will be used as the new index name instead of the class one (:py:attr:`DB.index_name`) :param index_conf: confi...
python
def create_index(self, indexname=None, index_conf=None): ''' Create the index Create the index with given configuration. If `indexname` is provided it will be used as the new index name instead of the class one (:py:attr:`DB.index_name`) :param index_conf: confi...
[ "def", "create_index", "(", "self", ",", "indexname", "=", "None", ",", "index_conf", "=", "None", ")", ":", "if", "indexname", "is", "None", ":", "indexname", "=", "self", ".", "index_name", "log", ".", "debug", "(", "\"Creating new index: '{0}'\"", ".", ...
Create the index Create the index with given configuration. If `indexname` is provided it will be used as the new index name instead of the class one (:py:attr:`DB.index_name`) :param index_conf: configuration to be used in index creation. If this ...
[ "Create", "the", "index" ]
55d529435baf4c05a86b8341899e9f5e14e50245
https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/libreantdb/api.py#L186-L209
47,593
insomnia-lab/libreant
libreantdb/api.py
DB.clone_index
def clone_index(self, new_indexname, index_conf=None): '''Clone current index All entries of the current index will be copied into the newly created one named `new_indexname` :param index_conf: Configuration to be used in the new index creation. T...
python
def clone_index(self, new_indexname, index_conf=None): '''Clone current index All entries of the current index will be copied into the newly created one named `new_indexname` :param index_conf: Configuration to be used in the new index creation. T...
[ "def", "clone_index", "(", "self", ",", "new_indexname", ",", "index_conf", "=", "None", ")", ":", "log", ".", "debug", "(", "\"Cloning index '{}' into '{}'\"", ".", "format", "(", "self", ".", "index_name", ",", "new_indexname", ")", ")", "self", ".", "crea...
Clone current index All entries of the current index will be copied into the newly created one named `new_indexname` :param index_conf: Configuration to be used in the new index creation. This param will be passed directly to :py:func:`DB.create_index`
[ "Clone", "current", "index" ]
55d529435baf4c05a86b8341899e9f5e14e50245
https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/libreantdb/api.py#L211-L222
47,594
insomnia-lab/libreant
libreantdb/api.py
DB.reindex
def reindex(self, new_index=None, index_conf=None): '''Rebuilt the current index This function could be useful in the case you want to change some index settings/mappings and you don't want to loose all the entries belonging to that index. This function is built in such a way ...
python
def reindex(self, new_index=None, index_conf=None): '''Rebuilt the current index This function could be useful in the case you want to change some index settings/mappings and you don't want to loose all the entries belonging to that index. This function is built in such a way ...
[ "def", "reindex", "(", "self", ",", "new_index", "=", "None", ",", "index_conf", "=", "None", ")", ":", "alias", "=", "self", ".", "index_name", "if", "self", ".", "es", ".", "indices", ".", "exists_alias", "(", "name", "=", "self", ".", "index_name", ...
Rebuilt the current index This function could be useful in the case you want to change some index settings/mappings and you don't want to loose all the entries belonging to that index. This function is built in such a way that you can continue to use the old index name, thi...
[ "Rebuilt", "the", "current", "index" ]
55d529435baf4c05a86b8341899e9f5e14e50245
https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/libreantdb/api.py#L224-L277
47,595
insomnia-lab/libreant
libreantdb/api.py
DB.mlt
def mlt(self, _id): ''' High-level method to do "more like this". Its exact implementation can vary. ''' query = { 'query': {'more_like_this': { 'like': {'_id': _id}, 'min_term_freq': 1, 'min_doc_freq'...
python
def mlt(self, _id): ''' High-level method to do "more like this". Its exact implementation can vary. ''' query = { 'query': {'more_like_this': { 'like': {'_id': _id}, 'min_term_freq': 1, 'min_doc_freq'...
[ "def", "mlt", "(", "self", ",", "_id", ")", ":", "query", "=", "{", "'query'", ":", "{", "'more_like_this'", ":", "{", "'like'", ":", "{", "'_id'", ":", "_id", "}", ",", "'min_term_freq'", ":", "1", ",", "'min_doc_freq'", ":", "1", ",", "}", "}", ...
High-level method to do "more like this". Its exact implementation can vary.
[ "High", "-", "level", "method", "to", "do", "more", "like", "this", "." ]
55d529435baf4c05a86b8341899e9f5e14e50245
https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/libreantdb/api.py#L296-L313
47,596
insomnia-lab/libreant
libreantdb/api.py
DB.file_is_attached
def file_is_attached(self, url): '''return true if at least one book has file with the given url as attachment ''' body = self._get_search_field('_attachments.url', url) return self.es.count(index=self.index_name, body=body)['count'] > 0
python
def file_is_attached(self, url): '''return true if at least one book has file with the given url as attachment ''' body = self._get_search_field('_attachments.url', url) return self.es.count(index=self.index_name, body=body)['count'] > 0
[ "def", "file_is_attached", "(", "self", ",", "url", ")", ":", "body", "=", "self", ".", "_get_search_field", "(", "'_attachments.url'", ",", "url", ")", "return", "self", ".", "es", ".", "count", "(", "index", "=", "self", ".", "index_name", ",", "body",...
return true if at least one book has file with the given url as attachment
[ "return", "true", "if", "at", "least", "one", "book", "has", "file", "with", "the", "given", "url", "as", "attachment" ]
55d529435baf4c05a86b8341899e9f5e14e50245
https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/libreantdb/api.py#L352-L357
47,597
insomnia-lab/libreant
libreantdb/api.py
DB.delete_all
def delete_all(self): '''Delete all books from the index''' def delete_action_gen(): scanner = scan(self.es, index=self.index_name, query={'query': {'match_all':{}}}) for v in scanner: yield { '_op_type': 'dele...
python
def delete_all(self): '''Delete all books from the index''' def delete_action_gen(): scanner = scan(self.es, index=self.index_name, query={'query': {'match_all':{}}}) for v in scanner: yield { '_op_type': 'dele...
[ "def", "delete_all", "(", "self", ")", ":", "def", "delete_action_gen", "(", ")", ":", "scanner", "=", "scan", "(", "self", ".", "es", ",", "index", "=", "self", ".", "index_name", ",", "query", "=", "{", "'query'", ":", "{", "'match_all'", ":", "{",...
Delete all books from the index
[ "Delete", "all", "books", "from", "the", "index" ]
55d529435baf4c05a86b8341899e9f5e14e50245
https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/libreantdb/api.py#L379-L391
47,598
insomnia-lab/libreant
libreantdb/api.py
DB.update_book
def update_book(self, id, body, doc_type='book'): ''' Update a book The "body" is merged with the current one. Yes, it is NOT overwritten. In case of concurrency conflict this function could raise `elasticsearch.ConflictError` ''' # note that we ...
python
def update_book(self, id, body, doc_type='book'): ''' Update a book The "body" is merged with the current one. Yes, it is NOT overwritten. In case of concurrency conflict this function could raise `elasticsearch.ConflictError` ''' # note that we ...
[ "def", "update_book", "(", "self", ",", "id", ",", "body", ",", "doc_type", "=", "'book'", ")", ":", "# note that we are NOT overwriting all the _source, just merging", "book", "=", "self", ".", "get_book_by_id", "(", "id", ")", "book", "[", "'_source'", "]", "....
Update a book The "body" is merged with the current one. Yes, it is NOT overwritten. In case of concurrency conflict this function could raise `elasticsearch.ConflictError`
[ "Update", "a", "book" ]
55d529435baf4c05a86b8341899e9f5e14e50245
https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/libreantdb/api.py#L393-L408
47,599
insomnia-lab/libreant
libreantdb/api.py
DB.modify_book
def modify_book(self, id, body, doc_type='book', version=None): ''' replace the entire book body Instead of `update_book` this function will overwrite the book content with param body If param `version` is given, it will be checked that the changes are applied u...
python
def modify_book(self, id, body, doc_type='book', version=None): ''' replace the entire book body Instead of `update_book` this function will overwrite the book content with param body If param `version` is given, it will be checked that the changes are applied u...
[ "def", "modify_book", "(", "self", ",", "id", ",", "body", ",", "doc_type", "=", "'book'", ",", "version", "=", "None", ")", ":", "validatedBody", "=", "validate_book", "(", "body", ")", "params", "=", "dict", "(", "index", "=", "self", ".", "index_nam...
replace the entire book body Instead of `update_book` this function will overwrite the book content with param body If param `version` is given, it will be checked that the changes are applied upon that document version. If the document version provided is d...
[ "replace", "the", "entire", "book", "body" ]
55d529435baf4c05a86b8341899e9f5e14e50245
https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/libreantdb/api.py#L410-L426