repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 3
values | summary stringlengths 4 350 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
PrefPy/prefpy | prefpy/evbwie.py | EMMMixPLAggregator._MStep | def _MStep(self, l, K, x, z_h1, pi_h1, p_h1, p_h, delta_i_j_s):
"""
Description:
Internal function for computing the M-Step of the EMM algorithm,
which is itself an MM algorithm.
"""
for k in range(K):
normconst = 0
if l == 0: # only need t... | python | def _MStep(self, l, K, x, z_h1, pi_h1, p_h1, p_h, delta_i_j_s):
"""
Description:
Internal function for computing the M-Step of the EMM algorithm,
which is itself an MM algorithm.
"""
for k in range(K):
normconst = 0
if l == 0: # only need t... | [
"def",
"_MStep",
"(",
"self",
",",
"l",
",",
"K",
",",
"x",
",",
"z_h1",
",",
"pi_h1",
",",
"p_h1",
",",
"p_h",
",",
"delta_i_j_s",
")",
":",
"for",
"k",
"in",
"range",
"(",
"K",
")",
":",
"normconst",
"=",
"0",
"if",
"l",
"==",
"0",
":",
"... | Description:
Internal function for computing the M-Step of the EMM algorithm,
which is itself an MM algorithm. | [
"Description",
":",
"Internal",
"function",
"for",
"computing",
"the",
"M",
"-",
"Step",
"of",
"the",
"EMM",
"algorithm",
"which",
"is",
"itself",
"an",
"MM",
"algorithm",
"."
] | f395ba3782f05684fa5de0cece387a6da9391d02 | https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/evbwie.py#L219-L246 | train | This function computes the M - Step of the EMM algorithm. |
htm-community/menorah | menorah/riverstream.py | RiverStream.load | def load(self):
"""
Loads this stream by calling River View for data.
"""
print "Loading data for %s..." % self.getName()
self._dataHandle = self._stream.data(
since=self._since, until=self._until,
limit=self._limit, aggregate=self._aggregate
)
self._data = self._dataHandle.data... | python | def load(self):
"""
Loads this stream by calling River View for data.
"""
print "Loading data for %s..." % self.getName()
self._dataHandle = self._stream.data(
since=self._since, until=self._until,
limit=self._limit, aggregate=self._aggregate
)
self._data = self._dataHandle.data... | [
"def",
"load",
"(",
"self",
")",
":",
"print",
"\"Loading data for %s...\"",
"%",
"self",
".",
"getName",
"(",
")",
"self",
".",
"_dataHandle",
"=",
"self",
".",
"_stream",
".",
"data",
"(",
"since",
"=",
"self",
".",
"_since",
",",
"until",
"=",
"self... | Loads this stream by calling River View for data. | [
"Loads",
"this",
"stream",
"by",
"calling",
"River",
"View",
"for",
"data",
"."
] | 1991b01eda3f6361b22ed165b4a688ae3fb2deaf | https://github.com/htm-community/menorah/blob/1991b01eda3f6361b22ed165b4a688ae3fb2deaf/menorah/riverstream.py#L80-L91 | train | Loads the data from the stream by calling River View for data. |
htm-community/menorah | menorah/riverstream.py | RiverStream.next | def next(self):
"""
Returns the next data value.
:return: (float|int) the next data value
"""
out = self.peek()[self._headers.index(self._field)]
self._cursor += 1
if out is not None:
self._lastValue = out
return out | python | def next(self):
"""
Returns the next data value.
:return: (float|int) the next data value
"""
out = self.peek()[self._headers.index(self._field)]
self._cursor += 1
if out is not None:
self._lastValue = out
return out | [
"def",
"next",
"(",
"self",
")",
":",
"out",
"=",
"self",
".",
"peek",
"(",
")",
"[",
"self",
".",
"_headers",
".",
"index",
"(",
"self",
".",
"_field",
")",
"]",
"self",
".",
"_cursor",
"+=",
"1",
"if",
"out",
"is",
"not",
"None",
":",
"self",... | Returns the next data value.
:return: (float|int) the next data value | [
"Returns",
"the",
"next",
"data",
"value",
".",
":",
"return",
":",
"(",
"float|int",
")",
"the",
"next",
"data",
"value"
] | 1991b01eda3f6361b22ed165b4a688ae3fb2deaf | https://github.com/htm-community/menorah/blob/1991b01eda3f6361b22ed165b4a688ae3fb2deaf/menorah/riverstream.py#L94-L103 | train | Returns the next data value in the sequence. |
htm-community/menorah | menorah/riverstream.py | RiverStream.advance | def advance(self, myDateTime):
"""
Advances to the next value and returns an appropriate value for the given
time.
:param myDateTime: (datetime) when to fetch the value for
:return: (float|int) value for given time
"""
if self.getTime() == myDateTime:
out = self.next()
# Someti... | python | def advance(self, myDateTime):
"""
Advances to the next value and returns an appropriate value for the given
time.
:param myDateTime: (datetime) when to fetch the value for
:return: (float|int) value for given time
"""
if self.getTime() == myDateTime:
out = self.next()
# Someti... | [
"def",
"advance",
"(",
"self",
",",
"myDateTime",
")",
":",
"if",
"self",
".",
"getTime",
"(",
")",
"==",
"myDateTime",
":",
"out",
"=",
"self",
".",
"next",
"(",
")",
"# Sometimes, the stream has no value for this field and returns None, in ",
"# this case we'll us... | Advances to the next value and returns an appropriate value for the given
time.
:param myDateTime: (datetime) when to fetch the value for
:return: (float|int) value for given time | [
"Advances",
"to",
"the",
"next",
"value",
"and",
"returns",
"an",
"appropriate",
"value",
"for",
"the",
"given",
"time",
".",
":",
"param",
"myDateTime",
":",
"(",
"datetime",
")",
"when",
"to",
"fetch",
"the",
"value",
"for",
":",
"return",
":",
"(",
... | 1991b01eda3f6361b22ed165b4a688ae3fb2deaf | https://github.com/htm-community/menorah/blob/1991b01eda3f6361b22ed165b4a688ae3fb2deaf/menorah/riverstream.py#L124-L154 | train | Advance the stream to the next value and returns an appropriate value for the given time. |
htm-community/menorah | menorah/riverstream.py | RiverStream.getTime | def getTime(self):
"""
Gets the time for the next data point.
:return: (datetime)
"""
headers = self._headers
timeStringIndex = headers.index(TIMESTAMP_FIELD)
timeString = self.peek()[timeStringIndex]
return datetime.strptime(timeString, "%Y/%m/%d %H:%M:%S") | python | def getTime(self):
"""
Gets the time for the next data point.
:return: (datetime)
"""
headers = self._headers
timeStringIndex = headers.index(TIMESTAMP_FIELD)
timeString = self.peek()[timeStringIndex]
return datetime.strptime(timeString, "%Y/%m/%d %H:%M:%S") | [
"def",
"getTime",
"(",
"self",
")",
":",
"headers",
"=",
"self",
".",
"_headers",
"timeStringIndex",
"=",
"headers",
".",
"index",
"(",
"TIMESTAMP_FIELD",
")",
"timeString",
"=",
"self",
".",
"peek",
"(",
")",
"[",
"timeStringIndex",
"]",
"return",
"dateti... | Gets the time for the next data point.
:return: (datetime) | [
"Gets",
"the",
"time",
"for",
"the",
"next",
"data",
"point",
".",
":",
"return",
":",
"(",
"datetime",
")"
] | 1991b01eda3f6361b22ed165b4a688ae3fb2deaf | https://github.com/htm-community/menorah/blob/1991b01eda3f6361b22ed165b4a688ae3fb2deaf/menorah/riverstream.py#L170-L178 | train | Gets the time for the next data point. |
htm-community/menorah | menorah/riverstream.py | RiverStream.createFieldDescription | def createFieldDescription(self):
"""
Provides a field description dict for swarm description.
:return: (dict)
"""
return {
"fieldName": self.getName(),
"fieldType": self._dataType,
"minValue": self._min,
"maxValue": self._max
} | python | def createFieldDescription(self):
"""
Provides a field description dict for swarm description.
:return: (dict)
"""
return {
"fieldName": self.getName(),
"fieldType": self._dataType,
"minValue": self._min,
"maxValue": self._max
} | [
"def",
"createFieldDescription",
"(",
"self",
")",
":",
"return",
"{",
"\"fieldName\"",
":",
"self",
".",
"getName",
"(",
")",
",",
"\"fieldType\"",
":",
"self",
".",
"_dataType",
",",
"\"minValue\"",
":",
"self",
".",
"_min",
",",
"\"maxValue\"",
":",
"se... | Provides a field description dict for swarm description.
:return: (dict) | [
"Provides",
"a",
"field",
"description",
"dict",
"for",
"swarm",
"description",
".",
":",
"return",
":",
"(",
"dict",
")"
] | 1991b01eda3f6361b22ed165b4a688ae3fb2deaf | https://github.com/htm-community/menorah/blob/1991b01eda3f6361b22ed165b4a688ae3fb2deaf/menorah/riverstream.py#L181-L191 | train | Provides a field description dict for swarm description. |
lexibank/pylexibank | src/pylexibank/cldf.py | Dataset.add_lexemes | def add_lexemes(self, **kw):
"""
:return: list of dicts corresponding to newly created Lexemes
"""
lexemes = []
# Do we have morpheme segmentation on top of phonemes?
with_morphemes = '+' in self['FormTable', 'Segments'].separator
for i, form in enumerate(self.d... | python | def add_lexemes(self, **kw):
"""
:return: list of dicts corresponding to newly created Lexemes
"""
lexemes = []
# Do we have morpheme segmentation on top of phonemes?
with_morphemes = '+' in self['FormTable', 'Segments'].separator
for i, form in enumerate(self.d... | [
"def",
"add_lexemes",
"(",
"self",
",",
"*",
"*",
"kw",
")",
":",
"lexemes",
"=",
"[",
"]",
"# Do we have morpheme segmentation on top of phonemes?",
"with_morphemes",
"=",
"'+'",
"in",
"self",
"[",
"'FormTable'",
",",
"'Segments'",
"]",
".",
"separator",
"for",... | :return: list of dicts corresponding to newly created Lexemes | [
":",
"return",
":",
"list",
"of",
"dicts",
"corresponding",
"to",
"newly",
"created",
"Lexemes"
] | c28e7f122f20de1232623dd7003cb5b01535e581 | https://github.com/lexibank/pylexibank/blob/c28e7f122f20de1232623dd7003cb5b01535e581/src/pylexibank/cldf.py#L106-L147 | train | Add new Lexemes to the database. |
lexibank/pylexibank | src/pylexibank/cldf.py | Dataset.add_languages | def add_languages(self, id_factory=lambda d: d['ID']):
"""
Add languages as specified in a dataset's etc/languages.csv
:param id_factory: A callable taking a dict describing a language as argument and returning\
a value to be used as ID for the language.
:return: The set of lang... | python | def add_languages(self, id_factory=lambda d: d['ID']):
"""
Add languages as specified in a dataset's etc/languages.csv
:param id_factory: A callable taking a dict describing a language as argument and returning\
a value to be used as ID for the language.
:return: The set of lang... | [
"def",
"add_languages",
"(",
"self",
",",
"id_factory",
"=",
"lambda",
"d",
":",
"d",
"[",
"'ID'",
"]",
")",
":",
"ids",
"=",
"set",
"(",
")",
"for",
"kw",
"in",
"self",
".",
"dataset",
".",
"languages",
":",
"if",
"(",
"not",
"kw",
".",
"get",
... | Add languages as specified in a dataset's etc/languages.csv
:param id_factory: A callable taking a dict describing a language as argument and returning\
a value to be used as ID for the language.
:return: The set of language IDs which have been added. | [
"Add",
"languages",
"as",
"specified",
"in",
"a",
"dataset",
"s",
"etc",
"/",
"languages",
".",
"csv"
] | c28e7f122f20de1232623dd7003cb5b01535e581 | https://github.com/lexibank/pylexibank/blob/c28e7f122f20de1232623dd7003cb5b01535e581/src/pylexibank/cldf.py#L176-L191 | train | Add languages as specified in a dataset s etc / languages. csv file. |
lexibank/pylexibank | src/pylexibank/cldf.py | Dataset.add_concepts | def add_concepts(self, id_factory=lambda d: d.number):
"""
Add concepts as specified in a dataset's associated Concepticon concept list or in
etc/concepts.csv
:param id_factory: A callable taking a pyconcepticon.api.Concept object as argument and \
returning a value to be used a... | python | def add_concepts(self, id_factory=lambda d: d.number):
"""
Add concepts as specified in a dataset's associated Concepticon concept list or in
etc/concepts.csv
:param id_factory: A callable taking a pyconcepticon.api.Concept object as argument and \
returning a value to be used a... | [
"def",
"add_concepts",
"(",
"self",
",",
"id_factory",
"=",
"lambda",
"d",
":",
"d",
".",
"number",
")",
":",
"ids",
",",
"concepts",
"=",
"set",
"(",
")",
",",
"[",
"]",
"if",
"self",
".",
"dataset",
".",
"conceptlist",
":",
"concepts",
"=",
"self... | Add concepts as specified in a dataset's associated Concepticon concept list or in
etc/concepts.csv
:param id_factory: A callable taking a pyconcepticon.api.Concept object as argument and \
returning a value to be used as ID for the concept.
:return: The set of concept IDs which have be... | [
"Add",
"concepts",
"as",
"specified",
"in",
"a",
"dataset",
"s",
"associated",
"Concepticon",
"concept",
"list",
"or",
"in",
"etc",
"/",
"concepts",
".",
"csv"
] | c28e7f122f20de1232623dd7003cb5b01535e581 | https://github.com/lexibank/pylexibank/blob/c28e7f122f20de1232623dd7003cb5b01535e581/src/pylexibank/cldf.py#L200-L240 | train | Adds concepts as specified in a dataset s associated Concepticon concept list or infrastructure. csv file. |
tamasgal/km3pipe | km3pipe/plot.py | hexbin | def hexbin(x, y, color="purple", **kwargs):
"""Seaborn-compatible hexbin plot.
See also: http://seaborn.pydata.org/tutorial/axis_grids.html#mapping-custom-functions-onto-the-grid
"""
if HAS_SEABORN:
cmap = sns.light_palette(color, as_cmap=True)
else:
cmap = "Purples"
plt.hexbin(... | python | def hexbin(x, y, color="purple", **kwargs):
"""Seaborn-compatible hexbin plot.
See also: http://seaborn.pydata.org/tutorial/axis_grids.html#mapping-custom-functions-onto-the-grid
"""
if HAS_SEABORN:
cmap = sns.light_palette(color, as_cmap=True)
else:
cmap = "Purples"
plt.hexbin(... | [
"def",
"hexbin",
"(",
"x",
",",
"y",
",",
"color",
"=",
"\"purple\"",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"HAS_SEABORN",
":",
"cmap",
"=",
"sns",
".",
"light_palette",
"(",
"color",
",",
"as_cmap",
"=",
"True",
")",
"else",
":",
"cmap",
"=",
... | Seaborn-compatible hexbin plot.
See also: http://seaborn.pydata.org/tutorial/axis_grids.html#mapping-custom-functions-onto-the-grid | [
"Seaborn",
"-",
"compatible",
"hexbin",
"plot",
"."
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/plot.py#L33-L42 | train | Seaborn - compatible hexbin plot. |
tamasgal/km3pipe | km3pipe/plot.py | diag | def diag(ax=None, linecolor='0.0', linestyle='--', **kwargs):
"""Plot the diagonal."""
ax = get_ax(ax)
xy_min = np.min((ax.get_xlim(), ax.get_ylim()))
xy_max = np.max((ax.get_ylim(), ax.get_xlim()))
return ax.plot([xy_min, xy_max], [xy_min, xy_max],
ls=linestyle,
... | python | def diag(ax=None, linecolor='0.0', linestyle='--', **kwargs):
"""Plot the diagonal."""
ax = get_ax(ax)
xy_min = np.min((ax.get_xlim(), ax.get_ylim()))
xy_max = np.max((ax.get_ylim(), ax.get_xlim()))
return ax.plot([xy_min, xy_max], [xy_min, xy_max],
ls=linestyle,
... | [
"def",
"diag",
"(",
"ax",
"=",
"None",
",",
"linecolor",
"=",
"'0.0'",
",",
"linestyle",
"=",
"'--'",
",",
"*",
"*",
"kwargs",
")",
":",
"ax",
"=",
"get_ax",
"(",
"ax",
")",
"xy_min",
"=",
"np",
".",
"min",
"(",
"(",
"ax",
".",
"get_xlim",
"(",... | Plot the diagonal. | [
"Plot",
"the",
"diagonal",
"."
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/plot.py#L52-L60 | train | Plot the diagonal of the sequence. |
tamasgal/km3pipe | km3pipe/plot.py | automeshgrid | def automeshgrid(
x, y, step=0.02, xstep=None, ystep=None, pad=0.5, xpad=None, ypad=None
):
"""Make a meshgrid, inferred from data."""
if xpad is None:
xpad = pad
if xstep is None:
xstep = step
if ypad is None:
ypad = pad
if ystep is None:
ystep = step
xmi... | python | def automeshgrid(
x, y, step=0.02, xstep=None, ystep=None, pad=0.5, xpad=None, ypad=None
):
"""Make a meshgrid, inferred from data."""
if xpad is None:
xpad = pad
if xstep is None:
xstep = step
if ypad is None:
ypad = pad
if ystep is None:
ystep = step
xmi... | [
"def",
"automeshgrid",
"(",
"x",
",",
"y",
",",
"step",
"=",
"0.02",
",",
"xstep",
"=",
"None",
",",
"ystep",
"=",
"None",
",",
"pad",
"=",
"0.5",
",",
"xpad",
"=",
"None",
",",
"ypad",
"=",
"None",
")",
":",
"if",
"xpad",
"is",
"None",
":",
... | Make a meshgrid, inferred from data. | [
"Make",
"a",
"meshgrid",
"inferred",
"from",
"data",
"."
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/plot.py#L63-L79 | train | Make a meshgrid inferred from data. |
tamasgal/km3pipe | km3pipe/plot.py | meshgrid | def meshgrid(x_min, x_max, x_step, y_min=None, y_max=None, y_step=None):
"""Make a meshgrid, e.g. when plotting decision surfaces."""
if y_min is None:
y_min = x_min
if y_max is None:
y_max = x_max
if y_step is None:
y_step = x_step
xx, yy = np.meshgrid(
np.arange(x_m... | python | def meshgrid(x_min, x_max, x_step, y_min=None, y_max=None, y_step=None):
"""Make a meshgrid, e.g. when plotting decision surfaces."""
if y_min is None:
y_min = x_min
if y_max is None:
y_max = x_max
if y_step is None:
y_step = x_step
xx, yy = np.meshgrid(
np.arange(x_m... | [
"def",
"meshgrid",
"(",
"x_min",
",",
"x_max",
",",
"x_step",
",",
"y_min",
"=",
"None",
",",
"y_max",
"=",
"None",
",",
"y_step",
"=",
"None",
")",
":",
"if",
"y_min",
"is",
"None",
":",
"y_min",
"=",
"x_min",
"if",
"y_max",
"is",
"None",
":",
"... | Make a meshgrid, e.g. when plotting decision surfaces. | [
"Make",
"a",
"meshgrid",
"e",
".",
"g",
".",
"when",
"plotting",
"decision",
"surfaces",
"."
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/plot.py#L82-L93 | train | Make a meshgrid e. g. when plotting decision surfaces. |
tamasgal/km3pipe | km3pipe/plot.py | prebinned_hist | def prebinned_hist(counts, binlims, ax=None, *args, **kwargs):
"""Plot a histogram with counts, binlims already given.
Example
=======
>>> gaus = np.random.normal(size=100)
>>> counts, binlims = np.histogram(gaus, bins='auto')
>>> prebinned_hist(countsl binlims)
"""
ax = get_ax(ax)
... | python | def prebinned_hist(counts, binlims, ax=None, *args, **kwargs):
"""Plot a histogram with counts, binlims already given.
Example
=======
>>> gaus = np.random.normal(size=100)
>>> counts, binlims = np.histogram(gaus, bins='auto')
>>> prebinned_hist(countsl binlims)
"""
ax = get_ax(ax)
... | [
"def",
"prebinned_hist",
"(",
"counts",
",",
"binlims",
",",
"ax",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"ax",
"=",
"get_ax",
"(",
"ax",
")",
"x",
"=",
"bincenters",
"(",
"binlims",
")",
"weights",
"=",
"counts",
"return... | Plot a histogram with counts, binlims already given.
Example
=======
>>> gaus = np.random.normal(size=100)
>>> counts, binlims = np.histogram(gaus, bins='auto')
>>> prebinned_hist(countsl binlims) | [
"Plot",
"a",
"histogram",
"with",
"counts",
"binlims",
"already",
"given",
"."
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/plot.py#L96-L108 | train | Plot a histogram with counts and binlims already given. |
tamasgal/km3pipe | km3pipe/plot.py | joint_hex | def joint_hex(x, y, **kwargs):
"""Seaborn Joint Hexplot with marginal KDE + hists."""
return sns.jointplot(
x, y, kind='hex', stat_func=None, marginal_kws={'kde': True}, **kwargs
) | python | def joint_hex(x, y, **kwargs):
"""Seaborn Joint Hexplot with marginal KDE + hists."""
return sns.jointplot(
x, y, kind='hex', stat_func=None, marginal_kws={'kde': True}, **kwargs
) | [
"def",
"joint_hex",
"(",
"x",
",",
"y",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"sns",
".",
"jointplot",
"(",
"x",
",",
"y",
",",
"kind",
"=",
"'hex'",
",",
"stat_func",
"=",
"None",
",",
"marginal_kws",
"=",
"{",
"'kde'",
":",
"True",
"}",
... | Seaborn Joint Hexplot with marginal KDE + hists. | [
"Seaborn",
"Joint",
"Hexplot",
"with",
"marginal",
"KDE",
"+",
"hists",
"."
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/plot.py#L111-L115 | train | Seaborn Joint Hexplot with marginal KDE + hists. |
IRC-SPHERE/HyperStream | hyperstream/workflow/workflow.py | Workflow.execute | def execute(self, time_interval):
"""
Here we execute the factors over the streams in the workflow
Execute the factors in reverse order. We can't just execute the last factor because there may be multiple
"leaf" factors that aren't triggered by upstream computations.
:param time... | python | def execute(self, time_interval):
"""
Here we execute the factors over the streams in the workflow
Execute the factors in reverse order. We can't just execute the last factor because there may be multiple
"leaf" factors that aren't triggered by upstream computations.
:param time... | [
"def",
"execute",
"(",
"self",
",",
"time_interval",
")",
":",
"# TODO: What if the leaf nodes have different time intervals?",
"# if not self._hyperstream:",
"# raise ValueError(\"\")",
"with",
"WorkflowMonitor",
"(",
"self",
")",
":",
"# First look for asset writers",
"for"... | Here we execute the factors over the streams in the workflow
Execute the factors in reverse order. We can't just execute the last factor because there may be multiple
"leaf" factors that aren't triggered by upstream computations.
:param time_interval: The time interval to execute this workflow ... | [
"Here",
"we",
"execute",
"the",
"factors",
"over",
"the",
"streams",
"in",
"the",
"workflow",
"Execute",
"the",
"factors",
"in",
"reverse",
"order",
".",
"We",
"can",
"t",
"just",
"execute",
"the",
"last",
"factor",
"because",
"there",
"may",
"be",
"multip... | 98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780 | https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/workflow/workflow.py#L87-L107 | train | Execute the factors over the streams in the workflow. |
IRC-SPHERE/HyperStream | hyperstream/workflow/workflow.py | Workflow._add_node | def _add_node(self, node):
"""
Add a node to the workflow
:param node: The node object
:type node: Node
:return: None
"""
self.nodes[node.node_id] = node
logging.info("Added node with id {} containing {} streams".format(node.node_id, len(node.streams))) | python | def _add_node(self, node):
"""
Add a node to the workflow
:param node: The node object
:type node: Node
:return: None
"""
self.nodes[node.node_id] = node
logging.info("Added node with id {} containing {} streams".format(node.node_id, len(node.streams))) | [
"def",
"_add_node",
"(",
"self",
",",
"node",
")",
":",
"self",
".",
"nodes",
"[",
"node",
".",
"node_id",
"]",
"=",
"node",
"logging",
".",
"info",
"(",
"\"Added node with id {} containing {} streams\"",
".",
"format",
"(",
"node",
".",
"node_id",
",",
"l... | Add a node to the workflow
:param node: The node object
:type node: Node
:return: None | [
"Add",
"a",
"node",
"to",
"the",
"workflow"
] | 98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780 | https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/workflow/workflow.py#L109-L118 | train | Adds a node to the workflow
|
IRC-SPHERE/HyperStream | hyperstream/workflow/workflow.py | Workflow._add_factor | def _add_factor(self, factor):
"""
Add a factor to the workflow
:param factor: The factor object
:type factor: Factor | MultiOutputFactor | NodeCreationFactor
:return: None
"""
self.factors.append(factor)
logging.info("Added factor with tool {} ".format(f... | python | def _add_factor(self, factor):
"""
Add a factor to the workflow
:param factor: The factor object
:type factor: Factor | MultiOutputFactor | NodeCreationFactor
:return: None
"""
self.factors.append(factor)
logging.info("Added factor with tool {} ".format(f... | [
"def",
"_add_factor",
"(",
"self",
",",
"factor",
")",
":",
"self",
".",
"factors",
".",
"append",
"(",
"factor",
")",
"logging",
".",
"info",
"(",
"\"Added factor with tool {} \"",
".",
"format",
"(",
"factor",
".",
"tool",
")",
")"
] | Add a factor to the workflow
:param factor: The factor object
:type factor: Factor | MultiOutputFactor | NodeCreationFactor
:return: None | [
"Add",
"a",
"factor",
"to",
"the",
"workflow"
] | 98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780 | https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/workflow/workflow.py#L120-L129 | train | Adds a factor to the workflow
|
IRC-SPHERE/HyperStream | hyperstream/workflow/workflow.py | Workflow.create_node | def create_node(self, stream_name, channel, plates):
"""
Create a node in the graph. Note: assumes that the streams already exist
:param stream_name: The name of the stream
:param channel: The channel where this stream lives
:param plates: The plates. The stream meta-data will b... | python | def create_node(self, stream_name, channel, plates):
"""
Create a node in the graph. Note: assumes that the streams already exist
:param stream_name: The name of the stream
:param channel: The channel where this stream lives
:param plates: The plates. The stream meta-data will b... | [
"def",
"create_node",
"(",
"self",
",",
"stream_name",
",",
"channel",
",",
"plates",
")",
":",
"streams",
"=",
"{",
"}",
"plate_values",
"=",
"Plate",
".",
"get_overlapping_values",
"(",
"plates",
")",
"if",
"plates",
":",
"if",
"not",
"plate_values",
":"... | Create a node in the graph. Note: assumes that the streams already exist
:param stream_name: The name of the stream
:param channel: The channel where this stream lives
:param plates: The plates. The stream meta-data will be auto-generated from these
:return: The streams associated with ... | [
"Create",
"a",
"node",
"in",
"the",
"graph",
".",
"Note",
":",
"assumes",
"that",
"the",
"streams",
"already",
"exist"
] | 98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780 | https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/workflow/workflow.py#L131-L162 | train | Create a node in the graph. |
IRC-SPHERE/HyperStream | hyperstream/workflow/workflow.py | Workflow.create_factor_general | def create_factor_general(self, *args, **kwargs):
"""
General signature for factor creation that tries each of the factor creation types using duck typing
:param args: The positional arguments
:param kwargs: The named arguments
:return: The created factor
"""
try... | python | def create_factor_general(self, *args, **kwargs):
"""
General signature for factor creation that tries each of the factor creation types using duck typing
:param args: The positional arguments
:param kwargs: The named arguments
:return: The created factor
"""
try... | [
"def",
"create_factor_general",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"return",
"self",
".",
"create_factor",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"except",
"TypeError",
":",
"pass",
"try",
":",
"ret... | General signature for factor creation that tries each of the factor creation types using duck typing
:param args: The positional arguments
:param kwargs: The named arguments
:return: The created factor | [
"General",
"signature",
"for",
"factor",
"creation",
"that",
"tries",
"each",
"of",
"the",
"factor",
"creation",
"types",
"using",
"duck",
"typing"
] | 98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780 | https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/workflow/workflow.py#L164-L184 | train | This method is used to create a factor in a general signature for factor creation that tries each of the factor creation types using duck typing. |
IRC-SPHERE/HyperStream | hyperstream/workflow/workflow.py | Workflow.create_factor | def create_factor(self, tool, sources, sink, alignment_node=None):
"""
Creates a factor. Instantiates a single tool for all of the plates, and connects the source and sink nodes with
that tool.
Note that the tool parameters these are currently fixed over a plate. For parameters that var... | python | def create_factor(self, tool, sources, sink, alignment_node=None):
"""
Creates a factor. Instantiates a single tool for all of the plates, and connects the source and sink nodes with
that tool.
Note that the tool parameters these are currently fixed over a plate. For parameters that var... | [
"def",
"create_factor",
"(",
"self",
",",
"tool",
",",
"sources",
",",
"sink",
",",
"alignment_node",
"=",
"None",
")",
":",
"# if isinstance(tool, dict):",
"# tool = self.channels.get_tool(**tool)",
"if",
"not",
"isinstance",
"(",
"tool",
",",
"BaseTool",
")",
... | Creates a factor. Instantiates a single tool for all of the plates, and connects the source and sink nodes with
that tool.
Note that the tool parameters these are currently fixed over a plate. For parameters that vary over a plate,
an extra input stream should be used
:param alignment_... | [
"Creates",
"a",
"factor",
".",
"Instantiates",
"a",
"single",
"tool",
"for",
"all",
"of",
"the",
"plates",
"and",
"connects",
"the",
"source",
"and",
"sink",
"nodes",
"with",
"that",
"tool",
"."
] | 98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780 | https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/workflow/workflow.py#L186-L285 | train | Creates a factor for the given tool and source and sink nodes. |
IRC-SPHERE/HyperStream | hyperstream/workflow/workflow.py | Workflow.create_multi_output_factor | def create_multi_output_factor(self, tool, source, splitting_node, sink):
"""
Creates a multi-output factor.
This takes a single node, applies a MultiOutputTool to create multiple nodes on a new plate
Instantiates a single tool for all of the input plate values,
and connects the ... | python | def create_multi_output_factor(self, tool, source, splitting_node, sink):
"""
Creates a multi-output factor.
This takes a single node, applies a MultiOutputTool to create multiple nodes on a new plate
Instantiates a single tool for all of the input plate values,
and connects the ... | [
"def",
"create_multi_output_factor",
"(",
"self",
",",
"tool",
",",
"source",
",",
"splitting_node",
",",
"sink",
")",
":",
"if",
"source",
"and",
"not",
"isinstance",
"(",
"source",
",",
"Node",
")",
":",
"raise",
"ValueError",
"(",
"\"Expected Node, got {}\"... | Creates a multi-output factor.
This takes a single node, applies a MultiOutputTool to create multiple nodes on a new plate
Instantiates a single tool for all of the input plate values,
and connects the source and sink nodes with that tool.
Note that the tool parameters these are current... | [
"Creates",
"a",
"multi",
"-",
"output",
"factor",
".",
"This",
"takes",
"a",
"single",
"node",
"applies",
"a",
"MultiOutputTool",
"to",
"create",
"multiple",
"nodes",
"on",
"a",
"new",
"plate",
"Instantiates",
"a",
"single",
"tool",
"for",
"all",
"of",
"th... | 98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780 | https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/workflow/workflow.py#L287-L374 | train | Creates a multi - output factor for all of the input plate values and connects the source and sink nodes with that tool. |
IRC-SPHERE/HyperStream | hyperstream/workflow/workflow.py | Workflow.create_node_creation_factor | def create_node_creation_factor(self, tool, source, output_plate, plate_manager):
"""
Creates a factor that itself creates an output node, and ensures that the plate for the output node exists
along with all relevant meta-data
:param tool: The tool
:param source: The source node... | python | def create_node_creation_factor(self, tool, source, output_plate, plate_manager):
"""
Creates a factor that itself creates an output node, and ensures that the plate for the output node exists
along with all relevant meta-data
:param tool: The tool
:param source: The source node... | [
"def",
"create_node_creation_factor",
"(",
"self",
",",
"tool",
",",
"source",
",",
"output_plate",
",",
"plate_manager",
")",
":",
"# if isinstance(tool, dict):",
"# tool = self.channels.get_tool(**tool)",
"if",
"not",
"isinstance",
"(",
"tool",
",",
"PlateCreationTo... | Creates a factor that itself creates an output node, and ensures that the plate for the output node exists
along with all relevant meta-data
:param tool: The tool
:param source: The source node
:param output_plate: The details of the plate that will be created (dict)
:param plat... | [
"Creates",
"a",
"factor",
"that",
"itself",
"creates",
"an",
"output",
"node",
"and",
"ensures",
"that",
"the",
"plate",
"for",
"the",
"output",
"node",
"exists",
"along",
"with",
"all",
"relevant",
"meta",
"-",
"data"
] | 98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780 | https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/workflow/workflow.py#L376-L409 | train | Creates a factor that creates an output node and ensures that the plate for the output node exists along with all relevant meta - data. |
IRC-SPHERE/HyperStream | hyperstream/workflow/workflow.py | Workflow.check_plate_compatibility | def check_plate_compatibility(tool, source_plate, sink_plate):
"""
Checks whether the source and sink plate are compatible given the tool
:param tool: The tool
:param source_plate: The source plate
:param sink_plate: The sink plate
:return: Either an error, or None
... | python | def check_plate_compatibility(tool, source_plate, sink_plate):
"""
Checks whether the source and sink plate are compatible given the tool
:param tool: The tool
:param source_plate: The source plate
:param sink_plate: The sink plate
:return: Either an error, or None
... | [
"def",
"check_plate_compatibility",
"(",
"tool",
",",
"source_plate",
",",
"sink_plate",
")",
":",
"if",
"sink_plate",
"==",
"source_plate",
".",
"parent",
":",
"return",
"None",
"# could be that they have the same meta data, but the sink plate is a simplification of the source... | Checks whether the source and sink plate are compatible given the tool
:param tool: The tool
:param source_plate: The source plate
:param sink_plate: The sink plate
:return: Either an error, or None
:type tool: Tool
:type source_plate: Plate
:type sink_plate: Pla... | [
"Checks",
"whether",
"the",
"source",
"and",
"sink",
"plate",
"are",
"compatible",
"given",
"the",
"tool"
] | 98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780 | https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/workflow/workflow.py#L412-L445 | train | Checks whether the source and sink plates are compatible with the tool. |
IRC-SPHERE/HyperStream | hyperstream/workflow/workflow.py | Workflow.check_multi_output_plate_compatibility | def check_multi_output_plate_compatibility(source_plates, sink_plate):
"""
Check multi-output plate compatibility. This ensures that the source plates and sink plates match for a multi-
output plate
:param source_plates: The source plates
:param sink_plate: The sink plate
... | python | def check_multi_output_plate_compatibility(source_plates, sink_plate):
"""
Check multi-output plate compatibility. This ensures that the source plates and sink plates match for a multi-
output plate
:param source_plates: The source plates
:param sink_plate: The sink plate
... | [
"def",
"check_multi_output_plate_compatibility",
"(",
"source_plates",
",",
"sink_plate",
")",
":",
"if",
"len",
"(",
"source_plates",
")",
"==",
"0",
":",
"if",
"sink_plate",
".",
"parent",
"is",
"not",
"None",
":",
"return",
"False",
"else",
":",
"if",
"si... | Check multi-output plate compatibility. This ensures that the source plates and sink plates match for a multi-
output plate
:param source_plates: The source plates
:param sink_plate: The sink plate
:return: True if the plates are compatible | [
"Check",
"multi",
"-",
"output",
"plate",
"compatibility",
".",
"This",
"ensures",
"that",
"the",
"source",
"plates",
"and",
"sink",
"plates",
"match",
"for",
"a",
"multi",
"-",
"output",
"plate"
] | 98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780 | https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/workflow/workflow.py#L448-L466 | train | Checks if the source and sink plates are compatible with a multi - output plate. |
IRC-SPHERE/HyperStream | hyperstream/workflow/workflow.py | Workflow.requested_intervals | def requested_intervals(self):
"""
Get the requested intervals (from the database)
:return: The requested intervals
"""
with switch_db(WorkflowStatusModel, db_alias='hyperstream'):
workflow_statuses = WorkflowStatusModel.objects(workflow_id=self.workflow_id)
... | python | def requested_intervals(self):
"""
Get the requested intervals (from the database)
:return: The requested intervals
"""
with switch_db(WorkflowStatusModel, db_alias='hyperstream'):
workflow_statuses = WorkflowStatusModel.objects(workflow_id=self.workflow_id)
... | [
"def",
"requested_intervals",
"(",
"self",
")",
":",
"with",
"switch_db",
"(",
"WorkflowStatusModel",
",",
"db_alias",
"=",
"'hyperstream'",
")",
":",
"workflow_statuses",
"=",
"WorkflowStatusModel",
".",
"objects",
"(",
"workflow_id",
"=",
"self",
".",
"workflow_... | Get the requested intervals (from the database)
:return: The requested intervals | [
"Get",
"the",
"requested",
"intervals",
"(",
"from",
"the",
"database",
")"
] | 98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780 | https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/workflow/workflow.py#L469-L481 | train | Get the requested intervals from the database |
IRC-SPHERE/HyperStream | hyperstream/workflow/workflow.py | Workflow.requested_intervals | def requested_intervals(self, intervals):
"""
Set the requested intervals (to the database)
:param intervals: The intervals
:type intervals: TimeIntervals
:return: None
"""
with switch_db(WorkflowStatusModel, db_alias='hyperstream'):
workflow_statuses... | python | def requested_intervals(self, intervals):
"""
Set the requested intervals (to the database)
:param intervals: The intervals
:type intervals: TimeIntervals
:return: None
"""
with switch_db(WorkflowStatusModel, db_alias='hyperstream'):
workflow_statuses... | [
"def",
"requested_intervals",
"(",
"self",
",",
"intervals",
")",
":",
"with",
"switch_db",
"(",
"WorkflowStatusModel",
",",
"db_alias",
"=",
"'hyperstream'",
")",
":",
"workflow_statuses",
"=",
"WorkflowStatusModel",
".",
"objects",
"(",
"workflow_id",
"=",
"self... | Set the requested intervals (to the database)
:param intervals: The intervals
:type intervals: TimeIntervals
:return: None | [
"Set",
"the",
"requested",
"intervals",
"(",
"to",
"the",
"database",
")"
] | 98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780 | https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/workflow/workflow.py#L484-L508 | train | Set the requested intervals to the database. |
IRC-SPHERE/HyperStream | hyperstream/workflow/workflow.py | Workflow.to_dict | def to_dict(self, tool_long_names=True):
"""
Get a representation of the workflow as a dictionary for display purposes
:param tool_long_names: Indicates whether to use long names, such as
SplitterFromStream(element=None, use_mapping_keys_only=True)
... | python | def to_dict(self, tool_long_names=True):
"""
Get a representation of the workflow as a dictionary for display purposes
:param tool_long_names: Indicates whether to use long names, such as
SplitterFromStream(element=None, use_mapping_keys_only=True)
... | [
"def",
"to_dict",
"(",
"self",
",",
"tool_long_names",
"=",
"True",
")",
":",
"d",
"=",
"dict",
"(",
"nodes",
"=",
"[",
"]",
",",
"factors",
"=",
"[",
"]",
",",
"plates",
"=",
"defaultdict",
"(",
"list",
")",
")",
"for",
"node",
"in",
"self",
"."... | Get a representation of the workflow as a dictionary for display purposes
:param tool_long_names: Indicates whether to use long names, such as
SplitterFromStream(element=None, use_mapping_keys_only=True)
or short names, such as
... | [
"Get",
"a",
"representation",
"of",
"the",
"workflow",
"as",
"a",
"dictionary",
"for",
"display",
"purposes"
] | 98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780 | https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/workflow/workflow.py#L510-L553 | train | Returns a dictionary representation of the workflow as a dictionary for display purposes. |
IRC-SPHERE/HyperStream | hyperstream/workflow/workflow.py | Workflow.to_json | def to_json(self, formatter=None, tool_long_names=True, **kwargs):
"""
Get a JSON representation of the workflow
:param tool_long_names: Indicates whether to use long names, such as
SplitterFromStream(element=None, use_mapping_keys_only=True)
... | python | def to_json(self, formatter=None, tool_long_names=True, **kwargs):
"""
Get a JSON representation of the workflow
:param tool_long_names: Indicates whether to use long names, such as
SplitterFromStream(element=None, use_mapping_keys_only=True)
... | [
"def",
"to_json",
"(",
"self",
",",
"formatter",
"=",
"None",
",",
"tool_long_names",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"d",
"=",
"self",
".",
"to_dict",
"(",
"tool_long_names",
"=",
"tool_long_names",
")",
"if",
"formatter",
":",
"d",
"=... | Get a JSON representation of the workflow
:param tool_long_names: Indicates whether to use long names, such as
SplitterFromStream(element=None, use_mapping_keys_only=True)
or short names, such as
splitter_from_strea... | [
"Get",
"a",
"JSON",
"representation",
"of",
"the",
"workflow"
] | 98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780 | https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/workflow/workflow.py#L555-L570 | train | Returns a JSON representation of the workflow s entry set in the format that is suitable for JSON serialization. |
IRC-SPHERE/HyperStream | hyperstream/workflow/workflow.py | Workflow.factorgraph_viz | def factorgraph_viz(d):
"""
Map the dictionary into factorgraph-viz format. See https://github.com/mbforbes/factorgraph-viz
:param d: The dictionary
:return: The formatted dictionary
"""
m = defaultdict(list)
for node in d['nodes']:
m['nodes'].append... | python | def factorgraph_viz(d):
"""
Map the dictionary into factorgraph-viz format. See https://github.com/mbforbes/factorgraph-viz
:param d: The dictionary
:return: The formatted dictionary
"""
m = defaultdict(list)
for node in d['nodes']:
m['nodes'].append... | [
"def",
"factorgraph_viz",
"(",
"d",
")",
":",
"m",
"=",
"defaultdict",
"(",
"list",
")",
"for",
"node",
"in",
"d",
"[",
"'nodes'",
"]",
":",
"m",
"[",
"'nodes'",
"]",
".",
"append",
"(",
"dict",
"(",
"id",
"=",
"node",
"[",
"'id'",
"]",
",",
"t... | Map the dictionary into factorgraph-viz format. See https://github.com/mbforbes/factorgraph-viz
:param d: The dictionary
:return: The formatted dictionary | [
"Map",
"the",
"dictionary",
"into",
"factorgraph",
"-",
"viz",
"format",
".",
"See",
"https",
":",
"//",
"github",
".",
"com",
"/",
"mbforbes",
"/",
"factorgraph",
"-",
"viz"
] | 98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780 | https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/workflow/workflow.py#L573-L605 | train | Map the dictionary into factorgraph -viz format. See https://github. com / mbforbes / factorgraph -viz format. |
PrefPy/prefpy | prefpy/mov.py | MoVScoring | def MoVScoring(profile, scoringVector):
"""
Returns an integer that represents the winning candidate given an election profile.
The winner has the largest score.
Tie-breaking rule: numerically increasing order
:ivar Profile profile: A Profile object that represents an election profile.
:ivar li... | python | def MoVScoring(profile, scoringVector):
"""
Returns an integer that represents the winning candidate given an election profile.
The winner has the largest score.
Tie-breaking rule: numerically increasing order
:ivar Profile profile: A Profile object that represents an election profile.
:ivar li... | [
"def",
"MoVScoring",
"(",
"profile",
",",
"scoringVector",
")",
":",
"# Currently, we expect the profile to contain complete ordering over candidates.",
"elecType",
"=",
"profile",
".",
"getElecType",
"(",
")",
"if",
"elecType",
"!=",
"\"soc\"",
"and",
"elecType",
"!=",
... | Returns an integer that represents the winning candidate given an election profile.
The winner has the largest score.
Tie-breaking rule: numerically increasing order
:ivar Profile profile: A Profile object that represents an election profile.
:ivar list<int> scoringVector: A list of integers (or floats... | [
"Returns",
"an",
"integer",
"that",
"represents",
"the",
"winning",
"candidate",
"given",
"an",
"election",
"profile",
".",
"The",
"winner",
"has",
"the",
"largest",
"score",
".",
"Tie",
"-",
"breaking",
"rule",
":",
"numerically",
"increasing",
"order"
] | f395ba3782f05684fa5de0cece387a6da9391d02 | https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mov.py#L15-L98 | train | Returns an integer that represents the winning candidate given an election profile and a scoring vector. |
PrefPy/prefpy | prefpy/mov.py | MoVSimplifiedBucklin | def MoVSimplifiedBucklin(profile):
"""
Returns an integer that is equal to the margin of victory of the election profile, that is,
the smallest number k such that changing k votes can change the winners.
:ivar Profile profile: A Profile object that represents an election profile.
"""
# Current... | python | def MoVSimplifiedBucklin(profile):
"""
Returns an integer that is equal to the margin of victory of the election profile, that is,
the smallest number k such that changing k votes can change the winners.
:ivar Profile profile: A Profile object that represents an election profile.
"""
# Current... | [
"def",
"MoVSimplifiedBucklin",
"(",
"profile",
")",
":",
"# Currently, we expect the profile to contain complete ordering over candidates.",
"elecType",
"=",
"profile",
".",
"getElecType",
"(",
")",
"if",
"elecType",
"!=",
"\"soc\"",
"and",
"elecType",
"!=",
"\"csv\"",
"a... | Returns an integer that is equal to the margin of victory of the election profile, that is,
the smallest number k such that changing k votes can change the winners.
:ivar Profile profile: A Profile object that represents an election profile. | [
"Returns",
"an",
"integer",
"that",
"is",
"equal",
"to",
"the",
"margin",
"of",
"victory",
"of",
"the",
"election",
"profile",
"that",
"is",
"the",
"smallest",
"number",
"k",
"such",
"that",
"changing",
"k",
"votes",
"can",
"change",
"the",
"winners",
"."
... | f395ba3782f05684fa5de0cece387a6da9391d02 | https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mov.py#L101-L164 | train | Returns the MoV of the given profile. |
PrefPy/prefpy | prefpy/mov.py | MoVPluRunOff | def MoVPluRunOff(profile):
"""
Returns an integer that is equal to the margin of victory of the election profile, that is,
the smallest number k such that changing k votes can change the winners.
:ivar Profile profile: A Profile object that represents an election profile.
"""
# Currently, we e... | python | def MoVPluRunOff(profile):
"""
Returns an integer that is equal to the margin of victory of the election profile, that is,
the smallest number k such that changing k votes can change the winners.
:ivar Profile profile: A Profile object that represents an election profile.
"""
# Currently, we e... | [
"def",
"MoVPluRunOff",
"(",
"profile",
")",
":",
"# Currently, we expect the profile to contain complete ordering over candidates.",
"elecType",
"=",
"profile",
".",
"getElecType",
"(",
")",
"if",
"elecType",
"!=",
"\"soc\"",
"and",
"elecType",
"!=",
"\"toc\"",
"and",
"... | Returns an integer that is equal to the margin of victory of the election profile, that is,
the smallest number k such that changing k votes can change the winners.
:ivar Profile profile: A Profile object that represents an election profile. | [
"Returns",
"an",
"integer",
"that",
"is",
"equal",
"to",
"the",
"margin",
"of",
"victory",
"of",
"the",
"election",
"profile",
"that",
"is",
"the",
"smallest",
"number",
"k",
"such",
"that",
"changing",
"k",
"votes",
"can",
"change",
"the",
"winners",
"."
... | f395ba3782f05684fa5de0cece387a6da9391d02 | https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mov.py#L167-L303 | train | Returns an integer that is equal to the margin of victory of the election profile that can change the winners. |
PrefPy/prefpy | prefpy/mov.py | AppMoVMaximin | def AppMoVMaximin(profile):
"""
Returns an integer that is equal to the margin of victory of the election profile, that is,
the smallest number k such that changing k votes can change the winners.
:ivar Profile profile: A Profile object that represents an election profile.
"""
# Currently, we ... | python | def AppMoVMaximin(profile):
"""
Returns an integer that is equal to the margin of victory of the election profile, that is,
the smallest number k such that changing k votes can change the winners.
:ivar Profile profile: A Profile object that represents an election profile.
"""
# Currently, we ... | [
"def",
"AppMoVMaximin",
"(",
"profile",
")",
":",
"# Currently, we expect the profile to contain complete ordering over candidates.",
"elecType",
"=",
"profile",
".",
"getElecType",
"(",
")",
"if",
"elecType",
"!=",
"\"soc\"",
"and",
"elecType",
"!=",
"\"toc\"",
":",
"p... | Returns an integer that is equal to the margin of victory of the election profile, that is,
the smallest number k such that changing k votes can change the winners.
:ivar Profile profile: A Profile object that represents an election profile. | [
"Returns",
"an",
"integer",
"that",
"is",
"equal",
"to",
"the",
"margin",
"of",
"victory",
"of",
"the",
"election",
"profile",
"that",
"is",
"the",
"smallest",
"number",
"k",
"such",
"that",
"changing",
"k",
"votes",
"can",
"change",
"the",
"winners",
"."
... | f395ba3782f05684fa5de0cece387a6da9391d02 | https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mov.py#L306-L346 | train | Compute the maximum MOF V maximin score for a single election profile. |
PrefPy/prefpy | prefpy/mov.py | MaximinWinner | def MaximinWinner(profile):
"""
Returns an integer that represents the winning candidate given an election profile.
Tie-breaking rule: numerically increasing order
:ivar Profile profile: A Profile object that represents an election profile.
"""
# Currently, we expect the profile to contain com... | python | def MaximinWinner(profile):
"""
Returns an integer that represents the winning candidate given an election profile.
Tie-breaking rule: numerically increasing order
:ivar Profile profile: A Profile object that represents an election profile.
"""
# Currently, we expect the profile to contain com... | [
"def",
"MaximinWinner",
"(",
"profile",
")",
":",
"# Currently, we expect the profile to contain complete ordering over candidates.",
"elecType",
"=",
"profile",
".",
"getElecType",
"(",
")",
"if",
"elecType",
"!=",
"\"soc\"",
"and",
"elecType",
"!=",
"\"toc\"",
":",
"p... | Returns an integer that represents the winning candidate given an election profile.
Tie-breaking rule: numerically increasing order
:ivar Profile profile: A Profile object that represents an election profile. | [
"Returns",
"an",
"integer",
"that",
"represents",
"the",
"winning",
"candidate",
"given",
"an",
"election",
"profile",
".",
"Tie",
"-",
"breaking",
"rule",
":",
"numerically",
"increasing",
"order"
] | f395ba3782f05684fa5de0cece387a6da9391d02 | https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mov.py#L349-L365 | train | Returns an integer that represents the winning candidate given an election profile. |
PrefPy/prefpy | prefpy/mov.py | getMaximinScores | def getMaximinScores(profile):
"""
Returns a dictionary that associates integer representations of each candidate with their
Copeland score.
:ivar Profile profile: A Profile object that represents an election profile.
"""
# Currently, we expect the profile to contain complete ordering over can... | python | def getMaximinScores(profile):
"""
Returns a dictionary that associates integer representations of each candidate with their
Copeland score.
:ivar Profile profile: A Profile object that represents an election profile.
"""
# Currently, we expect the profile to contain complete ordering over can... | [
"def",
"getMaximinScores",
"(",
"profile",
")",
":",
"# Currently, we expect the profile to contain complete ordering over candidates. Ties are",
"# allowed however.",
"elecType",
"=",
"profile",
".",
"getElecType",
"(",
")",
"if",
"elecType",
"!=",
"\"soc\"",
"and",
"elecTyp... | Returns a dictionary that associates integer representations of each candidate with their
Copeland score.
:ivar Profile profile: A Profile object that represents an election profile. | [
"Returns",
"a",
"dictionary",
"that",
"associates",
"integer",
"representations",
"of",
"each",
"candidate",
"with",
"their",
"Copeland",
"score",
"."
] | f395ba3782f05684fa5de0cece387a6da9391d02 | https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mov.py#L368-L397 | train | Returns a dictionary that associates integer representations of each candidate with their maximin scores. |
PrefPy/prefpy | prefpy/mov.py | AppMoVCopeland | def AppMoVCopeland(profile, alpha=0.5):
"""
Returns an integer that is equal to the margin of victory of the election profile, that is,
the smallest number k such that changing k votes can change the winners.
:ivar Profile profile: A Profile object that represents an election profile.
"""
# Cu... | python | def AppMoVCopeland(profile, alpha=0.5):
"""
Returns an integer that is equal to the margin of victory of the election profile, that is,
the smallest number k such that changing k votes can change the winners.
:ivar Profile profile: A Profile object that represents an election profile.
"""
# Cu... | [
"def",
"AppMoVCopeland",
"(",
"profile",
",",
"alpha",
"=",
"0.5",
")",
":",
"# Currently, we expect the profile to contain complete ordering over candidates.",
"elecType",
"=",
"profile",
".",
"getElecType",
"(",
")",
"if",
"elecType",
"!=",
"\"soc\"",
"and",
"elecType... | Returns an integer that is equal to the margin of victory of the election profile, that is,
the smallest number k such that changing k votes can change the winners.
:ivar Profile profile: A Profile object that represents an election profile. | [
"Returns",
"an",
"integer",
"that",
"is",
"equal",
"to",
"the",
"margin",
"of",
"victory",
"of",
"the",
"election",
"profile",
"that",
"is",
"the",
"smallest",
"number",
"k",
"such",
"that",
"changing",
"k",
"votes",
"can",
"change",
"the",
"winners",
"."
... | f395ba3782f05684fa5de0cece387a6da9391d02 | https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mov.py#L400-L446 | train | Compute the Mo - V winner of an election profile. |
PrefPy/prefpy | prefpy/mov.py | CopelandWinner | def CopelandWinner(profile, alpha=0.5):
"""
Returns an integer that represents the winning candidate given an election profile.
Tie-breaking rule: numerically increasing order
:ivar Profile profile: A Profile object that represents an election profile.
"""
# Currently, we expect the profile to... | python | def CopelandWinner(profile, alpha=0.5):
"""
Returns an integer that represents the winning candidate given an election profile.
Tie-breaking rule: numerically increasing order
:ivar Profile profile: A Profile object that represents an election profile.
"""
# Currently, we expect the profile to... | [
"def",
"CopelandWinner",
"(",
"profile",
",",
"alpha",
"=",
"0.5",
")",
":",
"# Currently, we expect the profile to contain complete ordering over candidates.",
"elecType",
"=",
"profile",
".",
"getElecType",
"(",
")",
"if",
"elecType",
"!=",
"\"soc\"",
"and",
"elecType... | Returns an integer that represents the winning candidate given an election profile.
Tie-breaking rule: numerically increasing order
:ivar Profile profile: A Profile object that represents an election profile. | [
"Returns",
"an",
"integer",
"that",
"represents",
"the",
"winning",
"candidate",
"given",
"an",
"election",
"profile",
".",
"Tie",
"-",
"breaking",
"rule",
":",
"numerically",
"increasing",
"order"
] | f395ba3782f05684fa5de0cece387a6da9391d02 | https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mov.py#L472-L488 | train | Returns an integer that represents the winning candidate given an election profile. |
PrefPy/prefpy | prefpy/mov.py | getCopelandScores | def getCopelandScores(profile, alpha=0.5, normalize=False):
"""
Returns a dictionary that associates integer representations of each candidate with their
Copeland score.
:ivar Profile profile: A Profile object that represents an election profile.
"""
# Currently, we expect the profile to conta... | python | def getCopelandScores(profile, alpha=0.5, normalize=False):
"""
Returns a dictionary that associates integer representations of each candidate with their
Copeland score.
:ivar Profile profile: A Profile object that represents an election profile.
"""
# Currently, we expect the profile to conta... | [
"def",
"getCopelandScores",
"(",
"profile",
",",
"alpha",
"=",
"0.5",
",",
"normalize",
"=",
"False",
")",
":",
"# Currently, we expect the profile to contain complete ordering over candidates. Ties are",
"# allowed however.",
"elecType",
"=",
"profile",
".",
"getElecType",
... | Returns a dictionary that associates integer representations of each candidate with their
Copeland score.
:ivar Profile profile: A Profile object that represents an election profile. | [
"Returns",
"a",
"dictionary",
"that",
"associates",
"integer",
"representations",
"of",
"each",
"candidate",
"with",
"their",
"Copeland",
"score",
"."
] | f395ba3782f05684fa5de0cece387a6da9391d02 | https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mov.py#L491-L530 | train | Returns a dictionary that associates integer representations of each candidate with their Copeland score. |
PrefPy/prefpy | prefpy/mov.py | MoV_SNTV | def MoV_SNTV(profile, K):
"""
Returns an integer that represents the winning candidate given an election profile.
Tie-breaking rule: numerically increasing order
:ivar Profile profile: A Profile object that represents an election profile.
"""
# Currently, we expect the profile to contain compl... | python | def MoV_SNTV(profile, K):
"""
Returns an integer that represents the winning candidate given an election profile.
Tie-breaking rule: numerically increasing order
:ivar Profile profile: A Profile object that represents an election profile.
"""
# Currently, we expect the profile to contain compl... | [
"def",
"MoV_SNTV",
"(",
"profile",
",",
"K",
")",
":",
"# Currently, we expect the profile to contain complete ordering over candidates.",
"elecType",
"=",
"profile",
".",
"getElecType",
"(",
")",
"if",
"elecType",
"!=",
"\"soc\"",
"and",
"elecType",
"!=",
"\"toc\"",
... | Returns an integer that represents the winning candidate given an election profile.
Tie-breaking rule: numerically increasing order
:ivar Profile profile: A Profile object that represents an election profile. | [
"Returns",
"an",
"integer",
"that",
"represents",
"the",
"winning",
"candidate",
"given",
"an",
"election",
"profile",
".",
"Tie",
"-",
"breaking",
"rule",
":",
"numerically",
"increasing",
"order"
] | f395ba3782f05684fa5de0cece387a6da9391d02 | https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mov.py#L533-L556 | train | Returns the number of winning candidates given an election profile. |
IRC-SPHERE/HyperStream | hyperstream/tool/base_tool.py | BaseTool.parameters_dict | def parameters_dict(self):
"""
Get the tool parameters as a simple dictionary
:return: The tool parameters
"""
d = {}
for k, v in self.__dict__.items():
if not k.startswith("_"):
d[k] = v
return d | python | def parameters_dict(self):
"""
Get the tool parameters as a simple dictionary
:return: The tool parameters
"""
d = {}
for k, v in self.__dict__.items():
if not k.startswith("_"):
d[k] = v
return d | [
"def",
"parameters_dict",
"(",
"self",
")",
":",
"d",
"=",
"{",
"}",
"for",
"k",
",",
"v",
"in",
"self",
".",
"__dict__",
".",
"items",
"(",
")",
":",
"if",
"not",
"k",
".",
"startswith",
"(",
"\"_\"",
")",
":",
"d",
"[",
"k",
"]",
"=",
"v",
... | Get the tool parameters as a simple dictionary
:return: The tool parameters | [
"Get",
"the",
"tool",
"parameters",
"as",
"a",
"simple",
"dictionary"
] | 98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780 | https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/tool/base_tool.py#L85-L95 | train | Get the tool parameters as a simple dictionary |
IRC-SPHERE/HyperStream | hyperstream/tool/base_tool.py | BaseTool.parameters | def parameters(self):
"""
Get the tool parameters
:return: The tool parameters along with additional information (whether they are functions or sets)
"""
parameters = []
for k, v in self.__dict__.items():
if k.startswith("_"):
continue
... | python | def parameters(self):
"""
Get the tool parameters
:return: The tool parameters along with additional information (whether they are functions or sets)
"""
parameters = []
for k, v in self.__dict__.items():
if k.startswith("_"):
continue
... | [
"def",
"parameters",
"(",
"self",
")",
":",
"parameters",
"=",
"[",
"]",
"for",
"k",
",",
"v",
"in",
"self",
".",
"__dict__",
".",
"items",
"(",
")",
":",
"if",
"k",
".",
"startswith",
"(",
"\"_\"",
")",
":",
"continue",
"is_function",
"=",
"False"... | Get the tool parameters
:return: The tool parameters along with additional information (whether they are functions or sets) | [
"Get",
"the",
"tool",
"parameters"
] | 98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780 | https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/tool/base_tool.py#L98-L128 | train | Get the tool parameters along with additional information |
IRC-SPHERE/HyperStream | hyperstream/tool/base_tool.py | BaseTool.parameters_from_model | def parameters_from_model(parameters_model):
"""
Get the tool parameters model from dictionaries
:param parameters_model: The parameters as a mongoengine model
:return: The tool parameters as a dictionary
"""
parameters = {}
for p in parameters_model:
... | python | def parameters_from_model(parameters_model):
"""
Get the tool parameters model from dictionaries
:param parameters_model: The parameters as a mongoengine model
:return: The tool parameters as a dictionary
"""
parameters = {}
for p in parameters_model:
... | [
"def",
"parameters_from_model",
"(",
"parameters_model",
")",
":",
"parameters",
"=",
"{",
"}",
"for",
"p",
"in",
"parameters_model",
":",
"if",
"p",
".",
"is_function",
":",
"code",
",",
"defaults",
",",
"closure",
"=",
"pickle",
".",
"loads",
"(",
"p",
... | Get the tool parameters model from dictionaries
:param parameters_model: The parameters as a mongoengine model
:return: The tool parameters as a dictionary | [
"Get",
"the",
"tool",
"parameters",
"model",
"from",
"dictionaries"
] | 98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780 | https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/tool/base_tool.py#L131-L147 | train | Get the tool parameters model from a dictionary of parameters. |
IRC-SPHERE/HyperStream | hyperstream/tool/base_tool.py | BaseTool.get_model | def get_model(self):
"""
Gets the mongoengine model for this tool, which serializes parameters that are functions
:return: The mongoengine model. TODO: Note that the tool version is currently incorrect (0.0.0)
"""
return ToolModel(
name=self.name,
versio... | python | def get_model(self):
"""
Gets the mongoengine model for this tool, which serializes parameters that are functions
:return: The mongoengine model. TODO: Note that the tool version is currently incorrect (0.0.0)
"""
return ToolModel(
name=self.name,
versio... | [
"def",
"get_model",
"(",
"self",
")",
":",
"return",
"ToolModel",
"(",
"name",
"=",
"self",
".",
"name",
",",
"version",
"=",
"\"0.0.0\"",
",",
"parameters",
"=",
"self",
".",
"parameters_from_dicts",
"(",
"self",
".",
"parameters",
")",
")"
] | Gets the mongoengine model for this tool, which serializes parameters that are functions
:return: The mongoengine model. TODO: Note that the tool version is currently incorrect (0.0.0) | [
"Gets",
"the",
"mongoengine",
"model",
"for",
"this",
"tool",
"which",
"serializes",
"parameters",
"that",
"are",
"functions"
] | 98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780 | https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/tool/base_tool.py#L159-L170 | train | Gets the mongoengine model for this tool which serializes parameters that are functions
|
IRC-SPHERE/HyperStream | hyperstream/tool/base_tool.py | BaseTool.write_to_history | def write_to_history(**kwargs):
"""
Write to the history of executions of this tool
:param kwargs: keyword arguments describing the executions
:return: None
"""
from hyperstream import HyperStream
hs = HyperStream(loglevel=logging.CRITICAL, file_logger=False, con... | python | def write_to_history(**kwargs):
"""
Write to the history of executions of this tool
:param kwargs: keyword arguments describing the executions
:return: None
"""
from hyperstream import HyperStream
hs = HyperStream(loglevel=logging.CRITICAL, file_logger=False, con... | [
"def",
"write_to_history",
"(",
"*",
"*",
"kwargs",
")",
":",
"from",
"hyperstream",
"import",
"HyperStream",
"hs",
"=",
"HyperStream",
"(",
"loglevel",
"=",
"logging",
".",
"CRITICAL",
",",
"file_logger",
"=",
"False",
",",
"console_logger",
"=",
"False",
"... | Write to the history of executions of this tool
:param kwargs: keyword arguments describing the executions
:return: None | [
"Write",
"to",
"the",
"history",
"of",
"executions",
"of",
"this",
"tool"
] | 98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780 | https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/tool/base_tool.py#L173-L183 | train | Write to the history of executions of this tool
|
PrefPy/prefpy | prefpy/gmm_mixpl.py | calcMomentsMatlabEmpirical | def calcMomentsMatlabEmpirical(params):
"""Top 3 alternatives 20 empirical moment conditions"""
alpha = params[0]
a = params[1:5]
b = params[5:]
p1 = alpha*a+(1-alpha)*b
p21 = alpha*a[0]*a[1:]/(1-a[0])+(1-alpha)*b[0]*b[1:]/(1-b[0])
p22 = alpha*a[1]*np.hstack((a[0],a[2:]))/(1-a[1])+(1-alpha)*... | python | def calcMomentsMatlabEmpirical(params):
"""Top 3 alternatives 20 empirical moment conditions"""
alpha = params[0]
a = params[1:5]
b = params[5:]
p1 = alpha*a+(1-alpha)*b
p21 = alpha*a[0]*a[1:]/(1-a[0])+(1-alpha)*b[0]*b[1:]/(1-b[0])
p22 = alpha*a[1]*np.hstack((a[0],a[2:]))/(1-a[1])+(1-alpha)*... | [
"def",
"calcMomentsMatlabEmpirical",
"(",
"params",
")",
":",
"alpha",
"=",
"params",
"[",
"0",
"]",
"a",
"=",
"params",
"[",
"1",
":",
"5",
"]",
"b",
"=",
"params",
"[",
"5",
":",
"]",
"p1",
"=",
"alpha",
"*",
"a",
"+",
"(",
"1",
"-",
"alpha",... | Top 3 alternatives 20 empirical moment conditions | [
"Top",
"3",
"alternatives",
"20",
"empirical",
"moment",
"conditions"
] | f395ba3782f05684fa5de0cece387a6da9391d02 | https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/gmm_mixpl.py#L33-L49 | train | Calculate the empirical moment conditions for the given set of alternatives. |
PrefPy/prefpy | prefpy/gmm_mixpl.py | GMMMixPLAggregator.aggregate | def aggregate(self, rankings, algorithm, epsilon, max_iters, approx_step, opto="scipy", true_params=None):
"""
Description:
Takes in a set of rankings and an algorithm to apply
and computes the mixing proportions and parameters for
a mixture of Plackett-Luce models.
... | python | def aggregate(self, rankings, algorithm, epsilon, max_iters, approx_step, opto="scipy", true_params=None):
"""
Description:
Takes in a set of rankings and an algorithm to apply
and computes the mixing proportions and parameters for
a mixture of Plackett-Luce models.
... | [
"def",
"aggregate",
"(",
"self",
",",
"rankings",
",",
"algorithm",
",",
"epsilon",
",",
"max_iters",
",",
"approx_step",
",",
"opto",
"=",
"\"scipy\"",
",",
"true_params",
"=",
"None",
")",
":",
"t0",
"=",
"None",
"t1",
"=",
"None",
"t2",
"=",
"None",... | Description:
Takes in a set of rankings and an algorithm to apply
and computes the mixing proportions and parameters for
a mixture of Plackett-Luce models.
Parameters:
rankings: set of rankings over the set of alternatives
algorithm: string abbrev... | [
"Description",
":",
"Takes",
"in",
"a",
"set",
"of",
"rankings",
"and",
"an",
"algorithm",
"to",
"apply",
"and",
"computes",
"the",
"mixing",
"proportions",
"and",
"parameters",
"for",
"a",
"mixture",
"of",
"Plackett",
"-",
"Luce",
"models",
".",
"Parameters... | f395ba3782f05684fa5de0cece387a6da9391d02 | https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/gmm_mixpl.py#L123-L240 | train | This function computes the mixing proportions and parameters for a single language language. |
tamasgal/km3pipe | km3modules/plot.py | plot_dom_parameters | def plot_dom_parameters(
data,
detector,
filename,
label,
title,
vmin=0.0,
vmax=10.0,
cmap='RdYlGn_r',
under='deepskyblue',
over='deeppink',
underfactor=1.0,
overfactor=1.0,
missing='lightgray',
hide_limits=F... | python | def plot_dom_parameters(
data,
detector,
filename,
label,
title,
vmin=0.0,
vmax=10.0,
cmap='RdYlGn_r',
under='deepskyblue',
over='deeppink',
underfactor=1.0,
overfactor=1.0,
missing='lightgray',
hide_limits=F... | [
"def",
"plot_dom_parameters",
"(",
"data",
",",
"detector",
",",
"filename",
",",
"label",
",",
"title",
",",
"vmin",
"=",
"0.0",
",",
"vmax",
"=",
"10.0",
",",
"cmap",
"=",
"'RdYlGn_r'",
",",
"under",
"=",
"'deepskyblue'",
",",
"over",
"=",
"'deeppink'"... | Creates a plot in the classical monitoring.km3net.de style.
Parameters
----------
data: dict((du, floor) -> value)
detector: km3pipe.hardware.Detector() instance
filename: filename or filepath
label: str
title: str
underfactor: a scale factor for the points used for underflow values
... | [
"Creates",
"a",
"plot",
"in",
"the",
"classical",
"monitoring",
".",
"km3net",
".",
"de",
"style",
"."
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3modules/plot.py#L27-L129 | train | Plots the dominance parameters for a single classical monitoring. km3net. de style. |
tamasgal/km3pipe | km3modules/plot.py | make_dom_map | def make_dom_map(pmt_directions, values, nside=512, d=0.2, smoothing=0.1):
"""Create a mollweide projection of a DOM with given PMTs.
The output can be used to call the `healpy.mollview` function.
"""
import healpy as hp
discs = [hp.query_disc(nside, dir, 0.2) for dir in pmt_directions]
npix = ... | python | def make_dom_map(pmt_directions, values, nside=512, d=0.2, smoothing=0.1):
"""Create a mollweide projection of a DOM with given PMTs.
The output can be used to call the `healpy.mollview` function.
"""
import healpy as hp
discs = [hp.query_disc(nside, dir, 0.2) for dir in pmt_directions]
npix = ... | [
"def",
"make_dom_map",
"(",
"pmt_directions",
",",
"values",
",",
"nside",
"=",
"512",
",",
"d",
"=",
"0.2",
",",
"smoothing",
"=",
"0.1",
")",
":",
"import",
"healpy",
"as",
"hp",
"discs",
"=",
"[",
"hp",
".",
"query_disc",
"(",
"nside",
",",
"dir",... | Create a mollweide projection of a DOM with given PMTs.
The output can be used to call the `healpy.mollview` function. | [
"Create",
"a",
"mollweide",
"projection",
"of",
"a",
"DOM",
"with",
"given",
"PMTs",
"."
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3modules/plot.py#L132-L146 | train | Create a map of a DOM with given PMTs. |
IRC-SPHERE/HyperStream | hyperstream/stream/stream.py | Stream.calculated_intervals | def calculated_intervals(self, value):
"""
Set the calculated intervals
This will be written to the stream_status collection if it's in the database channel
:param value: The calculated intervals
:type value: TimeIntervals, TimeInterval, list[TimeInterval]
"""
if... | python | def calculated_intervals(self, value):
"""
Set the calculated intervals
This will be written to the stream_status collection if it's in the database channel
:param value: The calculated intervals
:type value: TimeIntervals, TimeInterval, list[TimeInterval]
"""
if... | [
"def",
"calculated_intervals",
"(",
"self",
",",
"value",
")",
":",
"if",
"not",
"value",
":",
"self",
".",
"_calculated_intervals",
"=",
"TimeIntervals",
"(",
")",
"return",
"if",
"isinstance",
"(",
"value",
",",
"TimeInterval",
")",
":",
"value",
"=",
"T... | Set the calculated intervals
This will be written to the stream_status collection if it's in the database channel
:param value: The calculated intervals
:type value: TimeIntervals, TimeInterval, list[TimeInterval] | [
"Set",
"the",
"calculated",
"intervals",
"This",
"will",
"be",
"written",
"to",
"the",
"stream_status",
"collection",
"if",
"it",
"s",
"in",
"the",
"database",
"channel"
] | 98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780 | https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/stream/stream.py#L115-L140 | train | Set the calculated intervals for the current channel |
IRC-SPHERE/HyperStream | hyperstream/stream/stream.py | Stream.purge | def purge(self):
"""
Purge the stream. This removes all data and clears the calculated intervals
:return: None
"""
self.channel.purge_stream(self.stream_id, remove_definition=False, sandbox=None) | python | def purge(self):
"""
Purge the stream. This removes all data and clears the calculated intervals
:return: None
"""
self.channel.purge_stream(self.stream_id, remove_definition=False, sandbox=None) | [
"def",
"purge",
"(",
"self",
")",
":",
"self",
".",
"channel",
".",
"purge_stream",
"(",
"self",
".",
"stream_id",
",",
"remove_definition",
"=",
"False",
",",
"sandbox",
"=",
"None",
")"
] | Purge the stream. This removes all data and clears the calculated intervals
:return: None | [
"Purge",
"the",
"stream",
".",
"This",
"removes",
"all",
"data",
"and",
"clears",
"the",
"calculated",
"intervals"
] | 98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780 | https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/stream/stream.py#L142-L148 | train | This method removes all data and clears the calculated intervals
|
IRC-SPHERE/HyperStream | hyperstream/stream/stream.py | Stream.window | def window(self, time_interval=None, force_calculation=False):
"""
Gets a view on this stream for the time interval given
:param time_interval: either a TimeInterval object or (start, end) tuple of type str or datetime
:param force_calculation: Whether we should force calculation for th... | python | def window(self, time_interval=None, force_calculation=False):
"""
Gets a view on this stream for the time interval given
:param time_interval: either a TimeInterval object or (start, end) tuple of type str or datetime
:param force_calculation: Whether we should force calculation for th... | [
"def",
"window",
"(",
"self",
",",
"time_interval",
"=",
"None",
",",
"force_calculation",
"=",
"False",
")",
":",
"if",
"not",
"time_interval",
":",
"if",
"self",
".",
"calculated_intervals",
":",
"time_interval",
"=",
"self",
".",
"calculated_intervals",
"["... | Gets a view on this stream for the time interval given
:param time_interval: either a TimeInterval object or (start, end) tuple of type str or datetime
:param force_calculation: Whether we should force calculation for this stream view if data does not exist
:type time_interval: None | Iterable ... | [
"Gets",
"a",
"view",
"on",
"this",
"stream",
"for",
"the",
"time",
"interval",
"given"
] | 98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780 | https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/stream/stream.py#L154-L180 | train | Returns a StreamView object for the given time interval. |
IRC-SPHERE/HyperStream | hyperstream/stream/stream.py | DatabaseStream.load | def load(self):
"""
Load the stream definition from the database
:return: None
"""
with switch_db(StreamDefinitionModel, 'hyperstream'):
self.mongo_model = StreamDefinitionModel.objects.get(__raw__=self.stream_id.as_raw())
self._calculated_intervals = sel... | python | def load(self):
"""
Load the stream definition from the database
:return: None
"""
with switch_db(StreamDefinitionModel, 'hyperstream'):
self.mongo_model = StreamDefinitionModel.objects.get(__raw__=self.stream_id.as_raw())
self._calculated_intervals = sel... | [
"def",
"load",
"(",
"self",
")",
":",
"with",
"switch_db",
"(",
"StreamDefinitionModel",
",",
"'hyperstream'",
")",
":",
"self",
".",
"mongo_model",
"=",
"StreamDefinitionModel",
".",
"objects",
".",
"get",
"(",
"__raw__",
"=",
"self",
".",
"stream_id",
".",... | Load the stream definition from the database
:return: None | [
"Load",
"the",
"stream",
"definition",
"from",
"the",
"database"
] | 98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780 | https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/stream/stream.py#L212-L220 | train | Load the stream definition from the database |
IRC-SPHERE/HyperStream | hyperstream/stream/stream.py | DatabaseStream.calculated_intervals | def calculated_intervals(self):
"""
Gets the calculated intervals from the database
:return: The calculated intervals
"""
if self._calculated_intervals is None:
logging.debug("get calculated intervals")
self.load()
return self.mongo_model.get_... | python | def calculated_intervals(self):
"""
Gets the calculated intervals from the database
:return: The calculated intervals
"""
if self._calculated_intervals is None:
logging.debug("get calculated intervals")
self.load()
return self.mongo_model.get_... | [
"def",
"calculated_intervals",
"(",
"self",
")",
":",
"if",
"self",
".",
"_calculated_intervals",
"is",
"None",
":",
"logging",
".",
"debug",
"(",
"\"get calculated intervals\"",
")",
"self",
".",
"load",
"(",
")",
"return",
"self",
".",
"mongo_model",
".",
... | Gets the calculated intervals from the database
:return: The calculated intervals | [
"Gets",
"the",
"calculated",
"intervals",
"from",
"the",
"database"
] | 98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780 | https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/stream/stream.py#L233-L243 | train | Gets the calculated intervals from the database |
IRC-SPHERE/HyperStream | hyperstream/stream/stream.py | DatabaseStream.calculated_intervals | def calculated_intervals(self, intervals):
"""
Updates the calculated intervals in the database. Performs an upsert
:param intervals: The calculated intervals
:return: None
"""
logging.debug("set calculated intervals")
self.mongo_model.set_calculated_intervals(in... | python | def calculated_intervals(self, intervals):
"""
Updates the calculated intervals in the database. Performs an upsert
:param intervals: The calculated intervals
:return: None
"""
logging.debug("set calculated intervals")
self.mongo_model.set_calculated_intervals(in... | [
"def",
"calculated_intervals",
"(",
"self",
",",
"intervals",
")",
":",
"logging",
".",
"debug",
"(",
"\"set calculated intervals\"",
")",
"self",
".",
"mongo_model",
".",
"set_calculated_intervals",
"(",
"intervals",
")",
"self",
".",
"save",
"(",
")",
"self",
... | Updates the calculated intervals in the database. Performs an upsert
:param intervals: The calculated intervals
:return: None | [
"Updates",
"the",
"calculated",
"intervals",
"in",
"the",
"database",
".",
"Performs",
"an",
"upsert"
] | 98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780 | https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/stream/stream.py#L246-L256 | train | Updates the calculated intervals in the database. Performs an upsert
. |
IRC-SPHERE/HyperStream | hyperstream/stream/stream.py | AssetStream.calculated_intervals | def calculated_intervals(self, intervals):
"""
Updates the calculated intervals in the database. Performs an upsert
:param intervals: The calculated intervals
:return: None
"""
if len(intervals) > 1:
raise ValueError("Only single calculated interval valid for... | python | def calculated_intervals(self, intervals):
"""
Updates the calculated intervals in the database. Performs an upsert
:param intervals: The calculated intervals
:return: None
"""
if len(intervals) > 1:
raise ValueError("Only single calculated interval valid for... | [
"def",
"calculated_intervals",
"(",
"self",
",",
"intervals",
")",
":",
"if",
"len",
"(",
"intervals",
")",
">",
"1",
":",
"raise",
"ValueError",
"(",
"\"Only single calculated interval valid for AssetStream\"",
")",
"super",
"(",
"AssetStream",
",",
"self",
".",
... | Updates the calculated intervals in the database. Performs an upsert
:param intervals: The calculated intervals
:return: None | [
"Updates",
"the",
"calculated",
"intervals",
"in",
"the",
"database",
".",
"Performs",
"an",
"upsert"
] | 98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780 | https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/stream/stream.py#L308-L317 | train | Updates the calculated intervals in the database. Performs an upsert
. |
tamasgal/km3pipe | km3pipe/io/__init__.py | GenericPump | def GenericPump(filenames, use_jppy=False, name="GenericPump", **kwargs):
"""A generic pump which utilises the appropriate pump."""
if isinstance(filenames, str):
filenames = [filenames]
try:
iter(filenames)
except TypeError:
log.critical("Don't know how to iterate through filen... | python | def GenericPump(filenames, use_jppy=False, name="GenericPump", **kwargs):
"""A generic pump which utilises the appropriate pump."""
if isinstance(filenames, str):
filenames = [filenames]
try:
iter(filenames)
except TypeError:
log.critical("Don't know how to iterate through filen... | [
"def",
"GenericPump",
"(",
"filenames",
",",
"use_jppy",
"=",
"False",
",",
"name",
"=",
"\"GenericPump\"",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"filenames",
",",
"str",
")",
":",
"filenames",
"=",
"[",
"filenames",
"]",
"try",
"... | A generic pump which utilises the appropriate pump. | [
"A",
"generic",
"pump",
"which",
"utilises",
"the",
"appropriate",
"pump",
"."
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/io/__init__.py#L36-L87 | train | A generic pump which utilises the appropriate pump. |
tamasgal/km3pipe | km3pipe/io/__init__.py | read_calibration | def read_calibration(
detx=None, det_id=None, from_file=False, det_id_table=None
):
"""Retrive calibration from file, the DB."""
from km3pipe.calib import Calibration # noqa
if not (detx or det_id or from_file):
return None
if detx is not None:
return Calibration(filename=det... | python | def read_calibration(
detx=None, det_id=None, from_file=False, det_id_table=None
):
"""Retrive calibration from file, the DB."""
from km3pipe.calib import Calibration # noqa
if not (detx or det_id or from_file):
return None
if detx is not None:
return Calibration(filename=det... | [
"def",
"read_calibration",
"(",
"detx",
"=",
"None",
",",
"det_id",
"=",
"None",
",",
"from_file",
"=",
"False",
",",
"det_id_table",
"=",
"None",
")",
":",
"from",
"km3pipe",
".",
"calib",
"import",
"Calibration",
"# noqa",
"if",
"not",
"(",
"detx",
"or... | Retrive calibration from file, the DB. | [
"Retrive",
"calibration",
"from",
"file",
"the",
"DB",
"."
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/io/__init__.py#L90-L113 | train | Retrive calibration from file the DB. |
NaPs/Kolekto | kolekto/printer.py | KolektoPrinter.ask | def ask(self, question, default=False):
""" Ask a y/n question to the user.
"""
choices = '[%s/%s]' % ('Y' if default else 'y', 'n' if default else 'N')
while True:
response = raw_input('%s %s' % (question, choices)).strip()
if not response:
return... | python | def ask(self, question, default=False):
""" Ask a y/n question to the user.
"""
choices = '[%s/%s]' % ('Y' if default else 'y', 'n' if default else 'N')
while True:
response = raw_input('%s %s' % (question, choices)).strip()
if not response:
return... | [
"def",
"ask",
"(",
"self",
",",
"question",
",",
"default",
"=",
"False",
")",
":",
"choices",
"=",
"'[%s/%s]'",
"%",
"(",
"'Y'",
"if",
"default",
"else",
"'y'",
",",
"'n'",
"if",
"default",
"else",
"'N'",
")",
"while",
"True",
":",
"response",
"=",
... | Ask a y/n question to the user. | [
"Ask",
"a",
"y",
"/",
"n",
"question",
"to",
"the",
"user",
"."
] | 29c5469da8782780a06bf9a76c59414bb6fd8fe3 | https://github.com/NaPs/Kolekto/blob/29c5469da8782780a06bf9a76c59414bb6fd8fe3/kolekto/printer.py#L263-L274 | train | Ask a y or n question to the user. |
NaPs/Kolekto | kolekto/printer.py | KolektoPrinter.edit | def edit(self, text):
""" Edit a text using an external editor.
"""
if isinstance(text, unicode):
text = text.encode(self._encoding)
if self._editor is None:
printer.p('Warning: no editor found, skipping edit')
return text
with tempfile.NamedTe... | python | def edit(self, text):
""" Edit a text using an external editor.
"""
if isinstance(text, unicode):
text = text.encode(self._encoding)
if self._editor is None:
printer.p('Warning: no editor found, skipping edit')
return text
with tempfile.NamedTe... | [
"def",
"edit",
"(",
"self",
",",
"text",
")",
":",
"if",
"isinstance",
"(",
"text",
",",
"unicode",
")",
":",
"text",
"=",
"text",
".",
"encode",
"(",
"self",
".",
"_encoding",
")",
"if",
"self",
".",
"_editor",
"is",
"None",
":",
"printer",
".",
... | Edit a text using an external editor. | [
"Edit",
"a",
"text",
"using",
"an",
"external",
"editor",
"."
] | 29c5469da8782780a06bf9a76c59414bb6fd8fe3 | https://github.com/NaPs/Kolekto/blob/29c5469da8782780a06bf9a76c59414bb6fd8fe3/kolekto/printer.py#L276-L290 | train | Edit a text using an external editor. |
jdodds/feather | feather/application.py | Application.register | def register(self, plugin):
"""Take a feather.plugin.Plugin and tell our dispatcher about it.
Plugins are expected to provide a list of the messages that they
listen for and generate. If registering this plugin makes it so we have
at least one plugin listening for and generating our exp... | python | def register(self, plugin):
"""Take a feather.plugin.Plugin and tell our dispatcher about it.
Plugins are expected to provide a list of the messages that they
listen for and generate. If registering this plugin makes it so we have
at least one plugin listening for and generating our exp... | [
"def",
"register",
"(",
"self",
",",
"plugin",
")",
":",
"self",
".",
"needed_listeners",
"-=",
"plugin",
".",
"listeners",
"self",
".",
"needed_messengers",
"-=",
"plugin",
".",
"messengers",
"if",
"self",
".",
"needed_messengers",
"==",
"self",
".",
"neede... | Take a feather.plugin.Plugin and tell our dispatcher about it.
Plugins are expected to provide a list of the messages that they
listen for and generate. If registering this plugin makes it so we have
at least one plugin listening for and generating our expected messages,
set self.valid ... | [
"Take",
"a",
"feather",
".",
"plugin",
".",
"Plugin",
"and",
"tell",
"our",
"dispatcher",
"about",
"it",
"."
] | 92a9426e692b33c7fddf758df8dbc99a9a1ba8ef | https://github.com/jdodds/feather/blob/92a9426e692b33c7fddf758df8dbc99a9a1ba8ef/feather/application.py#L29-L43 | train | Register a feather. plugin. Plugin and tell our dispatcher about it. |
jdodds/feather | feather/application.py | Application.start | def start(self):
"""If we have a set of plugins that provide our expected listeners and
messengers, tell our dispatcher to start up. Otherwise, raise
InvalidApplication
"""
if not self.valid:
err = ("\nMessengers and listeners that still need set:\n\n"
... | python | def start(self):
"""If we have a set of plugins that provide our expected listeners and
messengers, tell our dispatcher to start up. Otherwise, raise
InvalidApplication
"""
if not self.valid:
err = ("\nMessengers and listeners that still need set:\n\n"
... | [
"def",
"start",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"valid",
":",
"err",
"=",
"(",
"\"\\nMessengers and listeners that still need set:\\n\\n\"",
"\"messengers : %s\\n\\n\"",
"\"listeners : %s\\n\"",
")",
"raise",
"InvalidApplication",
"(",
"err",
"%",
"("... | If we have a set of plugins that provide our expected listeners and
messengers, tell our dispatcher to start up. Otherwise, raise
InvalidApplication | [
"If",
"we",
"have",
"a",
"set",
"of",
"plugins",
"that",
"provide",
"our",
"expected",
"listeners",
"and",
"messengers",
"tell",
"our",
"dispatcher",
"to",
"start",
"up",
".",
"Otherwise",
"raise",
"InvalidApplication"
] | 92a9426e692b33c7fddf758df8dbc99a9a1ba8ef | https://github.com/jdodds/feather/blob/92a9426e692b33c7fddf758df8dbc99a9a1ba8ef/feather/application.py#L45-L56 | train | Start the dispatcher if we have a set of needed messengers and the calendars that need to be set. |
baranbartu/rulengine | rulengine/conditions.py | execute_condition | def execute_condition(cond):
"""
Get a rule instance for given operator and
return condition lambda func
"""
condition_method = 'rulengine.conditions.c_{0}_{1}'.format(
cond.data_type, cond.operator)
try:
func = import_class(condition_method)
except AttributeError:
c... | python | def execute_condition(cond):
"""
Get a rule instance for given operator and
return condition lambda func
"""
condition_method = 'rulengine.conditions.c_{0}_{1}'.format(
cond.data_type, cond.operator)
try:
func = import_class(condition_method)
except AttributeError:
c... | [
"def",
"execute_condition",
"(",
"cond",
")",
":",
"condition_method",
"=",
"'rulengine.conditions.c_{0}_{1}'",
".",
"format",
"(",
"cond",
".",
"data_type",
",",
"cond",
".",
"operator",
")",
"try",
":",
"func",
"=",
"import_class",
"(",
"condition_method",
")"... | Get a rule instance for given operator and
return condition lambda func | [
"Get",
"a",
"rule",
"instance",
"for",
"given",
"operator",
"and",
"return",
"condition",
"lambda",
"func"
] | f4d1e6258927cb171cb7fc8a90a3cba546a2aee5 | https://github.com/baranbartu/rulengine/blob/f4d1e6258927cb171cb7fc8a90a3cba546a2aee5/rulengine/conditions.py#L5-L21 | train | Execute a condition for the current language and return a function that returns the rule instance for the given operator and
ArcGIS object |
abiiranathan/db2 | db2/session.py | Session.add | def add(self, instance):
'''
Insert a record to the table
emp = Employee(emp_id=1, name='Jane Doe', sex='Female')
inserted = Session().add(emp)
Returns a bool or raises mysql.Error exception
'''
table = instance.__class__.__name__.lower()
keys = ", ".joi... | python | def add(self, instance):
'''
Insert a record to the table
emp = Employee(emp_id=1, name='Jane Doe', sex='Female')
inserted = Session().add(emp)
Returns a bool or raises mysql.Error exception
'''
table = instance.__class__.__name__.lower()
keys = ", ".joi... | [
"def",
"add",
"(",
"self",
",",
"instance",
")",
":",
"table",
"=",
"instance",
".",
"__class__",
".",
"__name__",
".",
"lower",
"(",
")",
"keys",
"=",
"\", \"",
".",
"join",
"(",
"vars",
"(",
"instance",
")",
".",
"keys",
"(",
")",
")",
"values",
... | Insert a record to the table
emp = Employee(emp_id=1, name='Jane Doe', sex='Female')
inserted = Session().add(emp)
Returns a bool or raises mysql.Error exception | [
"Insert",
"a",
"record",
"to",
"the",
"table",
"emp",
"=",
"Employee",
"(",
"emp_id",
"=",
"1",
"name",
"=",
"Jane",
"Doe",
"sex",
"=",
"Female",
")",
"inserted",
"=",
"Session",
"()",
".",
"add",
"(",
"emp",
")",
"Returns",
"a",
"bool",
"or",
"rai... | 347319e421921517bcae7639f524c3c3eb5446e6 | https://github.com/abiiranathan/db2/blob/347319e421921517bcae7639f524c3c3eb5446e6/db2/session.py#L91-L125 | train | Insert a record to the table
|
abiiranathan/db2 | db2/session.py | Session.update | def update(self, instance):
'''
Update a record to the table
emp = Employee(emp_id=1, name='John Doe', sex='Female')
updated = Session().add(emp)
Returns a bool or raises mysql.Error exception
'''
if not self.exists(instance.__class__, instance.id):
... | python | def update(self, instance):
'''
Update a record to the table
emp = Employee(emp_id=1, name='John Doe', sex='Female')
updated = Session().add(emp)
Returns a bool or raises mysql.Error exception
'''
if not self.exists(instance.__class__, instance.id):
... | [
"def",
"update",
"(",
"self",
",",
"instance",
")",
":",
"if",
"not",
"self",
".",
"exists",
"(",
"instance",
".",
"__class__",
",",
"instance",
".",
"id",
")",
":",
"print",
"(",
"\"Cant update a value that does not exist\"",
")",
"return",
"False",
"instan... | Update a record to the table
emp = Employee(emp_id=1, name='John Doe', sex='Female')
updated = Session().add(emp)
Returns a bool or raises mysql.Error exception | [
"Update",
"a",
"record",
"to",
"the",
"table",
"emp",
"=",
"Employee",
"(",
"emp_id",
"=",
"1",
"name",
"=",
"John",
"Doe",
"sex",
"=",
"Female",
")",
"updated",
"=",
"Session",
"()",
".",
"add",
"(",
"emp",
")",
"Returns",
"a",
"bool",
"or",
"rais... | 347319e421921517bcae7639f524c3c3eb5446e6 | https://github.com/abiiranathan/db2/blob/347319e421921517bcae7639f524c3c3eb5446e6/db2/session.py#L127-L161 | train | Update a record in the table
|
abiiranathan/db2 | db2/session.py | Session.delete | def delete(self, model_class, **where):
'''
Session().delete(Employee, id=1, name='John Doe')
'''
assert hasattr(model_class, '_fields'), 'Not a valid class'
table = model_class.__name__.lower()
with Session() as conn:
SQL = f'DELETE FROM {table} WHERE'
... | python | def delete(self, model_class, **where):
'''
Session().delete(Employee, id=1, name='John Doe')
'''
assert hasattr(model_class, '_fields'), 'Not a valid class'
table = model_class.__name__.lower()
with Session() as conn:
SQL = f'DELETE FROM {table} WHERE'
... | [
"def",
"delete",
"(",
"self",
",",
"model_class",
",",
"*",
"*",
"where",
")",
":",
"assert",
"hasattr",
"(",
"model_class",
",",
"'_fields'",
")",
",",
"'Not a valid class'",
"table",
"=",
"model_class",
".",
"__name__",
".",
"lower",
"(",
")",
"with",
... | Session().delete(Employee, id=1, name='John Doe') | [
"Session",
"()",
".",
"delete",
"(",
"Employee",
"id",
"=",
"1",
"name",
"=",
"John",
"Doe",
")"
] | 347319e421921517bcae7639f524c3c3eb5446e6 | https://github.com/abiiranathan/db2/blob/347319e421921517bcae7639f524c3c3eb5446e6/db2/session.py#L163-L182 | train | Delete all records of the given model class. |
abiiranathan/db2 | db2/session.py | Session.delete_all | def delete_all(self, model_class):
'''Drop all records from the table model_class.__name__.lower()
'''
assert hasattr(model_class, '_fields'), 'Not a valid model class'
table = model_class.__name__.lower()
with Session() as conn:
SQL = f'DELETE FROM {table}'
... | python | def delete_all(self, model_class):
'''Drop all records from the table model_class.__name__.lower()
'''
assert hasattr(model_class, '_fields'), 'Not a valid model class'
table = model_class.__name__.lower()
with Session() as conn:
SQL = f'DELETE FROM {table}'
... | [
"def",
"delete_all",
"(",
"self",
",",
"model_class",
")",
":",
"assert",
"hasattr",
"(",
"model_class",
",",
"'_fields'",
")",
",",
"'Not a valid model class'",
"table",
"=",
"model_class",
".",
"__name__",
".",
"lower",
"(",
")",
"with",
"Session",
"(",
")... | Drop all records from the table model_class.__name__.lower() | [
"Drop",
"all",
"records",
"from",
"the",
"table",
"model_class",
".",
"__name__",
".",
"lower",
"()"
] | 347319e421921517bcae7639f524c3c3eb5446e6 | https://github.com/abiiranathan/db2/blob/347319e421921517bcae7639f524c3c3eb5446e6/db2/session.py#L184-L193 | train | Drop all records from the table model_class. |
abiiranathan/db2 | db2/session.py | Session.get | def get(self, model_class, strict=True, returnDict=False, fetchOne=False, **where):
'''params:
model_class: The queried model class
strict: bool -> If True, queries are run with EQUAL(=) operator.
If False: Queries are run with RLIKE keyword
returnDict: bool -> Return a list if d... | python | def get(self, model_class, strict=True, returnDict=False, fetchOne=False, **where):
'''params:
model_class: The queried model class
strict: bool -> If True, queries are run with EQUAL(=) operator.
If False: Queries are run with RLIKE keyword
returnDict: bool -> Return a list if d... | [
"def",
"get",
"(",
"self",
",",
"model_class",
",",
"strict",
"=",
"True",
",",
"returnDict",
"=",
"False",
",",
"fetchOne",
"=",
"False",
",",
"*",
"*",
"where",
")",
":",
"self",
".",
"typeassert",
"(",
"model_class",
",",
"strict",
",",
"returnDict"... | params:
model_class: The queried model class
strict: bool -> If True, queries are run with EQUAL(=) operator.
If False: Queries are run with RLIKE keyword
returnDict: bool -> Return a list if dictionaries(field_names: values)
fetchOne: bool -> cursor.fetchone() else: cursor.fetch... | [
"params",
":",
"model_class",
":",
"The",
"queried",
"model",
"class",
"strict",
":",
"bool",
"-",
">",
"If",
"True",
"queries",
"are",
"run",
"with",
"EQUAL",
"(",
"=",
")",
"operator",
".",
"If",
"False",
":",
"Queries",
"are",
"run",
"with",
"RLIKE"... | 347319e421921517bcae7639f524c3c3eb5446e6 | https://github.com/abiiranathan/db2/blob/347319e421921517bcae7639f524c3c3eb5446e6/db2/session.py#L201-L252 | train | Get all the related entries of a specific model class. |
abiiranathan/db2 | db2/session.py | Session.execute | def execute(self, SQL, fetchOne=False):
'''Directly execute queries
Works on all SELECT, UPDATE, INSERT AND DELETE QUERIES
SQL: query to execute
fetchOne: bool >> cursor.fetchone()
Return:
False if an exception occurs
True: No errors in queries
... | python | def execute(self, SQL, fetchOne=False):
'''Directly execute queries
Works on all SELECT, UPDATE, INSERT AND DELETE QUERIES
SQL: query to execute
fetchOne: bool >> cursor.fetchone()
Return:
False if an exception occurs
True: No errors in queries
... | [
"def",
"execute",
"(",
"self",
",",
"SQL",
",",
"fetchOne",
"=",
"False",
")",
":",
"with",
"Session",
"(",
"self",
".",
"settings",
")",
"as",
"conn",
":",
"c",
"=",
"conn",
".",
"cursor",
"(",
")",
"try",
":",
"c",
".",
"execute",
"(",
"SQL",
... | Directly execute queries
Works on all SELECT, UPDATE, INSERT AND DELETE QUERIES
SQL: query to execute
fetchOne: bool >> cursor.fetchone()
Return:
False if an exception occurs
True: No errors in queries
List if select query | [
"Directly",
"execute",
"queries",
"Works",
"on",
"all",
"SELECT",
"UPDATE",
"INSERT",
"AND",
"DELETE",
"QUERIES",
"SQL",
":",
"query",
"to",
"execute",
"fetchOne",
":",
"bool",
">>",
"cursor",
".",
"fetchone",
"()",
"Return",
":",
"False",
"if",
"an",
"exc... | 347319e421921517bcae7639f524c3c3eb5446e6 | https://github.com/abiiranathan/db2/blob/347319e421921517bcae7639f524c3c3eb5446e6/db2/session.py#L273-L295 | train | Directly execute queries
SQL |
abiiranathan/db2 | db2/session.py | Session.exists | def exists(self, model_class, ID):
'''Check if a record of id==ID exists in table model_class.__name__.lower()'''
assert hasattr(model_class, '_fields'), 'Not a valid model class'
res = self.get(model_class, id=ID, fetchOne=True)
if res:
return True
return False | python | def exists(self, model_class, ID):
'''Check if a record of id==ID exists in table model_class.__name__.lower()'''
assert hasattr(model_class, '_fields'), 'Not a valid model class'
res = self.get(model_class, id=ID, fetchOne=True)
if res:
return True
return False | [
"def",
"exists",
"(",
"self",
",",
"model_class",
",",
"ID",
")",
":",
"assert",
"hasattr",
"(",
"model_class",
",",
"'_fields'",
")",
",",
"'Not a valid model class'",
"res",
"=",
"self",
".",
"get",
"(",
"model_class",
",",
"id",
"=",
"ID",
",",
"fetch... | Check if a record of id==ID exists in table model_class.__name__.lower() | [
"Check",
"if",
"a",
"record",
"of",
"id",
"==",
"ID",
"exists",
"in",
"table",
"model_class",
".",
"__name__",
".",
"lower",
"()"
] | 347319e421921517bcae7639f524c3c3eb5446e6 | https://github.com/abiiranathan/db2/blob/347319e421921517bcae7639f524c3c3eb5446e6/db2/session.py#L297-L304 | train | Check if a record of id == ID exists in table model_class. |
abiiranathan/db2 | db2/session.py | Session.makemigrations | def makemigrations(self):
''' Do database migrations
1. Creates new tables from models
2. Updates columns and columns
Returns True if no exception else raises an unhandled exception
'''
UNCHANGED = []
with Session(self.settings) as conn:
cursor = co... | python | def makemigrations(self):
''' Do database migrations
1. Creates new tables from models
2. Updates columns and columns
Returns True if no exception else raises an unhandled exception
'''
UNCHANGED = []
with Session(self.settings) as conn:
cursor = co... | [
"def",
"makemigrations",
"(",
"self",
")",
":",
"UNCHANGED",
"=",
"[",
"]",
"with",
"Session",
"(",
"self",
".",
"settings",
")",
"as",
"conn",
":",
"cursor",
"=",
"conn",
".",
"cursor",
"(",
")",
"for",
"name",
",",
"model",
"in",
"self",
".",
"mo... | Do database migrations
1. Creates new tables from models
2. Updates columns and columns
Returns True if no exception else raises an unhandled exception | [
"Do",
"database",
"migrations",
"1",
".",
"Creates",
"new",
"tables",
"from",
"models",
"2",
".",
"Updates",
"columns",
"and",
"columns"
] | 347319e421921517bcae7639f524c3c3eb5446e6 | https://github.com/abiiranathan/db2/blob/347319e421921517bcae7639f524c3c3eb5446e6/db2/session.py#L307-L342 | train | Do database migrations for the current version of the tables. Returns True if no exception else raises an unhandled exception. |
abiiranathan/db2 | db2/session.py | Session.UpdateColums | def UpdateColums(self, cursor, field, FieldType, model, columns, UNCHANGED):
'''Updates the columns. Dont call directly
'''
table = model.__name__.lower()
if field not in columns:
n = UNCHANGED.pop()
new_sql = f"ALTER TABLE {table} ADD COLUMN {field} {FieldType} A... | python | def UpdateColums(self, cursor, field, FieldType, model, columns, UNCHANGED):
'''Updates the columns. Dont call directly
'''
table = model.__name__.lower()
if field not in columns:
n = UNCHANGED.pop()
new_sql = f"ALTER TABLE {table} ADD COLUMN {field} {FieldType} A... | [
"def",
"UpdateColums",
"(",
"self",
",",
"cursor",
",",
"field",
",",
"FieldType",
",",
"model",
",",
"columns",
",",
"UNCHANGED",
")",
":",
"table",
"=",
"model",
".",
"__name__",
".",
"lower",
"(",
")",
"if",
"field",
"not",
"in",
"columns",
":",
"... | Updates the columns. Dont call directly | [
"Updates",
"the",
"columns",
".",
"Dont",
"call",
"directly"
] | 347319e421921517bcae7639f524c3c3eb5446e6 | https://github.com/abiiranathan/db2/blob/347319e421921517bcae7639f524c3c3eb5446e6/db2/session.py#L344-L364 | train | Updates the columns. Dont call directly |
IRC-SPHERE/HyperStream | hyperstream/stream/stream_id.py | StreamId.as_raw | def as_raw(self):
"""
Return a representation of this object that can be used with mongoengine Document.objects(__raw__=x)
Example:
>>> stream_id = StreamId(name='test', meta_data=((u'house', u'1'), (u'resident', u'1')))
>>> stream_id.as_raw()
{'stream_id.meta_data': [(u... | python | def as_raw(self):
"""
Return a representation of this object that can be used with mongoengine Document.objects(__raw__=x)
Example:
>>> stream_id = StreamId(name='test', meta_data=((u'house', u'1'), (u'resident', u'1')))
>>> stream_id.as_raw()
{'stream_id.meta_data': [(u... | [
"def",
"as_raw",
"(",
"self",
")",
":",
"return",
"dict",
"(",
"(",
"'stream_id.'",
"+",
"k",
",",
"v",
")",
"for",
"k",
",",
"v",
"in",
"self",
".",
"as_dict",
"(",
")",
".",
"items",
"(",
")",
")"
] | Return a representation of this object that can be used with mongoengine Document.objects(__raw__=x)
Example:
>>> stream_id = StreamId(name='test', meta_data=((u'house', u'1'), (u'resident', u'1')))
>>> stream_id.as_raw()
{'stream_id.meta_data': [(u'house', u'1'), (u'resident', u'1')], ... | [
"Return",
"a",
"representation",
"of",
"this",
"object",
"that",
"can",
"be",
"used",
"with",
"mongoengine",
"Document",
".",
"objects",
"(",
"__raw__",
"=",
"x",
")",
"Example",
":"
] | 98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780 | https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/stream/stream_id.py#L87-L98 | train | Return a representation of this object that can be used with mongoengine Document. objects |
tamasgal/km3pipe | km3pipe/srv.py | srv_event | def srv_event(token, hits, url=RBA_URL):
"""Serve event to RainbowAlga"""
if url is None:
log.error("Please provide a valid RainbowAlga URL.")
return
ws_url = url + '/message'
if isinstance(hits, pd.core.frame.DataFrame):
pos = [tuple(x) for x in hits[['x', 'y', 'z']].values]
... | python | def srv_event(token, hits, url=RBA_URL):
"""Serve event to RainbowAlga"""
if url is None:
log.error("Please provide a valid RainbowAlga URL.")
return
ws_url = url + '/message'
if isinstance(hits, pd.core.frame.DataFrame):
pos = [tuple(x) for x in hits[['x', 'y', 'z']].values]
... | [
"def",
"srv_event",
"(",
"token",
",",
"hits",
",",
"url",
"=",
"RBA_URL",
")",
":",
"if",
"url",
"is",
"None",
":",
"log",
".",
"error",
"(",
"\"Please provide a valid RainbowAlga URL.\"",
")",
"return",
"ws_url",
"=",
"url",
"+",
"'/message'",
"if",
"isi... | Serve event to RainbowAlga | [
"Serve",
"event",
"to",
"RainbowAlga"
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/srv.py#L289-L322 | train | Serve event to RainbowAlga |
tamasgal/km3pipe | km3pipe/srv.py | srv_data | def srv_data(url, token, data, kind):
"""Serve data to RainbowAlga"""
ws = websocket.create_connection(url)
message = {'token': token, 'data': data, 'kind': kind}
ws.send(pd.io.json.dumps(message))
ws.close() | python | def srv_data(url, token, data, kind):
"""Serve data to RainbowAlga"""
ws = websocket.create_connection(url)
message = {'token': token, 'data': data, 'kind': kind}
ws.send(pd.io.json.dumps(message))
ws.close() | [
"def",
"srv_data",
"(",
"url",
",",
"token",
",",
"data",
",",
"kind",
")",
":",
"ws",
"=",
"websocket",
".",
"create_connection",
"(",
"url",
")",
"message",
"=",
"{",
"'token'",
":",
"token",
",",
"'data'",
":",
"data",
",",
"'kind'",
":",
"kind",
... | Serve data to RainbowAlga | [
"Serve",
"data",
"to",
"RainbowAlga"
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/srv.py#L325-L330 | train | Serve data to RainbowAlga |
tamasgal/km3pipe | km3pipe/srv.py | ClientManager.raw_message_to | def raw_message_to(self, token, message):
"""Convert message to JSON and send it to the client with token"""
if token not in self._clients:
log.critical("Client with token '{0}' not found!".format(token))
return
client = self._clients[token]
try:
clien... | python | def raw_message_to(self, token, message):
"""Convert message to JSON and send it to the client with token"""
if token not in self._clients:
log.critical("Client with token '{0}' not found!".format(token))
return
client = self._clients[token]
try:
clien... | [
"def",
"raw_message_to",
"(",
"self",
",",
"token",
",",
"message",
")",
":",
"if",
"token",
"not",
"in",
"self",
".",
"_clients",
":",
"log",
".",
"critical",
"(",
"\"Client with token '{0}' not found!\"",
".",
"format",
"(",
"token",
")",
")",
"return",
... | Convert message to JSON and send it to the client with token | [
"Convert",
"message",
"to",
"JSON",
"and",
"send",
"it",
"to",
"the",
"client",
"with",
"token"
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/srv.py#L114-L125 | train | Convert message to JSON and send it to the client with token |
tamasgal/km3pipe | km3pipe/srv.py | EchoWebSocket.message | def message(self, data, kind="info"):
"""Convert message to json and send it to the clients"""
message = pd.io.json.dumps({'kind': kind, 'data': data})
print("Sent {0} bytes.".format(len(message)))
self.write_message(message) | python | def message(self, data, kind="info"):
"""Convert message to json and send it to the clients"""
message = pd.io.json.dumps({'kind': kind, 'data': data})
print("Sent {0} bytes.".format(len(message)))
self.write_message(message) | [
"def",
"message",
"(",
"self",
",",
"data",
",",
"kind",
"=",
"\"info\"",
")",
":",
"message",
"=",
"pd",
".",
"io",
".",
"json",
".",
"dumps",
"(",
"{",
"'kind'",
":",
"kind",
",",
"'data'",
":",
"data",
"}",
")",
"print",
"(",
"\"Sent {0} bytes.\... | Convert message to json and send it to the clients | [
"Convert",
"message",
"to",
"json",
"and",
"send",
"it",
"to",
"the",
"clients"
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/srv.py#L282-L286 | train | Convert a message to json and send it to the clients |
lexibank/pylexibank | src/pylexibank/db.py | schema | def schema(ds):
"""
Convert the table and column descriptions of a `Dataset` into specifications for the
DB schema.
:param ds:
:return: A pair (tables, reference_tables).
"""
tables, ref_tables = {}, {}
table_lookup = {t.url.string: t for t in ds.tables if ds.get_tabletype(t)}
for t... | python | def schema(ds):
"""
Convert the table and column descriptions of a `Dataset` into specifications for the
DB schema.
:param ds:
:return: A pair (tables, reference_tables).
"""
tables, ref_tables = {}, {}
table_lookup = {t.url.string: t for t in ds.tables if ds.get_tabletype(t)}
for t... | [
"def",
"schema",
"(",
"ds",
")",
":",
"tables",
",",
"ref_tables",
"=",
"{",
"}",
",",
"{",
"}",
"table_lookup",
"=",
"{",
"t",
".",
"url",
".",
"string",
":",
"t",
"for",
"t",
"in",
"ds",
".",
"tables",
"if",
"ds",
".",
"get_tabletype",
"(",
"... | Convert the table and column descriptions of a `Dataset` into specifications for the
DB schema.
:param ds:
:return: A pair (tables, reference_tables). | [
"Convert",
"the",
"table",
"and",
"column",
"descriptions",
"of",
"a",
"Dataset",
"into",
"specifications",
"for",
"the",
"DB",
"schema",
"."
] | c28e7f122f20de1232623dd7003cb5b01535e581 | https://github.com/lexibank/pylexibank/blob/c28e7f122f20de1232623dd7003cb5b01535e581/src/pylexibank/db.py#L141-L238 | train | Convert the table and column descriptions of a Dataset into a pair of tables and reference tables. |
lexibank/pylexibank | src/pylexibank/db.py | Database.create | def create(self, force=False, exists_ok=False):
"""
Creates a db file with the core schema.
:param force: If `True` an existing db file will be overwritten.
"""
if self.fname and self.fname.exists():
if force:
self.drop()
elif exists_ok:
... | python | def create(self, force=False, exists_ok=False):
"""
Creates a db file with the core schema.
:param force: If `True` an existing db file will be overwritten.
"""
if self.fname and self.fname.exists():
if force:
self.drop()
elif exists_ok:
... | [
"def",
"create",
"(",
"self",
",",
"force",
"=",
"False",
",",
"exists_ok",
"=",
"False",
")",
":",
"if",
"self",
".",
"fname",
"and",
"self",
".",
"fname",
".",
"exists",
"(",
")",
":",
"if",
"force",
":",
"self",
".",
"drop",
"(",
")",
"elif",
... | Creates a db file with the core schema.
:param force: If `True` an existing db file will be overwritten. | [
"Creates",
"a",
"db",
"file",
"with",
"the",
"core",
"schema",
"."
] | c28e7f122f20de1232623dd7003cb5b01535e581 | https://github.com/lexibank/pylexibank/blob/c28e7f122f20de1232623dd7003cb5b01535e581/src/pylexibank/db.py#L257-L296 | train | Creates a new db file with the core schema. |
lexibank/pylexibank | src/pylexibank/db.py | Database.load | def load(self, ds, verbose=False):
"""
Load a CLDF dataset into the database.
:param dataset:
:return:
"""
try:
self.fetchone('select ID from dataset')
except sqlite3.OperationalError:
self.create(force=True)
self.unload(ds)
... | python | def load(self, ds, verbose=False):
"""
Load a CLDF dataset into the database.
:param dataset:
:return:
"""
try:
self.fetchone('select ID from dataset')
except sqlite3.OperationalError:
self.create(force=True)
self.unload(ds)
... | [
"def",
"load",
"(",
"self",
",",
"ds",
",",
"verbose",
"=",
"False",
")",
":",
"try",
":",
"self",
".",
"fetchone",
"(",
"'select ID from dataset'",
")",
"except",
"sqlite3",
".",
"OperationalError",
":",
"self",
".",
"create",
"(",
"force",
"=",
"True",... | Load a CLDF dataset into the database.
:param dataset:
:return: | [
"Load",
"a",
"CLDF",
"dataset",
"into",
"the",
"database",
"."
] | c28e7f122f20de1232623dd7003cb5b01535e581 | https://github.com/lexibank/pylexibank/blob/c28e7f122f20de1232623dd7003cb5b01535e581/src/pylexibank/db.py#L348-L459 | train | Load a CLDF dataset into the database. |
vslutov/turingmarkov | turingmarkov/markov.py | Algorithm.add_rule | def add_rule(self, rule):
"""Supported rules: `a -> b` and `a => b` (terminal rule)."""
parsed_rule = None
if rule.count('->') == 1 and rule.count('=>') == 0:
parsed_rule = tuple(''.join(part.split()) for part in rule.split('->')) + (0,)
elif rule.count('->') == 0 and rule.c... | python | def add_rule(self, rule):
"""Supported rules: `a -> b` and `a => b` (terminal rule)."""
parsed_rule = None
if rule.count('->') == 1 and rule.count('=>') == 0:
parsed_rule = tuple(''.join(part.split()) for part in rule.split('->')) + (0,)
elif rule.count('->') == 0 and rule.c... | [
"def",
"add_rule",
"(",
"self",
",",
"rule",
")",
":",
"parsed_rule",
"=",
"None",
"if",
"rule",
".",
"count",
"(",
"'->'",
")",
"==",
"1",
"and",
"rule",
".",
"count",
"(",
"'=>'",
")",
"==",
"0",
":",
"parsed_rule",
"=",
"tuple",
"(",
"''",
"."... | Supported rules: `a -> b` and `a => b` (terminal rule). | [
"Supported",
"rules",
":",
"a",
"-",
">",
"b",
"and",
"a",
"=",
">",
"b",
"(",
"terminal",
"rule",
")",
"."
] | 63e2ba255d7d0d868cbc4bf3e568b1c1bbcf38ce | https://github.com/vslutov/turingmarkov/blob/63e2ba255d7d0d868cbc4bf3e568b1c1bbcf38ce/turingmarkov/markov.py#L33-L45 | train | Add a rule to the list of rules. |
vslutov/turingmarkov | turingmarkov/markov.py | Algorithm.execute_once | def execute_once(self, string):
"""Execute only one rule."""
for rule in self.rules:
if rule[0] in string:
pos = string.find(rule[0])
self.last_rule = rule
return string[:pos] + rule[1] + string[pos+len(rule[0]):]
self.last_rule = None
... | python | def execute_once(self, string):
"""Execute only one rule."""
for rule in self.rules:
if rule[0] in string:
pos = string.find(rule[0])
self.last_rule = rule
return string[:pos] + rule[1] + string[pos+len(rule[0]):]
self.last_rule = None
... | [
"def",
"execute_once",
"(",
"self",
",",
"string",
")",
":",
"for",
"rule",
"in",
"self",
".",
"rules",
":",
"if",
"rule",
"[",
"0",
"]",
"in",
"string",
":",
"pos",
"=",
"string",
".",
"find",
"(",
"rule",
"[",
"0",
"]",
")",
"self",
".",
"las... | Execute only one rule. | [
"Execute",
"only",
"one",
"rule",
"."
] | 63e2ba255d7d0d868cbc4bf3e568b1c1bbcf38ce | https://github.com/vslutov/turingmarkov/blob/63e2ba255d7d0d868cbc4bf3e568b1c1bbcf38ce/turingmarkov/markov.py#L51-L59 | train | Execute only one rule. |
vslutov/turingmarkov | turingmarkov/markov.py | Algorithm.execute | def execute(self, string, max_tacts=None):
"""Execute algorithm (if max_times = None, there can be forever loop)."""
counter = 0
self.last_rule = None
while True:
string = self.execute_once(string)
if self.last_rule is None or self.last_rule[2]:
b... | python | def execute(self, string, max_tacts=None):
"""Execute algorithm (if max_times = None, there can be forever loop)."""
counter = 0
self.last_rule = None
while True:
string = self.execute_once(string)
if self.last_rule is None or self.last_rule[2]:
b... | [
"def",
"execute",
"(",
"self",
",",
"string",
",",
"max_tacts",
"=",
"None",
")",
":",
"counter",
"=",
"0",
"self",
".",
"last_rule",
"=",
"None",
"while",
"True",
":",
"string",
"=",
"self",
".",
"execute_once",
"(",
"string",
")",
"if",
"self",
"."... | Execute algorithm (if max_times = None, there can be forever loop). | [
"Execute",
"algorithm",
"(",
"if",
"max_times",
"=",
"None",
"there",
"can",
"be",
"forever",
"loop",
")",
"."
] | 63e2ba255d7d0d868cbc4bf3e568b1c1bbcf38ce | https://github.com/vslutov/turingmarkov/blob/63e2ba255d7d0d868cbc4bf3e568b1c1bbcf38ce/turingmarkov/markov.py#L61-L74 | train | Execute algorithm. |
vslutov/turingmarkov | turingmarkov/markov.py | Algorithm.compile | def compile(self):
"""Return python code for create and execute algo."""
result = TEMPLATE
for rule in self.rules:
if rule[2]:
arrow = '=>'
else:
arrow = '->'
repr_rule = repr(rule[0] + arrow + rule[1])
result += "... | python | def compile(self):
"""Return python code for create and execute algo."""
result = TEMPLATE
for rule in self.rules:
if rule[2]:
arrow = '=>'
else:
arrow = '->'
repr_rule = repr(rule[0] + arrow + rule[1])
result += "... | [
"def",
"compile",
"(",
"self",
")",
":",
"result",
"=",
"TEMPLATE",
"for",
"rule",
"in",
"self",
".",
"rules",
":",
"if",
"rule",
"[",
"2",
"]",
":",
"arrow",
"=",
"'=>'",
"else",
":",
"arrow",
"=",
"'->'",
"repr_rule",
"=",
"repr",
"(",
"rule",
... | Return python code for create and execute algo. | [
"Return",
"python",
"code",
"for",
"create",
"and",
"execute",
"algo",
"."
] | 63e2ba255d7d0d868cbc4bf3e568b1c1bbcf38ce | https://github.com/vslutov/turingmarkov/blob/63e2ba255d7d0d868cbc4bf3e568b1c1bbcf38ce/turingmarkov/markov.py#L76-L91 | train | Return python code for create and execute algo. |
wtsi-hgi/consul-lock | consullock/_logging.py | create_logger | def create_logger(name: str) -> Logger:
"""
Creates a logger with the given name.
:param name: name of the logger (gets prefixed with the package name)
:return: the created logger
"""
logger = logging.getLogger(f"{PACKAGE_NAME}.{name}")
logger.addHandler(StreamHandler())
return logger | python | def create_logger(name: str) -> Logger:
"""
Creates a logger with the given name.
:param name: name of the logger (gets prefixed with the package name)
:return: the created logger
"""
logger = logging.getLogger(f"{PACKAGE_NAME}.{name}")
logger.addHandler(StreamHandler())
return logger | [
"def",
"create_logger",
"(",
"name",
":",
"str",
")",
"->",
"Logger",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"f\"{PACKAGE_NAME}.{name}\"",
")",
"logger",
".",
"addHandler",
"(",
"StreamHandler",
"(",
")",
")",
"return",
"logger"
] | Creates a logger with the given name.
:param name: name of the logger (gets prefixed with the package name)
:return: the created logger | [
"Creates",
"a",
"logger",
"with",
"the",
"given",
"name",
".",
":",
"param",
"name",
":",
"name",
"of",
"the",
"logger",
"(",
"gets",
"prefixed",
"with",
"the",
"package",
"name",
")",
":",
"return",
":",
"the",
"created",
"logger"
] | deb07ab41dabbb49f4d0bbc062bc3b4b6e5d71b2 | https://github.com/wtsi-hgi/consul-lock/blob/deb07ab41dabbb49f4d0bbc062bc3b4b6e5d71b2/consullock/_logging.py#L6-L14 | train | Creates a logger with the given name. |
RazerM/parver | src/parver/_helpers.py | kwonly_args | def kwonly_args(kws, required, withdefaults=(), leftovers=False):
"""
Based on the snippet by Eric Snow
http://code.activestate.com/recipes/577940
SPDX-License-Identifier: MIT
"""
if hasattr(withdefaults, 'items'):
# allows for OrderedDict to be passed
withdefaults = withdefaul... | python | def kwonly_args(kws, required, withdefaults=(), leftovers=False):
"""
Based on the snippet by Eric Snow
http://code.activestate.com/recipes/577940
SPDX-License-Identifier: MIT
"""
if hasattr(withdefaults, 'items'):
# allows for OrderedDict to be passed
withdefaults = withdefaul... | [
"def",
"kwonly_args",
"(",
"kws",
",",
"required",
",",
"withdefaults",
"=",
"(",
")",
",",
"leftovers",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"withdefaults",
",",
"'items'",
")",
":",
"# allows for OrderedDict to be passed",
"withdefaults",
"=",
"with... | Based on the snippet by Eric Snow
http://code.activestate.com/recipes/577940
SPDX-License-Identifier: MIT | [
"Based",
"on",
"the",
"snippet",
"by",
"Eric",
"Snow",
"http",
":",
"//",
"code",
".",
"activestate",
".",
"com",
"/",
"recipes",
"/",
"577940"
] | e5133085ac8c4619e7c392223a2e78ba394c2a10 | https://github.com/RazerM/parver/blob/e5133085ac8c4619e7c392223a2e78ba394c2a10/src/parver/_helpers.py#L123-L169 | train | Return a list of keyword - only arguments for a MIT
. |
IRC-SPHERE/HyperStream | hyperstream/factor/factor.py | Factor.execute | def execute(self, time_interval):
"""
Execute the factor over the given time interval
:param time_interval:
:return:
"""
logging.info('{} with sink node {} running from {} to {}'.format(
self.tool.__class__.__name__, self.sink.node_id, time_interval.start, ti... | python | def execute(self, time_interval):
"""
Execute the factor over the given time interval
:param time_interval:
:return:
"""
logging.info('{} with sink node {} running from {} to {}'.format(
self.tool.__class__.__name__, self.sink.node_id, time_interval.start, ti... | [
"def",
"execute",
"(",
"self",
",",
"time_interval",
")",
":",
"logging",
".",
"info",
"(",
"'{} with sink node {} running from {} to {}'",
".",
"format",
"(",
"self",
".",
"tool",
".",
"__class__",
".",
"__name__",
",",
"self",
".",
"sink",
".",
"node_id",
... | Execute the factor over the given time interval
:param time_interval:
:return: | [
"Execute",
"the",
"factor",
"over",
"the",
"given",
"time",
"interval"
] | 98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780 | https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/factor/factor.py#L93-L202 | train | Execute the factor over the given time interval. |
IRC-SPHERE/HyperStream | hyperstream/factor/factor.py | Factor.get_sources | def get_sources(self, plate, plate_value, sources=None):
"""
Gets the source streams for a given plate value on a plate.
Also populates with source streams that are valid for the parent plates of this plate,
with the appropriate meta-data for the parent plate.
:param plate: The ... | python | def get_sources(self, plate, plate_value, sources=None):
"""
Gets the source streams for a given plate value on a plate.
Also populates with source streams that are valid for the parent plates of this plate,
with the appropriate meta-data for the parent plate.
:param plate: The ... | [
"def",
"get_sources",
"(",
"self",
",",
"plate",
",",
"plate_value",
",",
"sources",
"=",
"None",
")",
":",
"if",
"sources",
"is",
"None",
":",
"sources",
"=",
"[",
"]",
"if",
"self",
".",
"sources",
":",
"for",
"si",
",",
"source",
"in",
"enumerate"... | Gets the source streams for a given plate value on a plate.
Also populates with source streams that are valid for the parent plates of this plate,
with the appropriate meta-data for the parent plate.
:param plate: The plate being operated on
:param plate_value: The specific plate value ... | [
"Gets",
"the",
"source",
"streams",
"for",
"a",
"given",
"plate",
"value",
"on",
"a",
"plate",
".",
"Also",
"populates",
"with",
"source",
"streams",
"that",
"are",
"valid",
"for",
"the",
"parent",
"plates",
"of",
"this",
"plate",
"with",
"the",
"appropria... | 98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780 | https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/factor/factor.py#L204-L240 | train | Gets the source streams for a given plate value on a given plate. |
IRC-SPHERE/HyperStream | hyperstream/factor/factor.py | Factor.get_global_sources | def get_global_sources(self):
"""
Gets streams that live outside of the plates
:return: Global streams
"""
sources = []
if self.sources:
for source in self.sources:
if None in source.streams:
sources.append(source.streams[N... | python | def get_global_sources(self):
"""
Gets streams that live outside of the plates
:return: Global streams
"""
sources = []
if self.sources:
for source in self.sources:
if None in source.streams:
sources.append(source.streams[N... | [
"def",
"get_global_sources",
"(",
"self",
")",
":",
"sources",
"=",
"[",
"]",
"if",
"self",
".",
"sources",
":",
"for",
"source",
"in",
"self",
".",
"sources",
":",
"if",
"None",
"in",
"source",
".",
"streams",
":",
"sources",
".",
"append",
"(",
"so... | Gets streams that live outside of the plates
:return: Global streams | [
"Gets",
"streams",
"that",
"live",
"outside",
"of",
"the",
"plates"
] | 98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780 | https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/factor/factor.py#L242-L253 | train | Gets streams that live outside of the plates
|
IRC-SPHERE/HyperStream | hyperstream/factor/factor.py | Factor.get_alignment_stream | def get_alignment_stream(self, plate=None, plate_value=None):
"""
Gets the alignment stream for a particular plate value
:param plate: The plate on which the alignment node lives
:param plate_value: The plate value to select the stream from the node
:return: The alignment stream... | python | def get_alignment_stream(self, plate=None, plate_value=None):
"""
Gets the alignment stream for a particular plate value
:param plate: The plate on which the alignment node lives
:param plate_value: The plate value to select the stream from the node
:return: The alignment stream... | [
"def",
"get_alignment_stream",
"(",
"self",
",",
"plate",
"=",
"None",
",",
"plate_value",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"alignment_node",
":",
"return",
"None",
"if",
"plate",
"is",
"not",
"None",
"or",
"plate_value",
"is",
"not",
"No... | Gets the alignment stream for a particular plate value
:param plate: The plate on which the alignment node lives
:param plate_value: The plate value to select the stream from the node
:return: The alignment stream | [
"Gets",
"the",
"alignment",
"stream",
"for",
"a",
"particular",
"plate",
"value"
] | 98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780 | https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/factor/factor.py#L255-L268 | train | Gets the alignment stream for a particular plate value |
IRC-SPHERE/HyperStream | hyperstream/factor/factor.py | MultiOutputFactor.execute | def execute(self, time_interval):
"""
Execute the factor over the given time interval. Note that this is normally done by the workflow,
but can also be done on the factor directly
:param time_interval: The time interval
:return: self (for chaining)
"""
logging.in... | python | def execute(self, time_interval):
"""
Execute the factor over the given time interval. Note that this is normally done by the workflow,
but can also be done on the factor directly
:param time_interval: The time interval
:return: self (for chaining)
"""
logging.in... | [
"def",
"execute",
"(",
"self",
",",
"time_interval",
")",
":",
"logging",
".",
"info",
"(",
"'{} running from {} to {}'",
".",
"format",
"(",
"self",
".",
"tool",
".",
"__class__",
".",
"__name__",
",",
"time_interval",
".",
"start",
",",
"time_interval",
".... | Execute the factor over the given time interval. Note that this is normally done by the workflow,
but can also be done on the factor directly
:param time_interval: The time interval
:return: self (for chaining) | [
"Execute",
"the",
"factor",
"over",
"the",
"given",
"time",
"interval",
".",
"Note",
"that",
"this",
"is",
"normally",
"done",
"by",
"the",
"workflow",
"but",
"can",
"also",
"be",
"done",
"on",
"the",
"factor",
"directly"
] | 98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780 | https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/factor/factor.py#L324-L388 | train | Execute the factor over the given time interval. |
IRC-SPHERE/HyperStream | hyperstream/factor/factor.py | MultiOutputFactor.get_splitting_stream | def get_splitting_stream(self, input_plate_value):
"""
Get the splitting stream
:param input_plate_value: The input plate value
:return: The splitting stream
"""
if not self.splitting_node:
return None
if len(self.splitting_node.plates) == 0:
... | python | def get_splitting_stream(self, input_plate_value):
"""
Get the splitting stream
:param input_plate_value: The input plate value
:return: The splitting stream
"""
if not self.splitting_node:
return None
if len(self.splitting_node.plates) == 0:
... | [
"def",
"get_splitting_stream",
"(",
"self",
",",
"input_plate_value",
")",
":",
"if",
"not",
"self",
".",
"splitting_node",
":",
"return",
"None",
"if",
"len",
"(",
"self",
".",
"splitting_node",
".",
"plates",
")",
"==",
"0",
":",
"# Use global plate value",
... | Get the splitting stream
:param input_plate_value: The input plate value
:return: The splitting stream | [
"Get",
"the",
"splitting",
"stream"
] | 98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780 | https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/factor/factor.py#L390-L436 | train | Get the splitting stream for the given input plate value. |
IRC-SPHERE/HyperStream | hyperstream/factor/factor.py | MultiOutputFactor.update_computed_intervals | def update_computed_intervals(sinks, time_interval):
"""
Update computed intervals
:param sinks: The streams to update
:param time_interval: The time interval
"""
for sink in sinks:
sink.calculated_intervals += time_interval
required_intervals = T... | python | def update_computed_intervals(sinks, time_interval):
"""
Update computed intervals
:param sinks: The streams to update
:param time_interval: The time interval
"""
for sink in sinks:
sink.calculated_intervals += time_interval
required_intervals = T... | [
"def",
"update_computed_intervals",
"(",
"sinks",
",",
"time_interval",
")",
":",
"for",
"sink",
"in",
"sinks",
":",
"sink",
".",
"calculated_intervals",
"+=",
"time_interval",
"required_intervals",
"=",
"TimeIntervals",
"(",
"[",
"time_interval",
"]",
")",
"-",
... | Update computed intervals
:param sinks: The streams to update
:param time_interval: The time interval | [
"Update",
"computed",
"intervals"
] | 98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780 | https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/factor/factor.py#L439-L451 | train | Update the computed intervals of the given time interval. |
IRC-SPHERE/HyperStream | hyperstream/factor/factor.py | NodeCreationFactor.execute | def execute(self, time_interval):
"""
Execute the factor over the given time interval. Note that this is normally done by the workflow,
but can also be done on the factor directly
:param time_interval: The time interval
:return: self (for chaining)
"""
logging.in... | python | def execute(self, time_interval):
"""
Execute the factor over the given time interval. Note that this is normally done by the workflow,
but can also be done on the factor directly
:param time_interval: The time interval
:return: self (for chaining)
"""
logging.in... | [
"def",
"execute",
"(",
"self",
",",
"time_interval",
")",
":",
"logging",
".",
"info",
"(",
"'{} running from {} to {}'",
".",
"format",
"(",
"self",
".",
"tool",
".",
"__class__",
".",
"__name__",
",",
"time_interval",
".",
"start",
",",
"time_interval",
".... | Execute the factor over the given time interval. Note that this is normally done by the workflow,
but can also be done on the factor directly
:param time_interval: The time interval
:return: self (for chaining) | [
"Execute",
"the",
"factor",
"over",
"the",
"given",
"time",
"interval",
".",
"Note",
"that",
"this",
"is",
"normally",
"done",
"by",
"the",
"workflow",
"but",
"can",
"also",
"be",
"done",
"on",
"the",
"factor",
"directly"
] | 98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780 | https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/factor/factor.py#L502-L577 | train | Execute the tool over the given time interval. |
lexibank/pylexibank | src/pylexibank/util.py | getEvoBibAsBibtex | def getEvoBibAsBibtex(*keys, **kw):
"""Download bibtex format and parse it from EvoBib"""
res = []
for key in keys:
bib = get_url(
"http://bibliography.lingpy.org/raw.php?key=" + key,
log=kw.get('log')).text
try:
res.append('@' + bib.split('@')[1].split('<... | python | def getEvoBibAsBibtex(*keys, **kw):
"""Download bibtex format and parse it from EvoBib"""
res = []
for key in keys:
bib = get_url(
"http://bibliography.lingpy.org/raw.php?key=" + key,
log=kw.get('log')).text
try:
res.append('@' + bib.split('@')[1].split('<... | [
"def",
"getEvoBibAsBibtex",
"(",
"*",
"keys",
",",
"*",
"*",
"kw",
")",
":",
"res",
"=",
"[",
"]",
"for",
"key",
"in",
"keys",
":",
"bib",
"=",
"get_url",
"(",
"\"http://bibliography.lingpy.org/raw.php?key=\"",
"+",
"key",
",",
"log",
"=",
"kw",
".",
"... | Download bibtex format and parse it from EvoBib | [
"Download",
"bibtex",
"format",
"and",
"parse",
"it",
"from",
"EvoBib"
] | c28e7f122f20de1232623dd7003cb5b01535e581 | https://github.com/lexibank/pylexibank/blob/c28e7f122f20de1232623dd7003cb5b01535e581/src/pylexibank/util.py#L233-L244 | train | Download bibtex format and parse it from EvoBib |
lexibank/pylexibank | src/pylexibank/util.py | DataDir.download_and_unpack | def download_and_unpack(self, url, *paths, **kw):
"""
Download a zipfile and immediately unpack selected content.
:param url:
:param paths:
:param kw:
:return:
"""
with self.temp_download(url, 'ds.zip', log=kw.pop('log', None)) as zipp:
with T... | python | def download_and_unpack(self, url, *paths, **kw):
"""
Download a zipfile and immediately unpack selected content.
:param url:
:param paths:
:param kw:
:return:
"""
with self.temp_download(url, 'ds.zip', log=kw.pop('log', None)) as zipp:
with T... | [
"def",
"download_and_unpack",
"(",
"self",
",",
"url",
",",
"*",
"paths",
",",
"*",
"*",
"kw",
")",
":",
"with",
"self",
".",
"temp_download",
"(",
"url",
",",
"'ds.zip'",
",",
"log",
"=",
"kw",
".",
"pop",
"(",
"'log'",
",",
"None",
")",
")",
"a... | Download a zipfile and immediately unpack selected content.
:param url:
:param paths:
:param kw:
:return: | [
"Download",
"a",
"zipfile",
"and",
"immediately",
"unpack",
"selected",
"content",
"."
] | c28e7f122f20de1232623dd7003cb5b01535e581 | https://github.com/lexibank/pylexibank/blob/c28e7f122f20de1232623dd7003cb5b01535e581/src/pylexibank/util.py#L216-L230 | train | Download a zipfile and immediately unpack selected content. |
PrefPy/prefpy | prefpy/mechanismMcmc.py | MechanismMcmc.getWinners | def getWinners(self, profile, sampleFileName = None):
"""
Returns a list of all winning candidates when we use MCMC approximation to compute Bayesian
utilities for an election profile.
:ivar Profile profile: A Profile object that represents an election profile.
:ivar str... | python | def getWinners(self, profile, sampleFileName = None):
"""
Returns a list of all winning candidates when we use MCMC approximation to compute Bayesian
utilities for an election profile.
:ivar Profile profile: A Profile object that represents an election profile.
:ivar str... | [
"def",
"getWinners",
"(",
"self",
",",
"profile",
",",
"sampleFileName",
"=",
"None",
")",
":",
"if",
"sampleFileName",
"!=",
"None",
":",
"candScores",
"=",
"self",
".",
"getCandScoresMapFromSamplesFile",
"(",
"profile",
",",
"sampleFileName",
")",
"else",
":... | Returns a list of all winning candidates when we use MCMC approximation to compute Bayesian
utilities for an election profile.
:ivar Profile profile: A Profile object that represents an election profile.
:ivar str sampleFileName: An optional argument for the name of the input file conta... | [
"Returns",
"a",
"list",
"of",
"all",
"winning",
"candidates",
"when",
"we",
"use",
"MCMC",
"approximation",
"to",
"compute",
"Bayesian",
"utilities",
"for",
"an",
"election",
"profile",
".",
":",
"ivar",
"Profile",
"profile",
":",
"A",
"Profile",
"object",
"... | f395ba3782f05684fa5de0cece387a6da9391d02 | https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mechanismMcmc.py#L18-L46 | train | Returns a list of all winning candidates when we use MCMC approximation to compute Bayesian
utilities for an election profile. |
PrefPy/prefpy | prefpy/mechanismMcmc.py | MechanismMcmc.getRanking | def getRanking(self, profile, sampleFileName = None):
"""
Returns a list of lists that orders all candidates in tiers from best to worst when we use
MCMC approximation to compute Bayesian utilities for an election profile.
:ivar Profile profile: A Profile object that represents an elec... | python | def getRanking(self, profile, sampleFileName = None):
"""
Returns a list of lists that orders all candidates in tiers from best to worst when we use
MCMC approximation to compute Bayesian utilities for an election profile.
:ivar Profile profile: A Profile object that represents an elec... | [
"def",
"getRanking",
"(",
"self",
",",
"profile",
",",
"sampleFileName",
"=",
"None",
")",
":",
"if",
"sampleFileName",
"!=",
"None",
":",
"candScoresMap",
"=",
"self",
".",
"getCandScoresMapFromSamplesFile",
"(",
"profile",
",",
"sampleFileName",
")",
"else",
... | Returns a list of lists that orders all candidates in tiers from best to worst when we use
MCMC approximation to compute Bayesian utilities for an election profile.
:ivar Profile profile: A Profile object that represents an election profile.
:ivar str sampleFileName: An optional argument for t... | [
"Returns",
"a",
"list",
"of",
"lists",
"that",
"orders",
"all",
"candidates",
"in",
"tiers",
"from",
"best",
"to",
"worst",
"when",
"we",
"use",
"MCMC",
"approximation",
"to",
"compute",
"Bayesian",
"utilities",
"for",
"an",
"election",
"profile",
"."
] | f395ba3782f05684fa5de0cece387a6da9391d02 | https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mechanismMcmc.py#L48-L84 | train | Returns a list of lists that orders all candidates in tiers from best to worst when we use
MCMC approximation to compute Bayesian utilities for an election profile. |
PrefPy/prefpy | prefpy/mechanismMcmc.py | MechanismMcmc.getCandScoresMap | def getCandScoresMap(self, profile):
"""
Returns a dictonary that associates the integer representation of each candidate with the
Bayesian utilities we approximate from our sampling of the profile.
:ivar Profile profile: A Profile object that represents an election profile.
""... | python | def getCandScoresMap(self, profile):
"""
Returns a dictonary that associates the integer representation of each candidate with the
Bayesian utilities we approximate from our sampling of the profile.
:ivar Profile profile: A Profile object that represents an election profile.
""... | [
"def",
"getCandScoresMap",
"(",
"self",
",",
"profile",
")",
":",
"wmg",
"=",
"profile",
".",
"getWmg",
"(",
"True",
")",
"V",
"=",
"self",
".",
"getInitialSample",
"(",
"wmg",
")",
"utilities",
"=",
"dict",
"(",
")",
"for",
"cand",
"in",
"profile",
... | Returns a dictonary that associates the integer representation of each candidate with the
Bayesian utilities we approximate from our sampling of the profile.
:ivar Profile profile: A Profile object that represents an election profile. | [
"Returns",
"a",
"dictonary",
"that",
"associates",
"the",
"integer",
"representation",
"of",
"each",
"candidate",
"with",
"the",
"Bayesian",
"utilities",
"we",
"approximate",
"from",
"our",
"sampling",
"of",
"the",
"profile",
"."
] | f395ba3782f05684fa5de0cece387a6da9391d02 | https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mechanismMcmc.py#L86-L113 | train | Returns a dictonary that associates the integer representation of each candidate with the integer representation of each candidate with the bayesian utilities we approximate from our sampling of the profile. |
PrefPy/prefpy | prefpy/mechanismMcmc.py | MechanismMcmc.getWinnersBruteForce | def getWinnersBruteForce(self, profile):
"""
Returns a list of all winning candidates when we use brute force to compute Bayesian
utilities for an election profile. This function assumes that
getCandScoresMapBruteForce(profile) is implemented for the child MechanismMcmc class.
... | python | def getWinnersBruteForce(self, profile):
"""
Returns a list of all winning candidates when we use brute force to compute Bayesian
utilities for an election profile. This function assumes that
getCandScoresMapBruteForce(profile) is implemented for the child MechanismMcmc class.
... | [
"def",
"getWinnersBruteForce",
"(",
"self",
",",
"profile",
")",
":",
"candScoresMapBruteForce",
"=",
"self",
".",
"getCandScoresMapBruteForce",
"(",
"profile",
")",
"# Check whether the winning candidate is the candidate that maximizes the score or ",
"# minimizes it.",
"if",
... | Returns a list of all winning candidates when we use brute force to compute Bayesian
utilities for an election profile. This function assumes that
getCandScoresMapBruteForce(profile) is implemented for the child MechanismMcmc class.
:ivar Profile profile: A Profile object that represen... | [
"Returns",
"a",
"list",
"of",
"all",
"winning",
"candidates",
"when",
"we",
"use",
"brute",
"force",
"to",
"compute",
"Bayesian",
"utilities",
"for",
"an",
"election",
"profile",
".",
"This",
"function",
"assumes",
"that",
"getCandScoresMapBruteForce",
"(",
"pro... | f395ba3782f05684fa5de0cece387a6da9391d02 | https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mechanismMcmc.py#L115-L138 | train | Returns a list of all winning candidates when we use brute force to compute Bayesian
utilities for an election profile. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.