partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | publish | Publish code to PyPI or index of choice.
All parameters save ``dry_run`` and ``directory`` honor config settings of
the same name, under the ``packaging`` tree. E.g. say
``.configure({'packaging': {'wheel': True}})`` to force building wheel
archives by default.
:param bool sdist:
Whether t... | invocations/packaging/release.py | def publish(
c,
sdist=True,
wheel=False,
index=None,
sign=False,
dry_run=False,
directory=None,
dual_wheels=False,
alt_python=None,
check_desc=False,
):
"""
Publish code to PyPI or index of choice.
All parameters save ``dry_run`` and ``directory`` honor config settin... | def publish(
c,
sdist=True,
wheel=False,
index=None,
sign=False,
dry_run=False,
directory=None,
dual_wheels=False,
alt_python=None,
check_desc=False,
):
"""
Publish code to PyPI or index of choice.
All parameters save ``dry_run`` and ``directory`` honor config settin... | [
"Publish",
"code",
"to",
"PyPI",
"or",
"index",
"of",
"choice",
"."
] | pyinvoke/invocations | python | https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/packaging/release.py#L605-L700 | [
"def",
"publish",
"(",
"c",
",",
"sdist",
"=",
"True",
",",
"wheel",
"=",
"False",
",",
"index",
"=",
"None",
",",
"sign",
"=",
"False",
",",
"dry_run",
"=",
"False",
",",
"directory",
"=",
"None",
",",
"dual_wheels",
"=",
"False",
",",
"alt_python",... | bbf1b319bd1536817d5301ceb9eeb2f31830e5dc |
train | upload | Upload (potentially also signing) all artifacts in ``directory``.
:param str index:
Custom upload index/repository name.
By default, uses whatever the invoked ``pip`` is configured to use.
Modify your ``pypirc`` file to add new named repositories.
:param bool sign:
Whether to ... | invocations/packaging/release.py | def upload(c, directory, index=None, sign=False, dry_run=False):
"""
Upload (potentially also signing) all artifacts in ``directory``.
:param str index:
Custom upload index/repository name.
By default, uses whatever the invoked ``pip`` is configured to use.
Modify your ``pypirc`` f... | def upload(c, directory, index=None, sign=False, dry_run=False):
"""
Upload (potentially also signing) all artifacts in ``directory``.
:param str index:
Custom upload index/repository name.
By default, uses whatever the invoked ``pip`` is configured to use.
Modify your ``pypirc`` f... | [
"Upload",
"(",
"potentially",
"also",
"signing",
")",
"all",
"artifacts",
"in",
"directory",
"."
] | pyinvoke/invocations | python | https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/packaging/release.py#L703-L766 | [
"def",
"upload",
"(",
"c",
",",
"directory",
",",
"index",
"=",
"None",
",",
"sign",
"=",
"False",
",",
"dry_run",
"=",
"False",
")",
":",
"# Obtain list of archive filenames, then ensure any wheels come first",
"# so their improved metadata is what PyPI sees initially (oth... | bbf1b319bd1536817d5301ceb9eeb2f31830e5dc |
train | tmpdir | Context-manage a temporary directory.
Can be given ``skip_cleanup`` to skip cleanup, and ``explicit`` to choose a
specific location.
(If both are given, this is basically not doing anything, but it allows
code that normally requires a secure temporary directory to 'dry run'
instead.) | invocations/util.py | def tmpdir(skip_cleanup=False, explicit=None):
"""
Context-manage a temporary directory.
Can be given ``skip_cleanup`` to skip cleanup, and ``explicit`` to choose a
specific location.
(If both are given, this is basically not doing anything, but it allows
code that normally requires a secure t... | def tmpdir(skip_cleanup=False, explicit=None):
"""
Context-manage a temporary directory.
Can be given ``skip_cleanup`` to skip cleanup, and ``explicit`` to choose a
specific location.
(If both are given, this is basically not doing anything, but it allows
code that normally requires a secure t... | [
"Context",
"-",
"manage",
"a",
"temporary",
"directory",
"."
] | pyinvoke/invocations | python | https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/util.py#L7-L23 | [
"def",
"tmpdir",
"(",
"skip_cleanup",
"=",
"False",
",",
"explicit",
"=",
"None",
")",
":",
"tmp",
"=",
"explicit",
"if",
"explicit",
"is",
"not",
"None",
"else",
"mkdtemp",
"(",
")",
"try",
":",
"yield",
"tmp",
"finally",
":",
"if",
"not",
"skip_clean... | bbf1b319bd1536817d5301ceb9eeb2f31830e5dc |
train | Rose.permute | Generate ransom spatial permutations for inference on LISA vectors.
Parameters
----------
permutations : int, optional
Number of random permutations of observations.
alternative : string, optional
Type of alternative to form in generating p-values.
Op... | giddy/directional.py | def permute(self, permutations=99, alternative='two.sided'):
"""
Generate ransom spatial permutations for inference on LISA vectors.
Parameters
----------
permutations : int, optional
Number of random permutations of observations.
alternative : string, option... | def permute(self, permutations=99, alternative='two.sided'):
"""
Generate ransom spatial permutations for inference on LISA vectors.
Parameters
----------
permutations : int, optional
Number of random permutations of observations.
alternative : string, option... | [
"Generate",
"ransom",
"spatial",
"permutations",
"for",
"inference",
"on",
"LISA",
"vectors",
"."
] | pysal/giddy | python | https://github.com/pysal/giddy/blob/13fae6c18933614be78e91a6b5060693bea33a04/giddy/directional.py#L227-L300 | [
"def",
"permute",
"(",
"self",
",",
"permutations",
"=",
"99",
",",
"alternative",
"=",
"'two.sided'",
")",
":",
"rY",
"=",
"self",
".",
"Y",
".",
"copy",
"(",
")",
"idxs",
"=",
"np",
".",
"arange",
"(",
"len",
"(",
"rY",
")",
")",
"counts",
"=",... | 13fae6c18933614be78e91a6b5060693bea33a04 |
train | Rose.plot | Plot the rose diagram.
Parameters
----------
attribute : (n,) ndarray, optional
Variable to specify colors of the colorbars.
ax : Matplotlib Axes instance, optional
If given, the figure will be created inside this axis.
Default =None. Note, this axis ... | giddy/directional.py | def plot(self, attribute=None, ax=None, **kwargs):
"""
Plot the rose diagram.
Parameters
----------
attribute : (n,) ndarray, optional
Variable to specify colors of the colorbars.
ax : Matplotlib Axes instance, optional
If given, the figure will b... | def plot(self, attribute=None, ax=None, **kwargs):
"""
Plot the rose diagram.
Parameters
----------
attribute : (n,) ndarray, optional
Variable to specify colors of the colorbars.
ax : Matplotlib Axes instance, optional
If given, the figure will b... | [
"Plot",
"the",
"rose",
"diagram",
"."
] | pysal/giddy | python | https://github.com/pysal/giddy/blob/13fae6c18933614be78e91a6b5060693bea33a04/giddy/directional.py#L324-L351 | [
"def",
"plot",
"(",
"self",
",",
"attribute",
"=",
"None",
",",
"ax",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
"splot",
".",
"giddy",
"import",
"dynamic_lisa_rose",
"fig",
",",
"ax",
"=",
"dynamic_lisa_rose",
"(",
"self",
",",
"attribute... | 13fae6c18933614be78e91a6b5060693bea33a04 |
train | Rose.plot_origin | Plot vectors of positional transition of LISA values starting
from the same origin. | giddy/directional.py | def plot_origin(self): # TODO add attribute option to color vectors
"""
Plot vectors of positional transition of LISA values starting
from the same origin.
"""
import matplotlib.cm as cm
import matplotlib.pyplot as plt
ax = plt.subplot(111)
xlim = [self._... | def plot_origin(self): # TODO add attribute option to color vectors
"""
Plot vectors of positional transition of LISA values starting
from the same origin.
"""
import matplotlib.cm as cm
import matplotlib.pyplot as plt
ax = plt.subplot(111)
xlim = [self._... | [
"Plot",
"vectors",
"of",
"positional",
"transition",
"of",
"LISA",
"values",
"starting",
"from",
"the",
"same",
"origin",
"."
] | pysal/giddy | python | https://github.com/pysal/giddy/blob/13fae6c18933614be78e91a6b5060693bea33a04/giddy/directional.py#L353-L369 | [
"def",
"plot_origin",
"(",
"self",
")",
":",
"# TODO add attribute option to color vectors",
"import",
"matplotlib",
".",
"cm",
"as",
"cm",
"import",
"matplotlib",
".",
"pyplot",
"as",
"plt",
"ax",
"=",
"plt",
".",
"subplot",
"(",
"111",
")",
"xlim",
"=",
"[... | 13fae6c18933614be78e91a6b5060693bea33a04 |
train | Rose.plot_vectors | Plot vectors of positional transition of LISA values
within quadrant in scatterplot in a polar plot.
Parameters
----------
ax : Matplotlib Axes instance, optional
If given, the figure will be created inside this axis.
Default =None.
arrows : boolean, opti... | giddy/directional.py | def plot_vectors(self, arrows=True):
"""
Plot vectors of positional transition of LISA values
within quadrant in scatterplot in a polar plot.
Parameters
----------
ax : Matplotlib Axes instance, optional
If given, the figure will be created inside this axis.
... | def plot_vectors(self, arrows=True):
"""
Plot vectors of positional transition of LISA values
within quadrant in scatterplot in a polar plot.
Parameters
----------
ax : Matplotlib Axes instance, optional
If given, the figure will be created inside this axis.
... | [
"Plot",
"vectors",
"of",
"positional",
"transition",
"of",
"LISA",
"values",
"within",
"quadrant",
"in",
"scatterplot",
"in",
"a",
"polar",
"plot",
"."
] | pysal/giddy | python | https://github.com/pysal/giddy/blob/13fae6c18933614be78e91a6b5060693bea33a04/giddy/directional.py#L372-L400 | [
"def",
"plot_vectors",
"(",
"self",
",",
"arrows",
"=",
"True",
")",
":",
"from",
"splot",
".",
"giddy",
"import",
"dynamic_lisa_vectors",
"fig",
",",
"ax",
"=",
"dynamic_lisa_vectors",
"(",
"self",
",",
"arrows",
"=",
"arrows",
")",
"return",
"fig",
",",
... | 13fae6c18933614be78e91a6b5060693bea33a04 |
train | _clean | Nuke docs build target directory so next build is clean. | invocations/docs.py | def _clean(c):
"""
Nuke docs build target directory so next build is clean.
"""
if isdir(c.sphinx.target):
rmtree(c.sphinx.target) | def _clean(c):
"""
Nuke docs build target directory so next build is clean.
"""
if isdir(c.sphinx.target):
rmtree(c.sphinx.target) | [
"Nuke",
"docs",
"build",
"target",
"directory",
"so",
"next",
"build",
"is",
"clean",
"."
] | pyinvoke/invocations | python | https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/docs.py#L17-L22 | [
"def",
"_clean",
"(",
"c",
")",
":",
"if",
"isdir",
"(",
"c",
".",
"sphinx",
".",
"target",
")",
":",
"rmtree",
"(",
"c",
".",
"sphinx",
".",
"target",
")"
] | bbf1b319bd1536817d5301ceb9eeb2f31830e5dc |
train | _browse | Open build target's index.html in a browser (using 'open'). | invocations/docs.py | def _browse(c):
"""
Open build target's index.html in a browser (using 'open').
"""
index = join(c.sphinx.target, c.sphinx.target_file)
c.run("open {0}".format(index)) | def _browse(c):
"""
Open build target's index.html in a browser (using 'open').
"""
index = join(c.sphinx.target, c.sphinx.target_file)
c.run("open {0}".format(index)) | [
"Open",
"build",
"target",
"s",
"index",
".",
"html",
"in",
"a",
"browser",
"(",
"using",
"open",
")",
"."
] | pyinvoke/invocations | python | https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/docs.py#L27-L32 | [
"def",
"_browse",
"(",
"c",
")",
":",
"index",
"=",
"join",
"(",
"c",
".",
"sphinx",
".",
"target",
",",
"c",
".",
"sphinx",
".",
"target_file",
")",
"c",
".",
"run",
"(",
"\"open {0}\"",
".",
"format",
"(",
"index",
")",
")"
] | bbf1b319bd1536817d5301ceb9eeb2f31830e5dc |
train | build | Build the project's Sphinx docs. | invocations/docs.py | def build(
c,
clean=False,
browse=False,
nitpick=False,
opts=None,
source=None,
target=None,
):
"""
Build the project's Sphinx docs.
"""
if clean:
_clean(c)
if opts is None:
opts = ""
if nitpick:
opts += " -n -W -T"
cmd = "sphinx-build{0} {... | def build(
c,
clean=False,
browse=False,
nitpick=False,
opts=None,
source=None,
target=None,
):
"""
Build the project's Sphinx docs.
"""
if clean:
_clean(c)
if opts is None:
opts = ""
if nitpick:
opts += " -n -W -T"
cmd = "sphinx-build{0} {... | [
"Build",
"the",
"project",
"s",
"Sphinx",
"docs",
"."
] | pyinvoke/invocations | python | https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/docs.py#L46-L71 | [
"def",
"build",
"(",
"c",
",",
"clean",
"=",
"False",
",",
"browse",
"=",
"False",
",",
"nitpick",
"=",
"False",
",",
"opts",
"=",
"None",
",",
"source",
"=",
"None",
",",
"target",
"=",
"None",
",",
")",
":",
"if",
"clean",
":",
"_clean",
"(",
... | bbf1b319bd1536817d5301ceb9eeb2f31830e5dc |
train | tree | Display documentation contents with the 'tree' program. | invocations/docs.py | def tree(c):
"""
Display documentation contents with the 'tree' program.
"""
ignore = ".git|*.pyc|*.swp|dist|*.egg-info|_static|_build|_templates"
c.run('tree -Ca -I "{0}" {1}'.format(ignore, c.sphinx.source)) | def tree(c):
"""
Display documentation contents with the 'tree' program.
"""
ignore = ".git|*.pyc|*.swp|dist|*.egg-info|_static|_build|_templates"
c.run('tree -Ca -I "{0}" {1}'.format(ignore, c.sphinx.source)) | [
"Display",
"documentation",
"contents",
"with",
"the",
"tree",
"program",
"."
] | pyinvoke/invocations | python | https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/docs.py#L95-L100 | [
"def",
"tree",
"(",
"c",
")",
":",
"ignore",
"=",
"\".git|*.pyc|*.swp|dist|*.egg-info|_static|_build|_templates\"",
"c",
".",
"run",
"(",
"'tree -Ca -I \"{0}\" {1}'",
".",
"format",
"(",
"ignore",
",",
"c",
".",
"sphinx",
".",
"source",
")",
")"
] | bbf1b319bd1536817d5301ceb9eeb2f31830e5dc |
train | sites | Build both doc sites w/ maxed nitpicking. | invocations/docs.py | def sites(c):
"""
Build both doc sites w/ maxed nitpicking.
"""
# TODO: This is super lolzy but we haven't actually tackled nontrivial
# in-Python task calling yet, so we do this to get a copy of 'our' context,
# which has been updated with the per-collection config data of the
# docs/www su... | def sites(c):
"""
Build both doc sites w/ maxed nitpicking.
"""
# TODO: This is super lolzy but we haven't actually tackled nontrivial
# in-Python task calling yet, so we do this to get a copy of 'our' context,
# which has been updated with the per-collection config data of the
# docs/www su... | [
"Build",
"both",
"doc",
"sites",
"w",
"/",
"maxed",
"nitpicking",
"."
] | pyinvoke/invocations | python | https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/docs.py#L143-L169 | [
"def",
"sites",
"(",
"c",
")",
":",
"# TODO: This is super lolzy but we haven't actually tackled nontrivial",
"# in-Python task calling yet, so we do this to get a copy of 'our' context,",
"# which has been updated with the per-collection config data of the",
"# docs/www subcollections.",
"docs_... | bbf1b319bd1536817d5301ceb9eeb2f31830e5dc |
train | watch_docs | Watch both doc trees & rebuild them if files change.
This includes e.g. rebuilding the API docs if the source code changes;
rebuilding the WWW docs if the README changes; etc.
Reuses the configuration values ``packaging.package`` or ``tests.package``
(the former winning over the latter if both defined... | invocations/docs.py | def watch_docs(c):
"""
Watch both doc trees & rebuild them if files change.
This includes e.g. rebuilding the API docs if the source code changes;
rebuilding the WWW docs if the README changes; etc.
Reuses the configuration values ``packaging.package`` or ``tests.package``
(the former winning ... | def watch_docs(c):
"""
Watch both doc trees & rebuild them if files change.
This includes e.g. rebuilding the API docs if the source code changes;
rebuilding the WWW docs if the README changes; etc.
Reuses the configuration values ``packaging.package`` or ``tests.package``
(the former winning ... | [
"Watch",
"both",
"doc",
"trees",
"&",
"rebuild",
"them",
"if",
"files",
"change",
"."
] | pyinvoke/invocations | python | https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/docs.py#L173-L215 | [
"def",
"watch_docs",
"(",
"c",
")",
":",
"# TODO: break back down into generic single-site version, then create split",
"# tasks as with docs/www above. Probably wants invoke#63.",
"# NOTE: 'www'/'docs' refer to the module level sub-collections. meh.",
"# Readme & WWW triggers WWW",
"www_c",
"... | bbf1b319bd1536817d5301ceb9eeb2f31830e5dc |
train | shuffle_matrix | Random permutation of rows and columns of a matrix
Parameters
----------
X : array
(k, k), array to be permutated.
ids : array
range (k, ).
Returns
-------
X : array
(k, k) with rows and columns randomly shuffled.
Examples
--------
>>> import ... | giddy/util.py | def shuffle_matrix(X, ids):
"""
Random permutation of rows and columns of a matrix
Parameters
----------
X : array
(k, k), array to be permutated.
ids : array
range (k, ).
Returns
-------
X : array
(k, k) with rows and columns randomly shuffled.
... | def shuffle_matrix(X, ids):
"""
Random permutation of rows and columns of a matrix
Parameters
----------
X : array
(k, k), array to be permutated.
ids : array
range (k, ).
Returns
-------
X : array
(k, k) with rows and columns randomly shuffled.
... | [
"Random",
"permutation",
"of",
"rows",
"and",
"columns",
"of",
"a",
"matrix"
] | pysal/giddy | python | https://github.com/pysal/giddy/blob/13fae6c18933614be78e91a6b5060693bea33a04/giddy/util.py#L9-L40 | [
"def",
"shuffle_matrix",
"(",
"X",
",",
"ids",
")",
":",
"np",
".",
"random",
".",
"shuffle",
"(",
"ids",
")",
"return",
"X",
"[",
"ids",
",",
":",
"]",
"[",
":",
",",
"ids",
"]"
] | 13fae6c18933614be78e91a6b5060693bea33a04 |
train | get_lower | Flattens the lower part of an n x n matrix into an n*(n-1)/2 x 1 vector.
Parameters
----------
matrix : array
(n, n) numpy array, a distance matrix.
Returns
-------
lowvec : array
numpy array, the lower half of the distance matrix flattened into
a ve... | giddy/util.py | def get_lower(matrix):
"""
Flattens the lower part of an n x n matrix into an n*(n-1)/2 x 1 vector.
Parameters
----------
matrix : array
(n, n) numpy array, a distance matrix.
Returns
-------
lowvec : array
numpy array, the lower half of the distance matri... | def get_lower(matrix):
"""
Flattens the lower part of an n x n matrix into an n*(n-1)/2 x 1 vector.
Parameters
----------
matrix : array
(n, n) numpy array, a distance matrix.
Returns
-------
lowvec : array
numpy array, the lower half of the distance matri... | [
"Flattens",
"the",
"lower",
"part",
"of",
"an",
"n",
"x",
"n",
"matrix",
"into",
"an",
"n",
"*",
"(",
"n",
"-",
"1",
")",
"/",
"2",
"x",
"1",
"vector",
"."
] | pysal/giddy | python | https://github.com/pysal/giddy/blob/13fae6c18933614be78e91a6b5060693bea33a04/giddy/util.py#L43-L81 | [
"def",
"get_lower",
"(",
"matrix",
")",
":",
"n",
"=",
"matrix",
".",
"shape",
"[",
"0",
"]",
"lowerlist",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"n",
")",
":",
"for",
"j",
"in",
"range",
"(",
"n",
")",
":",
"if",
"i",
">",
"j",
":"... | 13fae6c18933614be78e91a6b5060693bea33a04 |
train | blacken | r"""
Run black on the current source tree (all ``.py`` files).
.. warning::
``black`` only runs on Python 3.6 or above. (However, it can be
executed against Python 2 compatible code.)
:param int line_length:
Line length argument. Default: ``79``.
:param list folders:
Li... | invocations/checks.py | def blacken(
c, line_length=79, folders=None, check=False, diff=False, find_opts=None
):
r"""
Run black on the current source tree (all ``.py`` files).
.. warning::
``black`` only runs on Python 3.6 or above. (However, it can be
executed against Python 2 compatible code.)
:param in... | def blacken(
c, line_length=79, folders=None, check=False, diff=False, find_opts=None
):
r"""
Run black on the current source tree (all ``.py`` files).
.. warning::
``black`` only runs on Python 3.6 or above. (However, it can be
executed against Python 2 compatible code.)
:param in... | [
"r",
"Run",
"black",
"on",
"the",
"current",
"source",
"tree",
"(",
"all",
".",
"py",
"files",
")",
"."
] | pyinvoke/invocations | python | https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/checks.py#L13-L65 | [
"def",
"blacken",
"(",
"c",
",",
"line_length",
"=",
"79",
",",
"folders",
"=",
"None",
",",
"check",
"=",
"False",
",",
"diff",
"=",
"False",
",",
"find_opts",
"=",
"None",
")",
":",
"config",
"=",
"c",
".",
"config",
".",
"get",
"(",
"\"blacken\"... | bbf1b319bd1536817d5301ceb9eeb2f31830e5dc |
train | normalize_response_value | Normalize the response value into a 3-tuple (rv, status, headers)
:type rv: tuple|*
:returns: tuple(rv, status, headers)
:rtype: tuple(Response|JsonResponse|*, int|None, dict|None) | flask_jsontools/response.py | def normalize_response_value(rv):
""" Normalize the response value into a 3-tuple (rv, status, headers)
:type rv: tuple|*
:returns: tuple(rv, status, headers)
:rtype: tuple(Response|JsonResponse|*, int|None, dict|None)
"""
status = headers = None
if isinstance(rv, tuple):
... | def normalize_response_value(rv):
""" Normalize the response value into a 3-tuple (rv, status, headers)
:type rv: tuple|*
:returns: tuple(rv, status, headers)
:rtype: tuple(Response|JsonResponse|*, int|None, dict|None)
"""
status = headers = None
if isinstance(rv, tuple):
... | [
"Normalize",
"the",
"response",
"value",
"into",
"a",
"3",
"-",
"tuple",
"(",
"rv",
"status",
"headers",
")",
":",
"type",
"rv",
":",
"tuple|",
"*",
":",
"returns",
":",
"tuple",
"(",
"rv",
"status",
"headers",
")",
":",
"rtype",
":",
"tuple",
"(",
... | kolypto/py-flask-jsontools | python | https://github.com/kolypto/py-flask-jsontools/blob/1abee2d40e6db262e43f0c534e90faaa9b26246a/flask_jsontools/response.py#L51-L60 | [
"def",
"normalize_response_value",
"(",
"rv",
")",
":",
"status",
"=",
"headers",
"=",
"None",
"if",
"isinstance",
"(",
"rv",
",",
"tuple",
")",
":",
"rv",
",",
"status",
",",
"headers",
"=",
"rv",
"+",
"(",
"None",
",",
")",
"*",
"(",
"3",
"-",
... | 1abee2d40e6db262e43f0c534e90faaa9b26246a |
train | make_json_response | Make JsonResponse
:param rv: Response: the object to encode, or tuple (response, status, headers)
:type rv: tuple|*
:rtype: JsonResponse | flask_jsontools/response.py | def make_json_response(rv):
""" Make JsonResponse
:param rv: Response: the object to encode, or tuple (response, status, headers)
:type rv: tuple|*
:rtype: JsonResponse
"""
# Tuple of (response, status, headers)
rv, status, headers = normalize_response_value(rv)
# JsonResponse
if is... | def make_json_response(rv):
""" Make JsonResponse
:param rv: Response: the object to encode, or tuple (response, status, headers)
:type rv: tuple|*
:rtype: JsonResponse
"""
# Tuple of (response, status, headers)
rv, status, headers = normalize_response_value(rv)
# JsonResponse
if is... | [
"Make",
"JsonResponse",
":",
"param",
"rv",
":",
"Response",
":",
"the",
"object",
"to",
"encode",
"or",
"tuple",
"(",
"response",
"status",
"headers",
")",
":",
"type",
"rv",
":",
"tuple|",
"*",
":",
"rtype",
":",
"JsonResponse"
] | kolypto/py-flask-jsontools | python | https://github.com/kolypto/py-flask-jsontools/blob/1abee2d40e6db262e43f0c534e90faaa9b26246a/flask_jsontools/response.py#L63-L77 | [
"def",
"make_json_response",
"(",
"rv",
")",
":",
"# Tuple of (response, status, headers)",
"rv",
",",
"status",
",",
"headers",
"=",
"normalize_response_value",
"(",
"rv",
")",
"# JsonResponse",
"if",
"isinstance",
"(",
"rv",
",",
"JsonResponse",
")",
":",
"retur... | 1abee2d40e6db262e43f0c534e90faaa9b26246a |
train | markov_mobility | Markov-based mobility index.
Parameters
----------
p : array
(k, k), Markov transition probability matrix.
measure : string
If measure= "P",
:math:`M_{P} = \\frac{m-\sum_{i=1}^m P_{ii}}{m-1}`;
if measure = "D",
:math:`M_{D} = 1... | giddy/mobility.py | def markov_mobility(p, measure="P", ini=None):
"""
Markov-based mobility index.
Parameters
----------
p : array
(k, k), Markov transition probability matrix.
measure : string
If measure= "P",
:math:`M_{P} = \\frac{m-\sum_{i=1}^m P_{ii}}{m-1}`;
... | def markov_mobility(p, measure="P", ini=None):
"""
Markov-based mobility index.
Parameters
----------
p : array
(k, k), Markov transition probability matrix.
measure : string
If measure= "P",
:math:`M_{P} = \\frac{m-\sum_{i=1}^m P_{ii}}{m-1}`;
... | [
"Markov",
"-",
"based",
"mobility",
"index",
"."
] | pysal/giddy | python | https://github.com/pysal/giddy/blob/13fae6c18933614be78e91a6b5060693bea33a04/giddy/mobility.py#L13-L131 | [
"def",
"markov_mobility",
"(",
"p",
",",
"measure",
"=",
"\"P\"",
",",
"ini",
"=",
"None",
")",
":",
"p",
"=",
"np",
".",
"array",
"(",
"p",
")",
"k",
"=",
"p",
".",
"shape",
"[",
"1",
"]",
"if",
"measure",
"==",
"\"P\"",
":",
"t",
"=",
"np",... | 13fae6c18933614be78e91a6b5060693bea33a04 |
train | chi2 | chi-squared test of difference between two transition matrices.
Parameters
----------
T1 : array
(k, k), matrix of transitions (counts).
T2 : array
(k, k), matrix of transitions (counts) to use to form the
probabilities under the null.
Returns
-------
... | giddy/markov.py | def chi2(T1, T2):
"""
chi-squared test of difference between two transition matrices.
Parameters
----------
T1 : array
(k, k), matrix of transitions (counts).
T2 : array
(k, k), matrix of transitions (counts) to use to form the
probabilities under the n... | def chi2(T1, T2):
"""
chi-squared test of difference between two transition matrices.
Parameters
----------
T1 : array
(k, k), matrix of transitions (counts).
T2 : array
(k, k), matrix of transitions (counts) to use to form the
probabilities under the n... | [
"chi",
"-",
"squared",
"test",
"of",
"difference",
"between",
"two",
"transition",
"matrices",
"."
] | pysal/giddy | python | https://github.com/pysal/giddy/blob/13fae6c18933614be78e91a6b5060693bea33a04/giddy/markov.py#L858-L932 | [
"def",
"chi2",
"(",
"T1",
",",
"T2",
")",
":",
"rs2",
"=",
"T2",
".",
"sum",
"(",
"axis",
"=",
"1",
")",
"rs1",
"=",
"T1",
".",
"sum",
"(",
"axis",
"=",
"1",
")",
"rs2nz",
"=",
"rs2",
">",
"0",
"rs1nz",
"=",
"rs1",
">",
"0",
"dof1",
"=",
... | 13fae6c18933614be78e91a6b5060693bea33a04 |
train | kullback | Kullback information based test of Markov Homogeneity.
Parameters
----------
F : array
(s, r, r), values are transitions (not probabilities) for
s strata, r initial states, r terminal states.
Returns
-------
Results : dictionary
(key - value)
Condit... | giddy/markov.py | def kullback(F):
"""
Kullback information based test of Markov Homogeneity.
Parameters
----------
F : array
(s, r, r), values are transitions (not probabilities) for
s strata, r initial states, r terminal states.
Returns
-------
Results : dictionary
(key -... | def kullback(F):
"""
Kullback information based test of Markov Homogeneity.
Parameters
----------
F : array
(s, r, r), values are transitions (not probabilities) for
s strata, r initial states, r terminal states.
Returns
-------
Results : dictionary
(key -... | [
"Kullback",
"information",
"based",
"test",
"of",
"Markov",
"Homogeneity",
"."
] | pysal/giddy | python | https://github.com/pysal/giddy/blob/13fae6c18933614be78e91a6b5060693bea33a04/giddy/markov.py#L1336-L1425 | [
"def",
"kullback",
"(",
"F",
")",
":",
"F1",
"=",
"F",
"==",
"0",
"F1",
"=",
"F",
"+",
"F1",
"FLF",
"=",
"F",
"*",
"np",
".",
"log",
"(",
"F1",
")",
"T1",
"=",
"2",
"*",
"FLF",
".",
"sum",
"(",
")",
"FdJK",
"=",
"F",
".",
"sum",
"(",
... | 13fae6c18933614be78e91a6b5060693bea33a04 |
train | prais | Prais conditional mobility measure.
Parameters
----------
pmat : matrix
(k, k), Markov probability transition matrix.
Returns
-------
pr : matrix
(1, k), conditional mobility measures for each of the k classes.
Notes
-----
Prais' conditional mobility measur... | giddy/markov.py | def prais(pmat):
"""
Prais conditional mobility measure.
Parameters
----------
pmat : matrix
(k, k), Markov probability transition matrix.
Returns
-------
pr : matrix
(1, k), conditional mobility measures for each of the k classes.
Notes
-----
Prais... | def prais(pmat):
"""
Prais conditional mobility measure.
Parameters
----------
pmat : matrix
(k, k), Markov probability transition matrix.
Returns
-------
pr : matrix
(1, k), conditional mobility measures for each of the k classes.
Notes
-----
Prais... | [
"Prais",
"conditional",
"mobility",
"measure",
"."
] | pysal/giddy | python | https://github.com/pysal/giddy/blob/13fae6c18933614be78e91a6b5060693bea33a04/giddy/markov.py#L1428-L1477 | [
"def",
"prais",
"(",
"pmat",
")",
":",
"pmat",
"=",
"np",
".",
"array",
"(",
"pmat",
")",
"pr",
"=",
"1",
"-",
"np",
".",
"diag",
"(",
"pmat",
")",
"return",
"pr"
] | 13fae6c18933614be78e91a6b5060693bea33a04 |
train | homogeneity | Test for homogeneity of Markov transition probabilities across regimes.
Parameters
----------
transition_matrices : list
of transition matrices for regimes, all matrices must
have same size (r, c). r is the number of rows in the
... | giddy/markov.py | def homogeneity(transition_matrices, regime_names=[], class_names=[],
title="Markov Homogeneity Test"):
"""
Test for homogeneity of Markov transition probabilities across regimes.
Parameters
----------
transition_matrices : list
of transition matrices for r... | def homogeneity(transition_matrices, regime_names=[], class_names=[],
title="Markov Homogeneity Test"):
"""
Test for homogeneity of Markov transition probabilities across regimes.
Parameters
----------
transition_matrices : list
of transition matrices for r... | [
"Test",
"for",
"homogeneity",
"of",
"Markov",
"transition",
"probabilities",
"across",
"regimes",
"."
] | pysal/giddy | python | https://github.com/pysal/giddy/blob/13fae6c18933614be78e91a6b5060693bea33a04/giddy/markov.py#L1480-L1506 | [
"def",
"homogeneity",
"(",
"transition_matrices",
",",
"regime_names",
"=",
"[",
"]",
",",
"class_names",
"=",
"[",
"]",
",",
"title",
"=",
"\"Markov Homogeneity Test\"",
")",
":",
"return",
"Homogeneity_Results",
"(",
"transition_matrices",
",",
"regime_names",
"... | 13fae6c18933614be78e91a6b5060693bea33a04 |
train | sojourn_time | Calculate sojourn time based on a given transition probability matrix.
Parameters
----------
p : array
(k, k), a Markov transition probability matrix.
Returns
-------
: array
(k, ), sojourn times. Each element is the expected time a Markov
... | giddy/markov.py | def sojourn_time(p):
"""
Calculate sojourn time based on a given transition probability matrix.
Parameters
----------
p : array
(k, k), a Markov transition probability matrix.
Returns
-------
: array
(k, ), sojourn times. Each element is th... | def sojourn_time(p):
"""
Calculate sojourn time based on a given transition probability matrix.
Parameters
----------
p : array
(k, k), a Markov transition probability matrix.
Returns
-------
: array
(k, ), sojourn times. Each element is th... | [
"Calculate",
"sojourn",
"time",
"based",
"on",
"a",
"given",
"transition",
"probability",
"matrix",
"."
] | pysal/giddy | python | https://github.com/pysal/giddy/blob/13fae6c18933614be78e91a6b5060693bea33a04/giddy/markov.py#L1830-L1864 | [
"def",
"sojourn_time",
"(",
"p",
")",
":",
"p",
"=",
"np",
".",
"asarray",
"(",
"p",
")",
"pii",
"=",
"p",
".",
"diagonal",
"(",
")",
"if",
"not",
"(",
"1",
"-",
"pii",
")",
".",
"all",
"(",
")",
":",
"print",
"(",
"\"Sojourn times are infinite f... | 13fae6c18933614be78e91a6b5060693bea33a04 |
train | Spatial_Markov._calc | Helper to estimate spatial lag conditioned Markov transition
probability matrices based on maximum likelihood techniques. | giddy/markov.py | def _calc(self, y, w):
'''Helper to estimate spatial lag conditioned Markov transition
probability matrices based on maximum likelihood techniques.
'''
if self.discrete:
self.lclass_ids = weights.lag_categorical(w, self.class_ids,
... | def _calc(self, y, w):
'''Helper to estimate spatial lag conditioned Markov transition
probability matrices based on maximum likelihood techniques.
'''
if self.discrete:
self.lclass_ids = weights.lag_categorical(w, self.class_ids,
... | [
"Helper",
"to",
"estimate",
"spatial",
"lag",
"conditioned",
"Markov",
"transition",
"probability",
"matrices",
"based",
"on",
"maximum",
"likelihood",
"techniques",
"."
] | pysal/giddy | python | https://github.com/pysal/giddy/blob/13fae6c18933614be78e91a6b5060693bea33a04/giddy/markov.py#L731-L759 | [
"def",
"_calc",
"(",
"self",
",",
"y",
",",
"w",
")",
":",
"if",
"self",
".",
"discrete",
":",
"self",
".",
"lclass_ids",
"=",
"weights",
".",
"lag_categorical",
"(",
"w",
",",
"self",
".",
"class_ids",
",",
"ties",
"=",
"\"tryself\"",
")",
"else",
... | 13fae6c18933614be78e91a6b5060693bea33a04 |
train | Spatial_Markov.summary | A summary method to call the Markov homogeneity test to test for
temporally lagged spatial dependence.
To learn more about the properties of the tests, refer to
:cite:`Rey2016a` and :cite:`Kang2018`. | giddy/markov.py | def summary(self, file_name=None):
"""
A summary method to call the Markov homogeneity test to test for
temporally lagged spatial dependence.
To learn more about the properties of the tests, refer to
:cite:`Rey2016a` and :cite:`Kang2018`.
"""
class_names = ["C%d... | def summary(self, file_name=None):
"""
A summary method to call the Markov homogeneity test to test for
temporally lagged spatial dependence.
To learn more about the properties of the tests, refer to
:cite:`Rey2016a` and :cite:`Kang2018`.
"""
class_names = ["C%d... | [
"A",
"summary",
"method",
"to",
"call",
"the",
"Markov",
"homogeneity",
"test",
"to",
"test",
"for",
"temporally",
"lagged",
"spatial",
"dependence",
"."
] | pysal/giddy | python | https://github.com/pysal/giddy/blob/13fae6c18933614be78e91a6b5060693bea33a04/giddy/markov.py#L811-L830 | [
"def",
"summary",
"(",
"self",
",",
"file_name",
"=",
"None",
")",
":",
"class_names",
"=",
"[",
"\"C%d\"",
"%",
"i",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"k",
")",
"]",
"regime_names",
"=",
"[",
"\"LAG%d\"",
"%",
"i",
"for",
"i",
"in",
"... | 13fae6c18933614be78e91a6b5060693bea33a04 |
train | Spatial_Markov._maybe_classify | Helper method for classifying continuous data. | giddy/markov.py | def _maybe_classify(self, y, k, cutoffs):
'''Helper method for classifying continuous data.
'''
rows, cols = y.shape
if cutoffs is None:
if self.fixed:
mcyb = mc.Quantiles(y.flatten(), k=k)
yb = mcyb.yb.reshape(y.shape)
cutoff... | def _maybe_classify(self, y, k, cutoffs):
'''Helper method for classifying continuous data.
'''
rows, cols = y.shape
if cutoffs is None:
if self.fixed:
mcyb = mc.Quantiles(y.flatten(), k=k)
yb = mcyb.yb.reshape(y.shape)
cutoff... | [
"Helper",
"method",
"for",
"classifying",
"continuous",
"data",
"."
] | pysal/giddy | python | https://github.com/pysal/giddy/blob/13fae6c18933614be78e91a6b5060693bea33a04/giddy/markov.py#L832-L855 | [
"def",
"_maybe_classify",
"(",
"self",
",",
"y",
",",
"k",
",",
"cutoffs",
")",
":",
"rows",
",",
"cols",
"=",
"y",
".",
"shape",
"if",
"cutoffs",
"is",
"None",
":",
"if",
"self",
".",
"fixed",
":",
"mcyb",
"=",
"mc",
".",
"Quantiles",
"(",
"y",
... | 13fae6c18933614be78e91a6b5060693bea33a04 |
train | LISA_Markov.spillover | Detect spillover locations for diffusion in LISA Markov.
Parameters
----------
quadrant : int
which quadrant in the scatterplot should form the core
of a cluster.
neighbors_on : binary
If false, then only the 1st o... | giddy/markov.py | def spillover(self, quadrant=1, neighbors_on=False):
"""
Detect spillover locations for diffusion in LISA Markov.
Parameters
----------
quadrant : int
which quadrant in the scatterplot should form the core
of a cluster.
n... | def spillover(self, quadrant=1, neighbors_on=False):
"""
Detect spillover locations for diffusion in LISA Markov.
Parameters
----------
quadrant : int
which quadrant in the scatterplot should form the core
of a cluster.
n... | [
"Detect",
"spillover",
"locations",
"for",
"diffusion",
"in",
"LISA",
"Markov",
"."
] | pysal/giddy | python | https://github.com/pysal/giddy/blob/13fae6c18933614be78e91a6b5060693bea33a04/giddy/markov.py#L1212-L1333 | [
"def",
"spillover",
"(",
"self",
",",
"quadrant",
"=",
"1",
",",
"neighbors_on",
"=",
"False",
")",
":",
"n",
",",
"k",
"=",
"self",
".",
"q",
".",
"shape",
"if",
"self",
".",
"permutations",
":",
"spill_over",
"=",
"np",
".",
"zeros",
"(",
"(",
... | 13fae6c18933614be78e91a6b5060693bea33a04 |
train | get_entity_propnames | Get entity property names
:param entity: Entity
:type entity: sqlalchemy.ext.declarative.api.DeclarativeMeta
:returns: Set of entity property names
:rtype: set | flask_jsontools/formatting.py | def get_entity_propnames(entity):
""" Get entity property names
:param entity: Entity
:type entity: sqlalchemy.ext.declarative.api.DeclarativeMeta
:returns: Set of entity property names
:rtype: set
"""
ins = entity if isinstance(entity, InstanceState) else inspect(entity)
... | def get_entity_propnames(entity):
""" Get entity property names
:param entity: Entity
:type entity: sqlalchemy.ext.declarative.api.DeclarativeMeta
:returns: Set of entity property names
:rtype: set
"""
ins = entity if isinstance(entity, InstanceState) else inspect(entity)
... | [
"Get",
"entity",
"property",
"names"
] | kolypto/py-flask-jsontools | python | https://github.com/kolypto/py-flask-jsontools/blob/1abee2d40e6db262e43f0c534e90faaa9b26246a/flask_jsontools/formatting.py#L31-L43 | [
"def",
"get_entity_propnames",
"(",
"entity",
")",
":",
"ins",
"=",
"entity",
"if",
"isinstance",
"(",
"entity",
",",
"InstanceState",
")",
"else",
"inspect",
"(",
"entity",
")",
"return",
"set",
"(",
"ins",
".",
"mapper",
".",
"column_attrs",
".",
"keys",... | 1abee2d40e6db262e43f0c534e90faaa9b26246a |
train | get_entity_loaded_propnames | Get entity property names that are loaded (e.g. won't produce new queries)
:param entity: Entity
:type entity: sqlalchemy.ext.declarative.api.DeclarativeMeta
:returns: Set of entity property names
:rtype: set | flask_jsontools/formatting.py | def get_entity_loaded_propnames(entity):
""" Get entity property names that are loaded (e.g. won't produce new queries)
:param entity: Entity
:type entity: sqlalchemy.ext.declarative.api.DeclarativeMeta
:returns: Set of entity property names
:rtype: set
"""
ins = inspect(ent... | def get_entity_loaded_propnames(entity):
""" Get entity property names that are loaded (e.g. won't produce new queries)
:param entity: Entity
:type entity: sqlalchemy.ext.declarative.api.DeclarativeMeta
:returns: Set of entity property names
:rtype: set
"""
ins = inspect(ent... | [
"Get",
"entity",
"property",
"names",
"that",
"are",
"loaded",
"(",
"e",
".",
"g",
".",
"won",
"t",
"produce",
"new",
"queries",
")"
] | kolypto/py-flask-jsontools | python | https://github.com/kolypto/py-flask-jsontools/blob/1abee2d40e6db262e43f0c534e90faaa9b26246a/flask_jsontools/formatting.py#L46-L68 | [
"def",
"get_entity_loaded_propnames",
"(",
"entity",
")",
":",
"ins",
"=",
"inspect",
"(",
"entity",
")",
"keynames",
"=",
"get_entity_propnames",
"(",
"ins",
")",
"# If the entity is not transient -- exclude unloaded keys",
"# Transient entities won't load these anyway, so it'... | 1abee2d40e6db262e43f0c534e90faaa9b26246a |
train | next_minor | Return a Version whose minor number is one greater than self's.
.. note::
The new Version will always have a zeroed-out bugfix/tertiary version
number, because the "next minor release" of e.g. 1.2.1 is 1.3.0, not
1.3.1. | invocations/packaging/semantic_version_monkey.py | def next_minor(self):
"""
Return a Version whose minor number is one greater than self's.
.. note::
The new Version will always have a zeroed-out bugfix/tertiary version
number, because the "next minor release" of e.g. 1.2.1 is 1.3.0, not
1.3.1.
"""
clone = self.clone()
... | def next_minor(self):
"""
Return a Version whose minor number is one greater than self's.
.. note::
The new Version will always have a zeroed-out bugfix/tertiary version
number, because the "next minor release" of e.g. 1.2.1 is 1.3.0, not
1.3.1.
"""
clone = self.clone()
... | [
"Return",
"a",
"Version",
"whose",
"minor",
"number",
"is",
"one",
"greater",
"than",
"self",
"s",
"."
] | pyinvoke/invocations | python | https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/packaging/semantic_version_monkey.py#L26-L38 | [
"def",
"next_minor",
"(",
"self",
")",
":",
"clone",
"=",
"self",
".",
"clone",
"(",
")",
"clone",
".",
"minor",
"+=",
"1",
"clone",
".",
"patch",
"=",
"0",
"return",
"clone"
] | bbf1b319bd1536817d5301ceb9eeb2f31830e5dc |
train | _check_encoding | Check that ``encoding`` is a valid Python encoding
:param name: name under which the encoding is known to the user, e.g. 'default encoding'
:param encoding_to_check: name of the encoding to check, e.g. 'utf-8'
:param source: source where the encoding has been set, e.g. option name
:raise pygount.common.... | pygount/command.py | def _check_encoding(name, encoding_to_check, alternative_encoding, source=None):
"""
Check that ``encoding`` is a valid Python encoding
:param name: name under which the encoding is known to the user, e.g. 'default encoding'
:param encoding_to_check: name of the encoding to check, e.g. 'utf-8'
:para... | def _check_encoding(name, encoding_to_check, alternative_encoding, source=None):
"""
Check that ``encoding`` is a valid Python encoding
:param name: name under which the encoding is known to the user, e.g. 'default encoding'
:param encoding_to_check: name of the encoding to check, e.g. 'utf-8'
:para... | [
"Check",
"that",
"encoding",
"is",
"a",
"valid",
"Python",
"encoding",
":",
"param",
"name",
":",
"name",
"under",
"which",
"the",
"encoding",
"is",
"known",
"to",
"the",
"user",
"e",
".",
"g",
".",
"default",
"encoding",
":",
"param",
"encoding_to_check",... | roskakori/pygount | python | https://github.com/roskakori/pygount/blob/c2c150a534ba5be498eb39cb78fc6a531d62f145/pygount/command.py#L58-L75 | [
"def",
"_check_encoding",
"(",
"name",
",",
"encoding_to_check",
",",
"alternative_encoding",
",",
"source",
"=",
"None",
")",
":",
"assert",
"name",
"is",
"not",
"None",
"if",
"encoding_to_check",
"not",
"in",
"(",
"alternative_encoding",
",",
"'chardet'",
",",... | c2c150a534ba5be498eb39cb78fc6a531d62f145 |
train | lines | Generator function to yield lines (delimited with ``'\n'``) stored in
``text``. This is useful when a regular expression should only match on a
per line basis in a memory efficient way. | pygount/common.py | def lines(text):
"""
Generator function to yield lines (delimited with ``'\n'``) stored in
``text``. This is useful when a regular expression should only match on a
per line basis in a memory efficient way.
"""
assert text is not None
assert '\r' not in text
previous_newline_index = 0
... | def lines(text):
"""
Generator function to yield lines (delimited with ``'\n'``) stored in
``text``. This is useful when a regular expression should only match on a
per line basis in a memory efficient way.
"""
assert text is not None
assert '\r' not in text
previous_newline_index = 0
... | [
"Generator",
"function",
"to",
"yield",
"lines",
"(",
"delimited",
"with",
"\\",
"n",
")",
"stored",
"in",
"text",
".",
"This",
"is",
"useful",
"when",
"a",
"regular",
"expression",
"should",
"only",
"match",
"on",
"a",
"per",
"line",
"basis",
"in",
"a",... | roskakori/pygount | python | https://github.com/roskakori/pygount/blob/c2c150a534ba5be498eb39cb78fc6a531d62f145/pygount/common.py#L101-L117 | [
"def",
"lines",
"(",
"text",
")",
":",
"assert",
"text",
"is",
"not",
"None",
"assert",
"'\\r'",
"not",
"in",
"text",
"previous_newline_index",
"=",
"0",
"newline_index",
"=",
"text",
".",
"find",
"(",
"'\\n'",
")",
"while",
"newline_index",
"!=",
"-",
"... | c2c150a534ba5be498eb39cb78fc6a531d62f145 |
train | matching_number_line_and_regex | The first line and its number (starting with 0) in the source code that
indicated that the source code is generated.
:param source_lines: lines of text to scan
:param generated_regexes: regular expressions a line must match to indicate
the source code is generated.
:param max_line_count: maximum... | pygount/analysis.py | def matching_number_line_and_regex(source_lines, generated_regexes, max_line_count=15):
"""
The first line and its number (starting with 0) in the source code that
indicated that the source code is generated.
:param source_lines: lines of text to scan
:param generated_regexes: regular expressions a ... | def matching_number_line_and_regex(source_lines, generated_regexes, max_line_count=15):
"""
The first line and its number (starting with 0) in the source code that
indicated that the source code is generated.
:param source_lines: lines of text to scan
:param generated_regexes: regular expressions a ... | [
"The",
"first",
"line",
"and",
"its",
"number",
"(",
"starting",
"with",
"0",
")",
"in",
"the",
"source",
"code",
"that",
"indicated",
"that",
"the",
"source",
"code",
"is",
"generated",
".",
":",
"param",
"source_lines",
":",
"lines",
"of",
"text",
"to"... | roskakori/pygount | python | https://github.com/roskakori/pygount/blob/c2c150a534ba5be498eb39cb78fc6a531d62f145/pygount/analysis.py#L245-L266 | [
"def",
"matching_number_line_and_regex",
"(",
"source_lines",
",",
"generated_regexes",
",",
"max_line_count",
"=",
"15",
")",
":",
"initial_numbers_and_lines",
"=",
"enumerate",
"(",
"itertools",
".",
"islice",
"(",
"source_lines",
",",
"max_line_count",
")",
")",
... | c2c150a534ba5be498eb39cb78fc6a531d62f145 |
train | _pythonized_comments | Similar to tokens but converts strings after a colon (:) to comments. | pygount/analysis.py | def _pythonized_comments(tokens):
"""
Similar to tokens but converts strings after a colon (:) to comments.
"""
is_after_colon = True
for token_type, token_text in tokens:
if is_after_colon and (token_type in pygments.token.String):
token_type = pygments.token.Comment
eli... | def _pythonized_comments(tokens):
"""
Similar to tokens but converts strings after a colon (:) to comments.
"""
is_after_colon = True
for token_type, token_text in tokens:
if is_after_colon and (token_type in pygments.token.String):
token_type = pygments.token.Comment
eli... | [
"Similar",
"to",
"tokens",
"but",
"converts",
"strings",
"after",
"a",
"colon",
"(",
":",
")",
"to",
"comments",
"."
] | roskakori/pygount | python | https://github.com/roskakori/pygount/blob/c2c150a534ba5be498eb39cb78fc6a531d62f145/pygount/analysis.py#L299-L313 | [
"def",
"_pythonized_comments",
"(",
"tokens",
")",
":",
"is_after_colon",
"=",
"True",
"for",
"token_type",
",",
"token_text",
"in",
"tokens",
":",
"if",
"is_after_colon",
"and",
"(",
"token_type",
"in",
"pygments",
".",
"token",
".",
"String",
")",
":",
"to... | c2c150a534ba5be498eb39cb78fc6a531d62f145 |
train | encoding_for | The encoding used by the text file stored in ``source_path``.
The algorithm used is:
* If ``encoding`` is ``'automatic``, attempt the following:
1. Check BOM for UTF-8, UTF-16 and UTF-32.
2. Look for XML prolog or magic heading like ``# -*- coding: cp1252 -*-``
3. Read the file using UTF-8.
... | pygount/analysis.py | def encoding_for(source_path, encoding='automatic', fallback_encoding=None):
"""
The encoding used by the text file stored in ``source_path``.
The algorithm used is:
* If ``encoding`` is ``'automatic``, attempt the following:
1. Check BOM for UTF-8, UTF-16 and UTF-32.
2. Look for XML prolo... | def encoding_for(source_path, encoding='automatic', fallback_encoding=None):
"""
The encoding used by the text file stored in ``source_path``.
The algorithm used is:
* If ``encoding`` is ``'automatic``, attempt the following:
1. Check BOM for UTF-8, UTF-16 and UTF-32.
2. Look for XML prolo... | [
"The",
"encoding",
"used",
"by",
"the",
"text",
"file",
"stored",
"in",
"source_path",
"."
] | roskakori/pygount | python | https://github.com/roskakori/pygount/blob/c2c150a534ba5be498eb39cb78fc6a531d62f145/pygount/analysis.py#L340-L418 | [
"def",
"encoding_for",
"(",
"source_path",
",",
"encoding",
"=",
"'automatic'",
",",
"fallback_encoding",
"=",
"None",
")",
":",
"assert",
"encoding",
"is",
"not",
"None",
"if",
"encoding",
"==",
"'automatic'",
":",
"with",
"open",
"(",
"source_path",
",",
"... | c2c150a534ba5be498eb39cb78fc6a531d62f145 |
train | has_lexer | Initial quick check if there is a lexer for ``source_path``. This removes
the need for calling :py:func:`pygments.lexers.guess_lexer_for_filename()`
which fully reads the source file. | pygount/analysis.py | def has_lexer(source_path):
"""
Initial quick check if there is a lexer for ``source_path``. This removes
the need for calling :py:func:`pygments.lexers.guess_lexer_for_filename()`
which fully reads the source file.
"""
result = bool(pygments.lexers.find_lexer_class_for_filename(source_path))
... | def has_lexer(source_path):
"""
Initial quick check if there is a lexer for ``source_path``. This removes
the need for calling :py:func:`pygments.lexers.guess_lexer_for_filename()`
which fully reads the source file.
"""
result = bool(pygments.lexers.find_lexer_class_for_filename(source_path))
... | [
"Initial",
"quick",
"check",
"if",
"there",
"is",
"a",
"lexer",
"for",
"source_path",
".",
"This",
"removes",
"the",
"need",
"for",
"calling",
":",
"py",
":",
"func",
":",
"pygments",
".",
"lexers",
".",
"guess_lexer_for_filename",
"()",
"which",
"fully",
... | roskakori/pygount | python | https://github.com/roskakori/pygount/blob/c2c150a534ba5be498eb39cb78fc6a531d62f145/pygount/analysis.py#L459-L469 | [
"def",
"has_lexer",
"(",
"source_path",
")",
":",
"result",
"=",
"bool",
"(",
"pygments",
".",
"lexers",
".",
"find_lexer_class_for_filename",
"(",
"source_path",
")",
")",
"if",
"not",
"result",
":",
"suffix",
"=",
"os",
".",
"path",
".",
"splitext",
"(",... | c2c150a534ba5be498eb39cb78fc6a531d62f145 |
train | source_analysis | Analysis for line counts in source code stored in ``source_path``.
:param source_path:
:param group: name of a logical group the sourc code belongs to, e.g. a
package.
:param encoding: encoding according to :func:`encoding_for`
:param fallback_encoding: fallback encoding according to
:func:... | pygount/analysis.py | def source_analysis(
source_path, group, encoding='automatic', fallback_encoding='cp1252',
generated_regexes=pygount.common.regexes_from(DEFAULT_GENERATED_PATTERNS_TEXT),
duplicate_pool=None):
"""
Analysis for line counts in source code stored in ``source_path``.
:param source_path:... | def source_analysis(
source_path, group, encoding='automatic', fallback_encoding='cp1252',
generated_regexes=pygount.common.regexes_from(DEFAULT_GENERATED_PATTERNS_TEXT),
duplicate_pool=None):
"""
Analysis for line counts in source code stored in ``source_path``.
:param source_path:... | [
"Analysis",
"for",
"line",
"counts",
"in",
"source",
"code",
"stored",
"in",
"source_path",
"."
] | roskakori/pygount | python | https://github.com/roskakori/pygount/blob/c2c150a534ba5be498eb39cb78fc6a531d62f145/pygount/analysis.py#L484-L570 | [
"def",
"source_analysis",
"(",
"source_path",
",",
"group",
",",
"encoding",
"=",
"'automatic'",
",",
"fallback_encoding",
"=",
"'cp1252'",
",",
"generated_regexes",
"=",
"pygount",
".",
"common",
".",
"regexes_from",
"(",
"DEFAULT_GENERATED_PATTERNS_TEXT",
")",
","... | c2c150a534ba5be498eb39cb78fc6a531d62f145 |
train | polynomial | replace all masked values
calculate flatField from 2d-polynomal fit filling
all high gradient areas within averaged fit-image
returns flatField, average background level, fitted image, valid indices mask | DUMP/interpolationMethods.py | def polynomial(img, mask, inplace=False, replace_all=False,
max_dev=1e-5, max_iter=20, order=2):
'''
replace all masked values
calculate flatField from 2d-polynomal fit filling
all high gradient areas within averaged fit-image
returns flatField, average background level, fitte... | def polynomial(img, mask, inplace=False, replace_all=False,
max_dev=1e-5, max_iter=20, order=2):
'''
replace all masked values
calculate flatField from 2d-polynomal fit filling
all high gradient areas within averaged fit-image
returns flatField, average background level, fitte... | [
"replace",
"all",
"masked",
"values",
"calculate",
"flatField",
"from",
"2d",
"-",
"polynomal",
"fit",
"filling",
"all",
"high",
"gradient",
"areas",
"within",
"averaged",
"fit",
"-",
"image",
"returns",
"flatField",
"average",
"background",
"level",
"fitted",
"... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/DUMP/interpolationMethods.py#L55-L88 | [
"def",
"polynomial",
"(",
"img",
",",
"mask",
",",
"inplace",
"=",
"False",
",",
"replace_all",
"=",
"False",
",",
"max_dev",
"=",
"1e-5",
",",
"max_iter",
"=",
"20",
",",
"order",
"=",
"2",
")",
":",
"if",
"inplace",
":",
"out",
"=",
"img",
"else"... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | errorDist | TODO | imgProcessor/uncertainty/simulateUncertDependencyOnExpTime.py | def errorDist(scale, measExpTime, n_events_in_expTime,
event_duration, std,
points_per_time=100, n_repetitions=300):
'''
TODO
'''
ntimes = 10
s1 = measExpTime * scale * 10
# exp. time factor 1/16-->16:
p2 = np.logspace(-4, 4, 18, base=2)
t = np.lin... | def errorDist(scale, measExpTime, n_events_in_expTime,
event_duration, std,
points_per_time=100, n_repetitions=300):
'''
TODO
'''
ntimes = 10
s1 = measExpTime * scale * 10
# exp. time factor 1/16-->16:
p2 = np.logspace(-4, 4, 18, base=2)
t = np.lin... | [
"TODO"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/uncertainty/simulateUncertDependencyOnExpTime.py#L15-L47 | [
"def",
"errorDist",
"(",
"scale",
",",
"measExpTime",
",",
"n_events_in_expTime",
",",
"event_duration",
",",
"std",
",",
"points_per_time",
"=",
"100",
",",
"n_repetitions",
"=",
"300",
")",
":",
"ntimes",
"=",
"10",
"s1",
"=",
"measExpTime",
"*",
"scale",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | exampleSignals | std ... standard deviation of every signal
dur1...dur3 --> event duration per second
n1...n3 --> number of events per second | imgProcessor/uncertainty/simulateUncertDependencyOnExpTime.py | def exampleSignals(std=1, dur1=1, dur2=3, dur3=0.2,
n1=0.5, n2=0.5, n3=2):
'''
std ... standard deviation of every signal
dur1...dur3 --> event duration per second
n1...n3 --> number of events per second
'''
np.random.seed(123)
t = np.linspace(0, 10, 100)
... | def exampleSignals(std=1, dur1=1, dur2=3, dur3=0.2,
n1=0.5, n2=0.5, n3=2):
'''
std ... standard deviation of every signal
dur1...dur3 --> event duration per second
n1...n3 --> number of events per second
'''
np.random.seed(123)
t = np.linspace(0, 10, 100)
... | [
"std",
"...",
"standard",
"deviation",
"of",
"every",
"signal",
"dur1",
"...",
"dur3",
"--",
">",
"event",
"duration",
"per",
"second",
"n1",
"...",
"n3",
"--",
">",
"number",
"of",
"events",
"per",
"second"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/uncertainty/simulateUncertDependencyOnExpTime.py#L50-L63 | [
"def",
"exampleSignals",
"(",
"std",
"=",
"1",
",",
"dur1",
"=",
"1",
",",
"dur2",
"=",
"3",
",",
"dur3",
"=",
"0.2",
",",
"n1",
"=",
"0.5",
",",
"n2",
"=",
"0.5",
",",
"n3",
"=",
"2",
")",
":",
"np",
".",
"random",
".",
"seed",
"(",
"123",... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | _flux | returns Gaussian shaped signal fluctuations [events]
t --> times to calculate event for
n --> numbers of events per sec
duration --> event duration per sec
std --> std of event if averaged over time
offs --> event offset | imgProcessor/uncertainty/simulateUncertDependencyOnExpTime.py | def _flux(t, n, duration, std, offs=1):
'''
returns Gaussian shaped signal fluctuations [events]
t --> times to calculate event for
n --> numbers of events per sec
duration --> event duration per sec
std --> std of event if averaged over time
offs --> event offset
'''
... | def _flux(t, n, duration, std, offs=1):
'''
returns Gaussian shaped signal fluctuations [events]
t --> times to calculate event for
n --> numbers of events per sec
duration --> event duration per sec
std --> std of event if averaged over time
offs --> event offset
'''
... | [
"returns",
"Gaussian",
"shaped",
"signal",
"fluctuations",
"[",
"events",
"]",
"t",
"--",
">",
"times",
"to",
"calculate",
"event",
"for",
"n",
"--",
">",
"numbers",
"of",
"events",
"per",
"sec",
"duration",
"--",
">",
"event",
"duration",
"per",
"sec",
... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/uncertainty/simulateUncertDependencyOnExpTime.py#L66-L113 | [
"def",
"_flux",
"(",
"t",
",",
"n",
",",
"duration",
",",
"std",
",",
"offs",
"=",
"1",
")",
":",
"duration",
"*=",
"len",
"(",
"t",
")",
"/",
"t",
"[",
"-",
"1",
"]",
"duration",
"=",
"int",
"(",
"max",
"(",
"duration",
",",
"1",
")",
")",... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | _capture | capture signal and return its standard deviation
#TODO: more detail | imgProcessor/uncertainty/simulateUncertDependencyOnExpTime.py | def _capture(f, t, t0, factor):
'''
capture signal and return its standard deviation
#TODO: more detail
'''
n_per_sec = len(t) / t[-1]
# len of one split:
n = int(t0 * factor * n_per_sec)
s = len(f) // n
m = s * n
f = f[:m]
ff = np.split(f, s)
m = np.mean(ff... | def _capture(f, t, t0, factor):
'''
capture signal and return its standard deviation
#TODO: more detail
'''
n_per_sec = len(t) / t[-1]
# len of one split:
n = int(t0 * factor * n_per_sec)
s = len(f) // n
m = s * n
f = f[:m]
ff = np.split(f, s)
m = np.mean(ff... | [
"capture",
"signal",
"and",
"return",
"its",
"standard",
"deviation",
"#TODO",
":",
"more",
"detail"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/uncertainty/simulateUncertDependencyOnExpTime.py#L116-L131 | [
"def",
"_capture",
"(",
"f",
",",
"t",
",",
"t0",
",",
"factor",
")",
":",
"n_per_sec",
"=",
"len",
"(",
"t",
")",
"/",
"t",
"[",
"-",
"1",
"]",
"# len of one split:\r",
"n",
"=",
"int",
"(",
"t0",
"*",
"factor",
"*",
"n_per_sec",
")",
"s",
"="... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | genericCameraMatrix | Return a generic camera matrix
[[fx, 0, cx],
[ 0, fy, cy],
[ 0, 0, 1]]
for a given image shape | imgProcessor/utils/genericCameraMatrix.py | def genericCameraMatrix(shape, angularField=60):
'''
Return a generic camera matrix
[[fx, 0, cx],
[ 0, fy, cy],
[ 0, 0, 1]]
for a given image shape
'''
# http://nghiaho.com/?page_id=576
# assume that the optical centre is in the middle:
cy = int(shape[0] / 2)
cx ... | def genericCameraMatrix(shape, angularField=60):
'''
Return a generic camera matrix
[[fx, 0, cx],
[ 0, fy, cy],
[ 0, 0, 1]]
for a given image shape
'''
# http://nghiaho.com/?page_id=576
# assume that the optical centre is in the middle:
cy = int(shape[0] / 2)
cx ... | [
"Return",
"a",
"generic",
"camera",
"matrix",
"[[",
"fx",
"0",
"cx",
"]",
"[",
"0",
"fy",
"cy",
"]",
"[",
"0",
"0",
"1",
"]]",
"for",
"a",
"given",
"image",
"shape"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/utils/genericCameraMatrix.py#L7-L28 | [
"def",
"genericCameraMatrix",
"(",
"shape",
",",
"angularField",
"=",
"60",
")",
":",
"# http://nghiaho.com/?page_id=576\r",
"# assume that the optical centre is in the middle:\r",
"cy",
"=",
"int",
"(",
"shape",
"[",
"0",
"]",
"/",
"2",
")",
"cx",
"=",
"int",
"("... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | standardDeviation2d | calculate the spatial resolved standard deviation
for a given 2d array
ksize -> kernel size
blurred(optional) -> with same ksize gaussian filtered image
setting this parameter reduces processing time | imgProcessor/filters/standardDeviation.py | def standardDeviation2d(img, ksize=5, blurred=None):
'''
calculate the spatial resolved standard deviation
for a given 2d array
ksize -> kernel size
blurred(optional) -> with same ksize gaussian filtered image
setting this parameter reduces processing time
... | def standardDeviation2d(img, ksize=5, blurred=None):
'''
calculate the spatial resolved standard deviation
for a given 2d array
ksize -> kernel size
blurred(optional) -> with same ksize gaussian filtered image
setting this parameter reduces processing time
... | [
"calculate",
"the",
"spatial",
"resolved",
"standard",
"deviation",
"for",
"a",
"given",
"2d",
"array",
"ksize",
"-",
">",
"kernel",
"size",
"blurred",
"(",
"optional",
")",
"-",
">",
"with",
"same",
"ksize",
"gaussian",
"filtered",
"image",
"setting",
"this... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/filters/standardDeviation.py#L9-L31 | [
"def",
"standardDeviation2d",
"(",
"img",
",",
"ksize",
"=",
"5",
",",
"blurred",
"=",
"None",
")",
":",
"if",
"ksize",
"not",
"in",
"(",
"list",
",",
"tuple",
")",
":",
"ksize",
"=",
"(",
"ksize",
",",
"ksize",
")",
"if",
"blurred",
"is",
"None",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | maskedFilter | fn['mean', 'median']
fill_mask=True:
replaced masked areas with filtered results
fill_mask=False:
masked areas are ignored | imgProcessor/filters/maskedFilter.py | def maskedFilter(arr, mask, ksize=30, fill_mask=True,
fn='median'):
'''
fn['mean', 'median']
fill_mask=True:
replaced masked areas with filtered results
fill_mask=False:
masked areas are ignored
'''
if fill_mask:
mask1 = mask
out = ar... | def maskedFilter(arr, mask, ksize=30, fill_mask=True,
fn='median'):
'''
fn['mean', 'median']
fill_mask=True:
replaced masked areas with filtered results
fill_mask=False:
masked areas are ignored
'''
if fill_mask:
mask1 = mask
out = ar... | [
"fn",
"[",
"mean",
"median",
"]",
"fill_mask",
"=",
"True",
":",
"replaced",
"masked",
"areas",
"with",
"filtered",
"results",
"fill_mask",
"=",
"False",
":",
"masked",
"areas",
"are",
"ignored"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/filters/maskedFilter.py#L12-L37 | [
"def",
"maskedFilter",
"(",
"arr",
",",
"mask",
",",
"ksize",
"=",
"30",
",",
"fill_mask",
"=",
"True",
",",
"fn",
"=",
"'median'",
")",
":",
"if",
"fill_mask",
":",
"mask1",
"=",
"mask",
"out",
"=",
"arr",
"else",
":",
"mask1",
"=",
"~",
"mask",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | vignettingFromDifferentObjects | Extract vignetting from a set of images
containing different devices
The devices spatial inhomogeneities are averaged
This method is referred as 'Method C' in
---
K.Bedrich, M.Bokalic et al.:
ELECTROLUMINESCENCE IMAGING OF PV DEVICES:
ADVANCED FLAT FIELD CALIBRATION,2017
--- | imgProcessor/camera/flatField/vignettingFromDifferentObjects.py | def vignettingFromDifferentObjects(imgs, bg):
'''
Extract vignetting from a set of images
containing different devices
The devices spatial inhomogeneities are averaged
This method is referred as 'Method C' in
---
K.Bedrich, M.Bokalic et al.:
ELECTROLUMINESCENCE IMAGING OF PV D... | def vignettingFromDifferentObjects(imgs, bg):
'''
Extract vignetting from a set of images
containing different devices
The devices spatial inhomogeneities are averaged
This method is referred as 'Method C' in
---
K.Bedrich, M.Bokalic et al.:
ELECTROLUMINESCENCE IMAGING OF PV D... | [
"Extract",
"vignetting",
"from",
"a",
"set",
"of",
"images",
"containing",
"different",
"devices",
"The",
"devices",
"spatial",
"inhomogeneities",
"are",
"averaged",
"This",
"method",
"is",
"referred",
"as",
"Method",
"C",
"in",
"---",
"K",
".",
"Bedrich",
"M"... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/flatField/vignettingFromDifferentObjects.py#L129-L144 | [
"def",
"vignettingFromDifferentObjects",
"(",
"imgs",
",",
"bg",
")",
":",
"f",
"=",
"FlatFieldFromImgFit",
"(",
"imgs",
",",
"bg",
")",
"return",
"f",
".",
"result",
",",
"f",
".",
"mask"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | SNR_IEC | Calculate the averaged signal-to-noise ratio SNR50
as defined by IEC NP 60904-13
needs 2 reference EL images and one background image | imgProcessor/measure/SNR/SNR_IEC.py | def SNR_IEC(i1, i2, ibg=0, allow_color_images=False):
'''
Calculate the averaged signal-to-noise ratio SNR50
as defined by IEC NP 60904-13
needs 2 reference EL images and one background image
'''
# ensure images are type float64 (double precision):
i1 = np.asfarray(i1)
i2 = np.... | def SNR_IEC(i1, i2, ibg=0, allow_color_images=False):
'''
Calculate the averaged signal-to-noise ratio SNR50
as defined by IEC NP 60904-13
needs 2 reference EL images and one background image
'''
# ensure images are type float64 (double precision):
i1 = np.asfarray(i1)
i2 = np.... | [
"Calculate",
"the",
"averaged",
"signal",
"-",
"to",
"-",
"noise",
"ratio",
"SNR50",
"as",
"defined",
"by",
"IEC",
"NP",
"60904",
"-",
"13",
"needs",
"2",
"reference",
"EL",
"images",
"and",
"one",
"background",
"image"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/measure/SNR/SNR_IEC.py#L7-L33 | [
"def",
"SNR_IEC",
"(",
"i1",
",",
"i2",
",",
"ibg",
"=",
"0",
",",
"allow_color_images",
"=",
"False",
")",
":",
"# ensure images are type float64 (double precision):\r",
"i1",
"=",
"np",
".",
"asfarray",
"(",
"i1",
")",
"i2",
"=",
"np",
".",
"asfarray",
"... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | StitchImages._rotate | angle [DEG] | imgProcessor/transform/StitchImages.py | def _rotate(img, angle):
'''
angle [DEG]
'''
s = img.shape
if angle == 0:
return img
else:
M = cv2.getRotationMatrix2D((s[1] // 2,
s[0] // 2), angle, 1)
return cv2.warpAffine(img, M, (s... | def _rotate(img, angle):
'''
angle [DEG]
'''
s = img.shape
if angle == 0:
return img
else:
M = cv2.getRotationMatrix2D((s[1] // 2,
s[0] // 2), angle, 1)
return cv2.warpAffine(img, M, (s... | [
"angle",
"[",
"DEG",
"]"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transform/StitchImages.py#L83-L93 | [
"def",
"_rotate",
"(",
"img",
",",
"angle",
")",
":",
"s",
"=",
"img",
".",
"shape",
"if",
"angle",
"==",
"0",
":",
"return",
"img",
"else",
":",
"M",
"=",
"cv2",
".",
"getRotationMatrix2D",
"(",
"(",
"s",
"[",
"1",
"]",
"//",
"2",
",",
"s",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | StitchImages._findOverlap | return offset(x,y) which fit best self._base_img
through template matching | imgProcessor/transform/StitchImages.py | def _findOverlap(self, img_rgb, overlap, overlapDeviation,
rotation, rotationDeviation):
'''
return offset(x,y) which fit best self._base_img
through template matching
'''
# get gray images
if len(img_rgb.shape) != len(img_rgb.shape):
... | def _findOverlap(self, img_rgb, overlap, overlapDeviation,
rotation, rotationDeviation):
'''
return offset(x,y) which fit best self._base_img
through template matching
'''
# get gray images
if len(img_rgb.shape) != len(img_rgb.shape):
... | [
"return",
"offset",
"(",
"x",
"y",
")",
"which",
"fit",
"best",
"self",
".",
"_base_img",
"through",
"template",
"matching"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transform/StitchImages.py#L95-L136 | [
"def",
"_findOverlap",
"(",
"self",
",",
"img_rgb",
",",
"overlap",
",",
"overlapDeviation",
",",
"rotation",
",",
"rotationDeviation",
")",
":",
"# get gray images\r",
"if",
"len",
"(",
"img_rgb",
".",
"shape",
")",
"!=",
"len",
"(",
"img_rgb",
".",
"shape"... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | estimateFromImages | estimate the noise level function as stDev over image intensity
from a set of 2 image groups
images at the same position have to show
the identical setup, so
imgs1[i] - imgs2[i] = noise | imgProcessor/camera/NoiseLevelFunction.py | def estimateFromImages(imgs1, imgs2=None, mn_mx=None, nbins=100):
'''
estimate the noise level function as stDev over image intensity
from a set of 2 image groups
images at the same position have to show
the identical setup, so
imgs1[i] - imgs2[i] = noise
'''
if imgs2 is None:
... | def estimateFromImages(imgs1, imgs2=None, mn_mx=None, nbins=100):
'''
estimate the noise level function as stDev over image intensity
from a set of 2 image groups
images at the same position have to show
the identical setup, so
imgs1[i] - imgs2[i] = noise
'''
if imgs2 is None:
... | [
"estimate",
"the",
"noise",
"level",
"function",
"as",
"stDev",
"over",
"image",
"intensity",
"from",
"a",
"set",
"of",
"2",
"image",
"groups",
"images",
"at",
"the",
"same",
"position",
"have",
"to",
"show",
"the",
"identical",
"setup",
"so",
"imgs1",
"["... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/NoiseLevelFunction.py#L11-L68 | [
"def",
"estimateFromImages",
"(",
"imgs1",
",",
"imgs2",
"=",
"None",
",",
"mn_mx",
"=",
"None",
",",
"nbins",
"=",
"100",
")",
":",
"if",
"imgs2",
"is",
"None",
":",
"imgs2",
"=",
"[",
"None",
"]",
"*",
"len",
"(",
"imgs1",
")",
"else",
":",
"as... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | _evaluate | get the parameters of the, needed by 'function'
through curve fitting | imgProcessor/camera/NoiseLevelFunction.py | def _evaluate(x, y, weights):
'''
get the parameters of the, needed by 'function'
through curve fitting
'''
i = _validI(x, y, weights)
xx = x[i]
y = y[i]
try:
fitParams = _fit(xx, y)
# bound noise fn to min defined y value:
minY = function(xx[0], *fit... | def _evaluate(x, y, weights):
'''
get the parameters of the, needed by 'function'
through curve fitting
'''
i = _validI(x, y, weights)
xx = x[i]
y = y[i]
try:
fitParams = _fit(xx, y)
# bound noise fn to min defined y value:
minY = function(xx[0], *fit... | [
"get",
"the",
"parameters",
"of",
"the",
"needed",
"by",
"function",
"through",
"curve",
"fitting"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/NoiseLevelFunction.py#L71-L91 | [
"def",
"_evaluate",
"(",
"x",
",",
"y",
",",
"weights",
")",
":",
"i",
"=",
"_validI",
"(",
"x",
",",
"y",
",",
"weights",
")",
"xx",
"=",
"x",
"[",
"i",
"]",
"y",
"=",
"y",
"[",
"i",
"]",
"try",
":",
"fitParams",
"=",
"_fit",
"(",
"xx",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | boundedFunction | limit [function] to a minimum y value | imgProcessor/camera/NoiseLevelFunction.py | def boundedFunction(x, minY, ax, ay):
'''
limit [function] to a minimum y value
'''
y = function(x, ax, ay)
return np.maximum(np.nan_to_num(y), minY) | def boundedFunction(x, minY, ax, ay):
'''
limit [function] to a minimum y value
'''
y = function(x, ax, ay)
return np.maximum(np.nan_to_num(y), minY) | [
"limit",
"[",
"function",
"]",
"to",
"a",
"minimum",
"y",
"value"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/NoiseLevelFunction.py#L94-L99 | [
"def",
"boundedFunction",
"(",
"x",
",",
"minY",
",",
"ax",
",",
"ay",
")",
":",
"y",
"=",
"function",
"(",
"x",
",",
"ax",
",",
"ay",
")",
"return",
"np",
".",
"maximum",
"(",
"np",
".",
"nan_to_num",
"(",
"y",
")",
",",
"minY",
")"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | function | general square root function | imgProcessor/camera/NoiseLevelFunction.py | def function(x, ax, ay):
'''
general square root function
'''
with np.errstate(invalid='ignore'):
return ay * (x - ax)**0.5 | def function(x, ax, ay):
'''
general square root function
'''
with np.errstate(invalid='ignore'):
return ay * (x - ax)**0.5 | [
"general",
"square",
"root",
"function"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/NoiseLevelFunction.py#L102-L107 | [
"def",
"function",
"(",
"x",
",",
"ax",
",",
"ay",
")",
":",
"with",
"np",
".",
"errstate",
"(",
"invalid",
"=",
"'ignore'",
")",
":",
"return",
"ay",
"*",
"(",
"x",
"-",
"ax",
")",
"**",
"0.5"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | _validI | return indices that have enough data points and are not erroneous | imgProcessor/camera/NoiseLevelFunction.py | def _validI(x, y, weights):
'''
return indices that have enough data points and are not erroneous
'''
# density filter:
i = np.logical_and(np.isfinite(y), weights > np.median(weights))
# filter outliers:
try:
grad = np.abs(np.gradient(y[i]))
max_gradient = 4 * np.me... | def _validI(x, y, weights):
'''
return indices that have enough data points and are not erroneous
'''
# density filter:
i = np.logical_and(np.isfinite(y), weights > np.median(weights))
# filter outliers:
try:
grad = np.abs(np.gradient(y[i]))
max_gradient = 4 * np.me... | [
"return",
"indices",
"that",
"have",
"enough",
"data",
"points",
"and",
"are",
"not",
"erroneous"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/NoiseLevelFunction.py#L110-L123 | [
"def",
"_validI",
"(",
"x",
",",
"y",
",",
"weights",
")",
":",
"# density filter:\r",
"i",
"=",
"np",
".",
"logical_and",
"(",
"np",
".",
"isfinite",
"(",
"y",
")",
",",
"weights",
">",
"np",
".",
"median",
"(",
"weights",
")",
")",
"# filter outlie... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | smooth | in case the NLF cannot be described by
a square root function
commit bounded polynomial interpolation | imgProcessor/camera/NoiseLevelFunction.py | def smooth(x, y, weights):
'''
in case the NLF cannot be described by
a square root function
commit bounded polynomial interpolation
'''
# Spline hard to smooth properly, therefore solfed with
# bounded polynomal interpolation
# ext=3: no extrapolation, but boundary value
# ... | def smooth(x, y, weights):
'''
in case the NLF cannot be described by
a square root function
commit bounded polynomial interpolation
'''
# Spline hard to smooth properly, therefore solfed with
# bounded polynomal interpolation
# ext=3: no extrapolation, but boundary value
# ... | [
"in",
"case",
"the",
"NLF",
"cannot",
"be",
"described",
"by",
"a",
"square",
"root",
"function",
"commit",
"bounded",
"polynomial",
"interpolation"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/NoiseLevelFunction.py#L131-L150 | [
"def",
"smooth",
"(",
"x",
",",
"y",
",",
"weights",
")",
":",
"# Spline hard to smooth properly, therefore solfed with\r",
"# bounded polynomal interpolation\r",
"# ext=3: no extrapolation, but boundary value\r",
"# return UnivariateSpline(x, y, w=weights,\r",
"# ... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | oneImageNLF | Estimate the NLF from one or two images of the same kind | imgProcessor/camera/NoiseLevelFunction.py | def oneImageNLF(img, img2=None, signal=None):
'''
Estimate the NLF from one or two images of the same kind
'''
x, y, weights, signal = calcNLF(img, img2, signal)
_, fn, _ = _evaluate(x, y, weights)
return fn, signal | def oneImageNLF(img, img2=None, signal=None):
'''
Estimate the NLF from one or two images of the same kind
'''
x, y, weights, signal = calcNLF(img, img2, signal)
_, fn, _ = _evaluate(x, y, weights)
return fn, signal | [
"Estimate",
"the",
"NLF",
"from",
"one",
"or",
"two",
"images",
"of",
"the",
"same",
"kind"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/NoiseLevelFunction.py#L153-L159 | [
"def",
"oneImageNLF",
"(",
"img",
",",
"img2",
"=",
"None",
",",
"signal",
"=",
"None",
")",
":",
"x",
",",
"y",
",",
"weights",
",",
"signal",
"=",
"calcNLF",
"(",
"img",
",",
"img2",
",",
"signal",
")",
"_",
",",
"fn",
",",
"_",
"=",
"_evalua... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | _getMinMax | Get the a range of image intensities
that most pixels are in with | imgProcessor/camera/NoiseLevelFunction.py | def _getMinMax(img):
'''
Get the a range of image intensities
that most pixels are in with
'''
av = np.mean(img)
std = np.std(img)
# define range for segmentation:
mn = av - 3 * std
mx = av + 3 * std
return max(img.min(), mn, 0), min(img.max(), mx) | def _getMinMax(img):
'''
Get the a range of image intensities
that most pixels are in with
'''
av = np.mean(img)
std = np.std(img)
# define range for segmentation:
mn = av - 3 * std
mx = av + 3 * std
return max(img.min(), mn, 0), min(img.max(), mx) | [
"Get",
"the",
"a",
"range",
"of",
"image",
"intensities",
"that",
"most",
"pixels",
"are",
"in",
"with"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/NoiseLevelFunction.py#L162-L173 | [
"def",
"_getMinMax",
"(",
"img",
")",
":",
"av",
"=",
"np",
".",
"mean",
"(",
"img",
")",
"std",
"=",
"np",
".",
"std",
"(",
"img",
")",
"# define range for segmentation:\r",
"mn",
"=",
"av",
"-",
"3",
"*",
"std",
"mx",
"=",
"av",
"+",
"3",
"*",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | calcNLF | Calculate the noise level function (NLF) as f(intensity)
using one or two image.
The approach for this work is published in JPV##########
img2 - 2nd image taken under same conditions
used to estimate noise via image difference
signalFromMultipleImages - whether the signal is an avera... | imgProcessor/camera/NoiseLevelFunction.py | def calcNLF(img, img2=None, signal=None, mn_mx_nbins=None, x=None,
averageFn='AAD',
signalFromMultipleImages=False):
'''
Calculate the noise level function (NLF) as f(intensity)
using one or two image.
The approach for this work is published in JPV##########
img2 - 2... | def calcNLF(img, img2=None, signal=None, mn_mx_nbins=None, x=None,
averageFn='AAD',
signalFromMultipleImages=False):
'''
Calculate the noise level function (NLF) as f(intensity)
using one or two image.
The approach for this work is published in JPV##########
img2 - 2... | [
"Calculate",
"the",
"noise",
"level",
"function",
"(",
"NLF",
")",
"as",
"f",
"(",
"intensity",
")",
"using",
"one",
"or",
"two",
"image",
".",
"The",
"approach",
"for",
"this",
"work",
"is",
"published",
"in",
"JPV##########",
"img2",
"-",
"2nd",
"image... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/NoiseLevelFunction.py#L176-L271 | [
"def",
"calcNLF",
"(",
"img",
",",
"img2",
"=",
"None",
",",
"signal",
"=",
"None",
",",
"mn_mx_nbins",
"=",
"None",
",",
"x",
"=",
"None",
",",
"averageFn",
"=",
"'AAD'",
",",
"signalFromMultipleImages",
"=",
"False",
")",
":",
"# CONSTANTS:\r",
"# fact... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | polyfit2d | fit unstructured data | imgProcessor/interpolate/polyfit2d.py | def polyfit2d(x, y, z, order=3 #bounds=None
):
'''
fit unstructured data
'''
ncols = (order + 1)**2
G = np.zeros((x.size, ncols))
ij = itertools.product(list(range(order+1)), list(range(order+1)))
for k, (i,j) in enumerate(ij):
G[:,k] = x**i * y**j
m = np... | def polyfit2d(x, y, z, order=3 #bounds=None
):
'''
fit unstructured data
'''
ncols = (order + 1)**2
G = np.zeros((x.size, ncols))
ij = itertools.product(list(range(order+1)), list(range(order+1)))
for k, (i,j) in enumerate(ij):
G[:,k] = x**i * y**j
m = np... | [
"fit",
"unstructured",
"data"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/interpolate/polyfit2d.py#L8-L19 | [
"def",
"polyfit2d",
"(",
"x",
",",
"y",
",",
"z",
",",
"order",
"=",
"3",
"#bounds=None\r",
")",
":",
"ncols",
"=",
"(",
"order",
"+",
"1",
")",
"**",
"2",
"G",
"=",
"np",
".",
"zeros",
"(",
"(",
"x",
".",
"size",
",",
"ncols",
")",
")",
"i... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | polyfit2dGrid | replace all masked values with polynomial fitted ones | imgProcessor/interpolate/polyfit2d.py | def polyfit2dGrid(arr, mask=None, order=3, replace_all=False,
copy=True, outgrid=None):
'''
replace all masked values with polynomial fitted ones
'''
s0,s1 = arr.shape
if mask is None:
if outgrid is None:
y,x = np.mgrid[:float(s0),:float(s1)]
... | def polyfit2dGrid(arr, mask=None, order=3, replace_all=False,
copy=True, outgrid=None):
'''
replace all masked values with polynomial fitted ones
'''
s0,s1 = arr.shape
if mask is None:
if outgrid is None:
y,x = np.mgrid[:float(s0),:float(s1)]
... | [
"replace",
"all",
"masked",
"values",
"with",
"polynomial",
"fitted",
"ones"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/interpolate/polyfit2d.py#L31-L65 | [
"def",
"polyfit2dGrid",
"(",
"arr",
",",
"mask",
"=",
"None",
",",
"order",
"=",
"3",
",",
"replace_all",
"=",
"False",
",",
"copy",
"=",
"True",
",",
"outgrid",
"=",
"None",
")",
":",
"s0",
",",
"s1",
"=",
"arr",
".",
"shape",
"if",
"mask",
"is"... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | minimumLineInArray | find closest minimum position next to middle line
relative: return position relative to middle line
f: relative decrease (0...1) - setting this value close to one will
discriminate positions further away from the center
##order: 2 for cubic refinement | imgProcessor/features/minimumLineInArray.py | def minimumLineInArray(arr, relative=False, f=0,
refinePosition=True,
max_pos=100,
return_pos_arr=False,
# order=2
):
'''
find closest minimum position next to middle line
relative: ret... | def minimumLineInArray(arr, relative=False, f=0,
refinePosition=True,
max_pos=100,
return_pos_arr=False,
# order=2
):
'''
find closest minimum position next to middle line
relative: ret... | [
"find",
"closest",
"minimum",
"position",
"next",
"to",
"middle",
"line",
"relative",
":",
"return",
"position",
"relative",
"to",
"middle",
"line",
"f",
":",
"relative",
"decrease",
"(",
"0",
"...",
"1",
")",
"-",
"setting",
"this",
"value",
"close",
"to"... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/features/minimumLineInArray.py#L27-L72 | [
"def",
"minimumLineInArray",
"(",
"arr",
",",
"relative",
"=",
"False",
",",
"f",
"=",
"0",
",",
"refinePosition",
"=",
"True",
",",
"max_pos",
"=",
"100",
",",
"return_pos_arr",
"=",
"False",
",",
"# order=2\r",
")",
":",
"s0",
",",
"s1",
"=",
"arr",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | FourierFilter.highPassFilter | remove all low frequencies by setting a square in the middle of the
Fourier transformation of the size (2*threshold)^2 to zero
threshold = 0...1 | imgProcessor/filters/FourierFilter.py | def highPassFilter(self, threshold):
'''
remove all low frequencies by setting a square in the middle of the
Fourier transformation of the size (2*threshold)^2 to zero
threshold = 0...1
'''
if not threshold:
return
rows, cols = self.img.shape
... | def highPassFilter(self, threshold):
'''
remove all low frequencies by setting a square in the middle of the
Fourier transformation of the size (2*threshold)^2 to zero
threshold = 0...1
'''
if not threshold:
return
rows, cols = self.img.shape
... | [
"remove",
"all",
"low",
"frequencies",
"by",
"setting",
"a",
"square",
"in",
"the",
"middle",
"of",
"the",
"Fourier",
"transformation",
"of",
"the",
"size",
"(",
"2",
"*",
"threshold",
")",
"^2",
"to",
"zero",
"threshold",
"=",
"0",
"...",
"1"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/filters/FourierFilter.py#L27-L41 | [
"def",
"highPassFilter",
"(",
"self",
",",
"threshold",
")",
":",
"if",
"not",
"threshold",
":",
"return",
"rows",
",",
"cols",
"=",
"self",
".",
"img",
".",
"shape",
"tx",
"=",
"int",
"(",
"cols",
"*",
"threshold",
")",
"ty",
"=",
"int",
"(",
"row... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | FourierFilter.lowPassFilter | remove all high frequencies by setting boundary around a quarry in the middle
of the size (2*threshold)^2 to zero
threshold = 0...1 | imgProcessor/filters/FourierFilter.py | def lowPassFilter(self, threshold):
'''
remove all high frequencies by setting boundary around a quarry in the middle
of the size (2*threshold)^2 to zero
threshold = 0...1
'''
if not threshold:
return
rows, cols = self.img.shape
tx = i... | def lowPassFilter(self, threshold):
'''
remove all high frequencies by setting boundary around a quarry in the middle
of the size (2*threshold)^2 to zero
threshold = 0...1
'''
if not threshold:
return
rows, cols = self.img.shape
tx = i... | [
"remove",
"all",
"high",
"frequencies",
"by",
"setting",
"boundary",
"around",
"a",
"quarry",
"in",
"the",
"middle",
"of",
"the",
"size",
"(",
"2",
"*",
"threshold",
")",
"^2",
"to",
"zero",
"threshold",
"=",
"0",
"...",
"1"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/filters/FourierFilter.py#L43-L61 | [
"def",
"lowPassFilter",
"(",
"self",
",",
"threshold",
")",
":",
"if",
"not",
"threshold",
":",
"return",
"rows",
",",
"cols",
"=",
"self",
".",
"img",
".",
"shape",
"tx",
"=",
"int",
"(",
"cols",
"*",
"threshold",
"*",
"0.25",
")",
"ty",
"=",
"int... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | FourierFilter.reconstructImage | do inverse Fourier transform and return result | imgProcessor/filters/FourierFilter.py | def reconstructImage(self):
'''
do inverse Fourier transform and return result
'''
f_ishift = np.fft.ifftshift(self.fshift)
return np.real(np.fft.ifft2(f_ishift)) | def reconstructImage(self):
'''
do inverse Fourier transform and return result
'''
f_ishift = np.fft.ifftshift(self.fshift)
return np.real(np.fft.ifft2(f_ishift)) | [
"do",
"inverse",
"Fourier",
"transform",
"and",
"return",
"result"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/filters/FourierFilter.py#L108-L113 | [
"def",
"reconstructImage",
"(",
"self",
")",
":",
"f_ishift",
"=",
"np",
".",
"fft",
".",
"ifftshift",
"(",
"self",
".",
"fshift",
")",
"return",
"np",
".",
"real",
"(",
"np",
".",
"fft",
".",
"ifft2",
"(",
"f_ishift",
")",
")"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | interpolate2dUnstructuredIDW | x,y,v --> 1d numpy.array
grid --> 2d numpy.array
fast if number of given values is small relative to grid resolution | imgProcessor/interpolate/interpolate2dUnstructuredIDW.py | def interpolate2dUnstructuredIDW(x, y, v, grid, power=2):
'''
x,y,v --> 1d numpy.array
grid --> 2d numpy.array
fast if number of given values is small relative to grid resolution
'''
n = len(v)
gx = grid.shape[0]
gy = grid.shape[1]
for i in range(gx):
for j in ran... | def interpolate2dUnstructuredIDW(x, y, v, grid, power=2):
'''
x,y,v --> 1d numpy.array
grid --> 2d numpy.array
fast if number of given values is small relative to grid resolution
'''
n = len(v)
gx = grid.shape[0]
gy = grid.shape[1]
for i in range(gx):
for j in ran... | [
"x",
"y",
"v",
"--",
">",
"1d",
"numpy",
".",
"array",
"grid",
"--",
">",
"2d",
"numpy",
".",
"array",
"fast",
"if",
"number",
"of",
"given",
"values",
"is",
"small",
"relative",
"to",
"grid",
"resolution"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/interpolate/interpolate2dUnstructuredIDW.py#L8-L38 | [
"def",
"interpolate2dUnstructuredIDW",
"(",
"x",
",",
"y",
",",
"v",
",",
"grid",
",",
"power",
"=",
"2",
")",
":",
"n",
"=",
"len",
"(",
"v",
")",
"gx",
"=",
"grid",
".",
"shape",
"[",
"0",
"]",
"gy",
"=",
"grid",
".",
"shape",
"[",
"1",
"]"... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | hog | returns the Histogram of Oriented Gradients
:param ksize: convolution kernel size as (y,x) - needs to be odd
:param orientations: number of orientations in between rad=0 and rad=pi
similar to http://scikit-image.org/docs/dev/auto_examples/plot_hog.html
but faster and with less options | imgProcessor/features/hog.py | def hog(image, orientations=8, ksize=(5, 5)):
'''
returns the Histogram of Oriented Gradients
:param ksize: convolution kernel size as (y,x) - needs to be odd
:param orientations: number of orientations in between rad=0 and rad=pi
similar to http://scikit-image.org/docs/dev/auto_examples/pl... | def hog(image, orientations=8, ksize=(5, 5)):
'''
returns the Histogram of Oriented Gradients
:param ksize: convolution kernel size as (y,x) - needs to be odd
:param orientations: number of orientations in between rad=0 and rad=pi
similar to http://scikit-image.org/docs/dev/auto_examples/pl... | [
"returns",
"the",
"Histogram",
"of",
"Oriented",
"Gradients",
":",
"param",
"ksize",
":",
"convolution",
"kernel",
"size",
"as",
"(",
"y",
"x",
")",
"-",
"needs",
"to",
"be",
"odd",
":",
"param",
"orientations",
":",
"number",
"of",
"orientations",
"in",
... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/features/hog.py#L40-L64 | [
"def",
"hog",
"(",
"image",
",",
"orientations",
"=",
"8",
",",
"ksize",
"=",
"(",
"5",
",",
"5",
")",
")",
":",
"s0",
",",
"s1",
"=",
"image",
".",
"shape",
"[",
":",
"2",
"]",
"# speed up the process through saving generated kernels:\r",
"try",
":",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | visualize | visualize HOG as polynomial around cell center
for [grid] * cells | imgProcessor/features/hog.py | def visualize(hog, grid=(10, 10), radCircle=None):
'''
visualize HOG as polynomial around cell center
for [grid] * cells
'''
s0, s1, nang = hog.shape
angles = np.linspace(0, np.pi, nang + 1)[:-1]
# center of each sub array:
cx, cy = s0 // (2 * grid[0]), s1 // (2 * grid[1])
... | def visualize(hog, grid=(10, 10), radCircle=None):
'''
visualize HOG as polynomial around cell center
for [grid] * cells
'''
s0, s1, nang = hog.shape
angles = np.linspace(0, np.pi, nang + 1)[:-1]
# center of each sub array:
cx, cy = s0 // (2 * grid[0]), s1 // (2 * grid[1])
... | [
"visualize",
"HOG",
"as",
"polynomial",
"around",
"cell",
"center",
"for",
"[",
"grid",
"]",
"*",
"cells"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/features/hog.py#L68-L105 | [
"def",
"visualize",
"(",
"hog",
",",
"grid",
"=",
"(",
"10",
",",
"10",
")",
",",
"radCircle",
"=",
"None",
")",
":",
"s0",
",",
"s1",
",",
"nang",
"=",
"hog",
".",
"shape",
"angles",
"=",
"np",
".",
"linspace",
"(",
"0",
",",
"np",
".",
"pi"... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | postProcessing | Post process measured flat field [arr].
Depending on the measurement, different
post processing [method]s are beneficial.
The available methods are presented in
---
K.Bedrich, M.Bokalic et al.:
ELECTROLUMINESCENCE IMAGING OF PV DEVICES:
ADVANCED FLAT FIELD CALI... | imgProcessor/camera/flatField/postProcessing.py | def postProcessing(arr, method='KW replace + Gauss', mask=None):
'''
Post process measured flat field [arr].
Depending on the measurement, different
post processing [method]s are beneficial.
The available methods are presented in
---
K.Bedrich, M.Bokalic et al.:
... | def postProcessing(arr, method='KW replace + Gauss', mask=None):
'''
Post process measured flat field [arr].
Depending on the measurement, different
post processing [method]s are beneficial.
The available methods are presented in
---
K.Bedrich, M.Bokalic et al.:
... | [
"Post",
"process",
"measured",
"flat",
"field",
"[",
"arr",
"]",
".",
"Depending",
"on",
"the",
"measurement",
"different",
"post",
"processing",
"[",
"method",
"]",
"s",
"are",
"beneficial",
".",
"The",
"available",
"methods",
"are",
"presented",
"in",
"---... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/flatField/postProcessing.py#L16-L74 | [
"def",
"postProcessing",
"(",
"arr",
",",
"method",
"=",
"'KW replace + Gauss'",
",",
"mask",
"=",
"None",
")",
":",
"assert",
"method",
"in",
"ppMETHODS",
",",
"'post processing method (%s) must be one of %s'",
"%",
"(",
"method",
",",
"ppMETHODS",
")",
"if",
"... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | rmBorder | border [None], if images are corrected and device ends at
image border
[one number] (like 50),
if there is an equally spaced border
around the device
[two tu... | imgProcessor/transform/rmBorder.py | def rmBorder(img, border=None):
'''
border [None], if images are corrected and device ends at
image border
[one number] (like 50),
if there is an equally spaced border
aroun... | def rmBorder(img, border=None):
'''
border [None], if images are corrected and device ends at
image border
[one number] (like 50),
if there is an equally spaced border
aroun... | [
"border",
"[",
"None",
"]",
"if",
"images",
"are",
"corrected",
"and",
"device",
"ends",
"at",
"image",
"border",
"[",
"one",
"number",
"]",
"(",
"like",
"50",
")",
"if",
"there",
"is",
"an",
"equally",
"spaced",
"border",
"around",
"the",
"device",
"[... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transform/rmBorder.py#L6-L36 | [
"def",
"rmBorder",
"(",
"img",
",",
"border",
"=",
"None",
")",
":",
"if",
"border",
"is",
"None",
":",
"pass",
"elif",
"len",
"(",
"border",
")",
"==",
"2",
":",
"s0",
"=",
"slice",
"(",
"border",
"[",
"0",
"]",
"[",
"1",
"]",
",",
"border",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | SingleTimeEffectDetection.addImage | #########
mask -- optional | imgProcessor/features/SingleTimeEffectDetection.py | def addImage(self, image, mask=None):
'''
#########
mask -- optional
'''
self._last_diff = diff = image - self.noSTE
ste = diff > self.threshold
removeSinglePixels(ste)
self.mask_clean = clean = ~ste
if mask is not None:
... | def addImage(self, image, mask=None):
'''
#########
mask -- optional
'''
self._last_diff = diff = image - self.noSTE
ste = diff > self.threshold
removeSinglePixels(ste)
self.mask_clean = clean = ~ste
if mask is not None:
... | [
"#########",
"mask",
"--",
"optional"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/features/SingleTimeEffectDetection.py#L55-L75 | [
"def",
"addImage",
"(",
"self",
",",
"image",
",",
"mask",
"=",
"None",
")",
":",
"self",
".",
"_last_diff",
"=",
"diff",
"=",
"image",
"-",
"self",
".",
"noSTE",
"ste",
"=",
"diff",
">",
"self",
".",
"threshold",
"removeSinglePixels",
"(",
"ste",
")... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | SingleTimeEffectDetection.relativeAreaSTE | return STE area - relative to image area | imgProcessor/features/SingleTimeEffectDetection.py | def relativeAreaSTE(self):
'''
return STE area - relative to image area
'''
s = self.noSTE.shape
return np.sum(self.mask_STE) / (s[0] * s[1]) | def relativeAreaSTE(self):
'''
return STE area - relative to image area
'''
s = self.noSTE.shape
return np.sum(self.mask_STE) / (s[0] * s[1]) | [
"return",
"STE",
"area",
"-",
"relative",
"to",
"image",
"area"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/features/SingleTimeEffectDetection.py#L83-L88 | [
"def",
"relativeAreaSTE",
"(",
"self",
")",
":",
"s",
"=",
"self",
".",
"noSTE",
".",
"shape",
"return",
"np",
".",
"sum",
"(",
"self",
".",
"mask_STE",
")",
"/",
"(",
"s",
"[",
"0",
"]",
"*",
"s",
"[",
"1",
"]",
")"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | SingleTimeEffectDetection.intensityDistributionSTE | return distribution of STE intensity | imgProcessor/features/SingleTimeEffectDetection.py | def intensityDistributionSTE(self, bins=10, range=None):
'''
return distribution of STE intensity
'''
v = np.abs(self._last_diff[self.mask_STE])
return np.histogram(v, bins, range) | def intensityDistributionSTE(self, bins=10, range=None):
'''
return distribution of STE intensity
'''
v = np.abs(self._last_diff[self.mask_STE])
return np.histogram(v, bins, range) | [
"return",
"distribution",
"of",
"STE",
"intensity"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/features/SingleTimeEffectDetection.py#L90-L95 | [
"def",
"intensityDistributionSTE",
"(",
"self",
",",
"bins",
"=",
"10",
",",
"range",
"=",
"None",
")",
":",
"v",
"=",
"np",
".",
"abs",
"(",
"self",
".",
"_last_diff",
"[",
"self",
".",
"mask_STE",
"]",
")",
"return",
"np",
".",
"histogram",
"(",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | toUIntArray | transform a float to an unsigned integer array of a fitting dtype
adds an offset, to get rid of negative values
range = (min, max) - scale values between given range
cutNegative - all values <0 will be set to 0
cutHigh - set to False to rather scale values to fit | imgProcessor/transformations.py | def toUIntArray(img, dtype=None, cutNegative=True, cutHigh=True,
range=None, copy=True):
'''
transform a float to an unsigned integer array of a fitting dtype
adds an offset, to get rid of negative values
range = (min, max) - scale values between given range
cutNegative - a... | def toUIntArray(img, dtype=None, cutNegative=True, cutHigh=True,
range=None, copy=True):
'''
transform a float to an unsigned integer array of a fitting dtype
adds an offset, to get rid of negative values
range = (min, max) - scale values between given range
cutNegative - a... | [
"transform",
"a",
"float",
"to",
"an",
"unsigned",
"integer",
"array",
"of",
"a",
"fitting",
"dtype",
"adds",
"an",
"offset",
"to",
"get",
"rid",
"of",
"negative",
"values",
"range",
"=",
"(",
"min",
"max",
")",
"-",
"scale",
"values",
"between",
"given"... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transformations.py#L11-L75 | [
"def",
"toUIntArray",
"(",
"img",
",",
"dtype",
"=",
"None",
",",
"cutNegative",
"=",
"True",
",",
"cutHigh",
"=",
"True",
",",
"range",
"=",
"None",
",",
"copy",
"=",
"True",
")",
":",
"mn",
",",
"mx",
"=",
"None",
",",
"None",
"if",
"range",
"i... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | toFloatArray | transform an unsigned integer array into a
float array of the right size | imgProcessor/transformations.py | def toFloatArray(img):
'''
transform an unsigned integer array into a
float array of the right size
'''
_D = {1: np.float32, # uint8
2: np.float32, # uint16
4: np.float64, # uint32
8: np.float64} # uint64
return img.astype(_D[img.itemsize]) | def toFloatArray(img):
'''
transform an unsigned integer array into a
float array of the right size
'''
_D = {1: np.float32, # uint8
2: np.float32, # uint16
4: np.float64, # uint32
8: np.float64} # uint64
return img.astype(_D[img.itemsize]) | [
"transform",
"an",
"unsigned",
"integer",
"array",
"into",
"a",
"float",
"array",
"of",
"the",
"right",
"size"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transformations.py#L78-L87 | [
"def",
"toFloatArray",
"(",
"img",
")",
":",
"_D",
"=",
"{",
"1",
":",
"np",
".",
"float32",
",",
"# uint8\r",
"2",
":",
"np",
".",
"float32",
",",
"# uint16\r",
"4",
":",
"np",
".",
"float64",
",",
"# uint32\r",
"8",
":",
"np",
".",
"float64",
"... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | toNoUintArray | cast array to the next higher integer array
if dtype=unsigned integer | imgProcessor/transformations.py | def toNoUintArray(arr):
'''
cast array to the next higher integer array
if dtype=unsigned integer
'''
d = arr.dtype
if d.kind == 'u':
arr = arr.astype({1: np.int16,
2: np.int32,
4: np.int64}[d.itemsize])
return arr | def toNoUintArray(arr):
'''
cast array to the next higher integer array
if dtype=unsigned integer
'''
d = arr.dtype
if d.kind == 'u':
arr = arr.astype({1: np.int16,
2: np.int32,
4: np.int64}[d.itemsize])
return arr | [
"cast",
"array",
"to",
"the",
"next",
"higher",
"integer",
"array",
"if",
"dtype",
"=",
"unsigned",
"integer"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transformations.py#L90-L100 | [
"def",
"toNoUintArray",
"(",
"arr",
")",
":",
"d",
"=",
"arr",
".",
"dtype",
"if",
"d",
".",
"kind",
"==",
"'u'",
":",
"arr",
"=",
"arr",
".",
"astype",
"(",
"{",
"1",
":",
"np",
".",
"int16",
",",
"2",
":",
"np",
".",
"int32",
",",
"4",
":... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | toGray | weights see
https://en.wikipedia.org/wiki/Grayscale#Colorimetric_.28luminance-prese
http://docs.opencv.org/2.4/modules/imgproc/doc/miscellaneous_transformations.html#cvtcolor | imgProcessor/transformations.py | def toGray(img):
'''
weights see
https://en.wikipedia.org/wiki/Grayscale#Colorimetric_.28luminance-prese
http://docs.opencv.org/2.4/modules/imgproc/doc/miscellaneous_transformations.html#cvtcolor
'''
return np.average(img, axis=-1, weights=(0.299, # red
... | def toGray(img):
'''
weights see
https://en.wikipedia.org/wiki/Grayscale#Colorimetric_.28luminance-prese
http://docs.opencv.org/2.4/modules/imgproc/doc/miscellaneous_transformations.html#cvtcolor
'''
return np.average(img, axis=-1, weights=(0.299, # red
... | [
"weights",
"see",
"https",
":",
"//",
"en",
".",
"wikipedia",
".",
"org",
"/",
"wiki",
"/",
"Grayscale#Colorimetric_",
".",
"28luminance",
"-",
"prese",
"http",
":",
"//",
"docs",
".",
"opencv",
".",
"org",
"/",
"2",
".",
"4",
"/",
"modules",
"/",
"i... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transformations.py#L126-L135 | [
"def",
"toGray",
"(",
"img",
")",
":",
"return",
"np",
".",
"average",
"(",
"img",
",",
"axis",
"=",
"-",
"1",
",",
"weights",
"=",
"(",
"0.299",
",",
"# red\r",
"0.587",
",",
"# green\r",
"0.114",
")",
"# blue\r",
")",
".",
"astype",
"(",
"img",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | rgChromaticity | returns the normalized RGB space (RGB/intensity)
see https://en.wikipedia.org/wiki/Rg_chromaticity | imgProcessor/transformations.py | def rgChromaticity(img):
'''
returns the normalized RGB space (RGB/intensity)
see https://en.wikipedia.org/wiki/Rg_chromaticity
'''
out = _calc(img)
if img.dtype == np.uint8:
out = (255 * out).astype(np.uint8)
return out | def rgChromaticity(img):
'''
returns the normalized RGB space (RGB/intensity)
see https://en.wikipedia.org/wiki/Rg_chromaticity
'''
out = _calc(img)
if img.dtype == np.uint8:
out = (255 * out).astype(np.uint8)
return out | [
"returns",
"the",
"normalized",
"RGB",
"space",
"(",
"RGB",
"/",
"intensity",
")",
"see",
"https",
":",
"//",
"en",
".",
"wikipedia",
".",
"org",
"/",
"wiki",
"/",
"Rg_chromaticity"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transformations.py#L138-L146 | [
"def",
"rgChromaticity",
"(",
"img",
")",
":",
"out",
"=",
"_calc",
"(",
"img",
")",
"if",
"img",
".",
"dtype",
"==",
"np",
".",
"uint8",
":",
"out",
"=",
"(",
"255",
"*",
"out",
")",
".",
"astype",
"(",
"np",
".",
"uint8",
")",
"return",
"out"... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | monochromaticWavelength | TODO########## | imgProcessor/transformations.py | def monochromaticWavelength(img):
'''
TODO##########
'''
# peak wave lengths: https://en.wikipedia.org/wiki/RGB_color_model
out = _calc(img)
peakWavelengths = (570, 540, 440) # (r,g,b)
# s = sum(peakWavelengths)
for n, p in enumerate(peakWavelengths):
out[..., n] *= p... | def monochromaticWavelength(img):
'''
TODO##########
'''
# peak wave lengths: https://en.wikipedia.org/wiki/RGB_color_model
out = _calc(img)
peakWavelengths = (570, 540, 440) # (r,g,b)
# s = sum(peakWavelengths)
for n, p in enumerate(peakWavelengths):
out[..., n] *= p... | [
"TODO##########"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transformations.py#L157-L168 | [
"def",
"monochromaticWavelength",
"(",
"img",
")",
":",
"# peak wave lengths: https://en.wikipedia.org/wiki/RGB_color_model\r",
"out",
"=",
"_calc",
"(",
"img",
")",
"peakWavelengths",
"=",
"(",
"570",
",",
"540",
",",
"440",
")",
"# (r,g,b)\r",
"# s = sum(peakWavel... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | rot90 | rotate one or multiple grayscale or color images 90 degrees | imgProcessor/transformations.py | def rot90(img):
'''
rotate one or multiple grayscale or color images 90 degrees
'''
s = img.shape
if len(s) == 3:
if s[2] in (3, 4): # color image
out = np.empty((s[1], s[0], s[2]), dtype=img.dtype)
for i in range(s[2]):
out[:, :, i] = np.rot... | def rot90(img):
'''
rotate one or multiple grayscale or color images 90 degrees
'''
s = img.shape
if len(s) == 3:
if s[2] in (3, 4): # color image
out = np.empty((s[1], s[0], s[2]), dtype=img.dtype)
for i in range(s[2]):
out[:, :, i] = np.rot... | [
"rotate",
"one",
"or",
"multiple",
"grayscale",
"or",
"color",
"images",
"90",
"degrees"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transformations.py#L186-L209 | [
"def",
"rot90",
"(",
"img",
")",
":",
"s",
"=",
"img",
".",
"shape",
"if",
"len",
"(",
"s",
")",
"==",
"3",
":",
"if",
"s",
"[",
"2",
"]",
"in",
"(",
"3",
",",
"4",
")",
":",
"# color image\r",
"out",
"=",
"np",
".",
"empty",
"(",
"(",
"s... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | applyColorMap | like cv2.applyColorMap(im_gray, cv2.COLORMAP_*) but with different color maps | imgProcessor/transformations.py | def applyColorMap(gray, cmap='flame'):
'''
like cv2.applyColorMap(im_gray, cv2.COLORMAP_*) but with different color maps
'''
# TODO:implement more cmaps
if cmap != 'flame':
raise NotImplemented
# TODO: make better
mx = 256 # if gray.dtype==np.uint8 else 65535
lut = np.e... | def applyColorMap(gray, cmap='flame'):
'''
like cv2.applyColorMap(im_gray, cv2.COLORMAP_*) but with different color maps
'''
# TODO:implement more cmaps
if cmap != 'flame':
raise NotImplemented
# TODO: make better
mx = 256 # if gray.dtype==np.uint8 else 65535
lut = np.e... | [
"like",
"cv2",
".",
"applyColorMap",
"(",
"im_gray",
"cv2",
".",
"COLORMAP_",
"*",
")",
"but",
"with",
"different",
"color",
"maps"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transformations.py#L212-L246 | [
"def",
"applyColorMap",
"(",
"gray",
",",
"cmap",
"=",
"'flame'",
")",
":",
"# TODO:implement more cmaps\r",
"if",
"cmap",
"!=",
"'flame'",
":",
"raise",
"NotImplemented",
"# TODO: make better\r",
"mx",
"=",
"256",
"# if gray.dtype==np.uint8 else 65535\r",
"lut",
"=",... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | _insertDateIndex | returns the index to insert the given date in a list
where each items first value is a date | imgProcessor/camera/CameraCalibration.py | def _insertDateIndex(date, l):
'''
returns the index to insert the given date in a list
where each items first value is a date
'''
return next((i for i, n in enumerate(l) if n[0] < date), len(l)) | def _insertDateIndex(date, l):
'''
returns the index to insert the given date in a list
where each items first value is a date
'''
return next((i for i, n in enumerate(l) if n[0] < date), len(l)) | [
"returns",
"the",
"index",
"to",
"insert",
"the",
"given",
"date",
"in",
"a",
"list",
"where",
"each",
"items",
"first",
"value",
"is",
"a",
"date"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L29-L34 | [
"def",
"_insertDateIndex",
"(",
"date",
",",
"l",
")",
":",
"return",
"next",
"(",
"(",
"i",
"for",
"i",
",",
"n",
"in",
"enumerate",
"(",
"l",
")",
"if",
"n",
"[",
"0",
"]",
"<",
"date",
")",
",",
"len",
"(",
"l",
")",
")"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | _getFromDate | returns the index of given or best fitting date | imgProcessor/camera/CameraCalibration.py | def _getFromDate(l, date):
'''
returns the index of given or best fitting date
'''
try:
date = _toDate(date)
i = _insertDateIndex(date, l) - 1
if i == -1:
return l[0]
return l[i]
except (ValueError, TypeError):
# ValueError: date invalid... | def _getFromDate(l, date):
'''
returns the index of given or best fitting date
'''
try:
date = _toDate(date)
i = _insertDateIndex(date, l) - 1
if i == -1:
return l[0]
return l[i]
except (ValueError, TypeError):
# ValueError: date invalid... | [
"returns",
"the",
"index",
"of",
"given",
"or",
"best",
"fitting",
"date"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L37-L49 | [
"def",
"_getFromDate",
"(",
"l",
",",
"date",
")",
":",
"try",
":",
"date",
"=",
"_toDate",
"(",
"date",
")",
"i",
"=",
"_insertDateIndex",
"(",
"date",
",",
"l",
")",
"-",
"1",
"if",
"i",
"==",
"-",
"1",
":",
"return",
"l",
"[",
"0",
"]",
"r... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | CameraCalibration.dates | Args:
typ: type of calibration to look for. See .coeffs.keys() for all types available
light (Optional[str]): restrict to calibrations, done given light source
Returns:
list: All calibration dates available for given typ | imgProcessor/camera/CameraCalibration.py | def dates(self, typ, light=None):
'''
Args:
typ: type of calibration to look for. See .coeffs.keys() for all types available
light (Optional[str]): restrict to calibrations, done given light source
Returns:
list: All calibration dates available for giv... | def dates(self, typ, light=None):
'''
Args:
typ: type of calibration to look for. See .coeffs.keys() for all types available
light (Optional[str]): restrict to calibrations, done given light source
Returns:
list: All calibration dates available for giv... | [
"Args",
":",
"typ",
":",
"type",
"of",
"calibration",
"to",
"look",
"for",
".",
"See",
".",
"coeffs",
".",
"keys",
"()",
"for",
"all",
"types",
"available",
"light",
"(",
"Optional",
"[",
"str",
"]",
")",
":",
"restrict",
"to",
"calibrations",
"done",
... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L91-L104 | [
"def",
"dates",
"(",
"self",
",",
"typ",
",",
"light",
"=",
"None",
")",
":",
"try",
":",
"d",
"=",
"self",
".",
"_getDate",
"(",
"typ",
",",
"light",
")",
"return",
"[",
"self",
".",
"_toDateStr",
"(",
"c",
"[",
"0",
"]",
")",
"for",
"c",
"i... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | CameraCalibration.infos | Args:
typ: type of calibration to look for. See .coeffs.keys() for all types available
date (Optional[str]): date of calibration
Returns:
list: all infos available for given typ | imgProcessor/camera/CameraCalibration.py | def infos(self, typ, light=None, date=None):
'''
Args:
typ: type of calibration to look for. See .coeffs.keys() for all types available
date (Optional[str]): date of calibration
Returns:
list: all infos available for given typ
'''
d =... | def infos(self, typ, light=None, date=None):
'''
Args:
typ: type of calibration to look for. See .coeffs.keys() for all types available
date (Optional[str]): date of calibration
Returns:
list: all infos available for given typ
'''
d =... | [
"Args",
":",
"typ",
":",
"type",
"of",
"calibration",
"to",
"look",
"for",
".",
"See",
".",
"coeffs",
".",
"keys",
"()",
"for",
"all",
"types",
"available",
"date",
"(",
"Optional",
"[",
"str",
"]",
")",
":",
"date",
"of",
"calibration",
"Returns",
"... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L106-L119 | [
"def",
"infos",
"(",
"self",
",",
"typ",
",",
"light",
"=",
"None",
",",
"date",
"=",
"None",
")",
":",
"d",
"=",
"self",
".",
"_getDate",
"(",
"typ",
",",
"light",
")",
"if",
"date",
"is",
"None",
":",
"return",
"[",
"c",
"[",
"1",
"]",
"for... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | CameraCalibration.overview | Returns:
str: an overview covering all calibrations
infos and shapes | imgProcessor/camera/CameraCalibration.py | def overview(self):
'''
Returns:
str: an overview covering all calibrations
infos and shapes
'''
c = self.coeffs
out = 'camera name: %s' % c['name']
out += '\nmax value: %s' % c['depth']
out += '\nlight spectra: %s' % c['light spe... | def overview(self):
'''
Returns:
str: an overview covering all calibrations
infos and shapes
'''
c = self.coeffs
out = 'camera name: %s' % c['name']
out += '\nmax value: %s' % c['depth']
out += '\nlight spectra: %s' % c['light spe... | [
"Returns",
":",
"str",
":",
"an",
"overview",
"covering",
"all",
"calibrations",
"infos",
"and",
"shapes"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L121-L164 | [
"def",
"overview",
"(",
"self",
")",
":",
"c",
"=",
"self",
".",
"coeffs",
"out",
"=",
"'camera name: %s'",
"%",
"c",
"[",
"'name'",
"]",
"out",
"+=",
"'\\nmax value: %s'",
"%",
"c",
"[",
"'depth'",
"]",
"out",
"+=",
"'\\nlight spectra: %s'",
"%",
"c",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | CameraCalibration.setCamera | Args:
camera_name (str): Name of the camera
bit_depth (int): depth (bit) of the camera sensor | imgProcessor/camera/CameraCalibration.py | def setCamera(self, camera_name, bit_depth=16):
'''
Args:
camera_name (str): Name of the camera
bit_depth (int): depth (bit) of the camera sensor
'''
self.coeffs['name'] = camera_name
self.coeffs['depth'] = bit_depth | def setCamera(self, camera_name, bit_depth=16):
'''
Args:
camera_name (str): Name of the camera
bit_depth (int): depth (bit) of the camera sensor
'''
self.coeffs['name'] = camera_name
self.coeffs['depth'] = bit_depth | [
"Args",
":",
"camera_name",
"(",
"str",
")",
":",
"Name",
"of",
"the",
"camera",
"bit_depth",
"(",
"int",
")",
":",
"depth",
"(",
"bit",
")",
"of",
"the",
"camera",
"sensor"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L178-L185 | [
"def",
"setCamera",
"(",
"self",
",",
"camera_name",
",",
"bit_depth",
"=",
"16",
")",
":",
"self",
".",
"coeffs",
"[",
"'name'",
"]",
"=",
"camera_name",
"self",
".",
"coeffs",
"[",
"'depth'",
"]",
"=",
"bit_depth"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | CameraCalibration.addDarkCurrent | Args:
slope (np.array)
intercept (np.array)
error (numpy.array)
slope (float): dPx/dExposureTime[sec]
error (float): absolute
date (str): "DD Mon YY" e.g. "30 Nov 16" | imgProcessor/camera/CameraCalibration.py | def addDarkCurrent(self, slope, intercept=None, date=None, info='', error=None):
'''
Args:
slope (np.array)
intercept (np.array)
error (numpy.array)
slope (float): dPx/dExposureTime[sec]
error (float): absolute
date (str): "... | def addDarkCurrent(self, slope, intercept=None, date=None, info='', error=None):
'''
Args:
slope (np.array)
intercept (np.array)
error (numpy.array)
slope (float): dPx/dExposureTime[sec]
error (float): absolute
date (str): "... | [
"Args",
":",
"slope",
"(",
"np",
".",
"array",
")",
"intercept",
"(",
"np",
".",
"array",
")",
"error",
"(",
"numpy",
".",
"array",
")",
"slope",
"(",
"float",
")",
":",
"dPx",
"/",
"dExposureTime",
"[",
"sec",
"]",
"error",
"(",
"float",
")",
":... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L187-L207 | [
"def",
"addDarkCurrent",
"(",
"self",
",",
"slope",
",",
"intercept",
"=",
"None",
",",
"date",
"=",
"None",
",",
"info",
"=",
"''",
",",
"error",
"=",
"None",
")",
":",
"date",
"=",
"_toDate",
"(",
"date",
")",
"self",
".",
"_checkShape",
"(",
"sl... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | CameraCalibration.addNoise | Args:
nlf_coeff (list)
error (float): absolute
info (str): additional information
date (str): "DD Mon YY" e.g. "30 Nov 16" | imgProcessor/camera/CameraCalibration.py | def addNoise(self, nlf_coeff, date=None, info='', error=None):
'''
Args:
nlf_coeff (list)
error (float): absolute
info (str): additional information
date (str): "DD Mon YY" e.g. "30 Nov 16"
'''
date = _toDate(date)
d = self... | def addNoise(self, nlf_coeff, date=None, info='', error=None):
'''
Args:
nlf_coeff (list)
error (float): absolute
info (str): additional information
date (str): "DD Mon YY" e.g. "30 Nov 16"
'''
date = _toDate(date)
d = self... | [
"Args",
":",
"nlf_coeff",
"(",
"list",
")",
"error",
"(",
"float",
")",
":",
"absolute",
"info",
"(",
"str",
")",
":",
"additional",
"information",
"date",
"(",
"str",
")",
":",
"DD",
"Mon",
"YY",
"e",
".",
"g",
".",
"30",
"Nov",
"16"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L209-L219 | [
"def",
"addNoise",
"(",
"self",
",",
"nlf_coeff",
",",
"date",
"=",
"None",
",",
"info",
"=",
"''",
",",
"error",
"=",
"None",
")",
":",
"date",
"=",
"_toDate",
"(",
"date",
")",
"d",
"=",
"self",
".",
"coeffs",
"[",
"'noise'",
"]",
"d",
".",
"... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | CameraCalibration.addPSF | add a new point spread function | imgProcessor/camera/CameraCalibration.py | def addPSF(self, psf, date=None, info='', light_spectrum='visible'):
'''
add a new point spread function
'''
self._registerLight(light_spectrum)
date = _toDate(date)
f = self.coeffs['psf']
if light_spectrum not in f:
f[light_spectrum] = []
... | def addPSF(self, psf, date=None, info='', light_spectrum='visible'):
'''
add a new point spread function
'''
self._registerLight(light_spectrum)
date = _toDate(date)
f = self.coeffs['psf']
if light_spectrum not in f:
f[light_spectrum] = []
... | [
"add",
"a",
"new",
"point",
"spread",
"function"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L232-L243 | [
"def",
"addPSF",
"(",
"self",
",",
"psf",
",",
"date",
"=",
"None",
",",
"info",
"=",
"''",
",",
"light_spectrum",
"=",
"'visible'",
")",
":",
"self",
".",
"_registerLight",
"(",
"light_spectrum",
")",
"date",
"=",
"_toDate",
"(",
"date",
")",
"f",
"... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | CameraCalibration.addFlatField | light_spectrum = light, IR ... | imgProcessor/camera/CameraCalibration.py | def addFlatField(self, arr, date=None, info='', error=None,
light_spectrum='visible'):
'''
light_spectrum = light, IR ...
'''
self._registerLight(light_spectrum)
self._checkShape(arr)
date = _toDate(date)
f = self.coeffs['flat field']
... | def addFlatField(self, arr, date=None, info='', error=None,
light_spectrum='visible'):
'''
light_spectrum = light, IR ...
'''
self._registerLight(light_spectrum)
self._checkShape(arr)
date = _toDate(date)
f = self.coeffs['flat field']
... | [
"light_spectrum",
"=",
"light",
"IR",
"..."
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L255-L267 | [
"def",
"addFlatField",
"(",
"self",
",",
"arr",
",",
"date",
"=",
"None",
",",
"info",
"=",
"''",
",",
"error",
"=",
"None",
",",
"light_spectrum",
"=",
"'visible'",
")",
":",
"self",
".",
"_registerLight",
"(",
"light_spectrum",
")",
"self",
".",
"_ch... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | CameraCalibration.addLens | lens -> instance of LensDistortion or saved file | imgProcessor/camera/CameraCalibration.py | def addLens(self, lens, date=None, info='', light_spectrum='visible'):
'''
lens -> instance of LensDistortion or saved file
'''
self._registerLight(light_spectrum)
date = _toDate(date)
if not isinstance(lens, LensDistortion):
l = LensDistortion()
... | def addLens(self, lens, date=None, info='', light_spectrum='visible'):
'''
lens -> instance of LensDistortion or saved file
'''
self._registerLight(light_spectrum)
date = _toDate(date)
if not isinstance(lens, LensDistortion):
l = LensDistortion()
... | [
"lens",
"-",
">",
"instance",
"of",
"LensDistortion",
"or",
"saved",
"file"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L269-L285 | [
"def",
"addLens",
"(",
"self",
",",
"lens",
",",
"date",
"=",
"None",
",",
"info",
"=",
"''",
",",
"light_spectrum",
"=",
"'visible'",
")",
":",
"self",
".",
"_registerLight",
"(",
"light_spectrum",
")",
"date",
"=",
"_toDate",
"(",
"date",
")",
"if",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | CameraCalibration.clearOldCalibrations | if not only a specific date than remove all except of the youngest calibration | imgProcessor/camera/CameraCalibration.py | def clearOldCalibrations(self, date=None):
'''
if not only a specific date than remove all except of the youngest calibration
'''
self.coeffs['dark current'] = [self.coeffs['dark current'][-1]]
self.coeffs['noise'] = [self.coeffs['noise'][-1]]
for light in self.co... | def clearOldCalibrations(self, date=None):
'''
if not only a specific date than remove all except of the youngest calibration
'''
self.coeffs['dark current'] = [self.coeffs['dark current'][-1]]
self.coeffs['noise'] = [self.coeffs['noise'][-1]]
for light in self.co... | [
"if",
"not",
"only",
"a",
"specific",
"date",
"than",
"remove",
"all",
"except",
"of",
"the",
"youngest",
"calibration"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L287-L298 | [
"def",
"clearOldCalibrations",
"(",
"self",
",",
"date",
"=",
"None",
")",
":",
"self",
".",
"coeffs",
"[",
"'dark current'",
"]",
"=",
"[",
"self",
".",
"coeffs",
"[",
"'dark current'",
"]",
"[",
"-",
"1",
"]",
"]",
"self",
".",
"coeffs",
"[",
"'noi... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | CameraCalibration.transpose | transpose all calibration arrays
in case different array shape orders were used (x,y) vs. (y,x) | imgProcessor/camera/CameraCalibration.py | def transpose(self):
'''
transpose all calibration arrays
in case different array shape orders were used (x,y) vs. (y,x)
'''
def _t(item):
if type(item) == list:
for n, it in enumerate(item):
if type(it) == tuple:
... | def transpose(self):
'''
transpose all calibration arrays
in case different array shape orders were used (x,y) vs. (y,x)
'''
def _t(item):
if type(item) == list:
for n, it in enumerate(item):
if type(it) == tuple:
... | [
"transpose",
"all",
"calibration",
"arrays",
"in",
"case",
"different",
"array",
"shape",
"orders",
"were",
"used",
"(",
"x",
"y",
")",
"vs",
".",
"(",
"y",
"x",
")"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L324-L349 | [
"def",
"transpose",
"(",
"self",
")",
":",
"def",
"_t",
"(",
"item",
")",
":",
"if",
"type",
"(",
"item",
")",
"==",
"list",
":",
"for",
"n",
",",
"it",
"in",
"enumerate",
"(",
"item",
")",
":",
"if",
"type",
"(",
"it",
")",
"==",
"tuple",
":... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | CameraCalibration.correct | exposure_time [s]
date -> string e.g. '30. Nov 15' to get a calibration on from date
-> {'dark current':'30. Nov 15',
'flat field':'15. Nov 15',
'lens':'14. Nov 15',
'noise':'01. Nov 15'} | imgProcessor/camera/CameraCalibration.py | def correct(self, images,
bgImages=None,
exposure_time=None,
light_spectrum=None,
threshold=0.1,
keep_size=True,
date=None,
deblur=False,
denoise=False):
'''
exposure... | def correct(self, images,
bgImages=None,
exposure_time=None,
light_spectrum=None,
threshold=0.1,
keep_size=True,
date=None,
deblur=False,
denoise=False):
'''
exposure... | [
"exposure_time",
"[",
"s",
"]",
"date",
"-",
">",
"string",
"e",
".",
"g",
".",
"30",
".",
"Nov",
"15",
"to",
"get",
"a",
"calibration",
"on",
"from",
"date",
"-",
">",
"{",
"dark",
"current",
":",
"30",
".",
"Nov",
"15",
"flat",
"field",
":",
... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L351-L459 | [
"def",
"correct",
"(",
"self",
",",
"images",
",",
"bgImages",
"=",
"None",
",",
"exposure_time",
"=",
"None",
",",
"light_spectrum",
"=",
"None",
",",
"threshold",
"=",
"0.1",
",",
"keep_size",
"=",
"True",
",",
"date",
"=",
"None",
",",
"deblur",
"="... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | CameraCalibration._correctNoise | denoise using non-local-means
with guessing best parameters | imgProcessor/camera/CameraCalibration.py | def _correctNoise(self, image):
'''
denoise using non-local-means
with guessing best parameters
'''
from skimage.restoration import denoise_nl_means # save startup time
image[np.isnan(image)] = 0 # otherwise result =nan
out = denoise_nl_means(image,
... | def _correctNoise(self, image):
'''
denoise using non-local-means
with guessing best parameters
'''
from skimage.restoration import denoise_nl_means # save startup time
image[np.isnan(image)] = 0 # otherwise result =nan
out = denoise_nl_means(image,
... | [
"denoise",
"using",
"non",
"-",
"local",
"-",
"means",
"with",
"guessing",
"best",
"parameters"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L461-L474 | [
"def",
"_correctNoise",
"(",
"self",
",",
"image",
")",
":",
"from",
"skimage",
".",
"restoration",
"import",
"denoise_nl_means",
"# save startup time\r",
"image",
"[",
"np",
".",
"isnan",
"(",
"image",
")",
"]",
"=",
"0",
"# otherwise result =nan\r",
"out",
"... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | CameraCalibration._correctDarkCurrent | open OR calculate a background image: f(t)=m*t+n | imgProcessor/camera/CameraCalibration.py | def _correctDarkCurrent(self, image, exposuretime, bgImages, date):
'''
open OR calculate a background image: f(t)=m*t+n
'''
# either exposureTime or bgImages has to be given
# if exposuretime is not None or bgImages is not None:
print('... remove dark current')
... | def _correctDarkCurrent(self, image, exposuretime, bgImages, date):
'''
open OR calculate a background image: f(t)=m*t+n
'''
# either exposureTime or bgImages has to be given
# if exposuretime is not None or bgImages is not None:
print('... remove dark current')
... | [
"open",
"OR",
"calculate",
"a",
"background",
"image",
":",
"f",
"(",
"t",
")",
"=",
"m",
"*",
"t",
"+",
"n"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L476-L502 | [
"def",
"_correctDarkCurrent",
"(",
"self",
",",
"image",
",",
"exposuretime",
",",
"bgImages",
",",
"date",
")",
":",
"# either exposureTime or bgImages has to be given\r",
"# if exposuretime is not None or bgImages is not None:\r",
"print",
"(",
"'... remove dark current... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | CameraCalibration._correctArtefacts | Apply a thresholded median replacing high gradients
and values beyond the boundaries | imgProcessor/camera/CameraCalibration.py | def _correctArtefacts(self, image, threshold):
'''
Apply a thresholded median replacing high gradients
and values beyond the boundaries
'''
image = np.nan_to_num(image)
medianThreshold(image, threshold, copy=False)
return image | def _correctArtefacts(self, image, threshold):
'''
Apply a thresholded median replacing high gradients
and values beyond the boundaries
'''
image = np.nan_to_num(image)
medianThreshold(image, threshold, copy=False)
return image | [
"Apply",
"a",
"thresholded",
"median",
"replacing",
"high",
"gradients",
"and",
"values",
"beyond",
"the",
"boundaries"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L556-L563 | [
"def",
"_correctArtefacts",
"(",
"self",
",",
"image",
",",
"threshold",
")",
":",
"image",
"=",
"np",
".",
"nan_to_num",
"(",
"image",
")",
"medianThreshold",
"(",
"image",
",",
"threshold",
",",
"copy",
"=",
"False",
")",
"return",
"image"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | CameraCalibration.getCoeff | try to get calibration for right light source, but
use another if they is none existent | imgProcessor/camera/CameraCalibration.py | def getCoeff(self, name, light=None, date=None):
'''
try to get calibration for right light source, but
use another if they is none existent
'''
d = self.coeffs[name]
try:
c = d[light]
except KeyError:
try:
k, i ... | def getCoeff(self, name, light=None, date=None):
'''
try to get calibration for right light source, but
use another if they is none existent
'''
d = self.coeffs[name]
try:
c = d[light]
except KeyError:
try:
k, i ... | [
"try",
"to",
"get",
"calibration",
"for",
"right",
"light",
"source",
"but",
"use",
"another",
"if",
"they",
"is",
"none",
"existent"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L590-L611 | [
"def",
"getCoeff",
"(",
"self",
",",
"name",
",",
"light",
"=",
"None",
",",
"date",
"=",
"None",
")",
":",
"d",
"=",
"self",
".",
"coeffs",
"[",
"name",
"]",
"try",
":",
"c",
"=",
"d",
"[",
"light",
"]",
"except",
"KeyError",
":",
"try",
":",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | vignettingFromRandomSteps | important: first image should shown most iof the device
because it is used as reference | imgProcessor/camera/flatField/vignettingFromRandomSteps.py | def vignettingFromRandomSteps(imgs, bg, inPlane_scale_factor=None,
debugFolder=None, **kwargs):
'''
important: first image should shown most iof the device
because it is used as reference
'''
# TODO: inPlane_scale_factor
if debugFolder:
debugFolder =... | def vignettingFromRandomSteps(imgs, bg, inPlane_scale_factor=None,
debugFolder=None, **kwargs):
'''
important: first image should shown most iof the device
because it is used as reference
'''
# TODO: inPlane_scale_factor
if debugFolder:
debugFolder =... | [
"important",
":",
"first",
"image",
"should",
"shown",
"most",
"iof",
"the",
"device",
"because",
"it",
"is",
"used",
"as",
"reference"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/flatField/vignettingFromRandomSteps.py#L324-L352 | [
"def",
"vignettingFromRandomSteps",
"(",
"imgs",
",",
"bg",
",",
"inPlane_scale_factor",
"=",
"None",
",",
"debugFolder",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# TODO: inPlane_scale_factor\r",
"if",
"debugFolder",
":",
"debugFolder",
"=",
"PathStr",
"... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.