partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | TaskStore.partition | Partitions all tasks into groups of tasks. A group is
represented by a task_store object that indexes a sub-
set of tasks. | ocupy/parallel.py | def partition(self):
"""Partitions all tasks into groups of tasks. A group is
represented by a task_store object that indexes a sub-
set of tasks."""
step = int(math.ceil(self.num_tasks / float(self.partitions)))
if self.indices == None:
slice_ind = list(range(0... | def partition(self):
"""Partitions all tasks into groups of tasks. A group is
represented by a task_store object that indexes a sub-
set of tasks."""
step = int(math.ceil(self.num_tasks / float(self.partitions)))
if self.indices == None:
slice_ind = list(range(0... | [
"Partitions",
"all",
"tasks",
"into",
"groups",
"of",
"tasks",
".",
"A",
"group",
"is",
"represented",
"by",
"a",
"task_store",
"object",
"that",
"indexes",
"a",
"sub",
"-",
"set",
"of",
"tasks",
"."
] | nwilming/ocupy | python | https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/parallel.py#L228-L245 | [
"def",
"partition",
"(",
"self",
")",
":",
"step",
"=",
"int",
"(",
"math",
".",
"ceil",
"(",
"self",
".",
"num_tasks",
"/",
"float",
"(",
"self",
".",
"partitions",
")",
")",
")",
"if",
"self",
".",
"indices",
"==",
"None",
":",
"slice_ind",
"=",
... | a0bd64f822576feaa502939d6bafd1183b237d16 |
train | fit3d | Fits a 3D distribution with splines.
Input:
samples: Array
Array of samples from a probability distribution
e_x: Array
Edges that define the events in the probability
distribution along the x direction. For example,
e_x[0] < samples[0] <= e_x[1] pic... | ocupy/spline_base.py | def fit3d(samples, e_x, e_y, e_z, remove_zeros = False, **kw):
"""Fits a 3D distribution with splines.
Input:
samples: Array
Array of samples from a probability distribution
e_x: Array
Edges that define the events in the probability
distribution along the x ... | def fit3d(samples, e_x, e_y, e_z, remove_zeros = False, **kw):
"""Fits a 3D distribution with splines.
Input:
samples: Array
Array of samples from a probability distribution
e_x: Array
Edges that define the events in the probability
distribution along the x ... | [
"Fits",
"a",
"3D",
"distribution",
"with",
"splines",
"."
] | nwilming/ocupy | python | https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/spline_base.py#L9-L48 | [
"def",
"fit3d",
"(",
"samples",
",",
"e_x",
",",
"e_y",
",",
"e_z",
",",
"remove_zeros",
"=",
"False",
",",
"*",
"*",
"kw",
")",
":",
"height",
",",
"width",
",",
"depth",
"=",
"len",
"(",
"e_y",
")",
"-",
"1",
",",
"len",
"(",
"e_x",
")",
"-... | a0bd64f822576feaa502939d6bafd1183b237d16 |
train | fit2d | Fits a 2D distribution with splines.
Input:
samples: Matrix or list of arrays
If matrix, it must be of size Nx2, where N is the number of
observations. If list, it must contain two arrays of length
N.
e_x: Array
Edges that define the events in the pr... | ocupy/spline_base.py | def fit2d(samples,e_x, e_y, remove_zeros = False, p_est = None, **kw):
"""Fits a 2D distribution with splines.
Input:
samples: Matrix or list of arrays
If matrix, it must be of size Nx2, where N is the number of
observations. If list, it must contain two arrays of length
... | def fit2d(samples,e_x, e_y, remove_zeros = False, p_est = None, **kw):
"""Fits a 2D distribution with splines.
Input:
samples: Matrix or list of arrays
If matrix, it must be of size Nx2, where N is the number of
observations. If list, it must contain two arrays of length
... | [
"Fits",
"a",
"2D",
"distribution",
"with",
"splines",
"."
] | nwilming/ocupy | python | https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/spline_base.py#L51-L103 | [
"def",
"fit2d",
"(",
"samples",
",",
"e_x",
",",
"e_y",
",",
"remove_zeros",
"=",
"False",
",",
"p_est",
"=",
"None",
",",
"*",
"*",
"kw",
")",
":",
"if",
"p_est",
"is",
"None",
":",
"height",
"=",
"len",
"(",
"e_y",
")",
"-",
"1",
"width",
"="... | a0bd64f822576feaa502939d6bafd1183b237d16 |
train | fit1d | Fits a 1D distribution with splines.
Input:
samples: Array
Array of samples from a probability distribution
e: Array
Edges that define the events in the probability
distribution. For example, e[0] < x <= e[1] is
the range of values that are associate... | ocupy/spline_base.py | def fit1d(samples, e, remove_zeros = False, **kw):
"""Fits a 1D distribution with splines.
Input:
samples: Array
Array of samples from a probability distribution
e: Array
Edges that define the events in the probability
distribution. For example, e[0] < x <= ... | def fit1d(samples, e, remove_zeros = False, **kw):
"""Fits a 1D distribution with splines.
Input:
samples: Array
Array of samples from a probability distribution
e: Array
Edges that define the events in the probability
distribution. For example, e[0] < x <= ... | [
"Fits",
"a",
"1D",
"distribution",
"with",
"splines",
"."
] | nwilming/ocupy | python | https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/spline_base.py#L105-L137 | [
"def",
"fit1d",
"(",
"samples",
",",
"e",
",",
"remove_zeros",
"=",
"False",
",",
"*",
"*",
"kw",
")",
":",
"samples",
"=",
"samples",
"[",
"~",
"np",
".",
"isnan",
"(",
"samples",
")",
"]",
"length",
"=",
"len",
"(",
"e",
")",
"-",
"1",
"hist"... | a0bd64f822576feaa502939d6bafd1183b237d16 |
train | knots_from_marginal | Determines knot placement based on a marginal distribution.
It places knots such that each knot covers the same amount
of probability mass. Two of the knots are reserved for the
borders which are treated seperatly. For example, a uniform
distribution with 5 knots will cause the knots to be equally
... | ocupy/spline_base.py | def knots_from_marginal(marginal, nr_knots, spline_order):
"""
Determines knot placement based on a marginal distribution.
It places knots such that each knot covers the same amount
of probability mass. Two of the knots are reserved for the
borders which are treated seperatly. For example, a uni... | def knots_from_marginal(marginal, nr_knots, spline_order):
"""
Determines knot placement based on a marginal distribution.
It places knots such that each knot covers the same amount
of probability mass. Two of the knots are reserved for the
borders which are treated seperatly. For example, a uni... | [
"Determines",
"knot",
"placement",
"based",
"on",
"a",
"marginal",
"distribution",
"."
] | nwilming/ocupy | python | https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/spline_base.py#L139-L168 | [
"def",
"knots_from_marginal",
"(",
"marginal",
",",
"nr_knots",
",",
"spline_order",
")",
":",
"cumsum",
"=",
"np",
".",
"cumsum",
"(",
"marginal",
")",
"cumsum",
"=",
"cumsum",
"/",
"cumsum",
".",
"max",
"(",
")",
"borders",
"=",
"np",
".",
"linspace",
... | a0bd64f822576feaa502939d6bafd1183b237d16 |
train | spline_base1d | Computes a 1D spline basis
Input:
length: int
length of each basis
nr_knots: int
Number of knots, i.e. number of basis functions.
spline_order: int
Order of the splines.
marginal: array, optional
Estimate of the marginal distribut... | ocupy/spline_base.py | def spline_base1d(length, nr_knots = 20, spline_order = 5, marginal = None):
"""Computes a 1D spline basis
Input:
length: int
length of each basis
nr_knots: int
Number of knots, i.e. number of basis functions.
spline_order: int
Order of the splin... | def spline_base1d(length, nr_knots = 20, spline_order = 5, marginal = None):
"""Computes a 1D spline basis
Input:
length: int
length of each basis
nr_knots: int
Number of knots, i.e. number of basis functions.
spline_order: int
Order of the splin... | [
"Computes",
"a",
"1D",
"spline",
"basis",
"Input",
":",
"length",
":",
"int",
"length",
"of",
"each",
"basis",
"nr_knots",
":",
"int",
"Number",
"of",
"knots",
"i",
".",
"e",
".",
"number",
"of",
"basis",
"functions",
".",
"spline_order",
":",
"int",
"... | nwilming/ocupy | python | https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/spline_base.py#L171-L194 | [
"def",
"spline_base1d",
"(",
"length",
",",
"nr_knots",
"=",
"20",
",",
"spline_order",
"=",
"5",
",",
"marginal",
"=",
"None",
")",
":",
"if",
"marginal",
"is",
"None",
":",
"knots",
"=",
"augknt",
"(",
"np",
".",
"linspace",
"(",
"0",
",",
"length"... | a0bd64f822576feaa502939d6bafd1183b237d16 |
train | spline_base2d | Computes a set of 2D spline basis functions.
The basis functions cover the entire space in height*width and can
for example be used to create fixation density maps.
Input:
width: int
width of each basis
height: int
height of each basis
nr_knots_x: i... | ocupy/spline_base.py | def spline_base2d(width, height, nr_knots_x = 20.0, nr_knots_y = 20.0,
spline_order = 5, marginal_x = None, marginal_y = None):
"""Computes a set of 2D spline basis functions.
The basis functions cover the entire space in height*width and can
for example be used to create fixation density ma... | def spline_base2d(width, height, nr_knots_x = 20.0, nr_knots_y = 20.0,
spline_order = 5, marginal_x = None, marginal_y = None):
"""Computes a set of 2D spline basis functions.
The basis functions cover the entire space in height*width and can
for example be used to create fixation density ma... | [
"Computes",
"a",
"set",
"of",
"2D",
"spline",
"basis",
"functions",
".",
"The",
"basis",
"functions",
"cover",
"the",
"entire",
"space",
"in",
"height",
"*",
"width",
"and",
"can",
"for",
"example",
"be",
"used",
"to",
"create",
"fixation",
"density",
"map... | nwilming/ocupy | python | https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/spline_base.py#L197-L257 | [
"def",
"spline_base2d",
"(",
"width",
",",
"height",
",",
"nr_knots_x",
"=",
"20.0",
",",
"nr_knots_y",
"=",
"20.0",
",",
"spline_order",
"=",
"5",
",",
"marginal_x",
"=",
"None",
",",
"marginal_y",
"=",
"None",
")",
":",
"if",
"not",
"(",
"nr_knots_x",
... | a0bd64f822576feaa502939d6bafd1183b237d16 |
train | spline_base3d | Computes a set of 3D spline basis functions.
For a description of the parameters see spline_base2d. | ocupy/spline_base.py | def spline_base3d( width, height, depth, nr_knots_x = 10.0, nr_knots_y = 10.0,
nr_knots_z=10, spline_order = 3, marginal_x = None, marginal_y = None,
marginal_z = None):
"""Computes a set of 3D spline basis functions.
For a description of the parameters see spline_base2d.
"""
if... | def spline_base3d( width, height, depth, nr_knots_x = 10.0, nr_knots_y = 10.0,
nr_knots_z=10, spline_order = 3, marginal_x = None, marginal_y = None,
marginal_z = None):
"""Computes a set of 3D spline basis functions.
For a description of the parameters see spline_base2d.
"""
if... | [
"Computes",
"a",
"set",
"of",
"3D",
"spline",
"basis",
"functions",
".",
"For",
"a",
"description",
"of",
"the",
"parameters",
"see",
"spline_base2d",
"."
] | nwilming/ocupy | python | https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/spline_base.py#L259-L283 | [
"def",
"spline_base3d",
"(",
"width",
",",
"height",
",",
"depth",
",",
"nr_knots_x",
"=",
"10.0",
",",
"nr_knots_y",
"=",
"10.0",
",",
"nr_knots_z",
"=",
"10",
",",
"spline_order",
"=",
"3",
",",
"marginal_x",
"=",
"None",
",",
"marginal_y",
"=",
"None"... | a0bd64f822576feaa502939d6bafd1183b237d16 |
train | spline | Evaluates the ith spline basis given by knots on points in x | ocupy/spline_base.py | def spline(x,knots,p,i=0.0):
"""Evaluates the ith spline basis given by knots on points in x"""
assert(p+1<len(knots))
return np.array([N(float(u),float(i),float(p),knots) for u in x]) | def spline(x,knots,p,i=0.0):
"""Evaluates the ith spline basis given by knots on points in x"""
assert(p+1<len(knots))
return np.array([N(float(u),float(i),float(p),knots) for u in x]) | [
"Evaluates",
"the",
"ith",
"spline",
"basis",
"given",
"by",
"knots",
"on",
"points",
"in",
"x"
] | nwilming/ocupy | python | https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/spline_base.py#L285-L288 | [
"def",
"spline",
"(",
"x",
",",
"knots",
",",
"p",
",",
"i",
"=",
"0.0",
")",
":",
"assert",
"(",
"p",
"+",
"1",
"<",
"len",
"(",
"knots",
")",
")",
"return",
"np",
".",
"array",
"(",
"[",
"N",
"(",
"float",
"(",
"u",
")",
",",
"float",
"... | a0bd64f822576feaa502939d6bafd1183b237d16 |
train | spcol | Computes the spline colocation matrix for knots in x.
The spline collocation matrix contains all m-p-1 bases
defined by knots. Specifically it contains the ith basis
in the ith column.
Input:
x: vector to evaluate the bases on
knots: vector of knots
spline_order: orde... | ocupy/spline_base.py | def spcol(x,knots,spline_order):
"""Computes the spline colocation matrix for knots in x.
The spline collocation matrix contains all m-p-1 bases
defined by knots. Specifically it contains the ith basis
in the ith column.
Input:
x: vector to evaluate the bases on
knots: vec... | def spcol(x,knots,spline_order):
"""Computes the spline colocation matrix for knots in x.
The spline collocation matrix contains all m-p-1 bases
defined by knots. Specifically it contains the ith basis
in the ith column.
Input:
x: vector to evaluate the bases on
knots: vec... | [
"Computes",
"the",
"spline",
"colocation",
"matrix",
"for",
"knots",
"in",
"x",
".",
"The",
"spline",
"collocation",
"matrix",
"contains",
"all",
"m",
"-",
"p",
"-",
"1",
"bases",
"defined",
"by",
"knots",
".",
"Specifically",
"it",
"contains",
"the",
"ith... | nwilming/ocupy | python | https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/spline_base.py#L290-L311 | [
"def",
"spcol",
"(",
"x",
",",
"knots",
",",
"spline_order",
")",
":",
"colmat",
"=",
"np",
".",
"nan",
"*",
"np",
".",
"ones",
"(",
"(",
"len",
"(",
"x",
")",
",",
"len",
"(",
"knots",
")",
"-",
"spline_order",
"-",
"1",
")",
")",
"for",
"i"... | a0bd64f822576feaa502939d6bafd1183b237d16 |
train | augknt | Augment knot sequence such that some boundary conditions
are met. | ocupy/spline_base.py | def augknt(knots,order):
"""Augment knot sequence such that some boundary conditions
are met."""
a = []
[a.append(knots[0]) for t in range(0,order)]
[a.append(k) for k in knots]
[a.append(knots[-1]) for t in range(0,order)]
return np.array(a) | def augknt(knots,order):
"""Augment knot sequence such that some boundary conditions
are met."""
a = []
[a.append(knots[0]) for t in range(0,order)]
[a.append(k) for k in knots]
[a.append(knots[-1]) for t in range(0,order)]
return np.array(a) | [
"Augment",
"knot",
"sequence",
"such",
"that",
"some",
"boundary",
"conditions",
"are",
"met",
"."
] | nwilming/ocupy | python | https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/spline_base.py#L313-L320 | [
"def",
"augknt",
"(",
"knots",
",",
"order",
")",
":",
"a",
"=",
"[",
"]",
"[",
"a",
".",
"append",
"(",
"knots",
"[",
"0",
"]",
")",
"for",
"t",
"in",
"range",
"(",
"0",
",",
"order",
")",
"]",
"[",
"a",
".",
"append",
"(",
"k",
")",
"fo... | a0bd64f822576feaa502939d6bafd1183b237d16 |
train | N | Compute Spline Basis
Evaluates the spline basis of order p defined by knots
at knot i and point u. | ocupy/spline_base.py | def N(u,i,p,knots):
"""Compute Spline Basis
Evaluates the spline basis of order p defined by knots
at knot i and point u.
"""
if p == 0:
if knots[i] < u and u <=knots[i+1]:
return 1.0
else:
return 0.0
else:
try:
k = (( float((u-kn... | def N(u,i,p,knots):
"""Compute Spline Basis
Evaluates the spline basis of order p defined by knots
at knot i and point u.
"""
if p == 0:
if knots[i] < u and u <=knots[i+1]:
return 1.0
else:
return 0.0
else:
try:
k = (( float((u-kn... | [
"Compute",
"Spline",
"Basis",
"Evaluates",
"the",
"spline",
"basis",
"of",
"order",
"p",
"defined",
"by",
"knots",
"at",
"knot",
"i",
"and",
"point",
"u",
"."
] | nwilming/ocupy | python | https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/spline_base.py#L322-L344 | [
"def",
"N",
"(",
"u",
",",
"i",
",",
"p",
",",
"knots",
")",
":",
"if",
"p",
"==",
"0",
":",
"if",
"knots",
"[",
"i",
"]",
"<",
"u",
"and",
"u",
"<=",
"knots",
"[",
"i",
"+",
"1",
"]",
":",
"return",
"1.0",
"else",
":",
"return",
"0.0",
... | a0bd64f822576feaa502939d6bafd1183b237d16 |
train | prediction_scores | Evaluates a prediction against fixations in a fixmat with different measures.
The default measures which are used are AUC, NSS and KL-divergence. This
can be changed by setting the list of measures with set_scores.
As different measures need potentially different parameters, the kw
dictionary can be us... | ocupy/measures.py | def prediction_scores(prediction, fm, **kw):
"""
Evaluates a prediction against fixations in a fixmat with different measures.
The default measures which are used are AUC, NSS and KL-divergence. This
can be changed by setting the list of measures with set_scores.
As different measures need potentia... | def prediction_scores(prediction, fm, **kw):
"""
Evaluates a prediction against fixations in a fixmat with different measures.
The default measures which are used are AUC, NSS and KL-divergence. This
can be changed by setting the list of measures with set_scores.
As different measures need potentia... | [
"Evaluates",
"a",
"prediction",
"against",
"fixations",
"in",
"a",
"fixmat",
"with",
"different",
"measures",
"."
] | nwilming/ocupy | python | https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/measures.py#L23-L64 | [
"def",
"prediction_scores",
"(",
"prediction",
",",
"fm",
",",
"*",
"*",
"kw",
")",
":",
"if",
"prediction",
"==",
"None",
":",
"return",
"[",
"np",
".",
"NaN",
"for",
"measure",
"in",
"scores",
"]",
"results",
"=",
"[",
"]",
"for",
"measure",
"in",
... | a0bd64f822576feaa502939d6bafd1183b237d16 |
train | kldiv_model | wraps kldiv functionality for model evaluation
input:
prediction: 2D matrix
the model salience map
fm : fixmat
Should be filtered for the image corresponding to the prediction | ocupy/measures.py | def kldiv_model(prediction, fm):
"""
wraps kldiv functionality for model evaluation
input:
prediction: 2D matrix
the model salience map
fm : fixmat
Should be filtered for the image corresponding to the prediction
"""
(_, r_x) = calc_resize_factor(prediction, ... | def kldiv_model(prediction, fm):
"""
wraps kldiv functionality for model evaluation
input:
prediction: 2D matrix
the model salience map
fm : fixmat
Should be filtered for the image corresponding to the prediction
"""
(_, r_x) = calc_resize_factor(prediction, ... | [
"wraps",
"kldiv",
"functionality",
"for",
"model",
"evaluation"
] | nwilming/ocupy | python | https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/measures.py#L80-L94 | [
"def",
"kldiv_model",
"(",
"prediction",
",",
"fm",
")",
":",
"(",
"_",
",",
"r_x",
")",
"=",
"calc_resize_factor",
"(",
"prediction",
",",
"fm",
".",
"image_size",
")",
"q",
"=",
"np",
".",
"array",
"(",
"prediction",
",",
"copy",
"=",
"True",
")",
... | a0bd64f822576feaa502939d6bafd1183b237d16 |
train | kldiv | Computes the Kullback-Leibler divergence between two distributions.
Parameters
p : Matrix
The first probability distribution
q : Matrix
The second probability distribution
distp : fixmat
If p is None, distp is used to compute a FDM which
is th... | ocupy/measures.py | def kldiv(p, q, distp = None, distq = None, scale_factor = 1):
"""
Computes the Kullback-Leibler divergence between two distributions.
Parameters
p : Matrix
The first probability distribution
q : Matrix
The second probability distribution
distp : fixmat
... | def kldiv(p, q, distp = None, distq = None, scale_factor = 1):
"""
Computes the Kullback-Leibler divergence between two distributions.
Parameters
p : Matrix
The first probability distribution
q : Matrix
The second probability distribution
distp : fixmat
... | [
"Computes",
"the",
"Kullback",
"-",
"Leibler",
"divergence",
"between",
"two",
"distributions",
"."
] | nwilming/ocupy | python | https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/measures.py#L96-L129 | [
"def",
"kldiv",
"(",
"p",
",",
"q",
",",
"distp",
"=",
"None",
",",
"distq",
"=",
"None",
",",
"scale_factor",
"=",
"1",
")",
":",
"assert",
"q",
"!=",
"None",
"or",
"distq",
"!=",
"None",
",",
"\"Either q or distq have to be given\"",
"assert",
"p",
"... | a0bd64f822576feaa502939d6bafd1183b237d16 |
train | kldiv_cs_model | Computes Chao-Shen corrected KL-divergence between prediction
and fdm made from fixations in fm.
Parameters :
prediction : np.ndarray
a fixation density map
fm : FixMat object | ocupy/measures.py | def kldiv_cs_model(prediction, fm):
"""
Computes Chao-Shen corrected KL-divergence between prediction
and fdm made from fixations in fm.
Parameters :
prediction : np.ndarray
a fixation density map
fm : FixMat object
"""
# compute histogram of fixations needed for Cha... | def kldiv_cs_model(prediction, fm):
"""
Computes Chao-Shen corrected KL-divergence between prediction
and fdm made from fixations in fm.
Parameters :
prediction : np.ndarray
a fixation density map
fm : FixMat object
"""
# compute histogram of fixations needed for Cha... | [
"Computes",
"Chao",
"-",
"Shen",
"corrected",
"KL",
"-",
"divergence",
"between",
"prediction",
"and",
"fdm",
"made",
"from",
"fixations",
"in",
"fm",
"."
] | nwilming/ocupy | python | https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/measures.py#L131-L164 | [
"def",
"kldiv_cs_model",
"(",
"prediction",
",",
"fm",
")",
":",
"# compute histogram of fixations needed for ChaoShen corrected kl-div",
"# image category must exist (>-1) and image_size must be non-empty",
"assert",
"(",
"len",
"(",
"fm",
".",
"image_size",
")",
"==",
"2",
... | a0bd64f822576feaa502939d6bafd1183b237d16 |
train | chao_shen | Computes some terms needed for the Chao-Shen KL correction. | ocupy/measures.py | def chao_shen(q):
"""
Computes some terms needed for the Chao-Shen KL correction.
"""
yx = q[q > 0] # remove bins with zero counts
n = np.sum(yx)
p = yx.astype(float)/n
f1 = np.sum(yx == 1) # number of singletons in the sample
if f1 == n: # avoid C == 0
f1 -= 1
C = 1 - (f1/n)... | def chao_shen(q):
"""
Computes some terms needed for the Chao-Shen KL correction.
"""
yx = q[q > 0] # remove bins with zero counts
n = np.sum(yx)
p = yx.astype(float)/n
f1 = np.sum(yx == 1) # number of singletons in the sample
if f1 == n: # avoid C == 0
f1 -= 1
C = 1 - (f1/n)... | [
"Computes",
"some",
"terms",
"needed",
"for",
"the",
"Chao",
"-",
"Shen",
"KL",
"correction",
"."
] | nwilming/ocupy | python | https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/measures.py#L167-L181 | [
"def",
"chao_shen",
"(",
"q",
")",
":",
"yx",
"=",
"q",
"[",
"q",
">",
"0",
"]",
"# remove bins with zero counts",
"n",
"=",
"np",
".",
"sum",
"(",
"yx",
")",
"p",
"=",
"yx",
".",
"astype",
"(",
"float",
")",
"/",
"n",
"f1",
"=",
"np",
".",
"... | a0bd64f822576feaa502939d6bafd1183b237d16 |
train | correlation_model | wraps numpy.corrcoef functionality for model evaluation
input:
prediction: 2D Matrix
the model salience map
fm: fixmat
Used to compute a FDM to which the prediction is compared. | ocupy/measures.py | def correlation_model(prediction, fm):
"""
wraps numpy.corrcoef functionality for model evaluation
input:
prediction: 2D Matrix
the model salience map
fm: fixmat
Used to compute a FDM to which the prediction is compared.
"""
(_, r_x) = calc_resize_factor(pred... | def correlation_model(prediction, fm):
"""
wraps numpy.corrcoef functionality for model evaluation
input:
prediction: 2D Matrix
the model salience map
fm: fixmat
Used to compute a FDM to which the prediction is compared.
"""
(_, r_x) = calc_resize_factor(pred... | [
"wraps",
"numpy",
".",
"corrcoef",
"functionality",
"for",
"model",
"evaluation"
] | nwilming/ocupy | python | https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/measures.py#L184-L196 | [
"def",
"correlation_model",
"(",
"prediction",
",",
"fm",
")",
":",
"(",
"_",
",",
"r_x",
")",
"=",
"calc_resize_factor",
"(",
"prediction",
",",
"fm",
".",
"image_size",
")",
"fdm",
"=",
"compute_fdm",
"(",
"fm",
",",
"scale_factor",
"=",
"r_x",
")",
... | a0bd64f822576feaa502939d6bafd1183b237d16 |
train | nss_model | wraps nss functionality for model evaluation
input:
prediction: 2D matrix
the model salience map
fm : fixmat
Fixations that define the actuals | ocupy/measures.py | def nss_model(prediction, fm):
"""
wraps nss functionality for model evaluation
input:
prediction: 2D matrix
the model salience map
fm : fixmat
Fixations that define the actuals
"""
(r_y, r_x) = calc_resize_factor(prediction, fm.image_size)
fix = ((np.arr... | def nss_model(prediction, fm):
"""
wraps nss functionality for model evaluation
input:
prediction: 2D matrix
the model salience map
fm : fixmat
Fixations that define the actuals
"""
(r_y, r_x) = calc_resize_factor(prediction, fm.image_size)
fix = ((np.arr... | [
"wraps",
"nss",
"functionality",
"for",
"model",
"evaluation"
] | nwilming/ocupy | python | https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/measures.py#L199-L212 | [
"def",
"nss_model",
"(",
"prediction",
",",
"fm",
")",
":",
"(",
"r_y",
",",
"r_x",
")",
"=",
"calc_resize_factor",
"(",
"prediction",
",",
"fm",
".",
"image_size",
")",
"fix",
"=",
"(",
"(",
"np",
".",
"array",
"(",
"fm",
".",
"y",
"-",
"1",
")"... | a0bd64f822576feaa502939d6bafd1183b237d16 |
train | nss | Compute the normalized scanpath salience
input:
fix : list, l[0] contains y, l[1] contains x | ocupy/measures.py | def nss(prediction, fix):
"""
Compute the normalized scanpath salience
input:
fix : list, l[0] contains y, l[1] contains x
"""
prediction = prediction - np.mean(prediction)
prediction = prediction / np.std(prediction)
return np.mean(prediction[fix[0], fix[1]]) | def nss(prediction, fix):
"""
Compute the normalized scanpath salience
input:
fix : list, l[0] contains y, l[1] contains x
"""
prediction = prediction - np.mean(prediction)
prediction = prediction / np.std(prediction)
return np.mean(prediction[fix[0], fix[1]]) | [
"Compute",
"the",
"normalized",
"scanpath",
"salience"
] | nwilming/ocupy | python | https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/measures.py#L215-L225 | [
"def",
"nss",
"(",
"prediction",
",",
"fix",
")",
":",
"prediction",
"=",
"prediction",
"-",
"np",
".",
"mean",
"(",
"prediction",
")",
"prediction",
"=",
"prediction",
"/",
"np",
".",
"std",
"(",
"prediction",
")",
"return",
"np",
".",
"mean",
"(",
... | a0bd64f822576feaa502939d6bafd1183b237d16 |
train | roc_model | wraps roc functionality for model evaluation
Parameters:
prediction: 2D array
the model salience map
fm : fixmat
Fixations that define locations of the actuals
ctr_loc : tuple of (y.x) coordinates, optional
Allows to specify control points for spatial
... | ocupy/measures.py | def roc_model(prediction, fm, ctr_loc = None, ctr_size = None):
"""
wraps roc functionality for model evaluation
Parameters:
prediction: 2D array
the model salience map
fm : fixmat
Fixations that define locations of the actuals
ctr_loc : tuple of (y.x) coordi... | def roc_model(prediction, fm, ctr_loc = None, ctr_size = None):
"""
wraps roc functionality for model evaluation
Parameters:
prediction: 2D array
the model salience map
fm : fixmat
Fixations that define locations of the actuals
ctr_loc : tuple of (y.x) coordi... | [
"wraps",
"roc",
"functionality",
"for",
"model",
"evaluation"
] | nwilming/ocupy | python | https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/measures.py#L228-L266 | [
"def",
"roc_model",
"(",
"prediction",
",",
"fm",
",",
"ctr_loc",
"=",
"None",
",",
"ctr_size",
"=",
"None",
")",
":",
"# check if prediction is a valid numpy array",
"assert",
"type",
"(",
"prediction",
")",
"==",
"np",
".",
"ndarray",
"# check whether scaling pr... | a0bd64f822576feaa502939d6bafd1183b237d16 |
train | fast_roc | approximates the area under the roc curve for sets of actuals and controls.
Uses all values appearing in actuals as thresholds and lower sum
interpolation. Also returns arrays of the true positive rate and the false
positive rate that can be used for plotting the roc curve.
Parameters:
actuals ... | ocupy/measures.py | def fast_roc(actuals, controls):
"""
approximates the area under the roc curve for sets of actuals and controls.
Uses all values appearing in actuals as thresholds and lower sum
interpolation. Also returns arrays of the true positive rate and the false
positive rate that can be used for plotting the... | def fast_roc(actuals, controls):
"""
approximates the area under the roc curve for sets of actuals and controls.
Uses all values appearing in actuals as thresholds and lower sum
interpolation. Also returns arrays of the true positive rate and the false
positive rate that can be used for plotting the... | [
"approximates",
"the",
"area",
"under",
"the",
"roc",
"curve",
"for",
"sets",
"of",
"actuals",
"and",
"controls",
".",
"Uses",
"all",
"values",
"appearing",
"in",
"actuals",
"as",
"thresholds",
"and",
"lower",
"sum",
"interpolation",
".",
"Also",
"returns",
... | nwilming/ocupy | python | https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/measures.py#L269-L307 | [
"def",
"fast_roc",
"(",
"actuals",
",",
"controls",
")",
":",
"assert",
"(",
"type",
"(",
"actuals",
")",
"is",
"np",
".",
"ndarray",
")",
"assert",
"(",
"type",
"(",
"controls",
")",
"is",
"np",
".",
"ndarray",
")",
"actuals",
"=",
"np",
".",
"rav... | a0bd64f822576feaa502939d6bafd1183b237d16 |
train | faster_roc | Histogram based implementation of AUC unde ROC curve.
Parameters:
actuals : list
A list of numeric values for positive observations.
controls : list
A list of numeric values for negative observations. | ocupy/measures.py | def faster_roc(actuals, controls):
"""
Histogram based implementation of AUC unde ROC curve.
Parameters:
actuals : list
A list of numeric values for positive observations.
controls : list
A list of numeric values for negative observations.
"""
assert(type(actu... | def faster_roc(actuals, controls):
"""
Histogram based implementation of AUC unde ROC curve.
Parameters:
actuals : list
A list of numeric values for positive observations.
controls : list
A list of numeric values for negative observations.
"""
assert(type(actu... | [
"Histogram",
"based",
"implementation",
"of",
"AUC",
"unde",
"ROC",
"curve",
".",
"Parameters",
":",
"actuals",
":",
"list",
"A",
"list",
"of",
"numeric",
"values",
"for",
"positive",
"observations",
".",
"controls",
":",
"list",
"A",
"list",
"of",
"numeric"... | nwilming/ocupy | python | https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/measures.py#L309-L351 | [
"def",
"faster_roc",
"(",
"actuals",
",",
"controls",
")",
":",
"assert",
"(",
"type",
"(",
"actuals",
")",
"is",
"np",
".",
"ndarray",
")",
"assert",
"(",
"type",
"(",
"controls",
")",
"is",
"np",
".",
"ndarray",
")",
"if",
"len",
"(",
"actuals",
... | a0bd64f822576feaa502939d6bafd1183b237d16 |
train | emd_model | wraps emd functionality for model evaluation
requires:
OpenCV python bindings
input:
prediction: the model salience map
fm : fixmat filtered for the image corresponding to the prediction | ocupy/measures.py | def emd_model(prediction, fm):
"""
wraps emd functionality for model evaluation
requires:
OpenCV python bindings
input:
prediction: the model salience map
fm : fixmat filtered for the image corresponding to the prediction
"""
(_, r_x) = calc_resize_factor(prediction, fm... | def emd_model(prediction, fm):
"""
wraps emd functionality for model evaluation
requires:
OpenCV python bindings
input:
prediction: the model salience map
fm : fixmat filtered for the image corresponding to the prediction
"""
(_, r_x) = calc_resize_factor(prediction, fm... | [
"wraps",
"emd",
"functionality",
"for",
"model",
"evaluation"
] | nwilming/ocupy | python | https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/measures.py#L382-L395 | [
"def",
"emd_model",
"(",
"prediction",
",",
"fm",
")",
":",
"(",
"_",
",",
"r_x",
")",
"=",
"calc_resize_factor",
"(",
"prediction",
",",
"fm",
".",
"image_size",
")",
"gt",
"=",
"fixmat",
".",
"compute_fdm",
"(",
"fm",
",",
"scale_factor",
"=",
"r_x",... | a0bd64f822576feaa502939d6bafd1183b237d16 |
train | emd | Compute the Eart Movers Distance between prediction and model.
This implementation uses opencv for doing the actual work.
Unfortunately, at the time of implementation only the SWIG
bindings werer available and the numpy arrays have to
converted by hand. This changes with opencv 2.1. | ocupy/measures.py | def emd(prediction, ground_truth):
"""
Compute the Eart Movers Distance between prediction and model.
This implementation uses opencv for doing the actual work.
Unfortunately, at the time of implementation only the SWIG
bindings werer available and the numpy arrays have to
converted by hand. Th... | def emd(prediction, ground_truth):
"""
Compute the Eart Movers Distance between prediction and model.
This implementation uses opencv for doing the actual work.
Unfortunately, at the time of implementation only the SWIG
bindings werer available and the numpy arrays have to
converted by hand. Th... | [
"Compute",
"the",
"Eart",
"Movers",
"Distance",
"between",
"prediction",
"and",
"model",
"."
] | nwilming/ocupy | python | https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/measures.py#L398-L423 | [
"def",
"emd",
"(",
"prediction",
",",
"ground_truth",
")",
":",
"import",
"opencv",
"if",
"not",
"(",
"prediction",
".",
"shape",
"==",
"ground_truth",
".",
"shape",
")",
":",
"raise",
"RuntimeError",
"(",
"'Shapes of prediction and ground truth have'",
"+",
"' ... | a0bd64f822576feaa502939d6bafd1183b237d16 |
train | _rfc822 | Parse RFC 822 dates and times
http://tools.ietf.org/html/rfc822#section-5
There are some formatting differences that are accounted for:
1. Years may be two or four digits.
2. The month and day can be swapped.
3. Additional timezone names are supported.
4. A default time and timezone are assumed... | listparser/dates.py | def _rfc822(date):
"""Parse RFC 822 dates and times
http://tools.ietf.org/html/rfc822#section-5
There are some formatting differences that are accounted for:
1. Years may be two or four digits.
2. The month and day can be swapped.
3. Additional timezone names are supported.
4. A default tim... | def _rfc822(date):
"""Parse RFC 822 dates and times
http://tools.ietf.org/html/rfc822#section-5
There are some formatting differences that are accounted for:
1. Years may be two or four digits.
2. The month and day can be swapped.
3. Additional timezone names are supported.
4. A default tim... | [
"Parse",
"RFC",
"822",
"dates",
"and",
"times",
"http",
":",
"//",
"tools",
".",
"ietf",
".",
"org",
"/",
"html",
"/",
"rfc822#section",
"-",
"5"
] | kurtmckee/listparser | python | https://github.com/kurtmckee/listparser/blob/f9bc310a0ce567cd0611fea68be99974021f53c7/listparser/dates.py#L25-L126 | [
"def",
"_rfc822",
"(",
"date",
")",
":",
"daynames",
"=",
"set",
"(",
"[",
"'mon'",
",",
"'tue'",
",",
"'wed'",
",",
"'thu'",
",",
"'fri'",
",",
"'sat'",
",",
"'sun'",
"]",
")",
"months",
"=",
"{",
"'jan'",
":",
"1",
",",
"'feb'",
":",
"2",
","... | f9bc310a0ce567cd0611fea68be99974021f53c7 |
train | _to_rfc822 | _to_rfc822(datetime.datetime) -> str
The datetime `strftime` method is subject to locale-specific
day and month names, so this function hardcodes the conversion. | listparser/dates.py | def _to_rfc822(date):
"""_to_rfc822(datetime.datetime) -> str
The datetime `strftime` method is subject to locale-specific
day and month names, so this function hardcodes the conversion."""
months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
da... | def _to_rfc822(date):
"""_to_rfc822(datetime.datetime) -> str
The datetime `strftime` method is subject to locale-specific
day and month names, so this function hardcodes the conversion."""
months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
da... | [
"_to_rfc822",
"(",
"datetime",
".",
"datetime",
")",
"-",
">",
"str",
"The",
"datetime",
"strftime",
"method",
"is",
"subject",
"to",
"locale",
"-",
"specific",
"day",
"and",
"month",
"names",
"so",
"this",
"function",
"hardcodes",
"the",
"conversion",
"."
] | kurtmckee/listparser | python | https://github.com/kurtmckee/listparser/blob/f9bc310a0ce567cd0611fea68be99974021f53c7/listparser/dates.py#L129-L145 | [
"def",
"_to_rfc822",
"(",
"date",
")",
":",
"months",
"=",
"[",
"'Jan'",
",",
"'Feb'",
",",
"'Mar'",
",",
"'Apr'",
",",
"'May'",
",",
"'Jun'",
",",
"'Jul'",
",",
"'Aug'",
",",
"'Sep'",
",",
"'Oct'",
",",
"'Nov'",
",",
"'Dec'",
"]",
"days",
"=",
"... | f9bc310a0ce567cd0611fea68be99974021f53c7 |
train | SQLParams.format | Formats the SQL query to use ordinal parameters instead of named
parameters.
*sql* (|string|) is the SQL query.
*params* (|dict|) maps each named parameter (|string|) to value
(|object|). If |self.named| is "numeric", then *params* can be
simply a |sequence| of values mapped by index.
Returns a 2-|tuple|... | sqlparams/__init__.py | def format(self, sql, params):
"""
Formats the SQL query to use ordinal parameters instead of named
parameters.
*sql* (|string|) is the SQL query.
*params* (|dict|) maps each named parameter (|string|) to value
(|object|). If |self.named| is "numeric", then *params* can be
simply a |sequence| of values ... | def format(self, sql, params):
"""
Formats the SQL query to use ordinal parameters instead of named
parameters.
*sql* (|string|) is the SQL query.
*params* (|dict|) maps each named parameter (|string|) to value
(|object|). If |self.named| is "numeric", then *params* can be
simply a |sequence| of values ... | [
"Formats",
"the",
"SQL",
"query",
"to",
"use",
"ordinal",
"parameters",
"instead",
"of",
"named",
"parameters",
"."
] | cpburnz/python-sql-parameters | python | https://github.com/cpburnz/python-sql-parameters/blob/828088a54b84aa904ec54c50af60f8aecc62a5f4/sqlparams/__init__.py#L245-L301 | [
"def",
"format",
"(",
"self",
",",
"sql",
",",
"params",
")",
":",
"if",
"isinstance",
"(",
"sql",
",",
"unicode",
")",
":",
"string_type",
"=",
"unicode",
"elif",
"isinstance",
"(",
"sql",
",",
"bytes",
")",
":",
"string_type",
"=",
"bytes",
"sql",
... | 828088a54b84aa904ec54c50af60f8aecc62a5f4 |
train | SQLParams.formatmany | Formats the SQL query to use ordinal parameters instead of named
parameters.
*sql* (|string|) is the SQL query.
*many_params* (|iterable|) contains each *params* to format.
- *params* (|dict|) maps each named parameter (|string|) to value
(|object|). If |self.named| is "numeric", then *params* can be
... | sqlparams/__init__.py | def formatmany(self, sql, many_params):
"""
Formats the SQL query to use ordinal parameters instead of named
parameters.
*sql* (|string|) is the SQL query.
*many_params* (|iterable|) contains each *params* to format.
- *params* (|dict|) maps each named parameter (|string|) to value
(|object|). If |se... | def formatmany(self, sql, many_params):
"""
Formats the SQL query to use ordinal parameters instead of named
parameters.
*sql* (|string|) is the SQL query.
*many_params* (|iterable|) contains each *params* to format.
- *params* (|dict|) maps each named parameter (|string|) to value
(|object|). If |se... | [
"Formats",
"the",
"SQL",
"query",
"to",
"use",
"ordinal",
"parameters",
"instead",
"of",
"named",
"parameters",
"."
] | cpburnz/python-sql-parameters | python | https://github.com/cpburnz/python-sql-parameters/blob/828088a54b84aa904ec54c50af60f8aecc62a5f4/sqlparams/__init__.py#L303-L386 | [
"def",
"formatmany",
"(",
"self",
",",
"sql",
",",
"many_params",
")",
":",
"if",
"isinstance",
"(",
"sql",
",",
"unicode",
")",
":",
"string_type",
"=",
"unicode",
"elif",
"isinstance",
"(",
"sql",
",",
"bytes",
")",
":",
"string_type",
"=",
"bytes",
... | 828088a54b84aa904ec54c50af60f8aecc62a5f4 |
train | _get_parser | Gets the parser for the command f, if it not exists it creates a new one | reticular.py | def _get_parser(f):
"""
Gets the parser for the command f, if it not exists it creates a new one
"""
_COMMAND_GROUPS[f.__module__].load()
if f.__name__ not in _COMMAND_GROUPS[f.__module__].parsers:
parser = _COMMAND_GROUPS[f.__module__].parser_generator.add_parser(f.__name__, help=f.__doc__... | def _get_parser(f):
"""
Gets the parser for the command f, if it not exists it creates a new one
"""
_COMMAND_GROUPS[f.__module__].load()
if f.__name__ not in _COMMAND_GROUPS[f.__module__].parsers:
parser = _COMMAND_GROUPS[f.__module__].parser_generator.add_parser(f.__name__, help=f.__doc__... | [
"Gets",
"the",
"parser",
"for",
"the",
"command",
"f",
"if",
"it",
"not",
"exists",
"it",
"creates",
"a",
"new",
"one"
] | hecrj/reticular | python | https://github.com/hecrj/reticular/blob/b83c632459b3215284124373931fcaef76bc64e8/reticular.py#L180-L193 | [
"def",
"_get_parser",
"(",
"f",
")",
":",
"_COMMAND_GROUPS",
"[",
"f",
".",
"__module__",
"]",
".",
"load",
"(",
")",
"if",
"f",
".",
"__name__",
"not",
"in",
"_COMMAND_GROUPS",
"[",
"f",
".",
"__module__",
"]",
".",
"parsers",
":",
"parser",
"=",
"_... | b83c632459b3215284124373931fcaef76bc64e8 |
train | findMentions | Find all <a /> elements in the given html for a post. Only scan html element matching all criteria in look_in.
optionally the content to be scanned can be given as an argument.
If any have an href attribute that is not from the
one of the items in exclude_domains, append it to our lists.
:param sourc... | ronkyuu/webmention.py | def findMentions(sourceURL, targetURL=None, exclude_domains=[], content=None, test_urls=True, headers={}, timeout=None):
"""Find all <a /> elements in the given html for a post. Only scan html element matching all criteria in look_in.
optionally the content to be scanned can be given as an argument.
If an... | def findMentions(sourceURL, targetURL=None, exclude_domains=[], content=None, test_urls=True, headers={}, timeout=None):
"""Find all <a /> elements in the given html for a post. Only scan html element matching all criteria in look_in.
optionally the content to be scanned can be given as an argument.
If an... | [
"Find",
"all",
"<a",
"/",
">",
"elements",
"in",
"the",
"given",
"html",
"for",
"a",
"post",
".",
"Only",
"scan",
"html",
"element",
"matching",
"all",
"criteria",
"in",
"look_in",
"."
] | bear/ronkyuu | python | https://github.com/bear/ronkyuu/blob/91a05fbe220b661760467b7b3d3d780a9ba28afa/ronkyuu/webmention.py#L41-L112 | [
"def",
"findMentions",
"(",
"sourceURL",
",",
"targetURL",
"=",
"None",
",",
"exclude_domains",
"=",
"[",
"]",
",",
"content",
"=",
"None",
",",
"test_urls",
"=",
"True",
",",
"headers",
"=",
"{",
"}",
",",
"timeout",
"=",
"None",
")",
":",
"__doc__",
... | 91a05fbe220b661760467b7b3d3d780a9ba28afa |
train | findEndpoint | Search the given html content for all <link /> elements
and return any discovered WebMention URL.
:param html: html content
:rtype: WebMention URL | ronkyuu/webmention.py | def findEndpoint(html):
"""Search the given html content for all <link /> elements
and return any discovered WebMention URL.
:param html: html content
:rtype: WebMention URL
"""
poss_rels = ['webmention', 'http://webmention.org', 'http://webmention.org/', 'https://webmention.org', 'https://webm... | def findEndpoint(html):
"""Search the given html content for all <link /> elements
and return any discovered WebMention URL.
:param html: html content
:rtype: WebMention URL
"""
poss_rels = ['webmention', 'http://webmention.org', 'http://webmention.org/', 'https://webmention.org', 'https://webm... | [
"Search",
"the",
"given",
"html",
"content",
"for",
"all",
"<link",
"/",
">",
"elements",
"and",
"return",
"any",
"discovered",
"WebMention",
"URL",
"."
] | bear/ronkyuu | python | https://github.com/bear/ronkyuu/blob/91a05fbe220b661760467b7b3d3d780a9ba28afa/ronkyuu/webmention.py#L115-L131 | [
"def",
"findEndpoint",
"(",
"html",
")",
":",
"poss_rels",
"=",
"[",
"'webmention'",
",",
"'http://webmention.org'",
",",
"'http://webmention.org/'",
",",
"'https://webmention.org'",
",",
"'https://webmention.org/'",
"]",
"# find elements with correct rels and a href value",
... | 91a05fbe220b661760467b7b3d3d780a9ba28afa |
train | discoverEndpoint | Discover any WebMention endpoint for a given URL.
:param link: URL to discover WebMention endpoint
:param test_urls: optional flag to test URLs for validation
:param headers: optional headers to send with any web requests
:type headers dict
:param timeout: optional timeout for web requests
:typ... | ronkyuu/webmention.py | def discoverEndpoint(url, test_urls=True, headers={}, timeout=None, request=None, debug=False):
"""Discover any WebMention endpoint for a given URL.
:param link: URL to discover WebMention endpoint
:param test_urls: optional flag to test URLs for validation
:param headers: optional headers to send with... | def discoverEndpoint(url, test_urls=True, headers={}, timeout=None, request=None, debug=False):
"""Discover any WebMention endpoint for a given URL.
:param link: URL to discover WebMention endpoint
:param test_urls: optional flag to test URLs for validation
:param headers: optional headers to send with... | [
"Discover",
"any",
"WebMention",
"endpoint",
"for",
"a",
"given",
"URL",
"."
] | bear/ronkyuu | python | https://github.com/bear/ronkyuu/blob/91a05fbe220b661760467b7b3d3d780a9ba28afa/ronkyuu/webmention.py#L134-L185 | [
"def",
"discoverEndpoint",
"(",
"url",
",",
"test_urls",
"=",
"True",
",",
"headers",
"=",
"{",
"}",
",",
"timeout",
"=",
"None",
",",
"request",
"=",
"None",
",",
"debug",
"=",
"False",
")",
":",
"if",
"test_urls",
":",
"URLValidator",
"(",
"message",... | 91a05fbe220b661760467b7b3d3d780a9ba28afa |
train | sendWebmention | Send to the :targetURL: a WebMention for the :sourceURL:
The WebMention will be discovered if not given in the :webmention:
parameter.
:param sourceURL: URL that is referencing :targetURL:
:param targetURL: URL of mentioned post
:param webmention: optional WebMention endpoint
:param test_urls:... | ronkyuu/webmention.py | def sendWebmention(sourceURL, targetURL, webmention=None, test_urls=True, vouchDomain=None,
headers={}, timeout=None, debug=False):
"""Send to the :targetURL: a WebMention for the :sourceURL:
The WebMention will be discovered if not given in the :webmention:
parameter.
:param source... | def sendWebmention(sourceURL, targetURL, webmention=None, test_urls=True, vouchDomain=None,
headers={}, timeout=None, debug=False):
"""Send to the :targetURL: a WebMention for the :sourceURL:
The WebMention will be discovered if not given in the :webmention:
parameter.
:param source... | [
"Send",
"to",
"the",
":",
"targetURL",
":",
"a",
"WebMention",
"for",
"the",
":",
"sourceURL",
":"
] | bear/ronkyuu | python | https://github.com/bear/ronkyuu/blob/91a05fbe220b661760467b7b3d3d780a9ba28afa/ronkyuu/webmention.py#L187-L249 | [
"def",
"sendWebmention",
"(",
"sourceURL",
",",
"targetURL",
",",
"webmention",
"=",
"None",
",",
"test_urls",
"=",
"True",
",",
"vouchDomain",
"=",
"None",
",",
"headers",
"=",
"{",
"}",
",",
"timeout",
"=",
"None",
",",
"debug",
"=",
"False",
")",
":... | 91a05fbe220b661760467b7b3d3d780a9ba28afa |
train | parse_link_header | takes the link header as a string and returns a dictionary with rel values as keys and urls as values
:param link: link header as a string
:rtype: dictionary {rel_name: rel_value} | ronkyuu/tools.py | def parse_link_header(link):
"""takes the link header as a string and returns a dictionary with rel values as keys and urls as values
:param link: link header as a string
:rtype: dictionary {rel_name: rel_value}
"""
rel_dict = {}
for rels in link.split(','):
rel_break = quoted_split(rels... | def parse_link_header(link):
"""takes the link header as a string and returns a dictionary with rel values as keys and urls as values
:param link: link header as a string
:rtype: dictionary {rel_name: rel_value}
"""
rel_dict = {}
for rels in link.split(','):
rel_break = quoted_split(rels... | [
"takes",
"the",
"link",
"header",
"as",
"a",
"string",
"and",
"returns",
"a",
"dictionary",
"with",
"rel",
"values",
"as",
"keys",
"and",
"urls",
"as",
"values",
":",
"param",
"link",
":",
"link",
"header",
"as",
"a",
"string",
":",
"rtype",
":",
"dict... | bear/ronkyuu | python | https://github.com/bear/ronkyuu/blob/91a05fbe220b661760467b7b3d3d780a9ba28afa/ronkyuu/tools.py#L86-L104 | [
"def",
"parse_link_header",
"(",
"link",
")",
":",
"rel_dict",
"=",
"{",
"}",
"for",
"rels",
"in",
"link",
".",
"split",
"(",
"','",
")",
":",
"rel_break",
"=",
"quoted_split",
"(",
"rels",
",",
"';'",
")",
"try",
":",
"rel_url",
"=",
"re",
".",
"s... | 91a05fbe220b661760467b7b3d3d780a9ba28afa |
train | findRelMe | Find all <a /> elements in the given html for a post.
If any have an href attribute that is rel="me" then include
it in the result.
:param sourceURL: the URL for the post we are scanning
:rtype: dictionary of RelMe references | ronkyuu/relme.py | def findRelMe(sourceURL):
"""Find all <a /> elements in the given html for a post.
If any have an href attribute that is rel="me" then include
it in the result.
:param sourceURL: the URL for the post we are scanning
:rtype: dictionary of RelMe references
"""
r = requests.get(sourceURL)
... | def findRelMe(sourceURL):
"""Find all <a /> elements in the given html for a post.
If any have an href attribute that is rel="me" then include
it in the result.
:param sourceURL: the URL for the post we are scanning
:rtype: dictionary of RelMe references
"""
r = requests.get(sourceURL)
... | [
"Find",
"all",
"<a",
"/",
">",
"elements",
"in",
"the",
"given",
"html",
"for",
"a",
"post",
"."
] | bear/ronkyuu | python | https://github.com/bear/ronkyuu/blob/91a05fbe220b661760467b7b3d3d780a9ba28afa/ronkyuu/relme.py#L63-L89 | [
"def",
"findRelMe",
"(",
"sourceURL",
")",
":",
"r",
"=",
"requests",
".",
"get",
"(",
"sourceURL",
")",
"result",
"=",
"{",
"'status'",
":",
"r",
".",
"status_code",
",",
"'headers'",
":",
"r",
".",
"headers",
",",
"'history'",
":",
"r",
".",
"histo... | 91a05fbe220b661760467b7b3d3d780a9ba28afa |
train | confirmRelMe | Determine if a given :resourceURL: is authoritative for the :profileURL:
TODO add https/http filtering for those who wish to limit/restrict urls to match fully
TODO add code to ensure that each item in the redirect chain is authoritative
:param profileURL: URL of the user
:param resourceURL: URL of th... | ronkyuu/relme.py | def confirmRelMe(profileURL, resourceURL, profileRelMes=None, resourceRelMes=None):
"""Determine if a given :resourceURL: is authoritative for the :profileURL:
TODO add https/http filtering for those who wish to limit/restrict urls to match fully
TODO add code to ensure that each item in the redirect chain... | def confirmRelMe(profileURL, resourceURL, profileRelMes=None, resourceRelMes=None):
"""Determine if a given :resourceURL: is authoritative for the :profileURL:
TODO add https/http filtering for those who wish to limit/restrict urls to match fully
TODO add code to ensure that each item in the redirect chain... | [
"Determine",
"if",
"a",
"given",
":",
"resourceURL",
":",
"is",
"authoritative",
"for",
"the",
":",
"profileURL",
":"
] | bear/ronkyuu | python | https://github.com/bear/ronkyuu/blob/91a05fbe220b661760467b7b3d3d780a9ba28afa/ronkyuu/relme.py#L92-L119 | [
"def",
"confirmRelMe",
"(",
"profileURL",
",",
"resourceURL",
",",
"profileRelMes",
"=",
"None",
",",
"resourceRelMes",
"=",
"None",
")",
":",
"result",
"=",
"False",
"profile",
"=",
"normalizeURL",
"(",
"profileURL",
")",
"if",
"profileRelMes",
"is",
"None",
... | 91a05fbe220b661760467b7b3d3d780a9ba28afa |
train | indent_text | Indent every line of text in a newline-delimited string | bread/utils.py | def indent_text(string, indent_level=2):
"""Indent every line of text in a newline-delimited string"""
indented_lines = []
indent_spaces = ' ' * indent_level
for line in string.split('\n'):
indented_lines.append(indent_spaces + line)
return '\n'.join(indented_lines) | def indent_text(string, indent_level=2):
"""Indent every line of text in a newline-delimited string"""
indented_lines = []
indent_spaces = ' ' * indent_level
for line in string.split('\n'):
indented_lines.append(indent_spaces + line)
return '\n'.join(indented_lines) | [
"Indent",
"every",
"line",
"of",
"text",
"in",
"a",
"newline",
"-",
"delimited",
"string"
] | alexras/bread | python | https://github.com/alexras/bread/blob/2e131380878c07500167fc12685e7bff1df258a4/bread/utils.py#L1-L10 | [
"def",
"indent_text",
"(",
"string",
",",
"indent_level",
"=",
"2",
")",
":",
"indented_lines",
"=",
"[",
"]",
"indent_spaces",
"=",
"' '",
"*",
"indent_level",
"for",
"line",
"in",
"string",
".",
"split",
"(",
"'\\n'",
")",
":",
"indented_lines",
".",
"... | 2e131380878c07500167fc12685e7bff1df258a4 |
train | download | Download a file using requests.
This is like urllib.request.urlretrieve, but:
- requests validates SSL certificates by default
- you can pass tracker objects to e.g. display a progress bar or calculate
a file hash. | requests_download.py | def download(url, target, headers=None, trackers=()):
"""Download a file using requests.
This is like urllib.request.urlretrieve, but:
- requests validates SSL certificates by default
- you can pass tracker objects to e.g. display a progress bar or calculate
a file hash.
"""
if headers i... | def download(url, target, headers=None, trackers=()):
"""Download a file using requests.
This is like urllib.request.urlretrieve, but:
- requests validates SSL certificates by default
- you can pass tracker objects to e.g. display a progress bar or calculate
a file hash.
"""
if headers i... | [
"Download",
"a",
"file",
"using",
"requests",
"."
] | takluyver/requests_download | python | https://github.com/takluyver/requests_download/blob/bc0412bb930051af21ab1959402abab883c78e76/requests_download.py#L65-L91 | [
"def",
"download",
"(",
"url",
",",
"target",
",",
"headers",
"=",
"None",
",",
"trackers",
"=",
"(",
")",
")",
":",
"if",
"headers",
"is",
"None",
":",
"headers",
"=",
"{",
"}",
"headers",
".",
"setdefault",
"(",
"'user-agent'",
",",
"'requests_downlo... | bc0412bb930051af21ab1959402abab883c78e76 |
train | write | Writes an object created by `parse` to either a file or a bytearray.
If the object doesn't end on a byte boundary, zeroes are appended to it
until it does. | bread/lifecycle.py | def write(parsed_obj, spec=None, filename=None):
"""Writes an object created by `parse` to either a file or a bytearray.
If the object doesn't end on a byte boundary, zeroes are appended to it
until it does.
"""
if not isinstance(parsed_obj, BreadStruct):
raise ValueError(
'Obje... | def write(parsed_obj, spec=None, filename=None):
"""Writes an object created by `parse` to either a file or a bytearray.
If the object doesn't end on a byte boundary, zeroes are appended to it
until it does.
"""
if not isinstance(parsed_obj, BreadStruct):
raise ValueError(
'Obje... | [
"Writes",
"an",
"object",
"created",
"by",
"parse",
"to",
"either",
"a",
"file",
"or",
"a",
"bytearray",
"."
] | alexras/bread | python | https://github.com/alexras/bread/blob/2e131380878c07500167fc12685e7bff1df258a4/bread/lifecycle.py#L41-L56 | [
"def",
"write",
"(",
"parsed_obj",
",",
"spec",
"=",
"None",
",",
"filename",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"parsed_obj",
",",
"BreadStruct",
")",
":",
"raise",
"ValueError",
"(",
"'Object to write must be a structure created '",
"'by br... | 2e131380878c07500167fc12685e7bff1df258a4 |
train | deploy_file | Uploads a file to an S3 bucket, as a public file. | alotofeffort/send.py | def deploy_file(file_path, bucket):
""" Uploads a file to an S3 bucket, as a public file. """
# Paths look like:
# index.html
# css/bootstrap.min.css
logger.info("Deploying {0}".format(file_path))
# Upload the actual file to file_path
k = Key(bucket)
k.key = file_path
try:
... | def deploy_file(file_path, bucket):
""" Uploads a file to an S3 bucket, as a public file. """
# Paths look like:
# index.html
# css/bootstrap.min.css
logger.info("Deploying {0}".format(file_path))
# Upload the actual file to file_path
k = Key(bucket)
k.key = file_path
try:
... | [
"Uploads",
"a",
"file",
"to",
"an",
"S3",
"bucket",
"as",
"a",
"public",
"file",
"."
] | audreyr/alotofeffort | python | https://github.com/audreyr/alotofeffort/blob/06deca82a70fa9896496fd44c8c6f24707396c50/alotofeffort/send.py#L15-L35 | [
"def",
"deploy_file",
"(",
"file_path",
",",
"bucket",
")",
":",
"# Paths look like:",
"# index.html",
"# css/bootstrap.min.css",
"logger",
".",
"info",
"(",
"\"Deploying {0}\"",
".",
"format",
"(",
"file_path",
")",
")",
"# Upload the actual file to file_path",
"k",
... | 06deca82a70fa9896496fd44c8c6f24707396c50 |
train | deploy | Deploy to the configured S3 bucket. | alotofeffort/send.py | def deploy(www_dir, bucket_name):
""" Deploy to the configured S3 bucket. """
# Set up the connection to an S3 bucket.
conn = boto.connect_s3()
bucket = conn.get_bucket(bucket_name)
# Deploy each changed file in www_dir
os.chdir(www_dir)
for root, dirs, files in os.walk('.'):
for f... | def deploy(www_dir, bucket_name):
""" Deploy to the configured S3 bucket. """
# Set up the connection to an S3 bucket.
conn = boto.connect_s3()
bucket = conn.get_bucket(bucket_name)
# Deploy each changed file in www_dir
os.chdir(www_dir)
for root, dirs, files in os.walk('.'):
for f... | [
"Deploy",
"to",
"the",
"configured",
"S3",
"bucket",
"."
] | audreyr/alotofeffort | python | https://github.com/audreyr/alotofeffort/blob/06deca82a70fa9896496fd44c8c6f24707396c50/alotofeffort/send.py#L38-L67 | [
"def",
"deploy",
"(",
"www_dir",
",",
"bucket_name",
")",
":",
"# Set up the connection to an S3 bucket.",
"conn",
"=",
"boto",
".",
"connect_s3",
"(",
")",
"bucket",
"=",
"conn",
".",
"get_bucket",
"(",
"bucket_name",
")",
"# Deploy each changed file in www_dir",
"... | 06deca82a70fa9896496fd44c8c6f24707396c50 |
train | has_changed_since_last_deploy | Checks if a file has changed since the last time it was deployed.
:param file_path: Path to file which should be checked. Should be relative
from root of bucket.
:param bucket_name: Name of S3 bucket to check against.
:returns: True if the file has changed, else False. | alotofeffort/send.py | def has_changed_since_last_deploy(file_path, bucket):
"""
Checks if a file has changed since the last time it was deployed.
:param file_path: Path to file which should be checked. Should be relative
from root of bucket.
:param bucket_name: Name of S3 bucket to check against.
:... | def has_changed_since_last_deploy(file_path, bucket):
"""
Checks if a file has changed since the last time it was deployed.
:param file_path: Path to file which should be checked. Should be relative
from root of bucket.
:param bucket_name: Name of S3 bucket to check against.
:... | [
"Checks",
"if",
"a",
"file",
"has",
"changed",
"since",
"the",
"last",
"time",
"it",
"was",
"deployed",
"."
] | audreyr/alotofeffort | python | https://github.com/audreyr/alotofeffort/blob/06deca82a70fa9896496fd44c8c6f24707396c50/alotofeffort/send.py#L70-L105 | [
"def",
"has_changed_since_last_deploy",
"(",
"file_path",
",",
"bucket",
")",
":",
"msg",
"=",
"\"Checking if {0} has changed since last deploy.\"",
".",
"format",
"(",
"file_path",
")",
"logger",
".",
"debug",
"(",
"msg",
")",
"with",
"open",
"(",
"file_path",
")... | 06deca82a70fa9896496fd44c8c6f24707396c50 |
train | main | Entry point for the package, as defined in setup.py. | alotofeffort/main.py | def main():
""" Entry point for the package, as defined in setup.py. """
# Log info and above to console
logging.basicConfig(
format='%(levelname)s: %(message)s', level=logging.INFO)
# Get command line input/output arguments
msg = 'Instantly deploy static HTML sites to S3 at the command li... | def main():
""" Entry point for the package, as defined in setup.py. """
# Log info and above to console
logging.basicConfig(
format='%(levelname)s: %(message)s', level=logging.INFO)
# Get command line input/output arguments
msg = 'Instantly deploy static HTML sites to S3 at the command li... | [
"Entry",
"point",
"for",
"the",
"package",
"as",
"defined",
"in",
"setup",
".",
"py",
"."
] | audreyr/alotofeffort | python | https://github.com/audreyr/alotofeffort/blob/06deca82a70fa9896496fd44c8c6f24707396c50/alotofeffort/main.py#L9-L30 | [
"def",
"main",
"(",
")",
":",
"# Log info and above to console",
"logging",
".",
"basicConfig",
"(",
"format",
"=",
"'%(levelname)s: %(message)s'",
",",
"level",
"=",
"logging",
".",
"INFO",
")",
"# Get command line input/output arguments",
"msg",
"=",
"'Instantly deplo... | 06deca82a70fa9896496fd44c8c6f24707396c50 |
train | SikuliLibrary.start_sikuli_process | This keyword is used to start sikuli java process.
If library is inited with mode "OLD", sikuli java process is started automatically.
If library is inited with mode "NEW", this keyword should be used.
:param port: port of sikuli java process, if value is None or 0, a random free port will be u... | src/python/sikuli.py | def start_sikuli_process(self, port=None):
"""
This keyword is used to start sikuli java process.
If library is inited with mode "OLD", sikuli java process is started automatically.
If library is inited with mode "NEW", this keyword should be used.
:param port: port of sikuli ja... | def start_sikuli_process(self, port=None):
"""
This keyword is used to start sikuli java process.
If library is inited with mode "OLD", sikuli java process is started automatically.
If library is inited with mode "NEW", this keyword should be used.
:param port: port of sikuli ja... | [
"This",
"keyword",
"is",
"used",
"to",
"start",
"sikuli",
"java",
"process",
".",
"If",
"library",
"is",
"inited",
"with",
"mode",
"OLD",
"sikuli",
"java",
"process",
"is",
"started",
"automatically",
".",
"If",
"library",
"is",
"inited",
"with",
"mode",
"... | rainmanwy/robotframework-SikuliLibrary | python | https://github.com/rainmanwy/robotframework-SikuliLibrary/blob/992874dd96b139246a62fb07ec763e0a4caffad8/src/python/sikuli.py#L65-L93 | [
"def",
"start_sikuli_process",
"(",
"self",
",",
"port",
"=",
"None",
")",
":",
"if",
"port",
"is",
"None",
"or",
"int",
"(",
"port",
")",
"==",
"0",
":",
"port",
"=",
"self",
".",
"_get_free_tcp_port",
"(",
")",
"self",
".",
"port",
"=",
"port",
"... | 992874dd96b139246a62fb07ec763e0a4caffad8 |
train | ObtainExpiringAuthToken.post | Respond to POSTed username/password with token. | rest_framework_expiring_authtoken/views.py | def post(self, request):
"""Respond to POSTed username/password with token."""
serializer = AuthTokenSerializer(data=request.data)
if serializer.is_valid():
token, _ = ExpiringToken.objects.get_or_create(
user=serializer.validated_data['user']
)
... | def post(self, request):
"""Respond to POSTed username/password with token."""
serializer = AuthTokenSerializer(data=request.data)
if serializer.is_valid():
token, _ = ExpiringToken.objects.get_or_create(
user=serializer.validated_data['user']
)
... | [
"Respond",
"to",
"POSTed",
"username",
"/",
"password",
"with",
"token",
"."
] | JamesRitchie/django-rest-framework-expiring-tokens | python | https://github.com/JamesRitchie/django-rest-framework-expiring-tokens/blob/e62f1f92a621575174172e970da624d367ac0cf6/rest_framework_expiring_authtoken/views.py#L20-L39 | [
"def",
"post",
"(",
"self",
",",
"request",
")",
":",
"serializer",
"=",
"AuthTokenSerializer",
"(",
"data",
"=",
"request",
".",
"data",
")",
"if",
"serializer",
".",
"is_valid",
"(",
")",
":",
"token",
",",
"_",
"=",
"ExpiringToken",
".",
"objects",
... | e62f1f92a621575174172e970da624d367ac0cf6 |
train | TokenSettings.EXPIRING_TOKEN_LIFESPAN | Return the allowed lifespan of a token as a TimeDelta object.
Defaults to 30 days. | rest_framework_expiring_authtoken/settings.py | def EXPIRING_TOKEN_LIFESPAN(self):
"""
Return the allowed lifespan of a token as a TimeDelta object.
Defaults to 30 days.
"""
try:
val = settings.EXPIRING_TOKEN_LIFESPAN
except AttributeError:
val = timedelta(days=30)
return val | def EXPIRING_TOKEN_LIFESPAN(self):
"""
Return the allowed lifespan of a token as a TimeDelta object.
Defaults to 30 days.
"""
try:
val = settings.EXPIRING_TOKEN_LIFESPAN
except AttributeError:
val = timedelta(days=30)
return val | [
"Return",
"the",
"allowed",
"lifespan",
"of",
"a",
"token",
"as",
"a",
"TimeDelta",
"object",
"."
] | JamesRitchie/django-rest-framework-expiring-tokens | python | https://github.com/JamesRitchie/django-rest-framework-expiring-tokens/blob/e62f1f92a621575174172e970da624d367ac0cf6/rest_framework_expiring_authtoken/settings.py#L16-L27 | [
"def",
"EXPIRING_TOKEN_LIFESPAN",
"(",
"self",
")",
":",
"try",
":",
"val",
"=",
"settings",
".",
"EXPIRING_TOKEN_LIFESPAN",
"except",
"AttributeError",
":",
"val",
"=",
"timedelta",
"(",
"days",
"=",
"30",
")",
"return",
"val"
] | e62f1f92a621575174172e970da624d367ac0cf6 |
train | ExpiringToken.expired | Return boolean indicating token expiration. | rest_framework_expiring_authtoken/models.py | def expired(self):
"""Return boolean indicating token expiration."""
now = timezone.now()
if self.created < now - token_settings.EXPIRING_TOKEN_LIFESPAN:
return True
return False | def expired(self):
"""Return boolean indicating token expiration."""
now = timezone.now()
if self.created < now - token_settings.EXPIRING_TOKEN_LIFESPAN:
return True
return False | [
"Return",
"boolean",
"indicating",
"token",
"expiration",
"."
] | JamesRitchie/django-rest-framework-expiring-tokens | python | https://github.com/JamesRitchie/django-rest-framework-expiring-tokens/blob/e62f1f92a621575174172e970da624d367ac0cf6/rest_framework_expiring_authtoken/models.py#L21-L26 | [
"def",
"expired",
"(",
"self",
")",
":",
"now",
"=",
"timezone",
".",
"now",
"(",
")",
"if",
"self",
".",
"created",
"<",
"now",
"-",
"token_settings",
".",
"EXPIRING_TOKEN_LIFESPAN",
":",
"return",
"True",
"return",
"False"
] | e62f1f92a621575174172e970da624d367ac0cf6 |
train | unicode_is_punctuation | Test if a token is made entirely of Unicode characters of the following
classes:
- P: punctuation
- S: symbols
- Z: separators
- M: combining marks
- C: control characters
>>> unicode_is_punctuation('word')
False
>>> unicode_is_punctuation('。')
True
>>> unicode_is_punctuati... | metanl/extprocess.py | def unicode_is_punctuation(text):
"""
Test if a token is made entirely of Unicode characters of the following
classes:
- P: punctuation
- S: symbols
- Z: separators
- M: combining marks
- C: control characters
>>> unicode_is_punctuation('word')
False
>>> unicode_is_punctuat... | def unicode_is_punctuation(text):
"""
Test if a token is made entirely of Unicode characters of the following
classes:
- P: punctuation
- S: symbols
- Z: separators
- M: combining marks
- C: control characters
>>> unicode_is_punctuation('word')
False
>>> unicode_is_punctuat... | [
"Test",
"if",
"a",
"token",
"is",
"made",
"entirely",
"of",
"Unicode",
"characters",
"of",
"the",
"following",
"classes",
":"
] | commonsense/metanl | python | https://github.com/commonsense/metanl/blob/4b9ae8353489cc409bebd7e1fe10ab5b527b078e/metanl/extprocess.py#L246-L272 | [
"def",
"unicode_is_punctuation",
"(",
"text",
")",
":",
"for",
"char",
"in",
"str_func",
"(",
"text",
")",
":",
"category",
"=",
"unicodedata",
".",
"category",
"(",
"char",
")",
"[",
"0",
"]",
"if",
"category",
"not",
"in",
"'PSZMC'",
":",
"return",
"... | 4b9ae8353489cc409bebd7e1fe10ab5b527b078e |
train | ProcessWrapper.process | Store the actual process in _process. If it doesn't exist yet, create
it. | metanl/extprocess.py | def process(self):
"""
Store the actual process in _process. If it doesn't exist yet, create
it.
"""
if hasattr(self, '_process'):
return self._process
else:
self._process = self._get_process()
return self._process | def process(self):
"""
Store the actual process in _process. If it doesn't exist yet, create
it.
"""
if hasattr(self, '_process'):
return self._process
else:
self._process = self._get_process()
return self._process | [
"Store",
"the",
"actual",
"process",
"in",
"_process",
".",
"If",
"it",
"doesn",
"t",
"exist",
"yet",
"create",
"it",
"."
] | commonsense/metanl | python | https://github.com/commonsense/metanl/blob/4b9ae8353489cc409bebd7e1fe10ab5b527b078e/metanl/extprocess.py#L52-L61 | [
"def",
"process",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'_process'",
")",
":",
"return",
"self",
".",
"_process",
"else",
":",
"self",
".",
"_process",
"=",
"self",
".",
"_get_process",
"(",
")",
"return",
"self",
".",
"_process"
] | 4b9ae8353489cc409bebd7e1fe10ab5b527b078e |
train | ProcessWrapper._get_process | Create the process by running the specified command. | metanl/extprocess.py | def _get_process(self):
"""
Create the process by running the specified command.
"""
command = self._get_command()
return subprocess.Popen(command, bufsize=-1, close_fds=True,
stdout=subprocess.PIPE,
stdin=subprocess... | def _get_process(self):
"""
Create the process by running the specified command.
"""
command = self._get_command()
return subprocess.Popen(command, bufsize=-1, close_fds=True,
stdout=subprocess.PIPE,
stdin=subprocess... | [
"Create",
"the",
"process",
"by",
"running",
"the",
"specified",
"command",
"."
] | commonsense/metanl | python | https://github.com/commonsense/metanl/blob/4b9ae8353489cc409bebd7e1fe10ab5b527b078e/metanl/extprocess.py#L70-L77 | [
"def",
"_get_process",
"(",
"self",
")",
":",
"command",
"=",
"self",
".",
"_get_command",
"(",
")",
"return",
"subprocess",
".",
"Popen",
"(",
"command",
",",
"bufsize",
"=",
"-",
"1",
",",
"close_fds",
"=",
"True",
",",
"stdout",
"=",
"subprocess",
"... | 4b9ae8353489cc409bebd7e1fe10ab5b527b078e |
train | ProcessWrapper.tokenize_list | Split a text into separate words. | metanl/extprocess.py | def tokenize_list(self, text):
"""
Split a text into separate words.
"""
return [self.get_record_token(record) for record in self.analyze(text)] | def tokenize_list(self, text):
"""
Split a text into separate words.
"""
return [self.get_record_token(record) for record in self.analyze(text)] | [
"Split",
"a",
"text",
"into",
"separate",
"words",
"."
] | commonsense/metanl | python | https://github.com/commonsense/metanl/blob/4b9ae8353489cc409bebd7e1fe10ab5b527b078e/metanl/extprocess.py#L117-L121 | [
"def",
"tokenize_list",
"(",
"self",
",",
"text",
")",
":",
"return",
"[",
"self",
".",
"get_record_token",
"(",
"record",
")",
"for",
"record",
"in",
"self",
".",
"analyze",
"(",
"text",
")",
"]"
] | 4b9ae8353489cc409bebd7e1fe10ab5b527b078e |
train | ProcessWrapper.is_stopword | Determine whether a single word is a stopword, or whether a short
phrase is made entirely of stopwords, disregarding context.
Use of this function should be avoided; it's better to give the text
in context and let the process determine which words are the stopwords. | metanl/extprocess.py | def is_stopword(self, text):
"""
Determine whether a single word is a stopword, or whether a short
phrase is made entirely of stopwords, disregarding context.
Use of this function should be avoided; it's better to give the text
in context and let the process determine which word... | def is_stopword(self, text):
"""
Determine whether a single word is a stopword, or whether a short
phrase is made entirely of stopwords, disregarding context.
Use of this function should be avoided; it's better to give the text
in context and let the process determine which word... | [
"Determine",
"whether",
"a",
"single",
"word",
"is",
"a",
"stopword",
"or",
"whether",
"a",
"short",
"phrase",
"is",
"made",
"entirely",
"of",
"stopwords",
"disregarding",
"context",
"."
] | commonsense/metanl | python | https://github.com/commonsense/metanl/blob/4b9ae8353489cc409bebd7e1fe10ab5b527b078e/metanl/extprocess.py#L144-L157 | [
"def",
"is_stopword",
"(",
"self",
",",
"text",
")",
":",
"found_content_word",
"=",
"False",
"for",
"record",
"in",
"self",
".",
"analyze",
"(",
"text",
")",
":",
"if",
"not",
"self",
".",
"is_stopword_record",
"(",
"record",
")",
":",
"found_content_word... | 4b9ae8353489cc409bebd7e1fe10ab5b527b078e |
train | ProcessWrapper.normalize_list | Get a canonical list representation of text, with words
separated and reduced to their base forms.
TODO: use the cache. | metanl/extprocess.py | def normalize_list(self, text, cache=None):
"""
Get a canonical list representation of text, with words
separated and reduced to their base forms.
TODO: use the cache.
"""
words = []
analysis = self.analyze(text)
for record in analysis:
if not... | def normalize_list(self, text, cache=None):
"""
Get a canonical list representation of text, with words
separated and reduced to their base forms.
TODO: use the cache.
"""
words = []
analysis = self.analyze(text)
for record in analysis:
if not... | [
"Get",
"a",
"canonical",
"list",
"representation",
"of",
"text",
"with",
"words",
"separated",
"and",
"reduced",
"to",
"their",
"base",
"forms",
"."
] | commonsense/metanl | python | https://github.com/commonsense/metanl/blob/4b9ae8353489cc409bebd7e1fe10ab5b527b078e/metanl/extprocess.py#L171-L186 | [
"def",
"normalize_list",
"(",
"self",
",",
"text",
",",
"cache",
"=",
"None",
")",
":",
"words",
"=",
"[",
"]",
"analysis",
"=",
"self",
".",
"analyze",
"(",
"text",
")",
"for",
"record",
"in",
"analysis",
":",
"if",
"not",
"self",
".",
"is_stopword_... | 4b9ae8353489cc409bebd7e1fe10ab5b527b078e |
train | ProcessWrapper.tag_and_stem | Given some text, return a sequence of (stem, pos, text) triples as
appropriate for the reader. `pos` can be as general or specific as
necessary (for example, it might label all parts of speech, or it might
only distinguish function words from others).
Twitter-style hashtags and at-menti... | metanl/extprocess.py | def tag_and_stem(self, text, cache=None):
"""
Given some text, return a sequence of (stem, pos, text) triples as
appropriate for the reader. `pos` can be as general or specific as
necessary (for example, it might label all parts of speech, or it might
only distinguish function wo... | def tag_and_stem(self, text, cache=None):
"""
Given some text, return a sequence of (stem, pos, text) triples as
appropriate for the reader. `pos` can be as general or specific as
necessary (for example, it might label all parts of speech, or it might
only distinguish function wo... | [
"Given",
"some",
"text",
"return",
"a",
"sequence",
"of",
"(",
"stem",
"pos",
"text",
")",
"triples",
"as",
"appropriate",
"for",
"the",
"reader",
".",
"pos",
"can",
"be",
"as",
"general",
"or",
"specific",
"as",
"necessary",
"(",
"for",
"example",
"it",... | commonsense/metanl | python | https://github.com/commonsense/metanl/blob/4b9ae8353489cc409bebd7e1fe10ab5b527b078e/metanl/extprocess.py#L197-L222 | [
"def",
"tag_and_stem",
"(",
"self",
",",
"text",
",",
"cache",
"=",
"None",
")",
":",
"analysis",
"=",
"self",
".",
"analyze",
"(",
"text",
")",
"triples",
"=",
"[",
"]",
"for",
"record",
"in",
"analysis",
":",
"root",
"=",
"self",
".",
"get_record_r... | 4b9ae8353489cc409bebd7e1fe10ab5b527b078e |
train | ProcessWrapper.extract_phrases | Given some text, extract phrases of up to 2 content words,
and map their normalized form to the complete phrase. | metanl/extprocess.py | def extract_phrases(self, text):
"""
Given some text, extract phrases of up to 2 content words,
and map their normalized form to the complete phrase.
"""
analysis = self.analyze(text)
for pos1 in range(len(analysis)):
rec1 = analysis[pos1]
if not s... | def extract_phrases(self, text):
"""
Given some text, extract phrases of up to 2 content words,
and map their normalized form to the complete phrase.
"""
analysis = self.analyze(text)
for pos1 in range(len(analysis)):
rec1 = analysis[pos1]
if not s... | [
"Given",
"some",
"text",
"extract",
"phrases",
"of",
"up",
"to",
"2",
"content",
"words",
"and",
"map",
"their",
"normalized",
"form",
"to",
"the",
"complete",
"phrase",
"."
] | commonsense/metanl | python | https://github.com/commonsense/metanl/blob/4b9ae8353489cc409bebd7e1fe10ab5b527b078e/metanl/extprocess.py#L224-L243 | [
"def",
"extract_phrases",
"(",
"self",
",",
"text",
")",
":",
"analysis",
"=",
"self",
".",
"analyze",
"(",
"text",
")",
"for",
"pos1",
"in",
"range",
"(",
"len",
"(",
"analysis",
")",
")",
":",
"rec1",
"=",
"analysis",
"[",
"pos1",
"]",
"if",
"not... | 4b9ae8353489cc409bebd7e1fe10ab5b527b078e |
train | to_kana | Use MeCab to turn any text into its phonetic spelling, as katakana
separated by spaces. | metanl/mecab.py | def to_kana(text):
"""
Use MeCab to turn any text into its phonetic spelling, as katakana
separated by spaces.
"""
records = MECAB.analyze(text)
kana = []
for record in records:
if record.pronunciation:
kana.append(record.pronunciation)
elif record.reading:
... | def to_kana(text):
"""
Use MeCab to turn any text into its phonetic spelling, as katakana
separated by spaces.
"""
records = MECAB.analyze(text)
kana = []
for record in records:
if record.pronunciation:
kana.append(record.pronunciation)
elif record.reading:
... | [
"Use",
"MeCab",
"to",
"turn",
"any",
"text",
"into",
"its",
"phonetic",
"spelling",
"as",
"katakana",
"separated",
"by",
"spaces",
"."
] | commonsense/metanl | python | https://github.com/commonsense/metanl/blob/4b9ae8353489cc409bebd7e1fe10ab5b527b078e/metanl/mecab.py#L208-L222 | [
"def",
"to_kana",
"(",
"text",
")",
":",
"records",
"=",
"MECAB",
".",
"analyze",
"(",
"text",
")",
"kana",
"=",
"[",
"]",
"for",
"record",
"in",
"records",
":",
"if",
"record",
".",
"pronunciation",
":",
"kana",
".",
"append",
"(",
"record",
".",
... | 4b9ae8353489cc409bebd7e1fe10ab5b527b078e |
train | get_kana_info | Return two things about each character:
- Its transliterated value (in Roman characters, if it's a kana)
- A class of characters indicating how it affects the romanization | metanl/mecab.py | def get_kana_info(char):
"""
Return two things about each character:
- Its transliterated value (in Roman characters, if it's a kana)
- A class of characters indicating how it affects the romanization
"""
try:
name = unicodedata.name(char)
except ValueError:
return char, NOT... | def get_kana_info(char):
"""
Return two things about each character:
- Its transliterated value (in Roman characters, if it's a kana)
- A class of characters indicating how it affects the romanization
"""
try:
name = unicodedata.name(char)
except ValueError:
return char, NOT... | [
"Return",
"two",
"things",
"about",
"each",
"character",
":"
] | commonsense/metanl | python | https://github.com/commonsense/metanl/blob/4b9ae8353489cc409bebd7e1fe10ab5b527b078e/metanl/mecab.py#L225-L268 | [
"def",
"get_kana_info",
"(",
"char",
")",
":",
"try",
":",
"name",
"=",
"unicodedata",
".",
"name",
"(",
"char",
")",
"except",
"ValueError",
":",
"return",
"char",
",",
"NOT_KANA",
"# The names we're dealing with will probably look like",
"# \"KATAKANA CHARACTER ZI\"... | 4b9ae8353489cc409bebd7e1fe10ab5b527b078e |
train | MeCabWrapper.analyze | Runs a line of text through MeCab, and returns the results as a
list of lists ("records") that contain the MeCab analysis of each
word. | metanl/mecab.py | def analyze(self, text):
"""
Runs a line of text through MeCab, and returns the results as a
list of lists ("records") that contain the MeCab analysis of each
word.
"""
try:
self.process # make sure things are loaded
text = render_safe(text).repla... | def analyze(self, text):
"""
Runs a line of text through MeCab, and returns the results as a
list of lists ("records") that contain the MeCab analysis of each
word.
"""
try:
self.process # make sure things are loaded
text = render_safe(text).repla... | [
"Runs",
"a",
"line",
"of",
"text",
"through",
"MeCab",
"and",
"returns",
"the",
"results",
"as",
"a",
"list",
"of",
"lists",
"(",
"records",
")",
"that",
"contain",
"the",
"MeCab",
"analysis",
"of",
"each",
"word",
"."
] | commonsense/metanl | python | https://github.com/commonsense/metanl/blob/4b9ae8353489cc409bebd7e1fe10ab5b527b078e/metanl/mecab.py#L125-L160 | [
"def",
"analyze",
"(",
"self",
",",
"text",
")",
":",
"try",
":",
"self",
".",
"process",
"# make sure things are loaded",
"text",
"=",
"render_safe",
"(",
"text",
")",
".",
"replace",
"(",
"'\\n'",
",",
"' '",
")",
".",
"lower",
"(",
")",
"results",
"... | 4b9ae8353489cc409bebd7e1fe10ab5b527b078e |
train | MeCabWrapper.is_stopword_record | Determine whether a single MeCab record represents a stopword.
This mostly determines words to strip based on their parts of speech.
If common_words is set to True (default), it will also strip common
verbs and nouns such as くる and よう. If more_stopwords is True, it
will look at the sub-... | metanl/mecab.py | def is_stopword_record(self, record):
"""
Determine whether a single MeCab record represents a stopword.
This mostly determines words to strip based on their parts of speech.
If common_words is set to True (default), it will also strip common
verbs and nouns such as くる and よう. I... | def is_stopword_record(self, record):
"""
Determine whether a single MeCab record represents a stopword.
This mostly determines words to strip based on their parts of speech.
If common_words is set to True (default), it will also strip common
verbs and nouns such as くる and よう. I... | [
"Determine",
"whether",
"a",
"single",
"MeCab",
"record",
"represents",
"a",
"stopword",
"."
] | commonsense/metanl | python | https://github.com/commonsense/metanl/blob/4b9ae8353489cc409bebd7e1fe10ab5b527b078e/metanl/mecab.py#L162-L178 | [
"def",
"is_stopword_record",
"(",
"self",
",",
"record",
")",
":",
"# preserve negations",
"if",
"record",
".",
"root",
"==",
"'ない':",
"",
"return",
"False",
"return",
"(",
"record",
".",
"pos",
"in",
"STOPWORD_CATEGORIES",
"or",
"record",
".",
"subclass1",
... | 4b9ae8353489cc409bebd7e1fe10ab5b527b078e |
train | MeCabWrapper.get_record_pos | Given a record, get the word's part of speech.
Here we're going to return MeCab's part of speech (written in
Japanese), though if it's a stopword we prefix the part of speech
with '~'. | metanl/mecab.py | def get_record_pos(self, record):
"""
Given a record, get the word's part of speech.
Here we're going to return MeCab's part of speech (written in
Japanese), though if it's a stopword we prefix the part of speech
with '~'.
"""
if self.is_stopword_record(record):
... | def get_record_pos(self, record):
"""
Given a record, get the word's part of speech.
Here we're going to return MeCab's part of speech (written in
Japanese), though if it's a stopword we prefix the part of speech
with '~'.
"""
if self.is_stopword_record(record):
... | [
"Given",
"a",
"record",
"get",
"the",
"word",
"s",
"part",
"of",
"speech",
"."
] | commonsense/metanl | python | https://github.com/commonsense/metanl/blob/4b9ae8353489cc409bebd7e1fe10ab5b527b078e/metanl/mecab.py#L180-L191 | [
"def",
"get_record_pos",
"(",
"self",
",",
"record",
")",
":",
"if",
"self",
".",
"is_stopword_record",
"(",
"record",
")",
":",
"return",
"'~'",
"+",
"record",
".",
"pos",
"else",
":",
"return",
"record",
".",
"pos"
] | 4b9ae8353489cc409bebd7e1fe10ab5b527b078e |
train | FreelingWrapper.analyze | Run text through the external process, and get a list of lists
("records") that contain the analysis of each word. | metanl/freeling.py | def analyze(self, text):
"""
Run text through the external process, and get a list of lists
("records") that contain the analysis of each word.
"""
try:
text = render_safe(text).strip()
if not text:
return []
chunks = text.split... | def analyze(self, text):
"""
Run text through the external process, and get a list of lists
("records") that contain the analysis of each word.
"""
try:
text = render_safe(text).strip()
if not text:
return []
chunks = text.split... | [
"Run",
"text",
"through",
"the",
"external",
"process",
"and",
"get",
"a",
"list",
"of",
"lists",
"(",
"records",
")",
"that",
"contain",
"the",
"analysis",
"of",
"each",
"word",
"."
] | commonsense/metanl | python | https://github.com/commonsense/metanl/blob/4b9ae8353489cc409bebd7e1fe10ab5b527b078e/metanl/freeling.py#L76-L104 | [
"def",
"analyze",
"(",
"self",
",",
"text",
")",
":",
"try",
":",
"text",
"=",
"render_safe",
"(",
"text",
")",
".",
"strip",
"(",
")",
"if",
"not",
"text",
":",
"return",
"[",
"]",
"chunks",
"=",
"text",
".",
"split",
"(",
"'\\n'",
")",
"results... | 4b9ae8353489cc409bebd7e1fe10ab5b527b078e |
train | untokenize | Untokenizing a text undoes the tokenizing operation, restoring
punctuation and spaces to the places that people expect them to be.
Ideally, `untokenize(tokenize(text))` should be identical to `text`,
except for line breaks. | metanl/token_utils.py | def untokenize(words):
"""
Untokenizing a text undoes the tokenizing operation, restoring
punctuation and spaces to the places that people expect them to be.
Ideally, `untokenize(tokenize(text))` should be identical to `text`,
except for line breaks.
"""
text = ' '.join(words)
step1 = t... | def untokenize(words):
"""
Untokenizing a text undoes the tokenizing operation, restoring
punctuation and spaces to the places that people expect them to be.
Ideally, `untokenize(tokenize(text))` should be identical to `text`,
except for line breaks.
"""
text = ' '.join(words)
step1 = t... | [
"Untokenizing",
"a",
"text",
"undoes",
"the",
"tokenizing",
"operation",
"restoring",
"punctuation",
"and",
"spaces",
"to",
"the",
"places",
"that",
"people",
"expect",
"them",
"to",
"be",
"."
] | commonsense/metanl | python | https://github.com/commonsense/metanl/blob/4b9ae8353489cc409bebd7e1fe10ab5b527b078e/metanl/token_utils.py#L28-L44 | [
"def",
"untokenize",
"(",
"words",
")",
":",
"text",
"=",
"' '",
".",
"join",
"(",
"words",
")",
"step1",
"=",
"text",
".",
"replace",
"(",
"\"`` \"",
",",
"'\"'",
")",
".",
"replace",
"(",
"\" ''\"",
",",
"'\"'",
")",
".",
"replace",
"(",
"'. . .'... | 4b9ae8353489cc409bebd7e1fe10ab5b527b078e |
train | un_camel_case | r"""
Splits apart words that are written in CamelCase.
Bugs:
- Non-ASCII characters are treated as lowercase letters, even if they are
actually capital letters.
Examples:
>>> un_camel_case('1984ZXSpectrumGames')
'1984 ZX Spectrum Games'
>>> un_camel_case('aaAa aaAaA 0aA AAAa!AAA'... | metanl/token_utils.py | def un_camel_case(text):
r"""
Splits apart words that are written in CamelCase.
Bugs:
- Non-ASCII characters are treated as lowercase letters, even if they are
actually capital letters.
Examples:
>>> un_camel_case('1984ZXSpectrumGames')
'1984 ZX Spectrum Games'
>>> un_camel_ca... | def un_camel_case(text):
r"""
Splits apart words that are written in CamelCase.
Bugs:
- Non-ASCII characters are treated as lowercase letters, even if they are
actually capital letters.
Examples:
>>> un_camel_case('1984ZXSpectrumGames')
'1984 ZX Spectrum Games'
>>> un_camel_ca... | [
"r",
"Splits",
"apart",
"words",
"that",
"are",
"written",
"in",
"CamelCase",
"."
] | commonsense/metanl | python | https://github.com/commonsense/metanl/blob/4b9ae8353489cc409bebd7e1fe10ab5b527b078e/metanl/token_utils.py#L64-L110 | [
"def",
"un_camel_case",
"(",
"text",
")",
":",
"revtext",
"=",
"text",
"[",
":",
":",
"-",
"1",
"]",
"pieces",
"=",
"[",
"]",
"while",
"revtext",
":",
"match",
"=",
"CAMEL_RE",
".",
"match",
"(",
"revtext",
")",
"if",
"match",
":",
"pieces",
".",
... | 4b9ae8353489cc409bebd7e1fe10ab5b527b078e |
train | string_pieces | Takes a (unicode) string and yields pieces of it that are at most `maxlen`
characters, trying to break it at punctuation/whitespace. This is an
important step before using a tokenizer with a maximum buffer size. | metanl/token_utils.py | def string_pieces(s, maxlen=1024):
"""
Takes a (unicode) string and yields pieces of it that are at most `maxlen`
characters, trying to break it at punctuation/whitespace. This is an
important step before using a tokenizer with a maximum buffer size.
"""
if not s:
return
i = 0
wh... | def string_pieces(s, maxlen=1024):
"""
Takes a (unicode) string and yields pieces of it that are at most `maxlen`
characters, trying to break it at punctuation/whitespace. This is an
important step before using a tokenizer with a maximum buffer size.
"""
if not s:
return
i = 0
wh... | [
"Takes",
"a",
"(",
"unicode",
")",
"string",
"and",
"yields",
"pieces",
"of",
"it",
"that",
"are",
"at",
"most",
"maxlen",
"characters",
"trying",
"to",
"break",
"it",
"at",
"punctuation",
"/",
"whitespace",
".",
"This",
"is",
"an",
"important",
"step",
... | commonsense/metanl | python | https://github.com/commonsense/metanl/blob/4b9ae8353489cc409bebd7e1fe10ab5b527b078e/metanl/token_utils.py#L128-L150 | [
"def",
"string_pieces",
"(",
"s",
",",
"maxlen",
"=",
"1024",
")",
":",
"if",
"not",
"s",
":",
"return",
"i",
"=",
"0",
"while",
"True",
":",
"j",
"=",
"i",
"+",
"maxlen",
"if",
"j",
">=",
"len",
"(",
"s",
")",
":",
"yield",
"s",
"[",
"i",
... | 4b9ae8353489cc409bebd7e1fe10ab5b527b078e |
train | _word_badness | Assign a heuristic to possible outputs from Morphy. Minimizing this
heuristic avoids incorrect stems. | metanl/nltk_morphy.py | def _word_badness(word):
"""
Assign a heuristic to possible outputs from Morphy. Minimizing this
heuristic avoids incorrect stems.
"""
if word.endswith('e'):
return len(word) - 2
elif word.endswith('ess'):
return len(word) - 10
elif word.endswith('ss'):
return len(wor... | def _word_badness(word):
"""
Assign a heuristic to possible outputs from Morphy. Minimizing this
heuristic avoids incorrect stems.
"""
if word.endswith('e'):
return len(word) - 2
elif word.endswith('ess'):
return len(word) - 10
elif word.endswith('ss'):
return len(wor... | [
"Assign",
"a",
"heuristic",
"to",
"possible",
"outputs",
"from",
"Morphy",
".",
"Minimizing",
"this",
"heuristic",
"avoids",
"incorrect",
"stems",
"."
] | commonsense/metanl | python | https://github.com/commonsense/metanl/blob/4b9ae8353489cc409bebd7e1fe10ab5b527b078e/metanl/nltk_morphy.py#L88-L100 | [
"def",
"_word_badness",
"(",
"word",
")",
":",
"if",
"word",
".",
"endswith",
"(",
"'e'",
")",
":",
"return",
"len",
"(",
"word",
")",
"-",
"2",
"elif",
"word",
".",
"endswith",
"(",
"'ess'",
")",
":",
"return",
"len",
"(",
"word",
")",
"-",
"10"... | 4b9ae8353489cc409bebd7e1fe10ab5b527b078e |
train | _morphy_best | Get the most likely stem for a word using Morphy, once the input has been
pre-processed by morphy_stem(). | metanl/nltk_morphy.py | def _morphy_best(word, pos=None):
"""
Get the most likely stem for a word using Morphy, once the input has been
pre-processed by morphy_stem().
"""
results = []
if pos is None:
pos = 'nvar'
for pos_item in pos:
results.extend(morphy(word, pos_item))
if not results:
... | def _morphy_best(word, pos=None):
"""
Get the most likely stem for a word using Morphy, once the input has been
pre-processed by morphy_stem().
"""
results = []
if pos is None:
pos = 'nvar'
for pos_item in pos:
results.extend(morphy(word, pos_item))
if not results:
... | [
"Get",
"the",
"most",
"likely",
"stem",
"for",
"a",
"word",
"using",
"Morphy",
"once",
"the",
"input",
"has",
"been",
"pre",
"-",
"processed",
"by",
"morphy_stem",
"()",
"."
] | commonsense/metanl | python | https://github.com/commonsense/metanl/blob/4b9ae8353489cc409bebd7e1fe10ab5b527b078e/metanl/nltk_morphy.py#L103-L116 | [
"def",
"_morphy_best",
"(",
"word",
",",
"pos",
"=",
"None",
")",
":",
"results",
"=",
"[",
"]",
"if",
"pos",
"is",
"None",
":",
"pos",
"=",
"'nvar'",
"for",
"pos_item",
"in",
"pos",
":",
"results",
".",
"extend",
"(",
"morphy",
"(",
"word",
",",
... | 4b9ae8353489cc409bebd7e1fe10ab5b527b078e |
train | morphy_stem | Get the most likely stem for a word. If a part of speech is supplied,
the stem will be more accurate.
Valid parts of speech are:
- 'n' or 'NN' for nouns
- 'v' or 'VB' for verbs
- 'a' or 'JJ' for adjectives
- 'r' or 'RB' for adverbs
Any other part of speech will be treated as unknown. | metanl/nltk_morphy.py | def morphy_stem(word, pos=None):
"""
Get the most likely stem for a word. If a part of speech is supplied,
the stem will be more accurate.
Valid parts of speech are:
- 'n' or 'NN' for nouns
- 'v' or 'VB' for verbs
- 'a' or 'JJ' for adjectives
- 'r' or 'RB' for adverbs
Any other pa... | def morphy_stem(word, pos=None):
"""
Get the most likely stem for a word. If a part of speech is supplied,
the stem will be more accurate.
Valid parts of speech are:
- 'n' or 'NN' for nouns
- 'v' or 'VB' for verbs
- 'a' or 'JJ' for adjectives
- 'r' or 'RB' for adverbs
Any other pa... | [
"Get",
"the",
"most",
"likely",
"stem",
"for",
"a",
"word",
".",
"If",
"a",
"part",
"of",
"speech",
"is",
"supplied",
"the",
"stem",
"will",
"be",
"more",
"accurate",
"."
] | commonsense/metanl | python | https://github.com/commonsense/metanl/blob/4b9ae8353489cc409bebd7e1fe10ab5b527b078e/metanl/nltk_morphy.py#L119-L152 | [
"def",
"morphy_stem",
"(",
"word",
",",
"pos",
"=",
"None",
")",
":",
"word",
"=",
"word",
".",
"lower",
"(",
")",
"if",
"pos",
"is",
"not",
"None",
":",
"if",
"pos",
".",
"startswith",
"(",
"'NN'",
")",
":",
"pos",
"=",
"'n'",
"elif",
"pos",
"... | 4b9ae8353489cc409bebd7e1fe10ab5b527b078e |
train | tag_and_stem | Returns a list of (stem, tag, token) triples:
- stem: the word's uninflected form
- tag: the word's part of speech
- token: the original word, so we can reconstruct it later | metanl/nltk_morphy.py | def tag_and_stem(text):
"""
Returns a list of (stem, tag, token) triples:
- stem: the word's uninflected form
- tag: the word's part of speech
- token: the original word, so we can reconstruct it later
"""
tokens = tokenize(text)
tagged = nltk.pos_tag(tokens)
out = []
for token,... | def tag_and_stem(text):
"""
Returns a list of (stem, tag, token) triples:
- stem: the word's uninflected form
- tag: the word's part of speech
- token: the original word, so we can reconstruct it later
"""
tokens = tokenize(text)
tagged = nltk.pos_tag(tokens)
out = []
for token,... | [
"Returns",
"a",
"list",
"of",
"(",
"stem",
"tag",
"token",
")",
"triples",
":"
] | commonsense/metanl | python | https://github.com/commonsense/metanl/blob/4b9ae8353489cc409bebd7e1fe10ab5b527b078e/metanl/nltk_morphy.py#L155-L169 | [
"def",
"tag_and_stem",
"(",
"text",
")",
":",
"tokens",
"=",
"tokenize",
"(",
"text",
")",
"tagged",
"=",
"nltk",
".",
"pos_tag",
"(",
"tokens",
")",
"out",
"=",
"[",
"]",
"for",
"token",
",",
"tag",
"in",
"tagged",
":",
"stem",
"=",
"morphy_stem",
... | 4b9ae8353489cc409bebd7e1fe10ab5b527b078e |
train | normalize_list | Get a list of word stems that appear in the text. Stopwords and an initial
'to' will be stripped, unless this leaves nothing in the stem.
>>> normalize_list('the dog')
['dog']
>>> normalize_list('big dogs')
['big', 'dog']
>>> normalize_list('the')
['the'] | metanl/nltk_morphy.py | def normalize_list(text):
"""
Get a list of word stems that appear in the text. Stopwords and an initial
'to' will be stripped, unless this leaves nothing in the stem.
>>> normalize_list('the dog')
['dog']
>>> normalize_list('big dogs')
['big', 'dog']
>>> normalize_list('the')
['the... | def normalize_list(text):
"""
Get a list of word stems that appear in the text. Stopwords and an initial
'to' will be stripped, unless this leaves nothing in the stem.
>>> normalize_list('the dog')
['dog']
>>> normalize_list('big dogs')
['big', 'dog']
>>> normalize_list('the')
['the... | [
"Get",
"a",
"list",
"of",
"word",
"stems",
"that",
"appear",
"in",
"the",
"text",
".",
"Stopwords",
"and",
"an",
"initial",
"to",
"will",
"be",
"stripped",
"unless",
"this",
"leaves",
"nothing",
"in",
"the",
"stem",
"."
] | commonsense/metanl | python | https://github.com/commonsense/metanl/blob/4b9ae8353489cc409bebd7e1fe10ab5b527b078e/metanl/nltk_morphy.py#L176-L194 | [
"def",
"normalize_list",
"(",
"text",
")",
":",
"pieces",
"=",
"[",
"morphy_stem",
"(",
"word",
")",
"for",
"word",
"in",
"tokenize",
"(",
"text",
")",
"]",
"pieces",
"=",
"[",
"piece",
"for",
"piece",
"in",
"pieces",
"if",
"good_lemma",
"(",
"piece",
... | 4b9ae8353489cc409bebd7e1fe10ab5b527b078e |
train | normalize_topic | Get a canonical representation of a Wikipedia topic, which may include
a disambiguation string in parentheses.
Returns (name, disambig), where "name" is the normalized topic name,
and "disambig" is a string corresponding to the disambiguation text or
None. | metanl/nltk_morphy.py | def normalize_topic(topic):
"""
Get a canonical representation of a Wikipedia topic, which may include
a disambiguation string in parentheses.
Returns (name, disambig), where "name" is the normalized topic name,
and "disambig" is a string corresponding to the disambiguation text or
None.
""... | def normalize_topic(topic):
"""
Get a canonical representation of a Wikipedia topic, which may include
a disambiguation string in parentheses.
Returns (name, disambig), where "name" is the normalized topic name,
and "disambig" is a string corresponding to the disambiguation text or
None.
""... | [
"Get",
"a",
"canonical",
"representation",
"of",
"a",
"Wikipedia",
"topic",
"which",
"may",
"include",
"a",
"disambiguation",
"string",
"in",
"parentheses",
"."
] | commonsense/metanl | python | https://github.com/commonsense/metanl/blob/4b9ae8353489cc409bebd7e1fe10ab5b527b078e/metanl/nltk_morphy.py#L205-L220 | [
"def",
"normalize_topic",
"(",
"topic",
")",
":",
"# find titles of the form Foo (bar)",
"topic",
"=",
"topic",
".",
"replace",
"(",
"'_'",
",",
"' '",
")",
"match",
"=",
"re",
".",
"match",
"(",
"r'([^(]+) \\(([^)]+)\\)'",
",",
"topic",
")",
"if",
"not",
"m... | 4b9ae8353489cc409bebd7e1fe10ab5b527b078e |
train | key2elements | split key to elements | eppy/json_functions.py | def key2elements(key):
"""split key to elements"""
# words = key.split('.')
# if len(words) == 4:
# return words
# # there is a dot in object name
# fieldword = words.pop(-1)
# nameword = '.'.join(words[-2:])
# if nameword[-1] in ('"', "'"):
# # The object name is in quotes
... | def key2elements(key):
"""split key to elements"""
# words = key.split('.')
# if len(words) == 4:
# return words
# # there is a dot in object name
# fieldword = words.pop(-1)
# nameword = '.'.join(words[-2:])
# if nameword[-1] in ('"', "'"):
# # The object name is in quotes
... | [
"split",
"key",
"to",
"elements"
] | santoshphilip/eppy | python | https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/json_functions.py#L14-L34 | [
"def",
"key2elements",
"(",
"key",
")",
":",
"# words = key.split('.')",
"# if len(words) == 4:",
"# return words",
"# # there is a dot in object name",
"# fieldword = words.pop(-1)",
"# nameword = '.'.join(words[-2:])",
"# if nameword[-1] in ('\"', \"'\"):",
"# # The object name i... | 55410ff7c11722f35bc4331ff5e00a0b86f787e1 |
train | updateidf | update idf using dct | eppy/json_functions.py | def updateidf(idf, dct):
"""update idf using dct"""
for key in list(dct.keys()):
if key.startswith('idf.'):
idftag, objkey, objname, field = key2elements(key)
if objname == '':
try:
idfobj = idf.idfobjects[objkey.upper()][0]
exc... | def updateidf(idf, dct):
"""update idf using dct"""
for key in list(dct.keys()):
if key.startswith('idf.'):
idftag, objkey, objname, field = key2elements(key)
if objname == '':
try:
idfobj = idf.idfobjects[objkey.upper()][0]
exc... | [
"update",
"idf",
"using",
"dct"
] | santoshphilip/eppy | python | https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/json_functions.py#L37-L51 | [
"def",
"updateidf",
"(",
"idf",
",",
"dct",
")",
":",
"for",
"key",
"in",
"list",
"(",
"dct",
".",
"keys",
"(",
")",
")",
":",
"if",
"key",
".",
"startswith",
"(",
"'idf.'",
")",
":",
"idftag",
",",
"objkey",
",",
"objname",
",",
"field",
"=",
... | 55410ff7c11722f35bc4331ff5e00a0b86f787e1 |
train | fan_bhp | return the fan power in bhp given fan efficiency, Pressure rise (Pa) and flow (m3/s) | eppy/fanpower.py | def fan_bhp(fan_tot_eff, pascal, m3s):
"""return the fan power in bhp given fan efficiency, Pressure rise (Pa) and flow (m3/s)"""
# from discussion in
# http://energy-models.com/forum/baseline-fan-power-calculation
inh2o = pascal2inh2o(pascal)
cfm = m3s2cfm(m3s)
return (cfm * inh2o * 1.0) / (635... | def fan_bhp(fan_tot_eff, pascal, m3s):
"""return the fan power in bhp given fan efficiency, Pressure rise (Pa) and flow (m3/s)"""
# from discussion in
# http://energy-models.com/forum/baseline-fan-power-calculation
inh2o = pascal2inh2o(pascal)
cfm = m3s2cfm(m3s)
return (cfm * inh2o * 1.0) / (635... | [
"return",
"the",
"fan",
"power",
"in",
"bhp",
"given",
"fan",
"efficiency",
"Pressure",
"rise",
"(",
"Pa",
")",
"and",
"flow",
"(",
"m3",
"/",
"s",
")"
] | santoshphilip/eppy | python | https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/fanpower.py#L37-L43 | [
"def",
"fan_bhp",
"(",
"fan_tot_eff",
",",
"pascal",
",",
"m3s",
")",
":",
"# from discussion in",
"# http://energy-models.com/forum/baseline-fan-power-calculation",
"inh2o",
"=",
"pascal2inh2o",
"(",
"pascal",
")",
"cfm",
"=",
"m3s2cfm",
"(",
"m3s",
")",
"return",
... | 55410ff7c11722f35bc4331ff5e00a0b86f787e1 |
train | bhp2pascal | return inputs for E+ in pascal and m3/s | eppy/fanpower.py | def bhp2pascal(bhp, cfm, fan_tot_eff):
"""return inputs for E+ in pascal and m3/s"""
inh2o = bhp * 6356.0 * fan_tot_eff / cfm
pascal = inh2o2pascal(inh2o)
m3s = cfm2m3s(cfm)
return pascal, m3s | def bhp2pascal(bhp, cfm, fan_tot_eff):
"""return inputs for E+ in pascal and m3/s"""
inh2o = bhp * 6356.0 * fan_tot_eff / cfm
pascal = inh2o2pascal(inh2o)
m3s = cfm2m3s(cfm)
return pascal, m3s | [
"return",
"inputs",
"for",
"E",
"+",
"in",
"pascal",
"and",
"m3",
"/",
"s"
] | santoshphilip/eppy | python | https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/fanpower.py#L45-L50 | [
"def",
"bhp2pascal",
"(",
"bhp",
",",
"cfm",
",",
"fan_tot_eff",
")",
":",
"inh2o",
"=",
"bhp",
"*",
"6356.0",
"*",
"fan_tot_eff",
"/",
"cfm",
"pascal",
"=",
"inh2o2pascal",
"(",
"inh2o",
")",
"m3s",
"=",
"cfm2m3s",
"(",
"cfm",
")",
"return",
"pascal",... | 55410ff7c11722f35bc4331ff5e00a0b86f787e1 |
train | fan_watts | return the fan power in watts given fan efficiency, Pressure rise (Pa) and flow (m3/s) | eppy/fanpower.py | def fan_watts(fan_tot_eff, pascal, m3s):
"""return the fan power in watts given fan efficiency, Pressure rise (Pa) and flow (m3/s)"""
# got this from a google search
bhp = fan_bhp(fan_tot_eff, pascal, m3s)
return bhp2watts(bhp) | def fan_watts(fan_tot_eff, pascal, m3s):
"""return the fan power in watts given fan efficiency, Pressure rise (Pa) and flow (m3/s)"""
# got this from a google search
bhp = fan_bhp(fan_tot_eff, pascal, m3s)
return bhp2watts(bhp) | [
"return",
"the",
"fan",
"power",
"in",
"watts",
"given",
"fan",
"efficiency",
"Pressure",
"rise",
"(",
"Pa",
")",
"and",
"flow",
"(",
"m3",
"/",
"s",
")"
] | santoshphilip/eppy | python | https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/fanpower.py#L61-L65 | [
"def",
"fan_watts",
"(",
"fan_tot_eff",
",",
"pascal",
",",
"m3s",
")",
":",
"# got this from a google search",
"bhp",
"=",
"fan_bhp",
"(",
"fan_tot_eff",
",",
"pascal",
",",
"m3s",
")",
"return",
"bhp2watts",
"(",
"bhp",
")"
] | 55410ff7c11722f35bc4331ff5e00a0b86f787e1 |
train | watts2pascal | convert and return inputs for E+ in pascal and m3/s | eppy/fanpower.py | def watts2pascal(watts, cfm, fan_tot_eff):
"""convert and return inputs for E+ in pascal and m3/s"""
bhp = watts2bhp(watts)
return bhp2pascal(bhp, cfm, fan_tot_eff) | def watts2pascal(watts, cfm, fan_tot_eff):
"""convert and return inputs for E+ in pascal and m3/s"""
bhp = watts2bhp(watts)
return bhp2pascal(bhp, cfm, fan_tot_eff) | [
"convert",
"and",
"return",
"inputs",
"for",
"E",
"+",
"in",
"pascal",
"and",
"m3",
"/",
"s"
] | santoshphilip/eppy | python | https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/fanpower.py#L67-L70 | [
"def",
"watts2pascal",
"(",
"watts",
",",
"cfm",
",",
"fan_tot_eff",
")",
":",
"bhp",
"=",
"watts2bhp",
"(",
"watts",
")",
"return",
"bhp2pascal",
"(",
"bhp",
",",
"cfm",
",",
"fan_tot_eff",
")"
] | 55410ff7c11722f35bc4331ff5e00a0b86f787e1 |
train | fanpower_bhp | return fan power in bhp given the fan IDF object | eppy/fanpower.py | def fanpower_bhp(ddtt):
"""return fan power in bhp given the fan IDF object"""
from eppy.bunch_subclass import BadEPFieldError # here to prevent circular dependency
try:
fan_tot_eff = ddtt.Fan_Total_Efficiency # from V+ V8.7.0 onwards
except BadEPFieldError as e:
fan_tot_eff = ddtt.Fan_E... | def fanpower_bhp(ddtt):
"""return fan power in bhp given the fan IDF object"""
from eppy.bunch_subclass import BadEPFieldError # here to prevent circular dependency
try:
fan_tot_eff = ddtt.Fan_Total_Efficiency # from V+ V8.7.0 onwards
except BadEPFieldError as e:
fan_tot_eff = ddtt.Fan_E... | [
"return",
"fan",
"power",
"in",
"bhp",
"given",
"the",
"fan",
"IDF",
"object"
] | santoshphilip/eppy | python | https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/fanpower.py#L72-L85 | [
"def",
"fanpower_bhp",
"(",
"ddtt",
")",
":",
"from",
"eppy",
".",
"bunch_subclass",
"import",
"BadEPFieldError",
"# here to prevent circular dependency",
"try",
":",
"fan_tot_eff",
"=",
"ddtt",
".",
"Fan_Total_Efficiency",
"# from V+ V8.7.0 onwards",
"except",
"BadEPFiel... | 55410ff7c11722f35bc4331ff5e00a0b86f787e1 |
train | fanpower_watts | return fan power in bhp given the fan IDF object | eppy/fanpower.py | def fanpower_watts(ddtt):
"""return fan power in bhp given the fan IDF object"""
from eppy.bunch_subclass import BadEPFieldError # here to prevent circular dependency
try:
fan_tot_eff = ddtt.Fan_Total_Efficiency # from V+ V8.7.0 onwards
except BadEPFieldError as e:
fan_tot_eff = ddtt.Fan... | def fanpower_watts(ddtt):
"""return fan power in bhp given the fan IDF object"""
from eppy.bunch_subclass import BadEPFieldError # here to prevent circular dependency
try:
fan_tot_eff = ddtt.Fan_Total_Efficiency # from V+ V8.7.0 onwards
except BadEPFieldError as e:
fan_tot_eff = ddtt.Fan... | [
"return",
"fan",
"power",
"in",
"bhp",
"given",
"the",
"fan",
"IDF",
"object"
] | santoshphilip/eppy | python | https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/fanpower.py#L87-L100 | [
"def",
"fanpower_watts",
"(",
"ddtt",
")",
":",
"from",
"eppy",
".",
"bunch_subclass",
"import",
"BadEPFieldError",
"# here to prevent circular dependency",
"try",
":",
"fan_tot_eff",
"=",
"ddtt",
".",
"Fan_Total_Efficiency",
"# from V+ V8.7.0 onwards",
"except",
"BadEPFi... | 55410ff7c11722f35bc4331ff5e00a0b86f787e1 |
train | fan_maxcfm | return the fan max cfm | eppy/fanpower.py | def fan_maxcfm(ddtt):
"""return the fan max cfm"""
if str(ddtt.Maximum_Flow_Rate).lower() == 'autosize':
# str can fail with unicode chars :-(
return 'autosize'
else:
m3s = float(ddtt.Maximum_Flow_Rate)
return m3s2cfm(m3s) | def fan_maxcfm(ddtt):
"""return the fan max cfm"""
if str(ddtt.Maximum_Flow_Rate).lower() == 'autosize':
# str can fail with unicode chars :-(
return 'autosize'
else:
m3s = float(ddtt.Maximum_Flow_Rate)
return m3s2cfm(m3s) | [
"return",
"the",
"fan",
"max",
"cfm"
] | santoshphilip/eppy | python | https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/fanpower.py#L102-L109 | [
"def",
"fan_maxcfm",
"(",
"ddtt",
")",
":",
"if",
"str",
"(",
"ddtt",
".",
"Maximum_Flow_Rate",
")",
".",
"lower",
"(",
")",
"==",
"'autosize'",
":",
"# str can fail with unicode chars :-(",
"return",
"'autosize'",
"else",
":",
"m3s",
"=",
"float",
"(",
"ddt... | 55410ff7c11722f35bc4331ff5e00a0b86f787e1 |
train | install_paths | Get the install paths for EnergyPlus executable and weather files.
We prefer to get the install path from the IDD name but fall back to
getting it from the version number for backwards compatibility and to
simplify tests.
Parameters
----------
version : str, optional
EnergyPlus version... | eppy/runner/run_functions.py | def install_paths(version=None, iddname=None):
"""Get the install paths for EnergyPlus executable and weather files.
We prefer to get the install path from the IDD name but fall back to
getting it from the version number for backwards compatibility and to
simplify tests.
Parameters
----------
... | def install_paths(version=None, iddname=None):
"""Get the install paths for EnergyPlus executable and weather files.
We prefer to get the install path from the IDD name but fall back to
getting it from the version number for backwards compatibility and to
simplify tests.
Parameters
----------
... | [
"Get",
"the",
"install",
"paths",
"for",
"EnergyPlus",
"executable",
"and",
"weather",
"files",
"."
] | santoshphilip/eppy | python | https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/runner/run_functions.py#L29-L57 | [
"def",
"install_paths",
"(",
"version",
"=",
"None",
",",
"iddname",
"=",
"None",
")",
":",
"try",
":",
"eplus_exe",
",",
"eplus_home",
"=",
"paths_from_iddname",
"(",
"iddname",
")",
"except",
"(",
"AttributeError",
",",
"TypeError",
",",
"ValueError",
")",... | 55410ff7c11722f35bc4331ff5e00a0b86f787e1 |
train | paths_from_iddname | Get the EnergyPlus install directory and executable path.
Parameters
----------
iddname : str, optional
File path to the IDD.
Returns
-------
eplus_exe : str
Full path to the EnergyPlus executable.
eplus_home : str
Full path to the EnergyPlus install directory.
... | eppy/runner/run_functions.py | def paths_from_iddname(iddname):
"""Get the EnergyPlus install directory and executable path.
Parameters
----------
iddname : str, optional
File path to the IDD.
Returns
-------
eplus_exe : str
Full path to the EnergyPlus executable.
eplus_home : str
Full path t... | def paths_from_iddname(iddname):
"""Get the EnergyPlus install directory and executable path.
Parameters
----------
iddname : str, optional
File path to the IDD.
Returns
-------
eplus_exe : str
Full path to the EnergyPlus executable.
eplus_home : str
Full path t... | [
"Get",
"the",
"EnergyPlus",
"install",
"directory",
"and",
"executable",
"path",
"."
] | santoshphilip/eppy | python | https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/runner/run_functions.py#L60-L92 | [
"def",
"paths_from_iddname",
"(",
"iddname",
")",
":",
"eplus_home",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"iddname",
")",
")",
"if",
"platform",
".",
"system",
"(",
")",
"==",
"'Windows'",
":",
"eplus_exe... | 55410ff7c11722f35bc4331ff5e00a0b86f787e1 |
train | paths_from_version | Get the EnergyPlus install directory and executable path.
Parameters
----------
version : str, optional
EnergyPlus version in the format "X-X-X", e.g. "8-7-0".
Returns
-------
eplus_exe : str
Full path to the EnergyPlus executable.
eplus_home : str
Full path to the ... | eppy/runner/run_functions.py | def paths_from_version(version):
"""Get the EnergyPlus install directory and executable path.
Parameters
----------
version : str, optional
EnergyPlus version in the format "X-X-X", e.g. "8-7-0".
Returns
-------
eplus_exe : str
Full path to the EnergyPlus executable.
ep... | def paths_from_version(version):
"""Get the EnergyPlus install directory and executable path.
Parameters
----------
version : str, optional
EnergyPlus version in the format "X-X-X", e.g. "8-7-0".
Returns
-------
eplus_exe : str
Full path to the EnergyPlus executable.
ep... | [
"Get",
"the",
"EnergyPlus",
"install",
"directory",
"and",
"executable",
"path",
"."
] | santoshphilip/eppy | python | https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/runner/run_functions.py#L95-L120 | [
"def",
"paths_from_version",
"(",
"version",
")",
":",
"if",
"platform",
".",
"system",
"(",
")",
"==",
"'Windows'",
":",
"eplus_home",
"=",
"\"C:/EnergyPlusV{version}\"",
".",
"format",
"(",
"version",
"=",
"version",
")",
"eplus_exe",
"=",
"os",
".",
"path... | 55410ff7c11722f35bc4331ff5e00a0b86f787e1 |
train | wrapped_help_text | Decorator to pass through the documentation from a wrapped function. | eppy/runner/run_functions.py | def wrapped_help_text(wrapped_func):
"""Decorator to pass through the documentation from a wrapped function.
"""
def decorator(wrapper_func):
"""The decorator.
Parameters
----------
f : callable
The wrapped function.
"""
wrapper_func.__doc__ = ('... | def wrapped_help_text(wrapped_func):
"""Decorator to pass through the documentation from a wrapped function.
"""
def decorator(wrapper_func):
"""The decorator.
Parameters
----------
f : callable
The wrapped function.
"""
wrapper_func.__doc__ = ('... | [
"Decorator",
"to",
"pass",
"through",
"the",
"documentation",
"from",
"a",
"wrapped",
"function",
"."
] | santoshphilip/eppy | python | https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/runner/run_functions.py#L123-L138 | [
"def",
"wrapped_help_text",
"(",
"wrapped_func",
")",
":",
"def",
"decorator",
"(",
"wrapper_func",
")",
":",
"\"\"\"The decorator.\n\n Parameters\n ----------\n f : callable\n The wrapped function.\n\n \"\"\"",
"wrapper_func",
".",
"__doc__",
"... | 55410ff7c11722f35bc4331ff5e00a0b86f787e1 |
train | runIDFs | Wrapper for run() to be used when running IDF5 runs in parallel.
Parameters
----------
jobs : iterable
A list or generator made up of an IDF5 object and a kwargs dict
(see `run_functions.run` for valid keywords).
processors : int, optional
Number of processors to run on (default... | eppy/runner/run_functions.py | def runIDFs(jobs, processors=1):
"""Wrapper for run() to be used when running IDF5 runs in parallel.
Parameters
----------
jobs : iterable
A list or generator made up of an IDF5 object and a kwargs dict
(see `run_functions.run` for valid keywords).
processors : int, optional
... | def runIDFs(jobs, processors=1):
"""Wrapper for run() to be used when running IDF5 runs in parallel.
Parameters
----------
jobs : iterable
A list or generator made up of an IDF5 object and a kwargs dict
(see `run_functions.run` for valid keywords).
processors : int, optional
... | [
"Wrapper",
"for",
"run",
"()",
"to",
"be",
"used",
"when",
"running",
"IDF5",
"runs",
"in",
"parallel",
"."
] | santoshphilip/eppy | python | https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/runner/run_functions.py#L141-L169 | [
"def",
"runIDFs",
"(",
"jobs",
",",
"processors",
"=",
"1",
")",
":",
"if",
"processors",
"<=",
"0",
":",
"processors",
"=",
"max",
"(",
"1",
",",
"mp",
".",
"cpu_count",
"(",
")",
"-",
"processors",
")",
"shutil",
".",
"rmtree",
"(",
"\"multi_runs\"... | 55410ff7c11722f35bc4331ff5e00a0b86f787e1 |
train | prepare_run | Prepare run inputs for one of multiple EnergyPlus runs.
:param run_id: An ID number for naming the IDF.
:param run_data: Tuple of the IDF and keyword args to pass to EnergyPlus executable.
:return: Tuple of the IDF path and EPW, and the keyword args. | eppy/runner/run_functions.py | def prepare_run(run_id, run_data):
"""Prepare run inputs for one of multiple EnergyPlus runs.
:param run_id: An ID number for naming the IDF.
:param run_data: Tuple of the IDF and keyword args to pass to EnergyPlus executable.
:return: Tuple of the IDF path and EPW, and the keyword args.
"""
id... | def prepare_run(run_id, run_data):
"""Prepare run inputs for one of multiple EnergyPlus runs.
:param run_id: An ID number for naming the IDF.
:param run_data: Tuple of the IDF and keyword args to pass to EnergyPlus executable.
:return: Tuple of the IDF path and EPW, and the keyword args.
"""
id... | [
"Prepare",
"run",
"inputs",
"for",
"one",
"of",
"multiple",
"EnergyPlus",
"runs",
"."
] | santoshphilip/eppy | python | https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/runner/run_functions.py#L172-L185 | [
"def",
"prepare_run",
"(",
"run_id",
",",
"run_data",
")",
":",
"idf",
",",
"kwargs",
"=",
"run_data",
"epw",
"=",
"idf",
".",
"epw",
"idf_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"'multi_runs'",
",",
"'idf_%i'",
"%",
"run_id",
")",
"os",
".",... | 55410ff7c11722f35bc4331ff5e00a0b86f787e1 |
train | run | Wrapper around the EnergyPlus command line interface.
Parameters
----------
idf : str
Full or relative path to the IDF file to be run, or an IDF object.
weather : str
Full or relative path to the weather file.
output_directory : str, optional
Full or relative path to an ou... | eppy/runner/run_functions.py | def run(idf=None, weather=None, output_directory='', annual=False,
design_day=False, idd=None, epmacro=False, expandobjects=False,
readvars=False, output_prefix=None, output_suffix=None, version=False,
verbose='v', ep_version=None):
"""
Wrapper around the EnergyPlus command line interfac... | def run(idf=None, weather=None, output_directory='', annual=False,
design_day=False, idd=None, epmacro=False, expandobjects=False,
readvars=False, output_prefix=None, output_suffix=None, version=False,
verbose='v', ep_version=None):
"""
Wrapper around the EnergyPlus command line interfac... | [
"Wrapper",
"around",
"the",
"EnergyPlus",
"command",
"line",
"interface",
"."
] | santoshphilip/eppy | python | https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/runner/run_functions.py#L200-L334 | [
"def",
"run",
"(",
"idf",
"=",
"None",
",",
"weather",
"=",
"None",
",",
"output_directory",
"=",
"''",
",",
"annual",
"=",
"False",
",",
"design_day",
"=",
"False",
",",
"idd",
"=",
"None",
",",
"epmacro",
"=",
"False",
",",
"expandobjects",
"=",
"F... | 55410ff7c11722f35bc4331ff5e00a0b86f787e1 |
train | parse_error | Add contents of stderr and eplusout.err and put it in the exception message.
:param output_dir: str
:return: str | eppy/runner/run_functions.py | def parse_error(output_dir):
"""Add contents of stderr and eplusout.err and put it in the exception message.
:param output_dir: str
:return: str
"""
sys.stderr.seek(0)
std_err = sys.stderr.read().decode('utf-8')
err_file = os.path.join(output_dir, "eplusout.err")
if os.path.isfile(err_f... | def parse_error(output_dir):
"""Add contents of stderr and eplusout.err and put it in the exception message.
:param output_dir: str
:return: str
"""
sys.stderr.seek(0)
std_err = sys.stderr.read().decode('utf-8')
err_file = os.path.join(output_dir, "eplusout.err")
if os.path.isfile(err_f... | [
"Add",
"contents",
"of",
"stderr",
"and",
"eplusout",
".",
"err",
"and",
"put",
"it",
"in",
"the",
"exception",
"message",
"."
] | santoshphilip/eppy | python | https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/runner/run_functions.py#L337-L352 | [
"def",
"parse_error",
"(",
"output_dir",
")",
":",
"sys",
".",
"stderr",
".",
"seek",
"(",
"0",
")",
"std_err",
"=",
"sys",
".",
"stderr",
".",
"read",
"(",
")",
".",
"decode",
"(",
"'utf-8'",
")",
"err_file",
"=",
"os",
".",
"path",
".",
"join",
... | 55410ff7c11722f35bc4331ff5e00a0b86f787e1 |
train | rvalue | R value (W/K) of a construction or material.
thickness (m) / conductivity (W/m-K) | eppy/constructions/thermal_properties.py | def rvalue(ddtt):
"""
R value (W/K) of a construction or material.
thickness (m) / conductivity (W/m-K)
"""
object_type = ddtt.obj[0]
if object_type == 'Construction':
rvalue = INSIDE_FILM_R + OUTSIDE_FILM_R
layers = ddtt.obj[2:]
field_idd = ddtt.getfieldidd('Outside_Laye... | def rvalue(ddtt):
"""
R value (W/K) of a construction or material.
thickness (m) / conductivity (W/m-K)
"""
object_type = ddtt.obj[0]
if object_type == 'Construction':
rvalue = INSIDE_FILM_R + OUTSIDE_FILM_R
layers = ddtt.obj[2:]
field_idd = ddtt.getfieldidd('Outside_Laye... | [
"R",
"value",
"(",
"W",
"/",
"K",
")",
"of",
"a",
"construction",
"or",
"material",
".",
"thickness",
"(",
"m",
")",
"/",
"conductivity",
"(",
"W",
"/",
"m",
"-",
"K",
")"
] | santoshphilip/eppy | python | https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/constructions/thermal_properties.py#L24-L64 | [
"def",
"rvalue",
"(",
"ddtt",
")",
":",
"object_type",
"=",
"ddtt",
".",
"obj",
"[",
"0",
"]",
"if",
"object_type",
"==",
"'Construction'",
":",
"rvalue",
"=",
"INSIDE_FILM_R",
"+",
"OUTSIDE_FILM_R",
"layers",
"=",
"ddtt",
".",
"obj",
"[",
"2",
":",
"]... | 55410ff7c11722f35bc4331ff5e00a0b86f787e1 |
train | heatcapacity | Heat capacity (kJ/m2-K) of a construction or material.
thickness (m) * density (kg/m3) * specific heat (J/kg-K) * 0.001 | eppy/constructions/thermal_properties.py | def heatcapacity(ddtt):
"""
Heat capacity (kJ/m2-K) of a construction or material.
thickness (m) * density (kg/m3) * specific heat (J/kg-K) * 0.001
"""
object_type = ddtt.obj[0]
if object_type == 'Construction':
heatcapacity = 0
layers = ddtt.obj[2:]
field_idd = ddtt.getf... | def heatcapacity(ddtt):
"""
Heat capacity (kJ/m2-K) of a construction or material.
thickness (m) * density (kg/m3) * specific heat (J/kg-K) * 0.001
"""
object_type = ddtt.obj[0]
if object_type == 'Construction':
heatcapacity = 0
layers = ddtt.obj[2:]
field_idd = ddtt.getf... | [
"Heat",
"capacity",
"(",
"kJ",
"/",
"m2",
"-",
"K",
")",
"of",
"a",
"construction",
"or",
"material",
".",
"thickness",
"(",
"m",
")",
"*",
"density",
"(",
"kg",
"/",
"m3",
")",
"*",
"specific",
"heat",
"(",
"J",
"/",
"kg",
"-",
"K",
")",
"*",
... | santoshphilip/eppy | python | https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/constructions/thermal_properties.py#L87-L132 | [
"def",
"heatcapacity",
"(",
"ddtt",
")",
":",
"object_type",
"=",
"ddtt",
".",
"obj",
"[",
"0",
"]",
"if",
"object_type",
"==",
"'Construction'",
":",
"heatcapacity",
"=",
"0",
"layers",
"=",
"ddtt",
".",
"obj",
"[",
"2",
":",
"]",
"field_idd",
"=",
... | 55410ff7c11722f35bc4331ff5e00a0b86f787e1 |
train | almostequal | Test if two values are equal to a given number of places.
This is based on python's unittest so may be covered by Python's
license. | eppy/modeleditor.py | def almostequal(first, second, places=7, printit=True):
"""
Test if two values are equal to a given number of places.
This is based on python's unittest so may be covered by Python's
license.
"""
if first == second:
return True
if round(abs(second - first), places) != 0:
if... | def almostequal(first, second, places=7, printit=True):
"""
Test if two values are equal to a given number of places.
This is based on python's unittest so may be covered by Python's
license.
"""
if first == second:
return True
if round(abs(second - first), places) != 0:
if... | [
"Test",
"if",
"two",
"values",
"are",
"equal",
"to",
"a",
"given",
"number",
"of",
"places",
".",
"This",
"is",
"based",
"on",
"python",
"s",
"unittest",
"so",
"may",
"be",
"covered",
"by",
"Python",
"s",
"license",
"."
] | santoshphilip/eppy | python | https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/modeleditor.py#L58-L74 | [
"def",
"almostequal",
"(",
"first",
",",
"second",
",",
"places",
"=",
"7",
",",
"printit",
"=",
"True",
")",
":",
"if",
"first",
"==",
"second",
":",
"return",
"True",
"if",
"round",
"(",
"abs",
"(",
"second",
"-",
"first",
")",
",",
"places",
")"... | 55410ff7c11722f35bc4331ff5e00a0b86f787e1 |
train | newrawobject | Make a new object for the given key.
Parameters
----------
data : Eplusdata object
Data dictionary and list of objects for the entire model.
commdct : list of dicts
Comments from the IDD file describing each item type in `data`.
key : str
Object type of the object to add (in... | eppy/modeleditor.py | def newrawobject(data, commdct, key, block=None, defaultvalues=True):
"""Make a new object for the given key.
Parameters
----------
data : Eplusdata object
Data dictionary and list of objects for the entire model.
commdct : list of dicts
Comments from the IDD file describing each it... | def newrawobject(data, commdct, key, block=None, defaultvalues=True):
"""Make a new object for the given key.
Parameters
----------
data : Eplusdata object
Data dictionary and list of objects for the entire model.
commdct : list of dicts
Comments from the IDD file describing each it... | [
"Make",
"a",
"new",
"object",
"for",
"the",
"given",
"key",
"."
] | santoshphilip/eppy | python | https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/modeleditor.py#L95-L133 | [
"def",
"newrawobject",
"(",
"data",
",",
"commdct",
",",
"key",
",",
"block",
"=",
"None",
",",
"defaultvalues",
"=",
"True",
")",
":",
"dtls",
"=",
"data",
".",
"dtls",
"key",
"=",
"key",
".",
"upper",
"(",
")",
"key_i",
"=",
"dtls",
".",
"index",... | 55410ff7c11722f35bc4331ff5e00a0b86f787e1 |
train | addthisbunch | add a bunch to model.
abunch usually comes from another idf file
or it can be used to copy within the idf file | eppy/modeleditor.py | def addthisbunch(bunchdt, data, commdct, thisbunch, theidf):
"""add a bunch to model.
abunch usually comes from another idf file
or it can be used to copy within the idf file"""
key = thisbunch.key.upper()
obj = copy.copy(thisbunch.obj)
abunch = obj2bunch(data, commdct, obj)
bunchdt[key].app... | def addthisbunch(bunchdt, data, commdct, thisbunch, theidf):
"""add a bunch to model.
abunch usually comes from another idf file
or it can be used to copy within the idf file"""
key = thisbunch.key.upper()
obj = copy.copy(thisbunch.obj)
abunch = obj2bunch(data, commdct, obj)
bunchdt[key].app... | [
"add",
"a",
"bunch",
"to",
"model",
".",
"abunch",
"usually",
"comes",
"from",
"another",
"idf",
"file",
"or",
"it",
"can",
"be",
"used",
"to",
"copy",
"within",
"the",
"idf",
"file"
] | santoshphilip/eppy | python | https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/modeleditor.py#L136-L144 | [
"def",
"addthisbunch",
"(",
"bunchdt",
",",
"data",
",",
"commdct",
",",
"thisbunch",
",",
"theidf",
")",
":",
"key",
"=",
"thisbunch",
".",
"key",
".",
"upper",
"(",
")",
"obj",
"=",
"copy",
".",
"copy",
"(",
"thisbunch",
".",
"obj",
")",
"abunch",
... | 55410ff7c11722f35bc4331ff5e00a0b86f787e1 |
train | obj2bunch | make a new bunch object using the data object | eppy/modeleditor.py | def obj2bunch(data, commdct, obj):
"""make a new bunch object using the data object"""
dtls = data.dtls
key = obj[0].upper()
key_i = dtls.index(key)
abunch = makeabunch(commdct, obj, key_i)
return abunch | def obj2bunch(data, commdct, obj):
"""make a new bunch object using the data object"""
dtls = data.dtls
key = obj[0].upper()
key_i = dtls.index(key)
abunch = makeabunch(commdct, obj, key_i)
return abunch | [
"make",
"a",
"new",
"bunch",
"object",
"using",
"the",
"data",
"object"
] | santoshphilip/eppy | python | https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/modeleditor.py#L147-L153 | [
"def",
"obj2bunch",
"(",
"data",
",",
"commdct",
",",
"obj",
")",
":",
"dtls",
"=",
"data",
".",
"dtls",
"key",
"=",
"obj",
"[",
"0",
"]",
".",
"upper",
"(",
")",
"key_i",
"=",
"dtls",
".",
"index",
"(",
"key",
")",
"abunch",
"=",
"makeabunch",
... | 55410ff7c11722f35bc4331ff5e00a0b86f787e1 |
train | addobject | add an object to the eplus model | eppy/modeleditor.py | def addobject(bunchdt, data, commdct, key, theidf, aname=None, **kwargs):
"""add an object to the eplus model"""
obj = newrawobject(data, commdct, key)
abunch = obj2bunch(data, commdct, obj)
if aname:
namebunch(abunch, aname)
data.dt[key].append(obj)
bunchdt[key].append(abunch)
for k... | def addobject(bunchdt, data, commdct, key, theidf, aname=None, **kwargs):
"""add an object to the eplus model"""
obj = newrawobject(data, commdct, key)
abunch = obj2bunch(data, commdct, obj)
if aname:
namebunch(abunch, aname)
data.dt[key].append(obj)
bunchdt[key].append(abunch)
for k... | [
"add",
"an",
"object",
"to",
"the",
"eplus",
"model"
] | santoshphilip/eppy | python | https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/modeleditor.py#L165-L175 | [
"def",
"addobject",
"(",
"bunchdt",
",",
"data",
",",
"commdct",
",",
"key",
",",
"theidf",
",",
"aname",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"obj",
"=",
"newrawobject",
"(",
"data",
",",
"commdct",
",",
"key",
")",
"abunch",
"=",
"obj2... | 55410ff7c11722f35bc4331ff5e00a0b86f787e1 |
train | getnamedargs | allows you to pass a dict and named args
so you can pass ({'a':5, 'b':3}, c=8) and get
dict(a=5, b=3, c=8) | eppy/modeleditor.py | def getnamedargs(*args, **kwargs):
"""allows you to pass a dict and named args
so you can pass ({'a':5, 'b':3}, c=8) and get
dict(a=5, b=3, c=8)"""
adict = {}
for arg in args:
if isinstance(arg, dict):
adict.update(arg)
adict.update(kwargs)
return adict | def getnamedargs(*args, **kwargs):
"""allows you to pass a dict and named args
so you can pass ({'a':5, 'b':3}, c=8) and get
dict(a=5, b=3, c=8)"""
adict = {}
for arg in args:
if isinstance(arg, dict):
adict.update(arg)
adict.update(kwargs)
return adict | [
"allows",
"you",
"to",
"pass",
"a",
"dict",
"and",
"named",
"args",
"so",
"you",
"can",
"pass",
"(",
"{",
"a",
":",
"5",
"b",
":",
"3",
"}",
"c",
"=",
"8",
")",
"and",
"get",
"dict",
"(",
"a",
"=",
"5",
"b",
"=",
"3",
"c",
"=",
"8",
")"
] | santoshphilip/eppy | python | https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/modeleditor.py#L178-L187 | [
"def",
"getnamedargs",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"adict",
"=",
"{",
"}",
"for",
"arg",
"in",
"args",
":",
"if",
"isinstance",
"(",
"arg",
",",
"dict",
")",
":",
"adict",
".",
"update",
"(",
"arg",
")",
"adict",
".",
"... | 55410ff7c11722f35bc4331ff5e00a0b86f787e1 |
train | addobject1 | add an object to the eplus model | eppy/modeleditor.py | def addobject1(bunchdt, data, commdct, key, **kwargs):
"""add an object to the eplus model"""
obj = newrawobject(data, commdct, key)
abunch = obj2bunch(data, commdct, obj)
data.dt[key].append(obj)
bunchdt[key].append(abunch)
# adict = getnamedargs(*args, **kwargs)
for kkey, value in iteritem... | def addobject1(bunchdt, data, commdct, key, **kwargs):
"""add an object to the eplus model"""
obj = newrawobject(data, commdct, key)
abunch = obj2bunch(data, commdct, obj)
data.dt[key].append(obj)
bunchdt[key].append(abunch)
# adict = getnamedargs(*args, **kwargs)
for kkey, value in iteritem... | [
"add",
"an",
"object",
"to",
"the",
"eplus",
"model"
] | santoshphilip/eppy | python | https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/modeleditor.py#L190-L199 | [
"def",
"addobject1",
"(",
"bunchdt",
",",
"data",
",",
"commdct",
",",
"key",
",",
"*",
"*",
"kwargs",
")",
":",
"obj",
"=",
"newrawobject",
"(",
"data",
",",
"commdct",
",",
"key",
")",
"abunch",
"=",
"obj2bunch",
"(",
"data",
",",
"commdct",
",",
... | 55410ff7c11722f35bc4331ff5e00a0b86f787e1 |
train | getobject | get the object if you have the key and the name
returns a list of objects, in case you have more than one
You should not have more than one | eppy/modeleditor.py | def getobject(bunchdt, key, name):
"""get the object if you have the key and the name
returns a list of objects, in case you have more than one
You should not have more than one"""
# TODO : throw exception if more than one object, or return more objects
idfobjects = bunchdt[key]
if idfobjects:
... | def getobject(bunchdt, key, name):
"""get the object if you have the key and the name
returns a list of objects, in case you have more than one
You should not have more than one"""
# TODO : throw exception if more than one object, or return more objects
idfobjects = bunchdt[key]
if idfobjects:
... | [
"get",
"the",
"object",
"if",
"you",
"have",
"the",
"key",
"and",
"the",
"name",
"returns",
"a",
"list",
"of",
"objects",
"in",
"case",
"you",
"have",
"more",
"than",
"one",
"You",
"should",
"not",
"have",
"more",
"than",
"one"
] | santoshphilip/eppy | python | https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/modeleditor.py#L202-L216 | [
"def",
"getobject",
"(",
"bunchdt",
",",
"key",
",",
"name",
")",
":",
"# TODO : throw exception if more than one object, or return more objects",
"idfobjects",
"=",
"bunchdt",
"[",
"key",
"]",
"if",
"idfobjects",
":",
"# second item in list is a unique ID",
"unique_id",
... | 55410ff7c11722f35bc4331ff5e00a0b86f787e1 |
train | __objecthasfields | test if the idf object has the field values in kwargs | eppy/modeleditor.py | def __objecthasfields(bunchdt, data, commdct, idfobject, places=7, **kwargs):
"""test if the idf object has the field values in kwargs"""
for key, value in list(kwargs.items()):
if not isfieldvalue(
bunchdt, data, commdct,
idfobject, key, value, places=places):
... | def __objecthasfields(bunchdt, data, commdct, idfobject, places=7, **kwargs):
"""test if the idf object has the field values in kwargs"""
for key, value in list(kwargs.items()):
if not isfieldvalue(
bunchdt, data, commdct,
idfobject, key, value, places=places):
... | [
"test",
"if",
"the",
"idf",
"object",
"has",
"the",
"field",
"values",
"in",
"kwargs"
] | santoshphilip/eppy | python | https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/modeleditor.py#L219-L226 | [
"def",
"__objecthasfields",
"(",
"bunchdt",
",",
"data",
",",
"commdct",
",",
"idfobject",
",",
"places",
"=",
"7",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"key",
",",
"value",
"in",
"list",
"(",
"kwargs",
".",
"items",
"(",
")",
")",
":",
"if",
... | 55410ff7c11722f35bc4331ff5e00a0b86f787e1 |
train | getobjects | get all the objects of key that matches the fields in **kwargs | eppy/modeleditor.py | def getobjects(bunchdt, data, commdct, key, places=7, **kwargs):
"""get all the objects of key that matches the fields in **kwargs"""
idfobjects = bunchdt[key]
allobjs = []
for obj in idfobjects:
if __objecthasfields(
bunchdt, data, commdct,
obj, places=places, **... | def getobjects(bunchdt, data, commdct, key, places=7, **kwargs):
"""get all the objects of key that matches the fields in **kwargs"""
idfobjects = bunchdt[key]
allobjs = []
for obj in idfobjects:
if __objecthasfields(
bunchdt, data, commdct,
obj, places=places, **... | [
"get",
"all",
"the",
"objects",
"of",
"key",
"that",
"matches",
"the",
"fields",
"in",
"**",
"kwargs"
] | santoshphilip/eppy | python | https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/modeleditor.py#L229-L238 | [
"def",
"getobjects",
"(",
"bunchdt",
",",
"data",
",",
"commdct",
",",
"key",
",",
"places",
"=",
"7",
",",
"*",
"*",
"kwargs",
")",
":",
"idfobjects",
"=",
"bunchdt",
"[",
"key",
"]",
"allobjs",
"=",
"[",
"]",
"for",
"obj",
"in",
"idfobjects",
":"... | 55410ff7c11722f35bc4331ff5e00a0b86f787e1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.