repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
kolypto/py-flask-jsontools | flask_jsontools/decorators.py | jsonapi | def jsonapi(f):
""" Declare the view as a JSON API method
This converts view return value into a :cls:JsonResponse.
The following return types are supported:
- tuple: a tuple of (response, status, headers)
- any other object is converted to JSON
"""
@wraps(f)
de... | python | def jsonapi(f):
""" Declare the view as a JSON API method
This converts view return value into a :cls:JsonResponse.
The following return types are supported:
- tuple: a tuple of (response, status, headers)
- any other object is converted to JSON
"""
@wraps(f)
de... | [
"def",
"jsonapi",
"(",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"rv",
"=",
"f",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"return",
"make_json_response",
"(",
"rv",... | Declare the view as a JSON API method
This converts view return value into a :cls:JsonResponse.
The following return types are supported:
- tuple: a tuple of (response, status, headers)
- any other object is converted to JSON | [
"Declare",
"the",
"view",
"as",
"a",
"JSON",
"API",
"method"
] | 1abee2d40e6db262e43f0c534e90faaa9b26246a | https://github.com/kolypto/py-flask-jsontools/blob/1abee2d40e6db262e43f0c534e90faaa9b26246a/flask_jsontools/decorators.py#L6-L19 | train |
pyinvoke/invocations | invocations/packaging/vendorize.py | _unpack | def _unpack(c, tmp, package, version, git_url=None):
"""
Download + unpack given package into temp dir ``tmp``.
Return ``(real_version, source)`` where ``real_version`` is the "actual"
version downloaded (e.g. if a Git master was indicated, it will be the SHA
of master HEAD) and ``source`` is the s... | python | def _unpack(c, tmp, package, version, git_url=None):
"""
Download + unpack given package into temp dir ``tmp``.
Return ``(real_version, source)`` where ``real_version`` is the "actual"
version downloaded (e.g. if a Git master was indicated, it will be the SHA
of master HEAD) and ``source`` is the s... | [
"def",
"_unpack",
"(",
"c",
",",
"tmp",
",",
"package",
",",
"version",
",",
"git_url",
"=",
"None",
")",
":",
"real_version",
"=",
"version",
"[",
":",
"]",
"source",
"=",
"None",
"if",
"git_url",
":",
"pass",
"# git clone into tempdir",
"# git checko... | Download + unpack given package into temp dir ``tmp``.
Return ``(real_version, source)`` where ``real_version`` is the "actual"
version downloaded (e.g. if a Git master was indicated, it will be the SHA
of master HEAD) and ``source`` is the source directory (relative to
unpacked source) to import into ... | [
"Download",
"+",
"unpack",
"given",
"package",
"into",
"temp",
"dir",
"tmp",
"."
] | bbf1b319bd1536817d5301ceb9eeb2f31830e5dc | https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/packaging/vendorize.py#L13-L60 | train |
pyinvoke/invocations | invocations/packaging/vendorize.py | vendorize | def vendorize(
c,
distribution,
version,
vendor_dir,
package=None,
git_url=None,
license=None,
):
"""
Vendorize Python package ``distribution`` at version/SHA ``version``.
Specify the vendor folder (e.g. ``<mypackage>/vendor``) as ``vendor_dir``.
For Crate/PyPI releases, ``... | python | def vendorize(
c,
distribution,
version,
vendor_dir,
package=None,
git_url=None,
license=None,
):
"""
Vendorize Python package ``distribution`` at version/SHA ``version``.
Specify the vendor folder (e.g. ``<mypackage>/vendor``) as ``vendor_dir``.
For Crate/PyPI releases, ``... | [
"def",
"vendorize",
"(",
"c",
",",
"distribution",
",",
"version",
",",
"vendor_dir",
",",
"package",
"=",
"None",
",",
"git_url",
"=",
"None",
",",
"license",
"=",
"None",
",",
")",
":",
"with",
"tmpdir",
"(",
")",
"as",
"tmp",
":",
"package",
"=",
... | Vendorize Python package ``distribution`` at version/SHA ``version``.
Specify the vendor folder (e.g. ``<mypackage>/vendor``) as ``vendor_dir``.
For Crate/PyPI releases, ``package`` should be the name of the software
entry on those sites, and ``version`` should be a specific version number.
E.g. ``ven... | [
"Vendorize",
"Python",
"package",
"distribution",
"at",
"version",
"/",
"SHA",
"version",
"."
] | bbf1b319bd1536817d5301ceb9eeb2f31830e5dc | https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/packaging/vendorize.py#L64-L118 | train |
pyinvoke/invocations | invocations/travis.py | make_sudouser | def make_sudouser(c):
"""
Create a passworded sudo-capable user.
Used by other tasks to execute the test suite so sudo tests work.
"""
user = c.travis.sudo.user
password = c.travis.sudo.password
# --create-home because we need a place to put conf files, keys etc
# --groups travis becaus... | python | def make_sudouser(c):
"""
Create a passworded sudo-capable user.
Used by other tasks to execute the test suite so sudo tests work.
"""
user = c.travis.sudo.user
password = c.travis.sudo.password
# --create-home because we need a place to put conf files, keys etc
# --groups travis becaus... | [
"def",
"make_sudouser",
"(",
"c",
")",
":",
"user",
"=",
"c",
".",
"travis",
".",
"sudo",
".",
"user",
"password",
"=",
"c",
".",
"travis",
".",
"sudo",
".",
"password",
"# --create-home because we need a place to put conf files, keys etc",
"# --groups travis becaus... | Create a passworded sudo-capable user.
Used by other tasks to execute the test suite so sudo tests work. | [
"Create",
"a",
"passworded",
"sudo",
"-",
"capable",
"user",
"."
] | bbf1b319bd1536817d5301ceb9eeb2f31830e5dc | https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/travis.py#L26-L49 | train |
pyinvoke/invocations | invocations/travis.py | make_sshable | def make_sshable(c):
"""
Set up passwordless SSH keypair & authorized_hosts access to localhost.
"""
user = c.travis.sudo.user
home = "~{0}".format(user)
# Run sudo() as the new sudo user; means less chown'ing, etc.
c.config.sudo.user = user
ssh_dir = "{0}/.ssh".format(home)
# TODO: ... | python | def make_sshable(c):
"""
Set up passwordless SSH keypair & authorized_hosts access to localhost.
"""
user = c.travis.sudo.user
home = "~{0}".format(user)
# Run sudo() as the new sudo user; means less chown'ing, etc.
c.config.sudo.user = user
ssh_dir = "{0}/.ssh".format(home)
# TODO: ... | [
"def",
"make_sshable",
"(",
"c",
")",
":",
"user",
"=",
"c",
".",
"travis",
".",
"sudo",
".",
"user",
"home",
"=",
"\"~{0}\"",
".",
"format",
"(",
"user",
")",
"# Run sudo() as the new sudo user; means less chown'ing, etc.",
"c",
".",
"config",
".",
"sudo",
... | Set up passwordless SSH keypair & authorized_hosts access to localhost. | [
"Set",
"up",
"passwordless",
"SSH",
"keypair",
"&",
"authorized_hosts",
"access",
"to",
"localhost",
"."
] | bbf1b319bd1536817d5301ceb9eeb2f31830e5dc | https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/travis.py#L55-L68 | train |
pyinvoke/invocations | invocations/travis.py | sudo_run | def sudo_run(c, command):
"""
Run some command under Travis-oriented sudo subshell/virtualenv.
:param str command:
Command string to run, e.g. ``inv coverage``, ``inv integration``, etc.
(Does not necessarily need to be an Invoke task, but...)
"""
# NOTE: explicit shell wrapper beca... | python | def sudo_run(c, command):
"""
Run some command under Travis-oriented sudo subshell/virtualenv.
:param str command:
Command string to run, e.g. ``inv coverage``, ``inv integration``, etc.
(Does not necessarily need to be an Invoke task, but...)
"""
# NOTE: explicit shell wrapper beca... | [
"def",
"sudo_run",
"(",
"c",
",",
"command",
")",
":",
"# NOTE: explicit shell wrapper because sourcing the venv works best here;",
"# test tasks currently use their own subshell to call e.g. 'pytest --blah',",
"# so the tactic of '$VIRTUAL_ENV/bin/inv coverage' doesn't help - only that",
"# i... | Run some command under Travis-oriented sudo subshell/virtualenv.
:param str command:
Command string to run, e.g. ``inv coverage``, ``inv integration``, etc.
(Does not necessarily need to be an Invoke task, but...) | [
"Run",
"some",
"command",
"under",
"Travis",
"-",
"oriented",
"sudo",
"subshell",
"/",
"virtualenv",
"."
] | bbf1b319bd1536817d5301ceb9eeb2f31830e5dc | https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/travis.py#L72-L85 | train |
pyinvoke/invocations | invocations/travis.py | blacken | def blacken(c):
"""
Install and execute ``black`` under appropriate circumstances, with diffs.
Installs and runs ``black`` under Python 3.6 (the first version it
supports). Since this sort of CI based task only needs to run once per
commit (formatting is not going to change between interpreters) th... | python | def blacken(c):
"""
Install and execute ``black`` under appropriate circumstances, with diffs.
Installs and runs ``black`` under Python 3.6 (the first version it
supports). Since this sort of CI based task only needs to run once per
commit (formatting is not going to change between interpreters) th... | [
"def",
"blacken",
"(",
"c",
")",
":",
"if",
"not",
"PYTHON",
".",
"startswith",
"(",
"\"3.6\"",
")",
":",
"msg",
"=",
"\"Not blackening, since Python {} != Python 3.6\"",
".",
"format",
"(",
"PYTHON",
")",
"print",
"(",
"msg",
",",
"file",
"=",
"sys",
".",... | Install and execute ``black`` under appropriate circumstances, with diffs.
Installs and runs ``black`` under Python 3.6 (the first version it
supports). Since this sort of CI based task only needs to run once per
commit (formatting is not going to change between interpreters) this seems
like a worthwhi... | [
"Install",
"and",
"execute",
"black",
"under",
"appropriate",
"circumstances",
"with",
"diffs",
"."
] | bbf1b319bd1536817d5301ceb9eeb2f31830e5dc | https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/travis.py#L166-L190 | train |
pysal/giddy | giddy/rank.py | Tau._calc | def _calc(self, x, y):
"""
List based implementation of binary tree algorithm for concordance
measure after :cite:`Christensen2005`.
"""
x = np.array(x)
y = np.array(y)
n = len(y)
perm = list(range(n))
perm.sort(key=lambda a: (x[a], y[a]))
... | python | def _calc(self, x, y):
"""
List based implementation of binary tree algorithm for concordance
measure after :cite:`Christensen2005`.
"""
x = np.array(x)
y = np.array(y)
n = len(y)
perm = list(range(n))
perm.sort(key=lambda a: (x[a], y[a]))
... | [
"def",
"_calc",
"(",
"self",
",",
"x",
",",
"y",
")",
":",
"x",
"=",
"np",
".",
"array",
"(",
"x",
")",
"y",
"=",
"np",
".",
"array",
"(",
"y",
")",
"n",
"=",
"len",
"(",
"y",
")",
"perm",
"=",
"list",
"(",
"range",
"(",
"n",
")",
")",
... | List based implementation of binary tree algorithm for concordance
measure after :cite:`Christensen2005`. | [
"List",
"based",
"implementation",
"of",
"binary",
"tree",
"algorithm",
"for",
"concordance",
"measure",
"after",
":",
"cite",
":",
"Christensen2005",
"."
] | 13fae6c18933614be78e91a6b5060693bea33a04 | https://github.com/pysal/giddy/blob/13fae6c18933614be78e91a6b5060693bea33a04/giddy/rank.py#L171-L261 | train |
kolypto/py-flask-jsontools | flask_jsontools/views.py | _MethodViewInfo.decorator | def decorator(self, func):
""" Wrapper function to decorate a function """
if inspect.isfunction(func):
func._methodview = self
elif inspect.ismethod(func):
func.__func__._methodview = self
else:
raise AssertionError('Can only decorate function and met... | python | def decorator(self, func):
""" Wrapper function to decorate a function """
if inspect.isfunction(func):
func._methodview = self
elif inspect.ismethod(func):
func.__func__._methodview = self
else:
raise AssertionError('Can only decorate function and met... | [
"def",
"decorator",
"(",
"self",
",",
"func",
")",
":",
"if",
"inspect",
".",
"isfunction",
"(",
"func",
")",
":",
"func",
".",
"_methodview",
"=",
"self",
"elif",
"inspect",
".",
"ismethod",
"(",
"func",
")",
":",
"func",
".",
"__func__",
".",
"_met... | Wrapper function to decorate a function | [
"Wrapper",
"function",
"to",
"decorate",
"a",
"function"
] | 1abee2d40e6db262e43f0c534e90faaa9b26246a | https://github.com/kolypto/py-flask-jsontools/blob/1abee2d40e6db262e43f0c534e90faaa9b26246a/flask_jsontools/views.py#L30-L38 | train |
kolypto/py-flask-jsontools | flask_jsontools/views.py | _MethodViewInfo.matches | def matches(self, verb, params):
""" Test if the method matches the provided set of arguments
:param verb: HTTP verb. Uppercase
:type verb: str
:param params: Existing route parameters
:type params: set
:returns: Whether this view matches
:rtype: bool
"""... | python | def matches(self, verb, params):
""" Test if the method matches the provided set of arguments
:param verb: HTTP verb. Uppercase
:type verb: str
:param params: Existing route parameters
:type params: set
:returns: Whether this view matches
:rtype: bool
"""... | [
"def",
"matches",
"(",
"self",
",",
"verb",
",",
"params",
")",
":",
"return",
"(",
"self",
".",
"ifset",
"is",
"None",
"or",
"self",
".",
"ifset",
"<=",
"params",
")",
"and",
"(",
"self",
".",
"ifnset",
"is",
"None",
"or",
"self",
".",
"ifnset",
... | Test if the method matches the provided set of arguments
:param verb: HTTP verb. Uppercase
:type verb: str
:param params: Existing route parameters
:type params: set
:returns: Whether this view matches
:rtype: bool | [
"Test",
"if",
"the",
"method",
"matches",
"the",
"provided",
"set",
"of",
"arguments"
] | 1abee2d40e6db262e43f0c534e90faaa9b26246a | https://github.com/kolypto/py-flask-jsontools/blob/1abee2d40e6db262e43f0c534e90faaa9b26246a/flask_jsontools/views.py#L63-L75 | train |
kolypto/py-flask-jsontools | flask_jsontools/views.py | MethodView._match_view | def _match_view(self, method, route_params):
""" Detect a view matching the query
:param method: HTTP method
:param route_params: Route parameters dict
:return: Method
:rtype: Callable|None
"""
method = method.upper()
route_params = frozenset(k for k, v i... | python | def _match_view(self, method, route_params):
""" Detect a view matching the query
:param method: HTTP method
:param route_params: Route parameters dict
:return: Method
:rtype: Callable|None
"""
method = method.upper()
route_params = frozenset(k for k, v i... | [
"def",
"_match_view",
"(",
"self",
",",
"method",
",",
"route_params",
")",
":",
"method",
"=",
"method",
".",
"upper",
"(",
")",
"route_params",
"=",
"frozenset",
"(",
"k",
"for",
"k",
",",
"v",
"in",
"route_params",
".",
"items",
"(",
")",
"if",
"v... | Detect a view matching the query
:param method: HTTP method
:param route_params: Route parameters dict
:return: Method
:rtype: Callable|None | [
"Detect",
"a",
"view",
"matching",
"the",
"query"
] | 1abee2d40e6db262e43f0c534e90faaa9b26246a | https://github.com/kolypto/py-flask-jsontools/blob/1abee2d40e6db262e43f0c534e90faaa9b26246a/flask_jsontools/views.py#L112-L127 | train |
kolypto/py-flask-jsontools | flask_jsontools/views.py | MethodView.route_as_view | def route_as_view(cls, app, name, rules, *class_args, **class_kwargs):
""" Register the view with an URL route
:param app: Flask application
:type app: flask.Flask|flask.Blueprint
:param name: Unique view name
:type name: str
:param rules: List of route rules to use
... | python | def route_as_view(cls, app, name, rules, *class_args, **class_kwargs):
""" Register the view with an URL route
:param app: Flask application
:type app: flask.Flask|flask.Blueprint
:param name: Unique view name
:type name: str
:param rules: List of route rules to use
... | [
"def",
"route_as_view",
"(",
"cls",
",",
"app",
",",
"name",
",",
"rules",
",",
"*",
"class_args",
",",
"*",
"*",
"class_kwargs",
")",
":",
"view",
"=",
"super",
"(",
"MethodView",
",",
"cls",
")",
".",
"as_view",
"(",
"name",
",",
"*",
"class_args",... | Register the view with an URL route
:param app: Flask application
:type app: flask.Flask|flask.Blueprint
:param name: Unique view name
:type name: str
:param rules: List of route rules to use
:type rules: Iterable[str|werkzeug.routing.Rule]
:param class_args: Args... | [
"Register",
"the",
"view",
"with",
"an",
"URL",
"route",
":",
"param",
"app",
":",
"Flask",
"application",
":",
"type",
"app",
":",
"flask",
".",
"Flask|flask",
".",
"Blueprint",
":",
"param",
"name",
":",
"Unique",
"view",
"name",
":",
"type",
"name",
... | 1abee2d40e6db262e43f0c534e90faaa9b26246a | https://github.com/kolypto/py-flask-jsontools/blob/1abee2d40e6db262e43f0c534e90faaa9b26246a/flask_jsontools/views.py#L136-L152 | train |
pysal/giddy | giddy/ergodic.py | steady_state | def steady_state(P):
"""
Calculates the steady state probability vector for a regular Markov
transition matrix P.
Parameters
----------
P : array
(k, k), an ergodic Markov transition probability matrix.
Returns
-------
: array
(k, ), st... | python | def steady_state(P):
"""
Calculates the steady state probability vector for a regular Markov
transition matrix P.
Parameters
----------
P : array
(k, k), an ergodic Markov transition probability matrix.
Returns
-------
: array
(k, ), st... | [
"def",
"steady_state",
"(",
"P",
")",
":",
"v",
",",
"d",
"=",
"la",
".",
"eig",
"(",
"np",
".",
"transpose",
"(",
"P",
")",
")",
"d",
"=",
"np",
".",
"array",
"(",
"d",
")",
"# for a regular P maximum eigenvalue will be 1",
"mv",
"=",
"max",
"(",
... | Calculates the steady state probability vector for a regular Markov
transition matrix P.
Parameters
----------
P : array
(k, k), an ergodic Markov transition probability matrix.
Returns
-------
: array
(k, ), steady state distribution.
Exa... | [
"Calculates",
"the",
"steady",
"state",
"probability",
"vector",
"for",
"a",
"regular",
"Markov",
"transition",
"matrix",
"P",
"."
] | 13fae6c18933614be78e91a6b5060693bea33a04 | https://github.com/pysal/giddy/blob/13fae6c18933614be78e91a6b5060693bea33a04/giddy/ergodic.py#L12-L59 | train |
pysal/giddy | giddy/ergodic.py | fmpt | def fmpt(P):
"""
Calculates the matrix of first mean passage times for an ergodic transition
probability matrix.
Parameters
----------
P : array
(k, k), an ergodic Markov transition probability matrix.
Returns
-------
M : array
(k, k), elements are the e... | python | def fmpt(P):
"""
Calculates the matrix of first mean passage times for an ergodic transition
probability matrix.
Parameters
----------
P : array
(k, k), an ergodic Markov transition probability matrix.
Returns
-------
M : array
(k, k), elements are the e... | [
"def",
"fmpt",
"(",
"P",
")",
":",
"P",
"=",
"np",
".",
"matrix",
"(",
"P",
")",
"k",
"=",
"P",
".",
"shape",
"[",
"0",
"]",
"A",
"=",
"np",
".",
"zeros_like",
"(",
"P",
")",
"ss",
"=",
"steady_state",
"(",
"P",
")",
".",
"reshape",
"(",
... | Calculates the matrix of first mean passage times for an ergodic transition
probability matrix.
Parameters
----------
P : array
(k, k), an ergodic Markov transition probability matrix.
Returns
-------
M : array
(k, k), elements are the expected value for the num... | [
"Calculates",
"the",
"matrix",
"of",
"first",
"mean",
"passage",
"times",
"for",
"an",
"ergodic",
"transition",
"probability",
"matrix",
"."
] | 13fae6c18933614be78e91a6b5060693bea33a04 | https://github.com/pysal/giddy/blob/13fae6c18933614be78e91a6b5060693bea33a04/giddy/ergodic.py#L62-L118 | train |
pysal/giddy | giddy/ergodic.py | var_fmpt | def var_fmpt(P):
"""
Variances of first mean passage times for an ergodic transition
probability matrix.
Parameters
----------
P : array
(k, k), an ergodic Markov transition probability matrix.
Returns
-------
: array
(k, k), elements are the v... | python | def var_fmpt(P):
"""
Variances of first mean passage times for an ergodic transition
probability matrix.
Parameters
----------
P : array
(k, k), an ergodic Markov transition probability matrix.
Returns
-------
: array
(k, k), elements are the v... | [
"def",
"var_fmpt",
"(",
"P",
")",
":",
"P",
"=",
"np",
".",
"matrix",
"(",
"P",
")",
"A",
"=",
"P",
"**",
"1000",
"n",
",",
"k",
"=",
"A",
".",
"shape",
"I",
"=",
"np",
".",
"identity",
"(",
"k",
")",
"Z",
"=",
"la",
".",
"inv",
"(",
"I... | Variances of first mean passage times for an ergodic transition
probability matrix.
Parameters
----------
P : array
(k, k), an ergodic Markov transition probability matrix.
Returns
-------
: array
(k, k), elements are the variances for the number of in... | [
"Variances",
"of",
"first",
"mean",
"passage",
"times",
"for",
"an",
"ergodic",
"transition",
"probability",
"matrix",
"."
] | 13fae6c18933614be78e91a6b5060693bea33a04 | https://github.com/pysal/giddy/blob/13fae6c18933614be78e91a6b5060693bea33a04/giddy/ergodic.py#L121-L167 | train |
pyinvoke/invocations | invocations/packaging/release.py | _converge | def _converge(c):
"""
Examine world state, returning data on what needs updating for release.
:param c: Invoke ``Context`` object or subclass.
:returns:
Two dicts (technically, dict subclasses, which allow attribute access),
``actions`` and ``state`` (in that order.)
``actions... | python | def _converge(c):
"""
Examine world state, returning data on what needs updating for release.
:param c: Invoke ``Context`` object or subclass.
:returns:
Two dicts (technically, dict subclasses, which allow attribute access),
``actions`` and ``state`` (in that order.)
``actions... | [
"def",
"_converge",
"(",
"c",
")",
":",
"#",
"# Data/state gathering",
"#",
"# Get data about current repo context: what branch are we on & what kind of",
"# release does it appear to represent?",
"branch",
",",
"release_type",
"=",
"_release_line",
"(",
"c",
")",
"# Short-circ... | Examine world state, returning data on what needs updating for release.
:param c: Invoke ``Context`` object or subclass.
:returns:
Two dicts (technically, dict subclasses, which allow attribute access),
``actions`` and ``state`` (in that order.)
``actions`` maps release component name... | [
"Examine",
"world",
"state",
"returning",
"data",
"on",
"what",
"needs",
"updating",
"for",
"release",
"."
] | bbf1b319bd1536817d5301ceb9eeb2f31830e5dc | https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/packaging/release.py#L110-L240 | train |
pyinvoke/invocations | invocations/packaging/release.py | status | def status(c):
"""
Print current release (version, changelog, tag, etc) status.
Doubles as a subroutine, returning the return values from its inner call to
``_converge`` (an ``(actions, state)`` two-tuple of Lexicons).
"""
# TODO: wants some holistic "you don't actually HAVE any changes to
... | python | def status(c):
"""
Print current release (version, changelog, tag, etc) status.
Doubles as a subroutine, returning the return values from its inner call to
``_converge`` (an ``(actions, state)`` two-tuple of Lexicons).
"""
# TODO: wants some holistic "you don't actually HAVE any changes to
... | [
"def",
"status",
"(",
"c",
")",
":",
"# TODO: wants some holistic \"you don't actually HAVE any changes to",
"# release\" final status - i.e. all steps were at no-op status.",
"actions",
",",
"state",
"=",
"_converge",
"(",
"c",
")",
"table",
"=",
"[",
"]",
"# NOTE: explicit ... | Print current release (version, changelog, tag, etc) status.
Doubles as a subroutine, returning the return values from its inner call to
``_converge`` (an ``(actions, state)`` two-tuple of Lexicons). | [
"Print",
"current",
"release",
"(",
"version",
"changelog",
"tag",
"etc",
")",
"status",
"."
] | bbf1b319bd1536817d5301ceb9eeb2f31830e5dc | https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/packaging/release.py#L244-L260 | train |
pyinvoke/invocations | invocations/packaging/release.py | prepare | def prepare(c):
"""
Edit changelog & version, git commit, and git tag, to set up for release.
"""
# Print dry-run/status/actions-to-take data & grab programmatic result
# TODO: maybe expand the enum-based stuff to have values that split up
# textual description, command string, etc. See the TODO... | python | def prepare(c):
"""
Edit changelog & version, git commit, and git tag, to set up for release.
"""
# Print dry-run/status/actions-to-take data & grab programmatic result
# TODO: maybe expand the enum-based stuff to have values that split up
# textual description, command string, etc. See the TODO... | [
"def",
"prepare",
"(",
"c",
")",
":",
"# Print dry-run/status/actions-to-take data & grab programmatic result",
"# TODO: maybe expand the enum-based stuff to have values that split up",
"# textual description, command string, etc. See the TODO up by their",
"# definition too, re: just making them ... | Edit changelog & version, git commit, and git tag, to set up for release. | [
"Edit",
"changelog",
"&",
"version",
"git",
"commit",
"and",
"git",
"tag",
"to",
"set",
"up",
"for",
"release",
"."
] | bbf1b319bd1536817d5301ceb9eeb2f31830e5dc | https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/packaging/release.py#L277-L325 | train |
pyinvoke/invocations | invocations/packaging/release.py | _release_line | def _release_line(c):
"""
Examine current repo state to determine what type of release to prep.
:returns:
A two-tuple of ``(branch-name, line-type)`` where:
- ``branch-name`` is the current branch name, e.g. ``1.1``, ``master``,
``gobbledygook`` (or, usually, ``HEAD`` if not on a... | python | def _release_line(c):
"""
Examine current repo state to determine what type of release to prep.
:returns:
A two-tuple of ``(branch-name, line-type)`` where:
- ``branch-name`` is the current branch name, e.g. ``1.1``, ``master``,
``gobbledygook`` (or, usually, ``HEAD`` if not on a... | [
"def",
"_release_line",
"(",
"c",
")",
":",
"# TODO: I don't _think_ this technically overlaps with Releases (because",
"# that only ever deals with changelog contents, and therefore full release",
"# version numbers) but in case it does, move it there sometime.",
"# TODO: this and similar calls i... | Examine current repo state to determine what type of release to prep.
:returns:
A two-tuple of ``(branch-name, line-type)`` where:
- ``branch-name`` is the current branch name, e.g. ``1.1``, ``master``,
``gobbledygook`` (or, usually, ``HEAD`` if not on a branch).
- ``line-type`` ... | [
"Examine",
"current",
"repo",
"state",
"to",
"determine",
"what",
"type",
"of",
"release",
"to",
"prep",
"."
] | bbf1b319bd1536817d5301ceb9eeb2f31830e5dc | https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/packaging/release.py#L330-L364 | train |
pyinvoke/invocations | invocations/packaging/release.py | _versions_from_changelog | def _versions_from_changelog(changelog):
"""
Return all released versions from given ``changelog``, sorted.
:param dict changelog:
A changelog dict as returned by ``releases.util.parse_changelog``.
:returns: A sorted list of `semantic_version.Version` objects.
"""
versions = [Version(x... | python | def _versions_from_changelog(changelog):
"""
Return all released versions from given ``changelog``, sorted.
:param dict changelog:
A changelog dict as returned by ``releases.util.parse_changelog``.
:returns: A sorted list of `semantic_version.Version` objects.
"""
versions = [Version(x... | [
"def",
"_versions_from_changelog",
"(",
"changelog",
")",
":",
"versions",
"=",
"[",
"Version",
"(",
"x",
")",
"for",
"x",
"in",
"changelog",
"if",
"BUGFIX_RELEASE_RE",
".",
"match",
"(",
"x",
")",
"]",
"return",
"sorted",
"(",
"versions",
")"
] | Return all released versions from given ``changelog``, sorted.
:param dict changelog:
A changelog dict as returned by ``releases.util.parse_changelog``.
:returns: A sorted list of `semantic_version.Version` objects. | [
"Return",
"all",
"released",
"versions",
"from",
"given",
"changelog",
"sorted",
"."
] | bbf1b319bd1536817d5301ceb9eeb2f31830e5dc | https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/packaging/release.py#L381-L391 | train |
pyinvoke/invocations | invocations/packaging/release.py | _release_and_issues | def _release_and_issues(changelog, branch, release_type):
"""
Return most recent branch-appropriate release, if any, and its contents.
:param dict changelog:
Changelog contents, as returned by ``releases.util.parse_changelog``.
:param str branch:
Branch name.
:param release_type:
... | python | def _release_and_issues(changelog, branch, release_type):
"""
Return most recent branch-appropriate release, if any, and its contents.
:param dict changelog:
Changelog contents, as returned by ``releases.util.parse_changelog``.
:param str branch:
Branch name.
:param release_type:
... | [
"def",
"_release_and_issues",
"(",
"changelog",
",",
"branch",
",",
"release_type",
")",
":",
"# Bugfix lines just use the branch to find issues",
"bucket",
"=",
"branch",
"# Features need a bit more logic",
"if",
"release_type",
"is",
"Release",
".",
"FEATURE",
":",
"buc... | Return most recent branch-appropriate release, if any, and its contents.
:param dict changelog:
Changelog contents, as returned by ``releases.util.parse_changelog``.
:param str branch:
Branch name.
:param release_type:
Member of `Release`, e.g. `Release.FEATURE`.
:returns:
... | [
"Return",
"most",
"recent",
"branch",
"-",
"appropriate",
"release",
"if",
"any",
"and",
"its",
"contents",
"."
] | bbf1b319bd1536817d5301ceb9eeb2f31830e5dc | https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/packaging/release.py#L395-L427 | train |
pyinvoke/invocations | invocations/packaging/release.py | _get_tags | def _get_tags(c):
"""
Return sorted list of release-style tags as semver objects.
"""
tags_ = []
for tagstr in c.run("git tag", hide=True).stdout.strip().split("\n"):
try:
tags_.append(Version(tagstr))
# Ignore anything non-semver; most of the time they'll be non-release
... | python | def _get_tags(c):
"""
Return sorted list of release-style tags as semver objects.
"""
tags_ = []
for tagstr in c.run("git tag", hide=True).stdout.strip().split("\n"):
try:
tags_.append(Version(tagstr))
# Ignore anything non-semver; most of the time they'll be non-release
... | [
"def",
"_get_tags",
"(",
"c",
")",
":",
"tags_",
"=",
"[",
"]",
"for",
"tagstr",
"in",
"c",
".",
"run",
"(",
"\"git tag\"",
",",
"hide",
"=",
"True",
")",
".",
"stdout",
".",
"strip",
"(",
")",
".",
"split",
"(",
"\"\\n\"",
")",
":",
"try",
":"... | Return sorted list of release-style tags as semver objects. | [
"Return",
"sorted",
"list",
"of",
"release",
"-",
"style",
"tags",
"as",
"semver",
"objects",
"."
] | bbf1b319bd1536817d5301ceb9eeb2f31830e5dc | https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/packaging/release.py#L430-L445 | train |
pyinvoke/invocations | invocations/packaging/release.py | _find_package | def _find_package(c):
"""
Try to find 'the' One True Package for this project.
Mostly for obtaining the ``_version`` file within it.
Uses the ``packaging.package`` config setting if defined. If not defined,
fallback is to look for a single top-level Python package (directory
containing ``__ini... | python | def _find_package(c):
"""
Try to find 'the' One True Package for this project.
Mostly for obtaining the ``_version`` file within it.
Uses the ``packaging.package`` config setting if defined. If not defined,
fallback is to look for a single top-level Python package (directory
containing ``__ini... | [
"def",
"_find_package",
"(",
"c",
")",
":",
"# TODO: is there a way to get this from the same place setup.py does w/o",
"# setup.py barfing (since setup() runs at import time and assumes CLI use)?",
"configured_value",
"=",
"c",
".",
"get",
"(",
"\"packaging\"",
",",
"{",
"}",
")... | Try to find 'the' One True Package for this project.
Mostly for obtaining the ``_version`` file within it.
Uses the ``packaging.package`` config setting if defined. If not defined,
fallback is to look for a single top-level Python package (directory
containing ``__init__.py``). (This search ignores a ... | [
"Try",
"to",
"find",
"the",
"One",
"True",
"Package",
"for",
"this",
"project",
"."
] | bbf1b319bd1536817d5301ceb9eeb2f31830e5dc | https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/packaging/release.py#L471-L502 | train |
pyinvoke/invocations | invocations/packaging/release.py | build | def build(c, sdist=True, wheel=False, directory=None, python=None, clean=True):
"""
Build sdist and/or wheel archives, optionally in a temp base directory.
All parameters save ``directory`` honor config settings of the same name,
under the ``packaging`` tree. E.g. say ``.configure({'packaging': {'wheel... | python | def build(c, sdist=True, wheel=False, directory=None, python=None, clean=True):
"""
Build sdist and/or wheel archives, optionally in a temp base directory.
All parameters save ``directory`` honor config settings of the same name,
under the ``packaging`` tree. E.g. say ``.configure({'packaging': {'wheel... | [
"def",
"build",
"(",
"c",
",",
"sdist",
"=",
"True",
",",
"wheel",
"=",
"False",
",",
"directory",
"=",
"None",
",",
"python",
"=",
"None",
",",
"clean",
"=",
"True",
")",
":",
"# Config hooks",
"config",
"=",
"c",
".",
"config",
".",
"get",
"(",
... | Build sdist and/or wheel archives, optionally in a temp base directory.
All parameters save ``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:
... | [
"Build",
"sdist",
"and",
"/",
"or",
"wheel",
"archives",
"optionally",
"in",
"a",
"temp",
"base",
"directory",
"."
] | bbf1b319bd1536817d5301ceb9eeb2f31830e5dc | https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/packaging/release.py#L518-L590 | train |
pyinvoke/invocations | invocations/packaging/release.py | publish | 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... | python | 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",... | 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... | [
"Publish",
"code",
"to",
"PyPI",
"or",
"index",
"of",
"choice",
"."
] | bbf1b319bd1536817d5301ceb9eeb2f31830e5dc | https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/packaging/release.py#L605-L700 | train |
pyinvoke/invocations | invocations/packaging/release.py | upload | 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... | python | 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",
")",
":",
"# Obtain list of archive filenames, then ensure any wheels come first",
"# so their improved metadata is what PyPI sees initially (oth... | 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 ... | [
"Upload",
"(",
"potentially",
"also",
"signing",
")",
"all",
"artifacts",
"in",
"directory",
"."
] | bbf1b319bd1536817d5301ceb9eeb2f31830e5dc | https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/packaging/release.py#L703-L766 | train |
pyinvoke/invocations | invocations/util.py | tmpdir | 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... | python | 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",
")",
":",
"tmp",
"=",
"explicit",
"if",
"explicit",
"is",
"not",
"None",
"else",
"mkdtemp",
"(",
")",
"try",
":",
"yield",
"tmp",
"finally",
":",
"if",
"not",
"skip_clean... | 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.) | [
"Context",
"-",
"manage",
"a",
"temporary",
"directory",
"."
] | bbf1b319bd1536817d5301ceb9eeb2f31830e5dc | https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/util.py#L7-L23 | train |
pysal/giddy | giddy/directional.py | Rose.permute | 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... | python | 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'",
")",
":",
"rY",
"=",
"self",
".",
"Y",
".",
"copy",
"(",
")",
"idxs",
"=",
"np",
".",
"arange",
"(",
"len",
"(",
"rY",
")",
")",
"counts",
"=",... | 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... | [
"Generate",
"ransom",
"spatial",
"permutations",
"for",
"inference",
"on",
"LISA",
"vectors",
"."
] | 13fae6c18933614be78e91a6b5060693bea33a04 | https://github.com/pysal/giddy/blob/13fae6c18933614be78e91a6b5060693bea33a04/giddy/directional.py#L227-L300 | train |
pysal/giddy | giddy/directional.py | Rose.plot | 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... | python | 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",
")",
":",
"from",
"splot",
".",
"giddy",
"import",
"dynamic_lisa_rose",
"fig",
",",
"ax",
"=",
"dynamic_lisa_rose",
"(",
"self",
",",
"attribute... | 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 ... | [
"Plot",
"the",
"rose",
"diagram",
"."
] | 13fae6c18933614be78e91a6b5060693bea33a04 | https://github.com/pysal/giddy/blob/13fae6c18933614be78e91a6b5060693bea33a04/giddy/directional.py#L324-L351 | train |
pysal/giddy | giddy/directional.py | Rose.plot_origin | 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._... | python | 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",
"import",
"matplotlib",
".",
"cm",
"as",
"cm",
"import",
"matplotlib",
".",
"pyplot",
"as",
"plt",
"ax",
"=",
"plt",
".",
"subplot",
"(",
"111",
")",
"xlim",
"=",
"[... | Plot vectors of positional transition of LISA values starting
from the same origin. | [
"Plot",
"vectors",
"of",
"positional",
"transition",
"of",
"LISA",
"values",
"starting",
"from",
"the",
"same",
"origin",
"."
] | 13fae6c18933614be78e91a6b5060693bea33a04 | https://github.com/pysal/giddy/blob/13fae6c18933614be78e91a6b5060693bea33a04/giddy/directional.py#L353-L369 | train |
pysal/giddy | giddy/directional.py | Rose.plot_vectors | 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.
... | python | 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",
")",
":",
"from",
"splot",
".",
"giddy",
"import",
"dynamic_lisa_vectors",
"fig",
",",
"ax",
"=",
"dynamic_lisa_vectors",
"(",
"self",
",",
"arrows",
"=",
"arrows",
")",
"return",
"fig",
",",
... | 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... | [
"Plot",
"vectors",
"of",
"positional",
"transition",
"of",
"LISA",
"values",
"within",
"quadrant",
"in",
"scatterplot",
"in",
"a",
"polar",
"plot",
"."
] | 13fae6c18933614be78e91a6b5060693bea33a04 | https://github.com/pysal/giddy/blob/13fae6c18933614be78e91a6b5060693bea33a04/giddy/directional.py#L372-L400 | train |
pyinvoke/invocations | invocations/docs.py | _clean | def _clean(c):
"""
Nuke docs build target directory so next build is clean.
"""
if isdir(c.sphinx.target):
rmtree(c.sphinx.target) | python | 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",
")",
":",
"if",
"isdir",
"(",
"c",
".",
"sphinx",
".",
"target",
")",
":",
"rmtree",
"(",
"c",
".",
"sphinx",
".",
"target",
")"
] | Nuke docs build target directory so next build is clean. | [
"Nuke",
"docs",
"build",
"target",
"directory",
"so",
"next",
"build",
"is",
"clean",
"."
] | bbf1b319bd1536817d5301ceb9eeb2f31830e5dc | https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/docs.py#L17-L22 | train |
pyinvoke/invocations | invocations/docs.py | _browse | 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)) | python | 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",
")",
":",
"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'). | [
"Open",
"build",
"target",
"s",
"index",
".",
"html",
"in",
"a",
"browser",
"(",
"using",
"open",
")",
"."
] | bbf1b319bd1536817d5301ceb9eeb2f31830e5dc | https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/docs.py#L27-L32 | train |
pyinvoke/invocations | invocations/docs.py | build | 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} {... | python | 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",
",",
")",
":",
"if",
"clean",
":",
"_clean",
"(",
... | Build the project's Sphinx docs. | [
"Build",
"the",
"project",
"s",
"Sphinx",
"docs",
"."
] | bbf1b319bd1536817d5301ceb9eeb2f31830e5dc | https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/docs.py#L46-L71 | train |
pyinvoke/invocations | invocations/docs.py | tree | 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)) | python | 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",
")",
":",
"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. | [
"Display",
"documentation",
"contents",
"with",
"the",
"tree",
"program",
"."
] | bbf1b319bd1536817d5301ceb9eeb2f31830e5dc | https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/docs.py#L95-L100 | train |
pyinvoke/invocations | invocations/docs.py | sites | 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... | python | 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",
")",
":",
"# 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_... | Build both doc sites w/ maxed nitpicking. | [
"Build",
"both",
"doc",
"sites",
"w",
"/",
"maxed",
"nitpicking",
"."
] | bbf1b319bd1536817d5301ceb9eeb2f31830e5dc | https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/docs.py#L143-L169 | train |
pyinvoke/invocations | invocations/docs.py | watch_docs | 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 ... | python | 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",
")",
":",
"# 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",
"... | 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... | [
"Watch",
"both",
"doc",
"trees",
"&",
"rebuild",
"them",
"if",
"files",
"change",
"."
] | bbf1b319bd1536817d5301ceb9eeb2f31830e5dc | https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/docs.py#L173-L215 | train |
pysal/giddy | giddy/util.py | shuffle_matrix | 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.
... | python | 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",
")",
":",
"np",
".",
"random",
".",
"shuffle",
"(",
"ids",
")",
"return",
"X",
"[",
"ids",
",",
":",
"]",
"[",
":",
",",
"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.
Examples
--------
>>> import ... | [
"Random",
"permutation",
"of",
"rows",
"and",
"columns",
"of",
"a",
"matrix"
] | 13fae6c18933614be78e91a6b5060693bea33a04 | https://github.com/pysal/giddy/blob/13fae6c18933614be78e91a6b5060693bea33a04/giddy/util.py#L9-L40 | train |
pysal/giddy | giddy/util.py | get_lower | 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... | python | 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",
")",
":",
"n",
"=",
"matrix",
".",
"shape",
"[",
"0",
"]",
"lowerlist",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"n",
")",
":",
"for",
"j",
"in",
"range",
"(",
"n",
")",
":",
"if",
"i",
">",
"j",
":"... | 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... | [
"Flattens",
"the",
"lower",
"part",
"of",
"an",
"n",
"x",
"n",
"matrix",
"into",
"an",
"n",
"*",
"(",
"n",
"-",
"1",
")",
"/",
"2",
"x",
"1",
"vector",
"."
] | 13fae6c18933614be78e91a6b5060693bea33a04 | https://github.com/pysal/giddy/blob/13fae6c18933614be78e91a6b5060693bea33a04/giddy/util.py#L43-L81 | train |
pyinvoke/invocations | invocations/checks.py | blacken | 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... | python | 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",
")",
":",
"config",
"=",
"c",
".",
"config",
".",
"get",
"(",
"\"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... | [
"r",
"Run",
"black",
"on",
"the",
"current",
"source",
"tree",
"(",
"all",
".",
"py",
"files",
")",
"."
] | bbf1b319bd1536817d5301ceb9eeb2f31830e5dc | https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/checks.py#L13-L65 | train |
kolypto/py-flask-jsontools | flask_jsontools/response.py | normalize_response_value | 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):
... | python | 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",
")",
":",
"status",
"=",
"headers",
"=",
"None",
"if",
"isinstance",
"(",
"rv",
",",
"tuple",
")",
":",
"rv",
",",
"status",
",",
"headers",
"=",
"rv",
"+",
"(",
"None",
",",
")",
"*",
"(",
"3",
"-",
... | 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) | [
"Normalize",
"the",
"response",
"value",
"into",
"a",
"3",
"-",
"tuple",
"(",
"rv",
"status",
"headers",
")",
":",
"type",
"rv",
":",
"tuple|",
"*",
":",
"returns",
":",
"tuple",
"(",
"rv",
"status",
"headers",
")",
":",
"rtype",
":",
"tuple",
"(",
... | 1abee2d40e6db262e43f0c534e90faaa9b26246a | https://github.com/kolypto/py-flask-jsontools/blob/1abee2d40e6db262e43f0c534e90faaa9b26246a/flask_jsontools/response.py#L51-L60 | train |
kolypto/py-flask-jsontools | flask_jsontools/response.py | make_json_response | 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... | python | 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",
")",
":",
"# Tuple of (response, status, headers)",
"rv",
",",
"status",
",",
"headers",
"=",
"normalize_response_value",
"(",
"rv",
")",
"# JsonResponse",
"if",
"isinstance",
"(",
"rv",
",",
"JsonResponse",
")",
":",
"retur... | Make JsonResponse
:param rv: Response: the object to encode, or tuple (response, status, headers)
:type rv: tuple|*
:rtype: JsonResponse | [
"Make",
"JsonResponse",
":",
"param",
"rv",
":",
"Response",
":",
"the",
"object",
"to",
"encode",
"or",
"tuple",
"(",
"response",
"status",
"headers",
")",
":",
"type",
"rv",
":",
"tuple|",
"*",
":",
"rtype",
":",
"JsonResponse"
] | 1abee2d40e6db262e43f0c534e90faaa9b26246a | https://github.com/kolypto/py-flask-jsontools/blob/1abee2d40e6db262e43f0c534e90faaa9b26246a/flask_jsontools/response.py#L63-L77 | train |
pysal/giddy | giddy/mobility.py | markov_mobility | 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}`;
... | python | 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",
")",
":",
"p",
"=",
"np",
".",
"array",
"(",
"p",
")",
"k",
"=",
"p",
".",
"shape",
"[",
"1",
"]",
"if",
"measure",
"==",
"\"P\"",
":",
"t",
"=",
"np",... | 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... | [
"Markov",
"-",
"based",
"mobility",
"index",
"."
] | 13fae6c18933614be78e91a6b5060693bea33a04 | https://github.com/pysal/giddy/blob/13fae6c18933614be78e91a6b5060693bea33a04/giddy/mobility.py#L13-L131 | train |
pysal/giddy | giddy/markov.py | chi2 | 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... | python | 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",
")",
":",
"rs2",
"=",
"T2",
".",
"sum",
"(",
"axis",
"=",
"1",
")",
"rs1",
"=",
"T1",
".",
"sum",
"(",
"axis",
"=",
"1",
")",
"rs2nz",
"=",
"rs2",
">",
"0",
"rs1nz",
"=",
"rs1",
">",
"0",
"dof1",
"=",
... | 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
-------
... | [
"chi",
"-",
"squared",
"test",
"of",
"difference",
"between",
"two",
"transition",
"matrices",
"."
] | 13fae6c18933614be78e91a6b5060693bea33a04 | https://github.com/pysal/giddy/blob/13fae6c18933614be78e91a6b5060693bea33a04/giddy/markov.py#L858-L932 | train |
pysal/giddy | giddy/markov.py | kullback | 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 -... | python | 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",
")",
":",
"F1",
"=",
"F",
"==",
"0",
"F1",
"=",
"F",
"+",
"F1",
"FLF",
"=",
"F",
"*",
"np",
".",
"log",
"(",
"F1",
")",
"T1",
"=",
"2",
"*",
"FLF",
".",
"sum",
"(",
")",
"FdJK",
"=",
"F",
".",
"sum",
"(",
... | 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... | [
"Kullback",
"information",
"based",
"test",
"of",
"Markov",
"Homogeneity",
"."
] | 13fae6c18933614be78e91a6b5060693bea33a04 | https://github.com/pysal/giddy/blob/13fae6c18933614be78e91a6b5060693bea33a04/giddy/markov.py#L1336-L1425 | train |
pysal/giddy | giddy/markov.py | 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... | python | 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",
")",
":",
"pmat",
"=",
"np",
".",
"array",
"(",
"pmat",
")",
"pr",
"=",
"1",
"-",
"np",
".",
"diag",
"(",
"pmat",
")",
"return",
"pr"
] | 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... | [
"Prais",
"conditional",
"mobility",
"measure",
"."
] | 13fae6c18933614be78e91a6b5060693bea33a04 | https://github.com/pysal/giddy/blob/13fae6c18933614be78e91a6b5060693bea33a04/giddy/markov.py#L1428-L1477 | train |
pysal/giddy | giddy/markov.py | homogeneity | 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... | python | 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\"",
")",
":",
"return",
"Homogeneity_Results",
"(",
"transition_matrices",
",",
"regime_names",
"... | 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
... | [
"Test",
"for",
"homogeneity",
"of",
"Markov",
"transition",
"probabilities",
"across",
"regimes",
"."
] | 13fae6c18933614be78e91a6b5060693bea33a04 | https://github.com/pysal/giddy/blob/13fae6c18933614be78e91a6b5060693bea33a04/giddy/markov.py#L1480-L1506 | train |
pysal/giddy | giddy/markov.py | sojourn_time | 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... | python | 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",
")",
":",
"p",
"=",
"np",
".",
"asarray",
"(",
"p",
")",
"pii",
"=",
"p",
".",
"diagonal",
"(",
")",
"if",
"not",
"(",
"1",
"-",
"pii",
")",
".",
"all",
"(",
")",
":",
"print",
"(",
"\"Sojourn times are infinite f... | 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
... | [
"Calculate",
"sojourn",
"time",
"based",
"on",
"a",
"given",
"transition",
"probability",
"matrix",
"."
] | 13fae6c18933614be78e91a6b5060693bea33a04 | https://github.com/pysal/giddy/blob/13fae6c18933614be78e91a6b5060693bea33a04/giddy/markov.py#L1830-L1864 | train |
pysal/giddy | giddy/markov.py | Spatial_Markov._calc | 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,
... | python | 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",
")",
":",
"if",
"self",
".",
"discrete",
":",
"self",
".",
"lclass_ids",
"=",
"weights",
".",
"lag_categorical",
"(",
"w",
",",
"self",
".",
"class_ids",
",",
"ties",
"=",
"\"tryself\"",
")",
"else",
... | Helper to estimate spatial lag conditioned Markov transition
probability matrices based on maximum likelihood techniques. | [
"Helper",
"to",
"estimate",
"spatial",
"lag",
"conditioned",
"Markov",
"transition",
"probability",
"matrices",
"based",
"on",
"maximum",
"likelihood",
"techniques",
"."
] | 13fae6c18933614be78e91a6b5060693bea33a04 | https://github.com/pysal/giddy/blob/13fae6c18933614be78e91a6b5060693bea33a04/giddy/markov.py#L731-L759 | train |
pysal/giddy | giddy/markov.py | Spatial_Markov.summary | 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... | python | 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",
")",
":",
"class_names",
"=",
"[",
"\"C%d\"",
"%",
"i",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"k",
")",
"]",
"regime_names",
"=",
"[",
"\"LAG%d\"",
"%",
"i",
"for",
"i",
"in",
"... | 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`. | [
"A",
"summary",
"method",
"to",
"call",
"the",
"Markov",
"homogeneity",
"test",
"to",
"test",
"for",
"temporally",
"lagged",
"spatial",
"dependence",
"."
] | 13fae6c18933614be78e91a6b5060693bea33a04 | https://github.com/pysal/giddy/blob/13fae6c18933614be78e91a6b5060693bea33a04/giddy/markov.py#L811-L830 | train |
pysal/giddy | giddy/markov.py | Spatial_Markov._maybe_classify | 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... | python | 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",
")",
":",
"rows",
",",
"cols",
"=",
"y",
".",
"shape",
"if",
"cutoffs",
"is",
"None",
":",
"if",
"self",
".",
"fixed",
":",
"mcyb",
"=",
"mc",
".",
"Quantiles",
"(",
"y",
... | Helper method for classifying continuous data. | [
"Helper",
"method",
"for",
"classifying",
"continuous",
"data",
"."
] | 13fae6c18933614be78e91a6b5060693bea33a04 | https://github.com/pysal/giddy/blob/13fae6c18933614be78e91a6b5060693bea33a04/giddy/markov.py#L832-L855 | train |
pysal/giddy | giddy/markov.py | LISA_Markov.spillover | 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... | python | 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",
")",
":",
"n",
",",
"k",
"=",
"self",
".",
"q",
".",
"shape",
"if",
"self",
".",
"permutations",
":",
"spill_over",
"=",
"np",
".",
"zeros",
"(",
"(",
... | 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... | [
"Detect",
"spillover",
"locations",
"for",
"diffusion",
"in",
"LISA",
"Markov",
"."
] | 13fae6c18933614be78e91a6b5060693bea33a04 | https://github.com/pysal/giddy/blob/13fae6c18933614be78e91a6b5060693bea33a04/giddy/markov.py#L1212-L1333 | train |
kolypto/py-flask-jsontools | flask_jsontools/formatting.py | get_entity_propnames | 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)
... | python | 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",
")",
":",
"ins",
"=",
"entity",
"if",
"isinstance",
"(",
"entity",
",",
"InstanceState",
")",
"else",
"inspect",
"(",
"entity",
")",
"return",
"set",
"(",
"ins",
".",
"mapper",
".",
"column_attrs",
".",
"keys",... | Get entity property names
:param entity: Entity
:type entity: sqlalchemy.ext.declarative.api.DeclarativeMeta
:returns: Set of entity property names
:rtype: set | [
"Get",
"entity",
"property",
"names"
] | 1abee2d40e6db262e43f0c534e90faaa9b26246a | https://github.com/kolypto/py-flask-jsontools/blob/1abee2d40e6db262e43f0c534e90faaa9b26246a/flask_jsontools/formatting.py#L31-L43 | train |
kolypto/py-flask-jsontools | flask_jsontools/formatting.py | get_entity_loaded_propnames | 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... | python | 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",
")",
":",
"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'... | 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 | [
"Get",
"entity",
"property",
"names",
"that",
"are",
"loaded",
"(",
"e",
".",
"g",
".",
"won",
"t",
"produce",
"new",
"queries",
")"
] | 1abee2d40e6db262e43f0c534e90faaa9b26246a | https://github.com/kolypto/py-flask-jsontools/blob/1abee2d40e6db262e43f0c534e90faaa9b26246a/flask_jsontools/formatting.py#L46-L68 | train |
pyinvoke/invocations | invocations/packaging/semantic_version_monkey.py | next_minor | 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()
... | python | 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",
")",
":",
"clone",
"=",
"self",
".",
"clone",
"(",
")",
"clone",
".",
"minor",
"+=",
"1",
"clone",
".",
"patch",
"=",
"0",
"return",
"clone"
] | 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. | [
"Return",
"a",
"Version",
"whose",
"minor",
"number",
"is",
"one",
"greater",
"than",
"self",
"s",
"."
] | bbf1b319bd1536817d5301ceb9eeb2f31830e5dc | https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/packaging/semantic_version_monkey.py#L26-L38 | train |
roskakori/pygount | pygount/command.py | _check_encoding | 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... | python | 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",
")",
":",
"assert",
"name",
"is",
"not",
"None",
"if",
"encoding_to_check",
"not",
"in",
"(",
"alternative_encoding",
",",
"'chardet'",
",",... | 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.... | [
"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",... | c2c150a534ba5be498eb39cb78fc6a531d62f145 | https://github.com/roskakori/pygount/blob/c2c150a534ba5be498eb39cb78fc6a531d62f145/pygount/command.py#L58-L75 | train |
roskakori/pygount | pygount/common.py | lines | 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
... | python | 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",
")",
":",
"assert",
"text",
"is",
"not",
"None",
"assert",
"'\\r'",
"not",
"in",
"text",
"previous_newline_index",
"=",
"0",
"newline_index",
"=",
"text",
".",
"find",
"(",
"'\\n'",
")",
"while",
"newline_index",
"!=",
"-",
"... | 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. | [
"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",... | c2c150a534ba5be498eb39cb78fc6a531d62f145 | https://github.com/roskakori/pygount/blob/c2c150a534ba5be498eb39cb78fc6a531d62f145/pygount/common.py#L101-L117 | train |
roskakori/pygount | pygount/analysis.py | matching_number_line_and_regex | 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 ... | python | 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",
")",
":",
"initial_numbers_and_lines",
"=",
"enumerate",
"(",
"itertools",
".",
"islice",
"(",
"source_lines",
",",
"max_line_count",
")",
")",
... | 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... | [
"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"... | c2c150a534ba5be498eb39cb78fc6a531d62f145 | https://github.com/roskakori/pygount/blob/c2c150a534ba5be498eb39cb78fc6a531d62f145/pygount/analysis.py#L245-L266 | train |
roskakori/pygount | pygount/analysis.py | _pythonized_comments | 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... | python | 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",
")",
":",
"is_after_colon",
"=",
"True",
"for",
"token_type",
",",
"token_text",
"in",
"tokens",
":",
"if",
"is_after_colon",
"and",
"(",
"token_type",
"in",
"pygments",
".",
"token",
".",
"String",
")",
":",
"to... | Similar to tokens but converts strings after a colon (:) to comments. | [
"Similar",
"to",
"tokens",
"but",
"converts",
"strings",
"after",
"a",
"colon",
"(",
":",
")",
"to",
"comments",
"."
] | c2c150a534ba5be498eb39cb78fc6a531d62f145 | https://github.com/roskakori/pygount/blob/c2c150a534ba5be498eb39cb78fc6a531d62f145/pygount/analysis.py#L299-L313 | train |
roskakori/pygount | pygount/analysis.py | encoding_for | 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... | python | 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",
")",
":",
"assert",
"encoding",
"is",
"not",
"None",
"if",
"encoding",
"==",
"'automatic'",
":",
"with",
"open",
"(",
"source_path",
",",
"... | 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.
... | [
"The",
"encoding",
"used",
"by",
"the",
"text",
"file",
"stored",
"in",
"source_path",
"."
] | c2c150a534ba5be498eb39cb78fc6a531d62f145 | https://github.com/roskakori/pygount/blob/c2c150a534ba5be498eb39cb78fc6a531d62f145/pygount/analysis.py#L340-L418 | train |
roskakori/pygount | pygount/analysis.py | has_lexer | 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))
... | python | 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",
")",
":",
"result",
"=",
"bool",
"(",
"pygments",
".",
"lexers",
".",
"find_lexer_class_for_filename",
"(",
"source_path",
")",
")",
"if",
"not",
"result",
":",
"suffix",
"=",
"os",
".",
"path",
".",
"splitext",
"(",... | 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. | [
"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",
... | c2c150a534ba5be498eb39cb78fc6a531d62f145 | https://github.com/roskakori/pygount/blob/c2c150a534ba5be498eb39cb78fc6a531d62f145/pygount/analysis.py#L459-L469 | train |
roskakori/pygount | pygount/analysis.py | source_analysis | 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:... | python | 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",
")",
","... | 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:... | [
"Analysis",
"for",
"line",
"counts",
"in",
"source",
"code",
"stored",
"in",
"source_path",
"."
] | c2c150a534ba5be498eb39cb78fc6a531d62f145 | https://github.com/roskakori/pygount/blob/c2c150a534ba5be498eb39cb78fc6a531d62f145/pygount/analysis.py#L484-L570 | train |
radjkarl/imgProcessor | DUMP/interpolationMethods.py | polynomial | 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... | python | 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",
")",
":",
"if",
"inplace",
":",
"out",
"=",
"img",
"else"... | 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 | [
"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",
"... | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/DUMP/interpolationMethods.py#L55-L88 | train |
radjkarl/imgProcessor | imgProcessor/uncertainty/simulateUncertDependencyOnExpTime.py | errorDist | 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... | python | 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",
")",
":",
"ntimes",
"=",
"10",
"s1",
"=",
"measExpTime",
"*",
"scale",
... | TODO | [
"TODO"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/uncertainty/simulateUncertDependencyOnExpTime.py#L15-L47 | train |
radjkarl/imgProcessor | imgProcessor/uncertainty/simulateUncertDependencyOnExpTime.py | exampleSignals | 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)
... | python | 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",
")",
":",
"np",
".",
"random",
".",
"seed",
"(",
"123",... | std ... standard deviation of every signal
dur1...dur3 --> event duration per second
n1...n3 --> number of events per second | [
"std",
"...",
"standard",
"deviation",
"of",
"every",
"signal",
"dur1",
"...",
"dur3",
"--",
">",
"event",
"duration",
"per",
"second",
"n1",
"...",
"n3",
"--",
">",
"number",
"of",
"events",
"per",
"second"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/uncertainty/simulateUncertDependencyOnExpTime.py#L50-L63 | train |
radjkarl/imgProcessor | imgProcessor/uncertainty/simulateUncertDependencyOnExpTime.py | _flux | 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
'''
... | python | 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",
")",
":",
"duration",
"*=",
"len",
"(",
"t",
")",
"/",
"t",
"[",
"-",
"1",
"]",
"duration",
"=",
"int",
"(",
"max",
"(",
"duration",
",",
"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",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/uncertainty/simulateUncertDependencyOnExpTime.py#L66-L113 | train |
radjkarl/imgProcessor | imgProcessor/uncertainty/simulateUncertDependencyOnExpTime.py | _capture | 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... | python | 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",
")",
":",
"n_per_sec",
"=",
"len",
"(",
"t",
")",
"/",
"t",
"[",
"-",
"1",
"]",
"# len of one split:\r",
"n",
"=",
"int",
"(",
"t0",
"*",
"factor",
"*",
"n_per_sec",
")",
"s",
"="... | capture signal and return its standard deviation
#TODO: more detail | [
"capture",
"signal",
"and",
"return",
"its",
"standard",
"deviation",
"#TODO",
":",
"more",
"detail"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/uncertainty/simulateUncertDependencyOnExpTime.py#L116-L131 | train |
radjkarl/imgProcessor | imgProcessor/utils/genericCameraMatrix.py | genericCameraMatrix | 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 ... | python | 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",
")",
":",
"# http://nghiaho.com/?page_id=576\r",
"# assume that the optical centre is in the middle:\r",
"cy",
"=",
"int",
"(",
"shape",
"[",
"0",
"]",
"/",
"2",
")",
"cx",
"=",
"int",
"("... | Return a generic camera matrix
[[fx, 0, cx],
[ 0, fy, cy],
[ 0, 0, 1]]
for a given image shape | [
"Return",
"a",
"generic",
"camera",
"matrix",
"[[",
"fx",
"0",
"cx",
"]",
"[",
"0",
"fy",
"cy",
"]",
"[",
"0",
"0",
"1",
"]]",
"for",
"a",
"given",
"image",
"shape"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/utils/genericCameraMatrix.py#L7-L28 | train |
radjkarl/imgProcessor | imgProcessor/filters/standardDeviation.py | standardDeviation2d | 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
... | python | 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",
")",
":",
"if",
"ksize",
"not",
"in",
"(",
"list",
",",
"tuple",
")",
":",
"ksize",
"=",
"(",
"ksize",
",",
"ksize",
")",
"if",
"blurred",
"is",
"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... | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/filters/standardDeviation.py#L9-L31 | train |
radjkarl/imgProcessor | imgProcessor/filters/maskedFilter.py | maskedFilter | 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... | python | 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'",
")",
":",
"if",
"fill_mask",
":",
"mask1",
"=",
"mask",
"out",
"=",
"arr",
"else",
":",
"mask1",
"=",
"~",
"mask",
... | fn['mean', 'median']
fill_mask=True:
replaced masked areas with filtered results
fill_mask=False:
masked areas are ignored | [
"fn",
"[",
"mean",
"median",
"]",
"fill_mask",
"=",
"True",
":",
"replaced",
"masked",
"areas",
"with",
"filtered",
"results",
"fill_mask",
"=",
"False",
":",
"masked",
"areas",
"are",
"ignored"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/filters/maskedFilter.py#L12-L37 | train |
radjkarl/imgProcessor | imgProcessor/camera/flatField/vignettingFromDifferentObjects.py | vignettingFromDifferentObjects | 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... | python | 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",
")",
":",
"f",
"=",
"FlatFieldFromImgFit",
"(",
"imgs",
",",
"bg",
")",
"return",
"f",
".",
"result",
",",
"f",
".",
"mask"
] | 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
--- | [
"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"... | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/flatField/vignettingFromDifferentObjects.py#L129-L144 | train |
radjkarl/imgProcessor | imgProcessor/measure/SNR/SNR_IEC.py | SNR_IEC | 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.... | python | 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",
")",
":",
"# ensure images are type float64 (double precision):\r",
"i1",
"=",
"np",
".",
"asfarray",
"(",
"i1",
")",
"i2",
"=",
"np",
".",
"asfarray",
"... | Calculate the averaged signal-to-noise ratio SNR50
as defined by IEC NP 60904-13
needs 2 reference EL images and one background image | [
"Calculate",
"the",
"averaged",
"signal",
"-",
"to",
"-",
"noise",
"ratio",
"SNR50",
"as",
"defined",
"by",
"IEC",
"NP",
"60904",
"-",
"13",
"needs",
"2",
"reference",
"EL",
"images",
"and",
"one",
"background",
"image"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/measure/SNR/SNR_IEC.py#L7-L33 | train |
radjkarl/imgProcessor | imgProcessor/transform/StitchImages.py | StitchImages._rotate | 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... | python | 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",
")",
":",
"s",
"=",
"img",
".",
"shape",
"if",
"angle",
"==",
"0",
":",
"return",
"img",
"else",
":",
"M",
"=",
"cv2",
".",
"getRotationMatrix2D",
"(",
"(",
"s",
"[",
"1",
"]",
"//",
"2",
",",
"s",
... | angle [DEG] | [
"angle",
"[",
"DEG",
"]"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transform/StitchImages.py#L83-L93 | train |
radjkarl/imgProcessor | imgProcessor/transform/StitchImages.py | StitchImages._findOverlap | 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):
... | python | 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",
")",
":",
"# get gray images\r",
"if",
"len",
"(",
"img_rgb",
".",
"shape",
")",
"!=",
"len",
"(",
"img_rgb",
".",
"shape"... | return offset(x,y) which fit best self._base_img
through template matching | [
"return",
"offset",
"(",
"x",
"y",
")",
"which",
"fit",
"best",
"self",
".",
"_base_img",
"through",
"template",
"matching"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transform/StitchImages.py#L95-L136 | train |
radjkarl/imgProcessor | imgProcessor/camera/NoiseLevelFunction.py | estimateFromImages | 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:
... | python | 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",
")",
":",
"if",
"imgs2",
"is",
"None",
":",
"imgs2",
"=",
"[",
"None",
"]",
"*",
"len",
"(",
"imgs1",
")",
"else",
":",
"as... | 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 | [
"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",
"["... | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/NoiseLevelFunction.py#L11-L68 | train |
radjkarl/imgProcessor | imgProcessor/camera/NoiseLevelFunction.py | _evaluate | 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... | python | 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",
")",
":",
"i",
"=",
"_validI",
"(",
"x",
",",
"y",
",",
"weights",
")",
"xx",
"=",
"x",
"[",
"i",
"]",
"y",
"=",
"y",
"[",
"i",
"]",
"try",
":",
"fitParams",
"=",
"_fit",
"(",
"xx",
... | get the parameters of the, needed by 'function'
through curve fitting | [
"get",
"the",
"parameters",
"of",
"the",
"needed",
"by",
"function",
"through",
"curve",
"fitting"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/NoiseLevelFunction.py#L71-L91 | train |
radjkarl/imgProcessor | imgProcessor/camera/NoiseLevelFunction.py | boundedFunction | 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) | python | 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",
")",
":",
"y",
"=",
"function",
"(",
"x",
",",
"ax",
",",
"ay",
")",
"return",
"np",
".",
"maximum",
"(",
"np",
".",
"nan_to_num",
"(",
"y",
")",
",",
"minY",
")"
] | limit [function] to a minimum y value | [
"limit",
"[",
"function",
"]",
"to",
"a",
"minimum",
"y",
"value"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/NoiseLevelFunction.py#L94-L99 | train |
radjkarl/imgProcessor | imgProcessor/camera/NoiseLevelFunction.py | function | def function(x, ax, ay):
'''
general square root function
'''
with np.errstate(invalid='ignore'):
return ay * (x - ax)**0.5 | python | 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",
")",
":",
"with",
"np",
".",
"errstate",
"(",
"invalid",
"=",
"'ignore'",
")",
":",
"return",
"ay",
"*",
"(",
"x",
"-",
"ax",
")",
"**",
"0.5"
] | general square root function | [
"general",
"square",
"root",
"function"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/NoiseLevelFunction.py#L102-L107 | train |
radjkarl/imgProcessor | imgProcessor/camera/NoiseLevelFunction.py | _validI | 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... | python | 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",
")",
":",
"# density filter:\r",
"i",
"=",
"np",
".",
"logical_and",
"(",
"np",
".",
"isfinite",
"(",
"y",
")",
",",
"weights",
">",
"np",
".",
"median",
"(",
"weights",
")",
")",
"# filter outlie... | return indices that have enough data points and are not erroneous | [
"return",
"indices",
"that",
"have",
"enough",
"data",
"points",
"and",
"are",
"not",
"erroneous"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/NoiseLevelFunction.py#L110-L123 | train |
radjkarl/imgProcessor | imgProcessor/camera/NoiseLevelFunction.py | smooth | 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
# ... | python | 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",
")",
":",
"# 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",
"# ... | in case the NLF cannot be described by
a square root function
commit bounded polynomial interpolation | [
"in",
"case",
"the",
"NLF",
"cannot",
"be",
"described",
"by",
"a",
"square",
"root",
"function",
"commit",
"bounded",
"polynomial",
"interpolation"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/NoiseLevelFunction.py#L131-L150 | train |
radjkarl/imgProcessor | imgProcessor/camera/NoiseLevelFunction.py | oneImageNLF | 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 | python | 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",
")",
":",
"x",
",",
"y",
",",
"weights",
",",
"signal",
"=",
"calcNLF",
"(",
"img",
",",
"img2",
",",
"signal",
")",
"_",
",",
"fn",
",",
"_",
"=",
"_evalua... | Estimate the NLF from one or two images of the same kind | [
"Estimate",
"the",
"NLF",
"from",
"one",
"or",
"two",
"images",
"of",
"the",
"same",
"kind"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/NoiseLevelFunction.py#L153-L159 | train |
radjkarl/imgProcessor | imgProcessor/camera/NoiseLevelFunction.py | _getMinMax | 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) | python | 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",
")",
":",
"av",
"=",
"np",
".",
"mean",
"(",
"img",
")",
"std",
"=",
"np",
".",
"std",
"(",
"img",
")",
"# define range for segmentation:\r",
"mn",
"=",
"av",
"-",
"3",
"*",
"std",
"mx",
"=",
"av",
"+",
"3",
"*",
... | Get the a range of image intensities
that most pixels are in with | [
"Get",
"the",
"a",
"range",
"of",
"image",
"intensities",
"that",
"most",
"pixels",
"are",
"in",
"with"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/NoiseLevelFunction.py#L162-L173 | train |
radjkarl/imgProcessor | imgProcessor/camera/NoiseLevelFunction.py | calcNLF | 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... | python | 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",
")",
":",
"# CONSTANTS:\r",
"# fact... | 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... | [
"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... | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/NoiseLevelFunction.py#L176-L271 | train |
radjkarl/imgProcessor | imgProcessor/interpolate/polyfit2d.py | polyfit2d | 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... | python | 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\r",
")",
":",
"ncols",
"=",
"(",
"order",
"+",
"1",
")",
"**",
"2",
"G",
"=",
"np",
".",
"zeros",
"(",
"(",
"x",
".",
"size",
",",
"ncols",
")",
")",
"i... | fit unstructured data | [
"fit",
"unstructured",
"data"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/interpolate/polyfit2d.py#L8-L19 | train |
radjkarl/imgProcessor | imgProcessor/interpolate/polyfit2d.py | polyfit2dGrid | 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)]
... | python | 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",
")",
":",
"s0",
",",
"s1",
"=",
"arr",
".",
"shape",
"if",
"mask",
"is"... | replace all masked values with polynomial fitted ones | [
"replace",
"all",
"masked",
"values",
"with",
"polynomial",
"fitted",
"ones"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/interpolate/polyfit2d.py#L31-L65 | train |
radjkarl/imgProcessor | imgProcessor/features/minimumLineInArray.py | minimumLineInArray | 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... | python | 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\r",
")",
":",
"s0",
",",
"s1",
"=",
"arr",
... | 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 | [
"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"... | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/features/minimumLineInArray.py#L27-L72 | train |
radjkarl/imgProcessor | imgProcessor/filters/FourierFilter.py | FourierFilter.highPassFilter | 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
... | python | 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",
")",
":",
"if",
"not",
"threshold",
":",
"return",
"rows",
",",
"cols",
"=",
"self",
".",
"img",
".",
"shape",
"tx",
"=",
"int",
"(",
"cols",
"*",
"threshold",
")",
"ty",
"=",
"int",
"(",
"row... | 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 | [
"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"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/filters/FourierFilter.py#L27-L41 | train |
radjkarl/imgProcessor | imgProcessor/filters/FourierFilter.py | FourierFilter.lowPassFilter | 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... | python | 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",
")",
":",
"if",
"not",
"threshold",
":",
"return",
"rows",
",",
"cols",
"=",
"self",
".",
"img",
".",
"shape",
"tx",
"=",
"int",
"(",
"cols",
"*",
"threshold",
"*",
"0.25",
")",
"ty",
"=",
"int... | remove all high frequencies by setting boundary around a quarry in the middle
of the size (2*threshold)^2 to zero
threshold = 0...1 | [
"remove",
"all",
"high",
"frequencies",
"by",
"setting",
"boundary",
"around",
"a",
"quarry",
"in",
"the",
"middle",
"of",
"the",
"size",
"(",
"2",
"*",
"threshold",
")",
"^2",
"to",
"zero",
"threshold",
"=",
"0",
"...",
"1"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/filters/FourierFilter.py#L43-L61 | train |
radjkarl/imgProcessor | imgProcessor/filters/FourierFilter.py | FourierFilter.reconstructImage | 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)) | python | 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",
")",
":",
"f_ishift",
"=",
"np",
".",
"fft",
".",
"ifftshift",
"(",
"self",
".",
"fshift",
")",
"return",
"np",
".",
"real",
"(",
"np",
".",
"fft",
".",
"ifft2",
"(",
"f_ishift",
")",
")"
] | do inverse Fourier transform and return result | [
"do",
"inverse",
"Fourier",
"transform",
"and",
"return",
"result"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/filters/FourierFilter.py#L108-L113 | train |
radjkarl/imgProcessor | imgProcessor/interpolate/interpolate2dUnstructuredIDW.py | interpolate2dUnstructuredIDW | 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... | python | 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",
")",
":",
"n",
"=",
"len",
"(",
"v",
")",
"gx",
"=",
"grid",
".",
"shape",
"[",
"0",
"]",
"gy",
"=",
"grid",
".",
"shape",
"[",
"1",
"]"... | x,y,v --> 1d numpy.array
grid --> 2d numpy.array
fast if number of given values is small relative to grid resolution | [
"x",
"y",
"v",
"--",
">",
"1d",
"numpy",
".",
"array",
"grid",
"--",
">",
"2d",
"numpy",
".",
"array",
"fast",
"if",
"number",
"of",
"given",
"values",
"is",
"small",
"relative",
"to",
"grid",
"resolution"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/interpolate/interpolate2dUnstructuredIDW.py#L8-L38 | train |
radjkarl/imgProcessor | imgProcessor/features/hog.py | hog | 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... | python | 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",
")",
")",
":",
"s0",
",",
"s1",
"=",
"image",
".",
"shape",
"[",
":",
"2",
"]",
"# speed up the process through saving generated kernels:\r",
"try",
":",
... | 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 | [
"returns",
"the",
"Histogram",
"of",
"Oriented",
"Gradients",
":",
"param",
"ksize",
":",
"convolution",
"kernel",
"size",
"as",
"(",
"y",
"x",
")",
"-",
"needs",
"to",
"be",
"odd",
":",
"param",
"orientations",
":",
"number",
"of",
"orientations",
"in",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/features/hog.py#L40-L64 | train |
radjkarl/imgProcessor | imgProcessor/features/hog.py | visualize | 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])
... | python | 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",
")",
":",
"s0",
",",
"s1",
",",
"nang",
"=",
"hog",
".",
"shape",
"angles",
"=",
"np",
".",
"linspace",
"(",
"0",
",",
"np",
".",
"pi"... | visualize HOG as polynomial around cell center
for [grid] * cells | [
"visualize",
"HOG",
"as",
"polynomial",
"around",
"cell",
"center",
"for",
"[",
"grid",
"]",
"*",
"cells"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/features/hog.py#L68-L105 | train |
radjkarl/imgProcessor | imgProcessor/camera/flatField/postProcessing.py | postProcessing | 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.:
... | python | 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",
")",
":",
"assert",
"method",
"in",
"ppMETHODS",
",",
"'post processing method (%s) must be one of %s'",
"%",
"(",
"method",
",",
"ppMETHODS",
")",
"if",
"... | 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... | [
"Post",
"process",
"measured",
"flat",
"field",
"[",
"arr",
"]",
".",
"Depending",
"on",
"the",
"measurement",
"different",
"post",
"processing",
"[",
"method",
"]",
"s",
"are",
"beneficial",
".",
"The",
"available",
"methods",
"are",
"presented",
"in",
"---... | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/flatField/postProcessing.py#L16-L74 | train |
radjkarl/imgProcessor | imgProcessor/transform/rmBorder.py | rmBorder | 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... | python | 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",
")",
":",
"if",
"border",
"is",
"None",
":",
"pass",
"elif",
"len",
"(",
"border",
")",
"==",
"2",
":",
"s0",
"=",
"slice",
"(",
"border",
"[",
"0",
"]",
"[",
"1",
"]",
",",
"border",
... | 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... | [
"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",
"[... | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transform/rmBorder.py#L6-L36 | train |
radjkarl/imgProcessor | imgProcessor/features/SingleTimeEffectDetection.py | SingleTimeEffectDetection.addImage | 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:
... | python | 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",
")",
":",
"self",
".",
"_last_diff",
"=",
"diff",
"=",
"image",
"-",
"self",
".",
"noSTE",
"ste",
"=",
"diff",
">",
"self",
".",
"threshold",
"removeSinglePixels",
"(",
"ste",
")... | #########
mask -- optional | [
"#########",
"mask",
"--",
"optional"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/features/SingleTimeEffectDetection.py#L55-L75 | train |
radjkarl/imgProcessor | imgProcessor/features/SingleTimeEffectDetection.py | SingleTimeEffectDetection.relativeAreaSTE | def relativeAreaSTE(self):
'''
return STE area - relative to image area
'''
s = self.noSTE.shape
return np.sum(self.mask_STE) / (s[0] * s[1]) | python | 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",
")",
":",
"s",
"=",
"self",
".",
"noSTE",
".",
"shape",
"return",
"np",
".",
"sum",
"(",
"self",
".",
"mask_STE",
")",
"/",
"(",
"s",
"[",
"0",
"]",
"*",
"s",
"[",
"1",
"]",
")"
] | return STE area - relative to image area | [
"return",
"STE",
"area",
"-",
"relative",
"to",
"image",
"area"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/features/SingleTimeEffectDetection.py#L83-L88 | train |
radjkarl/imgProcessor | imgProcessor/features/SingleTimeEffectDetection.py | SingleTimeEffectDetection.intensityDistributionSTE | 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) | python | 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",
")",
":",
"v",
"=",
"np",
".",
"abs",
"(",
"self",
".",
"_last_diff",
"[",
"self",
".",
"mask_STE",
"]",
")",
"return",
"np",
".",
"histogram",
"(",
... | return distribution of STE intensity | [
"return",
"distribution",
"of",
"STE",
"intensity"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/features/SingleTimeEffectDetection.py#L90-L95 | train |
radjkarl/imgProcessor | imgProcessor/transformations.py | toUIntArray | 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... | python | 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",
")",
":",
"mn",
",",
"mx",
"=",
"None",
",",
"None",
"if",
"range",
"i... | 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 | [
"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"... | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transformations.py#L11-L75 | train |
radjkarl/imgProcessor | imgProcessor/transformations.py | toFloatArray | 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]) | python | 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",
")",
":",
"_D",
"=",
"{",
"1",
":",
"np",
".",
"float32",
",",
"# uint8\r",
"2",
":",
"np",
".",
"float32",
",",
"# uint16\r",
"4",
":",
"np",
".",
"float64",
",",
"# uint32\r",
"8",
":",
"np",
".",
"float64",
"... | transform an unsigned integer array into a
float array of the right size | [
"transform",
"an",
"unsigned",
"integer",
"array",
"into",
"a",
"float",
"array",
"of",
"the",
"right",
"size"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transformations.py#L78-L87 | train |
radjkarl/imgProcessor | imgProcessor/transformations.py | toNoUintArray | 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 | python | 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",
")",
":",
"d",
"=",
"arr",
".",
"dtype",
"if",
"d",
".",
"kind",
"==",
"'u'",
":",
"arr",
"=",
"arr",
".",
"astype",
"(",
"{",
"1",
":",
"np",
".",
"int16",
",",
"2",
":",
"np",
".",
"int32",
",",
"4",
":... | cast array to the next higher integer array
if dtype=unsigned integer | [
"cast",
"array",
"to",
"the",
"next",
"higher",
"integer",
"array",
"if",
"dtype",
"=",
"unsigned",
"integer"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transformations.py#L90-L100 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.