id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
5,300 | loli/medpy | medpy/features/intensity.py | mask_distance | def mask_distance(image, voxelspacing = None, mask = slice(None)):
r"""
Computes the distance of each point under the mask to the mask border taking the
voxel-spacing into account.
Note that this feature is independent of the actual image content, but depends
solely the mask image. Therefore al... | python | def mask_distance(image, voxelspacing = None, mask = slice(None)):
r"""
Computes the distance of each point under the mask to the mask border taking the
voxel-spacing into account.
Note that this feature is independent of the actual image content, but depends
solely the mask image. Therefore al... | [
"def",
"mask_distance",
"(",
"image",
",",
"voxelspacing",
"=",
"None",
",",
"mask",
"=",
"slice",
"(",
"None",
")",
")",
":",
"if",
"type",
"(",
"image",
")",
"==",
"tuple",
"or",
"type",
"(",
"image",
")",
"==",
"list",
":",
"image",
"=",
"image"... | r"""
Computes the distance of each point under the mask to the mask border taking the
voxel-spacing into account.
Note that this feature is independent of the actual image content, but depends
solely the mask image. Therefore always a one-dimensional feature is returned,
even if a multi-spectra... | [
"r",
"Computes",
"the",
"distance",
"of",
"each",
"point",
"under",
"the",
"mask",
"to",
"the",
"mask",
"border",
"taking",
"the",
"voxel",
"-",
"spacing",
"into",
"account",
".",
"Note",
"that",
"this",
"feature",
"is",
"independent",
"of",
"the",
"actual... | 95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5 | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/intensity.py#L246-L275 |
5,301 | loli/medpy | medpy/features/intensity.py | _extract_hemispheric_difference | def _extract_hemispheric_difference(image, mask = slice(None), sigma_active = 7, sigma_reference = 7, cut_plane = 0, voxelspacing = None):
"""
Internal, single-image version of `hemispheric_difference`.
"""
# constants
INTERPOLATION_RANGE = int(10) # how many neighbouring values to take into account... | python | def _extract_hemispheric_difference(image, mask = slice(None), sigma_active = 7, sigma_reference = 7, cut_plane = 0, voxelspacing = None):
"""
Internal, single-image version of `hemispheric_difference`.
"""
# constants
INTERPOLATION_RANGE = int(10) # how many neighbouring values to take into account... | [
"def",
"_extract_hemispheric_difference",
"(",
"image",
",",
"mask",
"=",
"slice",
"(",
"None",
")",
",",
"sigma_active",
"=",
"7",
",",
"sigma_reference",
"=",
"7",
",",
"cut_plane",
"=",
"0",
",",
"voxelspacing",
"=",
"None",
")",
":",
"# constants",
"IN... | Internal, single-image version of `hemispheric_difference`. | [
"Internal",
"single",
"-",
"image",
"version",
"of",
"hemispheric_difference",
"."
] | 95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5 | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/intensity.py#L522-L585 |
5,302 | loli/medpy | medpy/features/intensity.py | _extract_local_histogram | def _extract_local_histogram(image, mask=slice(None), bins=19, rang="image", cutoffp=(0.0, 100.0), size=None, footprint=None, output=None, mode="ignore", origin=0):
"""
Internal, single-image version of @see local_histogram
Note: Values outside of the histograms range are not considered.
Note: Mode... | python | def _extract_local_histogram(image, mask=slice(None), bins=19, rang="image", cutoffp=(0.0, 100.0), size=None, footprint=None, output=None, mode="ignore", origin=0):
"""
Internal, single-image version of @see local_histogram
Note: Values outside of the histograms range are not considered.
Note: Mode... | [
"def",
"_extract_local_histogram",
"(",
"image",
",",
"mask",
"=",
"slice",
"(",
"None",
")",
",",
"bins",
"=",
"19",
",",
"rang",
"=",
"\"image\"",
",",
"cutoffp",
"=",
"(",
"0.0",
",",
"100.0",
")",
",",
"size",
"=",
"None",
",",
"footprint",
"=",
... | Internal, single-image version of @see local_histogram
Note: Values outside of the histograms range are not considered.
Note: Mode constant is not available, instead a mode "ignore" is provided.
Note: Default dtype of returned values is float. | [
"Internal",
"single",
"-",
"image",
"version",
"of"
] | 95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5 | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/intensity.py#L587-L625 |
5,303 | loli/medpy | medpy/features/intensity.py | _extract_median | def _extract_median(image, mask = slice(None), size = 1, voxelspacing = None):
"""
Internal, single-image version of `median`.
"""
# set voxel spacing
if voxelspacing is None:
voxelspacing = [1.] * image.ndim
# determine structure element size in voxel units
size = _create_s... | python | def _extract_median(image, mask = slice(None), size = 1, voxelspacing = None):
"""
Internal, single-image version of `median`.
"""
# set voxel spacing
if voxelspacing is None:
voxelspacing = [1.] * image.ndim
# determine structure element size in voxel units
size = _create_s... | [
"def",
"_extract_median",
"(",
"image",
",",
"mask",
"=",
"slice",
"(",
"None",
")",
",",
"size",
"=",
"1",
",",
"voxelspacing",
"=",
"None",
")",
":",
"# set voxel spacing",
"if",
"voxelspacing",
"is",
"None",
":",
"voxelspacing",
"=",
"[",
"1.",
"]",
... | Internal, single-image version of `median`. | [
"Internal",
"single",
"-",
"image",
"version",
"of",
"median",
"."
] | 95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5 | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/intensity.py#L627-L638 |
5,304 | loli/medpy | medpy/features/intensity.py | _extract_gaussian_gradient_magnitude | def _extract_gaussian_gradient_magnitude(image, mask = slice(None), sigma = 1, voxelspacing = None):
"""
Internal, single-image version of `gaussian_gradient_magnitude`.
"""
# set voxel spacing
if voxelspacing is None:
voxelspacing = [1.] * image.ndim
# determine gaussian kernel... | python | def _extract_gaussian_gradient_magnitude(image, mask = slice(None), sigma = 1, voxelspacing = None):
"""
Internal, single-image version of `gaussian_gradient_magnitude`.
"""
# set voxel spacing
if voxelspacing is None:
voxelspacing = [1.] * image.ndim
# determine gaussian kernel... | [
"def",
"_extract_gaussian_gradient_magnitude",
"(",
"image",
",",
"mask",
"=",
"slice",
"(",
"None",
")",
",",
"sigma",
"=",
"1",
",",
"voxelspacing",
"=",
"None",
")",
":",
"# set voxel spacing",
"if",
"voxelspacing",
"is",
"None",
":",
"voxelspacing",
"=",
... | Internal, single-image version of `gaussian_gradient_magnitude`. | [
"Internal",
"single",
"-",
"image",
"version",
"of",
"gaussian_gradient_magnitude",
"."
] | 95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5 | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/intensity.py#L640-L651 |
5,305 | loli/medpy | medpy/features/intensity.py | _extract_shifted_mean_gauss | def _extract_shifted_mean_gauss(image, mask = slice(None), offset = None, sigma = 1, voxelspacing = None):
"""
Internal, single-image version of `shifted_mean_gauss`.
"""
# set voxel spacing
if voxelspacing is None:
voxelspacing = [1.] * image.ndim
# set offset
if offset is None:... | python | def _extract_shifted_mean_gauss(image, mask = slice(None), offset = None, sigma = 1, voxelspacing = None):
"""
Internal, single-image version of `shifted_mean_gauss`.
"""
# set voxel spacing
if voxelspacing is None:
voxelspacing = [1.] * image.ndim
# set offset
if offset is None:... | [
"def",
"_extract_shifted_mean_gauss",
"(",
"image",
",",
"mask",
"=",
"slice",
"(",
"None",
")",
",",
"offset",
"=",
"None",
",",
"sigma",
"=",
"1",
",",
"voxelspacing",
"=",
"None",
")",
":",
"# set voxel spacing",
"if",
"voxelspacing",
"is",
"None",
":",... | Internal, single-image version of `shifted_mean_gauss`. | [
"Internal",
"single",
"-",
"image",
"version",
"of",
"shifted_mean_gauss",
"."
] | 95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5 | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/intensity.py#L653-L678 |
5,306 | loli/medpy | medpy/features/intensity.py | _extract_mask_distance | def _extract_mask_distance(image, mask = slice(None), voxelspacing = None):
"""
Internal, single-image version of `mask_distance`.
"""
if isinstance(mask, slice):
mask = numpy.ones(image.shape, numpy.bool)
distance_map = distance_transform_edt(mask, sampling=voxelspacing)
retur... | python | def _extract_mask_distance(image, mask = slice(None), voxelspacing = None):
"""
Internal, single-image version of `mask_distance`.
"""
if isinstance(mask, slice):
mask = numpy.ones(image.shape, numpy.bool)
distance_map = distance_transform_edt(mask, sampling=voxelspacing)
retur... | [
"def",
"_extract_mask_distance",
"(",
"image",
",",
"mask",
"=",
"slice",
"(",
"None",
")",
",",
"voxelspacing",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"mask",
",",
"slice",
")",
":",
"mask",
"=",
"numpy",
".",
"ones",
"(",
"image",
".",
"sh... | Internal, single-image version of `mask_distance`. | [
"Internal",
"single",
"-",
"image",
"version",
"of",
"mask_distance",
"."
] | 95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5 | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/intensity.py#L680-L689 |
5,307 | loli/medpy | medpy/features/intensity.py | _extract_local_mean_gauss | def _extract_local_mean_gauss(image, mask = slice(None), sigma = 1, voxelspacing = None):
"""
Internal, single-image version of `local_mean_gauss`.
"""
# set voxel spacing
if voxelspacing is None:
voxelspacing = [1.] * image.ndim
# determine gaussian kernel size in voxel units
... | python | def _extract_local_mean_gauss(image, mask = slice(None), sigma = 1, voxelspacing = None):
"""
Internal, single-image version of `local_mean_gauss`.
"""
# set voxel spacing
if voxelspacing is None:
voxelspacing = [1.] * image.ndim
# determine gaussian kernel size in voxel units
... | [
"def",
"_extract_local_mean_gauss",
"(",
"image",
",",
"mask",
"=",
"slice",
"(",
"None",
")",
",",
"sigma",
"=",
"1",
",",
"voxelspacing",
"=",
"None",
")",
":",
"# set voxel spacing",
"if",
"voxelspacing",
"is",
"None",
":",
"voxelspacing",
"=",
"[",
"1.... | Internal, single-image version of `local_mean_gauss`. | [
"Internal",
"single",
"-",
"image",
"version",
"of",
"local_mean_gauss",
"."
] | 95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5 | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/intensity.py#L691-L702 |
5,308 | loli/medpy | medpy/features/intensity.py | _extract_centerdistance | def _extract_centerdistance(image, mask = slice(None), voxelspacing = None):
"""
Internal, single-image version of `centerdistance`.
"""
image = numpy.array(image, copy=False)
if None == voxelspacing:
voxelspacing = [1.] * image.ndim
# get image center and an array holding ... | python | def _extract_centerdistance(image, mask = slice(None), voxelspacing = None):
"""
Internal, single-image version of `centerdistance`.
"""
image = numpy.array(image, copy=False)
if None == voxelspacing:
voxelspacing = [1.] * image.ndim
# get image center and an array holding ... | [
"def",
"_extract_centerdistance",
"(",
"image",
",",
"mask",
"=",
"slice",
"(",
"None",
")",
",",
"voxelspacing",
"=",
"None",
")",
":",
"image",
"=",
"numpy",
".",
"array",
"(",
"image",
",",
"copy",
"=",
"False",
")",
"if",
"None",
"==",
"voxelspacin... | Internal, single-image version of `centerdistance`. | [
"Internal",
"single",
"-",
"image",
"version",
"of",
"centerdistance",
"."
] | 95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5 | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/intensity.py#L705-L724 |
5,309 | loli/medpy | medpy/features/intensity.py | _extract_intensities | def _extract_intensities(image, mask = slice(None)):
"""
Internal, single-image version of `intensities`.
"""
return numpy.array(image, copy=True)[mask].ravel() | python | def _extract_intensities(image, mask = slice(None)):
"""
Internal, single-image version of `intensities`.
"""
return numpy.array(image, copy=True)[mask].ravel() | [
"def",
"_extract_intensities",
"(",
"image",
",",
"mask",
"=",
"slice",
"(",
"None",
")",
")",
":",
"return",
"numpy",
".",
"array",
"(",
"image",
",",
"copy",
"=",
"True",
")",
"[",
"mask",
"]",
".",
"ravel",
"(",
")"
] | Internal, single-image version of `intensities`. | [
"Internal",
"single",
"-",
"image",
"version",
"of",
"intensities",
"."
] | 95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5 | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/intensity.py#L727-L731 |
5,310 | loli/medpy | medpy/features/intensity.py | _substract_hemispheres | def _substract_hemispheres(active, reference, active_sigma, reference_sigma, voxel_spacing):
"""
Helper function for `_extract_hemispheric_difference`.
Smoothes both images and then substracts the reference from the active image.
"""
active_kernel = _create_structure_array(active_sigma, voxel_spacin... | python | def _substract_hemispheres(active, reference, active_sigma, reference_sigma, voxel_spacing):
"""
Helper function for `_extract_hemispheric_difference`.
Smoothes both images and then substracts the reference from the active image.
"""
active_kernel = _create_structure_array(active_sigma, voxel_spacin... | [
"def",
"_substract_hemispheres",
"(",
"active",
",",
"reference",
",",
"active_sigma",
",",
"reference_sigma",
",",
"voxel_spacing",
")",
":",
"active_kernel",
"=",
"_create_structure_array",
"(",
"active_sigma",
",",
"voxel_spacing",
")",
"active_smoothed",
"=",
"gau... | Helper function for `_extract_hemispheric_difference`.
Smoothes both images and then substracts the reference from the active image. | [
"Helper",
"function",
"for",
"_extract_hemispheric_difference",
".",
"Smoothes",
"both",
"images",
"and",
"then",
"substracts",
"the",
"reference",
"from",
"the",
"active",
"image",
"."
] | 95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5 | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/intensity.py#L733-L744 |
5,311 | loli/medpy | doc/numpydoc/numpydoc/compiler_unparse.py | UnparseCompilerAst._dispatch | def _dispatch(self, tree):
"_dispatcher function, _dispatching tree type T to method _T."
if isinstance(tree, list):
for t in tree:
self._dispatch(t)
return
meth = getattr(self, "_"+tree.__class__.__name__)
if tree.__class__.__name__ == 'NoneType' ... | python | def _dispatch(self, tree):
"_dispatcher function, _dispatching tree type T to method _T."
if isinstance(tree, list):
for t in tree:
self._dispatch(t)
return
meth = getattr(self, "_"+tree.__class__.__name__)
if tree.__class__.__name__ == 'NoneType' ... | [
"def",
"_dispatch",
"(",
"self",
",",
"tree",
")",
":",
"if",
"isinstance",
"(",
"tree",
",",
"list",
")",
":",
"for",
"t",
"in",
"tree",
":",
"self",
".",
"_dispatch",
"(",
"t",
")",
"return",
"meth",
"=",
"getattr",
"(",
"self",
",",
"\"_\"",
"... | _dispatcher function, _dispatching tree type T to method _T. | [
"_dispatcher",
"function",
"_dispatching",
"tree",
"type",
"T",
"to",
"method",
"_T",
"."
] | 95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5 | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/doc/numpydoc/numpydoc/compiler_unparse.py#L80-L89 |
5,312 | loli/medpy | doc/numpydoc/numpydoc/compiler_unparse.py | UnparseCompilerAst._AssAttr | def _AssAttr(self, t):
""" Handle assigning an attribute of an object
"""
self._dispatch(t.expr)
self._write('.'+t.attrname) | python | def _AssAttr(self, t):
""" Handle assigning an attribute of an object
"""
self._dispatch(t.expr)
self._write('.'+t.attrname) | [
"def",
"_AssAttr",
"(",
"self",
",",
"t",
")",
":",
"self",
".",
"_dispatch",
"(",
"t",
".",
"expr",
")",
"self",
".",
"_write",
"(",
"'.'",
"+",
"t",
".",
"attrname",
")"
] | Handle assigning an attribute of an object | [
"Handle",
"assigning",
"an",
"attribute",
"of",
"an",
"object"
] | 95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5 | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/doc/numpydoc/numpydoc/compiler_unparse.py#L110-L114 |
5,313 | loli/medpy | doc/numpydoc/numpydoc/compiler_unparse.py | UnparseCompilerAst._Assign | def _Assign(self, t):
""" Expression Assignment such as "a = 1".
This only handles assignment in expressions. Keyword assignment
is handled separately.
"""
self._fill()
for target in t.nodes:
self._dispatch(target)
self._write(" = ")
... | python | def _Assign(self, t):
""" Expression Assignment such as "a = 1".
This only handles assignment in expressions. Keyword assignment
is handled separately.
"""
self._fill()
for target in t.nodes:
self._dispatch(target)
self._write(" = ")
... | [
"def",
"_Assign",
"(",
"self",
",",
"t",
")",
":",
"self",
".",
"_fill",
"(",
")",
"for",
"target",
"in",
"t",
".",
"nodes",
":",
"self",
".",
"_dispatch",
"(",
"target",
")",
"self",
".",
"_write",
"(",
"\" = \"",
")",
"self",
".",
"_dispatch",
... | Expression Assignment such as "a = 1".
This only handles assignment in expressions. Keyword assignment
is handled separately. | [
"Expression",
"Assignment",
"such",
"as",
"a",
"=",
"1",
"."
] | 95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5 | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/doc/numpydoc/numpydoc/compiler_unparse.py#L116-L128 |
5,314 | loli/medpy | doc/numpydoc/numpydoc/compiler_unparse.py | UnparseCompilerAst._AssTuple | def _AssTuple(self, t):
""" Tuple on left hand side of an expression.
"""
# _write each elements, separated by a comma.
for element in t.nodes[:-1]:
self._dispatch(element)
self._write(", ")
# Handle the last one without writing comma
last_elemen... | python | def _AssTuple(self, t):
""" Tuple on left hand side of an expression.
"""
# _write each elements, separated by a comma.
for element in t.nodes[:-1]:
self._dispatch(element)
self._write(", ")
# Handle the last one without writing comma
last_elemen... | [
"def",
"_AssTuple",
"(",
"self",
",",
"t",
")",
":",
"# _write each elements, separated by a comma.",
"for",
"element",
"in",
"t",
".",
"nodes",
"[",
":",
"-",
"1",
"]",
":",
"self",
".",
"_dispatch",
"(",
"element",
")",
"self",
".",
"_write",
"(",
"\",... | Tuple on left hand side of an expression. | [
"Tuple",
"on",
"left",
"hand",
"side",
"of",
"an",
"expression",
"."
] | 95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5 | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/doc/numpydoc/numpydoc/compiler_unparse.py#L137-L148 |
5,315 | loli/medpy | doc/numpydoc/numpydoc/compiler_unparse.py | UnparseCompilerAst._CallFunc | def _CallFunc(self, t):
""" Function call.
"""
self._dispatch(t.node)
self._write("(")
comma = False
for e in t.args:
if comma: self._write(", ")
else: comma = True
self._dispatch(e)
if t.star_args:
if comma: self._w... | python | def _CallFunc(self, t):
""" Function call.
"""
self._dispatch(t.node)
self._write("(")
comma = False
for e in t.args:
if comma: self._write(", ")
else: comma = True
self._dispatch(e)
if t.star_args:
if comma: self._w... | [
"def",
"_CallFunc",
"(",
"self",
",",
"t",
")",
":",
"self",
".",
"_dispatch",
"(",
"t",
".",
"node",
")",
"self",
".",
"_write",
"(",
"\"(\"",
")",
"comma",
"=",
"False",
"for",
"e",
"in",
"t",
".",
"args",
":",
"if",
"comma",
":",
"self",
"."... | Function call. | [
"Function",
"call",
"."
] | 95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5 | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/doc/numpydoc/numpydoc/compiler_unparse.py#L183-L203 |
5,316 | loli/medpy | doc/numpydoc/numpydoc/compiler_unparse.py | UnparseCompilerAst._From | def _From(self, t):
""" Handle "from xyz import foo, bar as baz".
"""
# fixme: Are From and ImportFrom handled differently?
self._fill("from ")
self._write(t.modname)
self._write(" import ")
for i, (name,asname) in enumerate(t.names):
if i != 0:
... | python | def _From(self, t):
""" Handle "from xyz import foo, bar as baz".
"""
# fixme: Are From and ImportFrom handled differently?
self._fill("from ")
self._write(t.modname)
self._write(" import ")
for i, (name,asname) in enumerate(t.names):
if i != 0:
... | [
"def",
"_From",
"(",
"self",
",",
"t",
")",
":",
"# fixme: Are From and ImportFrom handled differently?",
"self",
".",
"_fill",
"(",
"\"from \"",
")",
"self",
".",
"_write",
"(",
"t",
".",
"modname",
")",
"self",
".",
"_write",
"(",
"\" import \"",
")",
"for... | Handle "from xyz import foo, bar as baz". | [
"Handle",
"from",
"xyz",
"import",
"foo",
"bar",
"as",
"baz",
"."
] | 95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5 | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/doc/numpydoc/numpydoc/compiler_unparse.py#L244-L256 |
5,317 | loli/medpy | doc/numpydoc/numpydoc/compiler_unparse.py | UnparseCompilerAst._Function | def _Function(self, t):
""" Handle function definitions
"""
if t.decorators is not None:
self._fill("@")
self._dispatch(t.decorators)
self._fill("def "+t.name + "(")
defaults = [None] * (len(t.argnames) - len(t.defaults)) + list(t.defaults)
for i, ... | python | def _Function(self, t):
""" Handle function definitions
"""
if t.decorators is not None:
self._fill("@")
self._dispatch(t.decorators)
self._fill("def "+t.name + "(")
defaults = [None] * (len(t.argnames) - len(t.defaults)) + list(t.defaults)
for i, ... | [
"def",
"_Function",
"(",
"self",
",",
"t",
")",
":",
"if",
"t",
".",
"decorators",
"is",
"not",
"None",
":",
"self",
".",
"_fill",
"(",
"\"@\"",
")",
"self",
".",
"_dispatch",
"(",
"t",
".",
"decorators",
")",
"self",
".",
"_fill",
"(",
"\"def \"",... | Handle function definitions | [
"Handle",
"function",
"definitions"
] | 95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5 | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/doc/numpydoc/numpydoc/compiler_unparse.py#L258-L279 |
5,318 | loli/medpy | doc/numpydoc/numpydoc/compiler_unparse.py | UnparseCompilerAst._Getattr | def _Getattr(self, t):
""" Handle getting an attribute of an object
"""
if isinstance(t.expr, (Div, Mul, Sub, Add)):
self._write('(')
self._dispatch(t.expr)
self._write(')')
else:
self._dispatch(t.expr)
self._write('.'+... | python | def _Getattr(self, t):
""" Handle getting an attribute of an object
"""
if isinstance(t.expr, (Div, Mul, Sub, Add)):
self._write('(')
self._dispatch(t.expr)
self._write(')')
else:
self._dispatch(t.expr)
self._write('.'+... | [
"def",
"_Getattr",
"(",
"self",
",",
"t",
")",
":",
"if",
"isinstance",
"(",
"t",
".",
"expr",
",",
"(",
"Div",
",",
"Mul",
",",
"Sub",
",",
"Add",
")",
")",
":",
"self",
".",
"_write",
"(",
"'('",
")",
"self",
".",
"_dispatch",
"(",
"t",
"."... | Handle getting an attribute of an object | [
"Handle",
"getting",
"an",
"attribute",
"of",
"an",
"object"
] | 95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5 | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/doc/numpydoc/numpydoc/compiler_unparse.py#L281-L291 |
5,319 | loli/medpy | doc/numpydoc/numpydoc/compiler_unparse.py | UnparseCompilerAst._Import | def _Import(self, t):
""" Handle "import xyz.foo".
"""
self._fill("import ")
for i, (name,asname) in enumerate(t.names):
if i != 0:
self._write(", ")
self._write(name)
if asname is not None:
self._write(" as "+a... | python | def _Import(self, t):
""" Handle "import xyz.foo".
"""
self._fill("import ")
for i, (name,asname) in enumerate(t.names):
if i != 0:
self._write(", ")
self._write(name)
if asname is not None:
self._write(" as "+a... | [
"def",
"_Import",
"(",
"self",
",",
"t",
")",
":",
"self",
".",
"_fill",
"(",
"\"import \"",
")",
"for",
"i",
",",
"(",
"name",
",",
"asname",
")",
"in",
"enumerate",
"(",
"t",
".",
"names",
")",
":",
"if",
"i",
"!=",
"0",
":",
"self",
".",
"... | Handle "import xyz.foo". | [
"Handle",
"import",
"xyz",
".",
"foo",
"."
] | 95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5 | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/doc/numpydoc/numpydoc/compiler_unparse.py#L326-L336 |
5,320 | loli/medpy | doc/numpydoc/numpydoc/compiler_unparse.py | UnparseCompilerAst._Keyword | def _Keyword(self, t):
""" Keyword value assignment within function calls and definitions.
"""
self._write(t.name)
self._write("=")
self._dispatch(t.expr) | python | def _Keyword(self, t):
""" Keyword value assignment within function calls and definitions.
"""
self._write(t.name)
self._write("=")
self._dispatch(t.expr) | [
"def",
"_Keyword",
"(",
"self",
",",
"t",
")",
":",
"self",
".",
"_write",
"(",
"t",
".",
"name",
")",
"self",
".",
"_write",
"(",
"\"=\"",
")",
"self",
".",
"_dispatch",
"(",
"t",
".",
"expr",
")"
] | Keyword value assignment within function calls and definitions. | [
"Keyword",
"value",
"assignment",
"within",
"function",
"calls",
"and",
"definitions",
"."
] | 95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5 | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/doc/numpydoc/numpydoc/compiler_unparse.py#L338-L343 |
5,321 | loli/medpy | medpy/utilities/argparseu.py | __sequenceAscendingStrict | def __sequenceAscendingStrict(l):
"Test a sequences values to be in strictly ascending order."
it = iter(l)
next(it)
if not all(b > a for a, b in zip(l, it)):
raise argparse.ArgumentTypeError('All values must be given in strictly ascending order.')
return l | python | def __sequenceAscendingStrict(l):
"Test a sequences values to be in strictly ascending order."
it = iter(l)
next(it)
if not all(b > a for a, b in zip(l, it)):
raise argparse.ArgumentTypeError('All values must be given in strictly ascending order.')
return l | [
"def",
"__sequenceAscendingStrict",
"(",
"l",
")",
":",
"it",
"=",
"iter",
"(",
"l",
")",
"next",
"(",
"it",
")",
"if",
"not",
"all",
"(",
"b",
">",
"a",
"for",
"a",
",",
"b",
"in",
"zip",
"(",
"l",
",",
"it",
")",
")",
":",
"raise",
"argpars... | Test a sequences values to be in strictly ascending order. | [
"Test",
"a",
"sequences",
"values",
"to",
"be",
"in",
"strictly",
"ascending",
"order",
"."
] | 95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5 | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/utilities/argparseu.py#L238-L244 |
5,322 | loli/medpy | medpy/filter/IntensityRangeStandardization.py | IntensityRangeStandardization.__check_mapping | def __check_mapping(self, landmarks):
"""
Checks whether the image, from which the supplied landmarks were extracted, can
be transformed to the learned standard intensity space without loss of
information.
"""
sc_udiff = numpy.asarray(self.__sc_umaxs)[1:] - numpy.asarray(... | python | def __check_mapping(self, landmarks):
"""
Checks whether the image, from which the supplied landmarks were extracted, can
be transformed to the learned standard intensity space without loss of
information.
"""
sc_udiff = numpy.asarray(self.__sc_umaxs)[1:] - numpy.asarray(... | [
"def",
"__check_mapping",
"(",
"self",
",",
"landmarks",
")",
":",
"sc_udiff",
"=",
"numpy",
".",
"asarray",
"(",
"self",
".",
"__sc_umaxs",
")",
"[",
"1",
":",
"]",
"-",
"numpy",
".",
"asarray",
"(",
"self",
".",
"__sc_umins",
")",
"[",
":",
"-",
... | Checks whether the image, from which the supplied landmarks were extracted, can
be transformed to the learned standard intensity space without loss of
information. | [
"Checks",
"whether",
"the",
"image",
"from",
"which",
"the",
"supplied",
"landmarks",
"were",
"extracted",
"can",
"be",
"transformed",
"to",
"the",
"learned",
"standard",
"intensity",
"space",
"without",
"loss",
"of",
"information",
"."
] | 95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5 | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/filter/IntensityRangeStandardization.py#L459-L467 |
5,323 | loli/medpy | medpy/filter/IntensityRangeStandardization.py | IntensityRangeStandardization.is_in_interval | def is_in_interval(n, l, r, border = 'included'):
"""
Checks whether a number is inside the interval l, r.
"""
if 'included' == border:
return (n >= l) and (n <= r)
elif 'excluded' == border:
return (n > l) and (n < r)
else:
raise Value... | python | def is_in_interval(n, l, r, border = 'included'):
"""
Checks whether a number is inside the interval l, r.
"""
if 'included' == border:
return (n >= l) and (n <= r)
elif 'excluded' == border:
return (n > l) and (n < r)
else:
raise Value... | [
"def",
"is_in_interval",
"(",
"n",
",",
"l",
",",
"r",
",",
"border",
"=",
"'included'",
")",
":",
"if",
"'included'",
"==",
"border",
":",
"return",
"(",
"n",
">=",
"l",
")",
"and",
"(",
"n",
"<=",
"r",
")",
"elif",
"'excluded'",
"==",
"border",
... | Checks whether a number is inside the interval l, r. | [
"Checks",
"whether",
"a",
"number",
"is",
"inside",
"the",
"interval",
"l",
"r",
"."
] | 95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5 | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/filter/IntensityRangeStandardization.py#L497-L506 |
5,324 | loli/medpy | medpy/filter/IntensityRangeStandardization.py | IntensityRangeStandardization.are_in_interval | def are_in_interval(s, l, r, border = 'included'):
"""
Checks whether all number in the sequence s lie inside the interval formed by
l and r.
"""
return numpy.all([IntensityRangeStandardization.is_in_interval(x, l, r, border) for x in s]) | python | def are_in_interval(s, l, r, border = 'included'):
"""
Checks whether all number in the sequence s lie inside the interval formed by
l and r.
"""
return numpy.all([IntensityRangeStandardization.is_in_interval(x, l, r, border) for x in s]) | [
"def",
"are_in_interval",
"(",
"s",
",",
"l",
",",
"r",
",",
"border",
"=",
"'included'",
")",
":",
"return",
"numpy",
".",
"all",
"(",
"[",
"IntensityRangeStandardization",
".",
"is_in_interval",
"(",
"x",
",",
"l",
",",
"r",
",",
"border",
")",
"for"... | Checks whether all number in the sequence s lie inside the interval formed by
l and r. | [
"Checks",
"whether",
"all",
"number",
"in",
"the",
"sequence",
"s",
"lie",
"inside",
"the",
"interval",
"formed",
"by",
"l",
"and",
"r",
"."
] | 95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5 | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/filter/IntensityRangeStandardization.py#L509-L514 |
5,325 | loli/medpy | medpy/filter/houghtransform.py | template_sphere | def template_sphere (radius, dimensions):
r"""
Returns a spherical binary structure of a of the supplied radius that can be used as
template input to the generalized hough transform.
Parameters
----------
radius : integer
The circles radius in voxels.
dimensions : integer
Th... | python | def template_sphere (radius, dimensions):
r"""
Returns a spherical binary structure of a of the supplied radius that can be used as
template input to the generalized hough transform.
Parameters
----------
radius : integer
The circles radius in voxels.
dimensions : integer
Th... | [
"def",
"template_sphere",
"(",
"radius",
",",
"dimensions",
")",
":",
"if",
"int",
"(",
"dimensions",
")",
"!=",
"dimensions",
":",
"raise",
"TypeError",
"(",
"'The supplied dimension parameter must be of type integer.'",
")",
"dimensions",
"=",
"int",
"(",
"dimensi... | r"""
Returns a spherical binary structure of a of the supplied radius that can be used as
template input to the generalized hough transform.
Parameters
----------
radius : integer
The circles radius in voxels.
dimensions : integer
The dimensionality of the circle
Returns
... | [
"r",
"Returns",
"a",
"spherical",
"binary",
"structure",
"of",
"a",
"of",
"the",
"supplied",
"radius",
"that",
"can",
"be",
"used",
"as",
"template",
"input",
"to",
"the",
"generalized",
"hough",
"transform",
"."
] | 95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5 | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/filter/houghtransform.py#L156-L177 |
5,326 | loli/medpy | doc/numpydoc/numpydoc/traitsdoc.py | looks_like_issubclass | def looks_like_issubclass(obj, classname):
""" Return True if the object has a class or superclass with the given class
name.
Ignores old-style classes.
"""
t = obj
if t.__name__ == classname:
return True
for klass in t.__mro__:
if klass.__name__ == classname:
re... | python | def looks_like_issubclass(obj, classname):
""" Return True if the object has a class or superclass with the given class
name.
Ignores old-style classes.
"""
t = obj
if t.__name__ == classname:
return True
for klass in t.__mro__:
if klass.__name__ == classname:
re... | [
"def",
"looks_like_issubclass",
"(",
"obj",
",",
"classname",
")",
":",
"t",
"=",
"obj",
"if",
"t",
".",
"__name__",
"==",
"classname",
":",
"return",
"True",
"for",
"klass",
"in",
"t",
".",
"__mro__",
":",
"if",
"klass",
".",
"__name__",
"==",
"classn... | Return True if the object has a class or superclass with the given class
name.
Ignores old-style classes. | [
"Return",
"True",
"if",
"the",
"object",
"has",
"a",
"class",
"or",
"superclass",
"with",
"the",
"given",
"class",
"name",
"."
] | 95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5 | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/doc/numpydoc/numpydoc/traitsdoc.py#L102-L114 |
5,327 | loli/medpy | medpy/filter/utilities.py | __make_footprint | def __make_footprint(input, size, footprint):
"Creates a standard footprint element ala scipy.ndimage."
if footprint is None:
if size is None:
raise RuntimeError("no footprint or filter size provided")
sizes = _ni_support._normalize_sequence(size, input.ndim)
footprint = nump... | python | def __make_footprint(input, size, footprint):
"Creates a standard footprint element ala scipy.ndimage."
if footprint is None:
if size is None:
raise RuntimeError("no footprint or filter size provided")
sizes = _ni_support._normalize_sequence(size, input.ndim)
footprint = nump... | [
"def",
"__make_footprint",
"(",
"input",
",",
"size",
",",
"footprint",
")",
":",
"if",
"footprint",
"is",
"None",
":",
"if",
"size",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"\"no footprint or filter size provided\"",
")",
"sizes",
"=",
"_ni_support",
... | Creates a standard footprint element ala scipy.ndimage. | [
"Creates",
"a",
"standard",
"footprint",
"element",
"ala",
"scipy",
".",
"ndimage",
"."
] | 95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5 | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/filter/utilities.py#L246-L255 |
5,328 | loli/medpy | medpy/graphcut/energy_label.py | __check_label_image | def __check_label_image(label_image):
"""Check the label image for consistent labelling starting from 1."""
encountered_indices = scipy.unique(label_image)
expected_indices = scipy.arange(1, label_image.max() + 1)
if not encountered_indices.size == expected_indices.size or \
not (encountered_indi... | python | def __check_label_image(label_image):
"""Check the label image for consistent labelling starting from 1."""
encountered_indices = scipy.unique(label_image)
expected_indices = scipy.arange(1, label_image.max() + 1)
if not encountered_indices.size == expected_indices.size or \
not (encountered_indi... | [
"def",
"__check_label_image",
"(",
"label_image",
")",
":",
"encountered_indices",
"=",
"scipy",
".",
"unique",
"(",
"label_image",
")",
"expected_indices",
"=",
"scipy",
".",
"arange",
"(",
"1",
",",
"label_image",
".",
"max",
"(",
")",
"+",
"1",
")",
"if... | Check the label image for consistent labelling starting from 1. | [
"Check",
"the",
"label",
"image",
"for",
"consistent",
"labelling",
"starting",
"from",
"1",
"."
] | 95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5 | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/graphcut/energy_label.py#L407-L413 |
5,329 | loli/medpy | bin/medpy_graphcut_label_bgreduced.py | __xd_iterator_pass_on | def __xd_iterator_pass_on(arr, view, fun):
"""
Like xd_iterator, but the fun return values are always passed on to the next and only the last returned.
"""
# create list of iterations
iterations = [[None] if dim in view else list(range(arr.shape[dim])) for dim in range(arr.ndim)]
# iterate... | python | def __xd_iterator_pass_on(arr, view, fun):
"""
Like xd_iterator, but the fun return values are always passed on to the next and only the last returned.
"""
# create list of iterations
iterations = [[None] if dim in view else list(range(arr.shape[dim])) for dim in range(arr.ndim)]
# iterate... | [
"def",
"__xd_iterator_pass_on",
"(",
"arr",
",",
"view",
",",
"fun",
")",
":",
"# create list of iterations",
"iterations",
"=",
"[",
"[",
"None",
"]",
"if",
"dim",
"in",
"view",
"else",
"list",
"(",
"range",
"(",
"arr",
".",
"shape",
"[",
"dim",
"]",
... | Like xd_iterator, but the fun return values are always passed on to the next and only the last returned. | [
"Like",
"xd_iterator",
"but",
"the",
"fun",
"return",
"values",
"are",
"always",
"passed",
"on",
"to",
"the",
"next",
"and",
"only",
"the",
"last",
"returned",
"."
] | 95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5 | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/bin/medpy_graphcut_label_bgreduced.py#L176-L189 |
5,330 | loli/medpy | medpy/io/header.py | set_pixel_spacing | def set_pixel_spacing(hdr, spacing):
r"""Depreciated synonym of `~medpy.io.header.set_voxel_spacing`."""
warnings.warn('get_pixel_spacing() is depreciated, use set_voxel_spacing() instead', category=DeprecationWarning)
set_voxel_spacing(hdr, spacing) | python | def set_pixel_spacing(hdr, spacing):
r"""Depreciated synonym of `~medpy.io.header.set_voxel_spacing`."""
warnings.warn('get_pixel_spacing() is depreciated, use set_voxel_spacing() instead', category=DeprecationWarning)
set_voxel_spacing(hdr, spacing) | [
"def",
"set_pixel_spacing",
"(",
"hdr",
",",
"spacing",
")",
":",
"warnings",
".",
"warn",
"(",
"'get_pixel_spacing() is depreciated, use set_voxel_spacing() instead'",
",",
"category",
"=",
"DeprecationWarning",
")",
"set_voxel_spacing",
"(",
"hdr",
",",
"spacing",
")"... | r"""Depreciated synonym of `~medpy.io.header.set_voxel_spacing`. | [
"r",
"Depreciated",
"synonym",
"of",
"~medpy",
".",
"io",
".",
"header",
".",
"set_voxel_spacing",
"."
] | 95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5 | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/io/header.py#L100-L103 |
5,331 | loli/medpy | medpy/io/header.py | Header.copy_to | def copy_to(self, sitkimage):
"""
Copy all stored meta information info to an sitk Image.
Note that only the spacing and the offset/origin information
are guaranteed to be preserved, although the method also
tries to copy other meta information such as DICOM tags.
Param... | python | def copy_to(self, sitkimage):
"""
Copy all stored meta information info to an sitk Image.
Note that only the spacing and the offset/origin information
are guaranteed to be preserved, although the method also
tries to copy other meta information such as DICOM tags.
Param... | [
"def",
"copy_to",
"(",
"self",
",",
"sitkimage",
")",
":",
"if",
"self",
".",
"sitkimage",
"is",
"not",
"None",
":",
"for",
"k",
"in",
"self",
".",
"sitkimage",
".",
"GetMetaDataKeys",
"(",
")",
":",
"sitkimage",
".",
"SetMetaData",
"(",
"k",
",",
"s... | Copy all stored meta information info to an sitk Image.
Note that only the spacing and the offset/origin information
are guaranteed to be preserved, although the method also
tries to copy other meta information such as DICOM tags.
Parameters
----------
sitkimage : sitk.... | [
"Copy",
"all",
"stored",
"meta",
"information",
"info",
"to",
"an",
"sitk",
"Image",
"."
] | 95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5 | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/io/header.py#L213-L242 |
5,332 | loli/medpy | medpy/io/header.py | Header.get_info_consistent | def get_info_consistent(self, ndim):
"""
Returns the main meta-data information adapted to the supplied
image dimensionality.
It will try to resolve inconsistencies and other conflicts,
altering the information avilable int he most plausible way.
Parameters
----... | python | def get_info_consistent(self, ndim):
"""
Returns the main meta-data information adapted to the supplied
image dimensionality.
It will try to resolve inconsistencies and other conflicts,
altering the information avilable int he most plausible way.
Parameters
----... | [
"def",
"get_info_consistent",
"(",
"self",
",",
"ndim",
")",
":",
"if",
"ndim",
">",
"len",
"(",
"self",
".",
"spacing",
")",
":",
"spacing",
"=",
"self",
".",
"spacing",
"+",
"(",
"1.0",
",",
")",
"*",
"(",
"ndim",
"-",
"len",
"(",
"self",
".",
... | Returns the main meta-data information adapted to the supplied
image dimensionality.
It will try to resolve inconsistencies and other conflicts,
altering the information avilable int he most plausible way.
Parameters
----------
ndim : int
image's dimensional... | [
"Returns",
"the",
"main",
"meta",
"-",
"data",
"information",
"adapted",
"to",
"the",
"supplied",
"image",
"dimensionality",
"."
] | 95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5 | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/io/header.py#L244-L279 |
5,333 | loli/medpy | medpy/metric/binary.py | hd95 | def hd95(result, reference, voxelspacing=None, connectivity=1):
"""
95th percentile of the Hausdorff Distance.
Computes the 95th percentile of the (symmetric) Hausdorff Distance (HD) between the binary objects in two
images. Compared to the Hausdorff Distance, this metric is slightly more stable to sma... | python | def hd95(result, reference, voxelspacing=None, connectivity=1):
"""
95th percentile of the Hausdorff Distance.
Computes the 95th percentile of the (symmetric) Hausdorff Distance (HD) between the binary objects in two
images. Compared to the Hausdorff Distance, this metric is slightly more stable to sma... | [
"def",
"hd95",
"(",
"result",
",",
"reference",
",",
"voxelspacing",
"=",
"None",
",",
"connectivity",
"=",
"1",
")",
":",
"hd1",
"=",
"__surface_distances",
"(",
"result",
",",
"reference",
",",
"voxelspacing",
",",
"connectivity",
")",
"hd2",
"=",
"__sur... | 95th percentile of the Hausdorff Distance.
Computes the 95th percentile of the (symmetric) Hausdorff Distance (HD) between the binary objects in two
images. Compared to the Hausdorff Distance, this metric is slightly more stable to small outliers and is
commonly used in Biomedical Segmentation challenges.
... | [
"95th",
"percentile",
"of",
"the",
"Hausdorff",
"Distance",
"."
] | 95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5 | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/metric/binary.py#L354-L399 |
5,334 | loli/medpy | medpy/metric/binary.py | __surface_distances | def __surface_distances(result, reference, voxelspacing=None, connectivity=1):
"""
The distances between the surface voxel of binary objects in result and their
nearest partner surface voxel of a binary object in reference.
"""
result = numpy.atleast_1d(result.astype(numpy.bool))
reference = num... | python | def __surface_distances(result, reference, voxelspacing=None, connectivity=1):
"""
The distances between the surface voxel of binary objects in result and their
nearest partner surface voxel of a binary object in reference.
"""
result = numpy.atleast_1d(result.astype(numpy.bool))
reference = num... | [
"def",
"__surface_distances",
"(",
"result",
",",
"reference",
",",
"voxelspacing",
"=",
"None",
",",
"connectivity",
"=",
"1",
")",
":",
"result",
"=",
"numpy",
".",
"atleast_1d",
"(",
"result",
".",
"astype",
"(",
"numpy",
".",
"bool",
")",
")",
"refer... | The distances between the surface voxel of binary objects in result and their
nearest partner surface voxel of a binary object in reference. | [
"The",
"distances",
"between",
"the",
"surface",
"voxel",
"of",
"binary",
"objects",
"in",
"result",
"and",
"their",
"nearest",
"partner",
"surface",
"voxel",
"of",
"a",
"binary",
"object",
"in",
"reference",
"."
] | 95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5 | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/metric/binary.py#L1195-L1227 |
5,335 | loli/medpy | medpy/metric/histogram.py | __minowski_low_positive_integer_p | def __minowski_low_positive_integer_p(h1, h2, p = 2): # 11..43 us for p = 1..24 \w 100 bins
"""
A faster implementation of the Minowski distance for positive integer < 25.
@note do not use this function directly, but the general @link minowski() method.
@note the passed histograms must be scipy arrays.
... | python | def __minowski_low_positive_integer_p(h1, h2, p = 2): # 11..43 us for p = 1..24 \w 100 bins
"""
A faster implementation of the Minowski distance for positive integer < 25.
@note do not use this function directly, but the general @link minowski() method.
@note the passed histograms must be scipy arrays.
... | [
"def",
"__minowski_low_positive_integer_p",
"(",
"h1",
",",
"h2",
",",
"p",
"=",
"2",
")",
":",
"# 11..43 us for p = 1..24 \\w 100 bins",
"mult",
"=",
"scipy",
".",
"absolute",
"(",
"h1",
"-",
"h2",
")",
"dif",
"=",
"mult",
"for",
"_",
"in",
"range",
"(",
... | A faster implementation of the Minowski distance for positive integer < 25.
@note do not use this function directly, but the general @link minowski() method.
@note the passed histograms must be scipy arrays. | [
"A",
"faster",
"implementation",
"of",
"the",
"Minowski",
"distance",
"for",
"positive",
"integer",
"<",
"25",
"."
] | 95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5 | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/metric/histogram.py#L95-L104 |
5,336 | loli/medpy | medpy/metric/histogram.py | __kullback_leibler | def __kullback_leibler(h1, h2): # 36.3 us
"""
The actual KL implementation. @see kullback_leibler() for details.
Expects the histograms to be of type scipy.ndarray.
"""
result = h1.astype(scipy.float_)
mask = h1 != 0
result[mask] = scipy.multiply(h1[mask], scipy.log(h1[mask] / h2[mask]))
... | python | def __kullback_leibler(h1, h2): # 36.3 us
"""
The actual KL implementation. @see kullback_leibler() for details.
Expects the histograms to be of type scipy.ndarray.
"""
result = h1.astype(scipy.float_)
mask = h1 != 0
result[mask] = scipy.multiply(h1[mask], scipy.log(h1[mask] / h2[mask]))
... | [
"def",
"__kullback_leibler",
"(",
"h1",
",",
"h2",
")",
":",
"# 36.3 us",
"result",
"=",
"h1",
".",
"astype",
"(",
"scipy",
".",
"float_",
")",
"mask",
"=",
"h1",
"!=",
"0",
"result",
"[",
"mask",
"]",
"=",
"scipy",
".",
"multiply",
"(",
"h1",
"[",... | The actual KL implementation. @see kullback_leibler() for details.
Expects the histograms to be of type scipy.ndarray. | [
"The",
"actual",
"KL",
"implementation",
"."
] | 95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5 | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/metric/histogram.py#L562-L570 |
5,337 | loli/medpy | medpy/metric/histogram.py | __prepare_histogram | def __prepare_histogram(h1, h2):
"""Convert the histograms to scipy.ndarrays if required."""
h1 = h1 if scipy.ndarray == type(h1) else scipy.asarray(h1)
h2 = h2 if scipy.ndarray == type(h2) else scipy.asarray(h2)
if h1.shape != h2.shape or h1.size != h2.size:
raise ValueError('h1 and h2 must be ... | python | def __prepare_histogram(h1, h2):
"""Convert the histograms to scipy.ndarrays if required."""
h1 = h1 if scipy.ndarray == type(h1) else scipy.asarray(h1)
h2 = h2 if scipy.ndarray == type(h2) else scipy.asarray(h2)
if h1.shape != h2.shape or h1.size != h2.size:
raise ValueError('h1 and h2 must be ... | [
"def",
"__prepare_histogram",
"(",
"h1",
",",
"h2",
")",
":",
"h1",
"=",
"h1",
"if",
"scipy",
".",
"ndarray",
"==",
"type",
"(",
"h1",
")",
"else",
"scipy",
".",
"asarray",
"(",
"h1",
")",
"h2",
"=",
"h2",
"if",
"scipy",
".",
"ndarray",
"==",
"ty... | Convert the histograms to scipy.ndarrays if required. | [
"Convert",
"the",
"histograms",
"to",
"scipy",
".",
"ndarrays",
"if",
"required",
"."
] | 95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5 | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/metric/histogram.py#L1246-L1252 |
5,338 | minrk/findspark | findspark.py | find | def find():
"""Find a local spark installation.
Will first check the SPARK_HOME env variable, and otherwise
search common installation locations, e.g. from homebrew
"""
spark_home = os.environ.get('SPARK_HOME', None)
if not spark_home:
for path in [
'/usr/local/opt/apache-s... | python | def find():
"""Find a local spark installation.
Will first check the SPARK_HOME env variable, and otherwise
search common installation locations, e.g. from homebrew
"""
spark_home = os.environ.get('SPARK_HOME', None)
if not spark_home:
for path in [
'/usr/local/opt/apache-s... | [
"def",
"find",
"(",
")",
":",
"spark_home",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"'SPARK_HOME'",
",",
"None",
")",
"if",
"not",
"spark_home",
":",
"for",
"path",
"in",
"[",
"'/usr/local/opt/apache-spark/libexec'",
",",
"# OS X Homebrew",
"'/usr/lib/spar... | Find a local spark installation.
Will first check the SPARK_HOME env variable, and otherwise
search common installation locations, e.g. from homebrew | [
"Find",
"a",
"local",
"spark",
"installation",
"."
] | 20c945d5136269ca56b1341786c49087faa7c75e | https://github.com/minrk/findspark/blob/20c945d5136269ca56b1341786c49087faa7c75e/findspark.py#L14-L38 |
5,339 | minrk/findspark | findspark.py | change_rc | def change_rc(spark_home, spark_python, py4j):
"""Persists changes to environment by changing shell config.
Adds lines to .bashrc to set environment variables
including the adding of dependencies to the system path. Will only
edit this file if they already exist. Currently only works for bash.
Par... | python | def change_rc(spark_home, spark_python, py4j):
"""Persists changes to environment by changing shell config.
Adds lines to .bashrc to set environment variables
including the adding of dependencies to the system path. Will only
edit this file if they already exist. Currently only works for bash.
Par... | [
"def",
"change_rc",
"(",
"spark_home",
",",
"spark_python",
",",
"py4j",
")",
":",
"bashrc_location",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"\"~/.bashrc\"",
")",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"bashrc_location",
")",
":",
"with",
... | Persists changes to environment by changing shell config.
Adds lines to .bashrc to set environment variables
including the adding of dependencies to the system path. Will only
edit this file if they already exist. Currently only works for bash.
Parameters
----------
spark_home : str
Pa... | [
"Persists",
"changes",
"to",
"environment",
"by",
"changing",
"shell",
"config",
"."
] | 20c945d5136269ca56b1341786c49087faa7c75e | https://github.com/minrk/findspark/blob/20c945d5136269ca56b1341786c49087faa7c75e/findspark.py#L41-L65 |
5,340 | minrk/findspark | findspark.py | edit_ipython_profile | def edit_ipython_profile(spark_home, spark_python, py4j):
"""Adds a startup file to the current IPython profile to import pyspark.
The startup file sets the required environment variables and imports pyspark.
Parameters
----------
spark_home : str
Path to Spark installation.
spark_pyth... | python | def edit_ipython_profile(spark_home, spark_python, py4j):
"""Adds a startup file to the current IPython profile to import pyspark.
The startup file sets the required environment variables and imports pyspark.
Parameters
----------
spark_home : str
Path to Spark installation.
spark_pyth... | [
"def",
"edit_ipython_profile",
"(",
"spark_home",
",",
"spark_python",
",",
"py4j",
")",
":",
"from",
"IPython",
"import",
"get_ipython",
"ip",
"=",
"get_ipython",
"(",
")",
"if",
"ip",
":",
"profile_dir",
"=",
"ip",
".",
"profile_dir",
".",
"location",
"els... | Adds a startup file to the current IPython profile to import pyspark.
The startup file sets the required environment variables and imports pyspark.
Parameters
----------
spark_home : str
Path to Spark installation.
spark_python : str
Path to python subdirectory of Spark installatio... | [
"Adds",
"a",
"startup",
"file",
"to",
"the",
"current",
"IPython",
"profile",
"to",
"import",
"pyspark",
"."
] | 20c945d5136269ca56b1341786c49087faa7c75e | https://github.com/minrk/findspark/blob/20c945d5136269ca56b1341786c49087faa7c75e/findspark.py#L68-L98 |
5,341 | minrk/findspark | findspark.py | init | def init(spark_home=None, python_path=None, edit_rc=False, edit_profile=False):
"""Make pyspark importable.
Sets environment variables and adds dependencies to sys.path.
If no Spark location is provided, will try to find an installation.
Parameters
----------
spark_home : str, optional, defaul... | python | def init(spark_home=None, python_path=None, edit_rc=False, edit_profile=False):
"""Make pyspark importable.
Sets environment variables and adds dependencies to sys.path.
If no Spark location is provided, will try to find an installation.
Parameters
----------
spark_home : str, optional, defaul... | [
"def",
"init",
"(",
"spark_home",
"=",
"None",
",",
"python_path",
"=",
"None",
",",
"edit_rc",
"=",
"False",
",",
"edit_profile",
"=",
"False",
")",
":",
"if",
"not",
"spark_home",
":",
"spark_home",
"=",
"find",
"(",
")",
"if",
"not",
"python_path",
... | Make pyspark importable.
Sets environment variables and adds dependencies to sys.path.
If no Spark location is provided, will try to find an installation.
Parameters
----------
spark_home : str, optional, default = None
Path to Spark installation, will try to find automatically
if ... | [
"Make",
"pyspark",
"importable",
"."
] | 20c945d5136269ca56b1341786c49087faa7c75e | https://github.com/minrk/findspark/blob/20c945d5136269ca56b1341786c49087faa7c75e/findspark.py#L101-L147 |
5,342 | minrk/findspark | findspark.py | _add_to_submit_args | def _add_to_submit_args(s):
"""Adds string s to the PYSPARK_SUBMIT_ARGS env var"""
new_args = os.environ.get("PYSPARK_SUBMIT_ARGS", "") + (" %s" % s)
os.environ["PYSPARK_SUBMIT_ARGS"] = new_args
return new_args | python | def _add_to_submit_args(s):
"""Adds string s to the PYSPARK_SUBMIT_ARGS env var"""
new_args = os.environ.get("PYSPARK_SUBMIT_ARGS", "") + (" %s" % s)
os.environ["PYSPARK_SUBMIT_ARGS"] = new_args
return new_args | [
"def",
"_add_to_submit_args",
"(",
"s",
")",
":",
"new_args",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"\"PYSPARK_SUBMIT_ARGS\"",
",",
"\"\"",
")",
"+",
"(",
"\" %s\"",
"%",
"s",
")",
"os",
".",
"environ",
"[",
"\"PYSPARK_SUBMIT_ARGS\"",
"]",
"=",
"ne... | Adds string s to the PYSPARK_SUBMIT_ARGS env var | [
"Adds",
"string",
"s",
"to",
"the",
"PYSPARK_SUBMIT_ARGS",
"env",
"var"
] | 20c945d5136269ca56b1341786c49087faa7c75e | https://github.com/minrk/findspark/blob/20c945d5136269ca56b1341786c49087faa7c75e/findspark.py#L149-L153 |
5,343 | minrk/findspark | findspark.py | add_packages | def add_packages(packages):
"""Add external packages to the pyspark interpreter.
Set the PYSPARK_SUBMIT_ARGS properly.
Parameters
----------
packages: list of package names in string format
"""
#if the parameter is a string, convert to a single element list
if isinstance(packages,str)... | python | def add_packages(packages):
"""Add external packages to the pyspark interpreter.
Set the PYSPARK_SUBMIT_ARGS properly.
Parameters
----------
packages: list of package names in string format
"""
#if the parameter is a string, convert to a single element list
if isinstance(packages,str)... | [
"def",
"add_packages",
"(",
"packages",
")",
":",
"#if the parameter is a string, convert to a single element list",
"if",
"isinstance",
"(",
"packages",
",",
"str",
")",
":",
"packages",
"=",
"[",
"packages",
"]",
"_add_to_submit_args",
"(",
"\"--packages \"",
"+",
"... | Add external packages to the pyspark interpreter.
Set the PYSPARK_SUBMIT_ARGS properly.
Parameters
----------
packages: list of package names in string format | [
"Add",
"external",
"packages",
"to",
"the",
"pyspark",
"interpreter",
"."
] | 20c945d5136269ca56b1341786c49087faa7c75e | https://github.com/minrk/findspark/blob/20c945d5136269ca56b1341786c49087faa7c75e/findspark.py#L155-L169 |
5,344 | minrk/findspark | findspark.py | add_jars | def add_jars(jars):
"""Add external jars to the pyspark interpreter.
Set the PYSPARK_SUBMIT_ARGS properly.
Parameters
----------
jars: list of path to jars in string format
"""
#if the parameter is a string, convert to a single element list
if isinstance(jars,str):
jars = [jar... | python | def add_jars(jars):
"""Add external jars to the pyspark interpreter.
Set the PYSPARK_SUBMIT_ARGS properly.
Parameters
----------
jars: list of path to jars in string format
"""
#if the parameter is a string, convert to a single element list
if isinstance(jars,str):
jars = [jar... | [
"def",
"add_jars",
"(",
"jars",
")",
":",
"#if the parameter is a string, convert to a single element list",
"if",
"isinstance",
"(",
"jars",
",",
"str",
")",
":",
"jars",
"=",
"[",
"jars",
"]",
"_add_to_submit_args",
"(",
"\"--jars \"",
"+",
"\",\"",
".",
"join",... | Add external jars to the pyspark interpreter.
Set the PYSPARK_SUBMIT_ARGS properly.
Parameters
----------
jars: list of path to jars in string format | [
"Add",
"external",
"jars",
"to",
"the",
"pyspark",
"interpreter",
"."
] | 20c945d5136269ca56b1341786c49087faa7c75e | https://github.com/minrk/findspark/blob/20c945d5136269ca56b1341786c49087faa7c75e/findspark.py#L171-L185 |
5,345 | sdispater/cleo | cleo/parser.py | Parser.parse | def parse(cls, expression):
"""
Parse the given console command definition into a dict.
:param expression: The expression to parse
:type expression: str
:rtype: dict
"""
parsed = {"name": None, "arguments": [], "options": []}
if not expression.strip():
... | python | def parse(cls, expression):
"""
Parse the given console command definition into a dict.
:param expression: The expression to parse
:type expression: str
:rtype: dict
"""
parsed = {"name": None, "arguments": [], "options": []}
if not expression.strip():
... | [
"def",
"parse",
"(",
"cls",
",",
"expression",
")",
":",
"parsed",
"=",
"{",
"\"name\"",
":",
"None",
",",
"\"arguments\"",
":",
"[",
"]",
",",
"\"options\"",
":",
"[",
"]",
"}",
"if",
"not",
"expression",
".",
"strip",
"(",
")",
":",
"raise",
"Val... | Parse the given console command definition into a dict.
:param expression: The expression to parse
:type expression: str
:rtype: dict | [
"Parse",
"the",
"given",
"console",
"command",
"definition",
"into",
"a",
"dict",
"."
] | cf44ac2eba2d6435516501e47e5521ee2da9115a | https://github.com/sdispater/cleo/blob/cf44ac2eba2d6435516501e47e5521ee2da9115a/cleo/parser.py#L16-L45 |
5,346 | sdispater/cleo | cleo/parser.py | Parser._parameters | def _parameters(cls, tokens):
"""
Extract all of the parameters from the tokens.
:param tokens: The tokens to extract the parameters from
:type tokens: list
:rtype: dict
"""
arguments = []
options = []
for token in tokens:
if not tok... | python | def _parameters(cls, tokens):
"""
Extract all of the parameters from the tokens.
:param tokens: The tokens to extract the parameters from
:type tokens: list
:rtype: dict
"""
arguments = []
options = []
for token in tokens:
if not tok... | [
"def",
"_parameters",
"(",
"cls",
",",
"tokens",
")",
":",
"arguments",
"=",
"[",
"]",
"options",
"=",
"[",
"]",
"for",
"token",
"in",
"tokens",
":",
"if",
"not",
"token",
".",
"startswith",
"(",
"\"--\"",
")",
":",
"arguments",
".",
"append",
"(",
... | Extract all of the parameters from the tokens.
:param tokens: The tokens to extract the parameters from
:type tokens: list
:rtype: dict | [
"Extract",
"all",
"of",
"the",
"parameters",
"from",
"the",
"tokens",
"."
] | cf44ac2eba2d6435516501e47e5521ee2da9115a | https://github.com/sdispater/cleo/blob/cf44ac2eba2d6435516501e47e5521ee2da9115a/cleo/parser.py#L48-L66 |
5,347 | sdispater/cleo | cleo/parser.py | Parser._parse_argument | def _parse_argument(cls, token):
"""
Parse an argument expression.
:param token: The argument expression
:type token: str
:rtype: InputArgument
"""
description = ""
validator = None
if " : " in token:
token, description = tuple(token... | python | def _parse_argument(cls, token):
"""
Parse an argument expression.
:param token: The argument expression
:type token: str
:rtype: InputArgument
"""
description = ""
validator = None
if " : " in token:
token, description = tuple(token... | [
"def",
"_parse_argument",
"(",
"cls",
",",
"token",
")",
":",
"description",
"=",
"\"\"",
"validator",
"=",
"None",
"if",
"\" : \"",
"in",
"token",
":",
"token",
",",
"description",
"=",
"tuple",
"(",
"token",
".",
"split",
"(",
"\" : \"",
",",
"2",
")... | Parse an argument expression.
:param token: The argument expression
:type token: str
:rtype: InputArgument | [
"Parse",
"an",
"argument",
"expression",
"."
] | cf44ac2eba2d6435516501e47e5521ee2da9115a | https://github.com/sdispater/cleo/blob/cf44ac2eba2d6435516501e47e5521ee2da9115a/cleo/parser.py#L69-L117 |
5,348 | sdispater/cleo | cleo/parser.py | Parser._parse_option | def _parse_option(cls, token):
"""
Parse an option expression.
:param token: The option expression
:type token: str
:rtype: InputOption
"""
description = ""
validator = None
if " : " in token:
token, description = tuple(token.split("... | python | def _parse_option(cls, token):
"""
Parse an option expression.
:param token: The option expression
:type token: str
:rtype: InputOption
"""
description = ""
validator = None
if " : " in token:
token, description = tuple(token.split("... | [
"def",
"_parse_option",
"(",
"cls",
",",
"token",
")",
":",
"description",
"=",
"\"\"",
"validator",
"=",
"None",
"if",
"\" : \"",
"in",
"token",
":",
"token",
",",
"description",
"=",
"tuple",
"(",
"token",
".",
"split",
"(",
"\" : \"",
",",
"2",
")",... | Parse an option expression.
:param token: The option expression
:type token: str
:rtype: InputOption | [
"Parse",
"an",
"option",
"expression",
"."
] | cf44ac2eba2d6435516501e47e5521ee2da9115a | https://github.com/sdispater/cleo/blob/cf44ac2eba2d6435516501e47e5521ee2da9115a/cleo/parser.py#L120-L186 |
5,349 | sdispater/cleo | cleo/application.py | Application.add | def add(self, command): # type: (BaseCommand) -> Application
"""
Adds a command object.
"""
self.add_command(command.config)
command.set_application(self)
return self | python | def add(self, command): # type: (BaseCommand) -> Application
"""
Adds a command object.
"""
self.add_command(command.config)
command.set_application(self)
return self | [
"def",
"add",
"(",
"self",
",",
"command",
")",
":",
"# type: (BaseCommand) -> Application",
"self",
".",
"add_command",
"(",
"command",
".",
"config",
")",
"command",
".",
"set_application",
"(",
"self",
")",
"return",
"self"
] | Adds a command object. | [
"Adds",
"a",
"command",
"object",
"."
] | cf44ac2eba2d6435516501e47e5521ee2da9115a | https://github.com/sdispater/cleo/blob/cf44ac2eba2d6435516501e47e5521ee2da9115a/cleo/application.py#L38-L45 |
5,350 | sdispater/cleo | cleo/commands/command.py | Command._configure_using_fluent_definition | def _configure_using_fluent_definition(self):
"""
Configure the console command using a fluent definition.
"""
definition = Parser.parse(self.signature)
self._config.set_name(definition["name"])
for name, flags, description, default in definition["arguments"]:
... | python | def _configure_using_fluent_definition(self):
"""
Configure the console command using a fluent definition.
"""
definition = Parser.parse(self.signature)
self._config.set_name(definition["name"])
for name, flags, description, default in definition["arguments"]:
... | [
"def",
"_configure_using_fluent_definition",
"(",
"self",
")",
":",
"definition",
"=",
"Parser",
".",
"parse",
"(",
"self",
".",
"signature",
")",
"self",
".",
"_config",
".",
"set_name",
"(",
"definition",
"[",
"\"name\"",
"]",
")",
"for",
"name",
",",
"f... | Configure the console command using a fluent definition. | [
"Configure",
"the",
"console",
"command",
"using",
"a",
"fluent",
"definition",
"."
] | cf44ac2eba2d6435516501e47e5521ee2da9115a | https://github.com/sdispater/cleo/blob/cf44ac2eba2d6435516501e47e5521ee2da9115a/cleo/commands/command.py#L71-L83 |
5,351 | sdispater/cleo | cleo/commands/command.py | Command.argument | def argument(self, key=None):
"""
Get the value of a command argument.
"""
if key is None:
return self._args.arguments()
return self._args.argument(key) | python | def argument(self, key=None):
"""
Get the value of a command argument.
"""
if key is None:
return self._args.arguments()
return self._args.argument(key) | [
"def",
"argument",
"(",
"self",
",",
"key",
"=",
"None",
")",
":",
"if",
"key",
"is",
"None",
":",
"return",
"self",
".",
"_args",
".",
"arguments",
"(",
")",
"return",
"self",
".",
"_args",
".",
"argument",
"(",
"key",
")"
] | Get the value of a command argument. | [
"Get",
"the",
"value",
"of",
"a",
"command",
"argument",
"."
] | cf44ac2eba2d6435516501e47e5521ee2da9115a | https://github.com/sdispater/cleo/blob/cf44ac2eba2d6435516501e47e5521ee2da9115a/cleo/commands/command.py#L124-L131 |
5,352 | sdispater/cleo | cleo/commands/command.py | Command.option | def option(self, key=None):
"""
Get the value of a command option.
"""
if key is None:
return self._args.options()
return self._args.option(key) | python | def option(self, key=None):
"""
Get the value of a command option.
"""
if key is None:
return self._args.options()
return self._args.option(key) | [
"def",
"option",
"(",
"self",
",",
"key",
"=",
"None",
")",
":",
"if",
"key",
"is",
"None",
":",
"return",
"self",
".",
"_args",
".",
"options",
"(",
")",
"return",
"self",
".",
"_args",
".",
"option",
"(",
"key",
")"
] | Get the value of a command option. | [
"Get",
"the",
"value",
"of",
"a",
"command",
"option",
"."
] | cf44ac2eba2d6435516501e47e5521ee2da9115a | https://github.com/sdispater/cleo/blob/cf44ac2eba2d6435516501e47e5521ee2da9115a/cleo/commands/command.py#L133-L140 |
5,353 | sdispater/cleo | cleo/commands/command.py | Command.confirm | def confirm(self, question, default=False, true_answer_regex="(?i)^y"):
"""
Confirm a question with the user.
"""
return self._io.confirm(question, default, true_answer_regex) | python | def confirm(self, question, default=False, true_answer_regex="(?i)^y"):
"""
Confirm a question with the user.
"""
return self._io.confirm(question, default, true_answer_regex) | [
"def",
"confirm",
"(",
"self",
",",
"question",
",",
"default",
"=",
"False",
",",
"true_answer_regex",
"=",
"\"(?i)^y\"",
")",
":",
"return",
"self",
".",
"_io",
".",
"confirm",
"(",
"question",
",",
"default",
",",
"true_answer_regex",
")"
] | Confirm a question with the user. | [
"Confirm",
"a",
"question",
"with",
"the",
"user",
"."
] | cf44ac2eba2d6435516501e47e5521ee2da9115a | https://github.com/sdispater/cleo/blob/cf44ac2eba2d6435516501e47e5521ee2da9115a/cleo/commands/command.py#L142-L146 |
5,354 | sdispater/cleo | cleo/commands/command.py | Command.ask | def ask(self, question, default=None):
"""
Prompt the user for input.
"""
if isinstance(question, Question):
return self._io.ask_question(question)
return self._io.ask(question, default) | python | def ask(self, question, default=None):
"""
Prompt the user for input.
"""
if isinstance(question, Question):
return self._io.ask_question(question)
return self._io.ask(question, default) | [
"def",
"ask",
"(",
"self",
",",
"question",
",",
"default",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"question",
",",
"Question",
")",
":",
"return",
"self",
".",
"_io",
".",
"ask_question",
"(",
"question",
")",
"return",
"self",
".",
"_io",
... | Prompt the user for input. | [
"Prompt",
"the",
"user",
"for",
"input",
"."
] | cf44ac2eba2d6435516501e47e5521ee2da9115a | https://github.com/sdispater/cleo/blob/cf44ac2eba2d6435516501e47e5521ee2da9115a/cleo/commands/command.py#L148-L155 |
5,355 | sdispater/cleo | cleo/commands/command.py | Command.choice | def choice(self, question, choices, default=None, attempts=None, multiple=False):
"""
Give the user a single choice from an list of answers.
"""
question = ChoiceQuestion(question, choices, default)
question.set_max_attempts(attempts)
question.set_multi_select(multiple)
... | python | def choice(self, question, choices, default=None, attempts=None, multiple=False):
"""
Give the user a single choice from an list of answers.
"""
question = ChoiceQuestion(question, choices, default)
question.set_max_attempts(attempts)
question.set_multi_select(multiple)
... | [
"def",
"choice",
"(",
"self",
",",
"question",
",",
"choices",
",",
"default",
"=",
"None",
",",
"attempts",
"=",
"None",
",",
"multiple",
"=",
"False",
")",
":",
"question",
"=",
"ChoiceQuestion",
"(",
"question",
",",
"choices",
",",
"default",
")",
... | Give the user a single choice from an list of answers. | [
"Give",
"the",
"user",
"a",
"single",
"choice",
"from",
"an",
"list",
"of",
"answers",
"."
] | cf44ac2eba2d6435516501e47e5521ee2da9115a | https://github.com/sdispater/cleo/blob/cf44ac2eba2d6435516501e47e5521ee2da9115a/cleo/commands/command.py#L163-L172 |
5,356 | sdispater/cleo | cleo/commands/command.py | Command.create_question | def create_question(self, question, type=None, **kwargs):
"""
Returns a Question of specified type.
"""
if not type:
return Question(question, **kwargs)
if type == "choice":
return ChoiceQuestion(question, **kwargs)
if type == "confirmation":
... | python | def create_question(self, question, type=None, **kwargs):
"""
Returns a Question of specified type.
"""
if not type:
return Question(question, **kwargs)
if type == "choice":
return ChoiceQuestion(question, **kwargs)
if type == "confirmation":
... | [
"def",
"create_question",
"(",
"self",
",",
"question",
",",
"type",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"type",
":",
"return",
"Question",
"(",
"question",
",",
"*",
"*",
"kwargs",
")",
"if",
"type",
"==",
"\"choice\"",
":",... | Returns a Question of specified type. | [
"Returns",
"a",
"Question",
"of",
"specified",
"type",
"."
] | cf44ac2eba2d6435516501e47e5521ee2da9115a | https://github.com/sdispater/cleo/blob/cf44ac2eba2d6435516501e47e5521ee2da9115a/cleo/commands/command.py#L174-L185 |
5,357 | sdispater/cleo | cleo/commands/command.py | Command.table | def table(self, header=None, rows=None, style=None):
"""
Return a Table instance.
"""
if style is not None:
style = self.TABLE_STYLES[style]
table = Table(style)
if header:
table.set_header_row(header)
if rows:
table.set_rows... | python | def table(self, header=None, rows=None, style=None):
"""
Return a Table instance.
"""
if style is not None:
style = self.TABLE_STYLES[style]
table = Table(style)
if header:
table.set_header_row(header)
if rows:
table.set_rows... | [
"def",
"table",
"(",
"self",
",",
"header",
"=",
"None",
",",
"rows",
"=",
"None",
",",
"style",
"=",
"None",
")",
":",
"if",
"style",
"is",
"not",
"None",
":",
"style",
"=",
"self",
".",
"TABLE_STYLES",
"[",
"style",
"]",
"table",
"=",
"Table",
... | Return a Table instance. | [
"Return",
"a",
"Table",
"instance",
"."
] | cf44ac2eba2d6435516501e47e5521ee2da9115a | https://github.com/sdispater/cleo/blob/cf44ac2eba2d6435516501e47e5521ee2da9115a/cleo/commands/command.py#L187-L202 |
5,358 | sdispater/cleo | cleo/commands/command.py | Command.render_table | def render_table(self, headers, rows, style=None):
"""
Format input to textual table.
"""
table = self.table(headers, rows, style)
table.render(self._io) | python | def render_table(self, headers, rows, style=None):
"""
Format input to textual table.
"""
table = self.table(headers, rows, style)
table.render(self._io) | [
"def",
"render_table",
"(",
"self",
",",
"headers",
",",
"rows",
",",
"style",
"=",
"None",
")",
":",
"table",
"=",
"self",
".",
"table",
"(",
"headers",
",",
"rows",
",",
"style",
")",
"table",
".",
"render",
"(",
"self",
".",
"_io",
")"
] | Format input to textual table. | [
"Format",
"input",
"to",
"textual",
"table",
"."
] | cf44ac2eba2d6435516501e47e5521ee2da9115a | https://github.com/sdispater/cleo/blob/cf44ac2eba2d6435516501e47e5521ee2da9115a/cleo/commands/command.py#L204-L210 |
5,359 | sdispater/cleo | cleo/commands/command.py | Command.line | def line(self, text, style=None, verbosity=None):
"""
Write a string as information output.
"""
if style:
styled = "<%s>%s</>" % (style, text)
else:
styled = text
self._io.write_line(styled, verbosity) | python | def line(self, text, style=None, verbosity=None):
"""
Write a string as information output.
"""
if style:
styled = "<%s>%s</>" % (style, text)
else:
styled = text
self._io.write_line(styled, verbosity) | [
"def",
"line",
"(",
"self",
",",
"text",
",",
"style",
"=",
"None",
",",
"verbosity",
"=",
"None",
")",
":",
"if",
"style",
":",
"styled",
"=",
"\"<%s>%s</>\"",
"%",
"(",
"style",
",",
"text",
")",
"else",
":",
"styled",
"=",
"text",
"self",
".",
... | Write a string as information output. | [
"Write",
"a",
"string",
"as",
"information",
"output",
"."
] | cf44ac2eba2d6435516501e47e5521ee2da9115a | https://github.com/sdispater/cleo/blob/cf44ac2eba2d6435516501e47e5521ee2da9115a/cleo/commands/command.py#L224-L233 |
5,360 | sdispater/cleo | cleo/commands/command.py | Command.line_error | def line_error(self, text, style=None, verbosity=None):
"""
Write a string as information output to stderr.
"""
if style:
styled = "<%s>%s</>" % (style, text)
else:
styled = text
self._io.error_line(styled, verbosity) | python | def line_error(self, text, style=None, verbosity=None):
"""
Write a string as information output to stderr.
"""
if style:
styled = "<%s>%s</>" % (style, text)
else:
styled = text
self._io.error_line(styled, verbosity) | [
"def",
"line_error",
"(",
"self",
",",
"text",
",",
"style",
"=",
"None",
",",
"verbosity",
"=",
"None",
")",
":",
"if",
"style",
":",
"styled",
"=",
"\"<%s>%s</>\"",
"%",
"(",
"style",
",",
"text",
")",
"else",
":",
"styled",
"=",
"text",
"self",
... | Write a string as information output to stderr. | [
"Write",
"a",
"string",
"as",
"information",
"output",
"to",
"stderr",
"."
] | cf44ac2eba2d6435516501e47e5521ee2da9115a | https://github.com/sdispater/cleo/blob/cf44ac2eba2d6435516501e47e5521ee2da9115a/cleo/commands/command.py#L235-L244 |
5,361 | sdispater/cleo | cleo/commands/command.py | Command.progress_indicator | def progress_indicator(self, fmt=None, interval=100, values=None):
"""
Creates a new progress indicator.
"""
return ProgressIndicator(self.io, fmt, interval, values) | python | def progress_indicator(self, fmt=None, interval=100, values=None):
"""
Creates a new progress indicator.
"""
return ProgressIndicator(self.io, fmt, interval, values) | [
"def",
"progress_indicator",
"(",
"self",
",",
"fmt",
"=",
"None",
",",
"interval",
"=",
"100",
",",
"values",
"=",
"None",
")",
":",
"return",
"ProgressIndicator",
"(",
"self",
".",
"io",
",",
"fmt",
",",
"interval",
",",
"values",
")"
] | Creates a new progress indicator. | [
"Creates",
"a",
"new",
"progress",
"indicator",
"."
] | cf44ac2eba2d6435516501e47e5521ee2da9115a | https://github.com/sdispater/cleo/blob/cf44ac2eba2d6435516501e47e5521ee2da9115a/cleo/commands/command.py#L284-L288 |
5,362 | sdispater/cleo | cleo/commands/command.py | Command.spin | def spin(self, start_message, end_message, fmt=None, interval=100, values=None):
"""
Automatically spin a progress indicator.
"""
spinner = ProgressIndicator(self.io, fmt, interval, values)
return spinner.auto(start_message, end_message) | python | def spin(self, start_message, end_message, fmt=None, interval=100, values=None):
"""
Automatically spin a progress indicator.
"""
spinner = ProgressIndicator(self.io, fmt, interval, values)
return spinner.auto(start_message, end_message) | [
"def",
"spin",
"(",
"self",
",",
"start_message",
",",
"end_message",
",",
"fmt",
"=",
"None",
",",
"interval",
"=",
"100",
",",
"values",
"=",
"None",
")",
":",
"spinner",
"=",
"ProgressIndicator",
"(",
"self",
".",
"io",
",",
"fmt",
",",
"interval",
... | Automatically spin a progress indicator. | [
"Automatically",
"spin",
"a",
"progress",
"indicator",
"."
] | cf44ac2eba2d6435516501e47e5521ee2da9115a | https://github.com/sdispater/cleo/blob/cf44ac2eba2d6435516501e47e5521ee2da9115a/cleo/commands/command.py#L290-L296 |
5,363 | sdispater/cleo | cleo/commands/command.py | Command.add_style | def add_style(self, name, fg=None, bg=None, options=None):
"""
Adds a new style
"""
style = Style(name)
if fg is not None:
style.fg(fg)
if bg is not None:
style.bg(bg)
if options is not None:
if "bold" in options:
... | python | def add_style(self, name, fg=None, bg=None, options=None):
"""
Adds a new style
"""
style = Style(name)
if fg is not None:
style.fg(fg)
if bg is not None:
style.bg(bg)
if options is not None:
if "bold" in options:
... | [
"def",
"add_style",
"(",
"self",
",",
"name",
",",
"fg",
"=",
"None",
",",
"bg",
"=",
"None",
",",
"options",
"=",
"None",
")",
":",
"style",
"=",
"Style",
"(",
"name",
")",
"if",
"fg",
"is",
"not",
"None",
":",
"style",
".",
"fg",
"(",
"fg",
... | Adds a new style | [
"Adds",
"a",
"new",
"style"
] | cf44ac2eba2d6435516501e47e5521ee2da9115a | https://github.com/sdispater/cleo/blob/cf44ac2eba2d6435516501e47e5521ee2da9115a/cleo/commands/command.py#L298-L317 |
5,364 | sdispater/cleo | cleo/commands/command.py | Command.overwrite | def overwrite(self, text, size=None):
"""
Overwrites the current line.
It will not add a new line so use line('')
if necessary.
"""
self._io.overwrite(text, size=size) | python | def overwrite(self, text, size=None):
"""
Overwrites the current line.
It will not add a new line so use line('')
if necessary.
"""
self._io.overwrite(text, size=size) | [
"def",
"overwrite",
"(",
"self",
",",
"text",
",",
"size",
"=",
"None",
")",
":",
"self",
".",
"_io",
".",
"overwrite",
"(",
"text",
",",
"size",
"=",
"size",
")"
] | Overwrites the current line.
It will not add a new line so use line('')
if necessary. | [
"Overwrites",
"the",
"current",
"line",
"."
] | cf44ac2eba2d6435516501e47e5521ee2da9115a | https://github.com/sdispater/cleo/blob/cf44ac2eba2d6435516501e47e5521ee2da9115a/cleo/commands/command.py#L319-L326 |
5,365 | Mergifyio/git-pull-request | git_pull_request/__init__.py | get_github_hostname_user_repo_from_url | def get_github_hostname_user_repo_from_url(url):
"""Return hostname, user and repository to fork from.
:param url: The URL to parse
:return: hostname, user, repository
"""
parsed = parse.urlparse(url)
if parsed.netloc == '':
# Probably ssh
host, sep, path = parsed.path.partition... | python | def get_github_hostname_user_repo_from_url(url):
"""Return hostname, user and repository to fork from.
:param url: The URL to parse
:return: hostname, user, repository
"""
parsed = parse.urlparse(url)
if parsed.netloc == '':
# Probably ssh
host, sep, path = parsed.path.partition... | [
"def",
"get_github_hostname_user_repo_from_url",
"(",
"url",
")",
":",
"parsed",
"=",
"parse",
".",
"urlparse",
"(",
"url",
")",
"if",
"parsed",
".",
"netloc",
"==",
"''",
":",
"# Probably ssh",
"host",
",",
"sep",
",",
"path",
"=",
"parsed",
".",
"path",
... | Return hostname, user and repository to fork from.
:param url: The URL to parse
:return: hostname, user, repository | [
"Return",
"hostname",
"user",
"and",
"repository",
"to",
"fork",
"from",
"."
] | 58dbe3325b3dfada02482a32223fb36ebb193248 | https://github.com/Mergifyio/git-pull-request/blob/58dbe3325b3dfada02482a32223fb36ebb193248/git_pull_request/__init__.py#L114-L130 |
5,366 | Mergifyio/git-pull-request | git_pull_request/__init__.py | git_get_title_and_message | def git_get_title_and_message(begin, end):
"""Get title and message summary for patches between 2 commits.
:param begin: first commit to look at
:param end: last commit to look at
:return: number of commits, title, message
"""
titles = git_get_log_titles(begin, end)
title = "Pull request fo... | python | def git_get_title_and_message(begin, end):
"""Get title and message summary for patches between 2 commits.
:param begin: first commit to look at
:param end: last commit to look at
:return: number of commits, title, message
"""
titles = git_get_log_titles(begin, end)
title = "Pull request fo... | [
"def",
"git_get_title_and_message",
"(",
"begin",
",",
"end",
")",
":",
"titles",
"=",
"git_get_log_titles",
"(",
"begin",
",",
"end",
")",
"title",
"=",
"\"Pull request for \"",
"+",
"end",
"if",
"len",
"(",
"titles",
")",
"==",
"1",
":",
"title",
"=",
... | Get title and message summary for patches between 2 commits.
:param begin: first commit to look at
:param end: last commit to look at
:return: number of commits, title, message | [
"Get",
"title",
"and",
"message",
"summary",
"for",
"patches",
"between",
"2",
"commits",
"."
] | 58dbe3325b3dfada02482a32223fb36ebb193248 | https://github.com/Mergifyio/git-pull-request/blob/58dbe3325b3dfada02482a32223fb36ebb193248/git_pull_request/__init__.py#L160-L180 |
5,367 | zhebrak/raftos | raftos/state.py | validate_commit_index | def validate_commit_index(func):
"""Apply to State Machine everything up to commit index"""
@functools.wraps(func)
def wrapped(self, *args, **kwargs):
for not_applied in range(self.log.last_applied + 1, self.log.commit_index + 1):
self.state_machine.apply(self.log[not_applied]['command'... | python | def validate_commit_index(func):
"""Apply to State Machine everything up to commit index"""
@functools.wraps(func)
def wrapped(self, *args, **kwargs):
for not_applied in range(self.log.last_applied + 1, self.log.commit_index + 1):
self.state_machine.apply(self.log[not_applied]['command'... | [
"def",
"validate_commit_index",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"wrapped",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"not_applied",
"in",
"range",
"(",
"self",
".",
"log",... | Apply to State Machine everything up to commit index | [
"Apply",
"to",
"State",
"Machine",
"everything",
"up",
"to",
"commit",
"index"
] | 0d6f9e049b526279b1035f597291a96cf50c9b40 | https://github.com/zhebrak/raftos/blob/0d6f9e049b526279b1035f597291a96cf50c9b40/raftos/state.py#L42-L57 |
5,368 | zhebrak/raftos | raftos/state.py | Leader.execute_command | async def execute_command(self, command):
"""Write to log & send AppendEntries RPC"""
self.apply_future = asyncio.Future(loop=self.loop)
entry = self.log.write(self.storage.term, command)
asyncio.ensure_future(self.append_entries(), loop=self.loop)
await self.apply_future | python | async def execute_command(self, command):
"""Write to log & send AppendEntries RPC"""
self.apply_future = asyncio.Future(loop=self.loop)
entry = self.log.write(self.storage.term, command)
asyncio.ensure_future(self.append_entries(), loop=self.loop)
await self.apply_future | [
"async",
"def",
"execute_command",
"(",
"self",
",",
"command",
")",
":",
"self",
".",
"apply_future",
"=",
"asyncio",
".",
"Future",
"(",
"loop",
"=",
"self",
".",
"loop",
")",
"entry",
"=",
"self",
".",
"log",
".",
"write",
"(",
"self",
".",
"stora... | Write to log & send AppendEntries RPC | [
"Write",
"to",
"log",
"&",
"send",
"AppendEntries",
"RPC"
] | 0d6f9e049b526279b1035f597291a96cf50c9b40 | https://github.com/zhebrak/raftos/blob/0d6f9e049b526279b1035f597291a96cf50c9b40/raftos/state.py#L260-L267 |
5,369 | zhebrak/raftos | raftos/state.py | Candidate.start | def start(self):
"""Increment current term, vote for herself & send vote requests"""
self.storage.update({
'term': self.storage.term + 1,
'voted_for': self.id
})
self.vote_count = 1
self.request_vote()
self.election_timer.start() | python | def start(self):
"""Increment current term, vote for herself & send vote requests"""
self.storage.update({
'term': self.storage.term + 1,
'voted_for': self.id
})
self.vote_count = 1
self.request_vote()
self.election_timer.start() | [
"def",
"start",
"(",
"self",
")",
":",
"self",
".",
"storage",
".",
"update",
"(",
"{",
"'term'",
":",
"self",
".",
"storage",
".",
"term",
"+",
"1",
",",
"'voted_for'",
":",
"self",
".",
"id",
"}",
")",
"self",
".",
"vote_count",
"=",
"1",
"self... | Increment current term, vote for herself & send vote requests | [
"Increment",
"current",
"term",
"vote",
"for",
"herself",
"&",
"send",
"vote",
"requests"
] | 0d6f9e049b526279b1035f597291a96cf50c9b40 | https://github.com/zhebrak/raftos/blob/0d6f9e049b526279b1035f597291a96cf50c9b40/raftos/state.py#L293-L302 |
5,370 | zhebrak/raftos | raftos/state.py | Candidate.on_receive_request_vote_response | def on_receive_request_vote_response(self, data):
"""Receives response for vote request.
If the vote was granted then check if we got majority and may become Leader
"""
if data.get('vote_granted'):
self.vote_count += 1
if self.state.is_majority(self.vote_count):... | python | def on_receive_request_vote_response(self, data):
"""Receives response for vote request.
If the vote was granted then check if we got majority and may become Leader
"""
if data.get('vote_granted'):
self.vote_count += 1
if self.state.is_majority(self.vote_count):... | [
"def",
"on_receive_request_vote_response",
"(",
"self",
",",
"data",
")",
":",
"if",
"data",
".",
"get",
"(",
"'vote_granted'",
")",
":",
"self",
".",
"vote_count",
"+=",
"1",
"if",
"self",
".",
"state",
".",
"is_majority",
"(",
"self",
".",
"vote_count",
... | Receives response for vote request.
If the vote was granted then check if we got majority and may become Leader | [
"Receives",
"response",
"for",
"vote",
"request",
".",
"If",
"the",
"vote",
"was",
"granted",
"then",
"check",
"if",
"we",
"got",
"majority",
"and",
"may",
"become",
"Leader"
] | 0d6f9e049b526279b1035f597291a96cf50c9b40 | https://github.com/zhebrak/raftos/blob/0d6f9e049b526279b1035f597291a96cf50c9b40/raftos/state.py#L326-L335 |
5,371 | zhebrak/raftos | raftos/state.py | Follower.init_storage | def init_storage(self):
"""Set current term to zero upon initialization & voted_for to None"""
if not self.storage.exists('term'):
self.storage.update({
'term': 0,
})
self.storage.update({
'voted_for': None
}) | python | def init_storage(self):
"""Set current term to zero upon initialization & voted_for to None"""
if not self.storage.exists('term'):
self.storage.update({
'term': 0,
})
self.storage.update({
'voted_for': None
}) | [
"def",
"init_storage",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"storage",
".",
"exists",
"(",
"'term'",
")",
":",
"self",
".",
"storage",
".",
"update",
"(",
"{",
"'term'",
":",
"0",
",",
"}",
")",
"self",
".",
"storage",
".",
"update",
... | Set current term to zero upon initialization & voted_for to None | [
"Set",
"current",
"term",
"to",
"zero",
"upon",
"initialization",
"&",
"voted_for",
"to",
"None"
] | 0d6f9e049b526279b1035f597291a96cf50c9b40 | https://github.com/zhebrak/raftos/blob/0d6f9e049b526279b1035f597291a96cf50c9b40/raftos/state.py#L368-L377 |
5,372 | zhebrak/raftos | raftos/state.py | State.wait_for_election_success | async def wait_for_election_success(cls):
"""Await this function if your cluster must have a leader"""
if cls.leader is None:
cls.leader_future = asyncio.Future(loop=cls.loop)
await cls.leader_future | python | async def wait_for_election_success(cls):
"""Await this function if your cluster must have a leader"""
if cls.leader is None:
cls.leader_future = asyncio.Future(loop=cls.loop)
await cls.leader_future | [
"async",
"def",
"wait_for_election_success",
"(",
"cls",
")",
":",
"if",
"cls",
".",
"leader",
"is",
"None",
":",
"cls",
".",
"leader_future",
"=",
"asyncio",
".",
"Future",
"(",
"loop",
"=",
"cls",
".",
"loop",
")",
"await",
"cls",
".",
"leader_future"
... | Await this function if your cluster must have a leader | [
"Await",
"this",
"function",
"if",
"your",
"cluster",
"must",
"have",
"a",
"leader"
] | 0d6f9e049b526279b1035f597291a96cf50c9b40 | https://github.com/zhebrak/raftos/blob/0d6f9e049b526279b1035f597291a96cf50c9b40/raftos/state.py#L597-L601 |
5,373 | zhebrak/raftos | raftos/state.py | State.wait_until_leader | async def wait_until_leader(cls, node_id):
"""Await this function if you want to do nothing until node_id becomes a leader"""
if node_id is None:
raise ValueError('Node id can not be None!')
if cls.get_leader() != node_id:
cls.wait_until_leader_id = node_id
c... | python | async def wait_until_leader(cls, node_id):
"""Await this function if you want to do nothing until node_id becomes a leader"""
if node_id is None:
raise ValueError('Node id can not be None!')
if cls.get_leader() != node_id:
cls.wait_until_leader_id = node_id
c... | [
"async",
"def",
"wait_until_leader",
"(",
"cls",
",",
"node_id",
")",
":",
"if",
"node_id",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'Node id can not be None!'",
")",
"if",
"cls",
".",
"get_leader",
"(",
")",
"!=",
"node_id",
":",
"cls",
".",
"wait_... | Await this function if you want to do nothing until node_id becomes a leader | [
"Await",
"this",
"function",
"if",
"you",
"want",
"to",
"do",
"nothing",
"until",
"node_id",
"becomes",
"a",
"leader"
] | 0d6f9e049b526279b1035f597291a96cf50c9b40 | https://github.com/zhebrak/raftos/blob/0d6f9e049b526279b1035f597291a96cf50c9b40/raftos/state.py#L604-L615 |
5,374 | datajoint/datajoint-python | datajoint/declare.py | declare | def declare(full_table_name, definition, context):
"""
Parse declaration and create new SQL table accordingly.
:param full_table_name: full name of the table
:param definition: DataJoint table definition
:param context: dictionary of objects that might be referred to in the table.
"""
tabl... | python | def declare(full_table_name, definition, context):
"""
Parse declaration and create new SQL table accordingly.
:param full_table_name: full name of the table
:param definition: DataJoint table definition
:param context: dictionary of objects that might be referred to in the table.
"""
tabl... | [
"def",
"declare",
"(",
"full_table_name",
",",
"definition",
",",
"context",
")",
":",
"table_name",
"=",
"full_table_name",
".",
"strip",
"(",
"'`'",
")",
".",
"split",
"(",
"'.'",
")",
"[",
"1",
"]",
"if",
"len",
"(",
"table_name",
")",
">",
"MAX_TAB... | Parse declaration and create new SQL table accordingly.
:param full_table_name: full name of the table
:param definition: DataJoint table definition
:param context: dictionary of objects that might be referred to in the table. | [
"Parse",
"declaration",
"and",
"create",
"new",
"SQL",
"table",
"accordingly",
"."
] | 4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c | https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/declare.py#L192-L245 |
5,375 | datajoint/datajoint-python | datajoint/schema.py | create_virtual_module | def create_virtual_module(module_name, schema_name, create_schema=False, create_tables=False, connection=None):
"""
Creates a python module with the given name from the name of a schema on the server and
automatically adds classes to it corresponding to the tables in the schema.
:param module_name: dis... | python | def create_virtual_module(module_name, schema_name, create_schema=False, create_tables=False, connection=None):
"""
Creates a python module with the given name from the name of a schema on the server and
automatically adds classes to it corresponding to the tables in the schema.
:param module_name: dis... | [
"def",
"create_virtual_module",
"(",
"module_name",
",",
"schema_name",
",",
"create_schema",
"=",
"False",
",",
"create_tables",
"=",
"False",
",",
"connection",
"=",
"None",
")",
":",
"module",
"=",
"types",
".",
"ModuleType",
"(",
"module_name",
")",
"_sche... | Creates a python module with the given name from the name of a schema on the server and
automatically adds classes to it corresponding to the tables in the schema.
:param module_name: displayed module name
:param schema_name: name of the database in mysql
:param create_schema: if True, create the schem... | [
"Creates",
"a",
"python",
"module",
"with",
"the",
"given",
"name",
"from",
"the",
"name",
"of",
"a",
"schema",
"on",
"the",
"server",
"and",
"automatically",
"adds",
"classes",
"to",
"it",
"corresponding",
"to",
"the",
"tables",
"in",
"the",
"schema",
"."... | 4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c | https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/schema.py#L241-L256 |
5,376 | datajoint/datajoint-python | datajoint/schema.py | Schema.drop | def drop(self, force=False):
"""
Drop the associated schema if it exists
"""
if not self.exists:
logger.info("Schema named `{database}` does not exist. Doing nothing.".format(database=self.database))
elif (not config['safemode'] or
force or
... | python | def drop(self, force=False):
"""
Drop the associated schema if it exists
"""
if not self.exists:
logger.info("Schema named `{database}` does not exist. Doing nothing.".format(database=self.database))
elif (not config['safemode'] or
force or
... | [
"def",
"drop",
"(",
"self",
",",
"force",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"exists",
":",
"logger",
".",
"info",
"(",
"\"Schema named `{database}` does not exist. Doing nothing.\"",
".",
"format",
"(",
"database",
"=",
"self",
".",
"database",... | Drop the associated schema if it exists | [
"Drop",
"the",
"associated",
"schema",
"if",
"it",
"exists"
] | 4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c | https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/schema.py#L146-L161 |
5,377 | datajoint/datajoint-python | datajoint/schema.py | Schema.process_relation_class | def process_relation_class(self, relation_class, context, assert_declared=False):
"""
assign schema properties to the relation class and declare the table
"""
relation_class.database = self.database
relation_class._connection = self.connection
relation_class._heading = He... | python | def process_relation_class(self, relation_class, context, assert_declared=False):
"""
assign schema properties to the relation class and declare the table
"""
relation_class.database = self.database
relation_class._connection = self.connection
relation_class._heading = He... | [
"def",
"process_relation_class",
"(",
"self",
",",
"relation_class",
",",
"context",
",",
"assert_declared",
"=",
"False",
")",
":",
"relation_class",
".",
"database",
"=",
"self",
".",
"database",
"relation_class",
".",
"_connection",
"=",
"self",
".",
"connect... | assign schema properties to the relation class and declare the table | [
"assign",
"schema",
"properties",
"to",
"the",
"relation",
"class",
"and",
"declare",
"the",
"table"
] | 4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c | https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/schema.py#L171-L197 |
5,378 | datajoint/datajoint-python | datajoint/table.py | Table.declare | def declare(self, context=None):
"""
Use self.definition to declare the table in the schema.
"""
try:
sql, uses_external = declare(self.full_table_name, self.definition, context)
if uses_external:
sql = sql.format(external_table=self.external_table... | python | def declare(self, context=None):
"""
Use self.definition to declare the table in the schema.
"""
try:
sql, uses_external = declare(self.full_table_name, self.definition, context)
if uses_external:
sql = sql.format(external_table=self.external_table... | [
"def",
"declare",
"(",
"self",
",",
"context",
"=",
"None",
")",
":",
"try",
":",
"sql",
",",
"uses_external",
"=",
"declare",
"(",
"self",
".",
"full_table_name",
",",
"self",
".",
"definition",
",",
"context",
")",
"if",
"uses_external",
":",
"sql",
... | Use self.definition to declare the table in the schema. | [
"Use",
"self",
".",
"definition",
"to",
"declare",
"the",
"table",
"in",
"the",
"schema",
"."
] | 4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c | https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/table.py#L58-L74 |
5,379 | datajoint/datajoint-python | datajoint/table.py | Table.delete_quick | def delete_quick(self, get_count=False):
"""
Deletes the table without cascading and without user prompt.
If this table has populated dependent tables, this will fail.
"""
query = 'DELETE FROM ' + self.full_table_name + self.where_clause
self.connection.query(query)
... | python | def delete_quick(self, get_count=False):
"""
Deletes the table without cascading and without user prompt.
If this table has populated dependent tables, this will fail.
"""
query = 'DELETE FROM ' + self.full_table_name + self.where_clause
self.connection.query(query)
... | [
"def",
"delete_quick",
"(",
"self",
",",
"get_count",
"=",
"False",
")",
":",
"query",
"=",
"'DELETE FROM '",
"+",
"self",
".",
"full_table_name",
"+",
"self",
".",
"where_clause",
"self",
".",
"connection",
".",
"query",
"(",
"query",
")",
"count",
"=",
... | Deletes the table without cascading and without user prompt.
If this table has populated dependent tables, this will fail. | [
"Deletes",
"the",
"table",
"without",
"cascading",
"and",
"without",
"user",
"prompt",
".",
"If",
"this",
"table",
"has",
"populated",
"dependent",
"tables",
"this",
"will",
"fail",
"."
] | 4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c | https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/table.py#L313-L322 |
5,380 | datajoint/datajoint-python | datajoint/table.py | Table._update | def _update(self, attrname, value=None):
"""
Updates a field in an existing tuple. This is not a datajoyous operation and should not be used
routinely. Relational database maintain referential integrity on the level of a tuple. Therefore,
the UPDATE operator can violate refer... | python | def _update(self, attrname, value=None):
"""
Updates a field in an existing tuple. This is not a datajoyous operation and should not be used
routinely. Relational database maintain referential integrity on the level of a tuple. Therefore,
the UPDATE operator can violate refer... | [
"def",
"_update",
"(",
"self",
",",
"attrname",
",",
"value",
"=",
"None",
")",
":",
"if",
"len",
"(",
"self",
")",
"!=",
"1",
":",
"raise",
"DataJointError",
"(",
"'Update is only allowed on one tuple at a time'",
")",
"if",
"attrname",
"not",
"in",
"self",... | Updates a field in an existing tuple. This is not a datajoyous operation and should not be used
routinely. Relational database maintain referential integrity on the level of a tuple. Therefore,
the UPDATE operator can violate referential integrity. The datajoyous way to update information is
... | [
"Updates",
"a",
"field",
"in",
"an",
"existing",
"tuple",
".",
"This",
"is",
"not",
"a",
"datajoyous",
"operation",
"and",
"should",
"not",
"be",
"used",
"routinely",
".",
"Relational",
"database",
"maintain",
"referential",
"integrity",
"on",
"the",
"level",
... | 4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c | https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/table.py#L525-L568 |
5,381 | datajoint/datajoint-python | datajoint/expression.py | QueryExpression.where_clause | def where_clause(self):
"""
convert self.restriction to the SQL WHERE clause
"""
cond = self._make_condition(self.restriction)
return '' if cond is True else ' WHERE %s' % cond | python | def where_clause(self):
"""
convert self.restriction to the SQL WHERE clause
"""
cond = self._make_condition(self.restriction)
return '' if cond is True else ' WHERE %s' % cond | [
"def",
"where_clause",
"(",
"self",
")",
":",
"cond",
"=",
"self",
".",
"_make_condition",
"(",
"self",
".",
"restriction",
")",
"return",
"''",
"if",
"cond",
"is",
"True",
"else",
"' WHERE %s'",
"%",
"cond"
] | convert self.restriction to the SQL WHERE clause | [
"convert",
"self",
".",
"restriction",
"to",
"the",
"SQL",
"WHERE",
"clause"
] | 4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c | https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/expression.py#L196-L201 |
5,382 | datajoint/datajoint-python | datajoint/expression.py | QueryExpression.preview | def preview(self, limit=None, width=None):
"""
returns a preview of the contents of the query.
"""
heading = self.heading
rel = self.proj(*heading.non_blobs)
if limit is None:
limit = config['display.limit']
if width is None:
width = config... | python | def preview(self, limit=None, width=None):
"""
returns a preview of the contents of the query.
"""
heading = self.heading
rel = self.proj(*heading.non_blobs)
if limit is None:
limit = config['display.limit']
if width is None:
width = config... | [
"def",
"preview",
"(",
"self",
",",
"limit",
"=",
"None",
",",
"width",
"=",
"None",
")",
":",
"heading",
"=",
"self",
".",
"heading",
"rel",
"=",
"self",
".",
"proj",
"(",
"*",
"heading",
".",
"non_blobs",
")",
"if",
"limit",
"is",
"None",
":",
... | returns a preview of the contents of the query. | [
"returns",
"a",
"preview",
"of",
"the",
"contents",
"of",
"the",
"query",
"."
] | 4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c | https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/expression.py#L382-L405 |
5,383 | datajoint/datajoint-python | datajoint/expression.py | Join.make_argument_subquery | def make_argument_subquery(arg):
"""
Decide when a Join argument needs to be wrapped in a subquery
"""
return Subquery.create(arg) if isinstance(arg, (GroupBy, Projection)) or arg.restriction else arg | python | def make_argument_subquery(arg):
"""
Decide when a Join argument needs to be wrapped in a subquery
"""
return Subquery.create(arg) if isinstance(arg, (GroupBy, Projection)) or arg.restriction else arg | [
"def",
"make_argument_subquery",
"(",
"arg",
")",
":",
"return",
"Subquery",
".",
"create",
"(",
"arg",
")",
"if",
"isinstance",
"(",
"arg",
",",
"(",
"GroupBy",
",",
"Projection",
")",
")",
"or",
"arg",
".",
"restriction",
"else",
"arg"
] | Decide when a Join argument needs to be wrapped in a subquery | [
"Decide",
"when",
"a",
"Join",
"argument",
"needs",
"to",
"be",
"wrapped",
"in",
"a",
"subquery"
] | 4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c | https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/expression.py#L606-L610 |
5,384 | datajoint/datajoint-python | datajoint/expression.py | Projection._need_subquery | def _need_subquery(arg, attributes, named_attributes):
"""
Decide whether the projection argument needs to be wrapped in a subquery
"""
if arg.heading.expressions or arg.distinct: # argument has any renamed (computed) attributes
return True
restricting_attributes = a... | python | def _need_subquery(arg, attributes, named_attributes):
"""
Decide whether the projection argument needs to be wrapped in a subquery
"""
if arg.heading.expressions or arg.distinct: # argument has any renamed (computed) attributes
return True
restricting_attributes = a... | [
"def",
"_need_subquery",
"(",
"arg",
",",
"attributes",
",",
"named_attributes",
")",
":",
"if",
"arg",
".",
"heading",
".",
"expressions",
"or",
"arg",
".",
"distinct",
":",
"# argument has any renamed (computed) attributes",
"return",
"True",
"restricting_attributes... | Decide whether the projection argument needs to be wrapped in a subquery | [
"Decide",
"whether",
"the",
"projection",
"argument",
"needs",
"to",
"be",
"wrapped",
"in",
"a",
"subquery"
] | 4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c | https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/expression.py#L717-L725 |
5,385 | datajoint/datajoint-python | datajoint/expression.py | Subquery.create | def create(cls, arg):
"""
construct a subquery from arg
"""
obj = cls()
obj._connection = arg.connection
obj._heading = arg.heading.make_subquery_heading()
obj._arg = arg
return obj | python | def create(cls, arg):
"""
construct a subquery from arg
"""
obj = cls()
obj._connection = arg.connection
obj._heading = arg.heading.make_subquery_heading()
obj._arg = arg
return obj | [
"def",
"create",
"(",
"cls",
",",
"arg",
")",
":",
"obj",
"=",
"cls",
"(",
")",
"obj",
".",
"_connection",
"=",
"arg",
".",
"connection",
"obj",
".",
"_heading",
"=",
"arg",
".",
"heading",
".",
"make_subquery_heading",
"(",
")",
"obj",
".",
"_arg",
... | construct a subquery from arg | [
"construct",
"a",
"subquery",
"from",
"arg"
] | 4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c | https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/expression.py#L800-L808 |
5,386 | datajoint/datajoint-python | datajoint/utils.py | user_choice | def user_choice(prompt, choices=("yes", "no"), default=None):
"""
Prompts the user for confirmation. The default value, if any, is capitalized.
:param prompt: Information to display to the user.
:param choices: an iterable of possible choices.
:param default: default choice
:return: the user's... | python | def user_choice(prompt, choices=("yes", "no"), default=None):
"""
Prompts the user for confirmation. The default value, if any, is capitalized.
:param prompt: Information to display to the user.
:param choices: an iterable of possible choices.
:param default: default choice
:return: the user's... | [
"def",
"user_choice",
"(",
"prompt",
",",
"choices",
"=",
"(",
"\"yes\"",
",",
"\"no\"",
")",
",",
"default",
"=",
"None",
")",
":",
"assert",
"default",
"is",
"None",
"or",
"default",
"in",
"choices",
"choice_list",
"=",
"', '",
".",
"join",
"(",
"(",... | Prompts the user for confirmation. The default value, if any, is capitalized.
:param prompt: Information to display to the user.
:param choices: an iterable of possible choices.
:param default: default choice
:return: the user's choice | [
"Prompts",
"the",
"user",
"for",
"confirmation",
".",
"The",
"default",
"value",
"if",
"any",
"is",
"capitalized",
"."
] | 4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c | https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/utils.py#L16-L31 |
5,387 | datajoint/datajoint-python | datajoint/fetch.py | to_dicts | def to_dicts(recarray):
"""convert record array to a dictionaries"""
for rec in recarray:
yield dict(zip(recarray.dtype.names, rec.tolist())) | python | def to_dicts(recarray):
"""convert record array to a dictionaries"""
for rec in recarray:
yield dict(zip(recarray.dtype.names, rec.tolist())) | [
"def",
"to_dicts",
"(",
"recarray",
")",
":",
"for",
"rec",
"in",
"recarray",
":",
"yield",
"dict",
"(",
"zip",
"(",
"recarray",
".",
"dtype",
".",
"names",
",",
"rec",
".",
"tolist",
"(",
")",
")",
")"
] | convert record array to a dictionaries | [
"convert",
"record",
"array",
"to",
"a",
"dictionaries"
] | 4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c | https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/fetch.py#L24-L27 |
5,388 | datajoint/datajoint-python | datajoint/fetch.py | Fetch.keys | def keys(self, **kwargs):
"""
DEPRECATED
Iterator that returns primary keys as a sequence of dicts.
"""
warnings.warn('Use of `rel.fetch.keys()` notation is deprecated. '
'Please use `rel.fetch("KEY")` or `rel.fetch(dj.key)` for equivalent result', stackleve... | python | def keys(self, **kwargs):
"""
DEPRECATED
Iterator that returns primary keys as a sequence of dicts.
"""
warnings.warn('Use of `rel.fetch.keys()` notation is deprecated. '
'Please use `rel.fetch("KEY")` or `rel.fetch(dj.key)` for equivalent result', stackleve... | [
"def",
"keys",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"warnings",
".",
"warn",
"(",
"'Use of `rel.fetch.keys()` notation is deprecated. '",
"'Please use `rel.fetch(\"KEY\")` or `rel.fetch(dj.key)` for equivalent result'",
",",
"stacklevel",
"=",
"2",
")",
"yield",
... | DEPRECATED
Iterator that returns primary keys as a sequence of dicts. | [
"DEPRECATED",
"Iterator",
"that",
"returns",
"primary",
"keys",
"as",
"a",
"sequence",
"of",
"dicts",
"."
] | 4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c | https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/fetch.py#L131-L138 |
5,389 | datajoint/datajoint-python | datajoint/hash.py | key_hash | def key_hash(key):
"""
32-byte hash used for lookup of primary keys of jobs
"""
hashed = hashlib.md5()
for k, v in sorted(key.items()):
hashed.update(str(v).encode())
return hashed.hexdigest() | python | def key_hash(key):
"""
32-byte hash used for lookup of primary keys of jobs
"""
hashed = hashlib.md5()
for k, v in sorted(key.items()):
hashed.update(str(v).encode())
return hashed.hexdigest() | [
"def",
"key_hash",
"(",
"key",
")",
":",
"hashed",
"=",
"hashlib",
".",
"md5",
"(",
")",
"for",
"k",
",",
"v",
"in",
"sorted",
"(",
"key",
".",
"items",
"(",
")",
")",
":",
"hashed",
".",
"update",
"(",
"str",
"(",
"v",
")",
".",
"encode",
"(... | 32-byte hash used for lookup of primary keys of jobs | [
"32",
"-",
"byte",
"hash",
"used",
"for",
"lookup",
"of",
"primary",
"keys",
"of",
"jobs"
] | 4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c | https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/hash.py#L5-L12 |
5,390 | datajoint/datajoint-python | datajoint/connection.py | conn | def conn(host=None, user=None, password=None, init_fun=None, reset=False):
"""
Returns a persistent connection object to be shared by multiple modules.
If the connection is not yet established or reset=True, a new connection is set up.
If connection information is not provided, it is taken from config w... | python | def conn(host=None, user=None, password=None, init_fun=None, reset=False):
"""
Returns a persistent connection object to be shared by multiple modules.
If the connection is not yet established or reset=True, a new connection is set up.
If connection information is not provided, it is taken from config w... | [
"def",
"conn",
"(",
"host",
"=",
"None",
",",
"user",
"=",
"None",
",",
"password",
"=",
"None",
",",
"init_fun",
"=",
"None",
",",
"reset",
"=",
"False",
")",
":",
"if",
"not",
"hasattr",
"(",
"conn",
",",
"'connection'",
")",
"or",
"reset",
":",
... | Returns a persistent connection object to be shared by multiple modules.
If the connection is not yet established or reset=True, a new connection is set up.
If connection information is not provided, it is taken from config which takes the
information from dj_local_conf.json. If the password is not specifie... | [
"Returns",
"a",
"persistent",
"connection",
"object",
"to",
"be",
"shared",
"by",
"multiple",
"modules",
".",
"If",
"the",
"connection",
"is",
"not",
"yet",
"established",
"or",
"reset",
"=",
"True",
"a",
"new",
"connection",
"is",
"set",
"up",
".",
"If",
... | 4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c | https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/connection.py#L20-L44 |
5,391 | datajoint/datajoint-python | datajoint/connection.py | Connection.connect | def connect(self):
"""
Connects to the database server.
"""
with warnings.catch_warnings():
warnings.filterwarnings('ignore', '.*deprecated.*')
self._conn = client.connect(
init_command=self.init_fun,
sql_mode="NO_ZERO_DATE,NO_ZERO_... | python | def connect(self):
"""
Connects to the database server.
"""
with warnings.catch_warnings():
warnings.filterwarnings('ignore', '.*deprecated.*')
self._conn = client.connect(
init_command=self.init_fun,
sql_mode="NO_ZERO_DATE,NO_ZERO_... | [
"def",
"connect",
"(",
"self",
")",
":",
"with",
"warnings",
".",
"catch_warnings",
"(",
")",
":",
"warnings",
".",
"filterwarnings",
"(",
"'ignore'",
",",
"'.*deprecated.*'",
")",
"self",
".",
"_conn",
"=",
"client",
".",
"connect",
"(",
"init_command",
"... | Connects to the database server. | [
"Connects",
"to",
"the",
"database",
"server",
"."
] | 4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c | https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/connection.py#L88-L100 |
5,392 | datajoint/datajoint-python | datajoint/connection.py | Connection.start_transaction | def start_transaction(self):
"""
Starts a transaction error.
:raise DataJointError: if there is an ongoing transaction.
"""
if self.in_transaction:
raise DataJointError("Nested connections are not supported.")
self.query('START TRANSACTION WITH CONSISTENT SNA... | python | def start_transaction(self):
"""
Starts a transaction error.
:raise DataJointError: if there is an ongoing transaction.
"""
if self.in_transaction:
raise DataJointError("Nested connections are not supported.")
self.query('START TRANSACTION WITH CONSISTENT SNA... | [
"def",
"start_transaction",
"(",
"self",
")",
":",
"if",
"self",
".",
"in_transaction",
":",
"raise",
"DataJointError",
"(",
"\"Nested connections are not supported.\"",
")",
"self",
".",
"query",
"(",
"'START TRANSACTION WITH CONSISTENT SNAPSHOT'",
")",
"self",
".",
... | Starts a transaction error.
:raise DataJointError: if there is an ongoing transaction. | [
"Starts",
"a",
"transaction",
"error",
"."
] | 4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c | https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/connection.py#L185-L195 |
5,393 | datajoint/datajoint-python | datajoint/settings.py | Config.save_global | def save_global(self, verbose=False):
"""
saves the settings in the global config file
"""
self.save(os.path.expanduser(os.path.join('~', GLOBALCONFIG)), verbose) | python | def save_global(self, verbose=False):
"""
saves the settings in the global config file
"""
self.save(os.path.expanduser(os.path.join('~', GLOBALCONFIG)), verbose) | [
"def",
"save_global",
"(",
"self",
",",
"verbose",
"=",
"False",
")",
":",
"self",
".",
"save",
"(",
"os",
".",
"path",
".",
"expanduser",
"(",
"os",
".",
"path",
".",
"join",
"(",
"'~'",
",",
"GLOBALCONFIG",
")",
")",
",",
"verbose",
")"
] | saves the settings in the global config file | [
"saves",
"the",
"settings",
"in",
"the",
"global",
"config",
"file"
] | 4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c | https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/settings.py#L121-L125 |
5,394 | datajoint/datajoint-python | datajoint/heading.py | Attribute.todict | def todict(self):
"""Convert namedtuple to dict."""
return OrderedDict((name, self[i]) for i, name in enumerate(self._fields)) | python | def todict(self):
"""Convert namedtuple to dict."""
return OrderedDict((name, self[i]) for i, name in enumerate(self._fields)) | [
"def",
"todict",
"(",
"self",
")",
":",
"return",
"OrderedDict",
"(",
"(",
"name",
",",
"self",
"[",
"i",
"]",
")",
"for",
"i",
",",
"name",
"in",
"enumerate",
"(",
"self",
".",
"_fields",
")",
")"
] | Convert namedtuple to dict. | [
"Convert",
"namedtuple",
"to",
"dict",
"."
] | 4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c | https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/heading.py#L20-L22 |
5,395 | datajoint/datajoint-python | datajoint/heading.py | Heading.as_dtype | def as_dtype(self):
"""
represent the heading as a numpy dtype
"""
return np.dtype(dict(
names=self.names,
formats=[v.dtype for v in self.attributes.values()])) | python | def as_dtype(self):
"""
represent the heading as a numpy dtype
"""
return np.dtype(dict(
names=self.names,
formats=[v.dtype for v in self.attributes.values()])) | [
"def",
"as_dtype",
"(",
"self",
")",
":",
"return",
"np",
".",
"dtype",
"(",
"dict",
"(",
"names",
"=",
"self",
".",
"names",
",",
"formats",
"=",
"[",
"v",
".",
"dtype",
"for",
"v",
"in",
"self",
".",
"attributes",
".",
"values",
"(",
")",
"]",
... | represent the heading as a numpy dtype | [
"represent",
"the",
"heading",
"as",
"a",
"numpy",
"dtype"
] | 4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c | https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/heading.py#L112-L118 |
5,396 | datajoint/datajoint-python | datajoint/heading.py | Heading.as_sql | def as_sql(self):
"""
represent heading as SQL field list
"""
return ','.join('`%s`' % name if self.attributes[name].sql_expression is None
else '%s as `%s`' % (self.attributes[name].sql_expression, name)
for name in self.names) | python | def as_sql(self):
"""
represent heading as SQL field list
"""
return ','.join('`%s`' % name if self.attributes[name].sql_expression is None
else '%s as `%s`' % (self.attributes[name].sql_expression, name)
for name in self.names) | [
"def",
"as_sql",
"(",
"self",
")",
":",
"return",
"','",
".",
"join",
"(",
"'`%s`'",
"%",
"name",
"if",
"self",
".",
"attributes",
"[",
"name",
"]",
".",
"sql_expression",
"is",
"None",
"else",
"'%s as `%s`'",
"%",
"(",
"self",
".",
"attributes",
"[",
... | represent heading as SQL field list | [
"represent",
"heading",
"as",
"SQL",
"field",
"list"
] | 4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c | https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/heading.py#L121-L127 |
5,397 | datajoint/datajoint-python | datajoint/heading.py | Heading.join | def join(self, other):
"""
Join two headings into a new one.
It assumes that self and other are headings that share no common dependent attributes.
"""
return Heading(
[self.attributes[name].todict() for name in self.primary_key] +
[other.attributes[name].... | python | def join(self, other):
"""
Join two headings into a new one.
It assumes that self and other are headings that share no common dependent attributes.
"""
return Heading(
[self.attributes[name].todict() for name in self.primary_key] +
[other.attributes[name].... | [
"def",
"join",
"(",
"self",
",",
"other",
")",
":",
"return",
"Heading",
"(",
"[",
"self",
".",
"attributes",
"[",
"name",
"]",
".",
"todict",
"(",
")",
"for",
"name",
"in",
"self",
".",
"primary_key",
"]",
"+",
"[",
"other",
".",
"attributes",
"["... | Join two headings into a new one.
It assumes that self and other are headings that share no common dependent attributes. | [
"Join",
"two",
"headings",
"into",
"a",
"new",
"one",
".",
"It",
"assumes",
"that",
"self",
"and",
"other",
"are",
"headings",
"that",
"share",
"no",
"common",
"dependent",
"attributes",
"."
] | 4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c | https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/heading.py#L271-L280 |
5,398 | datajoint/datajoint-python | datajoint/heading.py | Heading.make_subquery_heading | def make_subquery_heading(self):
"""
Create a new heading with removed attribute sql_expressions.
Used by subqueries, which resolve the sql_expressions.
"""
return Heading(dict(v.todict(), sql_expression=None) for v in self.attributes.values()) | python | def make_subquery_heading(self):
"""
Create a new heading with removed attribute sql_expressions.
Used by subqueries, which resolve the sql_expressions.
"""
return Heading(dict(v.todict(), sql_expression=None) for v in self.attributes.values()) | [
"def",
"make_subquery_heading",
"(",
"self",
")",
":",
"return",
"Heading",
"(",
"dict",
"(",
"v",
".",
"todict",
"(",
")",
",",
"sql_expression",
"=",
"None",
")",
"for",
"v",
"in",
"self",
".",
"attributes",
".",
"values",
"(",
")",
")"
] | Create a new heading with removed attribute sql_expressions.
Used by subqueries, which resolve the sql_expressions. | [
"Create",
"a",
"new",
"heading",
"with",
"removed",
"attribute",
"sql_expressions",
".",
"Used",
"by",
"subqueries",
"which",
"resolve",
"the",
"sql_expressions",
"."
] | 4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c | https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/heading.py#L282-L287 |
5,399 | datajoint/datajoint-python | datajoint/blob.py | BlobReader.squeeze | def squeeze(self, array):
"""
Simplify the given array as much as possible - squeeze out all singleton
dimensions and also convert a zero dimensional array into array scalar
"""
if not self._squeeze:
return array
array = array.copy()
array = array.sque... | python | def squeeze(self, array):
"""
Simplify the given array as much as possible - squeeze out all singleton
dimensions and also convert a zero dimensional array into array scalar
"""
if not self._squeeze:
return array
array = array.copy()
array = array.sque... | [
"def",
"squeeze",
"(",
"self",
",",
"array",
")",
":",
"if",
"not",
"self",
".",
"_squeeze",
":",
"return",
"array",
"array",
"=",
"array",
".",
"copy",
"(",
")",
"array",
"=",
"array",
".",
"squeeze",
"(",
")",
"if",
"array",
".",
"ndim",
"==",
... | Simplify the given array as much as possible - squeeze out all singleton
dimensions and also convert a zero dimensional array into array scalar | [
"Simplify",
"the",
"given",
"array",
"as",
"much",
"as",
"possible",
"-",
"squeeze",
"out",
"all",
"singleton",
"dimensions",
"and",
"also",
"convert",
"a",
"zero",
"dimensional",
"array",
"into",
"array",
"scalar"
] | 4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c | https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/blob.py#L152-L163 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.