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 3
values | summary stringlengths 4 350 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
nilp0inter/cpe | cpe/cpeset1_1.py | CPESet1_1.name_match | def name_match(self, cpe):
"""
Accepts a set of known instances of CPE Names and a candidate CPE Name,
and returns 'True' if the candidate can be shown to be
an instance based on the content of the known instances.
Otherwise, it returns 'False'.
:param CPESet self: A set... | python | def name_match(self, cpe):
"""
Accepts a set of known instances of CPE Names and a candidate CPE Name,
and returns 'True' if the candidate can be shown to be
an instance based on the content of the known instances.
Otherwise, it returns 'False'.
:param CPESet self: A set... | [
"def",
"name_match",
"(",
"self",
",",
"cpe",
")",
":",
"# An empty set not matching with any CPE",
"if",
"len",
"(",
"self",
")",
"==",
"0",
":",
"return",
"False",
"# If input CPE Name string is in set of CPE Name strings",
"# not do searching more because there is a matchi... | Accepts a set of known instances of CPE Names and a candidate CPE Name,
and returns 'True' if the candidate can be shown to be
an instance based on the content of the known instances.
Otherwise, it returns 'False'.
:param CPESet self: A set of m known CPE Names K = {K1, K2, …, Km}.
... | [
"Accepts",
"a",
"set",
"of",
"known",
"instances",
"of",
"CPE",
"Names",
"and",
"a",
"candidate",
"CPE",
"Name",
"and",
"returns",
"True",
"if",
"the",
"candidate",
"can",
"be",
"shown",
"to",
"be",
"an",
"instance",
"based",
"on",
"the",
"content",
"of"... | 670d947472a7652af5149324977b50f9a7af9bcf | https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpeset1_1.py#L85-L169 | train | Tests if a set of known instances of a candidate CPE Name X matches a set of known instances of a candidate CPE Name X and returns True if the candidate can be shown to be
otherwise False. |
nilp0inter/cpe | cpe/cpe2_3_fs.py | CPE2_3_FS._parse | def _parse(self):
"""
Checks if the CPE Name is valid.
:returns: None
:exception: ValueError - bad-formed CPE Name
"""
# CPE Name must not have whitespaces
if (self._str.find(" ") != -1):
msg = "Bad-formed CPE Name: it must not have whitespaces"
... | python | def _parse(self):
"""
Checks if the CPE Name is valid.
:returns: None
:exception: ValueError - bad-formed CPE Name
"""
# CPE Name must not have whitespaces
if (self._str.find(" ") != -1):
msg = "Bad-formed CPE Name: it must not have whitespaces"
... | [
"def",
"_parse",
"(",
"self",
")",
":",
"# CPE Name must not have whitespaces",
"if",
"(",
"self",
".",
"_str",
".",
"find",
"(",
"\" \"",
")",
"!=",
"-",
"1",
")",
":",
"msg",
"=",
"\"Bad-formed CPE Name: it must not have whitespaces\"",
"raise",
"ValueError",
... | Checks if the CPE Name is valid.
:returns: None
:exception: ValueError - bad-formed CPE Name | [
"Checks",
"if",
"the",
"CPE",
"Name",
"is",
"valid",
"."
] | 670d947472a7652af5149324977b50f9a7af9bcf | https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpe2_3_fs.py#L130-L199 | train | Checks if the CPE Name is valid. |
nilp0inter/cpe | cpe/cpe2_3_fs.py | CPE2_3_FS.get_attribute_values | def get_attribute_values(self, att_name):
"""
Returns the values of attribute "att_name" of CPE Name.
By default a only element in each part.
:param string att_name: Attribute name to get
:returns: List of attribute values
:rtype: list
:exception: ValueError - in... | python | def get_attribute_values(self, att_name):
"""
Returns the values of attribute "att_name" of CPE Name.
By default a only element in each part.
:param string att_name: Attribute name to get
:returns: List of attribute values
:rtype: list
:exception: ValueError - in... | [
"def",
"get_attribute_values",
"(",
"self",
",",
"att_name",
")",
":",
"lc",
"=",
"[",
"]",
"if",
"not",
"CPEComponent",
".",
"is_valid_attribute",
"(",
"att_name",
")",
":",
"errmsg",
"=",
"\"Invalid attribute name: {0}\"",
".",
"format",
"(",
"att_name",
")"... | Returns the values of attribute "att_name" of CPE Name.
By default a only element in each part.
:param string att_name: Attribute name to get
:returns: List of attribute values
:rtype: list
:exception: ValueError - invalid attribute name | [
"Returns",
"the",
"values",
"of",
"attribute",
"att_name",
"of",
"CPE",
"Name",
".",
"By",
"default",
"a",
"only",
"element",
"in",
"each",
"part",
"."
] | 670d947472a7652af5149324977b50f9a7af9bcf | https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpe2_3_fs.py#L201-L233 | train | Returns the values of attribute att_name of CPE Name. By default a only element in each part. |
nilp0inter/cpe | cpe/cpe2_2.py | CPE2_2._parse | def _parse(self):
"""
Checks if CPE Name is valid.
:returns: None
:exception: ValueError - bad-formed CPE Name
"""
# CPE Name must not have whitespaces
if (self._str.find(" ") != -1):
msg = "Bad-formed CPE Name: it must not have whitespaces"
... | python | def _parse(self):
"""
Checks if CPE Name is valid.
:returns: None
:exception: ValueError - bad-formed CPE Name
"""
# CPE Name must not have whitespaces
if (self._str.find(" ") != -1):
msg = "Bad-formed CPE Name: it must not have whitespaces"
... | [
"def",
"_parse",
"(",
"self",
")",
":",
"# CPE Name must not have whitespaces",
"if",
"(",
"self",
".",
"_str",
".",
"find",
"(",
"\" \"",
")",
"!=",
"-",
"1",
")",
":",
"msg",
"=",
"\"Bad-formed CPE Name: it must not have whitespaces\"",
"raise",
"ValueError",
... | Checks if CPE Name is valid.
:returns: None
:exception: ValueError - bad-formed CPE Name | [
"Checks",
"if",
"CPE",
"Name",
"is",
"valid",
"."
] | 670d947472a7652af5149324977b50f9a7af9bcf | https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpe2_2.py#L127-L193 | train | Checks if the CPE Name is valid. |
nilp0inter/cpe | cpe/cpe2_2.py | CPE2_2.as_wfn | def as_wfn(self):
"""
Returns the CPE Name as WFN string of version 2.3.
Only shows the first seven components.
:return: CPE Name as WFN string
:rtype: string
:exception: TypeError - incompatible version
"""
wfn = []
wfn.append(CPE2_3_WFN.CPE_PRE... | python | def as_wfn(self):
"""
Returns the CPE Name as WFN string of version 2.3.
Only shows the first seven components.
:return: CPE Name as WFN string
:rtype: string
:exception: TypeError - incompatible version
"""
wfn = []
wfn.append(CPE2_3_WFN.CPE_PRE... | [
"def",
"as_wfn",
"(",
"self",
")",
":",
"wfn",
"=",
"[",
"]",
"wfn",
".",
"append",
"(",
"CPE2_3_WFN",
".",
"CPE_PREFIX",
")",
"for",
"ck",
"in",
"CPEComponent",
".",
"CPE_COMP_KEYS",
":",
"lc",
"=",
"self",
".",
"_get_attribute_components",
"(",
"ck",
... | Returns the CPE Name as WFN string of version 2.3.
Only shows the first seven components.
:return: CPE Name as WFN string
:rtype: string
:exception: TypeError - incompatible version | [
"Returns",
"the",
"CPE",
"Name",
"as",
"WFN",
"string",
"of",
"version",
"2",
".",
"3",
".",
"Only",
"shows",
"the",
"first",
"seven",
"components",
"."
] | 670d947472a7652af5149324977b50f9a7af9bcf | https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpe2_2.py#L195-L238 | train | Returns the CPE Name as WFN string of version 2. 3. |
nilp0inter/cpe | cpe/cpelang2_3.py | CPELanguage2_3._fact_ref_eval | def _fact_ref_eval(cls, cpeset, wfn):
"""
Returns True if wfn is a non-proper superset (True superset
or equal to) any of the names in cpeset, otherwise False.
:param CPESet cpeset: list of CPE bound Names.
:param CPE2_3_WFN wfn: WFN CPE Name.
:returns: True if wfn is a ... | python | def _fact_ref_eval(cls, cpeset, wfn):
"""
Returns True if wfn is a non-proper superset (True superset
or equal to) any of the names in cpeset, otherwise False.
:param CPESet cpeset: list of CPE bound Names.
:param CPE2_3_WFN wfn: WFN CPE Name.
:returns: True if wfn is a ... | [
"def",
"_fact_ref_eval",
"(",
"cls",
",",
"cpeset",
",",
"wfn",
")",
":",
"for",
"n",
"in",
"cpeset",
":",
"# Need to convert each n from bound form to WFN",
"if",
"(",
"CPESet2_3",
".",
"cpe_superset",
"(",
"wfn",
",",
"n",
")",
")",
":",
"return",
"True",
... | Returns True if wfn is a non-proper superset (True superset
or equal to) any of the names in cpeset, otherwise False.
:param CPESet cpeset: list of CPE bound Names.
:param CPE2_3_WFN wfn: WFN CPE Name.
:returns: True if wfn is a non-proper superset any of the names in cpeset, otherwise ... | [
"Returns",
"True",
"if",
"wfn",
"is",
"a",
"non",
"-",
"proper",
"superset",
"(",
"True",
"superset",
"or",
"equal",
"to",
")",
"any",
"of",
"the",
"names",
"in",
"cpeset",
"otherwise",
"False",
"."
] | 670d947472a7652af5149324977b50f9a7af9bcf | https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpelang2_3.py#L62-L78 | train | Returns True if wfn is a proper superset of any of the names in cpeset False otherwise. |
nilp0inter/cpe | cpe/cpelang2_3.py | CPELanguage2_3._check_fact_ref_eval | def _check_fact_ref_eval(cls, cpel_dom):
"""
Returns the result (True, False, Error) of performing the specified
check, unless the check isnt supported, in which case it returns
False. Error is a catch-all for all results other than True and
False.
:param string cpel_do... | python | def _check_fact_ref_eval(cls, cpel_dom):
"""
Returns the result (True, False, Error) of performing the specified
check, unless the check isnt supported, in which case it returns
False. Error is a catch-all for all results other than True and
False.
:param string cpel_do... | [
"def",
"_check_fact_ref_eval",
"(",
"cls",
",",
"cpel_dom",
")",
":",
"CHECK_SYSTEM",
"=",
"\"check-system\"",
"CHECK_LOCATION",
"=",
"\"check-location\"",
"CHECK_ID",
"=",
"\"check-id\"",
"checksystemID",
"=",
"cpel_dom",
".",
"getAttribute",
"(",
"CHECK_SYSTEM",
")"... | Returns the result (True, False, Error) of performing the specified
check, unless the check isnt supported, in which case it returns
False. Error is a catch-all for all results other than True and
False.
:param string cpel_dom: XML infoset for the check_fact_ref element.
:retur... | [
"Returns",
"the",
"result",
"(",
"True",
"False",
"Error",
")",
"of",
"performing",
"the",
"specified",
"check",
"unless",
"the",
"check",
"isnt",
"supported",
"in",
"which",
"case",
"it",
"returns",
"False",
".",
"Error",
"is",
"a",
"catch",
"-",
"all",
... | 670d947472a7652af5149324977b50f9a7af9bcf | https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpelang2_3.py#L81-L114 | train | This function evaluates the check - fact - ref element and returns the result of performing the specified check - fact - ref check. |
nilp0inter/cpe | cpe/cpelang2_3.py | CPELanguage2_3._unbind | def _unbind(cls, boundname):
"""
Unbinds a bound form to a WFN.
:param string boundname: CPE name
:returns: WFN object associated with boundname.
:rtype: CPE2_3_WFN
"""
try:
fs = CPE2_3_FS(boundname)
except:
# CPE name is not form... | python | def _unbind(cls, boundname):
"""
Unbinds a bound form to a WFN.
:param string boundname: CPE name
:returns: WFN object associated with boundname.
:rtype: CPE2_3_WFN
"""
try:
fs = CPE2_3_FS(boundname)
except:
# CPE name is not form... | [
"def",
"_unbind",
"(",
"cls",
",",
"boundname",
")",
":",
"try",
":",
"fs",
"=",
"CPE2_3_FS",
"(",
"boundname",
")",
"except",
":",
"# CPE name is not formatted string",
"try",
":",
"uri",
"=",
"CPE2_3_URI",
"(",
"boundname",
")",
"except",
":",
"# CPE name ... | Unbinds a bound form to a WFN.
:param string boundname: CPE name
:returns: WFN object associated with boundname.
:rtype: CPE2_3_WFN | [
"Unbinds",
"a",
"bound",
"form",
"to",
"a",
"WFN",
"."
] | 670d947472a7652af5149324977b50f9a7af9bcf | https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpelang2_3.py#L145-L166 | train | Unbinds a bound form to a WFN object. |
nilp0inter/cpe | cpe/cpelang2_3.py | CPELanguage2_3.language_match | def language_match(self, cpeset, cpel_dom=None):
"""
Accepts a set of known CPE Names and an expression in the CPE language,
and delivers the answer True if the expression matches with the set.
Otherwise, it returns False.
:param CPELanguage self: An expression in the CPE Applic... | python | def language_match(self, cpeset, cpel_dom=None):
"""
Accepts a set of known CPE Names and an expression in the CPE language,
and delivers the answer True if the expression matches with the set.
Otherwise, it returns False.
:param CPELanguage self: An expression in the CPE Applic... | [
"def",
"language_match",
"(",
"self",
",",
"cpeset",
",",
"cpel_dom",
"=",
"None",
")",
":",
"# Root element tag",
"TAG_ROOT",
"=",
"'#document'",
"# A container for child platform definitions",
"TAG_PLATSPEC",
"=",
"'cpe:platform-specification'",
"# Information about a platf... | Accepts a set of known CPE Names and an expression in the CPE language,
and delivers the answer True if the expression matches with the set.
Otherwise, it returns False.
:param CPELanguage self: An expression in the CPE Applicability
Language, represented as the XML infoset for the ... | [
"Accepts",
"a",
"set",
"of",
"known",
"CPE",
"Names",
"and",
"an",
"expression",
"in",
"the",
"CPE",
"language",
"and",
"delivers",
"the",
"answer",
"True",
"if",
"the",
"expression",
"matches",
"with",
"the",
"set",
".",
"Otherwise",
"it",
"returns",
"Fal... | 670d947472a7652af5149324977b50f9a7af9bcf | https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpelang2_3.py#L172-L277 | train | Returns True if the expression can be satisfied by the language matching with the set. |
nilp0inter/cpe | cpe/cpeset.py | CPESet.name_match | def name_match(self, cpe):
"""
Accepts a set of known instances of CPE Names and a candidate CPE Name,
and returns 'True' if the candidate can be shown to be
an instance based on the content of the known instances.
Otherwise, it returns 'False'.
:param CPESet self: A set... | python | def name_match(self, cpe):
"""
Accepts a set of known instances of CPE Names and a candidate CPE Name,
and returns 'True' if the candidate can be shown to be
an instance based on the content of the known instances.
Otherwise, it returns 'False'.
:param CPESet self: A set... | [
"def",
"name_match",
"(",
"self",
",",
"cpe",
")",
":",
"# An empty set not matching with any CPE",
"if",
"len",
"(",
"self",
")",
"==",
"0",
":",
"return",
"False",
"# If input CPE Name string is in set of CPE Name strings",
"# not do searching more because there is a matchi... | Accepts a set of known instances of CPE Names and a candidate CPE Name,
and returns 'True' if the candidate can be shown to be
an instance based on the content of the known instances.
Otherwise, it returns 'False'.
:param CPESet self: A set of m known CPE Names K = {K1, K2, …, Km}.
... | [
"Accepts",
"a",
"set",
"of",
"known",
"instances",
"of",
"CPE",
"Names",
"and",
"a",
"candidate",
"CPE",
"Name",
"and",
"returns",
"True",
"if",
"the",
"candidate",
"can",
"be",
"shown",
"to",
"be",
"an",
"instance",
"based",
"on",
"the",
"content",
"of"... | 670d947472a7652af5149324977b50f9a7af9bcf | https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpeset.py#L121-L195 | train | Returns True if the set of known instances of a candidate CPE Name X matches the set of known instances of a candidate CPE Name X. |
nilp0inter/cpe | cpe/comp/cpecomp2_2.py | CPEComponent2_2._decode | def _decode(self):
"""
Convert the encoded value of component to standard value (WFN value).
"""
result = []
idx = 0
s = self._encoded_value
while (idx < len(s)):
# Get the idx'th character of s
c = s[idx]
if (c in CPECompone... | python | def _decode(self):
"""
Convert the encoded value of component to standard value (WFN value).
"""
result = []
idx = 0
s = self._encoded_value
while (idx < len(s)):
# Get the idx'th character of s
c = s[idx]
if (c in CPECompone... | [
"def",
"_decode",
"(",
"self",
")",
":",
"result",
"=",
"[",
"]",
"idx",
"=",
"0",
"s",
"=",
"self",
".",
"_encoded_value",
"while",
"(",
"idx",
"<",
"len",
"(",
"s",
")",
")",
":",
"# Get the idx'th character of s",
"c",
"=",
"s",
"[",
"idx",
"]",... | Convert the encoded value of component to standard value (WFN value). | [
"Convert",
"the",
"encoded",
"value",
"of",
"component",
"to",
"standard",
"value",
"(",
"WFN",
"value",
")",
"."
] | 670d947472a7652af5149324977b50f9a7af9bcf | https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp2_2.py#L90-L113 | train | Decode the encoded value of component into a standard value. |
pysal/giddy | giddy/components.py | is_component | def is_component(w, ids):
"""Check if the set of ids form a single connected component
Parameters
----------
w : spatial weights boject
ids : list
identifiers of units that are tested to be a single connected
component
Returns
-------
True : if the list of ... | python | def is_component(w, ids):
"""Check if the set of ids form a single connected component
Parameters
----------
w : spatial weights boject
ids : list
identifiers of units that are tested to be a single connected
component
Returns
-------
True : if the list of ... | [
"def",
"is_component",
"(",
"w",
",",
"ids",
")",
":",
"components",
"=",
"0",
"marks",
"=",
"dict",
"(",
"[",
"(",
"node",
",",
"0",
")",
"for",
"node",
"in",
"ids",
"]",
")",
"q",
"=",
"[",
"]",
"for",
"node",
"in",
"ids",
":",
"if",
"marks... | Check if the set of ids form a single connected component
Parameters
----------
w : spatial weights boject
ids : list
identifiers of units that are tested to be a single connected
component
Returns
-------
True : if the list of ids represents a single connected... | [
"Check",
"if",
"the",
"set",
"of",
"ids",
"form",
"a",
"single",
"connected",
"component"
] | 13fae6c18933614be78e91a6b5060693bea33a04 | https://github.com/pysal/giddy/blob/13fae6c18933614be78e91a6b5060693bea33a04/giddy/components.py#L11-L50 | train | Checks if the set of ids form a single connected component. Returns True if the set of ids form a single connected component False otherwise |
pysal/giddy | giddy/components.py | check_contiguity | def check_contiguity(w, neighbors, leaver):
"""Check if contiguity is maintained if leaver is removed from neighbors
Parameters
----------
w : spatial weights object
simple contiguity based weights
neighbors : list
nodes that are to be checked if th... | python | def check_contiguity(w, neighbors, leaver):
"""Check if contiguity is maintained if leaver is removed from neighbors
Parameters
----------
w : spatial weights object
simple contiguity based weights
neighbors : list
nodes that are to be checked if th... | [
"def",
"check_contiguity",
"(",
"w",
",",
"neighbors",
",",
"leaver",
")",
":",
"ids",
"=",
"neighbors",
"[",
":",
"]",
"ids",
".",
"remove",
"(",
"leaver",
")",
"return",
"is_component",
"(",
"w",
",",
"ids",
")"
] | Check if contiguity is maintained if leaver is removed from neighbors
Parameters
----------
w : spatial weights object
simple contiguity based weights
neighbors : list
nodes that are to be checked if they form a single \
connec... | [
"Check",
"if",
"contiguity",
"is",
"maintained",
"if",
"leaver",
"is",
"removed",
"from",
"neighbors"
] | 13fae6c18933614be78e91a6b5060693bea33a04 | https://github.com/pysal/giddy/blob/13fae6c18933614be78e91a6b5060693bea33a04/giddy/components.py#L53-L103 | train | Checks if a node is contiguity based on a set of neighbors. |
pyinvoke/invocations | invocations/console.py | confirm | def confirm(question, assume_yes=True):
"""
Ask user a yes/no question and return their response as a boolean.
``question`` should be a simple, grammatically complete question such as
"Do you wish to continue?", and will have a string similar to ``" [Y/n] "``
appended automatically. This function w... | python | def confirm(question, assume_yes=True):
"""
Ask user a yes/no question and return their response as a boolean.
``question`` should be a simple, grammatically complete question such as
"Do you wish to continue?", and will have a string similar to ``" [Y/n] "``
appended automatically. This function w... | [
"def",
"confirm",
"(",
"question",
",",
"assume_yes",
"=",
"True",
")",
":",
"# Set up suffix",
"if",
"assume_yes",
":",
"suffix",
"=",
"\"Y/n\"",
"else",
":",
"suffix",
"=",
"\"y/N\"",
"# Loop till we get something we like",
"# TODO: maybe don't do this? It can be anno... | Ask user a yes/no question and return their response as a boolean.
``question`` should be a simple, grammatically complete question such as
"Do you wish to continue?", and will have a string similar to ``" [Y/n] "``
appended automatically. This function will *not* append a question mark for
you.
B... | [
"Ask",
"user",
"a",
"yes",
"/",
"no",
"question",
"and",
"return",
"their",
"response",
"as",
"a",
"boolean",
"."
] | bbf1b319bd1536817d5301ceb9eeb2f31830e5dc | https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/console.py#L13-L59 | train | Ask user a yes or no question and return their response as a boolean. |
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 | Declare the view as a JSON API method |
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 | Download + unpack given package into temp dir tmp and return the real_version and source directory. |
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 | Vendorize a Python package into a specific version of a Crate or PyPI package. |
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 | Create a passworded sudo - capable user. |
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 | Create a new SSH directory and authorized_hosts for the current user. |
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 | Run some command under Travis - oriented sudo subshell. |
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 | Blacken the base node. |
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 | Calculate the concordance binary tree for a given set of nodes and their associated values. |
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 | Decorator to decorate a function |
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 | Test if the method matches the provided set of arguments. |
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 | Detect a view matching the method and route_params. |
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 | Register the view with an URL rule |
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 | Calculates the steady state probability vector for a regular Markov transition matrix P. |
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 | Calculates the matrix of first mean passage times for an ergodic Markov transition probability matrix. |
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 | Variances of first mean passage times for an ergodic transition probability matrix. |
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 | Return the state of the current release. |
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 | Print current release version changelog tag etc. |
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 | Prepare the contents of the a
. |
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 | Examine current repo state to determine what type of release to prep. |
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 | Return all released versions from given changelog dict sorted. |
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 | Return most recent release and issue numbers for a given branch. |
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 | Return sorted list of release - style tags as semver objects. |
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 | Try to find the One True Package for this project. |
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 | Build a new sdist and wheel archives. |
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 | Publish a single entry to PyPI or index of choice. |
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 | Upload all build artifacts in a directory. |
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 | Context - manage a temporary directory. |
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 | Generate ransom spatial permutations for inference on LISA vectors. |
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 | Plots the rose diagram of the current object. |
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 | Plot the LISA values starting from the same origin. |
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 | Plots the vectors of positional transition of LISA values in a scatterplot. |
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 | Clean the target directory of the Nuke docs build. |
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 | Open build target s index. html in a browser. |
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 | Build the project s Sphinx docs. |
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 | Display documentation contents with the tree program. |
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 | Build both doc sites w/ maxed nitpicking. |
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 | Watch both doc trees & rebuild them if files change. |
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 | Random permutation of rows and columns of a matrix. |
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 | Flattens the lower part of an n x n matrix into an n x n x 1 vector. |
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 | r Runs black on the current source tree. |
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 | Normalizes the response value into a 3 - tuple |
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 | Make a JsonResponse object from a response. |
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 | Returns a Markov - based mobility index. |
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 | chi - squared test of difference between two transition matrices. |
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 | Kullback test of Markov Homogeneity. |
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 | Returns a Prais conditional mobility measure for each class in the k - class hierarchy. |
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 | Test for homogeneity of Markov transition probabilities across regimes. |
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 | Calculate sojourn time based on a given transition probability matrix. |
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 | Helper method to estimate spatial lag conditioned Markov transition sequence probability matrices based on maximum likelihood techniques. |
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 | A summary method to test for the Markov homogeneity test. |
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 | Helper method for classifying continuous data. |
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 | Detect spillover locations for diffusion in LISA Markov. |
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 | Get entity property names |
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 | Get the set of property names that are loaded in the entity. |
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 | Returns a new version with a minor number greater than self s. version
. |
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 | Checks that the encoding of the given name is valid Python encoding. |
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 | Generator function to yield lines stored in a
. |
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 | Returns the first line and its regex that matches the source code. |
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 | Yields the pythonized comments for the given list of tokens. |
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 | Returns the encoding used by the text file stored in source_path. |
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 | Returns True if there is a lexer for source_path. |
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 | Analyzes the source code in the specified source file. |
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 | polyfit2dGrid - 2d polynomial fit |
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 | Returns the error distribution of a single event in a single time series. |
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 | Example signals. |
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 | Returns a new array of the same size as the original array. |
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 | capture signal and return its standard deviation |
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 | Returns a generic camera matrix for a given image shape |
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 | calculate the spatial resolved standard deviation of a given 2d array |
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 | Returns a new array with masked areas replaced with filtered results |
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 | Extract vignetting from a set of images containing different devices |
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 | Calculate the average signal - to - noise ratio of two images. |
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 | rotate the image by the given angle |
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 | find the best image that fits best self. _base_img |
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 | estimate the noise level function over images at the same position |
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 | evaluate the parameters of the necessary by function
through curve fitting
|
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 | limit [ function ] to a minimum y value
|
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 | A more efficient version of the n - th function |
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 | Returns indices that have enough data points and are not erroneous
|
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 | smooth the NLF with respect to the given weights |
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 | Estimate the NLF from one or two images of the same kind |
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 | Get the a range of image intensities
that most pixels are in with
|
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 | Calculates the noise level function for a single image and a signal. |
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 | Returns a new array with the polynomial fitted values in the order specified by the mask and order specified. |
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 | Returns the minimum position in an array. |
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 | Remove all low frequencies by setting a square in the middle of the Fourier transformation of the size ( 2 * threshold^2 to zero |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.