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 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
klahnakoski/mo-logs | mo_logs/strings.py | utf82unicode | def utf82unicode(value):
"""
WITH EXPLANATION FOR FAILURE
"""
try:
return value.decode("utf8")
except Exception as e:
if not _Log:
_late_import()
if not is_binary(value):
_Log.error("Can not convert {{type}} to unicode because it's not bytes", type= ... | python | def utf82unicode(value):
"""
WITH EXPLANATION FOR FAILURE
"""
try:
return value.decode("utf8")
except Exception as e:
if not _Log:
_late_import()
if not is_binary(value):
_Log.error("Can not convert {{type}} to unicode because it's not bytes", type= ... | [
"def",
"utf82unicode",
"(",
"value",
")",
":",
"try",
":",
"return",
"value",
".",
"decode",
"(",
"\"utf8\"",
")",
"except",
"Exception",
"as",
"e",
":",
"if",
"not",
"_Log",
":",
"_late_import",
"(",
")",
"if",
"not",
"is_binary",
"(",
"value",
")",
... | WITH EXPLANATION FOR FAILURE | [
"WITH",
"EXPLANATION",
"FOR",
"FAILURE"
] | 0971277ac9caf28a755b766b70621916957d4fea | https://github.com/klahnakoski/mo-logs/blob/0971277ac9caf28a755b766b70621916957d4fea/mo_logs/strings.py#L858-L890 | train |
portfors-lab/sparkle | sparkle/gui/stim/tuning_curve.py | TuningCurveEditor.setModel | def setModel(self, model):
"""Sets the QStimulusModel for this editor"""
self.stimModel = model
self.parameterModel = model.autoParams()
tone = self.stimModel.data(self.stimModel.index(0,0), QtCore.Qt.UserRole+1)
info = tone.auto_details()
# set max/mins
fmax = i... | python | def setModel(self, model):
"""Sets the QStimulusModel for this editor"""
self.stimModel = model
self.parameterModel = model.autoParams()
tone = self.stimModel.data(self.stimModel.index(0,0), QtCore.Qt.UserRole+1)
info = tone.auto_details()
# set max/mins
fmax = i... | [
"def",
"setModel",
"(",
"self",
",",
"model",
")",
":",
"self",
".",
"stimModel",
"=",
"model",
"self",
".",
"parameterModel",
"=",
"model",
".",
"autoParams",
"(",
")",
"tone",
"=",
"self",
".",
"stimModel",
".",
"data",
"(",
"self",
".",
"stimModel",... | Sets the QStimulusModel for this editor | [
"Sets",
"the",
"QStimulusModel",
"for",
"this",
"editor"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/stim/tuning_curve.py#L39-L74 | train |
portfors-lab/sparkle | sparkle/gui/stim/tuning_curve.py | TuningCurveEditor.setStimDuration | def setStimDuration(self):
"""Sets the duration of the StimulusModel from values pulled from
this widget"""
duration = self.ui.durSpnbx.value()
self.tone.setDuration(duration) | python | def setStimDuration(self):
"""Sets the duration of the StimulusModel from values pulled from
this widget"""
duration = self.ui.durSpnbx.value()
self.tone.setDuration(duration) | [
"def",
"setStimDuration",
"(",
"self",
")",
":",
"duration",
"=",
"self",
".",
"ui",
".",
"durSpnbx",
".",
"value",
"(",
")",
"self",
".",
"tone",
".",
"setDuration",
"(",
"duration",
")"
] | Sets the duration of the StimulusModel from values pulled from
this widget | [
"Sets",
"the",
"duration",
"of",
"the",
"StimulusModel",
"from",
"values",
"pulled",
"from",
"this",
"widget"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/stim/tuning_curve.py#L83-L87 | train |
portfors-lab/sparkle | sparkle/gui/stim/tuning_curve.py | TuningCurveEditor.setStimReps | def setStimReps(self):
"""Sets the reps of the StimulusModel from values pulled from
this widget"""
reps = self.ui.nrepsSpnbx.value()
self.stimModel.setRepCount(reps) | python | def setStimReps(self):
"""Sets the reps of the StimulusModel from values pulled from
this widget"""
reps = self.ui.nrepsSpnbx.value()
self.stimModel.setRepCount(reps) | [
"def",
"setStimReps",
"(",
"self",
")",
":",
"reps",
"=",
"self",
".",
"ui",
".",
"nrepsSpnbx",
".",
"value",
"(",
")",
"self",
".",
"stimModel",
".",
"setRepCount",
"(",
"reps",
")"
] | Sets the reps of the StimulusModel from values pulled from
this widget | [
"Sets",
"the",
"reps",
"of",
"the",
"StimulusModel",
"from",
"values",
"pulled",
"from",
"this",
"widget"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/stim/tuning_curve.py#L90-L94 | train |
portfors-lab/sparkle | sparkle/gui/stim/tuning_curve.py | TuningCurveEditor.setStimRisefall | def setStimRisefall(self):
"""Sets the Risefall of the StimulusModel's tone from values pulled from
this widget"""
rf = self.ui.risefallSpnbx.value()
self.tone.setRisefall(rf) | python | def setStimRisefall(self):
"""Sets the Risefall of the StimulusModel's tone from values pulled from
this widget"""
rf = self.ui.risefallSpnbx.value()
self.tone.setRisefall(rf) | [
"def",
"setStimRisefall",
"(",
"self",
")",
":",
"rf",
"=",
"self",
".",
"ui",
".",
"risefallSpnbx",
".",
"value",
"(",
")",
"self",
".",
"tone",
".",
"setRisefall",
"(",
"rf",
")"
] | Sets the Risefall of the StimulusModel's tone from values pulled from
this widget | [
"Sets",
"the",
"Risefall",
"of",
"the",
"StimulusModel",
"s",
"tone",
"from",
"values",
"pulled",
"from",
"this",
"widget"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/stim/tuning_curve.py#L96-L100 | train |
loganasherjones/yapconf | yapconf/spec.py | YapconfSpec.add_arguments | def add_arguments(self, parser, bootstrap=False):
"""Adds all items to the parser passed in.
Args:
parser (argparse.ArgumentParser): The parser to add all items to.
bootstrap (bool): Flag to indicate whether you only want to mark
bootstrapped items as required on... | python | def add_arguments(self, parser, bootstrap=False):
"""Adds all items to the parser passed in.
Args:
parser (argparse.ArgumentParser): The parser to add all items to.
bootstrap (bool): Flag to indicate whether you only want to mark
bootstrapped items as required on... | [
"def",
"add_arguments",
"(",
"self",
",",
"parser",
",",
"bootstrap",
"=",
"False",
")",
":",
"[",
"item",
".",
"add_argument",
"(",
"parser",
",",
"bootstrap",
")",
"for",
"item",
"in",
"self",
".",
"_get_items",
"(",
"bootstrap",
"=",
"False",
")",
"... | Adds all items to the parser passed in.
Args:
parser (argparse.ArgumentParser): The parser to add all items to.
bootstrap (bool): Flag to indicate whether you only want to mark
bootstrapped items as required on the command-line. | [
"Adds",
"all",
"items",
"to",
"the",
"parser",
"passed",
"in",
"."
] | d2970e6e7e3334615d4d978d8b0ca33006d79d16 | https://github.com/loganasherjones/yapconf/blob/d2970e6e7e3334615d4d978d8b0ca33006d79d16/yapconf/spec.py#L133-L143 | train |
loganasherjones/yapconf | yapconf/spec.py | YapconfSpec.add_source | def add_source(self, label, source_type, **kwargs):
"""Add a source to the spec.
Sources should have a unique label. This will help tracing where your
configurations are coming from if you turn up the log-level.
The keyword arguments are significant. Different sources require
d... | python | def add_source(self, label, source_type, **kwargs):
"""Add a source to the spec.
Sources should have a unique label. This will help tracing where your
configurations are coming from if you turn up the log-level.
The keyword arguments are significant. Different sources require
d... | [
"def",
"add_source",
"(",
"self",
",",
"label",
",",
"source_type",
",",
"**",
"kwargs",
")",
":",
"self",
".",
"_sources",
"[",
"label",
"]",
"=",
"get_source",
"(",
"label",
",",
"source_type",
",",
"**",
"kwargs",
")"
] | Add a source to the spec.
Sources should have a unique label. This will help tracing where your
configurations are coming from if you turn up the log-level.
The keyword arguments are significant. Different sources require
different keyword arguments. Required keys for each source_type ... | [
"Add",
"a",
"source",
"to",
"the",
"spec",
"."
] | d2970e6e7e3334615d4d978d8b0ca33006d79d16 | https://github.com/loganasherjones/yapconf/blob/d2970e6e7e3334615d4d978d8b0ca33006d79d16/yapconf/spec.py#L145-L188 | train |
loganasherjones/yapconf | yapconf/spec.py | YapconfSpec.find_item | def find_item(self, fq_name):
"""Find an item in the specification by fully qualified name.
Args:
fq_name (str): Fully-qualified name of the item.
Returns:
The item if it is in the specification. None otherwise
"""
names = fq_name.split(self._separator)... | python | def find_item(self, fq_name):
"""Find an item in the specification by fully qualified name.
Args:
fq_name (str): Fully-qualified name of the item.
Returns:
The item if it is in the specification. None otherwise
"""
names = fq_name.split(self._separator)... | [
"def",
"find_item",
"(",
"self",
",",
"fq_name",
")",
":",
"names",
"=",
"fq_name",
".",
"split",
"(",
"self",
".",
"_separator",
")",
"current",
"=",
"self",
".",
"_yapconf_items",
"for",
"name",
"in",
"names",
":",
"if",
"isinstance",
"(",
"current",
... | Find an item in the specification by fully qualified name.
Args:
fq_name (str): Fully-qualified name of the item.
Returns:
The item if it is in the specification. None otherwise | [
"Find",
"an",
"item",
"in",
"the",
"specification",
"by",
"fully",
"qualified",
"name",
"."
] | d2970e6e7e3334615d4d978d8b0ca33006d79d16 | https://github.com/loganasherjones/yapconf/blob/d2970e6e7e3334615d4d978d8b0ca33006d79d16/yapconf/spec.py#L190-L209 | train |
loganasherjones/yapconf | yapconf/spec.py | YapconfSpec.get_item | def get_item(self, name, bootstrap=False):
"""Get a particular item in the specification.
Args:
name (str): The name of the item to retrieve.
bootstrap (bool): Only search bootstrap items
Returns (YapconfItem):
A YapconfItem if it is found, None otherwise.
... | python | def get_item(self, name, bootstrap=False):
"""Get a particular item in the specification.
Args:
name (str): The name of the item to retrieve.
bootstrap (bool): Only search bootstrap items
Returns (YapconfItem):
A YapconfItem if it is found, None otherwise.
... | [
"def",
"get_item",
"(",
"self",
",",
"name",
",",
"bootstrap",
"=",
"False",
")",
":",
"for",
"item",
"in",
"self",
".",
"_get_items",
"(",
"bootstrap",
")",
":",
"if",
"item",
".",
"name",
"==",
"name",
":",
"return",
"item",
"return",
"None"
] | Get a particular item in the specification.
Args:
name (str): The name of the item to retrieve.
bootstrap (bool): Only search bootstrap items
Returns (YapconfItem):
A YapconfItem if it is found, None otherwise. | [
"Get",
"a",
"particular",
"item",
"in",
"the",
"specification",
"."
] | d2970e6e7e3334615d4d978d8b0ca33006d79d16 | https://github.com/loganasherjones/yapconf/blob/d2970e6e7e3334615d4d978d8b0ca33006d79d16/yapconf/spec.py#L211-L225 | train |
loganasherjones/yapconf | yapconf/spec.py | YapconfSpec.update_defaults | def update_defaults(self, new_defaults, respect_none=False):
"""Update items defaults to the values in the new_defaults dict.
Args:
new_defaults (dict): A key-value pair of new defaults to be
applied.
respect_none (bool): Flag to indicate if ``None`` values shoul... | python | def update_defaults(self, new_defaults, respect_none=False):
"""Update items defaults to the values in the new_defaults dict.
Args:
new_defaults (dict): A key-value pair of new defaults to be
applied.
respect_none (bool): Flag to indicate if ``None`` values shoul... | [
"def",
"update_defaults",
"(",
"self",
",",
"new_defaults",
",",
"respect_none",
"=",
"False",
")",
":",
"for",
"key",
",",
"value",
"in",
"six",
".",
"iteritems",
"(",
"new_defaults",
")",
":",
"item",
"=",
"self",
".",
"get_item",
"(",
"key",
")",
"i... | Update items defaults to the values in the new_defaults dict.
Args:
new_defaults (dict): A key-value pair of new defaults to be
applied.
respect_none (bool): Flag to indicate if ``None`` values should
constitute an update to the default. | [
"Update",
"items",
"defaults",
"to",
"the",
"values",
"in",
"the",
"new_defaults",
"dict",
"."
] | d2970e6e7e3334615d4d978d8b0ca33006d79d16 | https://github.com/loganasherjones/yapconf/blob/d2970e6e7e3334615d4d978d8b0ca33006d79d16/yapconf/spec.py#L227-L244 | train |
loganasherjones/yapconf | yapconf/spec.py | YapconfSpec.generate_documentation | def generate_documentation(self, app_name, **kwargs):
"""Generate documentation for this specification.
Documentation is generated in Markdown format. An example
of the generated documentation can be found at:
https://github.com/loganasherjones/yapconf/blob/master/example/doc.md
... | python | def generate_documentation(self, app_name, **kwargs):
"""Generate documentation for this specification.
Documentation is generated in Markdown format. An example
of the generated documentation can be found at:
https://github.com/loganasherjones/yapconf/blob/master/example/doc.md
... | [
"def",
"generate_documentation",
"(",
"self",
",",
"app_name",
",",
"**",
"kwargs",
")",
":",
"output_file",
"=",
"kwargs",
".",
"get",
"(",
"'output_file_name'",
")",
"encoding",
"=",
"kwargs",
".",
"get",
"(",
"'encoding'",
",",
"'utf-8'",
")",
"doc_string... | Generate documentation for this specification.
Documentation is generated in Markdown format. An example
of the generated documentation can be found at:
https://github.com/loganasherjones/yapconf/blob/master/example/doc.md
Args:
app_name (str): The name of your application... | [
"Generate",
"documentation",
"for",
"this",
"specification",
"."
] | d2970e6e7e3334615d4d978d8b0ca33006d79d16 | https://github.com/loganasherjones/yapconf/blob/d2970e6e7e3334615d4d978d8b0ca33006d79d16/yapconf/spec.py#L246-L273 | train |
loganasherjones/yapconf | yapconf/spec.py | YapconfSpec.load_config | def load_config(self, *args, **kwargs):
"""Load a config based on the arguments passed in.
The order of arguments passed in as \*args is significant. It indicates
the order of precedence used to load configuration values. Each
argument can be a string, dictionary or a tuple. There is a ... | python | def load_config(self, *args, **kwargs):
"""Load a config based on the arguments passed in.
The order of arguments passed in as \*args is significant. It indicates
the order of precedence used to load configuration values. Each
argument can be a string, dictionary or a tuple. There is a ... | [
"def",
"load_config",
"(",
"self",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"bootstrap",
"=",
"kwargs",
".",
"get",
"(",
"'bootstrap'",
",",
"False",
")",
"overrides",
"=",
"self",
".",
"_generate_overrides",
"(",
"*",
"args",
")",
"config",
"=... | Load a config based on the arguments passed in.
The order of arguments passed in as \*args is significant. It indicates
the order of precedence used to load configuration values. Each
argument can be a string, dictionary or a tuple. There is a special
case string called 'ENVIRONMENT', o... | [
"Load",
"a",
"config",
"based",
"on",
"the",
"arguments",
"passed",
"in",
"."
] | d2970e6e7e3334615d4d978d8b0ca33006d79d16 | https://github.com/loganasherjones/yapconf/blob/d2970e6e7e3334615d4d978d8b0ca33006d79d16/yapconf/spec.py#L275-L327 | train |
loganasherjones/yapconf | yapconf/spec.py | YapconfSpec.spawn_watcher | def spawn_watcher(self, label, target=None, eternal=False):
"""Spawns a config watcher in a separate daemon thread.
If a particular config value changes, and the item has a
``watch_target`` defined, then that method will be called.
If a ``target`` is passed in, then it will call the ``... | python | def spawn_watcher(self, label, target=None, eternal=False):
"""Spawns a config watcher in a separate daemon thread.
If a particular config value changes, and the item has a
``watch_target`` defined, then that method will be called.
If a ``target`` is passed in, then it will call the ``... | [
"def",
"spawn_watcher",
"(",
"self",
",",
"label",
",",
"target",
"=",
"None",
",",
"eternal",
"=",
"False",
")",
":",
"if",
"label",
"not",
"in",
"self",
".",
"_sources",
":",
"raise",
"YapconfSourceError",
"(",
"'Cannot watch %s no source named %s'",
"%",
... | Spawns a config watcher in a separate daemon thread.
If a particular config value changes, and the item has a
``watch_target`` defined, then that method will be called.
If a ``target`` is passed in, then it will call the ``target``
anytime the config changes.
Args:
... | [
"Spawns",
"a",
"config",
"watcher",
"in",
"a",
"separate",
"daemon",
"thread",
"."
] | d2970e6e7e3334615d4d978d8b0ca33006d79d16 | https://github.com/loganasherjones/yapconf/blob/d2970e6e7e3334615d4d978d8b0ca33006d79d16/yapconf/spec.py#L329-L357 | train |
loganasherjones/yapconf | yapconf/spec.py | YapconfSpec.migrate_config_file | def migrate_config_file(
self,
config_file_path,
always_update=False,
current_file_type=None,
output_file_name=None,
output_file_type=None,
create=True,
update_defaults=True,
dump_kwargs=None,
include_bootstrap=True,
):
"""Migra... | python | def migrate_config_file(
self,
config_file_path,
always_update=False,
current_file_type=None,
output_file_name=None,
output_file_type=None,
create=True,
update_defaults=True,
dump_kwargs=None,
include_bootstrap=True,
):
"""Migra... | [
"def",
"migrate_config_file",
"(",
"self",
",",
"config_file_path",
",",
"always_update",
"=",
"False",
",",
"current_file_type",
"=",
"None",
",",
"output_file_name",
"=",
"None",
",",
"output_file_type",
"=",
"None",
",",
"create",
"=",
"True",
",",
"update_de... | Migrates a configuration file.
This is used to help you update your configurations throughout the
lifetime of your application. It is probably best explained through
example.
Examples:
Assume we have a JSON config file ('/path/to/config.json')
like the following... | [
"Migrates",
"a",
"configuration",
"file",
"."
] | d2970e6e7e3334615d4d978d8b0ca33006d79d16 | https://github.com/loganasherjones/yapconf/blob/d2970e6e7e3334615d4d978d8b0ca33006d79d16/yapconf/spec.py#L359-L446 | train |
portfors-lab/sparkle | sparkle/tools/spikestats.py | refractory | def refractory(times, refract=0.002):
"""Removes spikes in times list that do not satisfy refractor period
:param times: list(float) of spike times in seconds
:type times: list(float)
:param refract: Refractory period in seconds
:type refract: float
:returns: list(float) of spike times in seconds
For every int... | python | def refractory(times, refract=0.002):
"""Removes spikes in times list that do not satisfy refractor period
:param times: list(float) of spike times in seconds
:type times: list(float)
:param refract: Refractory period in seconds
:type refract: float
:returns: list(float) of spike times in seconds
For every int... | [
"def",
"refractory",
"(",
"times",
",",
"refract",
"=",
"0.002",
")",
":",
"times_refract",
"=",
"[",
"]",
"times_refract",
".",
"append",
"(",
"times",
"[",
"0",
"]",
")",
"for",
"i",
"in",
"range",
"(",
"1",
",",
"len",
"(",
"times",
")",
")",
... | Removes spikes in times list that do not satisfy refractor period
:param times: list(float) of spike times in seconds
:type times: list(float)
:param refract: Refractory period in seconds
:type refract: float
:returns: list(float) of spike times in seconds
For every interspike interval < refract,
removes the ... | [
"Removes",
"spikes",
"in",
"times",
"list",
"that",
"do",
"not",
"satisfy",
"refractor",
"period"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/tools/spikestats.py#L4-L20 | train |
portfors-lab/sparkle | sparkle/tools/spikestats.py | spike_times | def spike_times(signal, threshold, fs, absval=True):
"""Detect spikes from a given signal
:param signal: Spike trace recording (vector)
:type signal: numpy array
:param threshold: Threshold value to determine spikes
:type threshold: float
:param absval: Whether to apply absolute value to signal... | python | def spike_times(signal, threshold, fs, absval=True):
"""Detect spikes from a given signal
:param signal: Spike trace recording (vector)
:type signal: numpy array
:param threshold: Threshold value to determine spikes
:type threshold: float
:param absval: Whether to apply absolute value to signal... | [
"def",
"spike_times",
"(",
"signal",
",",
"threshold",
",",
"fs",
",",
"absval",
"=",
"True",
")",
":",
"times",
"=",
"[",
"]",
"if",
"absval",
":",
"signal",
"=",
"np",
".",
"abs",
"(",
"signal",
")",
"over",
",",
"=",
"np",
".",
"where",
"(",
... | Detect spikes from a given signal
:param signal: Spike trace recording (vector)
:type signal: numpy array
:param threshold: Threshold value to determine spikes
:type threshold: float
:param absval: Whether to apply absolute value to signal before thresholding
:type absval: bool
:returns: li... | [
"Detect",
"spikes",
"from",
"a",
"given",
"signal"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/tools/spikestats.py#L22-L74 | train |
portfors-lab/sparkle | sparkle/tools/spikestats.py | bin_spikes | def bin_spikes(spike_times, binsz):
"""Sort spike times into bins
:param spike_times: times of spike instances
:type spike_times: list
:param binsz: length of time bin to use
:type binsz: float
:returns: list of bin indicies, one for each element in spike_times
"""
bins = np.empty((len(... | python | def bin_spikes(spike_times, binsz):
"""Sort spike times into bins
:param spike_times: times of spike instances
:type spike_times: list
:param binsz: length of time bin to use
:type binsz: float
:returns: list of bin indicies, one for each element in spike_times
"""
bins = np.empty((len(... | [
"def",
"bin_spikes",
"(",
"spike_times",
",",
"binsz",
")",
":",
"bins",
"=",
"np",
".",
"empty",
"(",
"(",
"len",
"(",
"spike_times",
")",
",",
")",
",",
"dtype",
"=",
"int",
")",
"for",
"i",
",",
"stime",
"in",
"enumerate",
"(",
"spike_times",
")... | Sort spike times into bins
:param spike_times: times of spike instances
:type spike_times: list
:param binsz: length of time bin to use
:type binsz: float
:returns: list of bin indicies, one for each element in spike_times | [
"Sort",
"spike",
"times",
"into",
"bins"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/tools/spikestats.py#L76-L89 | train |
portfors-lab/sparkle | sparkle/tools/spikestats.py | spike_latency | def spike_latency(signal, threshold, fs):
"""Find the latency of the first spike over threshold
:param signal: Spike trace recording (vector)
:type signal: numpy array
:param threshold: Threshold value to determine spikes
:type threshold: float
:returns: float -- Time of peak of first spike, or... | python | def spike_latency(signal, threshold, fs):
"""Find the latency of the first spike over threshold
:param signal: Spike trace recording (vector)
:type signal: numpy array
:param threshold: Threshold value to determine spikes
:type threshold: float
:returns: float -- Time of peak of first spike, or... | [
"def",
"spike_latency",
"(",
"signal",
",",
"threshold",
",",
"fs",
")",
":",
"over",
",",
"=",
"np",
".",
"where",
"(",
"signal",
">",
"threshold",
")",
"segments",
",",
"=",
"np",
".",
"where",
"(",
"np",
".",
"diff",
"(",
"over",
")",
">",
"1"... | Find the latency of the first spike over threshold
:param signal: Spike trace recording (vector)
:type signal: numpy array
:param threshold: Threshold value to determine spikes
:type threshold: float
:returns: float -- Time of peak of first spike, or None if no values over threshold
This is th... | [
"Find",
"the",
"latency",
"of",
"the",
"first",
"spike",
"over",
"threshold"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/tools/spikestats.py#L91-L121 | train |
portfors-lab/sparkle | sparkle/tools/spikestats.py | firing_rate | def firing_rate(spike_times, window_size=None):
"""Calculate the firing rate of spikes
:param spike_times: times of spike instances
:type spike_times: list
:param window_size: length of time to use to determine rate.
If none, uses time from first to last spike in spike_times
:type window_size: ... | python | def firing_rate(spike_times, window_size=None):
"""Calculate the firing rate of spikes
:param spike_times: times of spike instances
:type spike_times: list
:param window_size: length of time to use to determine rate.
If none, uses time from first to last spike in spike_times
:type window_size: ... | [
"def",
"firing_rate",
"(",
"spike_times",
",",
"window_size",
"=",
"None",
")",
":",
"if",
"len",
"(",
"spike_times",
")",
"==",
"0",
":",
"return",
"0",
"if",
"window_size",
"is",
"None",
":",
"if",
"len",
"(",
"spike_times",
")",
">",
"1",
":",
"wi... | Calculate the firing rate of spikes
:param spike_times: times of spike instances
:type spike_times: list
:param window_size: length of time to use to determine rate.
If none, uses time from first to last spike in spike_times
:type window_size: float | [
"Calculate",
"the",
"firing",
"rate",
"of",
"spikes"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/tools/spikestats.py#L123-L145 | train |
aresio/miniful | miniful/miniful.py | FuzzyReasoner.evaluate_rules | def evaluate_rules(self):
"""Perform Sugeno inference."""
outputs = defaultdict(list)
total_rules = len(self._rules)
for rule in self._rules:
res = rule.evaluate(self._variables)
outputs[res['term']].append([res['weight'], res['output']])
return_values = {}
for k,v in outputs.items():
num = sum(m... | python | def evaluate_rules(self):
"""Perform Sugeno inference."""
outputs = defaultdict(list)
total_rules = len(self._rules)
for rule in self._rules:
res = rule.evaluate(self._variables)
outputs[res['term']].append([res['weight'], res['output']])
return_values = {}
for k,v in outputs.items():
num = sum(m... | [
"def",
"evaluate_rules",
"(",
"self",
")",
":",
"outputs",
"=",
"defaultdict",
"(",
"list",
")",
"total_rules",
"=",
"len",
"(",
"self",
".",
"_rules",
")",
"for",
"rule",
"in",
"self",
".",
"_rules",
":",
"res",
"=",
"rule",
".",
"evaluate",
"(",
"s... | Perform Sugeno inference. | [
"Perform",
"Sugeno",
"inference",
"."
] | 51eaa89677b22027134c208c012045de883c751e | https://github.com/aresio/miniful/blob/51eaa89677b22027134c208c012045de883c751e/miniful/miniful.py#L129-L145 | train |
TorkamaniLab/metapipe | metapipe/models/pbs_job.py | PBSJob.is_complete | def is_complete(self):
""" Checks the job's output or log file to determing if
the completion criteria was met.
"""
qstat = self._grep_qstat('complete')
comp = self._grep_status('complete')
if qstat and comp:
return True
return False | python | def is_complete(self):
""" Checks the job's output or log file to determing if
the completion criteria was met.
"""
qstat = self._grep_qstat('complete')
comp = self._grep_status('complete')
if qstat and comp:
return True
return False | [
"def",
"is_complete",
"(",
"self",
")",
":",
"qstat",
"=",
"self",
".",
"_grep_qstat",
"(",
"'complete'",
")",
"comp",
"=",
"self",
".",
"_grep_status",
"(",
"'complete'",
")",
"if",
"qstat",
"and",
"comp",
":",
"return",
"True",
"return",
"False"
] | Checks the job's output or log file to determing if
the completion criteria was met. | [
"Checks",
"the",
"job",
"s",
"output",
"or",
"log",
"file",
"to",
"determing",
"if",
"the",
"completion",
"criteria",
"was",
"met",
"."
] | 15592e5b0c217afb00ac03503f8d0d7453d4baf4 | https://github.com/TorkamaniLab/metapipe/blob/15592e5b0c217afb00ac03503f8d0d7453d4baf4/metapipe/models/pbs_job.py#L39-L47 | train |
mediawiki-utilities/python-mwoauth | mwoauth/functions.py | initiate | def initiate(mw_uri, consumer_token, callback='oob',
user_agent=defaults.USER_AGENT):
"""
Initiate an oauth handshake with MediaWiki.
:Parameters:
mw_uri : `str`
The base URI of the MediaWiki installation. Note that the URI
should end in ``"index.php"``.
... | python | def initiate(mw_uri, consumer_token, callback='oob',
user_agent=defaults.USER_AGENT):
"""
Initiate an oauth handshake with MediaWiki.
:Parameters:
mw_uri : `str`
The base URI of the MediaWiki installation. Note that the URI
should end in ``"index.php"``.
... | [
"def",
"initiate",
"(",
"mw_uri",
",",
"consumer_token",
",",
"callback",
"=",
"'oob'",
",",
"user_agent",
"=",
"defaults",
".",
"USER_AGENT",
")",
":",
"auth",
"=",
"OAuth1",
"(",
"consumer_token",
".",
"key",
",",
"client_secret",
"=",
"consumer_token",
".... | Initiate an oauth handshake with MediaWiki.
:Parameters:
mw_uri : `str`
The base URI of the MediaWiki installation. Note that the URI
should end in ``"index.php"``.
consumer_token : :class:`~mwoauth.ConsumerToken`
A token representing you, the consumer. Provide... | [
"Initiate",
"an",
"oauth",
"handshake",
"with",
"MediaWiki",
"."
] | cd6990753ec3d59b7cfd96a76459f71ef4790cd3 | https://github.com/mediawiki-utilities/python-mwoauth/blob/cd6990753ec3d59b7cfd96a76459f71ef4790cd3/mwoauth/functions.py#L60-L121 | train |
freshbooks/statsdecor | statsdecor/__init__.py | configure | def configure(*args, **kwargs):
"""Configure the module level statsd client that will
be used in all library operations.
Frequently used from application initialization code.
>>> import statsdecor
>>> statsdecor.configure(
host='localhost',
port=8125,
prefix='my... | python | def configure(*args, **kwargs):
"""Configure the module level statsd client that will
be used in all library operations.
Frequently used from application initialization code.
>>> import statsdecor
>>> statsdecor.configure(
host='localhost',
port=8125,
prefix='my... | [
"def",
"configure",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"global",
"_stats_client",
"log",
".",
"debug",
"(",
"'statsd.configure(%s)'",
"%",
"kwargs",
")",
"_config",
".",
"update",
"(",
"kwargs",
")",
"_stats_client",
"=",
"_create_client",
"(",... | Configure the module level statsd client that will
be used in all library operations.
Frequently used from application initialization code.
>>> import statsdecor
>>> statsdecor.configure(
host='localhost',
port=8125,
prefix='myapp',
maxudpsize=25) | [
"Configure",
"the",
"module",
"level",
"statsd",
"client",
"that",
"will",
"be",
"used",
"in",
"all",
"library",
"operations",
"."
] | 1c4a98e120799b430fd40c8fede9020a91162d31 | https://github.com/freshbooks/statsdecor/blob/1c4a98e120799b430fd40c8fede9020a91162d31/statsdecor/__init__.py#L31-L49 | train |
freshbooks/statsdecor | statsdecor/__init__.py | incr | def incr(name, value=1, rate=1, tags=None):
"""Increment a metric by value.
>>> import statsdecor
>>> statsdecor.incr('my.metric')
"""
client().incr(name, value, rate, tags) | python | def incr(name, value=1, rate=1, tags=None):
"""Increment a metric by value.
>>> import statsdecor
>>> statsdecor.incr('my.metric')
"""
client().incr(name, value, rate, tags) | [
"def",
"incr",
"(",
"name",
",",
"value",
"=",
"1",
",",
"rate",
"=",
"1",
",",
"tags",
"=",
"None",
")",
":",
"client",
"(",
")",
".",
"incr",
"(",
"name",
",",
"value",
",",
"rate",
",",
"tags",
")"
] | Increment a metric by value.
>>> import statsdecor
>>> statsdecor.incr('my.metric') | [
"Increment",
"a",
"metric",
"by",
"value",
"."
] | 1c4a98e120799b430fd40c8fede9020a91162d31 | https://github.com/freshbooks/statsdecor/blob/1c4a98e120799b430fd40c8fede9020a91162d31/statsdecor/__init__.py#L59-L65 | train |
freshbooks/statsdecor | statsdecor/__init__.py | decr | def decr(name, value=1, rate=1, tags=None):
"""Decrement a metric by value.
>>> import statsdecor
>>> statsdecor.decr('my.metric')
"""
client().decr(name, value, rate, tags) | python | def decr(name, value=1, rate=1, tags=None):
"""Decrement a metric by value.
>>> import statsdecor
>>> statsdecor.decr('my.metric')
"""
client().decr(name, value, rate, tags) | [
"def",
"decr",
"(",
"name",
",",
"value",
"=",
"1",
",",
"rate",
"=",
"1",
",",
"tags",
"=",
"None",
")",
":",
"client",
"(",
")",
".",
"decr",
"(",
"name",
",",
"value",
",",
"rate",
",",
"tags",
")"
] | Decrement a metric by value.
>>> import statsdecor
>>> statsdecor.decr('my.metric') | [
"Decrement",
"a",
"metric",
"by",
"value",
"."
] | 1c4a98e120799b430fd40c8fede9020a91162d31 | https://github.com/freshbooks/statsdecor/blob/1c4a98e120799b430fd40c8fede9020a91162d31/statsdecor/__init__.py#L68-L74 | train |
freshbooks/statsdecor | statsdecor/__init__.py | gauge | def gauge(name, value, rate=1, tags=None):
"""Set the value for a gauge.
>>> import statsdecor
>>> statsdecor.gauge('my.metric', 10)
"""
client().gauge(name, value, rate, tags) | python | def gauge(name, value, rate=1, tags=None):
"""Set the value for a gauge.
>>> import statsdecor
>>> statsdecor.gauge('my.metric', 10)
"""
client().gauge(name, value, rate, tags) | [
"def",
"gauge",
"(",
"name",
",",
"value",
",",
"rate",
"=",
"1",
",",
"tags",
"=",
"None",
")",
":",
"client",
"(",
")",
".",
"gauge",
"(",
"name",
",",
"value",
",",
"rate",
",",
"tags",
")"
] | Set the value for a gauge.
>>> import statsdecor
>>> statsdecor.gauge('my.metric', 10) | [
"Set",
"the",
"value",
"for",
"a",
"gauge",
"."
] | 1c4a98e120799b430fd40c8fede9020a91162d31 | https://github.com/freshbooks/statsdecor/blob/1c4a98e120799b430fd40c8fede9020a91162d31/statsdecor/__init__.py#L77-L83 | train |
freshbooks/statsdecor | statsdecor/__init__.py | timing | def timing(name, delta, rate=1, tags=None):
"""Sends new timing information. `delta` is in milliseconds.
>>> import statsdecor
>>> statsdecor.timing('my.metric', 314159265359)
"""
return client().timing(name, delta, rate=rate, tags=tags) | python | def timing(name, delta, rate=1, tags=None):
"""Sends new timing information. `delta` is in milliseconds.
>>> import statsdecor
>>> statsdecor.timing('my.metric', 314159265359)
"""
return client().timing(name, delta, rate=rate, tags=tags) | [
"def",
"timing",
"(",
"name",
",",
"delta",
",",
"rate",
"=",
"1",
",",
"tags",
"=",
"None",
")",
":",
"return",
"client",
"(",
")",
".",
"timing",
"(",
"name",
",",
"delta",
",",
"rate",
"=",
"rate",
",",
"tags",
"=",
"tags",
")"
] | Sends new timing information. `delta` is in milliseconds.
>>> import statsdecor
>>> statsdecor.timing('my.metric', 314159265359) | [
"Sends",
"new",
"timing",
"information",
".",
"delta",
"is",
"in",
"milliseconds",
"."
] | 1c4a98e120799b430fd40c8fede9020a91162d31 | https://github.com/freshbooks/statsdecor/blob/1c4a98e120799b430fd40c8fede9020a91162d31/statsdecor/__init__.py#L97-L103 | train |
ArabellaTech/django-basic-cms | basic_cms/admin/__init__.py | PageAdmin.list_pages | def list_pages(self, request, template_name=None, extra_context=None):
"""List root pages"""
if not self.admin_site.has_permission(request):
return self.admin_site.login(request)
language = get_language_from_request(request)
query = request.POST.get('q', '').strip()
... | python | def list_pages(self, request, template_name=None, extra_context=None):
"""List root pages"""
if not self.admin_site.has_permission(request):
return self.admin_site.login(request)
language = get_language_from_request(request)
query = request.POST.get('q', '').strip()
... | [
"def",
"list_pages",
"(",
"self",
",",
"request",
",",
"template_name",
"=",
"None",
",",
"extra_context",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"admin_site",
".",
"has_permission",
"(",
"request",
")",
":",
"return",
"self",
".",
"admin_site",
... | List root pages | [
"List",
"root",
"pages"
] | 863f3c6098606f663994930cd8e7723ad0c07caf | https://github.com/ArabellaTech/django-basic-cms/blob/863f3c6098606f663994930cd8e7723ad0c07caf/basic_cms/admin/__init__.py#L347-L376 | train |
lowandrew/OLCTools | coreGenome/annotate.py | Annotate.codingthreads | def codingthreads(self):
"""
Find CDS features in .gff files to filter out non-coding sequences from the analysis
"""
printtime('Extracting CDS features', self.start)
# Create and start threads
for i in range(self.cpus):
# Send the threads to the appropriate d... | python | def codingthreads(self):
"""
Find CDS features in .gff files to filter out non-coding sequences from the analysis
"""
printtime('Extracting CDS features', self.start)
# Create and start threads
for i in range(self.cpus):
# Send the threads to the appropriate d... | [
"def",
"codingthreads",
"(",
"self",
")",
":",
"printtime",
"(",
"'Extracting CDS features'",
",",
"self",
".",
"start",
")",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"cpus",
")",
":",
"threads",
"=",
"Thread",
"(",
"target",
"=",
"self",
".",
"cod... | Find CDS features in .gff files to filter out non-coding sequences from the analysis | [
"Find",
"CDS",
"features",
"in",
".",
"gff",
"files",
"to",
"filter",
"out",
"non",
"-",
"coding",
"sequences",
"from",
"the",
"analysis"
] | 88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a | https://github.com/lowandrew/OLCTools/blob/88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a/coreGenome/annotate.py#L142-L159 | train |
lowandrew/OLCTools | coreGenome/annotate.py | Annotate.corethreads | def corethreads(self):
"""
Create a .cds file consisting of fasta records of CDS features for each strain
"""
printtime('Creating CDS files and finding core genes', self.start)
# Create and start threads
for i in range(self.cpus):
# Send the threads to the app... | python | def corethreads(self):
"""
Create a .cds file consisting of fasta records of CDS features for each strain
"""
printtime('Creating CDS files and finding core genes', self.start)
# Create and start threads
for i in range(self.cpus):
# Send the threads to the app... | [
"def",
"corethreads",
"(",
"self",
")",
":",
"printtime",
"(",
"'Creating CDS files and finding core genes'",
",",
"self",
".",
"start",
")",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"cpus",
")",
":",
"threads",
"=",
"Thread",
"(",
"target",
"=",
"self... | Create a .cds file consisting of fasta records of CDS features for each strain | [
"Create",
"a",
".",
"cds",
"file",
"consisting",
"of",
"fasta",
"records",
"of",
"CDS",
"features",
"for",
"each",
"strain"
] | 88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a | https://github.com/lowandrew/OLCTools/blob/88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a/coreGenome/annotate.py#L193-L212 | train |
lowandrew/OLCTools | coreGenome/annotate.py | Annotate.corewriter | def corewriter(self):
"""
Creates .fasta files containing all alleles for each gene
"""
printtime('Creating core allele files', self.start)
for gene in sorted(self.genesequence):
self.geneset.add(gene)
# Set the name of the allele file
genefile... | python | def corewriter(self):
"""
Creates .fasta files containing all alleles for each gene
"""
printtime('Creating core allele files', self.start)
for gene in sorted(self.genesequence):
self.geneset.add(gene)
# Set the name of the allele file
genefile... | [
"def",
"corewriter",
"(",
"self",
")",
":",
"printtime",
"(",
"'Creating core allele files'",
",",
"self",
".",
"start",
")",
"for",
"gene",
"in",
"sorted",
"(",
"self",
".",
"genesequence",
")",
":",
"self",
".",
"geneset",
".",
"add",
"(",
"gene",
")",... | Creates .fasta files containing all alleles for each gene | [
"Creates",
".",
"fasta",
"files",
"containing",
"all",
"alleles",
"for",
"each",
"gene"
] | 88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a | https://github.com/lowandrew/OLCTools/blob/88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a/coreGenome/annotate.py#L258-L304 | train |
lowandrew/OLCTools | coreGenome/annotate.py | Annotate.profiler | def profiler(self):
"""
Calculates the core profile for each strain
"""
printtime('Calculating core profiles', self.start)
# Only create the profile if it doesn't exist already
# if not os.path.isfile('{}/profile.txt'.format(self.profilelocation)):
for strain in s... | python | def profiler(self):
"""
Calculates the core profile for each strain
"""
printtime('Calculating core profiles', self.start)
# Only create the profile if it doesn't exist already
# if not os.path.isfile('{}/profile.txt'.format(self.profilelocation)):
for strain in s... | [
"def",
"profiler",
"(",
"self",
")",
":",
"printtime",
"(",
"'Calculating core profiles'",
",",
"self",
".",
"start",
")",
"for",
"strain",
"in",
"self",
".",
"corealleles",
":",
"self",
".",
"coreset",
".",
"add",
"(",
"tuple",
"(",
"sorted",
"(",
"self... | Calculates the core profile for each strain | [
"Calculates",
"the",
"core",
"profile",
"for",
"each",
"strain"
] | 88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a | https://github.com/lowandrew/OLCTools/blob/88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a/coreGenome/annotate.py#L328-L359 | train |
lowandrew/OLCTools | coreGenome/annotate.py | Annotate.linker | def linker(self):
"""
Link the sequence types to the strains. Create a .csv file of the linkages
"""
strainprofile = os.path.join(self.profilelocation, 'strainprofiles.txt')
if not os.path.isfile(strainprofile):
header = 'Strain,SequenceType\n'
data = ''
... | python | def linker(self):
"""
Link the sequence types to the strains. Create a .csv file of the linkages
"""
strainprofile = os.path.join(self.profilelocation, 'strainprofiles.txt')
if not os.path.isfile(strainprofile):
header = 'Strain,SequenceType\n'
data = ''
... | [
"def",
"linker",
"(",
"self",
")",
":",
"strainprofile",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"profilelocation",
",",
"'strainprofiles.txt'",
")",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"strainprofile",
")",
":",
"header",
... | Link the sequence types to the strains. Create a .csv file of the linkages | [
"Link",
"the",
"sequence",
"types",
"to",
"the",
"strains",
".",
"Create",
"a",
".",
"csv",
"file",
"of",
"the",
"linkages"
] | 88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a | https://github.com/lowandrew/OLCTools/blob/88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a/coreGenome/annotate.py#L361-L381 | train |
AllTheWayDown/turgles | turgles/buffer.py | ChunkBuffer.get | def get(self, index):
"""Get a chunk by index"""
assert index <= self.count
assert index < self.size
offset = index * self.chunk_size
return self.data[offset:offset + self.chunk_size] | python | def get(self, index):
"""Get a chunk by index"""
assert index <= self.count
assert index < self.size
offset = index * self.chunk_size
return self.data[offset:offset + self.chunk_size] | [
"def",
"get",
"(",
"self",
",",
"index",
")",
":",
"assert",
"index",
"<=",
"self",
".",
"count",
"assert",
"index",
"<",
"self",
".",
"size",
"offset",
"=",
"index",
"*",
"self",
".",
"chunk_size",
"return",
"self",
".",
"data",
"[",
"offset",
":",
... | Get a chunk by index | [
"Get",
"a",
"chunk",
"by",
"index"
] | 1bb17abe9b3aa0953d9a8e9b05a23369c5bf8852 | https://github.com/AllTheWayDown/turgles/blob/1bb17abe9b3aa0953d9a8e9b05a23369c5bf8852/turgles/buffer.py#L59-L64 | train |
AllTheWayDown/turgles | turgles/buffer.py | ChunkBuffer.new | def new(self, init=None):
"""Return the last currently unused chunk, resizing if needed.
If init is passed, chunk will be initialised to that data"""
if self.count >= self.size:
self.resize(self.count * 2)
chunk = self.get(self.count)
if init is not None:
... | python | def new(self, init=None):
"""Return the last currently unused chunk, resizing if needed.
If init is passed, chunk will be initialised to that data"""
if self.count >= self.size:
self.resize(self.count * 2)
chunk = self.get(self.count)
if init is not None:
... | [
"def",
"new",
"(",
"self",
",",
"init",
"=",
"None",
")",
":",
"if",
"self",
".",
"count",
">=",
"self",
".",
"size",
":",
"self",
".",
"resize",
"(",
"self",
".",
"count",
"*",
"2",
")",
"chunk",
"=",
"self",
".",
"get",
"(",
"self",
".",
"c... | Return the last currently unused chunk, resizing if needed.
If init is passed, chunk will be initialised to that data | [
"Return",
"the",
"last",
"currently",
"unused",
"chunk",
"resizing",
"if",
"needed",
"."
] | 1bb17abe9b3aa0953d9a8e9b05a23369c5bf8852 | https://github.com/AllTheWayDown/turgles/blob/1bb17abe9b3aa0953d9a8e9b05a23369c5bf8852/turgles/buffer.py#L66-L77 | train |
AllTheWayDown/turgles | turgles/buffer.py | ChunkBuffer.resize | def resize(self, new_size):
"""Create a new larger array, and copy data over"""
assert new_size > self.size
new_data = self._allocate(new_size)
# copy
new_data[0:self.size * self.chunk_size] = self.data
self.size = new_size
self.data = new_data | python | def resize(self, new_size):
"""Create a new larger array, and copy data over"""
assert new_size > self.size
new_data = self._allocate(new_size)
# copy
new_data[0:self.size * self.chunk_size] = self.data
self.size = new_size
self.data = new_data | [
"def",
"resize",
"(",
"self",
",",
"new_size",
")",
":",
"assert",
"new_size",
">",
"self",
".",
"size",
"new_data",
"=",
"self",
".",
"_allocate",
"(",
"new_size",
")",
"new_data",
"[",
"0",
":",
"self",
".",
"size",
"*",
"self",
".",
"chunk_size",
... | Create a new larger array, and copy data over | [
"Create",
"a",
"new",
"larger",
"array",
"and",
"copy",
"data",
"over"
] | 1bb17abe9b3aa0953d9a8e9b05a23369c5bf8852 | https://github.com/AllTheWayDown/turgles/blob/1bb17abe9b3aa0953d9a8e9b05a23369c5bf8852/turgles/buffer.py#L79-L86 | train |
AllTheWayDown/turgles | turgles/buffer.py | ChunkBuffer.remove | def remove(self, index):
"""Remove chunk at index.
Doesn't actually delete data, copies last chunk's data over data to be
removed, and decreases the count"""
assert index < self.count
last_index = self.count - 1
data = self.get(index)
if index == last_index:
... | python | def remove(self, index):
"""Remove chunk at index.
Doesn't actually delete data, copies last chunk's data over data to be
removed, and decreases the count"""
assert index < self.count
last_index = self.count - 1
data = self.get(index)
if index == last_index:
... | [
"def",
"remove",
"(",
"self",
",",
"index",
")",
":",
"assert",
"index",
"<",
"self",
".",
"count",
"last_index",
"=",
"self",
".",
"count",
"-",
"1",
"data",
"=",
"self",
".",
"get",
"(",
"index",
")",
"if",
"index",
"==",
"last_index",
":",
"last... | Remove chunk at index.
Doesn't actually delete data, copies last chunk's data over data to be
removed, and decreases the count | [
"Remove",
"chunk",
"at",
"index",
"."
] | 1bb17abe9b3aa0953d9a8e9b05a23369c5bf8852 | https://github.com/AllTheWayDown/turgles/blob/1bb17abe9b3aa0953d9a8e9b05a23369c5bf8852/turgles/buffer.py#L88-L112 | train |
AllTheWayDown/turgles | turgles/buffer.py | BufferManager.create_turtle | def create_turtle(self, id, shape, model_init, color_init):
"""Create a slice of memory for turtle data storage"""
assert id not in self.id_to_shape
data = self._create_turtle(id, shape, model_init, color_init)
self.id_to_shape[id] = shape
return data | python | def create_turtle(self, id, shape, model_init, color_init):
"""Create a slice of memory for turtle data storage"""
assert id not in self.id_to_shape
data = self._create_turtle(id, shape, model_init, color_init)
self.id_to_shape[id] = shape
return data | [
"def",
"create_turtle",
"(",
"self",
",",
"id",
",",
"shape",
",",
"model_init",
",",
"color_init",
")",
":",
"assert",
"id",
"not",
"in",
"self",
".",
"id_to_shape",
"data",
"=",
"self",
".",
"_create_turtle",
"(",
"id",
",",
"shape",
",",
"model_init",... | Create a slice of memory for turtle data storage | [
"Create",
"a",
"slice",
"of",
"memory",
"for",
"turtle",
"data",
"storage"
] | 1bb17abe9b3aa0953d9a8e9b05a23369c5bf8852 | https://github.com/AllTheWayDown/turgles/blob/1bb17abe9b3aa0953d9a8e9b05a23369c5bf8852/turgles/buffer.py#L210-L215 | train |
AllTheWayDown/turgles | turgles/buffer.py | BufferManager.set_shape | def set_shape(self, id, new_shape):
"""Copies the turtle data from the old shape buffer to the new"""
old_shape = self.id_to_shape[id]
old_buffer = self.get_buffer(old_shape)
model, color = old_buffer.get(id)
new_data = self._create_turtle(id, new_shape, model, color)
old... | python | def set_shape(self, id, new_shape):
"""Copies the turtle data from the old shape buffer to the new"""
old_shape = self.id_to_shape[id]
old_buffer = self.get_buffer(old_shape)
model, color = old_buffer.get(id)
new_data = self._create_turtle(id, new_shape, model, color)
old... | [
"def",
"set_shape",
"(",
"self",
",",
"id",
",",
"new_shape",
")",
":",
"old_shape",
"=",
"self",
".",
"id_to_shape",
"[",
"id",
"]",
"old_buffer",
"=",
"self",
".",
"get_buffer",
"(",
"old_shape",
")",
"model",
",",
"color",
"=",
"old_buffer",
".",
"g... | Copies the turtle data from the old shape buffer to the new | [
"Copies",
"the",
"turtle",
"data",
"from",
"the",
"old",
"shape",
"buffer",
"to",
"the",
"new"
] | 1bb17abe9b3aa0953d9a8e9b05a23369c5bf8852 | https://github.com/AllTheWayDown/turgles/blob/1bb17abe9b3aa0953d9a8e9b05a23369c5bf8852/turgles/buffer.py#L222-L230 | train |
hughsie/python-appstream | appstream/component.py | Release.get_checksum_by_target | def get_checksum_by_target(self, target):
""" returns a checksum of a specific kind """
for csum in self.checksums:
if csum.target == target:
return csum
return None | python | def get_checksum_by_target(self, target):
""" returns a checksum of a specific kind """
for csum in self.checksums:
if csum.target == target:
return csum
return None | [
"def",
"get_checksum_by_target",
"(",
"self",
",",
"target",
")",
":",
"for",
"csum",
"in",
"self",
".",
"checksums",
":",
"if",
"csum",
".",
"target",
"==",
"target",
":",
"return",
"csum",
"return",
"None"
] | returns a checksum of a specific kind | [
"returns",
"a",
"checksum",
"of",
"a",
"specific",
"kind"
] | f2606380278c5728ee7f8e7d19914c54fca05e76 | https://github.com/hughsie/python-appstream/blob/f2606380278c5728ee7f8e7d19914c54fca05e76/appstream/component.py#L155-L160 | train |
hughsie/python-appstream | appstream/component.py | Release.add_checksum | def add_checksum(self, csum):
""" Add a checksum to a release object """
for csum_tmp in self.checksums:
if csum_tmp.target == csum.target:
self.checksums.remove(csum_tmp)
break
self.checksums.append(csum) | python | def add_checksum(self, csum):
""" Add a checksum to a release object """
for csum_tmp in self.checksums:
if csum_tmp.target == csum.target:
self.checksums.remove(csum_tmp)
break
self.checksums.append(csum) | [
"def",
"add_checksum",
"(",
"self",
",",
"csum",
")",
":",
"for",
"csum_tmp",
"in",
"self",
".",
"checksums",
":",
"if",
"csum_tmp",
".",
"target",
"==",
"csum",
".",
"target",
":",
"self",
".",
"checksums",
".",
"remove",
"(",
"csum_tmp",
")",
"break"... | Add a checksum to a release object | [
"Add",
"a",
"checksum",
"to",
"a",
"release",
"object"
] | f2606380278c5728ee7f8e7d19914c54fca05e76 | https://github.com/hughsie/python-appstream/blob/f2606380278c5728ee7f8e7d19914c54fca05e76/appstream/component.py#L162-L168 | train |
hughsie/python-appstream | appstream/component.py | Screenshot.get_image_by_kind | def get_image_by_kind(self, kind):
""" returns a image of a specific kind """
for ss in self.images:
if ss.kind == kind:
return ss
return None | python | def get_image_by_kind(self, kind):
""" returns a image of a specific kind """
for ss in self.images:
if ss.kind == kind:
return ss
return None | [
"def",
"get_image_by_kind",
"(",
"self",
",",
"kind",
")",
":",
"for",
"ss",
"in",
"self",
".",
"images",
":",
"if",
"ss",
".",
"kind",
"==",
"kind",
":",
"return",
"ss",
"return",
"None"
] | returns a image of a specific kind | [
"returns",
"a",
"image",
"of",
"a",
"specific",
"kind"
] | f2606380278c5728ee7f8e7d19914c54fca05e76 | https://github.com/hughsie/python-appstream/blob/f2606380278c5728ee7f8e7d19914c54fca05e76/appstream/component.py#L260-L265 | train |
hughsie/python-appstream | appstream/component.py | Screenshot.add_image | def add_image(self, im):
""" Add a image to a screenshot object """
for im_tmp in self.images:
if im_tmp.kind == im.kind:
self.images.remove(im_tmp)
break
self.images.append(im) | python | def add_image(self, im):
""" Add a image to a screenshot object """
for im_tmp in self.images:
if im_tmp.kind == im.kind:
self.images.remove(im_tmp)
break
self.images.append(im) | [
"def",
"add_image",
"(",
"self",
",",
"im",
")",
":",
"for",
"im_tmp",
"in",
"self",
".",
"images",
":",
"if",
"im_tmp",
".",
"kind",
"==",
"im",
".",
"kind",
":",
"self",
".",
"images",
".",
"remove",
"(",
"im_tmp",
")",
"break",
"self",
".",
"i... | Add a image to a screenshot object | [
"Add",
"a",
"image",
"to",
"a",
"screenshot",
"object"
] | f2606380278c5728ee7f8e7d19914c54fca05e76 | https://github.com/hughsie/python-appstream/blob/f2606380278c5728ee7f8e7d19914c54fca05e76/appstream/component.py#L267-L273 | train |
hughsie/python-appstream | appstream/component.py | Component.add_screenshot | def add_screenshot(self, screenshot):
""" Add a screenshot object if it does not already exist """
if screenshot in self.screenshots:
return
self.screenshots.append(screenshot) | python | def add_screenshot(self, screenshot):
""" Add a screenshot object if it does not already exist """
if screenshot in self.screenshots:
return
self.screenshots.append(screenshot) | [
"def",
"add_screenshot",
"(",
"self",
",",
"screenshot",
")",
":",
"if",
"screenshot",
"in",
"self",
".",
"screenshots",
":",
"return",
"self",
".",
"screenshots",
".",
"append",
"(",
"screenshot",
")"
] | Add a screenshot object if it does not already exist | [
"Add",
"a",
"screenshot",
"object",
"if",
"it",
"does",
"not",
"already",
"exist"
] | f2606380278c5728ee7f8e7d19914c54fca05e76 | https://github.com/hughsie/python-appstream/blob/f2606380278c5728ee7f8e7d19914c54fca05e76/appstream/component.py#L446-L450 | train |
hughsie/python-appstream | appstream/component.py | Component.add_provide | def add_provide(self, provide):
""" Add a provide object if it does not already exist """
for p in self.provides:
if p.value == provide.value:
return
self.provides.append(provide) | python | def add_provide(self, provide):
""" Add a provide object if it does not already exist """
for p in self.provides:
if p.value == provide.value:
return
self.provides.append(provide) | [
"def",
"add_provide",
"(",
"self",
",",
"provide",
")",
":",
"for",
"p",
"in",
"self",
".",
"provides",
":",
"if",
"p",
".",
"value",
"==",
"provide",
".",
"value",
":",
"return",
"self",
".",
"provides",
".",
"append",
"(",
"provide",
")"
] | Add a provide object if it does not already exist | [
"Add",
"a",
"provide",
"object",
"if",
"it",
"does",
"not",
"already",
"exist"
] | f2606380278c5728ee7f8e7d19914c54fca05e76 | https://github.com/hughsie/python-appstream/blob/f2606380278c5728ee7f8e7d19914c54fca05e76/appstream/component.py#L452-L457 | train |
hughsie/python-appstream | appstream/component.py | Component.get_provides_by_kind | def get_provides_by_kind(self, kind):
""" Returns an array of provides of a certain kind """
provs = []
for p in self.provides:
if p.kind == kind:
provs.append(p)
return provs | python | def get_provides_by_kind(self, kind):
""" Returns an array of provides of a certain kind """
provs = []
for p in self.provides:
if p.kind == kind:
provs.append(p)
return provs | [
"def",
"get_provides_by_kind",
"(",
"self",
",",
"kind",
")",
":",
"provs",
"=",
"[",
"]",
"for",
"p",
"in",
"self",
".",
"provides",
":",
"if",
"p",
".",
"kind",
"==",
"kind",
":",
"provs",
".",
"append",
"(",
"p",
")",
"return",
"provs"
] | Returns an array of provides of a certain kind | [
"Returns",
"an",
"array",
"of",
"provides",
"of",
"a",
"certain",
"kind"
] | f2606380278c5728ee7f8e7d19914c54fca05e76 | https://github.com/hughsie/python-appstream/blob/f2606380278c5728ee7f8e7d19914c54fca05e76/appstream/component.py#L459-L465 | train |
hughsie/python-appstream | appstream/component.py | Component.add_require | def add_require(self, require):
""" Add a require object if it does not already exist """
for p in self.requires:
if p.value == require.value:
return
self.requires.append(require) | python | def add_require(self, require):
""" Add a require object if it does not already exist """
for p in self.requires:
if p.value == require.value:
return
self.requires.append(require) | [
"def",
"add_require",
"(",
"self",
",",
"require",
")",
":",
"for",
"p",
"in",
"self",
".",
"requires",
":",
"if",
"p",
".",
"value",
"==",
"require",
".",
"value",
":",
"return",
"self",
".",
"requires",
".",
"append",
"(",
"require",
")"
] | Add a require object if it does not already exist | [
"Add",
"a",
"require",
"object",
"if",
"it",
"does",
"not",
"already",
"exist"
] | f2606380278c5728ee7f8e7d19914c54fca05e76 | https://github.com/hughsie/python-appstream/blob/f2606380278c5728ee7f8e7d19914c54fca05e76/appstream/component.py#L467-L472 | train |
hughsie/python-appstream | appstream/component.py | Component.get_require_by_kind | def get_require_by_kind(self, kind, value):
""" Returns a requires object of a specific value """
for r in self.requires:
if r.kind == kind and r.value == value:
return r
return None | python | def get_require_by_kind(self, kind, value):
""" Returns a requires object of a specific value """
for r in self.requires:
if r.kind == kind and r.value == value:
return r
return None | [
"def",
"get_require_by_kind",
"(",
"self",
",",
"kind",
",",
"value",
")",
":",
"for",
"r",
"in",
"self",
".",
"requires",
":",
"if",
"r",
".",
"kind",
"==",
"kind",
"and",
"r",
".",
"value",
"==",
"value",
":",
"return",
"r",
"return",
"None"
] | Returns a requires object of a specific value | [
"Returns",
"a",
"requires",
"object",
"of",
"a",
"specific",
"value"
] | f2606380278c5728ee7f8e7d19914c54fca05e76 | https://github.com/hughsie/python-appstream/blob/f2606380278c5728ee7f8e7d19914c54fca05e76/appstream/component.py#L474-L479 | train |
hughsie/python-appstream | appstream/store.py | Store.to_file | def to_file(self, filename):
""" Save the store to disk """
# save compressed file
xml = self.to_xml()
f = gzip.open(filename, 'wb')
try:
f.write(xml.encode('utf-8'))
finally:
f.close() | python | def to_file(self, filename):
""" Save the store to disk """
# save compressed file
xml = self.to_xml()
f = gzip.open(filename, 'wb')
try:
f.write(xml.encode('utf-8'))
finally:
f.close() | [
"def",
"to_file",
"(",
"self",
",",
"filename",
")",
":",
"xml",
"=",
"self",
".",
"to_xml",
"(",
")",
"f",
"=",
"gzip",
".",
"open",
"(",
"filename",
",",
"'wb'",
")",
"try",
":",
"f",
".",
"write",
"(",
"xml",
".",
"encode",
"(",
"'utf-8'",
"... | Save the store to disk | [
"Save",
"the",
"store",
"to",
"disk"
] | f2606380278c5728ee7f8e7d19914c54fca05e76 | https://github.com/hughsie/python-appstream/blob/f2606380278c5728ee7f8e7d19914c54fca05e76/appstream/store.py#L52-L61 | train |
hughsie/python-appstream | appstream/store.py | Store.from_file | def from_file(self, filename):
""" Open the store from disk """
with gzip.open(filename, 'rb') as f:
self.parse(f.read()) | python | def from_file(self, filename):
""" Open the store from disk """
with gzip.open(filename, 'rb') as f:
self.parse(f.read()) | [
"def",
"from_file",
"(",
"self",
",",
"filename",
")",
":",
"with",
"gzip",
".",
"open",
"(",
"filename",
",",
"'rb'",
")",
"as",
"f",
":",
"self",
".",
"parse",
"(",
"f",
".",
"read",
"(",
")",
")"
] | Open the store from disk | [
"Open",
"the",
"store",
"from",
"disk"
] | f2606380278c5728ee7f8e7d19914c54fca05e76 | https://github.com/hughsie/python-appstream/blob/f2606380278c5728ee7f8e7d19914c54fca05e76/appstream/store.py#L63-L66 | train |
hughsie/python-appstream | appstream/store.py | Store.get_components | def get_components(self):
""" Returns all the applications from the store """
components = []
for app_id in self.components:
components.append(self.components[app_id])
return components | python | def get_components(self):
""" Returns all the applications from the store """
components = []
for app_id in self.components:
components.append(self.components[app_id])
return components | [
"def",
"get_components",
"(",
"self",
")",
":",
"components",
"=",
"[",
"]",
"for",
"app_id",
"in",
"self",
".",
"components",
":",
"components",
".",
"append",
"(",
"self",
".",
"components",
"[",
"app_id",
"]",
")",
"return",
"components"
] | Returns all the applications from the store | [
"Returns",
"all",
"the",
"applications",
"from",
"the",
"store"
] | f2606380278c5728ee7f8e7d19914c54fca05e76 | https://github.com/hughsie/python-appstream/blob/f2606380278c5728ee7f8e7d19914c54fca05e76/appstream/store.py#L74-L79 | train |
hughsie/python-appstream | appstream/store.py | Store.add | def add(self, component):
""" Add component to the store """
# if already exists, just add the release objects
old = self.get_component(component.id)
if old:
old.releases.extend(component.releases)
return
self.components[component.id] = component | python | def add(self, component):
""" Add component to the store """
# if already exists, just add the release objects
old = self.get_component(component.id)
if old:
old.releases.extend(component.releases)
return
self.components[component.id] = component | [
"def",
"add",
"(",
"self",
",",
"component",
")",
":",
"old",
"=",
"self",
".",
"get_component",
"(",
"component",
".",
"id",
")",
"if",
"old",
":",
"old",
".",
"releases",
".",
"extend",
"(",
"component",
".",
"releases",
")",
"return",
"self",
".",... | Add component to the store | [
"Add",
"component",
"to",
"the",
"store"
] | f2606380278c5728ee7f8e7d19914c54fca05e76 | https://github.com/hughsie/python-appstream/blob/f2606380278c5728ee7f8e7d19914c54fca05e76/appstream/store.py#L81-L89 | train |
yarbshk/sqlalchemy-dst | sqlalchemy_dst/sqlalchemy_dst.py | row2dict | def row2dict(row, depth=None, exclude=None, exclude_pk=None,
exclude_underscore=None, only=None, fk_suffix=None):
"""
Recursively walk row attributes to serialize ones into a dict.
:param row: instance of the declarative base class
:param depth: number that represent the depth of related r... | python | def row2dict(row, depth=None, exclude=None, exclude_pk=None,
exclude_underscore=None, only=None, fk_suffix=None):
"""
Recursively walk row attributes to serialize ones into a dict.
:param row: instance of the declarative base class
:param depth: number that represent the depth of related r... | [
"def",
"row2dict",
"(",
"row",
",",
"depth",
"=",
"None",
",",
"exclude",
"=",
"None",
",",
"exclude_pk",
"=",
"None",
",",
"exclude_underscore",
"=",
"None",
",",
"only",
"=",
"None",
",",
"fk_suffix",
"=",
"None",
")",
":",
"if",
"depth",
"==",
"0"... | Recursively walk row attributes to serialize ones into a dict.
:param row: instance of the declarative base class
:param depth: number that represent the depth of related relationships
:param exclude: set of attributes names to exclude
:param exclude_pk: are foreign keys (e.g. fk_name_id) excluded
... | [
"Recursively",
"walk",
"row",
"attributes",
"to",
"serialize",
"ones",
"into",
"a",
"dict",
"."
] | 8d1ff1a940180c8a7f78a5db1263afd6eb53b7b9 | https://github.com/yarbshk/sqlalchemy-dst/blob/8d1ff1a940180c8a7f78a5db1263afd6eb53b7b9/sqlalchemy_dst/sqlalchemy_dst.py#L53-L108 | train |
yarbshk/sqlalchemy-dst | sqlalchemy_dst/sqlalchemy_dst.py | dict2row | def dict2row(d, model, rel=None, exclude=None, exclude_pk=None,
exclude_underscore=None, only=None, fk_suffix=None):
"""
Recursively walk dict attributes to serialize ones into a row.
:param d: dict that represent a serialized row
:param model: class nested from the declarative base class
... | python | def dict2row(d, model, rel=None, exclude=None, exclude_pk=None,
exclude_underscore=None, only=None, fk_suffix=None):
"""
Recursively walk dict attributes to serialize ones into a row.
:param d: dict that represent a serialized row
:param model: class nested from the declarative base class
... | [
"def",
"dict2row",
"(",
"d",
",",
"model",
",",
"rel",
"=",
"None",
",",
"exclude",
"=",
"None",
",",
"exclude_pk",
"=",
"None",
",",
"exclude_underscore",
"=",
"None",
",",
"only",
"=",
"None",
",",
"fk_suffix",
"=",
"None",
")",
":",
"if",
"not",
... | Recursively walk dict attributes to serialize ones into a row.
:param d: dict that represent a serialized row
:param model: class nested from the declarative base class
:param rel: dict of key (relationship name) -value (class) pairs
:param exclude: set of attributes names to exclude
:param exclude... | [
"Recursively",
"walk",
"dict",
"attributes",
"to",
"serialize",
"ones",
"into",
"a",
"row",
"."
] | 8d1ff1a940180c8a7f78a5db1263afd6eb53b7b9 | https://github.com/yarbshk/sqlalchemy-dst/blob/8d1ff1a940180c8a7f78a5db1263afd6eb53b7b9/sqlalchemy_dst/sqlalchemy_dst.py#L110-L167 | train |
wylee/runcommands | runcommands/commands.py | copy_file | def copy_file(source, destination, follow_symlinks=True,
template: arg(type=bool_or(str), choices=('format', 'string')) = False,
context=None):
"""Copy source file to destination.
The destination may be a file path or a directory. When it's a
directory, the source file will be c... | python | def copy_file(source, destination, follow_symlinks=True,
template: arg(type=bool_or(str), choices=('format', 'string')) = False,
context=None):
"""Copy source file to destination.
The destination may be a file path or a directory. When it's a
directory, the source file will be c... | [
"def",
"copy_file",
"(",
"source",
",",
"destination",
",",
"follow_symlinks",
"=",
"True",
",",
"template",
":",
"arg",
"(",
"type",
"=",
"bool_or",
"(",
"str",
")",
",",
"choices",
"=",
"(",
"'format'",
",",
"'string'",
")",
")",
"=",
"False",
",",
... | Copy source file to destination.
The destination may be a file path or a directory. When it's a
directory, the source file will be copied into the directory
using the file's base name.
When the source file is a template, ``context`` will be used as the
template context. The supported template type... | [
"Copy",
"source",
"file",
"to",
"destination",
"."
] | b1d7c262885b9ced7ab89b63562f5464ca9970fe | https://github.com/wylee/runcommands/blob/b1d7c262885b9ced7ab89b63562f5464ca9970fe/runcommands/commands.py#L16-L57 | train |
wylee/runcommands | runcommands/commands.py | git_version | def git_version(short: 'Get short hash' = True, show: 'Print version to stdout' = False):
"""Get tag associated with HEAD; fall back to SHA1.
If HEAD is tagged, return the tag name; otherwise fall back to
HEAD's short SHA1 hash.
.. note:: Only annotated tags are considered.
.. note:: The output i... | python | def git_version(short: 'Get short hash' = True, show: 'Print version to stdout' = False):
"""Get tag associated with HEAD; fall back to SHA1.
If HEAD is tagged, return the tag name; otherwise fall back to
HEAD's short SHA1 hash.
.. note:: Only annotated tags are considered.
.. note:: The output i... | [
"def",
"git_version",
"(",
"short",
":",
"'Get short hash'",
"=",
"True",
",",
"show",
":",
"'Print version to stdout'",
"=",
"False",
")",
":",
"result",
"=",
"local",
"(",
"[",
"'git'",
",",
"'rev-parse'",
",",
"'--is-inside-work-tree'",
"]",
",",
"stdout",
... | Get tag associated with HEAD; fall back to SHA1.
If HEAD is tagged, return the tag name; otherwise fall back to
HEAD's short SHA1 hash.
.. note:: Only annotated tags are considered.
.. note:: The output isn't shown by default. To show it, pass the
``--show`` flag. | [
"Get",
"tag",
"associated",
"with",
"HEAD",
";",
"fall",
"back",
"to",
"SHA1",
"."
] | b1d7c262885b9ced7ab89b63562f5464ca9970fe | https://github.com/wylee/runcommands/blob/b1d7c262885b9ced7ab89b63562f5464ca9970fe/runcommands/commands.py#L61-L100 | train |
wylee/runcommands | runcommands/commands.py | remote | def remote(cmd: arg(container=list),
host,
user=None,
port=None,
sudo=False,
run_as=None,
shell='/bin/sh',
cd=None,
environ: arg(container=dict) = None,
paths=(),
# Args passed through to local command:
... | python | def remote(cmd: arg(container=list),
host,
user=None,
port=None,
sudo=False,
run_as=None,
shell='/bin/sh',
cd=None,
environ: arg(container=dict) = None,
paths=(),
# Args passed through to local command:
... | [
"def",
"remote",
"(",
"cmd",
":",
"arg",
"(",
"container",
"=",
"list",
")",
",",
"host",
",",
"user",
"=",
"None",
",",
"port",
"=",
"None",
",",
"sudo",
"=",
"False",
",",
"run_as",
"=",
"None",
",",
"shell",
"=",
"'/bin/sh'",
",",
"cd",
"=",
... | Run a remote command via SSH.
Runs a remote shell command using ``ssh`` in a subprocess like so:
ssh -q [-t] [<user>@]<host> [sudo [-u <run_as>] -H] /bin/sh -c '
[cd <cd> &&]
[export XYZ="xyz" &&]
[export PATH="<path>" &&]
<cmd>
'
Args:
cmd (list|str): The comm... | [
"Run",
"a",
"remote",
"command",
"via",
"SSH",
"."
] | b1d7c262885b9ced7ab89b63562f5464ca9970fe | https://github.com/wylee/runcommands/blob/b1d7c262885b9ced7ab89b63562f5464ca9970fe/runcommands/commands.py#L214-L308 | train |
wylee/runcommands | runcommands/commands.py | sync | def sync(source,
destination,
host,
user=None,
sudo=False,
run_as=None,
options=('-rltvz', '--no-perms', '--no-group'),
excludes=(),
exclude_from=None,
delete=False,
dry_run=False,
mode='u=rwX,g=rwX,o=',
quiet=Tr... | python | def sync(source,
destination,
host,
user=None,
sudo=False,
run_as=None,
options=('-rltvz', '--no-perms', '--no-group'),
excludes=(),
exclude_from=None,
delete=False,
dry_run=False,
mode='u=rwX,g=rwX,o=',
quiet=Tr... | [
"def",
"sync",
"(",
"source",
",",
"destination",
",",
"host",
",",
"user",
"=",
"None",
",",
"sudo",
"=",
"False",
",",
"run_as",
"=",
"None",
",",
"options",
"=",
"(",
"'-rltvz'",
",",
"'--no-perms'",
",",
"'--no-group'",
")",
",",
"excludes",
"=",
... | Sync files using rsync.
By default, a local ``source`` is pushed to a remote
``destination``. To pull from a remote ``source`` to a local
``destination`` instead, pass ``pull=True``. | [
"Sync",
"files",
"using",
"rsync",
"."
] | b1d7c262885b9ced7ab89b63562f5464ca9970fe | https://github.com/wylee/runcommands/blob/b1d7c262885b9ced7ab89b63562f5464ca9970fe/runcommands/commands.py#L312-L369 | train |
raymondEhlers/pachyderm | pachyderm/remove_outliers.py | _get_mean_and_median | def _get_mean_and_median(hist: Hist) -> Tuple[float, float]:
""" Retrieve the mean and median from a ROOT histogram.
Note:
These values are not so trivial to calculate without ROOT, as they are the bin values
weighted by the bin content.
Args:
hist: Histogram from which the values ... | python | def _get_mean_and_median(hist: Hist) -> Tuple[float, float]:
""" Retrieve the mean and median from a ROOT histogram.
Note:
These values are not so trivial to calculate without ROOT, as they are the bin values
weighted by the bin content.
Args:
hist: Histogram from which the values ... | [
"def",
"_get_mean_and_median",
"(",
"hist",
":",
"Hist",
")",
"->",
"Tuple",
"[",
"float",
",",
"float",
"]",
":",
"x",
"=",
"ctypes",
".",
"c_double",
"(",
"0",
")",
"q",
"=",
"ctypes",
".",
"c_double",
"(",
"0.5",
")",
"hist",
".",
"ComputeIntegral... | Retrieve the mean and median from a ROOT histogram.
Note:
These values are not so trivial to calculate without ROOT, as they are the bin values
weighted by the bin content.
Args:
hist: Histogram from which the values will be extract.
Returns:
mean, median of the histogram. | [
"Retrieve",
"the",
"mean",
"and",
"median",
"from",
"a",
"ROOT",
"histogram",
"."
] | aaa1d8374fd871246290ce76f1796f2f7582b01d | https://github.com/raymondEhlers/pachyderm/blob/aaa1d8374fd871246290ce76f1796f2f7582b01d/pachyderm/remove_outliers.py#L25-L47 | train |
raymondEhlers/pachyderm | pachyderm/remove_outliers.py | _project_to_part_level | def _project_to_part_level(hist: Hist, outliers_removal_axis: OutliersRemovalAxis) -> Hist:
""" Project the input histogram to the particle level axis.
Args:
hist: Histogram to check for outliers.
outliers_removal_axis: Axis along which outliers removal will be performed. Usually
th... | python | def _project_to_part_level(hist: Hist, outliers_removal_axis: OutliersRemovalAxis) -> Hist:
""" Project the input histogram to the particle level axis.
Args:
hist: Histogram to check for outliers.
outliers_removal_axis: Axis along which outliers removal will be performed. Usually
th... | [
"def",
"_project_to_part_level",
"(",
"hist",
":",
"Hist",
",",
"outliers_removal_axis",
":",
"OutliersRemovalAxis",
")",
"->",
"Hist",
":",
"import",
"ROOT",
"if",
"isinstance",
"(",
"hist",
",",
"(",
"ROOT",
".",
"TH2",
",",
"ROOT",
".",
"TH3",
")",
")",... | Project the input histogram to the particle level axis.
Args:
hist: Histogram to check for outliers.
outliers_removal_axis: Axis along which outliers removal will be performed. Usually
the particle level aixs.
Returns:
The histogram to check for outliers. | [
"Project",
"the",
"input",
"histogram",
"to",
"the",
"particle",
"level",
"axis",
"."
] | aaa1d8374fd871246290ce76f1796f2f7582b01d | https://github.com/raymondEhlers/pachyderm/blob/aaa1d8374fd871246290ce76f1796f2f7582b01d/pachyderm/remove_outliers.py#L54-L92 | train |
raymondEhlers/pachyderm | pachyderm/remove_outliers.py | _determine_outliers_index | def _determine_outliers_index(hist: Hist,
moving_average_threshold: float = 1.0,
number_of_values_to_search_ahead: int = 5,
limit_of_number_of_values_below_threshold: int = None) -> int:
""" Determine the location of where out... | python | def _determine_outliers_index(hist: Hist,
moving_average_threshold: float = 1.0,
number_of_values_to_search_ahead: int = 5,
limit_of_number_of_values_below_threshold: int = None) -> int:
""" Determine the location of where out... | [
"def",
"_determine_outliers_index",
"(",
"hist",
":",
"Hist",
",",
"moving_average_threshold",
":",
"float",
"=",
"1.0",
",",
"number_of_values_to_search_ahead",
":",
"int",
"=",
"5",
",",
"limit_of_number_of_values_below_threshold",
":",
"int",
"=",
"None",
")",
"-... | Determine the location of where outliers begin in a 1D histogram.
When the moving average falls below the limit, we consider the outliers to have begun.
To determine the location of outliers:
- Calculate the moving average for number_of_values_to_search_ahead values.
- First, the moving average must ... | [
"Determine",
"the",
"location",
"of",
"where",
"outliers",
"begin",
"in",
"a",
"1D",
"histogram",
"."
] | aaa1d8374fd871246290ce76f1796f2f7582b01d | https://github.com/raymondEhlers/pachyderm/blob/aaa1d8374fd871246290ce76f1796f2f7582b01d/pachyderm/remove_outliers.py#L94-L163 | train |
raymondEhlers/pachyderm | pachyderm/remove_outliers.py | _determine_outliers_for_moving_average | def _determine_outliers_for_moving_average(moving_average: np.ndarray,
moving_average_threshold: float,
number_of_values_to_search_ahead: int,
limit_of_number_of_values_below_threshold: int) ... | python | def _determine_outliers_for_moving_average(moving_average: np.ndarray,
moving_average_threshold: float,
number_of_values_to_search_ahead: int,
limit_of_number_of_values_below_threshold: int) ... | [
"def",
"_determine_outliers_for_moving_average",
"(",
"moving_average",
":",
"np",
".",
"ndarray",
",",
"moving_average_threshold",
":",
"float",
",",
"number_of_values_to_search_ahead",
":",
"int",
",",
"limit_of_number_of_values_below_threshold",
":",
"int",
")",
"->",
... | Determine outliers to remove from a given moving average.
Note:
The index returned is when the moving average first drops below the threshold for a moving average
calculated with that bin at the center. This is somewhat different from a standard moving average
calculation which would only l... | [
"Determine",
"outliers",
"to",
"remove",
"from",
"a",
"given",
"moving",
"average",
"."
] | aaa1d8374fd871246290ce76f1796f2f7582b01d | https://github.com/raymondEhlers/pachyderm/blob/aaa1d8374fd871246290ce76f1796f2f7582b01d/pachyderm/remove_outliers.py#L165-L235 | train |
raymondEhlers/pachyderm | pachyderm/remove_outliers.py | _remove_outliers_from_hist | def _remove_outliers_from_hist(hist: Hist, outliers_start_index: int, outliers_removal_axis: OutliersRemovalAxis) -> None:
""" Remove outliers from a given histogram.
Args:
hist: Histogram to check for outliers.
outliers_start_index: Index in the truth axis where outliers begin.
outlier... | python | def _remove_outliers_from_hist(hist: Hist, outliers_start_index: int, outliers_removal_axis: OutliersRemovalAxis) -> None:
""" Remove outliers from a given histogram.
Args:
hist: Histogram to check for outliers.
outliers_start_index: Index in the truth axis where outliers begin.
outlier... | [
"def",
"_remove_outliers_from_hist",
"(",
"hist",
":",
"Hist",
",",
"outliers_start_index",
":",
"int",
",",
"outliers_removal_axis",
":",
"OutliersRemovalAxis",
")",
"->",
"None",
":",
"if",
"outliers_start_index",
">",
"0",
":",
"x",
"=",
"ctypes",
".",
"c_int... | Remove outliers from a given histogram.
Args:
hist: Histogram to check for outliers.
outliers_start_index: Index in the truth axis where outliers begin.
outliers_removal_axis: Axis along which outliers removal will be performed. Usually
the particle level aixs.
Returns:
... | [
"Remove",
"outliers",
"from",
"a",
"given",
"histogram",
"."
] | aaa1d8374fd871246290ce76f1796f2f7582b01d | https://github.com/raymondEhlers/pachyderm/blob/aaa1d8374fd871246290ce76f1796f2f7582b01d/pachyderm/remove_outliers.py#L237-L273 | train |
yoannMoreau/landsat_theia | python/clipper_helper.py | Clipper.shapefile | def shapefile(self, file):
"""
reprojette en WGS84 et recupere l'extend
"""
driver = ogr.GetDriverByName('ESRI Shapefile')
dataset = driver.Open(file)
if dataset is not None:
# from Layer
layer = dataset.GetLayer()
spatialRef ... | python | def shapefile(self, file):
"""
reprojette en WGS84 et recupere l'extend
"""
driver = ogr.GetDriverByName('ESRI Shapefile')
dataset = driver.Open(file)
if dataset is not None:
# from Layer
layer = dataset.GetLayer()
spatialRef ... | [
"def",
"shapefile",
"(",
"self",
",",
"file",
")",
":",
"driver",
"=",
"ogr",
".",
"GetDriverByName",
"(",
"'ESRI Shapefile'",
")",
"dataset",
"=",
"driver",
".",
"Open",
"(",
"file",
")",
"if",
"dataset",
"is",
"not",
"None",
":",
"layer",
"=",
"datas... | reprojette en WGS84 et recupere l'extend | [
"reprojette",
"en",
"WGS84",
"et",
"recupere",
"l",
"extend"
] | d23831417dfb6d0da8c9ef5c121f3a731f4eec94 | https://github.com/yoannMoreau/landsat_theia/blob/d23831417dfb6d0da8c9ef5c121f3a731f4eec94/python/clipper_helper.py#L28-L68 | train |
portfors-lab/sparkle | sparkle/run/protocol_runner.py | ProtocolRunner.set_comment | def set_comment(self, cellid, comment):
"""Saves the provided comment to the current dataset.
:param cellid: number of the current cell
:type cellid: int
:param comment: a message to add documentation to data
:type comment: str
"""
info = {'cellid': cellid, 'comm... | python | def set_comment(self, cellid, comment):
"""Saves the provided comment to the current dataset.
:param cellid: number of the current cell
:type cellid: int
:param comment: a message to add documentation to data
:type comment: str
"""
info = {'cellid': cellid, 'comm... | [
"def",
"set_comment",
"(",
"self",
",",
"cellid",
",",
"comment",
")",
":",
"info",
"=",
"{",
"'cellid'",
":",
"cellid",
",",
"'comment'",
":",
"comment",
"}",
"self",
".",
"datafile",
".",
"set_metadata",
"(",
"self",
".",
"current_dataset_name",
",",
"... | Saves the provided comment to the current dataset.
:param cellid: number of the current cell
:type cellid: int
:param comment: a message to add documentation to data
:type comment: str | [
"Saves",
"the",
"provided",
"comment",
"to",
"the",
"current",
"dataset",
"."
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/run/protocol_runner.py#L82-L91 | train |
NoviceLive/pat | pat/main.py | main | def main(argument, sets, big_endian, optimal, output, clipboard,
quiet, verbose):
"""Customizable Lazy Exploit Pattern Utility."""
logger = logging.getLogger()
handler = logging.StreamHandler(sys.stderr)
handler.setFormatter(LevelFormatter())
logger.addHandler(handler)
logger.setLevel(l... | python | def main(argument, sets, big_endian, optimal, output, clipboard,
quiet, verbose):
"""Customizable Lazy Exploit Pattern Utility."""
logger = logging.getLogger()
handler = logging.StreamHandler(sys.stderr)
handler.setFormatter(LevelFormatter())
logger.addHandler(handler)
logger.setLevel(l... | [
"def",
"main",
"(",
"argument",
",",
"sets",
",",
"big_endian",
",",
"optimal",
",",
"output",
",",
"clipboard",
",",
"quiet",
",",
"verbose",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
")",
"handler",
"=",
"logging",
".",
"StreamHandler"... | Customizable Lazy Exploit Pattern Utility. | [
"Customizable",
"Lazy",
"Exploit",
"Pattern",
"Utility",
"."
] | bd223fc5e758213662befbebdf9538f3fbf58ad6 | https://github.com/NoviceLive/pat/blob/bd223fc5e758213662befbebdf9538f3fbf58ad6/pat/main.py#L49-L91 | train |
portfors-lab/sparkle | sparkle/gui/plotmenubar.py | PlotMenuBar.mousePressEvent | def mousePressEvent(self, event):
"""Marshalls behaviour depending on location of the mouse click"""
if event.x() < 50:
super(PlotMenuBar, self).mousePressEvent(event)
else:
# ignore to allow proper functioning of float
event.ignore() | python | def mousePressEvent(self, event):
"""Marshalls behaviour depending on location of the mouse click"""
if event.x() < 50:
super(PlotMenuBar, self).mousePressEvent(event)
else:
# ignore to allow proper functioning of float
event.ignore() | [
"def",
"mousePressEvent",
"(",
"self",
",",
"event",
")",
":",
"if",
"event",
".",
"x",
"(",
")",
"<",
"50",
":",
"super",
"(",
"PlotMenuBar",
",",
"self",
")",
".",
"mousePressEvent",
"(",
"event",
")",
"else",
":",
"event",
".",
"ignore",
"(",
")... | Marshalls behaviour depending on location of the mouse click | [
"Marshalls",
"behaviour",
"depending",
"on",
"location",
"of",
"the",
"mouse",
"click"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/plotmenubar.py#L27-L33 | train |
TorkamaniLab/metapipe | metapipe/runtime.py | Runtime.add | def add(self, command_template, job_class):
""" Given a command template, add it as a job to the queue. """
job = JobTemplate(command_template.alias,
command_template=command_template,
depends_on=command_template.depends_on, queue=self.queue,
job_class=job_class)
... | python | def add(self, command_template, job_class):
""" Given a command template, add it as a job to the queue. """
job = JobTemplate(command_template.alias,
command_template=command_template,
depends_on=command_template.depends_on, queue=self.queue,
job_class=job_class)
... | [
"def",
"add",
"(",
"self",
",",
"command_template",
",",
"job_class",
")",
":",
"job",
"=",
"JobTemplate",
"(",
"command_template",
".",
"alias",
",",
"command_template",
"=",
"command_template",
",",
"depends_on",
"=",
"command_template",
".",
"depends_on",
","... | Given a command template, add it as a job to the queue. | [
"Given",
"a",
"command",
"template",
"add",
"it",
"as",
"a",
"job",
"to",
"the",
"queue",
"."
] | 15592e5b0c217afb00ac03503f8d0d7453d4baf4 | https://github.com/TorkamaniLab/metapipe/blob/15592e5b0c217afb00ac03503f8d0d7453d4baf4/metapipe/runtime.py#L26-L32 | train |
TorkamaniLab/metapipe | metapipe/runtime.py | Runtime.run | def run(self):
""" Begins the runtime execution. """
iterations = 0
queue = self.queue.tick()
while True:
try:
next(queue)
except StopIteration:
break
iterations += 1
sleep(self.sleep_time)
return it... | python | def run(self):
""" Begins the runtime execution. """
iterations = 0
queue = self.queue.tick()
while True:
try:
next(queue)
except StopIteration:
break
iterations += 1
sleep(self.sleep_time)
return it... | [
"def",
"run",
"(",
"self",
")",
":",
"iterations",
"=",
"0",
"queue",
"=",
"self",
".",
"queue",
".",
"tick",
"(",
")",
"while",
"True",
":",
"try",
":",
"next",
"(",
"queue",
")",
"except",
"StopIteration",
":",
"break",
"iterations",
"+=",
"1",
"... | Begins the runtime execution. | [
"Begins",
"the",
"runtime",
"execution",
"."
] | 15592e5b0c217afb00ac03503f8d0d7453d4baf4 | https://github.com/TorkamaniLab/metapipe/blob/15592e5b0c217afb00ac03503f8d0d7453d4baf4/metapipe/runtime.py#L34-L46 | train |
by46/simplekit | simplekit/objson/dynamic_class.py | make_dynamic_class | def make_dynamic_class(typename, field_names):
"""a factory function to create type dynamically
The factory function is used by :func:`objson.load` and :func:`objson.loads`.
Creating the object deserialize from json string. The inspiration come from
:func:`collections.namedtuple`. the difference is tha... | python | def make_dynamic_class(typename, field_names):
"""a factory function to create type dynamically
The factory function is used by :func:`objson.load` and :func:`objson.loads`.
Creating the object deserialize from json string. The inspiration come from
:func:`collections.namedtuple`. the difference is tha... | [
"def",
"make_dynamic_class",
"(",
"typename",
",",
"field_names",
")",
":",
"if",
"isinstance",
"(",
"field_names",
",",
"basestring",
")",
":",
"field_names",
"=",
"field_names",
".",
"replace",
"(",
"\",\"",
",",
"\" \"",
")",
".",
"split",
"(",
")",
"fi... | a factory function to create type dynamically
The factory function is used by :func:`objson.load` and :func:`objson.loads`.
Creating the object deserialize from json string. The inspiration come from
:func:`collections.namedtuple`. the difference is that I don't your the class
template to define a dyna... | [
"a",
"factory",
"function",
"to",
"create",
"type",
"dynamically"
] | 33f3ce6de33accc185e1057f096af41859db5976 | https://github.com/by46/simplekit/blob/33f3ce6de33accc185e1057f096af41859db5976/simplekit/objson/dynamic_class.py#L46-L113 | train |
sirfoga/pyhal | hal/profile/mem.py | get_memory_usage | def get_memory_usage():
"""Gets RAM memory usage
:return: MB of memory used by this process
"""
process = psutil.Process(os.getpid())
mem = process.memory_info().rss
return mem / (1024 * 1024) | python | def get_memory_usage():
"""Gets RAM memory usage
:return: MB of memory used by this process
"""
process = psutil.Process(os.getpid())
mem = process.memory_info().rss
return mem / (1024 * 1024) | [
"def",
"get_memory_usage",
"(",
")",
":",
"process",
"=",
"psutil",
".",
"Process",
"(",
"os",
".",
"getpid",
"(",
")",
")",
"mem",
"=",
"process",
".",
"memory_info",
"(",
")",
".",
"rss",
"return",
"mem",
"/",
"(",
"1024",
"*",
"1024",
")"
] | Gets RAM memory usage
:return: MB of memory used by this process | [
"Gets",
"RAM",
"memory",
"usage"
] | 4394d8a1f7e45bea28a255ec390f4962ee64d33a | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/profile/mem.py#L11-L18 | train |
computational-metabolomics/msp2db | msp2db/db.py | create_db | def create_db(file_pth):
""" Create an empty SQLite database for library spectra.
Example:
>>> from msp2db.db import create_db
>>> db_pth = 'library.db'
>>> create_db(file_pth=db_pth)
Args:
file_pth (str): File path for SQLite database
"""
conn = sqlite3.connect(fi... | python | def create_db(file_pth):
""" Create an empty SQLite database for library spectra.
Example:
>>> from msp2db.db import create_db
>>> db_pth = 'library.db'
>>> create_db(file_pth=db_pth)
Args:
file_pth (str): File path for SQLite database
"""
conn = sqlite3.connect(fi... | [
"def",
"create_db",
"(",
"file_pth",
")",
":",
"conn",
"=",
"sqlite3",
".",
"connect",
"(",
"file_pth",
")",
"c",
"=",
"conn",
".",
"cursor",
"(",
")",
"c",
".",
"execute",
"(",
"'DROP TABLE IF EXISTS library_spectra_source'",
")",
"c",
".",
"execute",
"("... | Create an empty SQLite database for library spectra.
Example:
>>> from msp2db.db import create_db
>>> db_pth = 'library.db'
>>> create_db(file_pth=db_pth)
Args:
file_pth (str): File path for SQLite database | [
"Create",
"an",
"empty",
"SQLite",
"database",
"for",
"library",
"spectra",
"."
] | f86f01efca26fd2745547c9993f97337c6bef123 | https://github.com/computational-metabolomics/msp2db/blob/f86f01efca26fd2745547c9993f97337c6bef123/msp2db/db.py#L6-L96 | train |
computational-metabolomics/msp2db | msp2db/db.py | get_connection | def get_connection(db_type, db_pth, user=None, password=None, name=None):
""" Get a connection to a SQL database. Can be used for SQLite, MySQL or Django MySQL database
Example:
>>> from msp2db.db import get_connection
>>> conn = get_connection('sqlite', 'library.db')
If using "mysql" mysq... | python | def get_connection(db_type, db_pth, user=None, password=None, name=None):
""" Get a connection to a SQL database. Can be used for SQLite, MySQL or Django MySQL database
Example:
>>> from msp2db.db import get_connection
>>> conn = get_connection('sqlite', 'library.db')
If using "mysql" mysq... | [
"def",
"get_connection",
"(",
"db_type",
",",
"db_pth",
",",
"user",
"=",
"None",
",",
"password",
"=",
"None",
",",
"name",
"=",
"None",
")",
":",
"if",
"db_type",
"==",
"'sqlite'",
":",
"print",
"(",
"db_pth",
")",
"conn",
"=",
"sqlite3",
".",
"con... | Get a connection to a SQL database. Can be used for SQLite, MySQL or Django MySQL database
Example:
>>> from msp2db.db import get_connection
>>> conn = get_connection('sqlite', 'library.db')
If using "mysql" mysql.connector needs to be installed.
If using "django_mysql" Django needs to be... | [
"Get",
"a",
"connection",
"to",
"a",
"SQL",
"database",
".",
"Can",
"be",
"used",
"for",
"SQLite",
"MySQL",
"or",
"Django",
"MySQL",
"database"
] | f86f01efca26fd2745547c9993f97337c6bef123 | https://github.com/computational-metabolomics/msp2db/blob/f86f01efca26fd2745547c9993f97337c6bef123/msp2db/db.py#L99-L129 | train |
computational-metabolomics/msp2db | msp2db/db.py | db_dict | def db_dict(c):
""" Get a dictionary of the library spectra from a database
Example:
>>> from msp2db.db import get_connection
>>> conn = get_connection('sqlite', 'library.db')
>>> test_db_d = db_dict(conn.cursor())
If using a large database the resulting dictionary will be very lar... | python | def db_dict(c):
""" Get a dictionary of the library spectra from a database
Example:
>>> from msp2db.db import get_connection
>>> conn = get_connection('sqlite', 'library.db')
>>> test_db_d = db_dict(conn.cursor())
If using a large database the resulting dictionary will be very lar... | [
"def",
"db_dict",
"(",
"c",
")",
":",
"db_d",
"=",
"{",
"}",
"c",
".",
"execute",
"(",
"'SELECT * FROM library_spectra'",
")",
"db_d",
"[",
"'library_spectra'",
"]",
"=",
"[",
"list",
"(",
"row",
")",
"for",
"row",
"in",
"c",
"]",
"c",
".",
"execute"... | Get a dictionary of the library spectra from a database
Example:
>>> from msp2db.db import get_connection
>>> conn = get_connection('sqlite', 'library.db')
>>> test_db_d = db_dict(conn.cursor())
If using a large database the resulting dictionary will be very large!
Args:
c... | [
"Get",
"a",
"dictionary",
"of",
"the",
"library",
"spectra",
"from",
"a",
"database"
] | f86f01efca26fd2745547c9993f97337c6bef123 | https://github.com/computational-metabolomics/msp2db/blob/f86f01efca26fd2745547c9993f97337c6bef123/msp2db/db.py#L132-L167 | train |
computational-metabolomics/msp2db | msp2db/db.py | insert_query_m | def insert_query_m(data, table, conn, columns=None, db_type='mysql'):
""" Insert python list of tuples into SQL table
Args:
data (list): List of tuples
table (str): Name of database table
conn (connection object): database connection object
columns (str): String of column names ... | python | def insert_query_m(data, table, conn, columns=None, db_type='mysql'):
""" Insert python list of tuples into SQL table
Args:
data (list): List of tuples
table (str): Name of database table
conn (connection object): database connection object
columns (str): String of column names ... | [
"def",
"insert_query_m",
"(",
"data",
",",
"table",
",",
"conn",
",",
"columns",
"=",
"None",
",",
"db_type",
"=",
"'mysql'",
")",
":",
"if",
"len",
"(",
"data",
")",
">",
"10000",
":",
"_chunk_query",
"(",
"data",
",",
"10000",
",",
"columns",
",",
... | Insert python list of tuples into SQL table
Args:
data (list): List of tuples
table (str): Name of database table
conn (connection object): database connection object
columns (str): String of column names to use if not assigned then all columns are presumed to be used [Optional]
... | [
"Insert",
"python",
"list",
"of",
"tuples",
"into",
"SQL",
"table"
] | f86f01efca26fd2745547c9993f97337c6bef123 | https://github.com/computational-metabolomics/msp2db/blob/f86f01efca26fd2745547c9993f97337c6bef123/msp2db/db.py#L170-L205 | train |
computational-metabolomics/msp2db | msp2db/db.py | _chunk_query | def _chunk_query(l, n, cn, conn, table, db_type):
""" Call for inserting SQL query in chunks based on n rows
Args:
l (list): List of tuples
n (int): Number of rows
cn (str): Column names
conn (connection object): Database connection object
table (str): Table name
... | python | def _chunk_query(l, n, cn, conn, table, db_type):
""" Call for inserting SQL query in chunks based on n rows
Args:
l (list): List of tuples
n (int): Number of rows
cn (str): Column names
conn (connection object): Database connection object
table (str): Table name
... | [
"def",
"_chunk_query",
"(",
"l",
",",
"n",
",",
"cn",
",",
"conn",
",",
"table",
",",
"db_type",
")",
":",
"[",
"insert_query_m",
"(",
"l",
"[",
"i",
":",
"i",
"+",
"n",
"]",
",",
"table",
",",
"conn",
",",
"cn",
",",
"db_type",
")",
"for",
"... | Call for inserting SQL query in chunks based on n rows
Args:
l (list): List of tuples
n (int): Number of rows
cn (str): Column names
conn (connection object): Database connection object
table (str): Table name
db_type (str): If "sqlite" or "mysql" | [
"Call",
"for",
"inserting",
"SQL",
"query",
"in",
"chunks",
"based",
"on",
"n",
"rows"
] | f86f01efca26fd2745547c9993f97337c6bef123 | https://github.com/computational-metabolomics/msp2db/blob/f86f01efca26fd2745547c9993f97337c6bef123/msp2db/db.py#L207-L220 | train |
Frzk/Ellis | ellis_actions/mail.py | send | async def send(from_addr, to_addrs, subject="Ellis", msg="", **kwargs):
"""
Sends an e-mail to the provided address.
:param from_addr: E-mail address of the sender.
:type from_addr: str
:param to_addrs: E-mail address(es) of the receiver(s).
:type to_addrs: list or str
:param msg: Message t... | python | async def send(from_addr, to_addrs, subject="Ellis", msg="", **kwargs):
"""
Sends an e-mail to the provided address.
:param from_addr: E-mail address of the sender.
:type from_addr: str
:param to_addrs: E-mail address(es) of the receiver(s).
:type to_addrs: list or str
:param msg: Message t... | [
"async",
"def",
"send",
"(",
"from_addr",
",",
"to_addrs",
",",
"subject",
"=",
"\"Ellis\"",
",",
"msg",
"=",
"\"\"",
",",
"**",
"kwargs",
")",
":",
"async",
"with",
"SMTP",
"(",
")",
"as",
"client",
":",
"msg",
"=",
"\"Subject: {0}\\n\\n{1}\"",
".",
"... | Sends an e-mail to the provided address.
:param from_addr: E-mail address of the sender.
:type from_addr: str
:param to_addrs: E-mail address(es) of the receiver(s).
:type to_addrs: list or str
:param msg: Message to be sent.
:type msg: str | [
"Sends",
"an",
"e",
"-",
"mail",
"to",
"the",
"provided",
"address",
"."
] | 39ce8987cbc503354cf1f45927344186a8b18363 | https://github.com/Frzk/Ellis/blob/39ce8987cbc503354cf1f45927344186a8b18363/ellis_actions/mail.py#L10-L39 | train |
sirfoga/pyhal | hal/ml/correlation.py | CorrelationMatrix.show_correlation_matrix | def show_correlation_matrix(self, correlation_matrix):
"""Shows the given correlation matrix as image
:param correlation_matrix: Correlation matrix of features
"""
cr_plot.create_correlation_matrix_plot(
correlation_matrix, self.title, self.headers_to_test
)
... | python | def show_correlation_matrix(self, correlation_matrix):
"""Shows the given correlation matrix as image
:param correlation_matrix: Correlation matrix of features
"""
cr_plot.create_correlation_matrix_plot(
correlation_matrix, self.title, self.headers_to_test
)
... | [
"def",
"show_correlation_matrix",
"(",
"self",
",",
"correlation_matrix",
")",
":",
"cr_plot",
".",
"create_correlation_matrix_plot",
"(",
"correlation_matrix",
",",
"self",
".",
"title",
",",
"self",
".",
"headers_to_test",
")",
"pyplot",
".",
"show",
"(",
")"
] | Shows the given correlation matrix as image
:param correlation_matrix: Correlation matrix of features | [
"Shows",
"the",
"given",
"correlation",
"matrix",
"as",
"image"
] | 4394d8a1f7e45bea28a255ec390f4962ee64d33a | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/ml/correlation.py#L42-L50 | train |
sirfoga/pyhal | hal/ml/correlation.py | CorrelationMatrix.save_to_file | def save_to_file(self, out_file):
"""Saves correlation matrix of selected headers
:param out_file: Output file
"""
correlation_matrix = self.get_correlation_matrix_from_columns()
cr_plot.create_correlation_matrix_plot(
correlation_matrix, self.title, self.headers_to_... | python | def save_to_file(self, out_file):
"""Saves correlation matrix of selected headers
:param out_file: Output file
"""
correlation_matrix = self.get_correlation_matrix_from_columns()
cr_plot.create_correlation_matrix_plot(
correlation_matrix, self.title, self.headers_to_... | [
"def",
"save_to_file",
"(",
"self",
",",
"out_file",
")",
":",
"correlation_matrix",
"=",
"self",
".",
"get_correlation_matrix_from_columns",
"(",
")",
"cr_plot",
".",
"create_correlation_matrix_plot",
"(",
"correlation_matrix",
",",
"self",
".",
"title",
",",
"self... | Saves correlation matrix of selected headers
:param out_file: Output file | [
"Saves",
"correlation",
"matrix",
"of",
"selected",
"headers"
] | 4394d8a1f7e45bea28a255ec390f4962ee64d33a | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/ml/correlation.py#L77-L88 | train |
sirfoga/pyhal | hal/ml/correlation.py | CorrelationMatrix.save_correlation_matrix_from_folder | def save_correlation_matrix_from_folder(folder_path):
"""Saves each file's correlation matrix of common headers
:param folder_path: Folder containing logs data
"""
file_name = "output-" + str(int(time.time()))
output_folder = os.path.join(folder_path, file_name)
os.maked... | python | def save_correlation_matrix_from_folder(folder_path):
"""Saves each file's correlation matrix of common headers
:param folder_path: Folder containing logs data
"""
file_name = "output-" + str(int(time.time()))
output_folder = os.path.join(folder_path, file_name)
os.maked... | [
"def",
"save_correlation_matrix_from_folder",
"(",
"folder_path",
")",
":",
"file_name",
"=",
"\"output-\"",
"+",
"str",
"(",
"int",
"(",
"time",
".",
"time",
"(",
")",
")",
")",
"output_folder",
"=",
"os",
".",
"path",
".",
"join",
"(",
"folder_path",
","... | Saves each file's correlation matrix of common headers
:param folder_path: Folder containing logs data | [
"Saves",
"each",
"file",
"s",
"correlation",
"matrix",
"of",
"common",
"headers"
] | 4394d8a1f7e45bea28a255ec390f4962ee64d33a | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/ml/correlation.py#L91-L114 | train |
JukeboxPipeline/jukeboxmaya | src/jukeboxmaya/addons/mayamgmt/mayamgmt.py | MayaMGMT.run | def run(self, *args, **kwargs):
"""Start the tool
:returns: None
:rtype: None
:raises: None
"""
pm = MayaPluginManager.get()
guerilla = pm.get_plugin("GuerillaMGMT")
mayawin = maya_main_window()
guerilla.run(parent=mayawin) | python | def run(self, *args, **kwargs):
"""Start the tool
:returns: None
:rtype: None
:raises: None
"""
pm = MayaPluginManager.get()
guerilla = pm.get_plugin("GuerillaMGMT")
mayawin = maya_main_window()
guerilla.run(parent=mayawin) | [
"def",
"run",
"(",
"self",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"pm",
"=",
"MayaPluginManager",
".",
"get",
"(",
")",
"guerilla",
"=",
"pm",
".",
"get_plugin",
"(",
"\"GuerillaMGMT\"",
")",
"mayawin",
"=",
"maya_main_window",
"(",
")",
"gue... | Start the tool
:returns: None
:rtype: None
:raises: None | [
"Start",
"the",
"tool"
] | c8d6318d53cdb5493453c4a6b65ef75bdb2d5f2c | https://github.com/JukeboxPipeline/jukeboxmaya/blob/c8d6318d53cdb5493453c4a6b65ef75bdb2d5f2c/src/jukeboxmaya/addons/mayamgmt/mayamgmt.py#L62-L72 | train |
lsst-sqre/sqre-codekit | codekit/pygithub.py | login_github | def login_github(token_path=None, token=None):
"""Log into GitHub using an existing token.
Parameters
----------
token_path : str, optional
Path to the token file. The default token is used otherwise.
token: str, optional
Literal token string. If specified, this value is used inste... | python | def login_github(token_path=None, token=None):
"""Log into GitHub using an existing token.
Parameters
----------
token_path : str, optional
Path to the token file. The default token is used otherwise.
token: str, optional
Literal token string. If specified, this value is used inste... | [
"def",
"login_github",
"(",
"token_path",
"=",
"None",
",",
"token",
"=",
"None",
")",
":",
"token",
"=",
"codetools",
".",
"github_token",
"(",
"token_path",
"=",
"token_path",
",",
"token",
"=",
"token",
")",
"g",
"=",
"Github",
"(",
"token",
")",
"d... | Log into GitHub using an existing token.
Parameters
----------
token_path : str, optional
Path to the token file. The default token is used otherwise.
token: str, optional
Literal token string. If specified, this value is used instead of
reading from the token_path file.
R... | [
"Log",
"into",
"GitHub",
"using",
"an",
"existing",
"token",
"."
] | 98122404cd9065d4d1d570867fe518042669126c | https://github.com/lsst-sqre/sqre-codekit/blob/98122404cd9065d4d1d570867fe518042669126c/codekit/pygithub.py#L159-L180 | train |
lsst-sqre/sqre-codekit | codekit/pygithub.py | find_tag_by_name | def find_tag_by_name(repo, tag_name, safe=True):
"""Find tag by name in a github Repository
Parameters
----------
repo: :class:`github.Repository` instance
tag_name: str
Short name of tag (not a fully qualified ref).
safe: bool, optional
Defaults to `True`. When `True`, `None`... | python | def find_tag_by_name(repo, tag_name, safe=True):
"""Find tag by name in a github Repository
Parameters
----------
repo: :class:`github.Repository` instance
tag_name: str
Short name of tag (not a fully qualified ref).
safe: bool, optional
Defaults to `True`. When `True`, `None`... | [
"def",
"find_tag_by_name",
"(",
"repo",
",",
"tag_name",
",",
"safe",
"=",
"True",
")",
":",
"tagfmt",
"=",
"'tags/{ref}'",
".",
"format",
"(",
"ref",
"=",
"tag_name",
")",
"try",
":",
"ref",
"=",
"repo",
".",
"get_git_ref",
"(",
"tagfmt",
")",
"if",
... | Find tag by name in a github Repository
Parameters
----------
repo: :class:`github.Repository` instance
tag_name: str
Short name of tag (not a fully qualified ref).
safe: bool, optional
Defaults to `True`. When `True`, `None` is returned on failure. When
`False`, an except... | [
"Find",
"tag",
"by",
"name",
"in",
"a",
"github",
"Repository"
] | 98122404cd9065d4d1d570867fe518042669126c | https://github.com/lsst-sqre/sqre-codekit/blob/98122404cd9065d4d1d570867fe518042669126c/codekit/pygithub.py#L184-L217 | train |
lsst-sqre/sqre-codekit | codekit/pygithub.py | debug_ratelimit | def debug_ratelimit(g):
"""Log debug of github ratelimit information from last API call
Parameters
----------
org: github.MainClass.Github
github object
"""
assert isinstance(g, github.MainClass.Github), type(g)
debug("github ratelimit: {rl}".format(rl=g.rate_limiting)) | python | def debug_ratelimit(g):
"""Log debug of github ratelimit information from last API call
Parameters
----------
org: github.MainClass.Github
github object
"""
assert isinstance(g, github.MainClass.Github), type(g)
debug("github ratelimit: {rl}".format(rl=g.rate_limiting)) | [
"def",
"debug_ratelimit",
"(",
"g",
")",
":",
"assert",
"isinstance",
"(",
"g",
",",
"github",
".",
"MainClass",
".",
"Github",
")",
",",
"type",
"(",
"g",
")",
"debug",
"(",
"\"github ratelimit: {rl}\"",
".",
"format",
"(",
"rl",
"=",
"g",
".",
"rate_... | Log debug of github ratelimit information from last API call
Parameters
----------
org: github.MainClass.Github
github object | [
"Log",
"debug",
"of",
"github",
"ratelimit",
"information",
"from",
"last",
"API",
"call"
] | 98122404cd9065d4d1d570867fe518042669126c | https://github.com/lsst-sqre/sqre-codekit/blob/98122404cd9065d4d1d570867fe518042669126c/codekit/pygithub.py#L292-L302 | train |
lsst-sqre/sqre-codekit | codekit/pygithub.py | get_default_ref | def get_default_ref(repo):
"""Return a `github.GitRef` object for the HEAD of the default branch.
Parameters
----------
repo: github.Repository.Repository
repo to get default branch head ref from
Returns
-------
head : :class:`github.GitRef` instance
Raises
------
gith... | python | def get_default_ref(repo):
"""Return a `github.GitRef` object for the HEAD of the default branch.
Parameters
----------
repo: github.Repository.Repository
repo to get default branch head ref from
Returns
-------
head : :class:`github.GitRef` instance
Raises
------
gith... | [
"def",
"get_default_ref",
"(",
"repo",
")",
":",
"assert",
"isinstance",
"(",
"repo",
",",
"github",
".",
"Repository",
".",
"Repository",
")",
",",
"type",
"(",
"repo",
")",
"default_branch",
"=",
"repo",
".",
"default_branch",
"default_branch_ref",
"=",
"\... | Return a `github.GitRef` object for the HEAD of the default branch.
Parameters
----------
repo: github.Repository.Repository
repo to get default branch head ref from
Returns
-------
head : :class:`github.GitRef` instance
Raises
------
github.RateLimitExceededException
... | [
"Return",
"a",
"github",
".",
"GitRef",
"object",
"for",
"the",
"HEAD",
"of",
"the",
"default",
"branch",
"."
] | 98122404cd9065d4d1d570867fe518042669126c | https://github.com/lsst-sqre/sqre-codekit/blob/98122404cd9065d4d1d570867fe518042669126c/codekit/pygithub.py#L353-L385 | train |
usc-isi-i2/dig-crf-tokenizer | digCrfTokenizer/crf_tokenizer.py | main | def main(argv=None):
'''this is called if run from command line'''
t = CrfTokenizer()
print t.tokenize("This is a sentence.")
print t.tokenize("Buy???This...Now!!!")
print t.tokenize("The <bold>only</bold> source.")
print t.tokenize("The<bold>only</bold>source.")
print t.tokenize("Big>li... | python | def main(argv=None):
'''this is called if run from command line'''
t = CrfTokenizer()
print t.tokenize("This is a sentence.")
print t.tokenize("Buy???This...Now!!!")
print t.tokenize("The <bold>only</bold> source.")
print t.tokenize("The<bold>only</bold>source.")
print t.tokenize("Big>li... | [
"def",
"main",
"(",
"argv",
"=",
"None",
")",
":",
"t",
"=",
"CrfTokenizer",
"(",
")",
"print",
"t",
".",
"tokenize",
"(",
"\"This is a sentence.\"",
")",
"print",
"t",
".",
"tokenize",
"(",
"\"Buy???This...Now!!!\"",
")",
"print",
"t",
".",
"tokenize",
... | this is called if run from command line | [
"this",
"is",
"called",
"if",
"run",
"from",
"command",
"line"
] | f06458af40e648a968e547aead4510ff07bb5304 | https://github.com/usc-isi-i2/dig-crf-tokenizer/blob/f06458af40e648a968e547aead4510ff07bb5304/digCrfTokenizer/crf_tokenizer.py#L357-L403 | train |
portfors-lab/sparkle | sparkle/gui/controlwindow.py | ControlWindow.verifyInputs | def verifyInputs(self, mode):
"""Goes through and checks all stimuli and input settings are valid
and consistent. Prompts user with a message if there is a condition
that would prevent acquisition.
:param mode: The mode of acquisition trying to be run. Options are
'chart', o... | python | def verifyInputs(self, mode):
"""Goes through and checks all stimuli and input settings are valid
and consistent. Prompts user with a message if there is a condition
that would prevent acquisition.
:param mode: The mode of acquisition trying to be run. Options are
'chart', o... | [
"def",
"verifyInputs",
"(",
"self",
",",
"mode",
")",
":",
"if",
"len",
"(",
"self",
".",
"_aichans",
")",
"<",
"1",
":",
"failmsg",
"=",
"\"Must have at least one input channel selected\"",
"QtGui",
".",
"QMessageBox",
".",
"warning",
"(",
"self",
",",
"\"I... | Goes through and checks all stimuli and input settings are valid
and consistent. Prompts user with a message if there is a condition
that would prevent acquisition.
:param mode: The mode of acquisition trying to be run. Options are
'chart', or anthing else ('explore', 'protocol', 'c... | [
"Goes",
"through",
"and",
"checks",
"all",
"stimuli",
"and",
"input",
"settings",
"are",
"valid",
"and",
"consistent",
".",
"Prompts",
"user",
"with",
"a",
"message",
"if",
"there",
"is",
"a",
"condition",
"that",
"would",
"prevent",
"acquisition",
"."
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/controlwindow.py#L93-L159 | train |
portfors-lab/sparkle | sparkle/gui/controlwindow.py | ControlWindow.updateUnitLabels | def updateUnitLabels(self, tscale, fscale):
"""When the GUI unit scale changes, it is neccessary to update
the unit labels on all fields throughout the GUI. This handles
The main window, and also notifys other windows to update
Only supports for conversion between two values :
... | python | def updateUnitLabels(self, tscale, fscale):
"""When the GUI unit scale changes, it is neccessary to update
the unit labels on all fields throughout the GUI. This handles
The main window, and also notifys other windows to update
Only supports for conversion between two values :
... | [
"def",
"updateUnitLabels",
"(",
"self",
",",
"tscale",
",",
"fscale",
")",
":",
"AbstractEditorWidget",
".",
"updateScales",
"(",
"tscale",
",",
"fscale",
")",
"SmartDelegate",
".",
"updateScales",
"(",
"tscale",
",",
"fscale",
")",
"AbstractEditorWidget",
".",
... | When the GUI unit scale changes, it is neccessary to update
the unit labels on all fields throughout the GUI. This handles
The main window, and also notifys other windows to update
Only supports for conversion between two values :
* seconds and miliseconds for time
... | [
"When",
"the",
"GUI",
"unit",
"scale",
"changes",
"it",
"is",
"neccessary",
"to",
"update",
"the",
"unit",
"labels",
"on",
"all",
"fields",
"throughout",
"the",
"GUI",
".",
"This",
"handles",
"The",
"main",
"window",
"and",
"also",
"notifys",
"other",
"win... | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/controlwindow.py#L161-L201 | train |
portfors-lab/sparkle | sparkle/gui/controlwindow.py | ControlWindow.reset_device_channels | def reset_device_channels(self):
"""Updates the input channel selection boxes based on the current
device name stored in this object"""
# clear boxes first
self.ui.aochanBox.clear()
devname = self.advanced_options['device_name']
device_list = get_devices()
if devn... | python | def reset_device_channels(self):
"""Updates the input channel selection boxes based on the current
device name stored in this object"""
# clear boxes first
self.ui.aochanBox.clear()
devname = self.advanced_options['device_name']
device_list = get_devices()
if devn... | [
"def",
"reset_device_channels",
"(",
"self",
")",
":",
"self",
".",
"ui",
".",
"aochanBox",
".",
"clear",
"(",
")",
"devname",
"=",
"self",
".",
"advanced_options",
"[",
"'device_name'",
"]",
"device_list",
"=",
"get_devices",
"(",
")",
"if",
"devname",
"i... | Updates the input channel selection boxes based on the current
device name stored in this object | [
"Updates",
"the",
"input",
"channel",
"selection",
"boxes",
"based",
"on",
"the",
"current",
"device",
"name",
"stored",
"in",
"this",
"object"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/controlwindow.py#L203-L240 | train |
portfors-lab/sparkle | sparkle/gui/controlwindow.py | ControlWindow.saveInputs | def saveInputs(self, fname):
"""Save the values in the input fields so they can be loaded
next time the GUI is run
:param fname: file path of location to store values at
:type fname: str
"""
# save current inputs to file for loading next time
if not fname:
... | python | def saveInputs(self, fname):
"""Save the values in the input fields so they can be loaded
next time the GUI is run
:param fname: file path of location to store values at
:type fname: str
"""
# save current inputs to file for loading next time
if not fname:
... | [
"def",
"saveInputs",
"(",
"self",
",",
"fname",
")",
":",
"if",
"not",
"fname",
":",
"return",
"appdir",
"=",
"systools",
".",
"get_appdir",
"(",
")",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"appdir",
")",
":",
"os",
".",
"makedirs",
"("... | Save the values in the input fields so they can be loaded
next time the GUI is run
:param fname: file path of location to store values at
:type fname: str | [
"Save",
"the",
"values",
"in",
"the",
"input",
"fields",
"so",
"they",
"can",
"be",
"loaded",
"next",
"time",
"the",
"GUI",
"is",
"run"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/controlwindow.py#L242-L293 | train |
portfors-lab/sparkle | sparkle/gui/controlwindow.py | ControlWindow.closeEvent | def closeEvent(self, event):
"""Closes listening threads and saves GUI data for later use.
Re-implemented from :qtdoc:`QWidget`
"""
self.acqmodel.stop_listening() # close listener threads
self.saveInputs(self.inputsFilename)
# save GUI size
settings = QtCore.QSe... | python | def closeEvent(self, event):
"""Closes listening threads and saves GUI data for later use.
Re-implemented from :qtdoc:`QWidget`
"""
self.acqmodel.stop_listening() # close listener threads
self.saveInputs(self.inputsFilename)
# save GUI size
settings = QtCore.QSe... | [
"def",
"closeEvent",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"acqmodel",
".",
"stop_listening",
"(",
")",
"self",
".",
"saveInputs",
"(",
"self",
".",
"inputsFilename",
")",
"settings",
"=",
"QtCore",
".",
"QSettings",
"(",
"\"audiolab\"",
")",
... | Closes listening threads and saves GUI data for later use.
Re-implemented from :qtdoc:`QWidget` | [
"Closes",
"listening",
"threads",
"and",
"saves",
"GUI",
"data",
"for",
"later",
"use",
"."
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/controlwindow.py#L399-L415 | train |
moin18/utilspie | utilspie/asyncutils/async_utils.py | ordered_async_call | def ordered_async_call(func_list):
"""
Runs the list of function asynchronously, returns the response maintaining the order
:param func_list: Expects list of lists to be of format
[[func1, args1, kwargs1], [func2, args2, kwargs2], ...]
:return: List of output of the functions
[output1, ... | python | def ordered_async_call(func_list):
"""
Runs the list of function asynchronously, returns the response maintaining the order
:param func_list: Expects list of lists to be of format
[[func1, args1, kwargs1], [func2, args2, kwargs2], ...]
:return: List of output of the functions
[output1, ... | [
"def",
"ordered_async_call",
"(",
"func_list",
")",
":",
"def",
"worker",
"(",
"function",
",",
"f_args",
",",
"f_kwargs",
",",
"queue",
",",
"index",
")",
":",
"response",
"=",
"{",
"'index'",
":",
"index",
",",
"'data'",
":",
"None",
",",
"'error'",
... | Runs the list of function asynchronously, returns the response maintaining the order
:param func_list: Expects list of lists to be of format
[[func1, args1, kwargs1], [func2, args2, kwargs2], ...]
:return: List of output of the functions
[output1, output2, ...] | [
"Runs",
"the",
"list",
"of",
"function",
"asynchronously",
"returns",
"the",
"response",
"maintaining",
"the",
"order"
] | ea96860b93fd058019a829847258e39323fef31f | https://github.com/moin18/utilspie/blob/ea96860b93fd058019a829847258e39323fef31f/utilspie/asyncutils/async_utils.py#L4-L52 | train |
sirfoga/pyhal | hal/internet/utils.py | add_params_to_url | def add_params_to_url(url, params):
"""Adds params to url
:param url: Url
:param params: Params to add
:return: original url with new params
"""
url_parts = list(urlparse.urlparse(url)) # get url parts
query = dict(urlparse.parse_qsl(url_parts[4])) # get url query
query.update(params)... | python | def add_params_to_url(url, params):
"""Adds params to url
:param url: Url
:param params: Params to add
:return: original url with new params
"""
url_parts = list(urlparse.urlparse(url)) # get url parts
query = dict(urlparse.parse_qsl(url_parts[4])) # get url query
query.update(params)... | [
"def",
"add_params_to_url",
"(",
"url",
",",
"params",
")",
":",
"url_parts",
"=",
"list",
"(",
"urlparse",
".",
"urlparse",
"(",
"url",
")",
")",
"query",
"=",
"dict",
"(",
"urlparse",
".",
"parse_qsl",
"(",
"url_parts",
"[",
"4",
"]",
")",
")",
"qu... | Adds params to url
:param url: Url
:param params: Params to add
:return: original url with new params | [
"Adds",
"params",
"to",
"url"
] | 4394d8a1f7e45bea28a255ec390f4962ee64d33a | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/internet/utils.py#L15-L26 | train |
sirfoga/pyhal | hal/internet/utils.py | is_internet_on | def is_internet_on(host="8.8.8.8", port=53, timeout=3):
"""Checks if machine has internet connection
:param host: hostname to test
:param port: port of hostname
:param timeout: seconds before discarding connection
:return: True iff machine has internet connection
"""
socket.setdefaulttimeou... | python | def is_internet_on(host="8.8.8.8", port=53, timeout=3):
"""Checks if machine has internet connection
:param host: hostname to test
:param port: port of hostname
:param timeout: seconds before discarding connection
:return: True iff machine has internet connection
"""
socket.setdefaulttimeou... | [
"def",
"is_internet_on",
"(",
"host",
"=",
"\"8.8.8.8\"",
",",
"port",
"=",
"53",
",",
"timeout",
"=",
"3",
")",
":",
"socket",
".",
"setdefaulttimeout",
"(",
"timeout",
")",
"socket",
".",
"socket",
"(",
"socket",
".",
"AF_INET",
",",
"socket",
".",
"... | Checks if machine has internet connection
:param host: hostname to test
:param port: port of hostname
:param timeout: seconds before discarding connection
:return: True iff machine has internet connection | [
"Checks",
"if",
"machine",
"has",
"internet",
"connection"
] | 4394d8a1f7e45bea28a255ec390f4962ee64d33a | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/internet/utils.py#L30-L39 | train |
sirfoga/pyhal | hal/internet/utils.py | wait_until_internet | def wait_until_internet(time_between_attempts=3, max_attempts=10):
"""Waits until machine has internet
:param time_between_attempts: seconds between 2 consecutive attempts
:param max_attempts: max number of attempts to try
:return: True iff there is internet connection
"""
counter = 0
while... | python | def wait_until_internet(time_between_attempts=3, max_attempts=10):
"""Waits until machine has internet
:param time_between_attempts: seconds between 2 consecutive attempts
:param max_attempts: max number of attempts to try
:return: True iff there is internet connection
"""
counter = 0
while... | [
"def",
"wait_until_internet",
"(",
"time_between_attempts",
"=",
"3",
",",
"max_attempts",
"=",
"10",
")",
":",
"counter",
"=",
"0",
"while",
"not",
"is_internet_on",
"(",
")",
":",
"time",
".",
"sleep",
"(",
"time_between_attempts",
")",
"counter",
"+=",
"1... | Waits until machine has internet
:param time_between_attempts: seconds between 2 consecutive attempts
:param max_attempts: max number of attempts to try
:return: True iff there is internet connection | [
"Waits",
"until",
"machine",
"has",
"internet"
] | 4394d8a1f7e45bea28a255ec390f4962ee64d33a | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/internet/utils.py#L42-L57 | train |
hozn/keepassdb | keepassdb/util.py | transform_key | def transform_key(startkey, seed_key, seed_rand, rounds):
"""
This method creates the key to decrypt the database.
"""
masterkey = startkey
aes = AES.new(seed_key, AES.MODE_ECB)
# Encrypt the created hash <rounds> times
for _i in range(rounds):
masterkey = aes.encrypt(masterkey)
... | python | def transform_key(startkey, seed_key, seed_rand, rounds):
"""
This method creates the key to decrypt the database.
"""
masterkey = startkey
aes = AES.new(seed_key, AES.MODE_ECB)
# Encrypt the created hash <rounds> times
for _i in range(rounds):
masterkey = aes.encrypt(masterkey)
... | [
"def",
"transform_key",
"(",
"startkey",
",",
"seed_key",
",",
"seed_rand",
",",
"rounds",
")",
":",
"masterkey",
"=",
"startkey",
"aes",
"=",
"AES",
".",
"new",
"(",
"seed_key",
",",
"AES",
".",
"MODE_ECB",
")",
"for",
"_i",
"in",
"range",
"(",
"round... | This method creates the key to decrypt the database. | [
"This",
"method",
"creates",
"the",
"key",
"to",
"decrypt",
"the",
"database",
"."
] | cb24985d1ed04e7d7db99ecdddf80dd1a91ee48b | https://github.com/hozn/keepassdb/blob/cb24985d1ed04e7d7db99ecdddf80dd1a91ee48b/keepassdb/util.py#L91-L105 | train |
wylee/runcommands | runcommands/completion/__init__.py | complete | def complete(command_line,
current_token,
position,
shell: arg(choices=('bash', 'fish'))):
"""Find completions for current command.
This assumes that we'll handle all completion logic here and that
the shell's automatic file name completion is disabled.
Args:
... | python | def complete(command_line,
current_token,
position,
shell: arg(choices=('bash', 'fish'))):
"""Find completions for current command.
This assumes that we'll handle all completion logic here and that
the shell's automatic file name completion is disabled.
Args:
... | [
"def",
"complete",
"(",
"command_line",
",",
"current_token",
",",
"position",
",",
"shell",
":",
"arg",
"(",
"choices",
"=",
"(",
"'bash'",
",",
"'fish'",
")",
")",
")",
":",
"position",
"=",
"int",
"(",
"position",
")",
"tokens",
"=",
"shlex",
".",
... | Find completions for current command.
This assumes that we'll handle all completion logic here and that
the shell's automatic file name completion is disabled.
Args:
command_line: Command line
current_token: Token at cursor
position: Current cursor position
shell: Name of s... | [
"Find",
"completions",
"for",
"current",
"command",
"."
] | b1d7c262885b9ced7ab89b63562f5464ca9970fe | https://github.com/wylee/runcommands/blob/b1d7c262885b9ced7ab89b63562f5464ca9970fe/runcommands/completion/__init__.py#L13-L80 | train |
kevinconway/venvctrl | venvctrl/venv/pip.py | PipMixin.install_package | def install_package(self, name, index=None, force=False, update=False):
"""Install a given package.
Args:
name (str): The package name to install. This can be any valid
pip package specification.
index (str): The URL for a pypi index to use.
force (bo... | python | def install_package(self, name, index=None, force=False, update=False):
"""Install a given package.
Args:
name (str): The package name to install. This can be any valid
pip package specification.
index (str): The URL for a pypi index to use.
force (bo... | [
"def",
"install_package",
"(",
"self",
",",
"name",
",",
"index",
"=",
"None",
",",
"force",
"=",
"False",
",",
"update",
"=",
"False",
")",
":",
"cmd",
"=",
"'install'",
"if",
"force",
":",
"cmd",
"=",
"'{0} {1}'",
".",
"format",
"(",
"cmd",
",",
... | Install a given package.
Args:
name (str): The package name to install. This can be any valid
pip package specification.
index (str): The URL for a pypi index to use.
force (bool): For the reinstall of packages during updates.
update (bool): Updat... | [
"Install",
"a",
"given",
"package",
"."
] | 36d4e0e4d5ebced6385a6ade1198f4769ff2df41 | https://github.com/kevinconway/venvctrl/blob/36d4e0e4d5ebced6385a6ade1198f4769ff2df41/venvctrl/venv/pip.py#L27-L50 | train |
kevinconway/venvctrl | venvctrl/venv/pip.py | PipMixin.install_requirements | def install_requirements(self, path, index=None):
"""Install packages from a requirements.txt file.
Args:
path (str): The path to the requirements file.
index (str): The URL for a pypi index to use.
"""
cmd = 'install -r {0}'.format(path)
if index:
... | python | def install_requirements(self, path, index=None):
"""Install packages from a requirements.txt file.
Args:
path (str): The path to the requirements file.
index (str): The URL for a pypi index to use.
"""
cmd = 'install -r {0}'.format(path)
if index:
... | [
"def",
"install_requirements",
"(",
"self",
",",
"path",
",",
"index",
"=",
"None",
")",
":",
"cmd",
"=",
"'install -r {0}'",
".",
"format",
"(",
"path",
")",
"if",
"index",
":",
"cmd",
"=",
"'install --index-url {0} -r {1}'",
".",
"format",
"(",
"index",
... | Install packages from a requirements.txt file.
Args:
path (str): The path to the requirements file.
index (str): The URL for a pypi index to use. | [
"Install",
"packages",
"from",
"a",
"requirements",
".",
"txt",
"file",
"."
] | 36d4e0e4d5ebced6385a6ade1198f4769ff2df41 | https://github.com/kevinconway/venvctrl/blob/36d4e0e4d5ebced6385a6ade1198f4769ff2df41/venvctrl/venv/pip.py#L52-L64 | train |
sirfoga/pyhal | hal/times/dates.py | Weekday.get_next | def get_next(weekday, including_today=False):
"""Gets next day of week
:param weekday: day of week
:param including_today: If today is sunday and requesting next sunday
:return: Date of next monday, tuesday ..
"""
now = datetime.datetime.now()
if now.weekday() ==... | python | def get_next(weekday, including_today=False):
"""Gets next day of week
:param weekday: day of week
:param including_today: If today is sunday and requesting next sunday
:return: Date of next monday, tuesday ..
"""
now = datetime.datetime.now()
if now.weekday() ==... | [
"def",
"get_next",
"(",
"weekday",
",",
"including_today",
"=",
"False",
")",
":",
"now",
"=",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
"if",
"now",
".",
"weekday",
"(",
")",
"==",
"weekday",
".",
"value",
"and",
"including_today",
":",
"delt... | Gets next day of week
:param weekday: day of week
:param including_today: If today is sunday and requesting next sunday
:return: Date of next monday, tuesday .. | [
"Gets",
"next",
"day",
"of",
"week"
] | 4394d8a1f7e45bea28a255ec390f4962ee64d33a | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/times/dates.py#L21-L37 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.