repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
orbingol/NURBS-Python | geomdl/_operations.py | find_ctrlpts_curve | def find_ctrlpts_curve(t, curve, **kwargs):
""" Finds the control points involved in the evaluation of the curve point defined by the input parameter.
This function uses a modified version of the algorithm *A3.1 CurvePoint* from The NURBS Book by Piegl & Tiller.
:param t: parameter
:type t: float
... | python | def find_ctrlpts_curve(t, curve, **kwargs):
""" Finds the control points involved in the evaluation of the curve point defined by the input parameter.
This function uses a modified version of the algorithm *A3.1 CurvePoint* from The NURBS Book by Piegl & Tiller.
:param t: parameter
:type t: float
... | [
"def",
"find_ctrlpts_curve",
"(",
"t",
",",
"curve",
",",
"**",
"kwargs",
")",
":",
"span_func",
"=",
"kwargs",
".",
"get",
"(",
"'find_span_func'",
",",
"helpers",
".",
"find_span_linear",
")",
"span",
"=",
"span_func",
"(",
"curve",
".",
"degree",
",",
... | Finds the control points involved in the evaluation of the curve point defined by the input parameter.
This function uses a modified version of the algorithm *A3.1 CurvePoint* from The NURBS Book by Piegl & Tiller.
:param t: parameter
:type t: float
:param curve: input curve object
:type curve: ab... | [
"Finds",
"the",
"control",
"points",
"involved",
"in",
"the",
"evaluation",
"of",
"the",
"curve",
"point",
"defined",
"by",
"the",
"input",
"parameter",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/_operations.py#L234-L259 | train |
orbingol/NURBS-Python | geomdl/_operations.py | find_ctrlpts_surface | def find_ctrlpts_surface(t_u, t_v, surf, **kwargs):
""" Finds the control points involved in the evaluation of the surface point defined by the input parameter pair.
This function uses a modified version of the algorithm *A3.5 SurfacePoint* from The NURBS Book by Piegl & Tiller.
:param t_u: parameter on t... | python | def find_ctrlpts_surface(t_u, t_v, surf, **kwargs):
""" Finds the control points involved in the evaluation of the surface point defined by the input parameter pair.
This function uses a modified version of the algorithm *A3.5 SurfacePoint* from The NURBS Book by Piegl & Tiller.
:param t_u: parameter on t... | [
"def",
"find_ctrlpts_surface",
"(",
"t_u",
",",
"t_v",
",",
"surf",
",",
"**",
"kwargs",
")",
":",
"span_func",
"=",
"kwargs",
".",
"get",
"(",
"'find_span_func'",
",",
"helpers",
".",
"find_span_linear",
")",
"span_u",
"=",
"span_func",
"(",
"surf",
".",
... | Finds the control points involved in the evaluation of the surface point defined by the input parameter pair.
This function uses a modified version of the algorithm *A3.5 SurfacePoint* from The NURBS Book by Piegl & Tiller.
:param t_u: parameter on the u-direction
:type t_u: float
:param t_v: paramete... | [
"Finds",
"the",
"control",
"points",
"involved",
"in",
"the",
"evaluation",
"of",
"the",
"surface",
"point",
"defined",
"by",
"the",
"input",
"parameter",
"pair",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/_operations.py#L262-L296 | train |
orbingol/NURBS-Python | geomdl/_operations.py | link_curves | def link_curves(*args, **kwargs):
""" Links the input curves together.
The end control point of the curve k has to be the same with the start control point of the curve k + 1.
Keyword Arguments:
* ``tol``: tolerance value for checking equality. *Default: 10e-8*
* ``validate``: flag to enab... | python | def link_curves(*args, **kwargs):
""" Links the input curves together.
The end control point of the curve k has to be the same with the start control point of the curve k + 1.
Keyword Arguments:
* ``tol``: tolerance value for checking equality. *Default: 10e-8*
* ``validate``: flag to enab... | [
"def",
"link_curves",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"tol",
"=",
"kwargs",
".",
"get",
"(",
"'tol'",
",",
"10e-8",
")",
"validate",
"=",
"kwargs",
".",
"get",
"(",
"'validate'",
",",
"False",
")",
"if",
"validate",
":",
"for",
"id... | Links the input curves together.
The end control point of the curve k has to be the same with the start control point of the curve k + 1.
Keyword Arguments:
* ``tol``: tolerance value for checking equality. *Default: 10e-8*
* ``validate``: flag to enable input validation. *Default: False*
... | [
"Links",
"the",
"input",
"curves",
"together",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/_operations.py#L299-L357 | train |
orbingol/NURBS-Python | geomdl/operations.py | add_dimension | def add_dimension(obj, **kwargs):
""" Elevates the spatial dimension of the spline geometry.
If you pass ``inplace=True`` keyword argument, the input will be updated. Otherwise, this function does not
change the input but returns a new instance with the updated data.
:param obj: spline geometry
:t... | python | def add_dimension(obj, **kwargs):
""" Elevates the spatial dimension of the spline geometry.
If you pass ``inplace=True`` keyword argument, the input will be updated. Otherwise, this function does not
change the input but returns a new instance with the updated data.
:param obj: spline geometry
:t... | [
"def",
"add_dimension",
"(",
"obj",
",",
"**",
"kwargs",
")",
":",
"if",
"not",
"isinstance",
"(",
"obj",
",",
"abstract",
".",
"SplineGeometry",
")",
":",
"raise",
"GeomdlException",
"(",
"\"Can only operate on spline geometry objects\"",
")",
"inplace",
"=",
"... | Elevates the spatial dimension of the spline geometry.
If you pass ``inplace=True`` keyword argument, the input will be updated. Otherwise, this function does not
change the input but returns a new instance with the updated data.
:param obj: spline geometry
:type obj: abstract.SplineGeometry
:retu... | [
"Elevates",
"the",
"spatial",
"dimension",
"of",
"the",
"spline",
"geometry",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/operations.py#L877-L909 | train |
orbingol/NURBS-Python | geomdl/operations.py | split_curve | def split_curve(obj, param, **kwargs):
""" Splits the curve at the input parametric coordinate.
This method splits the curve into two pieces at the given parametric coordinate, generates two different
curve objects and returns them. It does not modify the input curve.
Keyword Arguments:
* ``fi... | python | def split_curve(obj, param, **kwargs):
""" Splits the curve at the input parametric coordinate.
This method splits the curve into two pieces at the given parametric coordinate, generates two different
curve objects and returns them. It does not modify the input curve.
Keyword Arguments:
* ``fi... | [
"def",
"split_curve",
"(",
"obj",
",",
"param",
",",
"**",
"kwargs",
")",
":",
"if",
"not",
"isinstance",
"(",
"obj",
",",
"abstract",
".",
"Curve",
")",
":",
"raise",
"GeomdlException",
"(",
"\"Input shape must be an instance of abstract.Curve class\"",
")",
"i... | Splits the curve at the input parametric coordinate.
This method splits the curve into two pieces at the given parametric coordinate, generates two different
curve objects and returns them. It does not modify the input curve.
Keyword Arguments:
* ``find_span_func``: FindSpan implementation. *Defau... | [
"Splits",
"the",
"curve",
"at",
"the",
"input",
"parametric",
"coordinate",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/operations.py#L913-L979 | train |
orbingol/NURBS-Python | geomdl/operations.py | decompose_curve | def decompose_curve(obj, **kwargs):
""" Decomposes the curve into Bezier curve segments of the same degree.
This operation does not modify the input curve, instead it returns the split curve segments.
Keyword Arguments:
* ``find_span_func``: FindSpan implementation. *Default:* :func:`.helpers.find... | python | def decompose_curve(obj, **kwargs):
""" Decomposes the curve into Bezier curve segments of the same degree.
This operation does not modify the input curve, instead it returns the split curve segments.
Keyword Arguments:
* ``find_span_func``: FindSpan implementation. *Default:* :func:`.helpers.find... | [
"def",
"decompose_curve",
"(",
"obj",
",",
"**",
"kwargs",
")",
":",
"if",
"not",
"isinstance",
"(",
"obj",
",",
"abstract",
".",
"Curve",
")",
":",
"raise",
"GeomdlException",
"(",
"\"Input shape must be an instance of abstract.Curve class\"",
")",
"multi_curve",
... | Decomposes the curve into Bezier curve segments of the same degree.
This operation does not modify the input curve, instead it returns the split curve segments.
Keyword Arguments:
* ``find_span_func``: FindSpan implementation. *Default:* :func:`.helpers.find_span_linear`
* ``insert_knot_func``... | [
"Decomposes",
"the",
"curve",
"into",
"Bezier",
"curve",
"segments",
"of",
"the",
"same",
"degree",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/operations.py#L983-L1011 | train |
orbingol/NURBS-Python | geomdl/operations.py | length_curve | def length_curve(obj):
""" Computes the approximate length of the parametric curve.
Uses the following equation to compute the approximate length:
.. math::
\\sum_{i=0}^{n-1} \\sqrt{P_{i + 1}^2-P_{i}^2}
where :math:`n` is number of evaluated curve points and :math:`P` is the n-dimensional po... | python | def length_curve(obj):
""" Computes the approximate length of the parametric curve.
Uses the following equation to compute the approximate length:
.. math::
\\sum_{i=0}^{n-1} \\sqrt{P_{i + 1}^2-P_{i}^2}
where :math:`n` is number of evaluated curve points and :math:`P` is the n-dimensional po... | [
"def",
"length_curve",
"(",
"obj",
")",
":",
"if",
"not",
"isinstance",
"(",
"obj",
",",
"abstract",
".",
"Curve",
")",
":",
"raise",
"GeomdlException",
"(",
"\"Input shape must be an instance of abstract.Curve class\"",
")",
"length",
"=",
"0.0",
"evalpts",
"=",
... | Computes the approximate length of the parametric curve.
Uses the following equation to compute the approximate length:
.. math::
\\sum_{i=0}^{n-1} \\sqrt{P_{i + 1}^2-P_{i}^2}
where :math:`n` is number of evaluated curve points and :math:`P` is the n-dimensional point.
:param obj: input cur... | [
"Computes",
"the",
"approximate",
"length",
"of",
"the",
"parametric",
"curve",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/operations.py#L1054-L1078 | train |
orbingol/NURBS-Python | geomdl/operations.py | split_surface_u | def split_surface_u(obj, param, **kwargs):
""" Splits the surface at the input parametric coordinate on the u-direction.
This method splits the surface into two pieces at the given parametric coordinate on the u-direction,
generates two different surface objects and returns them. It does not modify the inp... | python | def split_surface_u(obj, param, **kwargs):
""" Splits the surface at the input parametric coordinate on the u-direction.
This method splits the surface into two pieces at the given parametric coordinate on the u-direction,
generates two different surface objects and returns them. It does not modify the inp... | [
"def",
"split_surface_u",
"(",
"obj",
",",
"param",
",",
"**",
"kwargs",
")",
":",
"if",
"not",
"isinstance",
"(",
"obj",
",",
"abstract",
".",
"Surface",
")",
":",
"raise",
"GeomdlException",
"(",
"\"Input shape must be an instance of abstract.Surface class\"",
"... | Splits the surface at the input parametric coordinate on the u-direction.
This method splits the surface into two pieces at the given parametric coordinate on the u-direction,
generates two different surface objects and returns them. It does not modify the input surface.
Keyword Arguments:
* ``fin... | [
"Splits",
"the",
"surface",
"at",
"the",
"input",
"parametric",
"coordinate",
"on",
"the",
"u",
"-",
"direction",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/operations.py#L1082-L1151 | train |
orbingol/NURBS-Python | geomdl/operations.py | decompose_surface | def decompose_surface(obj, **kwargs):
""" Decomposes the surface into Bezier surface patches of the same degree.
This operation does not modify the input surface, instead it returns the surface patches.
Keyword Arguments:
* ``find_span_func``: FindSpan implementation. *Default:* :func:`.helpers.fi... | python | def decompose_surface(obj, **kwargs):
""" Decomposes the surface into Bezier surface patches of the same degree.
This operation does not modify the input surface, instead it returns the surface patches.
Keyword Arguments:
* ``find_span_func``: FindSpan implementation. *Default:* :func:`.helpers.fi... | [
"def",
"decompose_surface",
"(",
"obj",
",",
"**",
"kwargs",
")",
":",
"def",
"decompose",
"(",
"srf",
",",
"idx",
",",
"split_func_list",
",",
"**",
"kws",
")",
":",
"srf_list",
"=",
"[",
"]",
"knots",
"=",
"srf",
".",
"knotvector",
"[",
"idx",
"]",... | Decomposes the surface into Bezier surface patches of the same degree.
This operation does not modify the input surface, instead it returns the surface patches.
Keyword Arguments:
* ``find_span_func``: FindSpan implementation. *Default:* :func:`.helpers.find_span_linear`
* ``insert_knot_func``... | [
"Decomposes",
"the",
"surface",
"into",
"Bezier",
"surface",
"patches",
"of",
"the",
"same",
"degree",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/operations.py#L1234-L1293 | train |
orbingol/NURBS-Python | geomdl/operations.py | tangent | def tangent(obj, params, **kwargs):
""" Evaluates the tangent vector of the curves or surfaces at the input parameter values.
This function is designed to evaluate tangent vectors of the B-Spline and NURBS shapes at single or
multiple parameter positions.
:param obj: input shape
:type obj: abstrac... | python | def tangent(obj, params, **kwargs):
""" Evaluates the tangent vector of the curves or surfaces at the input parameter values.
This function is designed to evaluate tangent vectors of the B-Spline and NURBS shapes at single or
multiple parameter positions.
:param obj: input shape
:type obj: abstrac... | [
"def",
"tangent",
"(",
"obj",
",",
"params",
",",
"**",
"kwargs",
")",
":",
"normalize",
"=",
"kwargs",
".",
"get",
"(",
"'normalize'",
",",
"True",
")",
"if",
"isinstance",
"(",
"obj",
",",
"abstract",
".",
"Curve",
")",
":",
"if",
"isinstance",
"("... | Evaluates the tangent vector of the curves or surfaces at the input parameter values.
This function is designed to evaluate tangent vectors of the B-Spline and NURBS shapes at single or
multiple parameter positions.
:param obj: input shape
:type obj: abstract.Curve or abstract.Surface
:param param... | [
"Evaluates",
"the",
"tangent",
"vector",
"of",
"the",
"curves",
"or",
"surfaces",
"at",
"the",
"input",
"parameter",
"values",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/operations.py#L1392-L1415 | train |
orbingol/NURBS-Python | geomdl/operations.py | normal | def normal(obj, params, **kwargs):
""" Evaluates the normal vector of the curves or surfaces at the input parameter values.
This function is designed to evaluate normal vectors of the B-Spline and NURBS shapes at single or
multiple parameter positions.
:param obj: input geometry
:type obj: abstrac... | python | def normal(obj, params, **kwargs):
""" Evaluates the normal vector of the curves or surfaces at the input parameter values.
This function is designed to evaluate normal vectors of the B-Spline and NURBS shapes at single or
multiple parameter positions.
:param obj: input geometry
:type obj: abstrac... | [
"def",
"normal",
"(",
"obj",
",",
"params",
",",
"**",
"kwargs",
")",
":",
"normalize",
"=",
"kwargs",
".",
"get",
"(",
"'normalize'",
",",
"True",
")",
"if",
"isinstance",
"(",
"obj",
",",
"abstract",
".",
"Curve",
")",
":",
"if",
"isinstance",
"(",... | Evaluates the normal vector of the curves or surfaces at the input parameter values.
This function is designed to evaluate normal vectors of the B-Spline and NURBS shapes at single or
multiple parameter positions.
:param obj: input geometry
:type obj: abstract.Curve or abstract.Surface
:param para... | [
"Evaluates",
"the",
"normal",
"vector",
"of",
"the",
"curves",
"or",
"surfaces",
"at",
"the",
"input",
"parameter",
"values",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/operations.py#L1419-L1442 | train |
orbingol/NURBS-Python | geomdl/operations.py | binormal | def binormal(obj, params, **kwargs):
""" Evaluates the binormal vector of the curves or surfaces at the input parameter values.
This function is designed to evaluate binormal vectors of the B-Spline and NURBS shapes at single or
multiple parameter positions.
:param obj: input shape
:type obj: abst... | python | def binormal(obj, params, **kwargs):
""" Evaluates the binormal vector of the curves or surfaces at the input parameter values.
This function is designed to evaluate binormal vectors of the B-Spline and NURBS shapes at single or
multiple parameter positions.
:param obj: input shape
:type obj: abst... | [
"def",
"binormal",
"(",
"obj",
",",
"params",
",",
"**",
"kwargs",
")",
":",
"normalize",
"=",
"kwargs",
".",
"get",
"(",
"'normalize'",
",",
"True",
")",
"if",
"isinstance",
"(",
"obj",
",",
"abstract",
".",
"Curve",
")",
":",
"if",
"isinstance",
"(... | Evaluates the binormal vector of the curves or surfaces at the input parameter values.
This function is designed to evaluate binormal vectors of the B-Spline and NURBS shapes at single or
multiple parameter positions.
:param obj: input shape
:type obj: abstract.Curve or abstract.Surface
:param par... | [
"Evaluates",
"the",
"binormal",
"vector",
"of",
"the",
"curves",
"or",
"surfaces",
"at",
"the",
"input",
"parameter",
"values",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/operations.py#L1446-L1466 | train |
orbingol/NURBS-Python | geomdl/operations.py | translate | def translate(obj, vec, **kwargs):
""" Translates curves, surface or volumes by the input vector.
Keyword Arguments:
* ``inplace``: if False, operation applied to a copy of the object. *Default: False*
:param obj: input geometry
:type obj: abstract.SplineGeometry or multi.AbstractContainer
... | python | def translate(obj, vec, **kwargs):
""" Translates curves, surface or volumes by the input vector.
Keyword Arguments:
* ``inplace``: if False, operation applied to a copy of the object. *Default: False*
:param obj: input geometry
:type obj: abstract.SplineGeometry or multi.AbstractContainer
... | [
"def",
"translate",
"(",
"obj",
",",
"vec",
",",
"**",
"kwargs",
")",
":",
"if",
"not",
"vec",
"or",
"not",
"isinstance",
"(",
"vec",
",",
"(",
"tuple",
",",
"list",
")",
")",
":",
"raise",
"GeomdlException",
"(",
"\"The input must be a list or a tuple\"",... | Translates curves, surface or volumes by the input vector.
Keyword Arguments:
* ``inplace``: if False, operation applied to a copy of the object. *Default: False*
:param obj: input geometry
:type obj: abstract.SplineGeometry or multi.AbstractContainer
:param vec: translation vector
:type v... | [
"Translates",
"curves",
"surface",
"or",
"volumes",
"by",
"the",
"input",
"vector",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/operations.py#L1470-L1506 | train |
orbingol/NURBS-Python | geomdl/operations.py | scale | def scale(obj, multiplier, **kwargs):
""" Scales curves, surfaces or volumes by the input multiplier.
Keyword Arguments:
* ``inplace``: if False, operation applied to a copy of the object. *Default: False*
:param obj: input geometry
:type obj: abstract.SplineGeometry, multi.AbstractGeometry
... | python | def scale(obj, multiplier, **kwargs):
""" Scales curves, surfaces or volumes by the input multiplier.
Keyword Arguments:
* ``inplace``: if False, operation applied to a copy of the object. *Default: False*
:param obj: input geometry
:type obj: abstract.SplineGeometry, multi.AbstractGeometry
... | [
"def",
"scale",
"(",
"obj",
",",
"multiplier",
",",
"**",
"kwargs",
")",
":",
"if",
"not",
"isinstance",
"(",
"multiplier",
",",
"(",
"int",
",",
"float",
")",
")",
":",
"raise",
"GeomdlException",
"(",
"\"The multiplier must be a float or an integer\"",
")",
... | Scales curves, surfaces or volumes by the input multiplier.
Keyword Arguments:
* ``inplace``: if False, operation applied to a copy of the object. *Default: False*
:param obj: input geometry
:type obj: abstract.SplineGeometry, multi.AbstractGeometry
:param multiplier: scaling multiplier
:t... | [
"Scales",
"curves",
"surfaces",
"or",
"volumes",
"by",
"the",
"input",
"multiplier",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/operations.py#L1607-L1638 | train |
orbingol/NURBS-Python | geomdl/voxelize.py | voxelize | def voxelize(obj, **kwargs):
""" Generates binary voxel representation of the surfaces and volumes.
Keyword Arguments:
* ``grid_size``: size of the voxel grid. *Default: (8, 8, 8)*
* ``padding``: voxel padding for in-outs finding. *Default: 10e-8*
* ``use_cubes``: use cube voxels instea... | python | def voxelize(obj, **kwargs):
""" Generates binary voxel representation of the surfaces and volumes.
Keyword Arguments:
* ``grid_size``: size of the voxel grid. *Default: (8, 8, 8)*
* ``padding``: voxel padding for in-outs finding. *Default: 10e-8*
* ``use_cubes``: use cube voxels instea... | [
"def",
"voxelize",
"(",
"obj",
",",
"**",
"kwargs",
")",
":",
"grid_size",
"=",
"kwargs",
".",
"pop",
"(",
"'grid_size'",
",",
"(",
"8",
",",
"8",
",",
"8",
")",
")",
"use_cubes",
"=",
"kwargs",
".",
"pop",
"(",
"'use_cubes'",
",",
"False",
")",
... | Generates binary voxel representation of the surfaces and volumes.
Keyword Arguments:
* ``grid_size``: size of the voxel grid. *Default: (8, 8, 8)*
* ``padding``: voxel padding for in-outs finding. *Default: 10e-8*
* ``use_cubes``: use cube voxels instead of cuboid ones. *Default: False*
... | [
"Generates",
"binary",
"voxel",
"representation",
"of",
"the",
"surfaces",
"and",
"volumes",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/voxelize.py#L16-L56 | train |
orbingol/NURBS-Python | geomdl/voxelize.py | convert_bb_to_faces | def convert_bb_to_faces(voxel_grid):
""" Converts a voxel grid defined by min and max coordinates to a voxel grid defined by faces.
:param voxel_grid: voxel grid defined by the bounding box of all voxels
:return: voxel grid with face data
"""
new_vg = []
for v in voxel_grid:
# Vertices
... | python | def convert_bb_to_faces(voxel_grid):
""" Converts a voxel grid defined by min and max coordinates to a voxel grid defined by faces.
:param voxel_grid: voxel grid defined by the bounding box of all voxels
:return: voxel grid with face data
"""
new_vg = []
for v in voxel_grid:
# Vertices
... | [
"def",
"convert_bb_to_faces",
"(",
"voxel_grid",
")",
":",
"new_vg",
"=",
"[",
"]",
"for",
"v",
"in",
"voxel_grid",
":",
"p1",
"=",
"v",
"[",
"0",
"]",
"p2",
"=",
"[",
"v",
"[",
"1",
"]",
"[",
"0",
"]",
",",
"v",
"[",
"0",
"]",
"[",
"1",
"]... | Converts a voxel grid defined by min and max coordinates to a voxel grid defined by faces.
:param voxel_grid: voxel grid defined by the bounding box of all voxels
:return: voxel grid with face data | [
"Converts",
"a",
"voxel",
"grid",
"defined",
"by",
"min",
"and",
"max",
"coordinates",
"to",
"a",
"voxel",
"grid",
"defined",
"by",
"faces",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/voxelize.py#L59-L85 | train |
orbingol/NURBS-Python | geomdl/voxelize.py | save_voxel_grid | def save_voxel_grid(voxel_grid, file_name):
""" Saves binary voxel grid as a binary file.
The binary file is structured in little-endian unsigned int format.
:param voxel_grid: binary voxel grid
:type voxel_grid: list, tuple
:param file_name: file name to save
:type file_name: str
"""
... | python | def save_voxel_grid(voxel_grid, file_name):
""" Saves binary voxel grid as a binary file.
The binary file is structured in little-endian unsigned int format.
:param voxel_grid: binary voxel grid
:type voxel_grid: list, tuple
:param file_name: file name to save
:type file_name: str
"""
... | [
"def",
"save_voxel_grid",
"(",
"voxel_grid",
",",
"file_name",
")",
":",
"try",
":",
"with",
"open",
"(",
"file_name",
",",
"'wb'",
")",
"as",
"fp",
":",
"for",
"voxel",
"in",
"voxel_grid",
":",
"fp",
".",
"write",
"(",
"struct",
".",
"pack",
"(",
"\... | Saves binary voxel grid as a binary file.
The binary file is structured in little-endian unsigned int format.
:param voxel_grid: binary voxel grid
:type voxel_grid: list, tuple
:param file_name: file name to save
:type file_name: str | [
"Saves",
"binary",
"voxel",
"grid",
"as",
"a",
"binary",
"file",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/voxelize.py#L89-L107 | train |
orbingol/NURBS-Python | geomdl/linalg.py | vector_cross | def vector_cross(vector1, vector2):
""" Computes the cross-product of the input vectors.
:param vector1: input vector 1
:type vector1: list, tuple
:param vector2: input vector 2
:type vector2: list, tuple
:return: result of the cross product
:rtype: tuple
"""
try:
if vector1... | python | def vector_cross(vector1, vector2):
""" Computes the cross-product of the input vectors.
:param vector1: input vector 1
:type vector1: list, tuple
:param vector2: input vector 2
:type vector2: list, tuple
:return: result of the cross product
:rtype: tuple
"""
try:
if vector1... | [
"def",
"vector_cross",
"(",
"vector1",
",",
"vector2",
")",
":",
"try",
":",
"if",
"vector1",
"is",
"None",
"or",
"len",
"(",
"vector1",
")",
"==",
"0",
"or",
"vector2",
"is",
"None",
"or",
"len",
"(",
"vector2",
")",
"==",
"0",
":",
"raise",
"Valu... | Computes the cross-product of the input vectors.
:param vector1: input vector 1
:type vector1: list, tuple
:param vector2: input vector 2
:type vector2: list, tuple
:return: result of the cross product
:rtype: tuple | [
"Computes",
"the",
"cross",
"-",
"product",
"of",
"the",
"input",
"vectors",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/linalg.py#L20-L59 | train |
orbingol/NURBS-Python | geomdl/linalg.py | vector_dot | def vector_dot(vector1, vector2):
""" Computes the dot-product of the input vectors.
:param vector1: input vector 1
:type vector1: list, tuple
:param vector2: input vector 2
:type vector2: list, tuple
:return: result of the dot product
:rtype: float
"""
try:
if vector1 is No... | python | def vector_dot(vector1, vector2):
""" Computes the dot-product of the input vectors.
:param vector1: input vector 1
:type vector1: list, tuple
:param vector2: input vector 2
:type vector2: list, tuple
:return: result of the dot product
:rtype: float
"""
try:
if vector1 is No... | [
"def",
"vector_dot",
"(",
"vector1",
",",
"vector2",
")",
":",
"try",
":",
"if",
"vector1",
"is",
"None",
"or",
"len",
"(",
"vector1",
")",
"==",
"0",
"or",
"vector2",
"is",
"None",
"or",
"len",
"(",
"vector2",
")",
"==",
"0",
":",
"raise",
"ValueE... | Computes the dot-product of the input vectors.
:param vector1: input vector 1
:type vector1: list, tuple
:param vector2: input vector 2
:type vector2: list, tuple
:return: result of the dot product
:rtype: float | [
"Computes",
"the",
"dot",
"-",
"product",
"of",
"the",
"input",
"vectors",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/linalg.py#L62-L87 | train |
orbingol/NURBS-Python | geomdl/linalg.py | vector_sum | def vector_sum(vector1, vector2, coeff=1.0):
""" Sums the vectors.
This function computes the result of the vector operation :math:`\\overline{v}_{1} + c * \\overline{v}_{2}`, where
:math:`\\overline{v}_{1}` is ``vector1``, :math:`\\overline{v}_{2}` is ``vector2`` and :math:`c` is ``coeff``.
:param v... | python | def vector_sum(vector1, vector2, coeff=1.0):
""" Sums the vectors.
This function computes the result of the vector operation :math:`\\overline{v}_{1} + c * \\overline{v}_{2}`, where
:math:`\\overline{v}_{1}` is ``vector1``, :math:`\\overline{v}_{2}` is ``vector2`` and :math:`c` is ``coeff``.
:param v... | [
"def",
"vector_sum",
"(",
"vector1",
",",
"vector2",
",",
"coeff",
"=",
"1.0",
")",
":",
"summed_vector",
"=",
"[",
"v1",
"+",
"(",
"coeff",
"*",
"v2",
")",
"for",
"v1",
",",
"v2",
"in",
"zip",
"(",
"vector1",
",",
"vector2",
")",
"]",
"return",
... | Sums the vectors.
This function computes the result of the vector operation :math:`\\overline{v}_{1} + c * \\overline{v}_{2}`, where
:math:`\\overline{v}_{1}` is ``vector1``, :math:`\\overline{v}_{2}` is ``vector2`` and :math:`c` is ``coeff``.
:param vector1: vector 1
:type vector1: list, tuple
:... | [
"Sums",
"the",
"vectors",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/linalg.py#L106-L122 | train |
orbingol/NURBS-Python | geomdl/linalg.py | vector_normalize | def vector_normalize(vector_in, decimals=18):
""" Generates a unit vector from the input.
:param vector_in: vector to be normalized
:type vector_in: list, tuple
:param decimals: number of significands
:type decimals: int
:return: the normalized vector (i.e. the unit vector)
:rtype: list
... | python | def vector_normalize(vector_in, decimals=18):
""" Generates a unit vector from the input.
:param vector_in: vector to be normalized
:type vector_in: list, tuple
:param decimals: number of significands
:type decimals: int
:return: the normalized vector (i.e. the unit vector)
:rtype: list
... | [
"def",
"vector_normalize",
"(",
"vector_in",
",",
"decimals",
"=",
"18",
")",
":",
"try",
":",
"if",
"vector_in",
"is",
"None",
"or",
"len",
"(",
"vector_in",
")",
"==",
"0",
":",
"raise",
"ValueError",
"(",
"\"Input vector cannot be empty\"",
")",
"except",... | Generates a unit vector from the input.
:param vector_in: vector to be normalized
:type vector_in: list, tuple
:param decimals: number of significands
:type decimals: int
:return: the normalized vector (i.e. the unit vector)
:rtype: list | [
"Generates",
"a",
"unit",
"vector",
"from",
"the",
"input",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/linalg.py#L125-L156 | train |
orbingol/NURBS-Python | geomdl/linalg.py | vector_generate | def vector_generate(start_pt, end_pt, normalize=False):
""" Generates a vector from 2 input points.
:param start_pt: start point of the vector
:type start_pt: list, tuple
:param end_pt: end point of the vector
:type end_pt: list, tuple
:param normalize: if True, the generated vector is normaliz... | python | def vector_generate(start_pt, end_pt, normalize=False):
""" Generates a vector from 2 input points.
:param start_pt: start point of the vector
:type start_pt: list, tuple
:param end_pt: end point of the vector
:type end_pt: list, tuple
:param normalize: if True, the generated vector is normaliz... | [
"def",
"vector_generate",
"(",
"start_pt",
",",
"end_pt",
",",
"normalize",
"=",
"False",
")",
":",
"try",
":",
"if",
"start_pt",
"is",
"None",
"or",
"len",
"(",
"start_pt",
")",
"==",
"0",
"or",
"end_pt",
"is",
"None",
"or",
"len",
"(",
"end_pt",
")... | Generates a vector from 2 input points.
:param start_pt: start point of the vector
:type start_pt: list, tuple
:param end_pt: end point of the vector
:type end_pt: list, tuple
:param normalize: if True, the generated vector is normalized
:type normalize: bool
:return: a vector from start_pt... | [
"Generates",
"a",
"vector",
"from",
"2",
"input",
"points",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/linalg.py#L159-L186 | train |
orbingol/NURBS-Python | geomdl/linalg.py | vector_magnitude | def vector_magnitude(vector_in):
""" Computes the magnitude of the input vector.
:param vector_in: input vector
:type vector_in: list, tuple
:return: magnitude of the vector
:rtype: float
"""
sq_sum = 0.0
for vin in vector_in:
sq_sum += vin**2
return math.sqrt(sq_sum) | python | def vector_magnitude(vector_in):
""" Computes the magnitude of the input vector.
:param vector_in: input vector
:type vector_in: list, tuple
:return: magnitude of the vector
:rtype: float
"""
sq_sum = 0.0
for vin in vector_in:
sq_sum += vin**2
return math.sqrt(sq_sum) | [
"def",
"vector_magnitude",
"(",
"vector_in",
")",
":",
"sq_sum",
"=",
"0.0",
"for",
"vin",
"in",
"vector_in",
":",
"sq_sum",
"+=",
"vin",
"**",
"2",
"return",
"math",
".",
"sqrt",
"(",
"sq_sum",
")"
] | Computes the magnitude of the input vector.
:param vector_in: input vector
:type vector_in: list, tuple
:return: magnitude of the vector
:rtype: float | [
"Computes",
"the",
"magnitude",
"of",
"the",
"input",
"vector",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/linalg.py#L223-L234 | train |
orbingol/NURBS-Python | geomdl/linalg.py | vector_angle_between | def vector_angle_between(vector1, vector2, **kwargs):
""" Computes the angle between the two input vectors.
If the keyword argument ``degrees`` is set to *True*, then the angle will be in degrees. Otherwise, it will be
in radians. By default, ``degrees`` is set to *True*.
:param vector1: vector
:t... | python | def vector_angle_between(vector1, vector2, **kwargs):
""" Computes the angle between the two input vectors.
If the keyword argument ``degrees`` is set to *True*, then the angle will be in degrees. Otherwise, it will be
in radians. By default, ``degrees`` is set to *True*.
:param vector1: vector
:t... | [
"def",
"vector_angle_between",
"(",
"vector1",
",",
"vector2",
",",
"**",
"kwargs",
")",
":",
"degrees",
"=",
"kwargs",
".",
"get",
"(",
"'degrees'",
",",
"True",
")",
"magn1",
"=",
"vector_magnitude",
"(",
"vector1",
")",
"magn2",
"=",
"vector_magnitude",
... | Computes the angle between the two input vectors.
If the keyword argument ``degrees`` is set to *True*, then the angle will be in degrees. Otherwise, it will be
in radians. By default, ``degrees`` is set to *True*.
:param vector1: vector
:type vector1: list, tuple
:param vector2: vector
:type ... | [
"Computes",
"the",
"angle",
"between",
"the",
"two",
"input",
"vectors",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/linalg.py#L237-L258 | train |
orbingol/NURBS-Python | geomdl/linalg.py | vector_is_zero | def vector_is_zero(vector_in, tol=10e-8):
""" Checks if the input vector is a zero vector.
:param vector_in: input vector
:type vector_in: list, tuple
:param tol: tolerance value
:type tol: float
:return: True if the input vector is zero, False otherwise
:rtype: bool
"""
if not isin... | python | def vector_is_zero(vector_in, tol=10e-8):
""" Checks if the input vector is a zero vector.
:param vector_in: input vector
:type vector_in: list, tuple
:param tol: tolerance value
:type tol: float
:return: True if the input vector is zero, False otherwise
:rtype: bool
"""
if not isin... | [
"def",
"vector_is_zero",
"(",
"vector_in",
",",
"tol",
"=",
"10e-8",
")",
":",
"if",
"not",
"isinstance",
"(",
"vector_in",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"raise",
"TypeError",
"(",
"\"Input vector must be a list or a tuple\"",
")",
"res",
"=... | Checks if the input vector is a zero vector.
:param vector_in: input vector
:type vector_in: list, tuple
:param tol: tolerance value
:type tol: float
:return: True if the input vector is zero, False otherwise
:rtype: bool | [
"Checks",
"if",
"the",
"input",
"vector",
"is",
"a",
"zero",
"vector",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/linalg.py#L261-L278 | train |
orbingol/NURBS-Python | geomdl/linalg.py | point_translate | def point_translate(point_in, vector_in):
""" Translates the input points using the input vector.
:param point_in: input point
:type point_in: list, tuple
:param vector_in: input vector
:type vector_in: list, tuple
:return: translated point
:rtype: list
"""
try:
if point_in ... | python | def point_translate(point_in, vector_in):
""" Translates the input points using the input vector.
:param point_in: input point
:type point_in: list, tuple
:param vector_in: input vector
:type vector_in: list, tuple
:return: translated point
:rtype: list
"""
try:
if point_in ... | [
"def",
"point_translate",
"(",
"point_in",
",",
"vector_in",
")",
":",
"try",
":",
"if",
"point_in",
"is",
"None",
"or",
"len",
"(",
"point_in",
")",
"==",
"0",
"or",
"vector_in",
"is",
"None",
"or",
"len",
"(",
"vector_in",
")",
"==",
"0",
":",
"rai... | Translates the input points using the input vector.
:param point_in: input point
:type point_in: list, tuple
:param vector_in: input vector
:type vector_in: list, tuple
:return: translated point
:rtype: list | [
"Translates",
"the",
"input",
"points",
"using",
"the",
"input",
"vector",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/linalg.py#L281-L303 | train |
orbingol/NURBS-Python | geomdl/linalg.py | point_distance | def point_distance(pt1, pt2):
""" Computes distance between two points.
:param pt1: point 1
:type pt1: list, tuple
:param pt2: point 2
:type pt2: list, tuple
:return: distance between input points
:rtype: float
"""
if len(pt1) != len(pt2):
raise ValueError("The input points ... | python | def point_distance(pt1, pt2):
""" Computes distance between two points.
:param pt1: point 1
:type pt1: list, tuple
:param pt2: point 2
:type pt2: list, tuple
:return: distance between input points
:rtype: float
"""
if len(pt1) != len(pt2):
raise ValueError("The input points ... | [
"def",
"point_distance",
"(",
"pt1",
",",
"pt2",
")",
":",
"if",
"len",
"(",
"pt1",
")",
"!=",
"len",
"(",
"pt2",
")",
":",
"raise",
"ValueError",
"(",
"\"The input points should have the same dimension\"",
")",
"dist_vector",
"=",
"vector_generate",
"(",
"pt1... | Computes distance between two points.
:param pt1: point 1
:type pt1: list, tuple
:param pt2: point 2
:type pt2: list, tuple
:return: distance between input points
:rtype: float | [
"Computes",
"distance",
"between",
"two",
"points",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/linalg.py#L306-L321 | train |
orbingol/NURBS-Python | geomdl/linalg.py | point_mid | def point_mid(pt1, pt2):
""" Computes the midpoint of the input points.
:param pt1: point 1
:type pt1: list, tuple
:param pt2: point 2
:type pt2: list, tuple
:return: midpoint
:rtype: list
"""
if len(pt1) != len(pt2):
raise ValueError("The input points should have the same d... | python | def point_mid(pt1, pt2):
""" Computes the midpoint of the input points.
:param pt1: point 1
:type pt1: list, tuple
:param pt2: point 2
:type pt2: list, tuple
:return: midpoint
:rtype: list
"""
if len(pt1) != len(pt2):
raise ValueError("The input points should have the same d... | [
"def",
"point_mid",
"(",
"pt1",
",",
"pt2",
")",
":",
"if",
"len",
"(",
"pt1",
")",
"!=",
"len",
"(",
"pt2",
")",
":",
"raise",
"ValueError",
"(",
"\"The input points should have the same dimension\"",
")",
"dist_vector",
"=",
"vector_generate",
"(",
"pt1",
... | Computes the midpoint of the input points.
:param pt1: point 1
:type pt1: list, tuple
:param pt2: point 2
:type pt2: list, tuple
:return: midpoint
:rtype: list | [
"Computes",
"the",
"midpoint",
"of",
"the",
"input",
"points",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/linalg.py#L324-L339 | train |
orbingol/NURBS-Python | geomdl/linalg.py | matrix_transpose | def matrix_transpose(m):
""" Transposes the input matrix.
The input matrix :math:`m` is a 2-dimensional array.
:param m: input matrix with dimensions :math:`(n \\times m)`
:type m: list, tuple
:return: transpose matrix with dimensions :math:`(m \\times n)`
:rtype: list
"""
num_cols = l... | python | def matrix_transpose(m):
""" Transposes the input matrix.
The input matrix :math:`m` is a 2-dimensional array.
:param m: input matrix with dimensions :math:`(n \\times m)`
:type m: list, tuple
:return: transpose matrix with dimensions :math:`(m \\times n)`
:rtype: list
"""
num_cols = l... | [
"def",
"matrix_transpose",
"(",
"m",
")",
":",
"num_cols",
"=",
"len",
"(",
"m",
")",
"num_rows",
"=",
"len",
"(",
"m",
"[",
"0",
"]",
")",
"m_t",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"num_rows",
")",
":",
"temp",
"=",
"[",
"]",
"fo... | Transposes the input matrix.
The input matrix :math:`m` is a 2-dimensional array.
:param m: input matrix with dimensions :math:`(n \\times m)`
:type m: list, tuple
:return: transpose matrix with dimensions :math:`(m \\times n)`
:rtype: list | [
"Transposes",
"the",
"input",
"matrix",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/linalg.py#L342-L360 | train |
orbingol/NURBS-Python | geomdl/linalg.py | triangle_center | def triangle_center(tri, uv=False):
""" Computes the center of mass of the input triangle.
:param tri: triangle object
:type tri: elements.Triangle
:param uv: if True, then finds parametric position of the center of mass
:type uv: bool
:return: center of mass of the triangle
:rtype: tuple
... | python | def triangle_center(tri, uv=False):
""" Computes the center of mass of the input triangle.
:param tri: triangle object
:type tri: elements.Triangle
:param uv: if True, then finds parametric position of the center of mass
:type uv: bool
:return: center of mass of the triangle
:rtype: tuple
... | [
"def",
"triangle_center",
"(",
"tri",
",",
"uv",
"=",
"False",
")",
":",
"if",
"uv",
":",
"data",
"=",
"[",
"t",
".",
"uv",
"for",
"t",
"in",
"tri",
"]",
"mid",
"=",
"[",
"0.0",
",",
"0.0",
"]",
"else",
":",
"data",
"=",
"tri",
".",
"vertices... | Computes the center of mass of the input triangle.
:param tri: triangle object
:type tri: elements.Triangle
:param uv: if True, then finds parametric position of the center of mass
:type uv: bool
:return: center of mass of the triangle
:rtype: tuple | [
"Computes",
"the",
"center",
"of",
"mass",
"of",
"the",
"input",
"triangle",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/linalg.py#L396-L415 | train |
orbingol/NURBS-Python | geomdl/linalg.py | lu_decomposition | def lu_decomposition(matrix_a):
""" LU-Factorization method using Doolittle's Method for solution of linear systems.
Decomposes the matrix :math:`A` such that :math:`A = LU`.
The input matrix is represented by a list or a tuple. The input matrix is **2-dimensional**, i.e. list of lists of
integers and... | python | def lu_decomposition(matrix_a):
""" LU-Factorization method using Doolittle's Method for solution of linear systems.
Decomposes the matrix :math:`A` such that :math:`A = LU`.
The input matrix is represented by a list or a tuple. The input matrix is **2-dimensional**, i.e. list of lists of
integers and... | [
"def",
"lu_decomposition",
"(",
"matrix_a",
")",
":",
"q",
"=",
"len",
"(",
"matrix_a",
")",
"for",
"idx",
",",
"m_a",
"in",
"enumerate",
"(",
"matrix_a",
")",
":",
"if",
"len",
"(",
"m_a",
")",
"!=",
"q",
":",
"raise",
"ValueError",
"(",
"\"The inpu... | LU-Factorization method using Doolittle's Method for solution of linear systems.
Decomposes the matrix :math:`A` such that :math:`A = LU`.
The input matrix is represented by a list or a tuple. The input matrix is **2-dimensional**, i.e. list of lists of
integers and/or floats.
:param matrix_a: Input ... | [
"LU",
"-",
"Factorization",
"method",
"using",
"Doolittle",
"s",
"Method",
"for",
"solution",
"of",
"linear",
"systems",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/linalg.py#L441-L462 | train |
orbingol/NURBS-Python | geomdl/linalg.py | forward_substitution | def forward_substitution(matrix_l, matrix_b):
""" Forward substitution method for the solution of linear systems.
Solves the equation :math:`Ly = b` using forward substitution method
where :math:`L` is a lower triangular matrix and :math:`b` is a column matrix.
:param matrix_l: L, lower triangular mat... | python | def forward_substitution(matrix_l, matrix_b):
""" Forward substitution method for the solution of linear systems.
Solves the equation :math:`Ly = b` using forward substitution method
where :math:`L` is a lower triangular matrix and :math:`b` is a column matrix.
:param matrix_l: L, lower triangular mat... | [
"def",
"forward_substitution",
"(",
"matrix_l",
",",
"matrix_b",
")",
":",
"q",
"=",
"len",
"(",
"matrix_b",
")",
"matrix_y",
"=",
"[",
"0.0",
"for",
"_",
"in",
"range",
"(",
"q",
")",
"]",
"matrix_y",
"[",
"0",
"]",
"=",
"float",
"(",
"matrix_b",
... | Forward substitution method for the solution of linear systems.
Solves the equation :math:`Ly = b` using forward substitution method
where :math:`L` is a lower triangular matrix and :math:`b` is a column matrix.
:param matrix_l: L, lower triangular matrix
:type matrix_l: list, tuple
:param matrix_... | [
"Forward",
"substitution",
"method",
"for",
"the",
"solution",
"of",
"linear",
"systems",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/linalg.py#L465-L484 | train |
orbingol/NURBS-Python | geomdl/linalg.py | backward_substitution | def backward_substitution(matrix_u, matrix_y):
""" Backward substitution method for the solution of linear systems.
Solves the equation :math:`Ux = y` using backward substitution method
where :math:`U` is a upper triangular matrix and :math:`y` is a column matrix.
:param matrix_u: U, upper triangular ... | python | def backward_substitution(matrix_u, matrix_y):
""" Backward substitution method for the solution of linear systems.
Solves the equation :math:`Ux = y` using backward substitution method
where :math:`U` is a upper triangular matrix and :math:`y` is a column matrix.
:param matrix_u: U, upper triangular ... | [
"def",
"backward_substitution",
"(",
"matrix_u",
",",
"matrix_y",
")",
":",
"q",
"=",
"len",
"(",
"matrix_y",
")",
"matrix_x",
"=",
"[",
"0.0",
"for",
"_",
"in",
"range",
"(",
"q",
")",
"]",
"matrix_x",
"[",
"q",
"-",
"1",
"]",
"=",
"float",
"(",
... | Backward substitution method for the solution of linear systems.
Solves the equation :math:`Ux = y` using backward substitution method
where :math:`U` is a upper triangular matrix and :math:`y` is a column matrix.
:param matrix_u: U, upper triangular matrix
:type matrix_u: list, tuple
:param matri... | [
"Backward",
"substitution",
"method",
"for",
"the",
"solution",
"of",
"linear",
"systems",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/linalg.py#L487-L506 | train |
orbingol/NURBS-Python | geomdl/linalg.py | linspace | def linspace(start, stop, num, decimals=18):
""" Returns a list of evenly spaced numbers over a specified interval.
Inspired from Numpy's linspace function: https://github.com/numpy/numpy/blob/master/numpy/core/function_base.py
:param start: starting value
:type start: float
:param stop: end value... | python | def linspace(start, stop, num, decimals=18):
""" Returns a list of evenly spaced numbers over a specified interval.
Inspired from Numpy's linspace function: https://github.com/numpy/numpy/blob/master/numpy/core/function_base.py
:param start: starting value
:type start: float
:param stop: end value... | [
"def",
"linspace",
"(",
"start",
",",
"stop",
",",
"num",
",",
"decimals",
"=",
"18",
")",
":",
"start",
"=",
"float",
"(",
"start",
")",
"stop",
"=",
"float",
"(",
"stop",
")",
"if",
"abs",
"(",
"start",
"-",
"stop",
")",
"<=",
"10e-8",
":",
"... | Returns a list of evenly spaced numbers over a specified interval.
Inspired from Numpy's linspace function: https://github.com/numpy/numpy/blob/master/numpy/core/function_base.py
:param start: starting value
:type start: float
:param stop: end value
:type stop: float
:param num: number of samp... | [
"Returns",
"a",
"list",
"of",
"evenly",
"spaced",
"numbers",
"over",
"a",
"specified",
"interval",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/linalg.py#L509-L535 | train |
orbingol/NURBS-Python | geomdl/linalg.py | convex_hull | def convex_hull(points):
""" Returns points on convex hull in counterclockwise order according to Graham's scan algorithm.
Reference: https://gist.github.com/arthur-e/5cf52962341310f438e96c1f3c3398b8
.. note:: This implementation only works in 2-dimensional space.
:param points: list of 2-dimensional... | python | def convex_hull(points):
""" Returns points on convex hull in counterclockwise order according to Graham's scan algorithm.
Reference: https://gist.github.com/arthur-e/5cf52962341310f438e96c1f3c3398b8
.. note:: This implementation only works in 2-dimensional space.
:param points: list of 2-dimensional... | [
"def",
"convex_hull",
"(",
"points",
")",
":",
"turn_left",
",",
"turn_right",
",",
"turn_none",
"=",
"(",
"1",
",",
"-",
"1",
",",
"0",
")",
"def",
"cmp",
"(",
"a",
",",
"b",
")",
":",
"return",
"(",
"a",
">",
"b",
")",
"-",
"(",
"a",
"<",
... | Returns points on convex hull in counterclockwise order according to Graham's scan algorithm.
Reference: https://gist.github.com/arthur-e/5cf52962341310f438e96c1f3c3398b8
.. note:: This implementation only works in 2-dimensional space.
:param points: list of 2-dimensional points
:type points: list, t... | [
"Returns",
"points",
"on",
"convex",
"hull",
"in",
"counterclockwise",
"order",
"according",
"to",
"Graham",
"s",
"scan",
"algorithm",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/linalg.py#L565-L595 | train |
orbingol/NURBS-Python | geomdl/linalg.py | is_left | def is_left(point0, point1, point2):
""" Tests if a point is Left|On|Right of an infinite line.
Ported from the C++ version: on http://geomalgorithms.com/a03-_inclusion.html
.. note:: This implementation only works in 2-dimensional space.
:param point0: Point P0
:param point1: Point P1
:param... | python | def is_left(point0, point1, point2):
""" Tests if a point is Left|On|Right of an infinite line.
Ported from the C++ version: on http://geomalgorithms.com/a03-_inclusion.html
.. note:: This implementation only works in 2-dimensional space.
:param point0: Point P0
:param point1: Point P1
:param... | [
"def",
"is_left",
"(",
"point0",
",",
"point1",
",",
"point2",
")",
":",
"return",
"(",
"(",
"point1",
"[",
"0",
"]",
"-",
"point0",
"[",
"0",
"]",
")",
"*",
"(",
"point2",
"[",
"1",
"]",
"-",
"point0",
"[",
"1",
"]",
")",
")",
"-",
"(",
"(... | Tests if a point is Left|On|Right of an infinite line.
Ported from the C++ version: on http://geomalgorithms.com/a03-_inclusion.html
.. note:: This implementation only works in 2-dimensional space.
:param point0: Point P0
:param point1: Point P1
:param point2: Point P2
:return:
>0 for... | [
"Tests",
"if",
"a",
"point",
"is",
"Left|On|Right",
"of",
"an",
"infinite",
"line",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/linalg.py#L598-L613 | train |
orbingol/NURBS-Python | geomdl/linalg.py | wn_poly | def wn_poly(point, vertices):
""" Winding number test for a point in a polygon.
Ported from the C++ version: http://geomalgorithms.com/a03-_inclusion.html
.. note:: This implementation only works in 2-dimensional space.
:param point: point to be tested
:type point: list, tuple
:param vertices... | python | def wn_poly(point, vertices):
""" Winding number test for a point in a polygon.
Ported from the C++ version: http://geomalgorithms.com/a03-_inclusion.html
.. note:: This implementation only works in 2-dimensional space.
:param point: point to be tested
:type point: list, tuple
:param vertices... | [
"def",
"wn_poly",
"(",
"point",
",",
"vertices",
")",
":",
"wn",
"=",
"0",
"v_size",
"=",
"len",
"(",
"vertices",
")",
"-",
"1",
"for",
"i",
"in",
"range",
"(",
"v_size",
")",
":",
"if",
"vertices",
"[",
"i",
"]",
"[",
"1",
"]",
"<=",
"point",
... | Winding number test for a point in a polygon.
Ported from the C++ version: http://geomalgorithms.com/a03-_inclusion.html
.. note:: This implementation only works in 2-dimensional space.
:param point: point to be tested
:type point: list, tuple
:param vertices: vertex points of a polygon vertices[... | [
"Winding",
"number",
"test",
"for",
"a",
"point",
"in",
"a",
"polygon",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/linalg.py#L616-L644 | train |
orbingol/NURBS-Python | geomdl/construct.py | construct_surface | def construct_surface(direction, *args, **kwargs):
""" Generates surfaces from curves.
Arguments:
* ``args``: a list of curve instances
Keyword Arguments (optional):
* ``degree``: degree of the 2nd parametric direction
* ``knotvector``: knot vector of the 2nd parametric direction
... | python | def construct_surface(direction, *args, **kwargs):
""" Generates surfaces from curves.
Arguments:
* ``args``: a list of curve instances
Keyword Arguments (optional):
* ``degree``: degree of the 2nd parametric direction
* ``knotvector``: knot vector of the 2nd parametric direction
... | [
"def",
"construct_surface",
"(",
"direction",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"possible_dirs",
"=",
"[",
"'u'",
",",
"'v'",
"]",
"if",
"direction",
"not",
"in",
"possible_dirs",
":",
"raise",
"GeomdlException",
"(",
"\"Possible direction value... | Generates surfaces from curves.
Arguments:
* ``args``: a list of curve instances
Keyword Arguments (optional):
* ``degree``: degree of the 2nd parametric direction
* ``knotvector``: knot vector of the 2nd parametric direction
* ``rational``: flag to generate rational surfaces
... | [
"Generates",
"surfaces",
"from",
"curves",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/construct.py#L16-L100 | train |
orbingol/NURBS-Python | geomdl/construct.py | extract_curves | def extract_curves(psurf, **kwargs):
""" Extracts curves from a surface.
The return value is a ``dict`` object containing the following keys:
* ``u``: the curves which generate u-direction (or which lie on the v-direction)
* ``v``: the curves which generate v-direction (or which lie on the u-direction... | python | def extract_curves(psurf, **kwargs):
""" Extracts curves from a surface.
The return value is a ``dict`` object containing the following keys:
* ``u``: the curves which generate u-direction (or which lie on the v-direction)
* ``v``: the curves which generate v-direction (or which lie on the u-direction... | [
"def",
"extract_curves",
"(",
"psurf",
",",
"**",
"kwargs",
")",
":",
"if",
"psurf",
".",
"pdimension",
"!=",
"2",
":",
"raise",
"GeomdlException",
"(",
"\"The input should be a spline surface\"",
")",
"if",
"len",
"(",
"psurf",
")",
"!=",
"1",
":",
"raise",... | Extracts curves from a surface.
The return value is a ``dict`` object containing the following keys:
* ``u``: the curves which generate u-direction (or which lie on the v-direction)
* ``v``: the curves which generate v-direction (or which lie on the u-direction)
As an example; if a curve lies on the ... | [
"Extracts",
"curves",
"from",
"a",
"surface",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/construct.py#L208-L270 | train |
orbingol/NURBS-Python | geomdl/construct.py | extract_surfaces | def extract_surfaces(pvol):
""" Extracts surfaces from a volume.
:param pvol: input volume
:type pvol: abstract.Volume
:return: extracted surface
:rtype: dict
"""
if pvol.pdimension != 3:
raise GeomdlException("The input should be a spline volume")
if len(pvol) != 1:
rai... | python | def extract_surfaces(pvol):
""" Extracts surfaces from a volume.
:param pvol: input volume
:type pvol: abstract.Volume
:return: extracted surface
:rtype: dict
"""
if pvol.pdimension != 3:
raise GeomdlException("The input should be a spline volume")
if len(pvol) != 1:
rai... | [
"def",
"extract_surfaces",
"(",
"pvol",
")",
":",
"if",
"pvol",
".",
"pdimension",
"!=",
"3",
":",
"raise",
"GeomdlException",
"(",
"\"The input should be a spline volume\"",
")",
"if",
"len",
"(",
"pvol",
")",
"!=",
"1",
":",
"raise",
"GeomdlException",
"(",
... | Extracts surfaces from a volume.
:param pvol: input volume
:type pvol: abstract.Volume
:return: extracted surface
:rtype: dict | [
"Extracts",
"surfaces",
"from",
"a",
"volume",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/construct.py#L273-L343 | train |
orbingol/NURBS-Python | geomdl/construct.py | extract_isosurface | def extract_isosurface(pvol):
""" Extracts the largest isosurface from a volume.
The following example illustrates one of the usage scenarios:
.. code-block:: python
:linenos:
from geomdl import construct, multi
from geomdl.visualization import VisMPL
# Assuming that "myv... | python | def extract_isosurface(pvol):
""" Extracts the largest isosurface from a volume.
The following example illustrates one of the usage scenarios:
.. code-block:: python
:linenos:
from geomdl import construct, multi
from geomdl.visualization import VisMPL
# Assuming that "myv... | [
"def",
"extract_isosurface",
"(",
"pvol",
")",
":",
"if",
"pvol",
".",
"pdimension",
"!=",
"3",
":",
"raise",
"GeomdlException",
"(",
"\"The input should be a spline volume\"",
")",
"if",
"len",
"(",
"pvol",
")",
"!=",
"1",
":",
"raise",
"GeomdlException",
"("... | Extracts the largest isosurface from a volume.
The following example illustrates one of the usage scenarios:
.. code-block:: python
:linenos:
from geomdl import construct, multi
from geomdl.visualization import VisMPL
# Assuming that "myvol" variable stores your spline volume... | [
"Extracts",
"the",
"largest",
"isosurface",
"from",
"a",
"volume",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/construct.py#L346-L383 | train |
orbingol/NURBS-Python | geomdl/trimming.py | check_trim_curve | def check_trim_curve(curve, parbox, **kwargs):
""" Checks if the trim curve was closed and sense was set.
:param curve: trim curve
:param parbox: parameter space bounding box of the underlying surface
:return: a tuple containing the status of the operation and list of extra trim curves generated
:r... | python | def check_trim_curve(curve, parbox, **kwargs):
""" Checks if the trim curve was closed and sense was set.
:param curve: trim curve
:param parbox: parameter space bounding box of the underlying surface
:return: a tuple containing the status of the operation and list of extra trim curves generated
:r... | [
"def",
"check_trim_curve",
"(",
"curve",
",",
"parbox",
",",
"**",
"kwargs",
")",
":",
"def",
"next_idx",
"(",
"edge_idx",
",",
"direction",
")",
":",
"tmp",
"=",
"edge_idx",
"+",
"direction",
"if",
"tmp",
"<",
"0",
":",
"return",
"3",
"if",
"tmp",
"... | Checks if the trim curve was closed and sense was set.
:param curve: trim curve
:param parbox: parameter space bounding box of the underlying surface
:return: a tuple containing the status of the operation and list of extra trim curves generated
:rtype: tuple | [
"Checks",
"if",
"the",
"trim",
"curve",
"was",
"closed",
"and",
"sense",
"was",
"set",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/trimming.py#L174-L278 | train |
orbingol/NURBS-Python | geomdl/trimming.py | get_par_box | def get_par_box(domain, last=False):
""" Returns the bounding box of the surface parametric domain in ccw direction.
:param domain: parametric domain
:type domain: list, tuple
:param last: if True, adds the first vertex to the end of the return list
:type last: bool
:return: edges of the parame... | python | def get_par_box(domain, last=False):
""" Returns the bounding box of the surface parametric domain in ccw direction.
:param domain: parametric domain
:type domain: list, tuple
:param last: if True, adds the first vertex to the end of the return list
:type last: bool
:return: edges of the parame... | [
"def",
"get_par_box",
"(",
"domain",
",",
"last",
"=",
"False",
")",
":",
"u_range",
"=",
"domain",
"[",
"0",
"]",
"v_range",
"=",
"domain",
"[",
"1",
"]",
"verts",
"=",
"[",
"(",
"u_range",
"[",
"0",
"]",
",",
"v_range",
"[",
"0",
"]",
")",
",... | Returns the bounding box of the surface parametric domain in ccw direction.
:param domain: parametric domain
:type domain: list, tuple
:param last: if True, adds the first vertex to the end of the return list
:type last: bool
:return: edges of the parametric domain
:rtype: tuple | [
"Returns",
"the",
"bounding",
"box",
"of",
"the",
"surface",
"parametric",
"domain",
"in",
"ccw",
"direction",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/trimming.py#L281-L296 | train |
orbingol/NURBS-Python | geomdl/trimming.py | detect_sense | def detect_sense(curve, tol):
""" Detects the sense, i.e. clockwise or counter-clockwise, of the curve.
:param curve: 2-dimensional trim curve
:type curve: abstract.Curve
:param tol: tolerance value
:type tol: float
:return: True if detection is successful, False otherwise
:rtype: bool
... | python | def detect_sense(curve, tol):
""" Detects the sense, i.e. clockwise or counter-clockwise, of the curve.
:param curve: 2-dimensional trim curve
:type curve: abstract.Curve
:param tol: tolerance value
:type tol: float
:return: True if detection is successful, False otherwise
:rtype: bool
... | [
"def",
"detect_sense",
"(",
"curve",
",",
"tol",
")",
":",
"if",
"curve",
".",
"opt_get",
"(",
"'reversed'",
")",
"is",
"None",
":",
"pts",
"=",
"curve",
".",
"evalpts",
"num_pts",
"=",
"len",
"(",
"pts",
")",
"for",
"idx",
"in",
"range",
"(",
"1",... | Detects the sense, i.e. clockwise or counter-clockwise, of the curve.
:param curve: 2-dimensional trim curve
:type curve: abstract.Curve
:param tol: tolerance value
:type tol: float
:return: True if detection is successful, False otherwise
:rtype: bool | [
"Detects",
"the",
"sense",
"i",
".",
"e",
".",
"clockwise",
"or",
"counter",
"-",
"clockwise",
"of",
"the",
"curve",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/trimming.py#L299-L336 | train |
orbingol/NURBS-Python | geomdl/ray.py | intersect | def intersect(ray1, ray2, **kwargs):
""" Finds intersection of 2 rays.
This functions finds the parameter values for the 1st and 2nd input rays and returns a tuple of
``(parameter for ray1, parameter for ray2, intersection status)``.
``status`` value is a enum type which reports the case which the inte... | python | def intersect(ray1, ray2, **kwargs):
""" Finds intersection of 2 rays.
This functions finds the parameter values for the 1st and 2nd input rays and returns a tuple of
``(parameter for ray1, parameter for ray2, intersection status)``.
``status`` value is a enum type which reports the case which the inte... | [
"def",
"intersect",
"(",
"ray1",
",",
"ray2",
",",
"**",
"kwargs",
")",
":",
"if",
"not",
"isinstance",
"(",
"ray1",
",",
"Ray",
")",
"or",
"not",
"isinstance",
"(",
"ray2",
",",
"Ray",
")",
":",
"raise",
"TypeError",
"(",
"\"The input arguments must be ... | Finds intersection of 2 rays.
This functions finds the parameter values for the 1st and 2nd input rays and returns a tuple of
``(parameter for ray1, parameter for ray2, intersection status)``.
``status`` value is a enum type which reports the case which the intersection operation encounters.
The inter... | [
"Finds",
"intersection",
"of",
"2",
"rays",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/ray.py#L107-L150 | train |
orbingol/NURBS-Python | geomdl/freeform.py | Freeform.evaluate | def evaluate(self, **kwargs):
""" Sets points that form the geometry.
Keyword Arguments:
* ``points``: sets the points
"""
self._eval_points = kwargs.get('points', self._init_array())
self._dimension = len(self._eval_points[0]) | python | def evaluate(self, **kwargs):
""" Sets points that form the geometry.
Keyword Arguments:
* ``points``: sets the points
"""
self._eval_points = kwargs.get('points', self._init_array())
self._dimension = len(self._eval_points[0]) | [
"def",
"evaluate",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"self",
".",
"_eval_points",
"=",
"kwargs",
".",
"get",
"(",
"'points'",
",",
"self",
".",
"_init_array",
"(",
")",
")",
"self",
".",
"_dimension",
"=",
"len",
"(",
"self",
".",
"_eval_po... | Sets points that form the geometry.
Keyword Arguments:
* ``points``: sets the points | [
"Sets",
"points",
"that",
"form",
"the",
"geometry",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/freeform.py#L20-L27 | train |
orbingol/NURBS-Python | geomdl/exchange_vtk.py | export_polydata | def export_polydata(obj, file_name, **kwargs):
""" Exports control points or evaluated points in VTK Polydata format.
Please see the following document for details: http://www.vtk.org/VTK/img/file-formats.pdf
Keyword Arguments:
* ``point_type``: **ctrlpts** for control points or **evalpts** for ev... | python | def export_polydata(obj, file_name, **kwargs):
""" Exports control points or evaluated points in VTK Polydata format.
Please see the following document for details: http://www.vtk.org/VTK/img/file-formats.pdf
Keyword Arguments:
* ``point_type``: **ctrlpts** for control points or **evalpts** for ev... | [
"def",
"export_polydata",
"(",
"obj",
",",
"file_name",
",",
"**",
"kwargs",
")",
":",
"content",
"=",
"export_polydata_str",
"(",
"obj",
",",
"**",
"kwargs",
")",
"return",
"exch",
".",
"write_file",
"(",
"file_name",
",",
"content",
")"
] | Exports control points or evaluated points in VTK Polydata format.
Please see the following document for details: http://www.vtk.org/VTK/img/file-formats.pdf
Keyword Arguments:
* ``point_type``: **ctrlpts** for control points or **evalpts** for evaluated points
* ``tessellate``: tessellates th... | [
"Exports",
"control",
"points",
"or",
"evaluated",
"points",
"in",
"VTK",
"Polydata",
"format",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/exchange_vtk.py#L125-L141 | train |
orbingol/NURBS-Python | geomdl/utilities.py | make_zigzag | def make_zigzag(points, num_cols):
""" Converts linear sequence of points into a zig-zag shape.
This function is designed to create input for the visualization software. It orders the points to draw a zig-zag
shape which enables generating properly connected lines without any scanlines. Please see the belo... | python | def make_zigzag(points, num_cols):
""" Converts linear sequence of points into a zig-zag shape.
This function is designed to create input for the visualization software. It orders the points to draw a zig-zag
shape which enables generating properly connected lines without any scanlines. Please see the belo... | [
"def",
"make_zigzag",
"(",
"points",
",",
"num_cols",
")",
":",
"new_points",
"=",
"[",
"]",
"points_size",
"=",
"len",
"(",
"points",
")",
"forward",
"=",
"True",
"idx",
"=",
"0",
"rev_idx",
"=",
"-",
"1",
"while",
"idx",
"<",
"points_size",
":",
"i... | Converts linear sequence of points into a zig-zag shape.
This function is designed to create input for the visualization software. It orders the points to draw a zig-zag
shape which enables generating properly connected lines without any scanlines. Please see the below sketch on the
functionality of the ``... | [
"Converts",
"linear",
"sequence",
"of",
"points",
"into",
"a",
"zig",
"-",
"zag",
"shape",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/utilities.py#L40-L80 | train |
orbingol/NURBS-Python | geomdl/utilities.py | make_quad | def make_quad(points, size_u, size_v):
""" Converts linear sequence of input points into a quad structure.
:param points: list of points to be ordered
:type points: list, tuple
:param size_v: number of elements in a row
:type size_v: int
:param size_u: number of elements in a column
:type s... | python | def make_quad(points, size_u, size_v):
""" Converts linear sequence of input points into a quad structure.
:param points: list of points to be ordered
:type points: list, tuple
:param size_v: number of elements in a row
:type size_v: int
:param size_u: number of elements in a column
:type s... | [
"def",
"make_quad",
"(",
"points",
",",
"size_u",
",",
"size_v",
")",
":",
"new_points",
"=",
"make_zigzag",
"(",
"points",
",",
"size_v",
")",
"new_points",
".",
"reverse",
"(",
")",
"forward",
"=",
"True",
"for",
"row",
"in",
"range",
"(",
"0",
",",
... | Converts linear sequence of input points into a quad structure.
:param points: list of points to be ordered
:type points: list, tuple
:param size_v: number of elements in a row
:type size_v: int
:param size_u: number of elements in a column
:type size_u: int
:return: re-ordered points
:... | [
"Converts",
"linear",
"sequence",
"of",
"input",
"points",
"into",
"a",
"quad",
"structure",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/utilities.py#L83-L112 | train |
orbingol/NURBS-Python | geomdl/utilities.py | make_quadtree | def make_quadtree(points, size_u, size_v, **kwargs):
""" Generates a quadtree-like structure from surface control points.
This function generates a 2-dimensional list of control point coordinates. Considering the object-oriented
representation of a quadtree data structure, first dimension of the generated ... | python | def make_quadtree(points, size_u, size_v, **kwargs):
""" Generates a quadtree-like structure from surface control points.
This function generates a 2-dimensional list of control point coordinates. Considering the object-oriented
representation of a quadtree data structure, first dimension of the generated ... | [
"def",
"make_quadtree",
"(",
"points",
",",
"size_u",
",",
"size_v",
",",
"**",
"kwargs",
")",
":",
"extrapolate",
"=",
"kwargs",
".",
"get",
"(",
"'extrapolate'",
",",
"True",
")",
"points2d",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"0",
",",... | Generates a quadtree-like structure from surface control points.
This function generates a 2-dimensional list of control point coordinates. Considering the object-oriented
representation of a quadtree data structure, first dimension of the generated list corresponds to a list of
*QuadTree* classes. Second ... | [
"Generates",
"a",
"quadtree",
"-",
"like",
"structure",
"from",
"surface",
"control",
"points",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/utilities.py#L115-L189 | train |
orbingol/NURBS-Python | geomdl/utilities.py | evaluate_bounding_box | def evaluate_bounding_box(ctrlpts):
""" Computes the minimum bounding box of the point set.
The (minimum) bounding box is the smallest enclosure in which all the input points lie.
:param ctrlpts: points
:type ctrlpts: list, tuple
:return: bounding box in the format [min, max]
:rtype: tuple
... | python | def evaluate_bounding_box(ctrlpts):
""" Computes the minimum bounding box of the point set.
The (minimum) bounding box is the smallest enclosure in which all the input points lie.
:param ctrlpts: points
:type ctrlpts: list, tuple
:return: bounding box in the format [min, max]
:rtype: tuple
... | [
"def",
"evaluate_bounding_box",
"(",
"ctrlpts",
")",
":",
"dimension",
"=",
"len",
"(",
"ctrlpts",
"[",
"0",
"]",
")",
"bbmin",
"=",
"[",
"float",
"(",
"'inf'",
")",
"for",
"_",
"in",
"range",
"(",
"0",
",",
"dimension",
")",
"]",
"bbmax",
"=",
"["... | Computes the minimum bounding box of the point set.
The (minimum) bounding box is the smallest enclosure in which all the input points lie.
:param ctrlpts: points
:type ctrlpts: list, tuple
:return: bounding box in the format [min, max]
:rtype: tuple | [
"Computes",
"the",
"minimum",
"bounding",
"box",
"of",
"the",
"point",
"set",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/utilities.py#L192-L216 | train |
orbingol/NURBS-Python | geomdl/_tessellate.py | make_triangle_mesh | def make_triangle_mesh(points, size_u, size_v, **kwargs):
""" Generates a triangular mesh from an array of points.
This function generates a triangular mesh for a NURBS or B-Spline surface on its parametric space.
The input is the surface points and the number of points on the parametric dimensions u and v... | python | def make_triangle_mesh(points, size_u, size_v, **kwargs):
""" Generates a triangular mesh from an array of points.
This function generates a triangular mesh for a NURBS or B-Spline surface on its parametric space.
The input is the surface points and the number of points on the parametric dimensions u and v... | [
"def",
"make_triangle_mesh",
"(",
"points",
",",
"size_u",
",",
"size_v",
",",
"**",
"kwargs",
")",
":",
"def",
"fix_numbering",
"(",
"vertex_list",
",",
"triangle_list",
")",
":",
"final_vertices",
"=",
"[",
"]",
"tri_vertex_ids",
"=",
"[",
"]",
"for",
"t... | Generates a triangular mesh from an array of points.
This function generates a triangular mesh for a NURBS or B-Spline surface on its parametric space.
The input is the surface points and the number of points on the parametric dimensions u and v,
indicated as row and column sizes in the function signature.... | [
"Generates",
"a",
"triangular",
"mesh",
"from",
"an",
"array",
"of",
"points",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/_tessellate.py#L18-L148 | train |
orbingol/NURBS-Python | geomdl/_tessellate.py | polygon_triangulate | def polygon_triangulate(tri_idx, *args):
""" Triangulates a monotone polygon defined by a list of vertices.
The input vertices must form a convex polygon and must be arranged in counter-clockwise order.
:param tri_idx: triangle numbering start value
:type tri_idx: int
:param args: list of Vertex o... | python | def polygon_triangulate(tri_idx, *args):
""" Triangulates a monotone polygon defined by a list of vertices.
The input vertices must form a convex polygon and must be arranged in counter-clockwise order.
:param tri_idx: triangle numbering start value
:type tri_idx: int
:param args: list of Vertex o... | [
"def",
"polygon_triangulate",
"(",
"tri_idx",
",",
"*",
"args",
")",
":",
"tidx",
"=",
"0",
"triangles",
"=",
"[",
"]",
"for",
"idx",
"in",
"range",
"(",
"1",
",",
"len",
"(",
"args",
")",
"-",
"1",
")",
":",
"tri",
"=",
"Triangle",
"(",
")",
"... | Triangulates a monotone polygon defined by a list of vertices.
The input vertices must form a convex polygon and must be arranged in counter-clockwise order.
:param tri_idx: triangle numbering start value
:type tri_idx: int
:param args: list of Vertex objects
:type args: Vertex
:return: list o... | [
"Triangulates",
"a",
"monotone",
"polygon",
"defined",
"by",
"a",
"list",
"of",
"vertices",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/_tessellate.py#L151-L176 | train |
orbingol/NURBS-Python | geomdl/_tessellate.py | make_quad_mesh | def make_quad_mesh(points, size_u, size_v):
""" Generates a mesh of quadrilateral elements.
:param points: list of points
:type points: list, tuple
:param size_u: number of points on the u-direction (column)
:type size_u: int
:param size_v: number of points on the v-direction (row)
:type si... | python | def make_quad_mesh(points, size_u, size_v):
""" Generates a mesh of quadrilateral elements.
:param points: list of points
:type points: list, tuple
:param size_u: number of points on the u-direction (column)
:type size_u: int
:param size_v: number of points on the v-direction (row)
:type si... | [
"def",
"make_quad_mesh",
"(",
"points",
",",
"size_u",
",",
"size_v",
")",
":",
"vertex_idx",
"=",
"0",
"quad_idx",
"=",
"0",
"vertices",
"=",
"[",
"]",
"for",
"pt",
"in",
"points",
":",
"vrt",
"=",
"Vertex",
"(",
"*",
"pt",
",",
"id",
"=",
"vertex... | Generates a mesh of quadrilateral elements.
:param points: list of points
:type points: list, tuple
:param size_u: number of points on the u-direction (column)
:type size_u: int
:param size_v: number of points on the v-direction (row)
:type size_v: int
:return: a tuple containing lists of v... | [
"Generates",
"a",
"mesh",
"of",
"quadrilateral",
"elements",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/_tessellate.py#L179-L214 | train |
orbingol/NURBS-Python | geomdl/_tessellate.py | surface_tessellate | def surface_tessellate(v1, v2, v3, v4, vidx, tidx, trim_curves, tessellate_args):
""" Triangular tessellation algorithm for surfaces with no trims.
This function can be directly used as an input to :func:`.make_triangle_mesh` using ``tessellate_func`` keyword
argument.
:param v1: vertex 1
:type v1... | python | def surface_tessellate(v1, v2, v3, v4, vidx, tidx, trim_curves, tessellate_args):
""" Triangular tessellation algorithm for surfaces with no trims.
This function can be directly used as an input to :func:`.make_triangle_mesh` using ``tessellate_func`` keyword
argument.
:param v1: vertex 1
:type v1... | [
"def",
"surface_tessellate",
"(",
"v1",
",",
"v2",
",",
"v3",
",",
"v4",
",",
"vidx",
",",
"tidx",
",",
"trim_curves",
",",
"tessellate_args",
")",
":",
"tris",
"=",
"polygon_triangulate",
"(",
"tidx",
",",
"v1",
",",
"v2",
",",
"v3",
",",
"v4",
")",... | Triangular tessellation algorithm for surfaces with no trims.
This function can be directly used as an input to :func:`.make_triangle_mesh` using ``tessellate_func`` keyword
argument.
:param v1: vertex 1
:type v1: Vertex
:param v2: vertex 2
:type v2: Vertex
:param v3: vertex 3
:type v3... | [
"Triangular",
"tessellation",
"algorithm",
"for",
"surfaces",
"with",
"no",
"trims",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/_tessellate.py#L217-L246 | train |
Bearle/django-private-chat | django_private_chat/handlers.py | gone_online | def gone_online(stream):
"""
Distributes the users online status to everyone he has dialog with
"""
while True:
packet = yield from stream.get()
session_id = packet.get('session_key')
if session_id:
user_owner = get_user_from_session(session_id)
i... | python | def gone_online(stream):
"""
Distributes the users online status to everyone he has dialog with
"""
while True:
packet = yield from stream.get()
session_id = packet.get('session_key')
if session_id:
user_owner = get_user_from_session(session_id)
i... | [
"def",
"gone_online",
"(",
"stream",
")",
":",
"while",
"True",
":",
"packet",
"=",
"yield",
"from",
"stream",
".",
"get",
"(",
")",
"session_id",
"=",
"packet",
".",
"get",
"(",
"'session_key'",
")",
"if",
"session_id",
":",
"user_owner",
"=",
"get_user... | Distributes the users online status to everyone he has dialog with | [
"Distributes",
"the",
"users",
"online",
"status",
"to",
"everyone",
"he",
"has",
"dialog",
"with"
] | 5b51e65875795c5c0ce21bb631c53bd3aac4c26b | https://github.com/Bearle/django-private-chat/blob/5b51e65875795c5c0ce21bb631c53bd3aac4c26b/django_private_chat/handlers.py#L40-L60 | train |
Bearle/django-private-chat | django_private_chat/handlers.py | new_messages_handler | def new_messages_handler(stream):
"""
Saves a new chat message to db and distributes msg to connected users
"""
# TODO: handle no user found exception
while True:
packet = yield from stream.get()
session_id = packet.get('session_key')
msg = packet.get('message')
... | python | def new_messages_handler(stream):
"""
Saves a new chat message to db and distributes msg to connected users
"""
# TODO: handle no user found exception
while True:
packet = yield from stream.get()
session_id = packet.get('session_key')
msg = packet.get('message')
... | [
"def",
"new_messages_handler",
"(",
"stream",
")",
":",
"while",
"True",
":",
"packet",
"=",
"yield",
"from",
"stream",
".",
"get",
"(",
")",
"session_id",
"=",
"packet",
".",
"get",
"(",
"'session_key'",
")",
"msg",
"=",
"packet",
".",
"get",
"(",
"'m... | Saves a new chat message to db and distributes msg to connected users | [
"Saves",
"a",
"new",
"chat",
"message",
"to",
"db",
"and",
"distributes",
"msg",
"to",
"connected",
"users"
] | 5b51e65875795c5c0ce21bb631c53bd3aac4c26b | https://github.com/Bearle/django-private-chat/blob/5b51e65875795c5c0ce21bb631c53bd3aac4c26b/django_private_chat/handlers.py#L118-L165 | train |
Bearle/django-private-chat | django_private_chat/handlers.py | users_changed_handler | def users_changed_handler(stream):
"""
Sends connected client list of currently active users in the chatroom
"""
while True:
yield from stream.get()
# Get list list of current active users
users = [
{'username': username, 'uuid': uuid_str}
for u... | python | def users_changed_handler(stream):
"""
Sends connected client list of currently active users in the chatroom
"""
while True:
yield from stream.get()
# Get list list of current active users
users = [
{'username': username, 'uuid': uuid_str}
for u... | [
"def",
"users_changed_handler",
"(",
"stream",
")",
":",
"while",
"True",
":",
"yield",
"from",
"stream",
".",
"get",
"(",
")",
"users",
"=",
"[",
"{",
"'username'",
":",
"username",
",",
"'uuid'",
":",
"uuid_str",
"}",
"for",
"username",
",",
"uuid_str"... | Sends connected client list of currently active users in the chatroom | [
"Sends",
"connected",
"client",
"list",
"of",
"currently",
"active",
"users",
"in",
"the",
"chatroom"
] | 5b51e65875795c5c0ce21bb631c53bd3aac4c26b | https://github.com/Bearle/django-private-chat/blob/5b51e65875795c5c0ce21bb631c53bd3aac4c26b/django_private_chat/handlers.py#L169-L188 | train |
Bearle/django-private-chat | django_private_chat/handlers.py | is_typing_handler | def is_typing_handler(stream):
"""
Show message to opponent if user is typing message
"""
while True:
packet = yield from stream.get()
session_id = packet.get('session_key')
user_opponent = packet.get('username')
typing = packet.get('typing')
if session_i... | python | def is_typing_handler(stream):
"""
Show message to opponent if user is typing message
"""
while True:
packet = yield from stream.get()
session_id = packet.get('session_key')
user_opponent = packet.get('username')
typing = packet.get('typing')
if session_i... | [
"def",
"is_typing_handler",
"(",
"stream",
")",
":",
"while",
"True",
":",
"packet",
"=",
"yield",
"from",
"stream",
".",
"get",
"(",
")",
"session_id",
"=",
"packet",
".",
"get",
"(",
"'session_key'",
")",
"user_opponent",
"=",
"packet",
".",
"get",
"("... | Show message to opponent if user is typing message | [
"Show",
"message",
"to",
"opponent",
"if",
"user",
"is",
"typing",
"message"
] | 5b51e65875795c5c0ce21bb631c53bd3aac4c26b | https://github.com/Bearle/django-private-chat/blob/5b51e65875795c5c0ce21bb631c53bd3aac4c26b/django_private_chat/handlers.py#L192-L211 | train |
Bearle/django-private-chat | django_private_chat/handlers.py | read_message_handler | def read_message_handler(stream):
"""
Send message to user if the opponent has read the message
"""
while True:
packet = yield from stream.get()
session_id = packet.get('session_key')
user_opponent = packet.get('username')
message_id = packet.get('message_id')
... | python | def read_message_handler(stream):
"""
Send message to user if the opponent has read the message
"""
while True:
packet = yield from stream.get()
session_id = packet.get('session_key')
user_opponent = packet.get('username')
message_id = packet.get('message_id')
... | [
"def",
"read_message_handler",
"(",
"stream",
")",
":",
"while",
"True",
":",
"packet",
"=",
"yield",
"from",
"stream",
".",
"get",
"(",
")",
"session_id",
"=",
"packet",
".",
"get",
"(",
"'session_key'",
")",
"user_opponent",
"=",
"packet",
".",
"get",
... | Send message to user if the opponent has read the message | [
"Send",
"message",
"to",
"user",
"if",
"the",
"opponent",
"has",
"read",
"the",
"message"
] | 5b51e65875795c5c0ce21bb631c53bd3aac4c26b | https://github.com/Bearle/django-private-chat/blob/5b51e65875795c5c0ce21bb631c53bd3aac4c26b/django_private_chat/handlers.py#L215-L242 | train |
Bearle/django-private-chat | django_private_chat/handlers.py | main_handler | def main_handler(websocket, path):
"""
An Asyncio Task is created for every new websocket client connection
that is established. This coroutine listens to messages from the connected
client and routes the message to the proper queue.
This coroutine can be thought of as a producer.
"""
... | python | def main_handler(websocket, path):
"""
An Asyncio Task is created for every new websocket client connection
that is established. This coroutine listens to messages from the connected
client and routes the message to the proper queue.
This coroutine can be thought of as a producer.
"""
... | [
"def",
"main_handler",
"(",
"websocket",
",",
"path",
")",
":",
"path",
"=",
"path",
".",
"split",
"(",
"'/'",
")",
"username",
"=",
"path",
"[",
"2",
"]",
"session_id",
"=",
"path",
"[",
"1",
"]",
"user_owner",
"=",
"get_user_from_session",
"(",
"sess... | An Asyncio Task is created for every new websocket client connection
that is established. This coroutine listens to messages from the connected
client and routes the message to the proper queue.
This coroutine can be thought of as a producer. | [
"An",
"Asyncio",
"Task",
"is",
"created",
"for",
"every",
"new",
"websocket",
"client",
"connection",
"that",
"is",
"established",
".",
"This",
"coroutine",
"listens",
"to",
"messages",
"from",
"the",
"connected",
"client",
"and",
"routes",
"the",
"message",
"... | 5b51e65875795c5c0ce21bb631c53bd3aac4c26b | https://github.com/Bearle/django-private-chat/blob/5b51e65875795c5c0ce21bb631c53bd3aac4c26b/django_private_chat/handlers.py#L246-L283 | train |
blockstack/blockstack-core | api/search/substring_search.py | anyword_substring_search_inner | def anyword_substring_search_inner(query_word, target_words):
""" return True if ANY target_word matches a query_word
"""
for target_word in target_words:
if(target_word.startswith(query_word)):
return query_word
return False | python | def anyword_substring_search_inner(query_word, target_words):
""" return True if ANY target_word matches a query_word
"""
for target_word in target_words:
if(target_word.startswith(query_word)):
return query_word
return False | [
"def",
"anyword_substring_search_inner",
"(",
"query_word",
",",
"target_words",
")",
":",
"for",
"target_word",
"in",
"target_words",
":",
"if",
"(",
"target_word",
".",
"startswith",
"(",
"query_word",
")",
")",
":",
"return",
"query_word",
"return",
"False"
] | return True if ANY target_word matches a query_word | [
"return",
"True",
"if",
"ANY",
"target_word",
"matches",
"a",
"query_word"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/api/search/substring_search.py#L41-L50 | train |
blockstack/blockstack-core | api/search/substring_search.py | anyword_substring_search | def anyword_substring_search(target_words, query_words):
""" return True if all query_words match
"""
matches_required = len(query_words)
matches_found = 0
for query_word in query_words:
reply = anyword_substring_search_inner(query_word, target_words)
if reply is not False:
... | python | def anyword_substring_search(target_words, query_words):
""" return True if all query_words match
"""
matches_required = len(query_words)
matches_found = 0
for query_word in query_words:
reply = anyword_substring_search_inner(query_word, target_words)
if reply is not False:
... | [
"def",
"anyword_substring_search",
"(",
"target_words",
",",
"query_words",
")",
":",
"matches_required",
"=",
"len",
"(",
"query_words",
")",
"matches_found",
"=",
"0",
"for",
"query_word",
"in",
"query_words",
":",
"reply",
"=",
"anyword_substring_search_inner",
"... | return True if all query_words match | [
"return",
"True",
"if",
"all",
"query_words",
"match"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/api/search/substring_search.py#L53-L76 | train |
blockstack/blockstack-core | api/search/substring_search.py | substring_search | def substring_search(query, list_of_strings, limit_results=DEFAULT_LIMIT):
""" main function to call for searching
"""
matching = []
query_words = query.split(' ')
# sort by longest word (higest probability of not finding a match)
query_words.sort(key=len, reverse=True)
counter = 0
... | python | def substring_search(query, list_of_strings, limit_results=DEFAULT_LIMIT):
""" main function to call for searching
"""
matching = []
query_words = query.split(' ')
# sort by longest word (higest probability of not finding a match)
query_words.sort(key=len, reverse=True)
counter = 0
... | [
"def",
"substring_search",
"(",
"query",
",",
"list_of_strings",
",",
"limit_results",
"=",
"DEFAULT_LIMIT",
")",
":",
"matching",
"=",
"[",
"]",
"query_words",
"=",
"query",
".",
"split",
"(",
"' '",
")",
"query_words",
".",
"sort",
"(",
"key",
"=",
"len"... | main function to call for searching | [
"main",
"function",
"to",
"call",
"for",
"searching"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/api/search/substring_search.py#L79-L105 | train |
blockstack/blockstack-core | api/search/substring_search.py | search_people_by_bio | def search_people_by_bio(query, limit_results=DEFAULT_LIMIT,
index=['onename_people_index']):
""" queries lucene index to find a nearest match, output is profile username
"""
from pyes import QueryStringQuery, ES
conn = ES()
q = QueryStringQuery(query,
... | python | def search_people_by_bio(query, limit_results=DEFAULT_LIMIT,
index=['onename_people_index']):
""" queries lucene index to find a nearest match, output is profile username
"""
from pyes import QueryStringQuery, ES
conn = ES()
q = QueryStringQuery(query,
... | [
"def",
"search_people_by_bio",
"(",
"query",
",",
"limit_results",
"=",
"DEFAULT_LIMIT",
",",
"index",
"=",
"[",
"'onename_people_index'",
"]",
")",
":",
"from",
"pyes",
"import",
"QueryStringQuery",
",",
"ES",
"conn",
"=",
"ES",
"(",
")",
"q",
"=",
"QuerySt... | queries lucene index to find a nearest match, output is profile username | [
"queries",
"lucene",
"index",
"to",
"find",
"a",
"nearest",
"match",
"output",
"is",
"profile",
"username"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/api/search/substring_search.py#L172-L210 | train |
blockstack/blockstack-core | api/search/substring_search.py | order_search_results | def order_search_results(query, search_results):
""" order of results should be a) query in first name, b) query in last name
"""
results = search_results
results_names = []
old_query = query
query = query.split(' ')
first_word = ''
second_word = ''
third_word = ''
if(len(que... | python | def order_search_results(query, search_results):
""" order of results should be a) query in first name, b) query in last name
"""
results = search_results
results_names = []
old_query = query
query = query.split(' ')
first_word = ''
second_word = ''
third_word = ''
if(len(que... | [
"def",
"order_search_results",
"(",
"query",
",",
"search_results",
")",
":",
"results",
"=",
"search_results",
"results_names",
"=",
"[",
"]",
"old_query",
"=",
"query",
"query",
"=",
"query",
".",
"split",
"(",
"' '",
")",
"first_word",
"=",
"''",
"second_... | order of results should be a) query in first name, b) query in last name | [
"order",
"of",
"results",
"should",
"be",
"a",
")",
"query",
"in",
"first",
"name",
"b",
")",
"query",
"in",
"last",
"name"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/api/search/substring_search.py#L242-L295 | train |
blockstack/blockstack-core | blockstack/lib/storage/auth.py | get_data_hash | def get_data_hash(data_txt):
"""
Generate a hash over data for immutable storage.
Return the hex string.
"""
h = hashlib.sha256()
h.update(data_txt)
return h.hexdigest() | python | def get_data_hash(data_txt):
"""
Generate a hash over data for immutable storage.
Return the hex string.
"""
h = hashlib.sha256()
h.update(data_txt)
return h.hexdigest() | [
"def",
"get_data_hash",
"(",
"data_txt",
")",
":",
"h",
"=",
"hashlib",
".",
"sha256",
"(",
")",
"h",
".",
"update",
"(",
"data_txt",
")",
"return",
"h",
".",
"hexdigest",
"(",
")"
] | Generate a hash over data for immutable storage.
Return the hex string. | [
"Generate",
"a",
"hash",
"over",
"data",
"for",
"immutable",
"storage",
".",
"Return",
"the",
"hex",
"string",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/storage/auth.py#L32-L39 | train |
blockstack/blockstack-core | blockstack/lib/storage/auth.py | verify_zonefile | def verify_zonefile( zonefile_str, value_hash ):
"""
Verify that a zonefile hashes to the given value hash
@zonefile_str must be the zonefile as a serialized string
"""
zonefile_hash = get_zonefile_data_hash( zonefile_str )
if zonefile_hash != value_hash:
log.debug("Zonefile hash mismatc... | python | def verify_zonefile( zonefile_str, value_hash ):
"""
Verify that a zonefile hashes to the given value hash
@zonefile_str must be the zonefile as a serialized string
"""
zonefile_hash = get_zonefile_data_hash( zonefile_str )
if zonefile_hash != value_hash:
log.debug("Zonefile hash mismatc... | [
"def",
"verify_zonefile",
"(",
"zonefile_str",
",",
"value_hash",
")",
":",
"zonefile_hash",
"=",
"get_zonefile_data_hash",
"(",
"zonefile_str",
")",
"if",
"zonefile_hash",
"!=",
"value_hash",
":",
"log",
".",
"debug",
"(",
"\"Zonefile hash mismatch: expected %s, got %s... | Verify that a zonefile hashes to the given value hash
@zonefile_str must be the zonefile as a serialized string | [
"Verify",
"that",
"a",
"zonefile",
"hashes",
"to",
"the",
"given",
"value",
"hash"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/storage/auth.py#L50-L60 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | atlas_peer_table_lock | def atlas_peer_table_lock():
"""
Lock the global health info table.
Return the table.
"""
global PEER_TABLE_LOCK, PEER_TABLE, PEER_TABLE_LOCK_HOLDER, PEER_TABLE_LOCK_TRACEBACK
if PEER_TABLE_LOCK_HOLDER is not None:
assert PEER_TABLE_LOCK_HOLDER != threading.current_thread(), "DEADLOCK"
... | python | def atlas_peer_table_lock():
"""
Lock the global health info table.
Return the table.
"""
global PEER_TABLE_LOCK, PEER_TABLE, PEER_TABLE_LOCK_HOLDER, PEER_TABLE_LOCK_TRACEBACK
if PEER_TABLE_LOCK_HOLDER is not None:
assert PEER_TABLE_LOCK_HOLDER != threading.current_thread(), "DEADLOCK"
... | [
"def",
"atlas_peer_table_lock",
"(",
")",
":",
"global",
"PEER_TABLE_LOCK",
",",
"PEER_TABLE",
",",
"PEER_TABLE_LOCK_HOLDER",
",",
"PEER_TABLE_LOCK_TRACEBACK",
"if",
"PEER_TABLE_LOCK_HOLDER",
"is",
"not",
"None",
":",
"assert",
"PEER_TABLE_LOCK_HOLDER",
"!=",
"threading",... | Lock the global health info table.
Return the table. | [
"Lock",
"the",
"global",
"health",
"info",
"table",
".",
"Return",
"the",
"table",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L352-L368 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | atlas_peer_table_unlock | def atlas_peer_table_unlock():
"""
Unlock the global health info table.
"""
global PEER_TABLE_LOCK, PEER_TABLE_LOCK_HOLDER, PEER_TABLE_LOCK_TRACEBACK
try:
assert PEER_TABLE_LOCK_HOLDER == threading.current_thread()
except:
log.error("Locked by %s, unlocked by %s" % (PEER_TAB... | python | def atlas_peer_table_unlock():
"""
Unlock the global health info table.
"""
global PEER_TABLE_LOCK, PEER_TABLE_LOCK_HOLDER, PEER_TABLE_LOCK_TRACEBACK
try:
assert PEER_TABLE_LOCK_HOLDER == threading.current_thread()
except:
log.error("Locked by %s, unlocked by %s" % (PEER_TAB... | [
"def",
"atlas_peer_table_unlock",
"(",
")",
":",
"global",
"PEER_TABLE_LOCK",
",",
"PEER_TABLE_LOCK_HOLDER",
",",
"PEER_TABLE_LOCK_TRACEBACK",
"try",
":",
"assert",
"PEER_TABLE_LOCK_HOLDER",
"==",
"threading",
".",
"current_thread",
"(",
")",
"except",
":",
"log",
"."... | Unlock the global health info table. | [
"Unlock",
"the",
"global",
"health",
"info",
"table",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L387-L405 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | atlasdb_format_query | def atlasdb_format_query( query, values ):
"""
Turn a query into a string for printing.
Useful for debugging.
"""
return "".join( ["%s %s" % (frag, "'%s'" % val if type(val) in [str, unicode] else val) for (frag, val) in zip(query.split("?"), values + ("",))] ) | python | def atlasdb_format_query( query, values ):
"""
Turn a query into a string for printing.
Useful for debugging.
"""
return "".join( ["%s %s" % (frag, "'%s'" % val if type(val) in [str, unicode] else val) for (frag, val) in zip(query.split("?"), values + ("",))] ) | [
"def",
"atlasdb_format_query",
"(",
"query",
",",
"values",
")",
":",
"return",
"\"\"",
".",
"join",
"(",
"[",
"\"%s %s\"",
"%",
"(",
"frag",
",",
"\"'%s'\"",
"%",
"val",
"if",
"type",
"(",
"val",
")",
"in",
"[",
"str",
",",
"unicode",
"]",
"else",
... | Turn a query into a string for printing.
Useful for debugging. | [
"Turn",
"a",
"query",
"into",
"a",
"string",
"for",
"printing",
".",
"Useful",
"for",
"debugging",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L532-L537 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | atlasdb_open | def atlasdb_open( path ):
"""
Open the atlas db.
Return a connection.
Return None if it doesn't exist
"""
if not os.path.exists(path):
log.debug("Atlas DB doesn't exist at %s" % path)
return None
con = sqlite3.connect( path, isolation_level=None )
con.row_factory = atlas... | python | def atlasdb_open( path ):
"""
Open the atlas db.
Return a connection.
Return None if it doesn't exist
"""
if not os.path.exists(path):
log.debug("Atlas DB doesn't exist at %s" % path)
return None
con = sqlite3.connect( path, isolation_level=None )
con.row_factory = atlas... | [
"def",
"atlasdb_open",
"(",
"path",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"path",
")",
":",
"log",
".",
"debug",
"(",
"\"Atlas DB doesn't exist at %s\"",
"%",
"path",
")",
"return",
"None",
"con",
"=",
"sqlite3",
".",
"connect",
... | Open the atlas db.
Return a connection.
Return None if it doesn't exist | [
"Open",
"the",
"atlas",
"db",
".",
"Return",
"a",
"connection",
".",
"Return",
"None",
"if",
"it",
"doesn",
"t",
"exist"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L550-L562 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | atlasdb_add_zonefile_info | def atlasdb_add_zonefile_info( name, zonefile_hash, txid, present, tried_storage, block_height, con=None, path=None ):
"""
Add a zonefile to the database.
Mark it as present or absent.
Keep our in-RAM inventory vector up-to-date
"""
global ZONEFILE_INV, NUM_ZONEFILES, ZONEFILE_INV_LOCK
with... | python | def atlasdb_add_zonefile_info( name, zonefile_hash, txid, present, tried_storage, block_height, con=None, path=None ):
"""
Add a zonefile to the database.
Mark it as present or absent.
Keep our in-RAM inventory vector up-to-date
"""
global ZONEFILE_INV, NUM_ZONEFILES, ZONEFILE_INV_LOCK
with... | [
"def",
"atlasdb_add_zonefile_info",
"(",
"name",
",",
"zonefile_hash",
",",
"txid",
",",
"present",
",",
"tried_storage",
",",
"block_height",
",",
"con",
"=",
"None",
",",
"path",
"=",
"None",
")",
":",
"global",
"ZONEFILE_INV",
",",
"NUM_ZONEFILES",
",",
"... | Add a zonefile to the database.
Mark it as present or absent.
Keep our in-RAM inventory vector up-to-date | [
"Add",
"a",
"zonefile",
"to",
"the",
"database",
".",
"Mark",
"it",
"as",
"present",
"or",
"absent",
".",
"Keep",
"our",
"in",
"-",
"RAM",
"inventory",
"vector",
"up",
"-",
"to",
"-",
"date"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L565-L616 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | atlasdb_get_lastblock | def atlasdb_get_lastblock( con=None, path=None ):
"""
Get the highest block height in the atlas db
"""
row = None
with AtlasDBOpen(con=con, path=path) as dbcon:
sql = "SELECT MAX(block_height) FROM zonefiles;"
args = ()
cur = dbcon.cursor()
res = atlasdb_query_execu... | python | def atlasdb_get_lastblock( con=None, path=None ):
"""
Get the highest block height in the atlas db
"""
row = None
with AtlasDBOpen(con=con, path=path) as dbcon:
sql = "SELECT MAX(block_height) FROM zonefiles;"
args = ()
cur = dbcon.cursor()
res = atlasdb_query_execu... | [
"def",
"atlasdb_get_lastblock",
"(",
"con",
"=",
"None",
",",
"path",
"=",
"None",
")",
":",
"row",
"=",
"None",
"with",
"AtlasDBOpen",
"(",
"con",
"=",
"con",
",",
"path",
"=",
"path",
")",
"as",
"dbcon",
":",
"sql",
"=",
"\"SELECT MAX(block_height) FRO... | Get the highest block height in the atlas db | [
"Get",
"the",
"highest",
"block",
"height",
"in",
"the",
"atlas",
"db"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L619-L637 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | atlasdb_get_zonefiles_missing_count_by_name | def atlasdb_get_zonefiles_missing_count_by_name(name, max_index=None, indexes_exclude=[], con=None, path=None):
"""
Get the number of missing zone files for a particular name, optionally up to a maximum
zonefile index and optionally omitting particular zone files in the count.
Returns an integer
"""... | python | def atlasdb_get_zonefiles_missing_count_by_name(name, max_index=None, indexes_exclude=[], con=None, path=None):
"""
Get the number of missing zone files for a particular name, optionally up to a maximum
zonefile index and optionally omitting particular zone files in the count.
Returns an integer
"""... | [
"def",
"atlasdb_get_zonefiles_missing_count_by_name",
"(",
"name",
",",
"max_index",
"=",
"None",
",",
"indexes_exclude",
"=",
"[",
"]",
",",
"con",
"=",
"None",
",",
"path",
"=",
"None",
")",
":",
"with",
"AtlasDBOpen",
"(",
"con",
"=",
"con",
",",
"path"... | Get the number of missing zone files for a particular name, optionally up to a maximum
zonefile index and optionally omitting particular zone files in the count.
Returns an integer | [
"Get",
"the",
"number",
"of",
"missing",
"zone",
"files",
"for",
"a",
"particular",
"name",
"optionally",
"up",
"to",
"a",
"maximum",
"zonefile",
"index",
"and",
"optionally",
"omitting",
"particular",
"zone",
"files",
"in",
"the",
"count",
".",
"Returns",
"... | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L764-L783 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | atlasdb_get_zonefiles_by_hash | def atlasdb_get_zonefiles_by_hash(zonefile_hash, block_height=None, con=None, path=None):
"""
Find all instances of this zone file in the atlasdb.
Optionally filter on block height
Returns [{'name': ..., 'zonefile_hash': ..., 'txid': ..., 'inv_index': ..., 'block_height': ..., 'present': ..., 'tried_st... | python | def atlasdb_get_zonefiles_by_hash(zonefile_hash, block_height=None, con=None, path=None):
"""
Find all instances of this zone file in the atlasdb.
Optionally filter on block height
Returns [{'name': ..., 'zonefile_hash': ..., 'txid': ..., 'inv_index': ..., 'block_height': ..., 'present': ..., 'tried_st... | [
"def",
"atlasdb_get_zonefiles_by_hash",
"(",
"zonefile_hash",
",",
"block_height",
"=",
"None",
",",
"con",
"=",
"None",
",",
"path",
"=",
"None",
")",
":",
"with",
"AtlasDBOpen",
"(",
"con",
"=",
"con",
",",
"path",
"=",
"path",
")",
"as",
"dbcon",
":",... | Find all instances of this zone file in the atlasdb.
Optionally filter on block height
Returns [{'name': ..., 'zonefile_hash': ..., 'txid': ..., 'inv_index': ..., 'block_height': ..., 'present': ..., 'tried_storage': ...}], in blockchain order
Returns None if the zone file is not in the db, or if block_hei... | [
"Find",
"all",
"instances",
"of",
"this",
"zone",
"file",
"in",
"the",
"atlasdb",
".",
"Optionally",
"filter",
"on",
"block",
"height"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L786-L817 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | atlasdb_set_zonefile_tried_storage | def atlasdb_set_zonefile_tried_storage( zonefile_hash, tried_storage, con=None, path=None ):
"""
Make a note that we tried to get the zonefile from storage
"""
with AtlasDBOpen(con=con, path=path) as dbcon:
if tried_storage:
tried_storage = 1
else:
tried_storage =... | python | def atlasdb_set_zonefile_tried_storage( zonefile_hash, tried_storage, con=None, path=None ):
"""
Make a note that we tried to get the zonefile from storage
"""
with AtlasDBOpen(con=con, path=path) as dbcon:
if tried_storage:
tried_storage = 1
else:
tried_storage =... | [
"def",
"atlasdb_set_zonefile_tried_storage",
"(",
"zonefile_hash",
",",
"tried_storage",
",",
"con",
"=",
"None",
",",
"path",
"=",
"None",
")",
":",
"with",
"AtlasDBOpen",
"(",
"con",
"=",
"con",
",",
"path",
"=",
"path",
")",
"as",
"dbcon",
":",
"if",
... | Make a note that we tried to get the zonefile from storage | [
"Make",
"a",
"note",
"that",
"we",
"tried",
"to",
"get",
"the",
"zonefile",
"from",
"storage"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L865-L882 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | atlasdb_reset_zonefile_tried_storage | def atlasdb_reset_zonefile_tried_storage( con=None, path=None ):
"""
For zonefiles that we don't have, re-attempt to fetch them from storage.
"""
with AtlasDBOpen(con=con, path=path) as dbcon:
sql = "UPDATE zonefiles SET tried_storage = ? WHERE present = ?;"
args = (0, 0)
cur ... | python | def atlasdb_reset_zonefile_tried_storage( con=None, path=None ):
"""
For zonefiles that we don't have, re-attempt to fetch them from storage.
"""
with AtlasDBOpen(con=con, path=path) as dbcon:
sql = "UPDATE zonefiles SET tried_storage = ? WHERE present = ?;"
args = (0, 0)
cur ... | [
"def",
"atlasdb_reset_zonefile_tried_storage",
"(",
"con",
"=",
"None",
",",
"path",
"=",
"None",
")",
":",
"with",
"AtlasDBOpen",
"(",
"con",
"=",
"con",
",",
"path",
"=",
"path",
")",
"as",
"dbcon",
":",
"sql",
"=",
"\"UPDATE zonefiles SET tried_storage = ? ... | For zonefiles that we don't have, re-attempt to fetch them from storage. | [
"For",
"zonefiles",
"that",
"we",
"don",
"t",
"have",
"re",
"-",
"attempt",
"to",
"fetch",
"them",
"from",
"storage",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L885-L899 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | atlasdb_cache_zonefile_info | def atlasdb_cache_zonefile_info( con=None, path=None ):
"""
Load up and cache our zonefile inventory from the database
"""
global ZONEFILE_INV, NUM_ZONEFILES, ZONEFILE_INV_LOCK
inv = None
with ZONEFILE_INV_LOCK:
inv_len = atlasdb_zonefile_inv_length( con=con, path=path )
inv... | python | def atlasdb_cache_zonefile_info( con=None, path=None ):
"""
Load up and cache our zonefile inventory from the database
"""
global ZONEFILE_INV, NUM_ZONEFILES, ZONEFILE_INV_LOCK
inv = None
with ZONEFILE_INV_LOCK:
inv_len = atlasdb_zonefile_inv_length( con=con, path=path )
inv... | [
"def",
"atlasdb_cache_zonefile_info",
"(",
"con",
"=",
"None",
",",
"path",
"=",
"None",
")",
":",
"global",
"ZONEFILE_INV",
",",
"NUM_ZONEFILES",
",",
"ZONEFILE_INV_LOCK",
"inv",
"=",
"None",
"with",
"ZONEFILE_INV_LOCK",
":",
"inv_len",
"=",
"atlasdb_zonefile_inv... | Load up and cache our zonefile inventory from the database | [
"Load",
"up",
"and",
"cache",
"our",
"zonefile",
"inventory",
"from",
"the",
"database"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L902-L916 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | atlasdb_queue_zonefiles | def atlasdb_queue_zonefiles( con, db, start_block, zonefile_dir, recover=False, validate=True, end_block=None ):
"""
Queue all zonefile hashes in the BlockstackDB
to the zonefile queue
NOT THREAD SAFE
Returns the list of zonefile infos queued, and whether or not they are present.
"""
# pop... | python | def atlasdb_queue_zonefiles( con, db, start_block, zonefile_dir, recover=False, validate=True, end_block=None ):
"""
Queue all zonefile hashes in the BlockstackDB
to the zonefile queue
NOT THREAD SAFE
Returns the list of zonefile infos queued, and whether or not they are present.
"""
# pop... | [
"def",
"atlasdb_queue_zonefiles",
"(",
"con",
",",
"db",
",",
"start_block",
",",
"zonefile_dir",
",",
"recover",
"=",
"False",
",",
"validate",
"=",
"True",
",",
"end_block",
"=",
"None",
")",
":",
"total",
"=",
"0",
"if",
"end_block",
"is",
"None",
":"... | Queue all zonefile hashes in the BlockstackDB
to the zonefile queue
NOT THREAD SAFE
Returns the list of zonefile infos queued, and whether or not they are present. | [
"Queue",
"all",
"zonefile",
"hashes",
"in",
"the",
"BlockstackDB",
"to",
"the",
"zonefile",
"queue"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L940-L989 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | atlasdb_sync_zonefiles | def atlasdb_sync_zonefiles( db, start_block, zonefile_dir, atlas_state, validate=True, end_block=None, path=None, con=None ):
"""
Synchronize atlas DB with name db
NOT THREAD SAFE
"""
ret = None
with AtlasDBOpen(con=con, path=path) as dbcon:
ret = atlasdb_queue_zonefiles( dbcon, db, sta... | python | def atlasdb_sync_zonefiles( db, start_block, zonefile_dir, atlas_state, validate=True, end_block=None, path=None, con=None ):
"""
Synchronize atlas DB with name db
NOT THREAD SAFE
"""
ret = None
with AtlasDBOpen(con=con, path=path) as dbcon:
ret = atlasdb_queue_zonefiles( dbcon, db, sta... | [
"def",
"atlasdb_sync_zonefiles",
"(",
"db",
",",
"start_block",
",",
"zonefile_dir",
",",
"atlas_state",
",",
"validate",
"=",
"True",
",",
"end_block",
"=",
"None",
",",
"path",
"=",
"None",
",",
"con",
"=",
"None",
")",
":",
"ret",
"=",
"None",
"with",... | Synchronize atlas DB with name db
NOT THREAD SAFE | [
"Synchronize",
"atlas",
"DB",
"with",
"name",
"db"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L992-L1012 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | atlasdb_add_peer | def atlasdb_add_peer( peer_hostport, discovery_time=None, peer_table=None, con=None, path=None, ping_on_evict=True ):
"""
Add a peer to the peer table.
If the peer conflicts with another peer, ping it first, and only insert
the new peer if the old peer is dead.
Keep the in-RAM peer table cache-cohe... | python | def atlasdb_add_peer( peer_hostport, discovery_time=None, peer_table=None, con=None, path=None, ping_on_evict=True ):
"""
Add a peer to the peer table.
If the peer conflicts with another peer, ping it first, and only insert
the new peer if the old peer is dead.
Keep the in-RAM peer table cache-cohe... | [
"def",
"atlasdb_add_peer",
"(",
"peer_hostport",
",",
"discovery_time",
"=",
"None",
",",
"peer_table",
"=",
"None",
",",
"con",
"=",
"None",
",",
"path",
"=",
"None",
",",
"ping_on_evict",
"=",
"True",
")",
":",
"assert",
"len",
"(",
"peer_hostport",
")",... | Add a peer to the peer table.
If the peer conflicts with another peer, ping it first, and only insert
the new peer if the old peer is dead.
Keep the in-RAM peer table cache-coherent as well.
Return True if this peer was added to the table (or preserved)
Return False if not | [
"Add",
"a",
"peer",
"to",
"the",
"peer",
"table",
".",
"If",
"the",
"peer",
"conflicts",
"with",
"another",
"peer",
"ping",
"it",
"first",
"and",
"only",
"insert",
"the",
"new",
"peer",
"if",
"the",
"old",
"peer",
"is",
"dead",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L1015-L1095 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | atlasdb_num_peers | def atlasdb_num_peers( con=None, path=None ):
"""
How many peers are there in the db?
"""
with AtlasDBOpen(con=con, path=path) as dbcon:
sql = "SELECT MAX(peer_index) FROM peers;"
args = ()
cur = dbcon.cursor()
res = atlasdb_query_execute( cur, sql, args )
ret ... | python | def atlasdb_num_peers( con=None, path=None ):
"""
How many peers are there in the db?
"""
with AtlasDBOpen(con=con, path=path) as dbcon:
sql = "SELECT MAX(peer_index) FROM peers;"
args = ()
cur = dbcon.cursor()
res = atlasdb_query_execute( cur, sql, args )
ret ... | [
"def",
"atlasdb_num_peers",
"(",
"con",
"=",
"None",
",",
"path",
"=",
"None",
")",
":",
"with",
"AtlasDBOpen",
"(",
"con",
"=",
"con",
",",
"path",
"=",
"path",
")",
"as",
"dbcon",
":",
"sql",
"=",
"\"SELECT MAX(peer_index) FROM peers;\"",
"args",
"=",
... | How many peers are there in the db? | [
"How",
"many",
"peers",
"are",
"there",
"in",
"the",
"db?"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L1124-L1144 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | atlas_get_peer | def atlas_get_peer( peer_hostport, peer_table=None ):
"""
Get the given peer's info
"""
ret = None
with AtlasPeerTableLocked(peer_table) as ptbl:
ret = ptbl.get(peer_hostport, None)
return ret | python | def atlas_get_peer( peer_hostport, peer_table=None ):
"""
Get the given peer's info
"""
ret = None
with AtlasPeerTableLocked(peer_table) as ptbl:
ret = ptbl.get(peer_hostport, None)
return ret | [
"def",
"atlas_get_peer",
"(",
"peer_hostport",
",",
"peer_table",
"=",
"None",
")",
":",
"ret",
"=",
"None",
"with",
"AtlasPeerTableLocked",
"(",
"peer_table",
")",
"as",
"ptbl",
":",
"ret",
"=",
"ptbl",
".",
"get",
"(",
"peer_hostport",
",",
"None",
")",
... | Get the given peer's info | [
"Get",
"the",
"given",
"peer",
"s",
"info"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L1147-L1156 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | atlasdb_get_random_peer | def atlasdb_get_random_peer( con=None, path=None ):
"""
Select a peer from the db at random
Return None if the table is empty
"""
ret = {}
with AtlasDBOpen(con=con, path=path) as dbcon:
num_peers = atlasdb_num_peers( con=con, path=path )
if num_peers is None or num_peers == 0:
... | python | def atlasdb_get_random_peer( con=None, path=None ):
"""
Select a peer from the db at random
Return None if the table is empty
"""
ret = {}
with AtlasDBOpen(con=con, path=path) as dbcon:
num_peers = atlasdb_num_peers( con=con, path=path )
if num_peers is None or num_peers == 0:
... | [
"def",
"atlasdb_get_random_peer",
"(",
"con",
"=",
"None",
",",
"path",
"=",
"None",
")",
":",
"ret",
"=",
"{",
"}",
"with",
"AtlasDBOpen",
"(",
"con",
"=",
"con",
",",
"path",
"=",
"path",
")",
"as",
"dbcon",
":",
"num_peers",
"=",
"atlasdb_num_peers"... | Select a peer from the db at random
Return None if the table is empty | [
"Select",
"a",
"peer",
"from",
"the",
"db",
"at",
"random",
"Return",
"None",
"if",
"the",
"table",
"is",
"empty"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L1159-L1188 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | atlasdb_get_old_peers | def atlasdb_get_old_peers( now, con=None, path=None ):
"""
Get peers older than now - PEER_LIFETIME
"""
with AtlasDBOpen(con=con, path=path) as dbcon:
if now is None:
now = time.time()
expire = now - atlas_peer_max_age()
sql = "SELECT * FROM peers WHERE discovery_ti... | python | def atlasdb_get_old_peers( now, con=None, path=None ):
"""
Get peers older than now - PEER_LIFETIME
"""
with AtlasDBOpen(con=con, path=path) as dbcon:
if now is None:
now = time.time()
expire = now - atlas_peer_max_age()
sql = "SELECT * FROM peers WHERE discovery_ti... | [
"def",
"atlasdb_get_old_peers",
"(",
"now",
",",
"con",
"=",
"None",
",",
"path",
"=",
"None",
")",
":",
"with",
"AtlasDBOpen",
"(",
"con",
"=",
"con",
",",
"path",
"=",
"path",
")",
"as",
"dbcon",
":",
"if",
"now",
"is",
"None",
":",
"now",
"=",
... | Get peers older than now - PEER_LIFETIME | [
"Get",
"peers",
"older",
"than",
"now",
"-",
"PEER_LIFETIME"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L1191-L1213 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | atlasdb_renew_peer | def atlasdb_renew_peer( peer_hostport, now, con=None, path=None ):
"""
Renew a peer's discovery time
"""
with AtlasDBOpen(con=con, path=path) as dbcon:
if now is None:
now = time.time()
sql = "UPDATE peers SET discovery_time = ? WHERE peer_hostport = ?;"
args = (now,... | python | def atlasdb_renew_peer( peer_hostport, now, con=None, path=None ):
"""
Renew a peer's discovery time
"""
with AtlasDBOpen(con=con, path=path) as dbcon:
if now is None:
now = time.time()
sql = "UPDATE peers SET discovery_time = ? WHERE peer_hostport = ?;"
args = (now,... | [
"def",
"atlasdb_renew_peer",
"(",
"peer_hostport",
",",
"now",
",",
"con",
"=",
"None",
",",
"path",
"=",
"None",
")",
":",
"with",
"AtlasDBOpen",
"(",
"con",
"=",
"con",
",",
"path",
"=",
"path",
")",
"as",
"dbcon",
":",
"if",
"now",
"is",
"None",
... | Renew a peer's discovery time | [
"Renew",
"a",
"peer",
"s",
"discovery",
"time"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L1216-L1231 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | atlasdb_load_peer_table | def atlasdb_load_peer_table( con=None, path=None ):
"""
Create a peer table from the peer DB
"""
peer_table = {}
with AtlasDBOpen(con=con, path=path) as dbcon:
sql = "SELECT * FROM peers;"
args = ()
cur = dbcon.cursor()
res = atlasdb_query_execute( cur, sql, ar... | python | def atlasdb_load_peer_table( con=None, path=None ):
"""
Create a peer table from the peer DB
"""
peer_table = {}
with AtlasDBOpen(con=con, path=path) as dbcon:
sql = "SELECT * FROM peers;"
args = ()
cur = dbcon.cursor()
res = atlasdb_query_execute( cur, sql, ar... | [
"def",
"atlasdb_load_peer_table",
"(",
"con",
"=",
"None",
",",
"path",
"=",
"None",
")",
":",
"peer_table",
"=",
"{",
"}",
"with",
"AtlasDBOpen",
"(",
"con",
"=",
"con",
",",
"path",
"=",
"path",
")",
"as",
"dbcon",
":",
"sql",
"=",
"\"SELECT * FROM p... | Create a peer table from the peer DB | [
"Create",
"a",
"peer",
"table",
"from",
"the",
"peer",
"DB"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L1234-L1257 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | atlasdb_zonefile_inv_list | def atlasdb_zonefile_inv_list( bit_offset, bit_length, con=None, path=None ):
"""
Get an inventory listing.
offset and length are in bits.
Return the list of zonefile information.
The list may be less than length elements.
"""
with AtlasDBOpen(con=con, path=path) as dbcon:
sql = "S... | python | def atlasdb_zonefile_inv_list( bit_offset, bit_length, con=None, path=None ):
"""
Get an inventory listing.
offset and length are in bits.
Return the list of zonefile information.
The list may be less than length elements.
"""
with AtlasDBOpen(con=con, path=path) as dbcon:
sql = "S... | [
"def",
"atlasdb_zonefile_inv_list",
"(",
"bit_offset",
",",
"bit_length",
",",
"con",
"=",
"None",
",",
"path",
"=",
"None",
")",
":",
"with",
"AtlasDBOpen",
"(",
"con",
"=",
"con",
",",
"path",
"=",
"path",
")",
"as",
"dbcon",
":",
"sql",
"=",
"\"SELE... | Get an inventory listing.
offset and length are in bits.
Return the list of zonefile information.
The list may be less than length elements. | [
"Get",
"an",
"inventory",
"listing",
".",
"offset",
"and",
"length",
"are",
"in",
"bits",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L1364-L1386 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | atlas_init_peer_info | def atlas_init_peer_info( peer_table, peer_hostport, blacklisted=False, whitelisted=False ):
"""
Initialize peer info table entry
"""
peer_table[peer_hostport] = {
"time": [],
"zonefile_inv": "",
"blacklisted": blacklisted,
"whitelisted": whitelisted
} | python | def atlas_init_peer_info( peer_table, peer_hostport, blacklisted=False, whitelisted=False ):
"""
Initialize peer info table entry
"""
peer_table[peer_hostport] = {
"time": [],
"zonefile_inv": "",
"blacklisted": blacklisted,
"whitelisted": whitelisted
} | [
"def",
"atlas_init_peer_info",
"(",
"peer_table",
",",
"peer_hostport",
",",
"blacklisted",
"=",
"False",
",",
"whitelisted",
"=",
"False",
")",
":",
"peer_table",
"[",
"peer_hostport",
"]",
"=",
"{",
"\"time\"",
":",
"[",
"]",
",",
"\"zonefile_inv\"",
":",
... | Initialize peer info table entry | [
"Initialize",
"peer",
"info",
"table",
"entry"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L1546-L1555 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | atlas_log_socket_error | def atlas_log_socket_error( method_invocation, peer_hostport, se ):
"""
Log a socket exception tastefully
"""
if isinstance( se, socket.timeout ):
log.debug("%s %s: timed out (socket.timeout)" % (method_invocation, peer_hostport))
elif isinstance( se, socket.gaierror ):
log.debug("%... | python | def atlas_log_socket_error( method_invocation, peer_hostport, se ):
"""
Log a socket exception tastefully
"""
if isinstance( se, socket.timeout ):
log.debug("%s %s: timed out (socket.timeout)" % (method_invocation, peer_hostport))
elif isinstance( se, socket.gaierror ):
log.debug("%... | [
"def",
"atlas_log_socket_error",
"(",
"method_invocation",
",",
"peer_hostport",
",",
"se",
")",
":",
"if",
"isinstance",
"(",
"se",
",",
"socket",
".",
"timeout",
")",
":",
"log",
".",
"debug",
"(",
"\"%s %s: timed out (socket.timeout)\"",
"%",
"(",
"method_inv... | Log a socket exception tastefully | [
"Log",
"a",
"socket",
"exception",
"tastefully"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L1558-L1582 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | atlas_peer_ping | def atlas_peer_ping( peer_hostport, timeout=None, peer_table=None ):
"""
Ping a host
Return True if alive
Return False if not
"""
if timeout is None:
timeout = atlas_ping_timeout()
assert not atlas_peer_table_is_locked_by_me()
host, port = url_to_host_port( peer_hostport )... | python | def atlas_peer_ping( peer_hostport, timeout=None, peer_table=None ):
"""
Ping a host
Return True if alive
Return False if not
"""
if timeout is None:
timeout = atlas_ping_timeout()
assert not atlas_peer_table_is_locked_by_me()
host, port = url_to_host_port( peer_hostport )... | [
"def",
"atlas_peer_ping",
"(",
"peer_hostport",
",",
"timeout",
"=",
"None",
",",
"peer_table",
"=",
"None",
")",
":",
"if",
"timeout",
"is",
"None",
":",
"timeout",
"=",
"atlas_ping_timeout",
"(",
")",
"assert",
"not",
"atlas_peer_table_is_locked_by_me",
"(",
... | Ping a host
Return True if alive
Return False if not | [
"Ping",
"a",
"host",
"Return",
"True",
"if",
"alive",
"Return",
"False",
"if",
"not"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L1585-L1621 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | atlas_inventory_count_missing | def atlas_inventory_count_missing( inv1, inv2 ):
"""
Find out how many bits are set in inv2
that are not set in inv1.
"""
count = 0
common = min(len(inv1), len(inv2))
for i in xrange(0, common):
for j in xrange(0, 8):
if ((1 << (7 - j)) & ord(inv2[i])) != 0 and ((1 << (7... | python | def atlas_inventory_count_missing( inv1, inv2 ):
"""
Find out how many bits are set in inv2
that are not set in inv1.
"""
count = 0
common = min(len(inv1), len(inv2))
for i in xrange(0, common):
for j in xrange(0, 8):
if ((1 << (7 - j)) & ord(inv2[i])) != 0 and ((1 << (7... | [
"def",
"atlas_inventory_count_missing",
"(",
"inv1",
",",
"inv2",
")",
":",
"count",
"=",
"0",
"common",
"=",
"min",
"(",
"len",
"(",
"inv1",
")",
",",
"len",
"(",
"inv2",
")",
")",
"for",
"i",
"in",
"xrange",
"(",
"0",
",",
"common",
")",
":",
"... | Find out how many bits are set in inv2
that are not set in inv1. | [
"Find",
"out",
"how",
"many",
"bits",
"are",
"set",
"in",
"inv2",
"that",
"are",
"not",
"set",
"in",
"inv1",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L1707-L1725 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | atlas_revalidate_peers | def atlas_revalidate_peers( con=None, path=None, now=None, peer_table=None ):
"""
Revalidate peers that are older than the maximum peer age.
Ping them, and if they don't respond, remove them.
"""
global MIN_PEER_HEALTH
if now is None:
now = time_now()
old_peer_infos = atlasdb_get_o... | python | def atlas_revalidate_peers( con=None, path=None, now=None, peer_table=None ):
"""
Revalidate peers that are older than the maximum peer age.
Ping them, and if they don't respond, remove them.
"""
global MIN_PEER_HEALTH
if now is None:
now = time_now()
old_peer_infos = atlasdb_get_o... | [
"def",
"atlas_revalidate_peers",
"(",
"con",
"=",
"None",
",",
"path",
"=",
"None",
",",
"now",
"=",
"None",
",",
"peer_table",
"=",
"None",
")",
":",
"global",
"MIN_PEER_HEALTH",
"if",
"now",
"is",
"None",
":",
"now",
"=",
"time_now",
"(",
")",
"old_p... | Revalidate peers that are older than the maximum peer age.
Ping them, and if they don't respond, remove them. | [
"Revalidate",
"peers",
"that",
"are",
"older",
"than",
"the",
"maximum",
"peer",
"age",
".",
"Ping",
"them",
"and",
"if",
"they",
"don",
"t",
"respond",
"remove",
"them",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L1775-L1803 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | atlas_peer_get_request_count | def atlas_peer_get_request_count( peer_hostport, peer_table=None ):
"""
How many times have we contacted this peer?
"""
with AtlasPeerTableLocked(peer_table) as ptbl:
if peer_hostport not in ptbl.keys():
return 0
count = 0
for (t, r) in ptbl[peer_hostport]['time']:
... | python | def atlas_peer_get_request_count( peer_hostport, peer_table=None ):
"""
How many times have we contacted this peer?
"""
with AtlasPeerTableLocked(peer_table) as ptbl:
if peer_hostport not in ptbl.keys():
return 0
count = 0
for (t, r) in ptbl[peer_hostport]['time']:
... | [
"def",
"atlas_peer_get_request_count",
"(",
"peer_hostport",
",",
"peer_table",
"=",
"None",
")",
":",
"with",
"AtlasPeerTableLocked",
"(",
"peer_table",
")",
"as",
"ptbl",
":",
"if",
"peer_hostport",
"not",
"in",
"ptbl",
".",
"keys",
"(",
")",
":",
"return",
... | How many times have we contacted this peer? | [
"How",
"many",
"times",
"have",
"we",
"contacted",
"this",
"peer?"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L1828-L1841 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | atlas_peer_get_zonefile_inventory | def atlas_peer_get_zonefile_inventory( peer_hostport, peer_table=None ):
"""
What's the zonefile inventory vector for this peer?
Return None if not defined
"""
inv = None
with AtlasPeerTableLocked(peer_table) as ptbl:
if peer_hostport not in ptbl.keys():
return None
... | python | def atlas_peer_get_zonefile_inventory( peer_hostport, peer_table=None ):
"""
What's the zonefile inventory vector for this peer?
Return None if not defined
"""
inv = None
with AtlasPeerTableLocked(peer_table) as ptbl:
if peer_hostport not in ptbl.keys():
return None
... | [
"def",
"atlas_peer_get_zonefile_inventory",
"(",
"peer_hostport",
",",
"peer_table",
"=",
"None",
")",
":",
"inv",
"=",
"None",
"with",
"AtlasPeerTableLocked",
"(",
"peer_table",
")",
"as",
"ptbl",
":",
"if",
"peer_hostport",
"not",
"in",
"ptbl",
".",
"keys",
... | What's the zonefile inventory vector for this peer?
Return None if not defined | [
"What",
"s",
"the",
"zonefile",
"inventory",
"vector",
"for",
"this",
"peer?",
"Return",
"None",
"if",
"not",
"defined"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L1844-L1857 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | atlas_peer_set_zonefile_inventory | def atlas_peer_set_zonefile_inventory( peer_hostport, peer_inv, peer_table=None ):
"""
Set this peer's zonefile inventory
"""
with AtlasPeerTableLocked(peer_table) as ptbl:
if peer_hostport not in ptbl.keys():
return None
ptbl[peer_hostport]['zonefile_inv'] = peer_inv
... | python | def atlas_peer_set_zonefile_inventory( peer_hostport, peer_inv, peer_table=None ):
"""
Set this peer's zonefile inventory
"""
with AtlasPeerTableLocked(peer_table) as ptbl:
if peer_hostport not in ptbl.keys():
return None
ptbl[peer_hostport]['zonefile_inv'] = peer_inv
... | [
"def",
"atlas_peer_set_zonefile_inventory",
"(",
"peer_hostport",
",",
"peer_inv",
",",
"peer_table",
"=",
"None",
")",
":",
"with",
"AtlasPeerTableLocked",
"(",
"peer_table",
")",
"as",
"ptbl",
":",
"if",
"peer_hostport",
"not",
"in",
"ptbl",
".",
"keys",
"(",
... | Set this peer's zonefile inventory | [
"Set",
"this",
"peer",
"s",
"zonefile",
"inventory"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L1860-L1870 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | atlas_peer_is_whitelisted | def atlas_peer_is_whitelisted( peer_hostport, peer_table=None ):
"""
Is a peer whitelisted
"""
ret = None
with AtlasPeerTableLocked(peer_table) as ptbl:
if peer_hostport not in ptbl.keys():
return None
ret = ptbl[peer_hostport].get("whitelisted", False)
return ret | python | def atlas_peer_is_whitelisted( peer_hostport, peer_table=None ):
"""
Is a peer whitelisted
"""
ret = None
with AtlasPeerTableLocked(peer_table) as ptbl:
if peer_hostport not in ptbl.keys():
return None
ret = ptbl[peer_hostport].get("whitelisted", False)
return ret | [
"def",
"atlas_peer_is_whitelisted",
"(",
"peer_hostport",
",",
"peer_table",
"=",
"None",
")",
":",
"ret",
"=",
"None",
"with",
"AtlasPeerTableLocked",
"(",
"peer_table",
")",
"as",
"ptbl",
":",
"if",
"peer_hostport",
"not",
"in",
"ptbl",
".",
"keys",
"(",
"... | Is a peer whitelisted | [
"Is",
"a",
"peer",
"whitelisted"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L1888-L1899 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | atlas_peer_update_health | def atlas_peer_update_health( peer_hostport, received_response, peer_table=None ):
"""
Mark the given peer as alive at this time.
Update times at which we contacted it,
and update its health score.
Use the global health table by default,
or use the given health info if set.
"""
with A... | python | def atlas_peer_update_health( peer_hostport, received_response, peer_table=None ):
"""
Mark the given peer as alive at this time.
Update times at which we contacted it,
and update its health score.
Use the global health table by default,
or use the given health info if set.
"""
with A... | [
"def",
"atlas_peer_update_health",
"(",
"peer_hostport",
",",
"received_response",
",",
"peer_table",
"=",
"None",
")",
":",
"with",
"AtlasPeerTableLocked",
"(",
"peer_table",
")",
"as",
"ptbl",
":",
"if",
"peer_hostport",
"not",
"in",
"ptbl",
".",
"keys",
"(",
... | Mark the given peer as alive at this time.
Update times at which we contacted it,
and update its health score.
Use the global health table by default,
or use the given health info if set. | [
"Mark",
"the",
"given",
"peer",
"as",
"alive",
"at",
"this",
"time",
".",
"Update",
"times",
"at",
"which",
"we",
"contacted",
"it",
"and",
"update",
"its",
"health",
"score",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L1902-L1930 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | atlas_peer_download_zonefile_inventory | def atlas_peer_download_zonefile_inventory( my_hostport, peer_hostport, maxlen, bit_offset=0, timeout=None, peer_table={} ):
"""
Get the zonefile inventory from the remote peer
Start from the given bit_offset
NOTE: this doesn't update the peer table health by default;
you'll have to explicitly pass... | python | def atlas_peer_download_zonefile_inventory( my_hostport, peer_hostport, maxlen, bit_offset=0, timeout=None, peer_table={} ):
"""
Get the zonefile inventory from the remote peer
Start from the given bit_offset
NOTE: this doesn't update the peer table health by default;
you'll have to explicitly pass... | [
"def",
"atlas_peer_download_zonefile_inventory",
"(",
"my_hostport",
",",
"peer_hostport",
",",
"maxlen",
",",
"bit_offset",
"=",
"0",
",",
"timeout",
"=",
"None",
",",
"peer_table",
"=",
"{",
"}",
")",
":",
"if",
"timeout",
"is",
"None",
":",
"timeout",
"="... | Get the zonefile inventory from the remote peer
Start from the given bit_offset
NOTE: this doesn't update the peer table health by default;
you'll have to explicitly pass in a peer table (i.e. setting
to {} ensures that nothing happens). | [
"Get",
"the",
"zonefile",
"inventory",
"from",
"the",
"remote",
"peer",
"Start",
"from",
"the",
"given",
"bit_offset"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L1993-L2027 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.