repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
dpursehouse/pygerrit2 | pygerrit2/rest/__init__.py | GerritRestAPI.translate_kwargs | def translate_kwargs(self, **kwargs):
"""Translate kwargs replacing `data` with `json` if necessary."""
local_kwargs = self.kwargs.copy()
local_kwargs.update(kwargs)
if "data" in local_kwargs and "json" in local_kwargs:
raise ValueError("Cannot use data and json together")
... | python | def translate_kwargs(self, **kwargs):
"""Translate kwargs replacing `data` with `json` if necessary."""
local_kwargs = self.kwargs.copy()
local_kwargs.update(kwargs)
if "data" in local_kwargs and "json" in local_kwargs:
raise ValueError("Cannot use data and json together")
... | [
"def",
"translate_kwargs",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"local_kwargs",
"=",
"self",
".",
"kwargs",
".",
"copy",
"(",
")",
"local_kwargs",
".",
"update",
"(",
"kwargs",
")",
"if",
"\"data\"",
"in",
"local_kwargs",
"and",
"\"json\"",
"i... | Translate kwargs replacing `data` with `json` if necessary. | [
"Translate",
"kwargs",
"replacing",
"data",
"with",
"json",
"if",
"necessary",
"."
] | train | https://github.com/dpursehouse/pygerrit2/blob/141031469603b33369d89c38c703390eb3786bd0/pygerrit2/rest/__init__.py#L133-L152 |
dpursehouse/pygerrit2 | pygerrit2/rest/__init__.py | GerritRestAPI.post | def post(self, endpoint, return_response=False, **kwargs):
"""Send HTTP POST to the endpoint.
:arg str endpoint: The endpoint to send to.
:returns:
JSON decoded result.
:raises:
requests.RequestException on timeout or connection error.
"""
args... | python | def post(self, endpoint, return_response=False, **kwargs):
"""Send HTTP POST to the endpoint.
:arg str endpoint: The endpoint to send to.
:returns:
JSON decoded result.
:raises:
requests.RequestException on timeout or connection error.
"""
args... | [
"def",
"post",
"(",
"self",
",",
"endpoint",
",",
"return_response",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"args",
"=",
"self",
".",
"translate_kwargs",
"(",
"*",
"*",
"kwargs",
")",
"response",
"=",
"self",
".",
"session",
".",
"post",
"(... | Send HTTP POST to the endpoint.
:arg str endpoint: The endpoint to send to.
:returns:
JSON decoded result.
:raises:
requests.RequestException on timeout or connection error. | [
"Send",
"HTTP",
"POST",
"to",
"the",
"endpoint",
"."
] | train | https://github.com/dpursehouse/pygerrit2/blob/141031469603b33369d89c38c703390eb3786bd0/pygerrit2/rest/__init__.py#L197-L216 |
dpursehouse/pygerrit2 | pygerrit2/__init__.py | escape_string | def escape_string(string):
"""Escape a string for use in Gerrit commands.
:arg str string: The string to escape.
:returns: The string with necessary escapes and surrounding double quotes
so that it can be passed to any of the Gerrit commands that require
double-quoted strings.
"""
... | python | def escape_string(string):
"""Escape a string for use in Gerrit commands.
:arg str string: The string to escape.
:returns: The string with necessary escapes and surrounding double quotes
so that it can be passed to any of the Gerrit commands that require
double-quoted strings.
"""
... | [
"def",
"escape_string",
"(",
"string",
")",
":",
"result",
"=",
"string",
"result",
"=",
"result",
".",
"replace",
"(",
"'\\\\'",
",",
"'\\\\\\\\'",
")",
"result",
"=",
"result",
".",
"replace",
"(",
"'\"'",
",",
"'\\\\\"'",
")",
"return",
"'\"'",
"+",
... | Escape a string for use in Gerrit commands.
:arg str string: The string to escape.
:returns: The string with necessary escapes and surrounding double quotes
so that it can be passed to any of the Gerrit commands that require
double-quoted strings. | [
"Escape",
"a",
"string",
"for",
"use",
"in",
"Gerrit",
"commands",
"."
] | train | https://github.com/dpursehouse/pygerrit2/blob/141031469603b33369d89c38c703390eb3786bd0/pygerrit2/__init__.py#L49-L62 |
dpursehouse/pygerrit2 | pygerrit2/__init__.py | GerritReviewMessageFormatter.append | def append(self, data):
"""Append the given `data` to the output.
:arg data: If a list, it is formatted as a bullet list with each
entry in the list being a separate bullet. Otherwise if it is a
string, the string is added as a paragraph.
:raises: ValueError if `data` ... | python | def append(self, data):
"""Append the given `data` to the output.
:arg data: If a list, it is formatted as a bullet list with each
entry in the list being a separate bullet. Otherwise if it is a
string, the string is added as a paragraph.
:raises: ValueError if `data` ... | [
"def",
"append",
"(",
"self",
",",
"data",
")",
":",
"if",
"not",
"data",
":",
"return",
"if",
"isinstance",
"(",
"data",
",",
"list",
")",
":",
"# First we need to clean up the data.",
"#",
"# Gerrit creates new bullet items when it gets newline characters",
"# withi... | Append the given `data` to the output.
:arg data: If a list, it is formatted as a bullet list with each
entry in the list being a separate bullet. Otherwise if it is a
string, the string is added as a paragraph.
:raises: ValueError if `data` is not a list or a string. | [
"Append",
"the",
"given",
"data",
"to",
"the",
"output",
"."
] | train | https://github.com/dpursehouse/pygerrit2/blob/141031469603b33369d89c38c703390eb3786bd0/pygerrit2/__init__.py#L87-L125 |
dpursehouse/pygerrit2 | pygerrit2/__init__.py | GerritReviewMessageFormatter.format | def format(self):
"""Format the message parts to a string.
:Returns: A string of all the message parts separated into paragraphs,
with header and footer paragraphs if they were specified in the
constructor.
"""
message = ""
if self.paragraphs:
... | python | def format(self):
"""Format the message parts to a string.
:Returns: A string of all the message parts separated into paragraphs,
with header and footer paragraphs if they were specified in the
constructor.
"""
message = ""
if self.paragraphs:
... | [
"def",
"format",
"(",
"self",
")",
":",
"message",
"=",
"\"\"",
"if",
"self",
".",
"paragraphs",
":",
"if",
"self",
".",
"header",
":",
"message",
"+=",
"(",
"self",
".",
"header",
"+",
"'\\n\\n'",
")",
"message",
"+=",
"\"\\n\\n\"",
".",
"join",
"("... | Format the message parts to a string.
:Returns: A string of all the message parts separated into paragraphs,
with header and footer paragraphs if they were specified in the
constructor. | [
"Format",
"the",
"message",
"parts",
"to",
"a",
"string",
"."
] | train | https://github.com/dpursehouse/pygerrit2/blob/141031469603b33369d89c38c703390eb3786bd0/pygerrit2/__init__.py#L135-L150 |
Zimbra-Community/python-zimbra | pythonzimbra/request.py | Request.set_context_params | def set_context_params(self, params):
""" Set header context parameters. Refer to the top of <Zimbra
Server-Root>/docs/soap.txt about specifics.
The <format>-Parameter cannot be changed, because it is set by the
implementing class.
Should be called by implementing method to ch... | python | def set_context_params(self, params):
""" Set header context parameters. Refer to the top of <Zimbra
Server-Root>/docs/soap.txt about specifics.
The <format>-Parameter cannot be changed, because it is set by the
implementing class.
Should be called by implementing method to ch... | [
"def",
"set_context_params",
"(",
"self",
",",
"params",
")",
":",
"for",
"key",
",",
"value",
"in",
"params",
".",
"items",
"(",
")",
":",
"if",
"key",
"not",
"in",
"self",
".",
"valid_context_params",
":",
"raise",
"RequestHeaderContextException",
"(",
"... | Set header context parameters. Refer to the top of <Zimbra
Server-Root>/docs/soap.txt about specifics.
The <format>-Parameter cannot be changed, because it is set by the
implementing class.
Should be called by implementing method to check for valid context
params.
:par... | [
"Set",
"header",
"context",
"parameters",
".",
"Refer",
"to",
"the",
"top",
"of",
"<Zimbra",
"Server",
"-",
"Root",
">",
"/",
"docs",
"/",
"soap",
".",
"txt",
"about",
"specifics",
"."
] | train | https://github.com/Zimbra-Community/python-zimbra/blob/8b839143c64b0507a30a9908ff39066ae4ef5d03/pythonzimbra/request.py#L38-L58 |
Zimbra-Community/python-zimbra | pythonzimbra/request.py | Request.enable_batch | def enable_batch(self, onerror="continue"):
""" Enables batch request gathering.
Do this first and then consecutively call "add_request" to add more
requests.
:param onerror: "continue" (default) if one request fails (and
response with soap Faults for the request) or "stop" ... | python | def enable_batch(self, onerror="continue"):
""" Enables batch request gathering.
Do this first and then consecutively call "add_request" to add more
requests.
:param onerror: "continue" (default) if one request fails (and
response with soap Faults for the request) or "stop" ... | [
"def",
"enable_batch",
"(",
"self",
",",
"onerror",
"=",
"\"continue\"",
")",
":",
"self",
".",
"batch_request",
"=",
"True",
"self",
".",
"batch_request_id",
"=",
"1",
"self",
".",
"_create_batch_node",
"(",
"onerror",
")"
] | Enables batch request gathering.
Do this first and then consecutively call "add_request" to add more
requests.
:param onerror: "continue" (default) if one request fails (and
response with soap Faults for the request) or "stop" processing. | [
"Enables",
"batch",
"request",
"gathering",
"."
] | train | https://github.com/Zimbra-Community/python-zimbra/blob/8b839143c64b0507a30a9908ff39066ae4ef5d03/pythonzimbra/request.py#L75-L89 |
Zimbra-Community/python-zimbra | pythonzimbra/response.py | Response.is_fault | def is_fault(self):
""" Checks, wether this response has at least one fault response (
supports both batch and single responses)
"""
if self.is_batch():
info = self.get_batch()
return info['hasFault']
else:
my_response = self.get_response... | python | def is_fault(self):
""" Checks, wether this response has at least one fault response (
supports both batch and single responses)
"""
if self.is_batch():
info = self.get_batch()
return info['hasFault']
else:
my_response = self.get_response... | [
"def",
"is_fault",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_batch",
"(",
")",
":",
"info",
"=",
"self",
".",
"get_batch",
"(",
")",
"return",
"info",
"[",
"'hasFault'",
"]",
"else",
":",
"my_response",
"=",
"self",
".",
"get_response",
"(",
")",... | Checks, wether this response has at least one fault response (
supports both batch and single responses) | [
"Checks",
"wether",
"this",
"response",
"has",
"at",
"least",
"one",
"fault",
"response",
"(",
"supports",
"both",
"batch",
"and",
"single",
"responses",
")"
] | train | https://github.com/Zimbra-Community/python-zimbra/blob/8b839143c64b0507a30a9908ff39066ae4ef5d03/pythonzimbra/response.py#L129-L149 |
Zimbra-Community/python-zimbra | pythonzimbra/response.py | Response._filter_response | def _filter_response(self, response_dict):
""" Add additional filters to the response dictionary
Currently the response dictionary is filtered like this:
* If a list only has one item, the list is replaced by that item
* Namespace-Keys (_jsns and xmlns) are removed
:param... | python | def _filter_response(self, response_dict):
""" Add additional filters to the response dictionary
Currently the response dictionary is filtered like this:
* If a list only has one item, the list is replaced by that item
* Namespace-Keys (_jsns and xmlns) are removed
:param... | [
"def",
"_filter_response",
"(",
"self",
",",
"response_dict",
")",
":",
"filtered_dict",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"response_dict",
".",
"items",
"(",
")",
":",
"if",
"key",
"==",
"\"_jsns\"",
":",
"continue",
"if",
"key",
"==",
... | Add additional filters to the response dictionary
Currently the response dictionary is filtered like this:
* If a list only has one item, the list is replaced by that item
* Namespace-Keys (_jsns and xmlns) are removed
:param response_dict: the pregenerated, but unfiltered respons... | [
"Add",
"additional",
"filters",
"to",
"the",
"response",
"dictionary"
] | train | https://github.com/Zimbra-Community/python-zimbra/blob/8b839143c64b0507a30a9908ff39066ae4ef5d03/pythonzimbra/response.py#L151-L197 |
Zimbra-Community/python-zimbra | pythonzimbra/tools/preauth.py | create_preauth | def create_preauth(byval, key, by='name', expires=0, timestamp=None):
""" Generates a zimbra preauth value
:param byval: The value of the targeted user (according to the
by-parameter). For example: The account name, if "by" is "name".
:param key: The domain preauth key (you can retrieve that using z... | python | def create_preauth(byval, key, by='name', expires=0, timestamp=None):
""" Generates a zimbra preauth value
:param byval: The value of the targeted user (according to the
by-parameter). For example: The account name, if "by" is "name".
:param key: The domain preauth key (you can retrieve that using z... | [
"def",
"create_preauth",
"(",
"byval",
",",
"key",
",",
"by",
"=",
"'name'",
",",
"expires",
"=",
"0",
",",
"timestamp",
"=",
"None",
")",
":",
"if",
"timestamp",
"is",
"None",
":",
"timestamp",
"=",
"int",
"(",
"datetime",
".",
"now",
"(",
")",
".... | Generates a zimbra preauth value
:param byval: The value of the targeted user (according to the
by-parameter). For example: The account name, if "by" is "name".
:param key: The domain preauth key (you can retrieve that using zmprov gd)
:param by: What type is the byval-parameter? Valid parameters are... | [
"Generates",
"a",
"zimbra",
"preauth",
"value"
] | train | https://github.com/Zimbra-Community/python-zimbra/blob/8b839143c64b0507a30a9908ff39066ae4ef5d03/pythonzimbra/tools/preauth.py#L8-L38 |
Zimbra-Community/python-zimbra | pythonzimbra/tools/dict.py | zimbra_to_python | def zimbra_to_python(zimbra_dict, key_attribute="n",
content_attribute="_content"):
"""
Converts single level Zimbra dicts to a standard python dict
:param zimbra_dict: The dictionary in Zimbra-Format
:return: A native python dict
"""
local_dict = {}
for item in zimb... | python | def zimbra_to_python(zimbra_dict, key_attribute="n",
content_attribute="_content"):
"""
Converts single level Zimbra dicts to a standard python dict
:param zimbra_dict: The dictionary in Zimbra-Format
:return: A native python dict
"""
local_dict = {}
for item in zimb... | [
"def",
"zimbra_to_python",
"(",
"zimbra_dict",
",",
"key_attribute",
"=",
"\"n\"",
",",
"content_attribute",
"=",
"\"_content\"",
")",
":",
"local_dict",
"=",
"{",
"}",
"for",
"item",
"in",
"zimbra_dict",
":",
"local_dict",
"[",
"item",
"[",
"key_attribute",
"... | Converts single level Zimbra dicts to a standard python dict
:param zimbra_dict: The dictionary in Zimbra-Format
:return: A native python dict | [
"Converts",
"single",
"level",
"Zimbra",
"dicts",
"to",
"a",
"standard",
"python",
"dict"
] | train | https://github.com/Zimbra-Community/python-zimbra/blob/8b839143c64b0507a30a9908ff39066ae4ef5d03/pythonzimbra/tools/dict.py#L15-L31 |
Zimbra-Community/python-zimbra | pythonzimbra/tools/dict.py | get_value | def get_value(haystack, needle, key_attribute="n",
content_attribute="_content"):
""" Fetch a value from a zimbra-like json dict (keys are "n", values are
"_content"
This function may be slightly faster than zimbra_to_python(haystack)[
needle], because it doesn't necessarily iterate over... | python | def get_value(haystack, needle, key_attribute="n",
content_attribute="_content"):
""" Fetch a value from a zimbra-like json dict (keys are "n", values are
"_content"
This function may be slightly faster than zimbra_to_python(haystack)[
needle], because it doesn't necessarily iterate over... | [
"def",
"get_value",
"(",
"haystack",
",",
"needle",
",",
"key_attribute",
"=",
"\"n\"",
",",
"content_attribute",
"=",
"\"_content\"",
")",
":",
"for",
"value",
"in",
"haystack",
":",
"if",
"value",
"[",
"key_attribute",
"]",
"==",
"needle",
":",
"return",
... | Fetch a value from a zimbra-like json dict (keys are "n", values are
"_content"
This function may be slightly faster than zimbra_to_python(haystack)[
needle], because it doesn't necessarily iterate over the complete list.
:param haystack: The list in zimbra-dict format
:param needle: the key to se... | [
"Fetch",
"a",
"value",
"from",
"a",
"zimbra",
"-",
"like",
"json",
"dict",
"(",
"keys",
"are",
"n",
"values",
"are",
"_content"
] | train | https://github.com/Zimbra-Community/python-zimbra/blob/8b839143c64b0507a30a9908ff39066ae4ef5d03/pythonzimbra/tools/dict.py#L34-L54 |
Zimbra-Community/python-zimbra | pythonzimbra/tools/xmlserializer.py | convert_to_str | def convert_to_str(input_string):
""" Returns a string of the input compatible between py2 and py3
:param input_string:
:return:
"""
if sys.version < '3':
if isinstance(input_string, str) \
or isinstance(input_string, unicode): # pragma: no cover py3
return i... | python | def convert_to_str(input_string):
""" Returns a string of the input compatible between py2 and py3
:param input_string:
:return:
"""
if sys.version < '3':
if isinstance(input_string, str) \
or isinstance(input_string, unicode): # pragma: no cover py3
return i... | [
"def",
"convert_to_str",
"(",
"input_string",
")",
":",
"if",
"sys",
".",
"version",
"<",
"'3'",
":",
"if",
"isinstance",
"(",
"input_string",
",",
"str",
")",
"or",
"isinstance",
"(",
"input_string",
",",
"unicode",
")",
":",
"# pragma: no cover py3",
"retu... | Returns a string of the input compatible between py2 and py3
:param input_string:
:return: | [
"Returns",
"a",
"string",
"of",
"the",
"input",
"compatible",
"between",
"py2",
"and",
"py3",
":",
"param",
"input_string",
":",
":",
"return",
":"
] | train | https://github.com/Zimbra-Community/python-zimbra/blob/8b839143c64b0507a30a9908ff39066ae4ef5d03/pythonzimbra/tools/xmlserializer.py#L5-L25 |
Zimbra-Community/python-zimbra | pythonzimbra/tools/xmlserializer.py | dict_to_dom | def dict_to_dom(root_node, xml_dict):
""" Create a DOM node and optionally several subnodes from a dictionary.
:param root_node: DOM-Node set the dictionary is applied upon
:type root_node: xml.dom.Element
:param xml_dict: The dictionary containing the nodes to process
:type xml_dict: dict
"""
... | python | def dict_to_dom(root_node, xml_dict):
""" Create a DOM node and optionally several subnodes from a dictionary.
:param root_node: DOM-Node set the dictionary is applied upon
:type root_node: xml.dom.Element
:param xml_dict: The dictionary containing the nodes to process
:type xml_dict: dict
"""
... | [
"def",
"dict_to_dom",
"(",
"root_node",
",",
"xml_dict",
")",
":",
"if",
"'_content'",
"in",
"list",
"(",
"xml_dict",
".",
"keys",
"(",
")",
")",
":",
"root_node",
".",
"appendChild",
"(",
"root_node",
".",
"ownerDocument",
".",
"createTextNode",
"(",
"con... | Create a DOM node and optionally several subnodes from a dictionary.
:param root_node: DOM-Node set the dictionary is applied upon
:type root_node: xml.dom.Element
:param xml_dict: The dictionary containing the nodes to process
:type xml_dict: dict | [
"Create",
"a",
"DOM",
"node",
"and",
"optionally",
"several",
"subnodes",
"from",
"a",
"dictionary",
"."
] | train | https://github.com/Zimbra-Community/python-zimbra/blob/8b839143c64b0507a30a9908ff39066ae4ef5d03/pythonzimbra/tools/xmlserializer.py#L28-L77 |
Zimbra-Community/python-zimbra | pythonzimbra/tools/xmlserializer.py | dom_to_dict | def dom_to_dict(root_node):
""" Serializes the given node to the dictionary
Serializes the given node to the documented dictionary format.
:param root_node: Node to serialize
:returns: The dictionary
:rtype: dict
"""
# Remove namespaces from tagname
tag = root_node.tagName
if "... | python | def dom_to_dict(root_node):
""" Serializes the given node to the dictionary
Serializes the given node to the documented dictionary format.
:param root_node: Node to serialize
:returns: The dictionary
:rtype: dict
"""
# Remove namespaces from tagname
tag = root_node.tagName
if "... | [
"def",
"dom_to_dict",
"(",
"root_node",
")",
":",
"# Remove namespaces from tagname",
"tag",
"=",
"root_node",
".",
"tagName",
"if",
"\":\"",
"in",
"tag",
":",
"tag",
"=",
"tag",
".",
"split",
"(",
"\":\"",
")",
"[",
"1",
"]",
"root_dict",
"=",
"{",
"tag... | Serializes the given node to the dictionary
Serializes the given node to the documented dictionary format.
:param root_node: Node to serialize
:returns: The dictionary
:rtype: dict | [
"Serializes",
"the",
"given",
"node",
"to",
"the",
"dictionary"
] | train | https://github.com/Zimbra-Community/python-zimbra/blob/8b839143c64b0507a30a9908ff39066ae4ef5d03/pythonzimbra/tools/xmlserializer.py#L80-L148 |
Zimbra-Community/python-zimbra | pythonzimbra/tools/urllib2_tls.py | TLS1Connection.connect | def connect(self):
"""Overrides HTTPSConnection.connect to specify TLS version"""
# Standard implementation from HTTPSConnection, which is not
# designed for extension, unfortunately
sock = socket.create_connection((self.host, self.port),
self.time... | python | def connect(self):
"""Overrides HTTPSConnection.connect to specify TLS version"""
# Standard implementation from HTTPSConnection, which is not
# designed for extension, unfortunately
sock = socket.create_connection((self.host, self.port),
self.time... | [
"def",
"connect",
"(",
"self",
")",
":",
"# Standard implementation from HTTPSConnection, which is not",
"# designed for extension, unfortunately",
"sock",
"=",
"socket",
".",
"create_connection",
"(",
"(",
"self",
".",
"host",
",",
"self",
".",
"port",
")",
",",
"sel... | Overrides HTTPSConnection.connect to specify TLS version | [
"Overrides",
"HTTPSConnection",
".",
"connect",
"to",
"specify",
"TLS",
"version"
] | train | https://github.com/Zimbra-Community/python-zimbra/blob/8b839143c64b0507a30a9908ff39066ae4ef5d03/pythonzimbra/tools/urllib2_tls.py#L22-L34 |
Zimbra-Community/python-zimbra | pythonzimbra/communication.py | Communication.gen_request | def gen_request(self, request_type="json", token=None, set_batch=False,
batch_onerror=None):
""" Convenience method to quickly generate a token
:param request_type: Type of request (defaults to json)
:param token: Authentication token
:param set_batch: Also set this... | python | def gen_request(self, request_type="json", token=None, set_batch=False,
batch_onerror=None):
""" Convenience method to quickly generate a token
:param request_type: Type of request (defaults to json)
:param token: Authentication token
:param set_batch: Also set this... | [
"def",
"gen_request",
"(",
"self",
",",
"request_type",
"=",
"\"json\"",
",",
"token",
"=",
"None",
",",
"set_batch",
"=",
"False",
",",
"batch_onerror",
"=",
"None",
")",
":",
"if",
"request_type",
"==",
"\"json\"",
":",
"local_request",
"=",
"RequestJson",... | Convenience method to quickly generate a token
:param request_type: Type of request (defaults to json)
:param token: Authentication token
:param set_batch: Also set this request to batch mode?
:param batch_onerror: Onerror-parameter for batch mode
:return: The request | [
"Convenience",
"method",
"to",
"quickly",
"generate",
"a",
"token"
] | train | https://github.com/Zimbra-Community/python-zimbra/blob/8b839143c64b0507a30a9908ff39066ae4ef5d03/pythonzimbra/communication.py#L54-L84 |
Zimbra-Community/python-zimbra | pythonzimbra/communication.py | Communication.send_request | def send_request(self, request, response=None):
""" Send the request.
Sends the request and retrieves the results, formats them and returns
them in a dict or a list (when it's a batchresponse). If something
goes wrong, raises a SoapFailure or a HTTPError on system-side
failu... | python | def send_request(self, request, response=None):
""" Send the request.
Sends the request and retrieves the results, formats them and returns
them in a dict or a list (when it's a batchresponse). If something
goes wrong, raises a SoapFailure or a HTTPError on system-side
failu... | [
"def",
"send_request",
"(",
"self",
",",
"request",
",",
"response",
"=",
"None",
")",
":",
"local_response",
"=",
"None",
"if",
"response",
"is",
"None",
":",
"if",
"request",
".",
"request_type",
"==",
"\"json\"",
":",
"local_response",
"=",
"ResponseJson"... | Send the request.
Sends the request and retrieves the results, formats them and returns
them in a dict or a list (when it's a batchresponse). If something
goes wrong, raises a SoapFailure or a HTTPError on system-side
failures. Note: AuthRequest raises an HTTPError on failed
... | [
"Send",
"the",
"request",
"."
] | train | https://github.com/Zimbra-Community/python-zimbra/blob/8b839143c64b0507a30a9908ff39066ae4ef5d03/pythonzimbra/communication.py#L86-L169 |
Zimbra-Community/python-zimbra | pythonzimbra/tools/auth.py | authenticate | def authenticate(url, account, key, by='name', expires=0, timestamp=None,
timeout=None, request_type="xml", admin_auth=False,
use_password=False, raise_on_error=False):
""" Authenticate to the Zimbra server
:param url: URL of Zimbra SOAP service
:param account: The accoun... | python | def authenticate(url, account, key, by='name', expires=0, timestamp=None,
timeout=None, request_type="xml", admin_auth=False,
use_password=False, raise_on_error=False):
""" Authenticate to the Zimbra server
:param url: URL of Zimbra SOAP service
:param account: The accoun... | [
"def",
"authenticate",
"(",
"url",
",",
"account",
",",
"key",
",",
"by",
"=",
"'name'",
",",
"expires",
"=",
"0",
",",
"timestamp",
"=",
"None",
",",
"timeout",
"=",
"None",
",",
"request_type",
"=",
"\"xml\"",
",",
"admin_auth",
"=",
"False",
",",
... | Authenticate to the Zimbra server
:param url: URL of Zimbra SOAP service
:param account: The account to be authenticated against
:param key: The preauth key of the domain of the account or a password (if
admin_auth or use_password is True)
:param by: If the account is specified as a name, an ID o... | [
"Authenticate",
"to",
"the",
"Zimbra",
"server"
] | train | https://github.com/Zimbra-Community/python-zimbra/blob/8b839143c64b0507a30a9908ff39066ae4ef5d03/pythonzimbra/tools/auth.py#L15-L119 |
openfisca/openfisca-survey-manager | openfisca_survey_manager/read_dbf.py | read_dbf | def read_dbf(dbf_path, index = None, cols = False, incl_index = False):
"""
Read a dbf file as a pandas.DataFrame, optionally selecting the index
variable and which columns are to be loaded.
__author__ = "Dani Arribas-Bel <darribas@asu.edu> "
...
Arguments
---------
dbf_path : str
... | python | def read_dbf(dbf_path, index = None, cols = False, incl_index = False):
"""
Read a dbf file as a pandas.DataFrame, optionally selecting the index
variable and which columns are to be loaded.
__author__ = "Dani Arribas-Bel <darribas@asu.edu> "
...
Arguments
---------
dbf_path : str
... | [
"def",
"read_dbf",
"(",
"dbf_path",
",",
"index",
"=",
"None",
",",
"cols",
"=",
"False",
",",
"incl_index",
"=",
"False",
")",
":",
"db",
"=",
"ps",
".",
"open",
"(",
"dbf_path",
")",
"if",
"cols",
":",
"if",
"incl_index",
":",
"cols",
".",
"appen... | Read a dbf file as a pandas.DataFrame, optionally selecting the index
variable and which columns are to be loaded.
__author__ = "Dani Arribas-Bel <darribas@asu.edu> "
...
Arguments
---------
dbf_path : str
Path to the DBF file to be read
index : str
... | [
"Read",
"a",
"dbf",
"file",
"as",
"a",
"pandas",
".",
"DataFrame",
"optionally",
"selecting",
"the",
"index",
"variable",
"and",
"which",
"columns",
"are",
"to",
"be",
"loaded",
"."
] | train | https://github.com/openfisca/openfisca-survey-manager/blob/bed6c65dc5e4ec2bdc9cda5b865fefd9e3d0c358/openfisca_survey_manager/read_dbf.py#L44-L84 |
Crunch-io/crunch-cube | src/cr/cube/min_base_size_mask.py | MinBaseSizeMask.column_mask | def column_mask(self):
"""ndarray, True where column margin <= min_base_size, same shape as slice."""
margin = compress_pruned(
self._slice.margin(
axis=0,
weighted=False,
include_transforms_for_dims=self._hs_dims,
prune=self._p... | python | def column_mask(self):
"""ndarray, True where column margin <= min_base_size, same shape as slice."""
margin = compress_pruned(
self._slice.margin(
axis=0,
weighted=False,
include_transforms_for_dims=self._hs_dims,
prune=self._p... | [
"def",
"column_mask",
"(",
"self",
")",
":",
"margin",
"=",
"compress_pruned",
"(",
"self",
".",
"_slice",
".",
"margin",
"(",
"axis",
"=",
"0",
",",
"weighted",
"=",
"False",
",",
"include_transforms_for_dims",
"=",
"self",
".",
"_hs_dims",
",",
"prune",
... | ndarray, True where column margin <= min_base_size, same shape as slice. | [
"ndarray",
"True",
"where",
"column",
"margin",
"<",
"=",
"min_base_size",
"same",
"shape",
"as",
"slice",
"."
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/min_base_size_mask.py#L28-L47 |
Crunch-io/crunch-cube | src/cr/cube/min_base_size_mask.py | MinBaseSizeMask.table_mask | def table_mask(self):
"""ndarray, True where table margin <= min_base_size, same shape as slice."""
margin = compress_pruned(
self._slice.margin(
axis=None,
weighted=False,
include_transforms_for_dims=self._hs_dims,
prune=self._... | python | def table_mask(self):
"""ndarray, True where table margin <= min_base_size, same shape as slice."""
margin = compress_pruned(
self._slice.margin(
axis=None,
weighted=False,
include_transforms_for_dims=self._hs_dims,
prune=self._... | [
"def",
"table_mask",
"(",
"self",
")",
":",
"margin",
"=",
"compress_pruned",
"(",
"self",
".",
"_slice",
".",
"margin",
"(",
"axis",
"=",
"None",
",",
"weighted",
"=",
"False",
",",
"include_transforms_for_dims",
"=",
"self",
".",
"_hs_dims",
",",
"prune"... | ndarray, True where table margin <= min_base_size, same shape as slice. | [
"ndarray",
"True",
"where",
"table",
"margin",
"<",
"=",
"min_base_size",
"same",
"shape",
"as",
"slice",
"."
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/min_base_size_mask.py#L72-L91 |
Crunch-io/crunch-cube | src/cr/cube/measures/pairwise_significance.py | PairwiseSignificance.values | def values(self):
"""list of _ColumnPairwiseSignificance tests.
Result has as many elements as there are coliumns in the slice. Each
significance test contains `p_vals` and `t_stats` significance tests.
"""
# TODO: Figure out how to intersperse pairwise objects for columns
... | python | def values(self):
"""list of _ColumnPairwiseSignificance tests.
Result has as many elements as there are coliumns in the slice. Each
significance test contains `p_vals` and `t_stats` significance tests.
"""
# TODO: Figure out how to intersperse pairwise objects for columns
... | [
"def",
"values",
"(",
"self",
")",
":",
"# TODO: Figure out how to intersperse pairwise objects for columns",
"# that represent H&S",
"return",
"[",
"_ColumnPairwiseSignificance",
"(",
"self",
".",
"_slice",
",",
"col_idx",
",",
"self",
".",
"_axis",
",",
"self",
".",
... | list of _ColumnPairwiseSignificance tests.
Result has as many elements as there are coliumns in the slice. Each
significance test contains `p_vals` and `t_stats` significance tests. | [
"list",
"of",
"_ColumnPairwiseSignificance",
"tests",
"."
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/measures/pairwise_significance.py#L33-L52 |
Crunch-io/crunch-cube | src/cr/cube/measures/pairwise_significance.py | PairwiseSignificance.pairwise_indices | def pairwise_indices(self):
"""ndarray containing tuples of pairwise indices."""
return np.array([sig.pairwise_indices for sig in self.values]).T | python | def pairwise_indices(self):
"""ndarray containing tuples of pairwise indices."""
return np.array([sig.pairwise_indices for sig in self.values]).T | [
"def",
"pairwise_indices",
"(",
"self",
")",
":",
"return",
"np",
".",
"array",
"(",
"[",
"sig",
".",
"pairwise_indices",
"for",
"sig",
"in",
"self",
".",
"values",
"]",
")",
".",
"T"
] | ndarray containing tuples of pairwise indices. | [
"ndarray",
"containing",
"tuples",
"of",
"pairwise",
"indices",
"."
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/measures/pairwise_significance.py#L55-L57 |
Crunch-io/crunch-cube | src/cr/cube/measures/pairwise_significance.py | PairwiseSignificance.summary_pairwise_indices | def summary_pairwise_indices(self):
"""ndarray containing tuples of pairwise indices for the column summary."""
summary_pairwise_indices = np.empty(
self.values[0].t_stats.shape[1], dtype=object
)
summary_pairwise_indices[:] = [
sig.summary_pairwise_indices for si... | python | def summary_pairwise_indices(self):
"""ndarray containing tuples of pairwise indices for the column summary."""
summary_pairwise_indices = np.empty(
self.values[0].t_stats.shape[1], dtype=object
)
summary_pairwise_indices[:] = [
sig.summary_pairwise_indices for si... | [
"def",
"summary_pairwise_indices",
"(",
"self",
")",
":",
"summary_pairwise_indices",
"=",
"np",
".",
"empty",
"(",
"self",
".",
"values",
"[",
"0",
"]",
".",
"t_stats",
".",
"shape",
"[",
"1",
"]",
",",
"dtype",
"=",
"object",
")",
"summary_pairwise_indic... | ndarray containing tuples of pairwise indices for the column summary. | [
"ndarray",
"containing",
"tuples",
"of",
"pairwise",
"indices",
"for",
"the",
"column",
"summary",
"."
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/measures/pairwise_significance.py#L60-L68 |
wooey/clinto | clinto/parsers/base.py | BaseParser.score | def score(self):
"""
Calculate and return a heuristic score for this Parser against the provided
script source and path. This is used to order the ArgumentParsers as "most likely to work"
against a given script/source file.
Each parser has a calculate_score() function that retur... | python | def score(self):
"""
Calculate and return a heuristic score for this Parser against the provided
script source and path. This is used to order the ArgumentParsers as "most likely to work"
against a given script/source file.
Each parser has a calculate_score() function that retur... | [
"def",
"score",
"(",
"self",
")",
":",
"if",
"self",
".",
"_heuristic_score",
"is",
"None",
":",
"matches",
"=",
"self",
".",
"heuristic",
"(",
")",
"self",
".",
"_heuristic_score",
"=",
"float",
"(",
"sum",
"(",
"matches",
")",
")",
"/",
"float",
"(... | Calculate and return a heuristic score for this Parser against the provided
script source and path. This is used to order the ArgumentParsers as "most likely to work"
against a given script/source file.
Each parser has a calculate_score() function that returns a list of booleans representing
... | [
"Calculate",
"and",
"return",
"a",
"heuristic",
"score",
"for",
"this",
"Parser",
"against",
"the",
"provided",
"script",
"source",
"and",
"path",
".",
"This",
"is",
"used",
"to",
"order",
"the",
"ArgumentParsers",
"as",
"most",
"likely",
"to",
"work",
"agai... | train | https://github.com/wooey/clinto/blob/f25be36710a391f1dc13214756df3be7cfa26993/clinto/parsers/base.py#L46-L60 |
openfisca/openfisca-survey-manager | openfisca_survey_manager/calibration.py | Calibration.reset | def reset(self):
"""
Reset the calibration to it initial state
"""
simulation = self.survey_scenario.simulation
holder = simulation.get_holder(self.weight_name)
holder.array = numpy.array(self.initial_weight, dtype = holder.variable.dtype) | python | def reset(self):
"""
Reset the calibration to it initial state
"""
simulation = self.survey_scenario.simulation
holder = simulation.get_holder(self.weight_name)
holder.array = numpy.array(self.initial_weight, dtype = holder.variable.dtype) | [
"def",
"reset",
"(",
"self",
")",
":",
"simulation",
"=",
"self",
".",
"survey_scenario",
".",
"simulation",
"holder",
"=",
"simulation",
".",
"get_holder",
"(",
"self",
".",
"weight_name",
")",
"holder",
".",
"array",
"=",
"numpy",
".",
"array",
"(",
"s... | Reset the calibration to it initial state | [
"Reset",
"the",
"calibration",
"to",
"it",
"initial",
"state"
] | train | https://github.com/openfisca/openfisca-survey-manager/blob/bed6c65dc5e4ec2bdc9cda5b865fefd9e3d0c358/openfisca_survey_manager/calibration.py#L45-L51 |
openfisca/openfisca-survey-manager | openfisca_survey_manager/calibration.py | Calibration._set_survey_scenario | def _set_survey_scenario(self, survey_scenario):
"""
Set survey scenario
:param survey_scenario: the survey scenario
"""
self.survey_scenario = survey_scenario
# TODO deal with baseline if reform is present
if survey_scenario.simulation is None:
... | python | def _set_survey_scenario(self, survey_scenario):
"""
Set survey scenario
:param survey_scenario: the survey scenario
"""
self.survey_scenario = survey_scenario
# TODO deal with baseline if reform is present
if survey_scenario.simulation is None:
... | [
"def",
"_set_survey_scenario",
"(",
"self",
",",
"survey_scenario",
")",
":",
"self",
".",
"survey_scenario",
"=",
"survey_scenario",
"# TODO deal with baseline if reform is present",
"if",
"survey_scenario",
".",
"simulation",
"is",
"None",
":",
"survey_scenario",
".",
... | Set survey scenario
:param survey_scenario: the survey scenario | [
"Set",
"survey",
"scenario"
] | train | https://github.com/openfisca/openfisca-survey-manager/blob/bed6c65dc5e4ec2bdc9cda5b865fefd9e3d0c358/openfisca_survey_manager/calibration.py#L53-L72 |
openfisca/openfisca-survey-manager | openfisca_survey_manager/calibration.py | Calibration.set_parameters | def set_parameters(self, parameter, value):
"""
Set parameters value
:param parameter: the parameter to be set
:param value: the valeu used to set the parameter
"""
if parameter == 'lo':
self.parameters['lo'] = 1 / value
else:
... | python | def set_parameters(self, parameter, value):
"""
Set parameters value
:param parameter: the parameter to be set
:param value: the valeu used to set the parameter
"""
if parameter == 'lo':
self.parameters['lo'] = 1 / value
else:
... | [
"def",
"set_parameters",
"(",
"self",
",",
"parameter",
",",
"value",
")",
":",
"if",
"parameter",
"==",
"'lo'",
":",
"self",
".",
"parameters",
"[",
"'lo'",
"]",
"=",
"1",
"/",
"value",
"else",
":",
"self",
".",
"parameters",
"[",
"parameter",
"]",
... | Set parameters value
:param parameter: the parameter to be set
:param value: the valeu used to set the parameter | [
"Set",
"parameters",
"value"
] | train | https://github.com/openfisca/openfisca-survey-manager/blob/bed6c65dc5e4ec2bdc9cda5b865fefd9e3d0c358/openfisca_survey_manager/calibration.py#L74-L84 |
openfisca/openfisca-survey-manager | openfisca_survey_manager/calibration.py | Calibration._build_calmar_data | def _build_calmar_data(self):
"""
Builds the data dictionnary used as calmar input argument
"""
# Select only filtered entities
assert self.initial_weight_name is not None
data = pd.DataFrame()
data[self.initial_weight_name] = self.initial_weight * self.filter... | python | def _build_calmar_data(self):
"""
Builds the data dictionnary used as calmar input argument
"""
# Select only filtered entities
assert self.initial_weight_name is not None
data = pd.DataFrame()
data[self.initial_weight_name] = self.initial_weight * self.filter... | [
"def",
"_build_calmar_data",
"(",
"self",
")",
":",
"# Select only filtered entities",
"assert",
"self",
".",
"initial_weight_name",
"is",
"not",
"None",
"data",
"=",
"pd",
".",
"DataFrame",
"(",
")",
"data",
"[",
"self",
".",
"initial_weight_name",
"]",
"=",
... | Builds the data dictionnary used as calmar input argument | [
"Builds",
"the",
"data",
"dictionnary",
"used",
"as",
"calmar",
"input",
"argument"
] | train | https://github.com/openfisca/openfisca-survey-manager/blob/bed6c65dc5e4ec2bdc9cda5b865fefd9e3d0c358/openfisca_survey_manager/calibration.py#L131-L146 |
openfisca/openfisca-survey-manager | openfisca_survey_manager/calibration.py | Calibration._update_weights | def _update_weights(self, margins, parameters = {}):
"""
Run calmar, stores new weights and returns adjusted margins
"""
data = self._build_calmar_data()
assert self.initial_weight_name is not None
parameters['initial_weight'] = self.initial_weight_name
val_po... | python | def _update_weights(self, margins, parameters = {}):
"""
Run calmar, stores new weights and returns adjusted margins
"""
data = self._build_calmar_data()
assert self.initial_weight_name is not None
parameters['initial_weight'] = self.initial_weight_name
val_po... | [
"def",
"_update_weights",
"(",
"self",
",",
"margins",
",",
"parameters",
"=",
"{",
"}",
")",
":",
"data",
"=",
"self",
".",
"_build_calmar_data",
"(",
")",
"assert",
"self",
".",
"initial_weight_name",
"is",
"not",
"None",
"parameters",
"[",
"'initial_weigh... | Run calmar, stores new weights and returns adjusted margins | [
"Run",
"calmar",
"stores",
"new",
"weights",
"and",
"returns",
"adjusted",
"margins"
] | train | https://github.com/openfisca/openfisca-survey-manager/blob/bed6c65dc5e4ec2bdc9cda5b865fefd9e3d0c358/openfisca_survey_manager/calibration.py#L148-L159 |
openfisca/openfisca-survey-manager | openfisca_survey_manager/calibration.py | Calibration.set_calibrated_weights | def set_calibrated_weights(self):
"""
Modify the weights to use the calibrated weights
"""
period = self.period
survey_scenario = self.survey_scenario
assert survey_scenario.simulation is not None
for simulation in [survey_scenario.simulation, survey_scenario.... | python | def set_calibrated_weights(self):
"""
Modify the weights to use the calibrated weights
"""
period = self.period
survey_scenario = self.survey_scenario
assert survey_scenario.simulation is not None
for simulation in [survey_scenario.simulation, survey_scenario.... | [
"def",
"set_calibrated_weights",
"(",
"self",
")",
":",
"period",
"=",
"self",
".",
"period",
"survey_scenario",
"=",
"self",
".",
"survey_scenario",
"assert",
"survey_scenario",
".",
"simulation",
"is",
"not",
"None",
"for",
"simulation",
"in",
"[",
"survey_sce... | Modify the weights to use the calibrated weights | [
"Modify",
"the",
"weights",
"to",
"use",
"the",
"calibrated",
"weights"
] | train | https://github.com/openfisca/openfisca-survey-manager/blob/bed6c65dc5e4ec2bdc9cda5b865fefd9e3d0c358/openfisca_survey_manager/calibration.py#L178-L188 |
wooey/clinto | clinto/parsers/argparse_.py | get_parameter_action | def get_parameter_action(action):
"""
To foster a general schema that can accomodate multiple parsers, the general behavior here is described
rather than the specific language of a given parser. For instance, the 'append' action of an argument
is collapsing each argument given to a single argument. It a... | python | def get_parameter_action(action):
"""
To foster a general schema that can accomodate multiple parsers, the general behavior here is described
rather than the specific language of a given parser. For instance, the 'append' action of an argument
is collapsing each argument given to a single argument. It a... | [
"def",
"get_parameter_action",
"(",
"action",
")",
":",
"actions",
"=",
"set",
"(",
")",
"if",
"isinstance",
"(",
"action",
",",
"argparse",
".",
"_AppendAction",
")",
":",
"actions",
".",
"add",
"(",
"SPECIFY_EVERY_PARAM",
")",
"return",
"actions"
] | To foster a general schema that can accomodate multiple parsers, the general behavior here is described
rather than the specific language of a given parser. For instance, the 'append' action of an argument
is collapsing each argument given to a single argument. It also returns a set of actions as well, since
... | [
"To",
"foster",
"a",
"general",
"schema",
"that",
"can",
"accomodate",
"multiple",
"parsers",
"the",
"general",
"behavior",
"here",
"is",
"described",
"rather",
"than",
"the",
"specific",
"language",
"of",
"a",
"given",
"parser",
".",
"For",
"instance",
"the",... | train | https://github.com/wooey/clinto/blob/f25be36710a391f1dc13214756df3be7cfa26993/clinto/parsers/argparse_.py#L45-L55 |
openfisca/openfisca-survey-manager | openfisca_survey_manager/matching.py | nnd_hotdeck_using_feather | def nnd_hotdeck_using_feather(receiver = None, donor = None, matching_variables = None, z_variables = None):
"""
Not working
"""
import feather
assert receiver is not None and donor is not None
assert matching_variables is not None
temporary_directory_path = os.path.join(config_files_direc... | python | def nnd_hotdeck_using_feather(receiver = None, donor = None, matching_variables = None, z_variables = None):
"""
Not working
"""
import feather
assert receiver is not None and donor is not None
assert matching_variables is not None
temporary_directory_path = os.path.join(config_files_direc... | [
"def",
"nnd_hotdeck_using_feather",
"(",
"receiver",
"=",
"None",
",",
"donor",
"=",
"None",
",",
"matching_variables",
"=",
"None",
",",
"z_variables",
"=",
"None",
")",
":",
"import",
"feather",
"assert",
"receiver",
"is",
"not",
"None",
"and",
"donor",
"i... | Not working | [
"Not",
"working"
] | train | https://github.com/openfisca/openfisca-survey-manager/blob/bed6c65dc5e4ec2bdc9cda5b865fefd9e3d0c358/openfisca_survey_manager/matching.py#L17-L77 |
Crunch-io/crunch-cube | src/cr/cube/distributions/wishart.py | WishartCDF.wishart_pfaffian | def wishart_pfaffian(self):
"""ndarray of wishart pfaffian CDF, before normalization"""
return np.array(
[Pfaffian(self, val).value for i, val in np.ndenumerate(self._chisq)]
).reshape(self._chisq.shape) | python | def wishart_pfaffian(self):
"""ndarray of wishart pfaffian CDF, before normalization"""
return np.array(
[Pfaffian(self, val).value for i, val in np.ndenumerate(self._chisq)]
).reshape(self._chisq.shape) | [
"def",
"wishart_pfaffian",
"(",
"self",
")",
":",
"return",
"np",
".",
"array",
"(",
"[",
"Pfaffian",
"(",
"self",
",",
"val",
")",
".",
"value",
"for",
"i",
",",
"val",
"in",
"np",
".",
"ndenumerate",
"(",
"self",
".",
"_chisq",
")",
"]",
")",
"... | ndarray of wishart pfaffian CDF, before normalization | [
"ndarray",
"of",
"wishart",
"pfaffian",
"CDF",
"before",
"normalization"
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/distributions/wishart.py#L50-L54 |
Crunch-io/crunch-cube | src/cr/cube/distributions/wishart.py | WishartCDF.other_ind | def other_ind(self):
"""last row or column of square A"""
return np.full(self.n_min, self.size - 1, dtype=np.int) | python | def other_ind(self):
"""last row or column of square A"""
return np.full(self.n_min, self.size - 1, dtype=np.int) | [
"def",
"other_ind",
"(",
"self",
")",
":",
"return",
"np",
".",
"full",
"(",
"self",
".",
"n_min",
",",
"self",
".",
"size",
"-",
"1",
",",
"dtype",
"=",
"np",
".",
"int",
")"
] | last row or column of square A | [
"last",
"row",
"or",
"column",
"of",
"square",
"A"
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/distributions/wishart.py#L77-L79 |
Crunch-io/crunch-cube | src/cr/cube/distributions/wishart.py | WishartCDF.K | def K(self):
"""Normalizing constant for wishart CDF."""
K1 = np.float_power(pi, 0.5 * self.n_min * self.n_min)
K1 /= (
np.float_power(2, 0.5 * self.n_min * self._n_max)
* self._mgamma(0.5 * self._n_max, self.n_min)
* self._mgamma(0.5 * self.n_min, self.n_min)... | python | def K(self):
"""Normalizing constant for wishart CDF."""
K1 = np.float_power(pi, 0.5 * self.n_min * self.n_min)
K1 /= (
np.float_power(2, 0.5 * self.n_min * self._n_max)
* self._mgamma(0.5 * self._n_max, self.n_min)
* self._mgamma(0.5 * self.n_min, self.n_min)... | [
"def",
"K",
"(",
"self",
")",
":",
"K1",
"=",
"np",
".",
"float_power",
"(",
"pi",
",",
"0.5",
"*",
"self",
".",
"n_min",
"*",
"self",
".",
"n_min",
")",
"K1",
"/=",
"(",
"np",
".",
"float_power",
"(",
"2",
",",
"0.5",
"*",
"self",
".",
"n_mi... | Normalizing constant for wishart CDF. | [
"Normalizing",
"constant",
"for",
"wishart",
"CDF",
"."
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/distributions/wishart.py#L89-L103 |
Crunch-io/crunch-cube | src/cr/cube/distributions/wishart.py | Pfaffian.value | def value(self):
"""return float Cumulative Distribution Function.
The return value represents a floating point number of the CDF of the
largest eigenvalue of a Wishart(n, p) evaluated at chisq_val.
"""
wishart = self._wishart_cdf
# Prepare variables for integration alg... | python | def value(self):
"""return float Cumulative Distribution Function.
The return value represents a floating point number of the CDF of the
largest eigenvalue of a Wishart(n, p) evaluated at chisq_val.
"""
wishart = self._wishart_cdf
# Prepare variables for integration alg... | [
"def",
"value",
"(",
"self",
")",
":",
"wishart",
"=",
"self",
".",
"_wishart_cdf",
"# Prepare variables for integration algorithm",
"A",
"=",
"self",
".",
"A",
"p",
"=",
"self",
".",
"_gammainc_a",
"g",
"=",
"gamma",
"(",
"wishart",
".",
"alpha_vec",
")",
... | return float Cumulative Distribution Function.
The return value represents a floating point number of the CDF of the
largest eigenvalue of a Wishart(n, p) evaluated at chisq_val. | [
"return",
"float",
"Cumulative",
"Distribution",
"Function",
"."
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/distributions/wishart.py#L124-L151 |
Crunch-io/crunch-cube | src/cr/cube/distributions/wishart.py | Pfaffian.A | def A(self):
"""ndarray - a skew-symmetric matrix for integrating the target distribution"""
wishart = self._wishart_cdf
base = np.zeros([wishart.size, wishart.size])
if wishart.n_min % 2:
# If matrix has odd number of elements, we need to append a
# row and a co... | python | def A(self):
"""ndarray - a skew-symmetric matrix for integrating the target distribution"""
wishart = self._wishart_cdf
base = np.zeros([wishart.size, wishart.size])
if wishart.n_min % 2:
# If matrix has odd number of elements, we need to append a
# row and a co... | [
"def",
"A",
"(",
"self",
")",
":",
"wishart",
"=",
"self",
".",
"_wishart_cdf",
"base",
"=",
"np",
".",
"zeros",
"(",
"[",
"wishart",
".",
"size",
",",
"wishart",
".",
"size",
"]",
")",
"if",
"wishart",
".",
"n_min",
"%",
"2",
":",
"# If matrix has... | ndarray - a skew-symmetric matrix for integrating the target distribution | [
"ndarray",
"-",
"a",
"skew",
"-",
"symmetric",
"matrix",
"for",
"integrating",
"the",
"target",
"distribution"
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/distributions/wishart.py#L154-L163 |
Crunch-io/crunch-cube | src/cr/cube/measures/index.py | Index.data | def data(cls, cube, weighted, prune):
"""Return ndarray representing table index by margin."""
return cls()._data(cube, weighted, prune) | python | def data(cls, cube, weighted, prune):
"""Return ndarray representing table index by margin."""
return cls()._data(cube, weighted, prune) | [
"def",
"data",
"(",
"cls",
",",
"cube",
",",
"weighted",
",",
"prune",
")",
":",
"return",
"cls",
"(",
")",
".",
"_data",
"(",
"cube",
",",
"weighted",
",",
"prune",
")"
] | Return ndarray representing table index by margin. | [
"Return",
"ndarray",
"representing",
"table",
"index",
"by",
"margin",
"."
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/measures/index.py#L18-L20 |
Crunch-io/crunch-cube | src/cr/cube/measures/index.py | Index._data | def _data(self, cube, weighted, prune):
"""ndarray representing table index by margin."""
result = []
for slice_ in cube.slices:
if cube.has_mr:
return self._mr_index(cube, weighted, prune)
num = slice_.margin(axis=0, weighted=weighted, prune=prune)
... | python | def _data(self, cube, weighted, prune):
"""ndarray representing table index by margin."""
result = []
for slice_ in cube.slices:
if cube.has_mr:
return self._mr_index(cube, weighted, prune)
num = slice_.margin(axis=0, weighted=weighted, prune=prune)
... | [
"def",
"_data",
"(",
"self",
",",
"cube",
",",
"weighted",
",",
"prune",
")",
":",
"result",
"=",
"[",
"]",
"for",
"slice_",
"in",
"cube",
".",
"slices",
":",
"if",
"cube",
".",
"has_mr",
":",
"return",
"self",
".",
"_mr_index",
"(",
"cube",
",",
... | ndarray representing table index by margin. | [
"ndarray",
"representing",
"table",
"index",
"by",
"margin",
"."
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/measures/index.py#L22-L43 |
openfisca/openfisca-survey-manager | openfisca_survey_manager/statshelpers.py | gini | def gini(values, weights = None, bin_size = None):
"""
Gini coefficient (normalized to 1)
Using fastgini formula :
i=N j=i
SUM W_i*(SUM W_j*X_j - W_i*X_i/2)
i=1 j=1
G = 1 - 2* ----------------------------------
... | python | def gini(values, weights = None, bin_size = None):
"""
Gini coefficient (normalized to 1)
Using fastgini formula :
i=N j=i
SUM W_i*(SUM W_j*X_j - W_i*X_i/2)
i=1 j=1
G = 1 - 2* ----------------------------------
... | [
"def",
"gini",
"(",
"values",
",",
"weights",
"=",
"None",
",",
"bin_size",
"=",
"None",
")",
":",
"if",
"weights",
"is",
"None",
":",
"weights",
"=",
"ones",
"(",
"len",
"(",
"values",
")",
")",
"df",
"=",
"pd",
".",
"DataFrame",
"(",
"{",
"'x'"... | Gini coefficient (normalized to 1)
Using fastgini formula :
i=N j=i
SUM W_i*(SUM W_j*X_j - W_i*X_i/2)
i=1 j=1
G = 1 - 2* ----------------------------------
i=N i=N
... | [
"Gini",
"coefficient",
"(",
"normalized",
"to",
"1",
")",
"Using",
"fastgini",
"formula",
":"
] | train | https://github.com/openfisca/openfisca-survey-manager/blob/bed6c65dc5e4ec2bdc9cda5b865fefd9e3d0c358/openfisca_survey_manager/statshelpers.py#L12-L45 |
openfisca/openfisca-survey-manager | openfisca_survey_manager/statshelpers.py | kakwani | def kakwani(values, ineq_axis, weights = None):
"""
Computes the Kakwani index
"""
from scipy.integrate import simps
if weights is None:
weights = ones(len(values))
# sign = -1
# if tax == True:
# sign = -1
# else:
# sign = 1
PLCx, PLCy = pseudo_lorenz(values, i... | python | def kakwani(values, ineq_axis, weights = None):
"""
Computes the Kakwani index
"""
from scipy.integrate import simps
if weights is None:
weights = ones(len(values))
# sign = -1
# if tax == True:
# sign = -1
# else:
# sign = 1
PLCx, PLCy = pseudo_lorenz(values, i... | [
"def",
"kakwani",
"(",
"values",
",",
"ineq_axis",
",",
"weights",
"=",
"None",
")",
":",
"from",
"scipy",
".",
"integrate",
"import",
"simps",
"if",
"weights",
"is",
"None",
":",
"weights",
"=",
"ones",
"(",
"len",
"(",
"values",
")",
")",
"# sign ... | Computes the Kakwani index | [
"Computes",
"the",
"Kakwani",
"index"
] | train | https://github.com/openfisca/openfisca-survey-manager/blob/bed6c65dc5e4ec2bdc9cda5b865fefd9e3d0c358/openfisca_survey_manager/statshelpers.py#L48-L68 |
openfisca/openfisca-survey-manager | openfisca_survey_manager/statshelpers.py | lorenz | def lorenz(values, weights = None):
"""
Computes Lorenz Curve coordinates
"""
if weights is None:
weights = ones(len(values))
df = pd.DataFrame({'v': values, 'w': weights})
df = df.sort_values(by = 'v')
x = cumsum(df['w'])
x = x / float(x[-1:])
y = cumsum(df['v'] * df['w'])
... | python | def lorenz(values, weights = None):
"""
Computes Lorenz Curve coordinates
"""
if weights is None:
weights = ones(len(values))
df = pd.DataFrame({'v': values, 'w': weights})
df = df.sort_values(by = 'v')
x = cumsum(df['w'])
x = x / float(x[-1:])
y = cumsum(df['v'] * df['w'])
... | [
"def",
"lorenz",
"(",
"values",
",",
"weights",
"=",
"None",
")",
":",
"if",
"weights",
"is",
"None",
":",
"weights",
"=",
"ones",
"(",
"len",
"(",
"values",
")",
")",
"df",
"=",
"pd",
".",
"DataFrame",
"(",
"{",
"'v'",
":",
"values",
",",
"'w'",... | Computes Lorenz Curve coordinates | [
"Computes",
"Lorenz",
"Curve",
"coordinates"
] | train | https://github.com/openfisca/openfisca-survey-manager/blob/bed6c65dc5e4ec2bdc9cda5b865fefd9e3d0c358/openfisca_survey_manager/statshelpers.py#L71-L85 |
Crunch-io/crunch-cube | src/cr/cube/measures/wishart_pairwise_significance.py | WishartPairwiseSignificance.pvals | def pvals(cls, slice_, axis=0, weighted=True):
"""Wishart CDF values for slice columns as square ndarray.
Wishart CDF (Cumulative Distribution Function) is calculated to determine
statistical significance of slice columns, in relation to all other columns.
These values represent the ans... | python | def pvals(cls, slice_, axis=0, weighted=True):
"""Wishart CDF values for slice columns as square ndarray.
Wishart CDF (Cumulative Distribution Function) is calculated to determine
statistical significance of slice columns, in relation to all other columns.
These values represent the ans... | [
"def",
"pvals",
"(",
"cls",
",",
"slice_",
",",
"axis",
"=",
"0",
",",
"weighted",
"=",
"True",
")",
":",
"return",
"cls",
".",
"_factory",
"(",
"slice_",
",",
"axis",
",",
"weighted",
")",
".",
"pvals"
] | Wishart CDF values for slice columns as square ndarray.
Wishart CDF (Cumulative Distribution Function) is calculated to determine
statistical significance of slice columns, in relation to all other columns.
These values represent the answer to the question "How much is a particular
colu... | [
"Wishart",
"CDF",
"values",
"for",
"slice",
"columns",
"as",
"square",
"ndarray",
"."
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/measures/wishart_pairwise_significance.py#L31-L39 |
Crunch-io/crunch-cube | src/cr/cube/measures/wishart_pairwise_significance.py | WishartPairwiseSignificance._chi_squared | def _chi_squared(self, proportions, margin, observed):
"""return ndarray of chi-squared measures for proportions' columns.
*proportions* (ndarray): The basis of chi-squared calcualations
*margin* (ndarray): Column margin for proportions (See `def _margin`)
*observed* (ndarray): Row marg... | python | def _chi_squared(self, proportions, margin, observed):
"""return ndarray of chi-squared measures for proportions' columns.
*proportions* (ndarray): The basis of chi-squared calcualations
*margin* (ndarray): Column margin for proportions (See `def _margin`)
*observed* (ndarray): Row marg... | [
"def",
"_chi_squared",
"(",
"self",
",",
"proportions",
",",
"margin",
",",
"observed",
")",
":",
"n",
"=",
"self",
".",
"_element_count",
"chi_squared",
"=",
"np",
".",
"zeros",
"(",
"[",
"n",
",",
"n",
"]",
")",
"for",
"i",
"in",
"xrange",
"(",
"... | return ndarray of chi-squared measures for proportions' columns.
*proportions* (ndarray): The basis of chi-squared calcualations
*margin* (ndarray): Column margin for proportions (See `def _margin`)
*observed* (ndarray): Row margin proportions (See `def _observed`) | [
"return",
"ndarray",
"of",
"chi",
"-",
"squared",
"measures",
"for",
"proportions",
"columns",
"."
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/measures/wishart_pairwise_significance.py#L45-L61 |
Crunch-io/crunch-cube | src/cr/cube/measures/wishart_pairwise_significance.py | WishartPairwiseSignificance._pvals_from_chi_squared | def _pvals_from_chi_squared(self, pairwise_chisq):
"""return statistical significance for props' columns.
*pairwise_chisq* (ndarray) Matrix of chi-squared values (bases for Wishart CDF)
"""
return self._intersperse_insertion_rows_and_columns(
1.0 - WishartCDF(pairwise_chisq,... | python | def _pvals_from_chi_squared(self, pairwise_chisq):
"""return statistical significance for props' columns.
*pairwise_chisq* (ndarray) Matrix of chi-squared values (bases for Wishart CDF)
"""
return self._intersperse_insertion_rows_and_columns(
1.0 - WishartCDF(pairwise_chisq,... | [
"def",
"_pvals_from_chi_squared",
"(",
"self",
",",
"pairwise_chisq",
")",
":",
"return",
"self",
".",
"_intersperse_insertion_rows_and_columns",
"(",
"1.0",
"-",
"WishartCDF",
"(",
"pairwise_chisq",
",",
"self",
".",
"_n_min",
",",
"self",
".",
"_n_max",
")",
"... | return statistical significance for props' columns.
*pairwise_chisq* (ndarray) Matrix of chi-squared values (bases for Wishart CDF) | [
"return",
"statistical",
"significance",
"for",
"props",
"columns",
"."
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/measures/wishart_pairwise_significance.py#L76-L83 |
Crunch-io/crunch-cube | src/cr/cube/measures/wishart_pairwise_significance.py | WishartPairwiseSignificance._factory | def _factory(slice_, axis, weighted):
"""return subclass for PairwiseSignificance, based on slice dimension types."""
if slice_.dim_types[0] == DT.MR_SUBVAR:
return _MrXCatPairwiseSignificance(slice_, axis, weighted)
return _CatXCatPairwiseSignificance(slice_, axis, weighted) | python | def _factory(slice_, axis, weighted):
"""return subclass for PairwiseSignificance, based on slice dimension types."""
if slice_.dim_types[0] == DT.MR_SUBVAR:
return _MrXCatPairwiseSignificance(slice_, axis, weighted)
return _CatXCatPairwiseSignificance(slice_, axis, weighted) | [
"def",
"_factory",
"(",
"slice_",
",",
"axis",
",",
"weighted",
")",
":",
"if",
"slice_",
".",
"dim_types",
"[",
"0",
"]",
"==",
"DT",
".",
"MR_SUBVAR",
":",
"return",
"_MrXCatPairwiseSignificance",
"(",
"slice_",
",",
"axis",
",",
"weighted",
")",
"retu... | return subclass for PairwiseSignificance, based on slice dimension types. | [
"return",
"subclass",
"for",
"PairwiseSignificance",
"based",
"on",
"slice",
"dimension",
"types",
"."
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/measures/wishart_pairwise_significance.py#L86-L90 |
Crunch-io/crunch-cube | src/cr/cube/measures/wishart_pairwise_significance.py | WishartPairwiseSignificance._intersperse_insertion_rows_and_columns | def _intersperse_insertion_rows_and_columns(self, pairwise_pvals):
"""Return pvals matrix with inserted NaN rows and columns, as numpy.ndarray.
Each insertion (a header or a subtotal) creates an offset in the calculated
pvals. These need to be taken into account when converting each pval to a
... | python | def _intersperse_insertion_rows_and_columns(self, pairwise_pvals):
"""Return pvals matrix with inserted NaN rows and columns, as numpy.ndarray.
Each insertion (a header or a subtotal) creates an offset in the calculated
pvals. These need to be taken into account when converting each pval to a
... | [
"def",
"_intersperse_insertion_rows_and_columns",
"(",
"self",
",",
"pairwise_pvals",
")",
":",
"for",
"i",
"in",
"self",
".",
"_insertion_indices",
":",
"pairwise_pvals",
"=",
"np",
".",
"insert",
"(",
"pairwise_pvals",
",",
"i",
",",
"np",
".",
"nan",
",",
... | Return pvals matrix with inserted NaN rows and columns, as numpy.ndarray.
Each insertion (a header or a subtotal) creates an offset in the calculated
pvals. These need to be taken into account when converting each pval to a
corresponding column letter. For this reason, we need to insert an all-... | [
"Return",
"pvals",
"matrix",
"with",
"inserted",
"NaN",
"rows",
"and",
"columns",
"as",
"numpy",
".",
"ndarray",
"."
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/measures/wishart_pairwise_significance.py#L97-L109 |
Crunch-io/crunch-cube | src/cr/cube/measures/wishart_pairwise_significance.py | WishartPairwiseSignificance._opposite_axis_margin | def _opposite_axis_margin(self):
"""ndarray representing margin along the axis opposite of self._axis
In the process of calculating p-values for the column significance testing we
need both the margin along the primary axis and the percentage margin along
the opposite axis.
"""
... | python | def _opposite_axis_margin(self):
"""ndarray representing margin along the axis opposite of self._axis
In the process of calculating p-values for the column significance testing we
need both the margin along the primary axis and the percentage margin along
the opposite axis.
"""
... | [
"def",
"_opposite_axis_margin",
"(",
"self",
")",
":",
"off_axis",
"=",
"1",
"-",
"self",
".",
"_axis",
"return",
"self",
".",
"_slice",
".",
"margin",
"(",
"axis",
"=",
"off_axis",
",",
"include_mr_cat",
"=",
"self",
".",
"_include_mr_cat",
")"
] | ndarray representing margin along the axis opposite of self._axis
In the process of calculating p-values for the column significance testing we
need both the margin along the primary axis and the percentage margin along
the opposite axis. | [
"ndarray",
"representing",
"margin",
"along",
"the",
"axis",
"opposite",
"of",
"self",
".",
"_axis"
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/measures/wishart_pairwise_significance.py#L132-L140 |
Crunch-io/crunch-cube | src/cr/cube/measures/wishart_pairwise_significance.py | WishartPairwiseSignificance._proportions | def _proportions(self):
"""ndarray representing slice proportions along correct axis."""
return self._slice.proportions(
axis=self._axis, include_mr_cat=self._include_mr_cat
) | python | def _proportions(self):
"""ndarray representing slice proportions along correct axis."""
return self._slice.proportions(
axis=self._axis, include_mr_cat=self._include_mr_cat
) | [
"def",
"_proportions",
"(",
"self",
")",
":",
"return",
"self",
".",
"_slice",
".",
"proportions",
"(",
"axis",
"=",
"self",
".",
"_axis",
",",
"include_mr_cat",
"=",
"self",
".",
"_include_mr_cat",
")"
] | ndarray representing slice proportions along correct axis. | [
"ndarray",
"representing",
"slice",
"proportions",
"along",
"correct",
"axis",
"."
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/measures/wishart_pairwise_significance.py#L143-L147 |
Crunch-io/crunch-cube | src/cr/cube/measures/wishart_pairwise_significance.py | _CatXCatPairwiseSignificance._pairwise_chisq | def _pairwise_chisq(self):
"""Pairwise comparisons (Chi-Square) along axis, as numpy.ndarray.
Returns a square, symmetric matrix of test statistics for the null
hypothesis that each vector along *axis* is equal to each other.
"""
return self._chi_squared(self._proportions, self.... | python | def _pairwise_chisq(self):
"""Pairwise comparisons (Chi-Square) along axis, as numpy.ndarray.
Returns a square, symmetric matrix of test statistics for the null
hypothesis that each vector along *axis* is equal to each other.
"""
return self._chi_squared(self._proportions, self.... | [
"def",
"_pairwise_chisq",
"(",
"self",
")",
":",
"return",
"self",
".",
"_chi_squared",
"(",
"self",
".",
"_proportions",
",",
"self",
".",
"_margin",
",",
"self",
".",
"_observed",
")"
] | Pairwise comparisons (Chi-Square) along axis, as numpy.ndarray.
Returns a square, symmetric matrix of test statistics for the null
hypothesis that each vector along *axis* is equal to each other. | [
"Pairwise",
"comparisons",
"(",
"Chi",
"-",
"Square",
")",
"along",
"axis",
"as",
"numpy",
".",
"ndarray",
"."
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/measures/wishart_pairwise_significance.py#L176-L182 |
Crunch-io/crunch-cube | src/cr/cube/measures/wishart_pairwise_significance.py | _MrXCatPairwiseSignificance._pairwise_chisq | def _pairwise_chisq(self):
"""Pairwise comparisons (Chi-Square) along axis, as numpy.ndarray.
Returns a list of square and symmetric matrices of test statistics for the null
hypothesis that each vector along *axis* is equal to each other.
"""
return [
self._chi_squar... | python | def _pairwise_chisq(self):
"""Pairwise comparisons (Chi-Square) along axis, as numpy.ndarray.
Returns a list of square and symmetric matrices of test statistics for the null
hypothesis that each vector along *axis* is equal to each other.
"""
return [
self._chi_squar... | [
"def",
"_pairwise_chisq",
"(",
"self",
")",
":",
"return",
"[",
"self",
".",
"_chi_squared",
"(",
"mr_subvar_proportions",
",",
"self",
".",
"_margin",
"[",
"idx",
"]",
",",
"self",
".",
"_opposite_axis_margin",
"[",
"idx",
"]",
"/",
"np",
".",
"sum",
"(... | Pairwise comparisons (Chi-Square) along axis, as numpy.ndarray.
Returns a list of square and symmetric matrices of test statistics for the null
hypothesis that each vector along *axis* is equal to each other. | [
"Pairwise",
"comparisons",
"(",
"Chi",
"-",
"Square",
")",
"along",
"axis",
"as",
"numpy",
".",
"ndarray",
"."
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/measures/wishart_pairwise_significance.py#L211-L225 |
wooey/clinto | clinto/parsers/docopt_.py | DocOptParser.process_parser | def process_parser(self):
"""
We can't use the exception catch trick for docopt because the module prevents access to
it's innards __all__ = ['docopt']. Instead call with --help enforced, catch sys.exit and
work up to the calling docopt function to pull out the elements. This is horrible... | python | def process_parser(self):
"""
We can't use the exception catch trick for docopt because the module prevents access to
it's innards __all__ = ['docopt']. Instead call with --help enforced, catch sys.exit and
work up to the calling docopt function to pull out the elements. This is horrible... | [
"def",
"process_parser",
"(",
"self",
")",
":",
"try",
":",
"# Parse with --help to enforce exit",
"usage_sections",
"=",
"docopt",
".",
"docopt",
"(",
"self",
".",
"parser",
",",
"[",
"'--help'",
"]",
")",
"except",
"SystemExit",
"as",
"e",
":",
"parser",
"... | We can't use the exception catch trick for docopt because the module prevents access to
it's innards __all__ = ['docopt']. Instead call with --help enforced, catch sys.exit and
work up to the calling docopt function to pull out the elements. This is horrible.
:return: | [
"We",
"can",
"t",
"use",
"the",
"exception",
"catch",
"trick",
"for",
"docopt",
"because",
"the",
"module",
"prevents",
"access",
"to",
"it",
"s",
"innards",
"__all__",
"=",
"[",
"docopt",
"]",
".",
"Instead",
"call",
"with",
"--",
"help",
"enforced",
"c... | train | https://github.com/wooey/clinto/blob/f25be36710a391f1dc13214756df3be7cfa26993/clinto/parsers/docopt_.py#L109-L157 |
openfisca/openfisca-survey-manager | openfisca_survey_manager/calmar.py | build_dummies_dict | def build_dummies_dict(data):
"""
Return a dict with unique values as keys and vectors as values
"""
unique_val_list = unique(data)
output = {}
for val in unique_val_list:
output[val] = (data == val)
return output | python | def build_dummies_dict(data):
"""
Return a dict with unique values as keys and vectors as values
"""
unique_val_list = unique(data)
output = {}
for val in unique_val_list:
output[val] = (data == val)
return output | [
"def",
"build_dummies_dict",
"(",
"data",
")",
":",
"unique_val_list",
"=",
"unique",
"(",
"data",
")",
"output",
"=",
"{",
"}",
"for",
"val",
"in",
"unique_val_list",
":",
"output",
"[",
"val",
"]",
"=",
"(",
"data",
"==",
"val",
")",
"return",
"outpu... | Return a dict with unique values as keys and vectors as values | [
"Return",
"a",
"dict",
"with",
"unique",
"values",
"as",
"keys",
"and",
"vectors",
"as",
"values"
] | train | https://github.com/openfisca/openfisca-survey-manager/blob/bed6c65dc5e4ec2bdc9cda5b865fefd9e3d0c358/openfisca_survey_manager/calmar.py#L44-L52 |
openfisca/openfisca-survey-manager | openfisca_survey_manager/calmar.py | calmar | def calmar(data_in, margins, initial_weight = 'wprm_init', method = 'linear', lo = None, up = None, use_proportions = False,
xtol = 1.49012e-08, maxfev = 256):
"""
Calibrate weights to satisfy some margin constraints
:param dataframe data_in: The observations data
:param str initial... | python | def calmar(data_in, margins, initial_weight = 'wprm_init', method = 'linear', lo = None, up = None, use_proportions = False,
xtol = 1.49012e-08, maxfev = 256):
"""
Calibrate weights to satisfy some margin constraints
:param dataframe data_in: The observations data
:param str initial... | [
"def",
"calmar",
"(",
"data_in",
",",
"margins",
",",
"initial_weight",
"=",
"'wprm_init'",
",",
"method",
"=",
"'linear'",
",",
"lo",
"=",
"None",
",",
"up",
"=",
"None",
",",
"use_proportions",
"=",
"False",
",",
"xtol",
"=",
"1.49012e-08",
",",
"maxfe... | Calibrate weights to satisfy some margin constraints
:param dataframe data_in: The observations data
:param str initial_weight: The initial weight variable name
:param dict margins: Margins is a dictionnary containing for each variable as key the following values
- a scalar for nume... | [
"Calibrate",
"weights",
"to",
"satisfy",
"some",
"margin",
"constraints"
] | train | https://github.com/openfisca/openfisca-survey-manager/blob/bed6c65dc5e4ec2bdc9cda5b865fefd9e3d0c358/openfisca_survey_manager/calmar.py#L55-L231 |
Crunch-io/crunch-cube | src/cr/cube/cube_slice.py | CubeSlice.ca_main_axis | def ca_main_axis(self):
"""For univariate CA, the main axis is the categorical axis"""
try:
ca_ind = self.dim_types.index(DT.CA_SUBVAR)
return 1 - ca_ind
except ValueError:
return None | python | def ca_main_axis(self):
"""For univariate CA, the main axis is the categorical axis"""
try:
ca_ind = self.dim_types.index(DT.CA_SUBVAR)
return 1 - ca_ind
except ValueError:
return None | [
"def",
"ca_main_axis",
"(",
"self",
")",
":",
"try",
":",
"ca_ind",
"=",
"self",
".",
"dim_types",
".",
"index",
"(",
"DT",
".",
"CA_SUBVAR",
")",
"return",
"1",
"-",
"ca_ind",
"except",
"ValueError",
":",
"return",
"None"
] | For univariate CA, the main axis is the categorical axis | [
"For",
"univariate",
"CA",
"the",
"main",
"axis",
"is",
"the",
"categorical",
"axis"
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/cube_slice.py#L166-L172 |
Crunch-io/crunch-cube | src/cr/cube/cube_slice.py | CubeSlice.can_compare_pairwise | def can_compare_pairwise(self):
"""Return bool indicating if slice can compute pairwise comparisons.
Currently, only the CAT x CAT slice can compute pairwise comparisons. This also
includes the categorical array categories dimnension (CA_CAT).
"""
if self.ndim != 2:
... | python | def can_compare_pairwise(self):
"""Return bool indicating if slice can compute pairwise comparisons.
Currently, only the CAT x CAT slice can compute pairwise comparisons. This also
includes the categorical array categories dimnension (CA_CAT).
"""
if self.ndim != 2:
... | [
"def",
"can_compare_pairwise",
"(",
"self",
")",
":",
"if",
"self",
".",
"ndim",
"!=",
"2",
":",
"return",
"False",
"return",
"all",
"(",
"dt",
"in",
"DT",
".",
"ALLOWED_PAIRWISE_TYPES",
"for",
"dt",
"in",
"self",
".",
"dim_types",
")"
] | Return bool indicating if slice can compute pairwise comparisons.
Currently, only the CAT x CAT slice can compute pairwise comparisons. This also
includes the categorical array categories dimnension (CA_CAT). | [
"Return",
"bool",
"indicating",
"if",
"slice",
"can",
"compute",
"pairwise",
"comparisons",
"."
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/cube_slice.py#L180-L189 |
Crunch-io/crunch-cube | src/cr/cube/cube_slice.py | CubeSlice.get_shape | def get_shape(self, prune=False, hs_dims=None):
"""Tuple of array dimensions' lengths.
It returns a tuple of ints, each representing the length of a cube
dimension, in the order those dimensions appear in the cube.
Pruning is supported. Dimensions that get reduced to a single element
... | python | def get_shape(self, prune=False, hs_dims=None):
"""Tuple of array dimensions' lengths.
It returns a tuple of ints, each representing the length of a cube
dimension, in the order those dimensions appear in the cube.
Pruning is supported. Dimensions that get reduced to a single element
... | [
"def",
"get_shape",
"(",
"self",
",",
"prune",
"=",
"False",
",",
"hs_dims",
"=",
"None",
")",
":",
"if",
"not",
"prune",
":",
"return",
"self",
".",
"as_array",
"(",
"include_transforms_for_dims",
"=",
"hs_dims",
")",
".",
"shape",
"shape",
"=",
"compre... | Tuple of array dimensions' lengths.
It returns a tuple of ints, each representing the length of a cube
dimension, in the order those dimensions appear in the cube.
Pruning is supported. Dimensions that get reduced to a single element
(e.g. due to pruning) are removed from the returning ... | [
"Tuple",
"of",
"array",
"dimensions",
"lengths",
"."
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/cube_slice.py#L197-L221 |
Crunch-io/crunch-cube | src/cr/cube/cube_slice.py | CubeSlice.index_table | def index_table(self, axis=None, baseline=None, prune=False):
"""Return index percentages for a given axis and baseline.
The index values represent the difference of the percentages to the
corresponding baseline values. The baseline values are the univariate
percentages of the correspon... | python | def index_table(self, axis=None, baseline=None, prune=False):
"""Return index percentages for a given axis and baseline.
The index values represent the difference of the percentages to the
corresponding baseline values. The baseline values are the univariate
percentages of the correspon... | [
"def",
"index_table",
"(",
"self",
",",
"axis",
"=",
"None",
",",
"baseline",
"=",
"None",
",",
"prune",
"=",
"False",
")",
":",
"proportions",
"=",
"self",
".",
"proportions",
"(",
"axis",
"=",
"axis",
")",
"baseline",
"=",
"(",
"baseline",
"if",
"b... | Return index percentages for a given axis and baseline.
The index values represent the difference of the percentages to the
corresponding baseline values. The baseline values are the univariate
percentages of the corresponding variable. | [
"Return",
"index",
"percentages",
"for",
"a",
"given",
"axis",
"and",
"baseline",
"."
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/cube_slice.py#L243-L265 |
Crunch-io/crunch-cube | src/cr/cube/cube_slice.py | CubeSlice.labels | def labels(self, hs_dims=None, prune=False):
"""Get labels for the cube slice, and perform pruning by slice."""
if self.ca_as_0th:
labels = self._cube.labels(include_transforms_for_dims=hs_dims)[1:]
else:
labels = self._cube.labels(include_transforms_for_dims=hs_dims)[-2:... | python | def labels(self, hs_dims=None, prune=False):
"""Get labels for the cube slice, and perform pruning by slice."""
if self.ca_as_0th:
labels = self._cube.labels(include_transforms_for_dims=hs_dims)[1:]
else:
labels = self._cube.labels(include_transforms_for_dims=hs_dims)[-2:... | [
"def",
"labels",
"(",
"self",
",",
"hs_dims",
"=",
"None",
",",
"prune",
"=",
"False",
")",
":",
"if",
"self",
".",
"ca_as_0th",
":",
"labels",
"=",
"self",
".",
"_cube",
".",
"labels",
"(",
"include_transforms_for_dims",
"=",
"hs_dims",
")",
"[",
"1",... | Get labels for the cube slice, and perform pruning by slice. | [
"Get",
"labels",
"for",
"the",
"cube",
"slice",
"and",
"perform",
"pruning",
"by",
"slice",
"."
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/cube_slice.py#L277-L296 |
Crunch-io/crunch-cube | src/cr/cube/cube_slice.py | CubeSlice.margin | def margin(
self,
axis=None,
weighted=True,
include_missing=False,
include_transforms_for_dims=None,
prune=False,
include_mr_cat=False,
):
"""Return ndarray representing slice margin across selected axis.
A margin (or basis) can be calculated ... | python | def margin(
self,
axis=None,
weighted=True,
include_missing=False,
include_transforms_for_dims=None,
prune=False,
include_mr_cat=False,
):
"""Return ndarray representing slice margin across selected axis.
A margin (or basis) can be calculated ... | [
"def",
"margin",
"(",
"self",
",",
"axis",
"=",
"None",
",",
"weighted",
"=",
"True",
",",
"include_missing",
"=",
"False",
",",
"include_transforms_for_dims",
"=",
"None",
",",
"prune",
"=",
"False",
",",
"include_mr_cat",
"=",
"False",
",",
")",
":",
"... | Return ndarray representing slice margin across selected axis.
A margin (or basis) can be calculated for a contingency table, provided
that the dimensions of the desired directions are marginable. The
dimensions are marginable if they represent mutualy exclusive data,
such as true categ... | [
"Return",
"ndarray",
"representing",
"slice",
"margin",
"across",
"selected",
"axis",
"."
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/cube_slice.py#L298-L346 |
Crunch-io/crunch-cube | src/cr/cube/cube_slice.py | CubeSlice.min_base_size_mask | def min_base_size_mask(self, size, hs_dims=None, prune=False):
"""Returns MinBaseSizeMask object with correct row, col and table masks.
The returned object stores the necessary information about the base size, as
well as about the base values. It can create corresponding masks in teh row,
... | python | def min_base_size_mask(self, size, hs_dims=None, prune=False):
"""Returns MinBaseSizeMask object with correct row, col and table masks.
The returned object stores the necessary information about the base size, as
well as about the base values. It can create corresponding masks in teh row,
... | [
"def",
"min_base_size_mask",
"(",
"self",
",",
"size",
",",
"hs_dims",
"=",
"None",
",",
"prune",
"=",
"False",
")",
":",
"return",
"MinBaseSizeMask",
"(",
"self",
",",
"size",
",",
"hs_dims",
"=",
"hs_dims",
",",
"prune",
"=",
"prune",
")"
] | Returns MinBaseSizeMask object with correct row, col and table masks.
The returned object stores the necessary information about the base size, as
well as about the base values. It can create corresponding masks in teh row,
column, and table directions, based on the corresponding base values
... | [
"Returns",
"MinBaseSizeMask",
"object",
"with",
"correct",
"row",
"col",
"and",
"table",
"masks",
"."
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/cube_slice.py#L348-L362 |
Crunch-io/crunch-cube | src/cr/cube/cube_slice.py | CubeSlice.mr_dim_ind | def mr_dim_ind(self):
"""Get the correct index of the MR dimension in the cube slice."""
mr_dim_ind = self._cube.mr_dim_ind
if self._cube.ndim == 3:
if isinstance(mr_dim_ind, int):
if mr_dim_ind == 0:
# If only the 0th dimension of a 3D is an MR, t... | python | def mr_dim_ind(self):
"""Get the correct index of the MR dimension in the cube slice."""
mr_dim_ind = self._cube.mr_dim_ind
if self._cube.ndim == 3:
if isinstance(mr_dim_ind, int):
if mr_dim_ind == 0:
# If only the 0th dimension of a 3D is an MR, t... | [
"def",
"mr_dim_ind",
"(",
"self",
")",
":",
"mr_dim_ind",
"=",
"self",
".",
"_cube",
".",
"mr_dim_ind",
"if",
"self",
".",
"_cube",
".",
"ndim",
"==",
"3",
":",
"if",
"isinstance",
"(",
"mr_dim_ind",
",",
"int",
")",
":",
"if",
"mr_dim_ind",
"==",
"0... | Get the correct index of the MR dimension in the cube slice. | [
"Get",
"the",
"correct",
"index",
"of",
"the",
"MR",
"dimension",
"in",
"the",
"cube",
"slice",
"."
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/cube_slice.py#L365-L387 |
Crunch-io/crunch-cube | src/cr/cube/cube_slice.py | CubeSlice.scale_means | def scale_means(self, hs_dims=None, prune=False):
"""Return list of column and row scaled means for this slice.
If a row/col doesn't have numerical values, return None for the
corresponding dimension. If a slice only has 1D, return only the column
scaled mean (as numpy array). If both r... | python | def scale_means(self, hs_dims=None, prune=False):
"""Return list of column and row scaled means for this slice.
If a row/col doesn't have numerical values, return None for the
corresponding dimension. If a slice only has 1D, return only the column
scaled mean (as numpy array). If both r... | [
"def",
"scale_means",
"(",
"self",
",",
"hs_dims",
"=",
"None",
",",
"prune",
"=",
"False",
")",
":",
"scale_means",
"=",
"self",
".",
"_cube",
".",
"scale_means",
"(",
"hs_dims",
",",
"prune",
")",
"if",
"self",
".",
"ca_as_0th",
":",
"# If slice is use... | Return list of column and row scaled means for this slice.
If a row/col doesn't have numerical values, return None for the
corresponding dimension. If a slice only has 1D, return only the column
scaled mean (as numpy array). If both row and col scaled means are
present, return them as t... | [
"Return",
"list",
"of",
"column",
"and",
"row",
"scaled",
"means",
"for",
"this",
"slice",
"."
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/cube_slice.py#L399-L419 |
Crunch-io/crunch-cube | src/cr/cube/cube_slice.py | CubeSlice.table_name | def table_name(self):
"""Get slice name.
In case of 2D return cube name. In case of 3D, return the combination
of the cube name with the label of the corresponding slice
(nth label of the 0th dimension).
"""
if self._cube.ndim < 3 and not self.ca_as_0th:
retu... | python | def table_name(self):
"""Get slice name.
In case of 2D return cube name. In case of 3D, return the combination
of the cube name with the label of the corresponding slice
(nth label of the 0th dimension).
"""
if self._cube.ndim < 3 and not self.ca_as_0th:
retu... | [
"def",
"table_name",
"(",
"self",
")",
":",
"if",
"self",
".",
"_cube",
".",
"ndim",
"<",
"3",
"and",
"not",
"self",
".",
"ca_as_0th",
":",
"return",
"None",
"title",
"=",
"self",
".",
"_cube",
".",
"name",
"table_name",
"=",
"self",
".",
"_cube",
... | Get slice name.
In case of 2D return cube name. In case of 3D, return the combination
of the cube name with the label of the corresponding slice
(nth label of the 0th dimension). | [
"Get",
"slice",
"name",
"."
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/cube_slice.py#L448-L460 |
Crunch-io/crunch-cube | src/cr/cube/cube_slice.py | CubeSlice.wishart_pairwise_pvals | def wishart_pairwise_pvals(self, axis=0):
"""Return square symmetric matrix of pairwise column-comparison p-values.
Square, symmetric matrix along *axis* of pairwise p-values for the
null hypothesis that col[i] = col[j] for each pair of columns.
*axis* (int): axis along which to perfor... | python | def wishart_pairwise_pvals(self, axis=0):
"""Return square symmetric matrix of pairwise column-comparison p-values.
Square, symmetric matrix along *axis* of pairwise p-values for the
null hypothesis that col[i] = col[j] for each pair of columns.
*axis* (int): axis along which to perfor... | [
"def",
"wishart_pairwise_pvals",
"(",
"self",
",",
"axis",
"=",
"0",
")",
":",
"if",
"axis",
"!=",
"0",
":",
"raise",
"NotImplementedError",
"(",
"\"Pairwise comparison only implemented for colums\"",
")",
"return",
"WishartPairwiseSignificance",
".",
"pvals",
"(",
... | Return square symmetric matrix of pairwise column-comparison p-values.
Square, symmetric matrix along *axis* of pairwise p-values for the
null hypothesis that col[i] = col[j] for each pair of columns.
*axis* (int): axis along which to perform comparison. Only columns (0)
are implemente... | [
"Return",
"square",
"symmetric",
"matrix",
"of",
"pairwise",
"column",
"-",
"comparison",
"p",
"-",
"values",
"."
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/cube_slice.py#L462-L473 |
Crunch-io/crunch-cube | src/cr/cube/cube_slice.py | CubeSlice.pvals | def pvals(self, weighted=True, prune=False, hs_dims=None):
"""Return 2D ndarray with calculated P values
This function calculates statistically significant cells for
categorical contingency tables under the null hypothesis that the
row and column variables are independent (uncorrelated)... | python | def pvals(self, weighted=True, prune=False, hs_dims=None):
"""Return 2D ndarray with calculated P values
This function calculates statistically significant cells for
categorical contingency tables under the null hypothesis that the
row and column variables are independent (uncorrelated)... | [
"def",
"pvals",
"(",
"self",
",",
"weighted",
"=",
"True",
",",
"prune",
"=",
"False",
",",
"hs_dims",
"=",
"None",
")",
":",
"stats",
"=",
"self",
".",
"zscore",
"(",
"weighted",
"=",
"weighted",
",",
"prune",
"=",
"prune",
",",
"hs_dims",
"=",
"h... | Return 2D ndarray with calculated P values
This function calculates statistically significant cells for
categorical contingency tables under the null hypothesis that the
row and column variables are independent (uncorrelated).
The values are calculated for 2D tables only.
:para... | [
"Return",
"2D",
"ndarray",
"with",
"calculated",
"P",
"values"
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/cube_slice.py#L501-L518 |
Crunch-io/crunch-cube | src/cr/cube/cube_slice.py | CubeSlice.zscore | def zscore(self, weighted=True, prune=False, hs_dims=None):
"""Return ndarray with slices's standardized residuals (Z-scores).
(Only applicable to a 2D contingency tables.) The Z-score or
standardized residual is the difference between observed and expected
cell counts if row and column... | python | def zscore(self, weighted=True, prune=False, hs_dims=None):
"""Return ndarray with slices's standardized residuals (Z-scores).
(Only applicable to a 2D contingency tables.) The Z-score or
standardized residual is the difference between observed and expected
cell counts if row and column... | [
"def",
"zscore",
"(",
"self",
",",
"weighted",
"=",
"True",
",",
"prune",
"=",
"False",
",",
"hs_dims",
"=",
"None",
")",
":",
"counts",
"=",
"self",
".",
"as_array",
"(",
"weighted",
"=",
"weighted",
")",
"total",
"=",
"self",
".",
"margin",
"(",
... | Return ndarray with slices's standardized residuals (Z-scores).
(Only applicable to a 2D contingency tables.) The Z-score or
standardized residual is the difference between observed and expected
cell counts if row and column variables were independent divided
by the residual cell varian... | [
"Return",
"ndarray",
"with",
"slices",
"s",
"standardized",
"residuals",
"(",
"Z",
"-",
"scores",
")",
"."
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/cube_slice.py#L520-L550 |
Crunch-io/crunch-cube | src/cr/cube/cube_slice.py | CubeSlice.pairwise_indices | def pairwise_indices(self, alpha=0.05, only_larger=True, hs_dims=None):
"""Indices of columns where p < alpha for column-comparison t-tests
Returns an array of tuples of columns that are significant at p<alpha,
from a series of pairwise t-tests.
Argument both_pairs returns indices stri... | python | def pairwise_indices(self, alpha=0.05, only_larger=True, hs_dims=None):
"""Indices of columns where p < alpha for column-comparison t-tests
Returns an array of tuples of columns that are significant at p<alpha,
from a series of pairwise t-tests.
Argument both_pairs returns indices stri... | [
"def",
"pairwise_indices",
"(",
"self",
",",
"alpha",
"=",
"0.05",
",",
"only_larger",
"=",
"True",
",",
"hs_dims",
"=",
"None",
")",
":",
"return",
"PairwiseSignificance",
"(",
"self",
",",
"alpha",
"=",
"alpha",
",",
"only_larger",
"=",
"only_larger",
",... | Indices of columns where p < alpha for column-comparison t-tests
Returns an array of tuples of columns that are significant at p<alpha,
from a series of pairwise t-tests.
Argument both_pairs returns indices striclty on the test statistic. If
False, however, only the index of values *si... | [
"Indices",
"of",
"columns",
"where",
"p",
"<",
"alpha",
"for",
"column",
"-",
"comparison",
"t",
"-",
"tests"
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/cube_slice.py#L552-L564 |
Crunch-io/crunch-cube | src/cr/cube/cube_slice.py | CubeSlice._array_type_std_res | def _array_type_std_res(self, counts, total, colsum, rowsum):
"""Return ndarray containing standard residuals for array values.
The shape of the return value is the same as that of *counts*.
Array variables require special processing because of the
underlying math. Essentially, it boils... | python | def _array_type_std_res(self, counts, total, colsum, rowsum):
"""Return ndarray containing standard residuals for array values.
The shape of the return value is the same as that of *counts*.
Array variables require special processing because of the
underlying math. Essentially, it boils... | [
"def",
"_array_type_std_res",
"(",
"self",
",",
"counts",
",",
"total",
",",
"colsum",
",",
"rowsum",
")",
":",
"if",
"self",
".",
"mr_dim_ind",
"==",
"0",
":",
"# --This is a special case where broadcasting cannot be",
"# --automatically done. We need to \"inflate\" the ... | Return ndarray containing standard residuals for array values.
The shape of the return value is the same as that of *counts*.
Array variables require special processing because of the
underlying math. Essentially, it boils down to the fact that the
variable dimensions are mutually indep... | [
"Return",
"ndarray",
"containing",
"standard",
"residuals",
"for",
"array",
"values",
"."
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/cube_slice.py#L588-L609 |
Crunch-io/crunch-cube | src/cr/cube/cube_slice.py | CubeSlice._calculate_std_res | def _calculate_std_res(self, counts, total, colsum, rowsum):
"""Return ndarray containing standard residuals.
The shape of the return value is the same as that of *counts*.
"""
if set(self.dim_types) & DT.ARRAY_TYPES: # ---has-mr-or-ca---
return self._array_type_std_res(cou... | python | def _calculate_std_res(self, counts, total, colsum, rowsum):
"""Return ndarray containing standard residuals.
The shape of the return value is the same as that of *counts*.
"""
if set(self.dim_types) & DT.ARRAY_TYPES: # ---has-mr-or-ca---
return self._array_type_std_res(cou... | [
"def",
"_calculate_std_res",
"(",
"self",
",",
"counts",
",",
"total",
",",
"colsum",
",",
"rowsum",
")",
":",
"if",
"set",
"(",
"self",
".",
"dim_types",
")",
"&",
"DT",
".",
"ARRAY_TYPES",
":",
"# ---has-mr-or-ca---",
"return",
"self",
".",
"_array_type_... | Return ndarray containing standard residuals.
The shape of the return value is the same as that of *counts*. | [
"Return",
"ndarray",
"containing",
"standard",
"residuals",
"."
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/cube_slice.py#L611-L618 |
Crunch-io/crunch-cube | src/cr/cube/cube_slice.py | CubeSlice._calculate_correct_axis_for_cube | def _calculate_correct_axis_for_cube(self, axis):
"""Return correct axis for cube, based on ndim.
If cube has 3 dimensions, increase axis by 1. This will translate the
default 0 (cols direction) and 1 (rows direction) to actual 1
(cols direction) and 2 (rows direction). This is needed b... | python | def _calculate_correct_axis_for_cube(self, axis):
"""Return correct axis for cube, based on ndim.
If cube has 3 dimensions, increase axis by 1. This will translate the
default 0 (cols direction) and 1 (rows direction) to actual 1
(cols direction) and 2 (rows direction). This is needed b... | [
"def",
"_calculate_correct_axis_for_cube",
"(",
"self",
",",
"axis",
")",
":",
"if",
"self",
".",
"_cube",
".",
"ndim",
"<",
"3",
":",
"if",
"self",
".",
"ca_as_0th",
"and",
"axis",
"is",
"None",
":",
"# Special case for CA slices (in multitables). In this case,",... | Return correct axis for cube, based on ndim.
If cube has 3 dimensions, increase axis by 1. This will translate the
default 0 (cols direction) and 1 (rows direction) to actual 1
(cols direction) and 2 (rows direction). This is needed because the
0th dimension of the 3D cube is only used ... | [
"Return",
"correct",
"axis",
"for",
"cube",
"based",
"on",
"ndim",
"."
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/cube_slice.py#L620-L659 |
Crunch-io/crunch-cube | src/cr/cube/cube_slice.py | CubeSlice._scalar_type_std_res | def _scalar_type_std_res(self, counts, total, colsum, rowsum):
"""Return ndarray containing standard residuals for category values.
The shape of the return value is the same as that of *counts*.
"""
expected_counts = expected_freq(counts)
residuals = counts - expected_counts
... | python | def _scalar_type_std_res(self, counts, total, colsum, rowsum):
"""Return ndarray containing standard residuals for category values.
The shape of the return value is the same as that of *counts*.
"""
expected_counts = expected_freq(counts)
residuals = counts - expected_counts
... | [
"def",
"_scalar_type_std_res",
"(",
"self",
",",
"counts",
",",
"total",
",",
"colsum",
",",
"rowsum",
")",
":",
"expected_counts",
"=",
"expected_freq",
"(",
"counts",
")",
"residuals",
"=",
"counts",
"-",
"expected_counts",
"variance",
"=",
"(",
"np",
".",... | Return ndarray containing standard residuals for category values.
The shape of the return value is the same as that of *counts*. | [
"Return",
"ndarray",
"containing",
"standard",
"residuals",
"for",
"category",
"values",
"."
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/cube_slice.py#L709-L721 |
Crunch-io/crunch-cube | src/cr/cube/measures/scale_means.py | ScaleMeans.data | def data(self):
"""list of mean numeric values of categorical responses."""
means = []
table = self._slice.as_array()
products = self._inner_prods(table, self.values)
for axis, product in enumerate(products):
if product is None:
means.append(product)
... | python | def data(self):
"""list of mean numeric values of categorical responses."""
means = []
table = self._slice.as_array()
products = self._inner_prods(table, self.values)
for axis, product in enumerate(products):
if product is None:
means.append(product)
... | [
"def",
"data",
"(",
"self",
")",
":",
"means",
"=",
"[",
"]",
"table",
"=",
"self",
".",
"_slice",
".",
"as_array",
"(",
")",
"products",
"=",
"self",
".",
"_inner_prods",
"(",
"table",
",",
"self",
".",
"values",
")",
"for",
"axis",
",",
"product"... | list of mean numeric values of categorical responses. | [
"list",
"of",
"mean",
"numeric",
"values",
"of",
"categorical",
"responses",
"."
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/measures/scale_means.py#L33-L52 |
Crunch-io/crunch-cube | src/cr/cube/measures/scale_means.py | ScaleMeans.margin | def margin(self, axis):
"""Return marginal value of the current slice scaled means.
This value is the the same what you would get from a single variable
(constituting a 2D cube/slice), when the "non-missing" filter of the
opposite variable would be applied. This behavior is consistent w... | python | def margin(self, axis):
"""Return marginal value of the current slice scaled means.
This value is the the same what you would get from a single variable
(constituting a 2D cube/slice), when the "non-missing" filter of the
opposite variable would be applied. This behavior is consistent w... | [
"def",
"margin",
"(",
"self",
",",
"axis",
")",
":",
"if",
"self",
".",
"_slice",
".",
"ndim",
"<",
"2",
":",
"msg",
"=",
"(",
"\"Scale Means marginal cannot be calculated on 1D cubes, as\"",
"\"the scale means already get reduced to a scalar value.\"",
")",
"raise",
... | Return marginal value of the current slice scaled means.
This value is the the same what you would get from a single variable
(constituting a 2D cube/slice), when the "non-missing" filter of the
opposite variable would be applied. This behavior is consistent with
what is visible in the ... | [
"Return",
"marginal",
"value",
"of",
"the",
"current",
"slice",
"scaled",
"means",
"."
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/measures/scale_means.py#L54-L83 |
Crunch-io/crunch-cube | src/cr/cube/measures/scale_means.py | ScaleMeans.values | def values(self):
"""list of ndarray value-ids for each dimension in slice.
The values for each dimension appear as an ndarray. None appears
instead of the array for each dimension having only NaN values.
"""
return [
(
np.array(dim.numeric_values)
... | python | def values(self):
"""list of ndarray value-ids for each dimension in slice.
The values for each dimension appear as an ndarray. None appears
instead of the array for each dimension having only NaN values.
"""
return [
(
np.array(dim.numeric_values)
... | [
"def",
"values",
"(",
"self",
")",
":",
"return",
"[",
"(",
"np",
".",
"array",
"(",
"dim",
".",
"numeric_values",
")",
"if",
"(",
"dim",
".",
"numeric_values",
"and",
"any",
"(",
"~",
"np",
".",
"isnan",
"(",
"dim",
".",
"numeric_values",
")",
")"... | list of ndarray value-ids for each dimension in slice.
The values for each dimension appear as an ndarray. None appears
instead of the array for each dimension having only NaN values. | [
"list",
"of",
"ndarray",
"value",
"-",
"ids",
"for",
"each",
"dimension",
"in",
"slice",
"."
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/measures/scale_means.py#L112-L125 |
Crunch-io/crunch-cube | src/cr/cube/util.py | compress_pruned | def compress_pruned(table):
"""Compress table based on pruning mask.
Only the rows/cols in which all of the elements are masked need to be
pruned.
"""
if not isinstance(table, np.ma.core.MaskedArray):
return table
if table.ndim == 0:
return table.data
if table.ndim == 1:
... | python | def compress_pruned(table):
"""Compress table based on pruning mask.
Only the rows/cols in which all of the elements are masked need to be
pruned.
"""
if not isinstance(table, np.ma.core.MaskedArray):
return table
if table.ndim == 0:
return table.data
if table.ndim == 1:
... | [
"def",
"compress_pruned",
"(",
"table",
")",
":",
"if",
"not",
"isinstance",
"(",
"table",
",",
"np",
".",
"ma",
".",
"core",
".",
"MaskedArray",
")",
":",
"return",
"table",
"if",
"table",
".",
"ndim",
"==",
"0",
":",
"return",
"table",
".",
"data",... | Compress table based on pruning mask.
Only the rows/cols in which all of the elements are masked need to be
pruned. | [
"Compress",
"table",
"based",
"on",
"pruning",
"mask",
"."
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/util.py#L16-L36 |
Crunch-io/crunch-cube | src/cr/cube/util.py | intersperse_hs_in_std_res | def intersperse_hs_in_std_res(slice_, hs_dims, res):
"""Perform the insertions of place-holding rows and cols for insertions."""
for dim, inds in enumerate(slice_.inserted_hs_indices()):
if dim not in hs_dims:
continue
for i in inds:
res = np.insert(res, i, np.nan, axis=(... | python | def intersperse_hs_in_std_res(slice_, hs_dims, res):
"""Perform the insertions of place-holding rows and cols for insertions."""
for dim, inds in enumerate(slice_.inserted_hs_indices()):
if dim not in hs_dims:
continue
for i in inds:
res = np.insert(res, i, np.nan, axis=(... | [
"def",
"intersperse_hs_in_std_res",
"(",
"slice_",
",",
"hs_dims",
",",
"res",
")",
":",
"for",
"dim",
",",
"inds",
"in",
"enumerate",
"(",
"slice_",
".",
"inserted_hs_indices",
"(",
")",
")",
":",
"if",
"dim",
"not",
"in",
"hs_dims",
":",
"continue",
"f... | Perform the insertions of place-holding rows and cols for insertions. | [
"Perform",
"the",
"insertions",
"of",
"place",
"-",
"holding",
"rows",
"and",
"cols",
"for",
"insertions",
"."
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/util.py#L39-L46 |
openfisca/openfisca-survey-manager | openfisca_survey_manager/utils.py | inflate_parameter_leaf | def inflate_parameter_leaf(sub_parameter, base_year, inflator, unit_type = 'unit'):
"""
Inflate a Parameter leaf according to unit type
Basic unit type are supposed by default
Other admissible unit types are threshold_unit and rate_unit
"""
if isinstance(sub_parameter, Scale):
if unit_... | python | def inflate_parameter_leaf(sub_parameter, base_year, inflator, unit_type = 'unit'):
"""
Inflate a Parameter leaf according to unit type
Basic unit type are supposed by default
Other admissible unit types are threshold_unit and rate_unit
"""
if isinstance(sub_parameter, Scale):
if unit_... | [
"def",
"inflate_parameter_leaf",
"(",
"sub_parameter",
",",
"base_year",
",",
"inflator",
",",
"unit_type",
"=",
"'unit'",
")",
":",
"if",
"isinstance",
"(",
"sub_parameter",
",",
"Scale",
")",
":",
"if",
"unit_type",
"==",
"'threshold_unit'",
":",
"for",
"bra... | Inflate a Parameter leaf according to unit type
Basic unit type are supposed by default
Other admissible unit types are threshold_unit and rate_unit | [
"Inflate",
"a",
"Parameter",
"leaf",
"according",
"to",
"unit",
"type"
] | train | https://github.com/openfisca/openfisca-survey-manager/blob/bed6c65dc5e4ec2bdc9cda5b865fefd9e3d0c358/openfisca_survey_manager/utils.py#L63-L121 |
openfisca/openfisca-survey-manager | openfisca_survey_manager/scenarios.py | AbstractSurveyScenario.calculate_variable | def calculate_variable(self, variable = None, period = None, use_baseline = False):
"""
Compute and return the variable values for period and baseline or reform tax_benefit_system
"""
if use_baseline:
assert self.baseline_simulation is not None, "self.baseline_simulation is N... | python | def calculate_variable(self, variable = None, period = None, use_baseline = False):
"""
Compute and return the variable values for period and baseline or reform tax_benefit_system
"""
if use_baseline:
assert self.baseline_simulation is not None, "self.baseline_simulation is N... | [
"def",
"calculate_variable",
"(",
"self",
",",
"variable",
"=",
"None",
",",
"period",
"=",
"None",
",",
"use_baseline",
"=",
"False",
")",
":",
"if",
"use_baseline",
":",
"assert",
"self",
".",
"baseline_simulation",
"is",
"not",
"None",
",",
"\"self.baseli... | Compute and return the variable values for period and baseline or reform tax_benefit_system | [
"Compute",
"and",
"return",
"the",
"variable",
"values",
"for",
"period",
"and",
"baseline",
"or",
"reform",
"tax_benefit_system"
] | train | https://github.com/openfisca/openfisca-survey-manager/blob/bed6c65dc5e4ec2bdc9cda5b865fefd9e3d0c358/openfisca_survey_manager/scenarios.py#L298-L339 |
openfisca/openfisca-survey-manager | openfisca_survey_manager/scenarios.py | AbstractSurveyScenario.filter_input_variables | def filter_input_variables(self, input_data_frame = None, simulation = None):
"""
Filter the input data frame from variables that won't be used or are set to be computed
"""
assert input_data_frame is not None
assert simulation is not None
id_variable_by_entity_key = self... | python | def filter_input_variables(self, input_data_frame = None, simulation = None):
"""
Filter the input data frame from variables that won't be used or are set to be computed
"""
assert input_data_frame is not None
assert simulation is not None
id_variable_by_entity_key = self... | [
"def",
"filter_input_variables",
"(",
"self",
",",
"input_data_frame",
"=",
"None",
",",
"simulation",
"=",
"None",
")",
":",
"assert",
"input_data_frame",
"is",
"not",
"None",
"assert",
"simulation",
"is",
"not",
"None",
"id_variable_by_entity_key",
"=",
"self",
... | Filter the input data frame from variables that won't be used or are set to be computed | [
"Filter",
"the",
"input",
"data",
"frame",
"from",
"variables",
"that",
"won",
"t",
"be",
"used",
"or",
"are",
"set",
"to",
"be",
"computed"
] | train | https://github.com/openfisca/openfisca-survey-manager/blob/bed6c65dc5e4ec2bdc9cda5b865fefd9e3d0c358/openfisca_survey_manager/scenarios.py#L523-L585 |
openfisca/openfisca-survey-manager | openfisca_survey_manager/scenarios.py | AbstractSurveyScenario.init_from_data | def init_from_data(self, calibration_kwargs = None, inflation_kwargs = None,
rebuild_input_data = False, rebuild_kwargs = None, data = None, memory_config = None):
'''Initialises a survey scenario from data.
:param rebuild_input_data: Whether or not to clean, format and save data.
... | python | def init_from_data(self, calibration_kwargs = None, inflation_kwargs = None,
rebuild_input_data = False, rebuild_kwargs = None, data = None, memory_config = None):
'''Initialises a survey scenario from data.
:param rebuild_input_data: Whether or not to clean, format and save data.
... | [
"def",
"init_from_data",
"(",
"self",
",",
"calibration_kwargs",
"=",
"None",
",",
"inflation_kwargs",
"=",
"None",
",",
"rebuild_input_data",
"=",
"False",
",",
"rebuild_kwargs",
"=",
"None",
",",
"data",
"=",
"None",
",",
"memory_config",
"=",
"None",
")",
... | Initialises a survey scenario from data.
:param rebuild_input_data: Whether or not to clean, format and save data.
Take a look at :func:`build_input_data`
:param data: Contains the data, or metadata needed to know where to find it. | [
"Initialises",
"a",
"survey",
"scenario",
"from",
"data",
"."
] | train | https://github.com/openfisca/openfisca-survey-manager/blob/bed6c65dc5e4ec2bdc9cda5b865fefd9e3d0c358/openfisca_survey_manager/scenarios.py#L628-L677 |
openfisca/openfisca-survey-manager | openfisca_survey_manager/scenarios.py | AbstractSurveyScenario.init_entity | def init_entity(self, entity = None, input_data_frame = None, period = None, simulation = None):
"""
Initialize the simulation period with current input_data_frame
"""
assert entity is not None
assert input_data_frame is not None
assert period is not None
assert s... | python | def init_entity(self, entity = None, input_data_frame = None, period = None, simulation = None):
"""
Initialize the simulation period with current input_data_frame
"""
assert entity is not None
assert input_data_frame is not None
assert period is not None
assert s... | [
"def",
"init_entity",
"(",
"self",
",",
"entity",
"=",
"None",
",",
"input_data_frame",
"=",
"None",
",",
"period",
"=",
"None",
",",
"simulation",
"=",
"None",
")",
":",
"assert",
"entity",
"is",
"not",
"None",
"assert",
"input_data_frame",
"is",
"not",
... | Initialize the simulation period with current input_data_frame | [
"Initialize",
"the",
"simulation",
"period",
"with",
"current",
"input_data_frame"
] | train | https://github.com/openfisca/openfisca-survey-manager/blob/bed6c65dc5e4ec2bdc9cda5b865fefd9e3d0c358/openfisca_survey_manager/scenarios.py#L679-L761 |
openfisca/openfisca-survey-manager | openfisca_survey_manager/scenarios.py | AbstractSurveyScenario.init_simulation_with_data_frame | def init_simulation_with_data_frame(self, input_data_frame = None, period = None, simulation = None, entity = None):
"""
Initialize the simulation period with current input_data_frame for an entity if specified
"""
assert input_data_frame is not None
assert period is not None
... | python | def init_simulation_with_data_frame(self, input_data_frame = None, period = None, simulation = None, entity = None):
"""
Initialize the simulation period with current input_data_frame for an entity if specified
"""
assert input_data_frame is not None
assert period is not None
... | [
"def",
"init_simulation_with_data_frame",
"(",
"self",
",",
"input_data_frame",
"=",
"None",
",",
"period",
"=",
"None",
",",
"simulation",
"=",
"None",
",",
"entity",
"=",
"None",
")",
":",
"assert",
"input_data_frame",
"is",
"not",
"None",
"assert",
"period"... | Initialize the simulation period with current input_data_frame for an entity if specified | [
"Initialize",
"the",
"simulation",
"period",
"with",
"current",
"input_data_frame",
"for",
"an",
"entity",
"if",
"specified"
] | train | https://github.com/openfisca/openfisca-survey-manager/blob/bed6c65dc5e4ec2bdc9cda5b865fefd9e3d0c358/openfisca_survey_manager/scenarios.py#L763-L841 |
openfisca/openfisca-survey-manager | openfisca_survey_manager/scenarios.py | AbstractSurveyScenario.neutralize_variables | def neutralize_variables(self, tax_benefit_system):
"""
Neutralizing input variables not in input dataframe and keep some crucial variables
"""
for variable_name, variable in tax_benefit_system.variables.items():
if variable.formulas:
continue
if s... | python | def neutralize_variables(self, tax_benefit_system):
"""
Neutralizing input variables not in input dataframe and keep some crucial variables
"""
for variable_name, variable in tax_benefit_system.variables.items():
if variable.formulas:
continue
if s... | [
"def",
"neutralize_variables",
"(",
"self",
",",
"tax_benefit_system",
")",
":",
"for",
"variable_name",
",",
"variable",
"in",
"tax_benefit_system",
".",
"variables",
".",
"items",
"(",
")",
":",
"if",
"variable",
".",
"formulas",
":",
"continue",
"if",
"self... | Neutralizing input variables not in input dataframe and keep some crucial variables | [
"Neutralizing",
"input",
"variables",
"not",
"in",
"input",
"dataframe",
"and",
"keep",
"some",
"crucial",
"variables"
] | train | https://github.com/openfisca/openfisca-survey-manager/blob/bed6c65dc5e4ec2bdc9cda5b865fefd9e3d0c358/openfisca_survey_manager/scenarios.py#L1020-L1034 |
openfisca/openfisca-survey-manager | openfisca_survey_manager/scenarios.py | AbstractSurveyScenario.set_tax_benefit_systems | def set_tax_benefit_systems(self, tax_benefit_system = None, baseline_tax_benefit_system = None):
"""
Set the tax and benefit system and eventually the baseline tax and benefit system
"""
assert tax_benefit_system is not None
self.tax_benefit_system = tax_benefit_system
i... | python | def set_tax_benefit_systems(self, tax_benefit_system = None, baseline_tax_benefit_system = None):
"""
Set the tax and benefit system and eventually the baseline tax and benefit system
"""
assert tax_benefit_system is not None
self.tax_benefit_system = tax_benefit_system
i... | [
"def",
"set_tax_benefit_systems",
"(",
"self",
",",
"tax_benefit_system",
"=",
"None",
",",
"baseline_tax_benefit_system",
"=",
"None",
")",
":",
"assert",
"tax_benefit_system",
"is",
"not",
"None",
"self",
".",
"tax_benefit_system",
"=",
"tax_benefit_system",
"if",
... | Set the tax and benefit system and eventually the baseline tax and benefit system | [
"Set",
"the",
"tax",
"and",
"benefit",
"system",
"and",
"eventually",
"the",
"baseline",
"tax",
"and",
"benefit",
"system"
] | train | https://github.com/openfisca/openfisca-survey-manager/blob/bed6c65dc5e4ec2bdc9cda5b865fefd9e3d0c358/openfisca_survey_manager/scenarios.py#L1058-L1069 |
openfisca/openfisca-survey-manager | openfisca_survey_manager/scenarios.py | AbstractSurveyScenario.summarize_variable | def summarize_variable(self, variable = None, use_baseline = False, weighted = False, force_compute = False):
"""
Prints a summary of a variable including its memory usage.
:param string variable: the variable being summarized
:param bool use_baseline: the tax-benefit-system... | python | def summarize_variable(self, variable = None, use_baseline = False, weighted = False, force_compute = False):
"""
Prints a summary of a variable including its memory usage.
:param string variable: the variable being summarized
:param bool use_baseline: the tax-benefit-system... | [
"def",
"summarize_variable",
"(",
"self",
",",
"variable",
"=",
"None",
",",
"use_baseline",
"=",
"False",
",",
"weighted",
"=",
"False",
",",
"force_compute",
"=",
"False",
")",
":",
"if",
"use_baseline",
":",
"simulation",
"=",
"self",
".",
"baseline_simul... | Prints a summary of a variable including its memory usage.
:param string variable: the variable being summarized
:param bool use_baseline: the tax-benefit-system considered
:param bool weighted: whether the produced statistics should be weigthted or not
:param bool force... | [
"Prints",
"a",
"summary",
"of",
"a",
"variable",
"including",
"its",
"memory",
"usage",
"."
] | train | https://github.com/openfisca/openfisca-survey-manager/blob/bed6c65dc5e4ec2bdc9cda5b865fefd9e3d0c358/openfisca_survey_manager/scenarios.py#L1071-L1182 |
openfisca/openfisca-survey-manager | openfisca_survey_manager/scenarios.py | AbstractSurveyScenario._set_id_variable_by_entity_key | def _set_id_variable_by_entity_key(self) -> Dict[str, str]:
'''Identify and set the good ids for the different entities'''
if self.id_variable_by_entity_key is None:
self.id_variable_by_entity_key = dict(
(entity.key, entity.key + '_id') for entity in self.tax_benefit_system.... | python | def _set_id_variable_by_entity_key(self) -> Dict[str, str]:
'''Identify and set the good ids for the different entities'''
if self.id_variable_by_entity_key is None:
self.id_variable_by_entity_key = dict(
(entity.key, entity.key + '_id') for entity in self.tax_benefit_system.... | [
"def",
"_set_id_variable_by_entity_key",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"str",
"]",
":",
"if",
"self",
".",
"id_variable_by_entity_key",
"is",
"None",
":",
"self",
".",
"id_variable_by_entity_key",
"=",
"dict",
"(",
"(",
"entity",
".",
"key... | Identify and set the good ids for the different entities | [
"Identify",
"and",
"set",
"the",
"good",
"ids",
"for",
"the",
"different",
"entities"
] | train | https://github.com/openfisca/openfisca-survey-manager/blob/bed6c65dc5e4ec2bdc9cda5b865fefd9e3d0c358/openfisca_survey_manager/scenarios.py#L1210-L1217 |
openfisca/openfisca-survey-manager | openfisca_survey_manager/scenarios.py | AbstractSurveyScenario._set_role_variable_by_entity_key | def _set_role_variable_by_entity_key(self) -> Dict[str, str]:
'''Identify and set the good roles for the different entities'''
if self.role_variable_by_entity_key is None:
self.role_variable_by_entity_key = dict(
(entity.key, entity.key + '_legacy_role') for entity in self.ta... | python | def _set_role_variable_by_entity_key(self) -> Dict[str, str]:
'''Identify and set the good roles for the different entities'''
if self.role_variable_by_entity_key is None:
self.role_variable_by_entity_key = dict(
(entity.key, entity.key + '_legacy_role') for entity in self.ta... | [
"def",
"_set_role_variable_by_entity_key",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"str",
"]",
":",
"if",
"self",
".",
"role_variable_by_entity_key",
"is",
"None",
":",
"self",
".",
"role_variable_by_entity_key",
"=",
"dict",
"(",
"(",
"entity",
".",
... | Identify and set the good roles for the different entities | [
"Identify",
"and",
"set",
"the",
"good",
"roles",
"for",
"the",
"different",
"entities"
] | train | https://github.com/openfisca/openfisca-survey-manager/blob/bed6c65dc5e4ec2bdc9cda5b865fefd9e3d0c358/openfisca_survey_manager/scenarios.py#L1219-L1225 |
openfisca/openfisca-survey-manager | openfisca_survey_manager/scenarios.py | AbstractSurveyScenario._set_used_as_input_variables_by_entity | def _set_used_as_input_variables_by_entity(self) -> Dict[str, List[str]]:
'''Identify and set the good input variables for the different entities'''
if self.used_as_input_variables_by_entity is not None:
return
tax_benefit_system = self.tax_benefit_system
assert set(self.us... | python | def _set_used_as_input_variables_by_entity(self) -> Dict[str, List[str]]:
'''Identify and set the good input variables for the different entities'''
if self.used_as_input_variables_by_entity is not None:
return
tax_benefit_system = self.tax_benefit_system
assert set(self.us... | [
"def",
"_set_used_as_input_variables_by_entity",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"List",
"[",
"str",
"]",
"]",
":",
"if",
"self",
".",
"used_as_input_variables_by_entity",
"is",
"not",
"None",
":",
"return",
"tax_benefit_system",
"=",
"self",
... | Identify and set the good input variables for the different entities | [
"Identify",
"and",
"set",
"the",
"good",
"input",
"variables",
"for",
"the",
"different",
"entities"
] | train | https://github.com/openfisca/openfisca-survey-manager/blob/bed6c65dc5e4ec2bdc9cda5b865fefd9e3d0c358/openfisca_survey_manager/scenarios.py#L1227-L1248 |
Crunch-io/crunch-cube | src/cr/cube/dimension.py | _ApparentDimensions._dimensions | def _dimensions(self):
"""tuple of dimension objects in this collection.
This composed tuple is the source for the dimension objects in this
collection.
"""
return tuple(d for d in self._all_dimensions if d.dimension_type != DT.MR_CAT) | python | def _dimensions(self):
"""tuple of dimension objects in this collection.
This composed tuple is the source for the dimension objects in this
collection.
"""
return tuple(d for d in self._all_dimensions if d.dimension_type != DT.MR_CAT) | [
"def",
"_dimensions",
"(",
"self",
")",
":",
"return",
"tuple",
"(",
"d",
"for",
"d",
"in",
"self",
".",
"_all_dimensions",
"if",
"d",
".",
"dimension_type",
"!=",
"DT",
".",
"MR_CAT",
")"
] | tuple of dimension objects in this collection.
This composed tuple is the source for the dimension objects in this
collection. | [
"tuple",
"of",
"dimension",
"objects",
"in",
"this",
"collection",
"."
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/dimension.py#L80-L86 |
Crunch-io/crunch-cube | src/cr/cube/dimension.py | _DimensionFactory._iter_dimensions | def _iter_dimensions(self):
"""Generate Dimension object for each dimension dict."""
return (
Dimension(raw_dimension.dimension_dict, raw_dimension.dimension_type)
for raw_dimension in self._raw_dimensions
) | python | def _iter_dimensions(self):
"""Generate Dimension object for each dimension dict."""
return (
Dimension(raw_dimension.dimension_dict, raw_dimension.dimension_type)
for raw_dimension in self._raw_dimensions
) | [
"def",
"_iter_dimensions",
"(",
"self",
")",
":",
"return",
"(",
"Dimension",
"(",
"raw_dimension",
".",
"dimension_dict",
",",
"raw_dimension",
".",
"dimension_type",
")",
"for",
"raw_dimension",
"in",
"self",
".",
"_raw_dimensions",
")"
] | Generate Dimension object for each dimension dict. | [
"Generate",
"Dimension",
"object",
"for",
"each",
"dimension",
"dict",
"."
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/dimension.py#L105-L110 |
Crunch-io/crunch-cube | src/cr/cube/dimension.py | _DimensionFactory._raw_dimensions | def _raw_dimensions(self):
"""Sequence of _RawDimension objects wrapping each dimension dict."""
return tuple(
_RawDimension(dimension_dict, self._dimension_dicts)
for dimension_dict in self._dimension_dicts
) | python | def _raw_dimensions(self):
"""Sequence of _RawDimension objects wrapping each dimension dict."""
return tuple(
_RawDimension(dimension_dict, self._dimension_dicts)
for dimension_dict in self._dimension_dicts
) | [
"def",
"_raw_dimensions",
"(",
"self",
")",
":",
"return",
"tuple",
"(",
"_RawDimension",
"(",
"dimension_dict",
",",
"self",
".",
"_dimension_dicts",
")",
"for",
"dimension_dict",
"in",
"self",
".",
"_dimension_dicts",
")"
] | Sequence of _RawDimension objects wrapping each dimension dict. | [
"Sequence",
"of",
"_RawDimension",
"objects",
"wrapping",
"each",
"dimension",
"dict",
"."
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/dimension.py#L113-L118 |
Crunch-io/crunch-cube | src/cr/cube/dimension.py | _RawDimension.dimension_type | def dimension_type(self):
"""Return member of DIMENSION_TYPE appropriate to dimension_dict."""
base_type = self._base_type
if base_type == "categorical":
return self._resolve_categorical()
if base_type == "enum.variable":
return self._resolve_array_type()
... | python | def dimension_type(self):
"""Return member of DIMENSION_TYPE appropriate to dimension_dict."""
base_type = self._base_type
if base_type == "categorical":
return self._resolve_categorical()
if base_type == "enum.variable":
return self._resolve_array_type()
... | [
"def",
"dimension_type",
"(",
"self",
")",
":",
"base_type",
"=",
"self",
".",
"_base_type",
"if",
"base_type",
"==",
"\"categorical\"",
":",
"return",
"self",
".",
"_resolve_categorical",
"(",
")",
"if",
"base_type",
"==",
"\"enum.variable\"",
":",
"return",
... | Return member of DIMENSION_TYPE appropriate to dimension_dict. | [
"Return",
"member",
"of",
"DIMENSION_TYPE",
"appropriate",
"to",
"dimension_dict",
"."
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/dimension.py#L139-L152 |
Crunch-io/crunch-cube | src/cr/cube/dimension.py | _RawDimension._base_type | def _base_type(self):
"""Return str like 'enum.numeric' representing dimension type.
This string is a 'type.subclass' concatenation of the str keys
used to identify the dimension type in the cube response JSON.
The '.subclass' suffix only appears where a subtype is present.
"""
... | python | def _base_type(self):
"""Return str like 'enum.numeric' representing dimension type.
This string is a 'type.subclass' concatenation of the str keys
used to identify the dimension type in the cube response JSON.
The '.subclass' suffix only appears where a subtype is present.
"""
... | [
"def",
"_base_type",
"(",
"self",
")",
":",
"type_class",
"=",
"self",
".",
"_dimension_dict",
"[",
"\"type\"",
"]",
"[",
"\"class\"",
"]",
"if",
"type_class",
"==",
"\"categorical\"",
":",
"return",
"\"categorical\"",
"if",
"type_class",
"==",
"\"enum\"",
":"... | Return str like 'enum.numeric' representing dimension type.
This string is a 'type.subclass' concatenation of the str keys
used to identify the dimension type in the cube response JSON.
The '.subclass' suffix only appears where a subtype is present. | [
"Return",
"str",
"like",
"enum",
".",
"numeric",
"representing",
"dimension",
"type",
"."
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/dimension.py#L160-L173 |
Crunch-io/crunch-cube | src/cr/cube/dimension.py | _RawDimension._next_raw_dimension | def _next_raw_dimension(self):
"""_RawDimension for next *dimension_dict* in sequence or None for last.
Returns None if this dimension is the last in sequence for this cube.
"""
dimension_dicts = self._dimension_dicts
this_idx = dimension_dicts.index(self._dimension_dict)
... | python | def _next_raw_dimension(self):
"""_RawDimension for next *dimension_dict* in sequence or None for last.
Returns None if this dimension is the last in sequence for this cube.
"""
dimension_dicts = self._dimension_dicts
this_idx = dimension_dicts.index(self._dimension_dict)
... | [
"def",
"_next_raw_dimension",
"(",
"self",
")",
":",
"dimension_dicts",
"=",
"self",
".",
"_dimension_dicts",
"this_idx",
"=",
"dimension_dicts",
".",
"index",
"(",
"self",
".",
"_dimension_dict",
")",
"if",
"this_idx",
">",
"len",
"(",
"dimension_dicts",
")",
... | _RawDimension for next *dimension_dict* in sequence or None for last.
Returns None if this dimension is the last in sequence for this cube. | [
"_RawDimension",
"for",
"next",
"*",
"dimension_dict",
"*",
"in",
"sequence",
"or",
"None",
"for",
"last",
"."
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/dimension.py#L198-L207 |
Crunch-io/crunch-cube | src/cr/cube/dimension.py | _RawDimension._resolve_array_type | def _resolve_array_type(self):
"""Return one of the ARRAY_TYPES members of DIMENSION_TYPE.
This method distinguishes between CA and MR dimensions. The return
value is only meaningful if the dimension is known to be of array
type (i.e. either CA or MR, base-type 'enum.variable').
... | python | def _resolve_array_type(self):
"""Return one of the ARRAY_TYPES members of DIMENSION_TYPE.
This method distinguishes between CA and MR dimensions. The return
value is only meaningful if the dimension is known to be of array
type (i.e. either CA or MR, base-type 'enum.variable').
... | [
"def",
"_resolve_array_type",
"(",
"self",
")",
":",
"next_raw_dimension",
"=",
"self",
".",
"_next_raw_dimension",
"if",
"next_raw_dimension",
"is",
"None",
":",
"return",
"DT",
".",
"CA",
"is_mr_subvar",
"=",
"(",
"next_raw_dimension",
".",
"_base_type",
"==",
... | Return one of the ARRAY_TYPES members of DIMENSION_TYPE.
This method distinguishes between CA and MR dimensions. The return
value is only meaningful if the dimension is known to be of array
type (i.e. either CA or MR, base-type 'enum.variable'). | [
"Return",
"one",
"of",
"the",
"ARRAY_TYPES",
"members",
"of",
"DIMENSION_TYPE",
"."
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/dimension.py#L209-L225 |
Crunch-io/crunch-cube | src/cr/cube/dimension.py | _RawDimension._resolve_categorical | def _resolve_categorical(self):
"""Return one of the categorical members of DIMENSION_TYPE.
This method distinguishes between CAT, CA_CAT, MR_CAT, and LOGICAL
dimension types, all of which have the base type 'categorical'. The
return value is only meaningful if the dimension is known to... | python | def _resolve_categorical(self):
"""Return one of the categorical members of DIMENSION_TYPE.
This method distinguishes between CAT, CA_CAT, MR_CAT, and LOGICAL
dimension types, all of which have the base type 'categorical'. The
return value is only meaningful if the dimension is known to... | [
"def",
"_resolve_categorical",
"(",
"self",
")",
":",
"# ---an array categorical is either CA_CAT or MR_CAT---",
"if",
"self",
".",
"_is_array_cat",
":",
"return",
"DT",
".",
"MR_CAT",
"if",
"self",
".",
"_has_selected_category",
"else",
"DT",
".",
"CA_CAT",
"# ---wha... | Return one of the categorical members of DIMENSION_TYPE.
This method distinguishes between CAT, CA_CAT, MR_CAT, and LOGICAL
dimension types, all of which have the base type 'categorical'. The
return value is only meaningful if the dimension is known to be one
of the categorical types (h... | [
"Return",
"one",
"of",
"the",
"categorical",
"members",
"of",
"DIMENSION_TYPE",
"."
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/dimension.py#L227-L240 |
Crunch-io/crunch-cube | src/cr/cube/dimension.py | Dimension.hs_indices | def hs_indices(self):
"""tuple of (anchor_idx, addend_idxs) pair for each subtotal.
Example::
(
(2, (0, 1, 2)),
(3, (3,)),
('bottom', (4, 5))
)
Note that the `anchor_idx` item in the first position of each pair
ca... | python | def hs_indices(self):
"""tuple of (anchor_idx, addend_idxs) pair for each subtotal.
Example::
(
(2, (0, 1, 2)),
(3, (3,)),
('bottom', (4, 5))
)
Note that the `anchor_idx` item in the first position of each pair
ca... | [
"def",
"hs_indices",
"(",
"self",
")",
":",
"if",
"self",
".",
"dimension_type",
"in",
"{",
"DT",
".",
"MR_CAT",
",",
"DT",
".",
"LOGICAL",
"}",
":",
"return",
"(",
")",
"return",
"tuple",
"(",
"(",
"subtotal",
".",
"anchor_idx",
",",
"subtotal",
"."... | tuple of (anchor_idx, addend_idxs) pair for each subtotal.
Example::
(
(2, (0, 1, 2)),
(3, (3,)),
('bottom', (4, 5))
)
Note that the `anchor_idx` item in the first position of each pair
can be 'top' or 'bottom' as well as... | [
"tuple",
"of",
"(",
"anchor_idx",
"addend_idxs",
")",
"pair",
"for",
"each",
"subtotal",
"."
] | train | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/dimension.py#L275-L296 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.