id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
7,500 | tylertreat/BigQuery-Python | bigquery/client.py | BigQueryClient._get_all_tables_for_dataset | def _get_all_tables_for_dataset(self, dataset_id, project_id=None):
"""Retrieve a list of all tables for the dataset.
Parameters
----------
dataset_id : str
The dataset to retrieve table names for
project_id: str
Unique ``str`` identifying the BigQuery pr... | python | def _get_all_tables_for_dataset(self, dataset_id, project_id=None):
"""Retrieve a list of all tables for the dataset.
Parameters
----------
dataset_id : str
The dataset to retrieve table names for
project_id: str
Unique ``str`` identifying the BigQuery pr... | [
"def",
"_get_all_tables_for_dataset",
"(",
"self",
",",
"dataset_id",
",",
"project_id",
"=",
"None",
")",
":",
"project_id",
"=",
"self",
".",
"_get_project_id",
"(",
"project_id",
")",
"result",
"=",
"self",
".",
"bigquery",
".",
"tables",
"(",
")",
".",
... | Retrieve a list of all tables for the dataset.
Parameters
----------
dataset_id : str
The dataset to retrieve table names for
project_id: str
Unique ``str`` identifying the BigQuery project contains the dataset
Returns
-------
dict
... | [
"Retrieve",
"a",
"list",
"of",
"all",
"tables",
"for",
"the",
"dataset",
"."
] | 88d99de42d954d49fc281460068f0e95003da098 | https://github.com/tylertreat/BigQuery-Python/blob/88d99de42d954d49fc281460068f0e95003da098/bigquery/client.py#L1472-L1502 |
7,501 | tylertreat/BigQuery-Python | bigquery/client.py | BigQueryClient._parse_table_list_response | def _parse_table_list_response(self, list_response):
"""Parse the response received from calling list on tables.
Parameters
----------
list_response
The response found by calling list on a BigQuery table object.
Returns
-------
dict
Dates... | python | def _parse_table_list_response(self, list_response):
"""Parse the response received from calling list on tables.
Parameters
----------
list_response
The response found by calling list on a BigQuery table object.
Returns
-------
dict
Dates... | [
"def",
"_parse_table_list_response",
"(",
"self",
",",
"list_response",
")",
":",
"tables",
"=",
"defaultdict",
"(",
"dict",
")",
"for",
"table",
"in",
"list_response",
".",
"get",
"(",
"'tables'",
",",
"[",
"]",
")",
":",
"table_ref",
"=",
"table",
".",
... | Parse the response received from calling list on tables.
Parameters
----------
list_response
The response found by calling list on a BigQuery table object.
Returns
-------
dict
Dates referenced by table names | [
"Parse",
"the",
"response",
"received",
"from",
"calling",
"list",
"on",
"tables",
"."
] | 88d99de42d954d49fc281460068f0e95003da098 | https://github.com/tylertreat/BigQuery-Python/blob/88d99de42d954d49fc281460068f0e95003da098/bigquery/client.py#L1504-L1540 |
7,502 | tylertreat/BigQuery-Python | bigquery/client.py | BigQueryClient._parse_table_name | def _parse_table_name(self, table_id):
"""Parse a table name in the form of appid_YYYY_MM or
YYYY_MM_appid and return a tuple consisting of YYYY-MM and the app id.
Returns (None, None) in the event of a name like <desc>_YYYYMMDD_<int>
Parameters
----------
table_id : st... | python | def _parse_table_name(self, table_id):
"""Parse a table name in the form of appid_YYYY_MM or
YYYY_MM_appid and return a tuple consisting of YYYY-MM and the app id.
Returns (None, None) in the event of a name like <desc>_YYYYMMDD_<int>
Parameters
----------
table_id : st... | [
"def",
"_parse_table_name",
"(",
"self",
",",
"table_id",
")",
":",
"# Prefix date",
"attributes",
"=",
"table_id",
".",
"split",
"(",
"'_'",
")",
"year_month",
"=",
"\"-\"",
".",
"join",
"(",
"attributes",
"[",
":",
"2",
"]",
")",
"app_id",
"=",
"\"-\""... | Parse a table name in the form of appid_YYYY_MM or
YYYY_MM_appid and return a tuple consisting of YYYY-MM and the app id.
Returns (None, None) in the event of a name like <desc>_YYYYMMDD_<int>
Parameters
----------
table_id : str
The table id as listed by BigQuery
... | [
"Parse",
"a",
"table",
"name",
"in",
"the",
"form",
"of",
"appid_YYYY_MM",
"or",
"YYYY_MM_appid",
"and",
"return",
"a",
"tuple",
"consisting",
"of",
"YYYY",
"-",
"MM",
"and",
"the",
"app",
"id",
"."
] | 88d99de42d954d49fc281460068f0e95003da098 | https://github.com/tylertreat/BigQuery-Python/blob/88d99de42d954d49fc281460068f0e95003da098/bigquery/client.py#L1542-L1581 |
7,503 | tylertreat/BigQuery-Python | bigquery/client.py | BigQueryClient._filter_tables_by_time | def _filter_tables_by_time(self, tables, start_time, end_time):
"""Filter a table dictionary and return table names based on the range
of start and end times in unix seconds.
Parameters
----------
tables : dict
Dates referenced by table names
start_time : int... | python | def _filter_tables_by_time(self, tables, start_time, end_time):
"""Filter a table dictionary and return table names based on the range
of start and end times in unix seconds.
Parameters
----------
tables : dict
Dates referenced by table names
start_time : int... | [
"def",
"_filter_tables_by_time",
"(",
"self",
",",
"tables",
",",
"start_time",
",",
"end_time",
")",
":",
"return",
"[",
"table_name",
"for",
"(",
"table_name",
",",
"unix_seconds",
")",
"in",
"tables",
".",
"items",
"(",
")",
"if",
"self",
".",
"_in_rang... | Filter a table dictionary and return table names based on the range
of start and end times in unix seconds.
Parameters
----------
tables : dict
Dates referenced by table names
start_time : int
The unix time after which records will be fetched
end_... | [
"Filter",
"a",
"table",
"dictionary",
"and",
"return",
"table",
"names",
"based",
"on",
"the",
"range",
"of",
"start",
"and",
"end",
"times",
"in",
"unix",
"seconds",
"."
] | 88d99de42d954d49fc281460068f0e95003da098 | https://github.com/tylertreat/BigQuery-Python/blob/88d99de42d954d49fc281460068f0e95003da098/bigquery/client.py#L1583-L1603 |
7,504 | tylertreat/BigQuery-Python | bigquery/client.py | BigQueryClient._in_range | def _in_range(self, start_time, end_time, time):
"""Indicate if the given time falls inside of the given range.
Parameters
----------
start_time : int
The unix time for the start of the range
end_time : int
The unix time for the end of the range
t... | python | def _in_range(self, start_time, end_time, time):
"""Indicate if the given time falls inside of the given range.
Parameters
----------
start_time : int
The unix time for the start of the range
end_time : int
The unix time for the end of the range
t... | [
"def",
"_in_range",
"(",
"self",
",",
"start_time",
",",
"end_time",
",",
"time",
")",
":",
"ONE_MONTH",
"=",
"2764800",
"# 32 days",
"return",
"start_time",
"<=",
"time",
"<=",
"end_time",
"or",
"time",
"<=",
"start_time",
"<=",
"time",
"+",
"ONE_MONTH",
... | Indicate if the given time falls inside of the given range.
Parameters
----------
start_time : int
The unix time for the start of the range
end_time : int
The unix time for the end of the range
time : int
The unix time to check
Return... | [
"Indicate",
"if",
"the",
"given",
"time",
"falls",
"inside",
"of",
"the",
"given",
"range",
"."
] | 88d99de42d954d49fc281460068f0e95003da098 | https://github.com/tylertreat/BigQuery-Python/blob/88d99de42d954d49fc281460068f0e95003da098/bigquery/client.py#L1605-L1627 |
7,505 | tylertreat/BigQuery-Python | bigquery/client.py | BigQueryClient._transform_row | def _transform_row(self, row, schema):
"""Apply the given schema to the given BigQuery data row.
Parameters
----------
row
A single BigQuery row to transform
schema : list
The BigQuery table schema to apply to the row, specifically
the list of... | python | def _transform_row(self, row, schema):
"""Apply the given schema to the given BigQuery data row.
Parameters
----------
row
A single BigQuery row to transform
schema : list
The BigQuery table schema to apply to the row, specifically
the list of... | [
"def",
"_transform_row",
"(",
"self",
",",
"row",
",",
"schema",
")",
":",
"log",
"=",
"{",
"}",
"# Match each schema column with its associated row value",
"for",
"index",
",",
"col_dict",
"in",
"enumerate",
"(",
"schema",
")",
":",
"col_name",
"=",
"col_dict",... | Apply the given schema to the given BigQuery data row.
Parameters
----------
row
A single BigQuery row to transform
schema : list
The BigQuery table schema to apply to the row, specifically
the list of field dicts.
Returns
-------
... | [
"Apply",
"the",
"given",
"schema",
"to",
"the",
"given",
"BigQuery",
"data",
"row",
"."
] | 88d99de42d954d49fc281460068f0e95003da098 | https://github.com/tylertreat/BigQuery-Python/blob/88d99de42d954d49fc281460068f0e95003da098/bigquery/client.py#L1664-L1711 |
7,506 | tylertreat/BigQuery-Python | bigquery/client.py | BigQueryClient._recurse_on_row | def _recurse_on_row(self, col_dict, nested_value):
"""Apply the schema specified by the given dict to the nested value by
recursing on it.
Parameters
----------
col_dict : dict
The schema to apply to the nested value.
nested_value : A value nested in a BigQue... | python | def _recurse_on_row(self, col_dict, nested_value):
"""Apply the schema specified by the given dict to the nested value by
recursing on it.
Parameters
----------
col_dict : dict
The schema to apply to the nested value.
nested_value : A value nested in a BigQue... | [
"def",
"_recurse_on_row",
"(",
"self",
",",
"col_dict",
",",
"nested_value",
")",
":",
"row_value",
"=",
"None",
"# Multiple nested records",
"if",
"col_dict",
"[",
"'mode'",
"]",
"==",
"'REPEATED'",
"and",
"isinstance",
"(",
"nested_value",
",",
"list",
")",
... | Apply the schema specified by the given dict to the nested value by
recursing on it.
Parameters
----------
col_dict : dict
The schema to apply to the nested value.
nested_value : A value nested in a BigQuery row.
Returns
-------
Union[dict, l... | [
"Apply",
"the",
"schema",
"specified",
"by",
"the",
"given",
"dict",
"to",
"the",
"nested",
"value",
"by",
"recursing",
"on",
"it",
"."
] | 88d99de42d954d49fc281460068f0e95003da098 | https://github.com/tylertreat/BigQuery-Python/blob/88d99de42d954d49fc281460068f0e95003da098/bigquery/client.py#L1713-L1740 |
7,507 | tylertreat/BigQuery-Python | bigquery/client.py | BigQueryClient._generate_hex_for_uris | def _generate_hex_for_uris(self, uris):
"""Given uris, generate and return hex version of it
Parameters
----------
uris : list
Containing all uris
Returns
-------
str
Hexed uris
"""
return sha256((":".join(uris) + str(time... | python | def _generate_hex_for_uris(self, uris):
"""Given uris, generate and return hex version of it
Parameters
----------
uris : list
Containing all uris
Returns
-------
str
Hexed uris
"""
return sha256((":".join(uris) + str(time... | [
"def",
"_generate_hex_for_uris",
"(",
"self",
",",
"uris",
")",
":",
"return",
"sha256",
"(",
"(",
"\":\"",
".",
"join",
"(",
"uris",
")",
"+",
"str",
"(",
"time",
"(",
")",
")",
")",
".",
"encode",
"(",
")",
")",
".",
"hexdigest",
"(",
")"
] | Given uris, generate and return hex version of it
Parameters
----------
uris : list
Containing all uris
Returns
-------
str
Hexed uris | [
"Given",
"uris",
"generate",
"and",
"return",
"hex",
"version",
"of",
"it"
] | 88d99de42d954d49fc281460068f0e95003da098 | https://github.com/tylertreat/BigQuery-Python/blob/88d99de42d954d49fc281460068f0e95003da098/bigquery/client.py#L1742-L1755 |
7,508 | tylertreat/BigQuery-Python | bigquery/client.py | BigQueryClient.create_dataset | def create_dataset(self, dataset_id, friendly_name=None, description=None,
access=None, location=None, project_id=None):
"""Create a new BigQuery dataset.
Parameters
----------
dataset_id : str
Unique ``str`` identifying the dataset with the project (t... | python | def create_dataset(self, dataset_id, friendly_name=None, description=None,
access=None, location=None, project_id=None):
"""Create a new BigQuery dataset.
Parameters
----------
dataset_id : str
Unique ``str`` identifying the dataset with the project (t... | [
"def",
"create_dataset",
"(",
"self",
",",
"dataset_id",
",",
"friendly_name",
"=",
"None",
",",
"description",
"=",
"None",
",",
"access",
"=",
"None",
",",
"location",
"=",
"None",
",",
"project_id",
"=",
"None",
")",
":",
"project_id",
"=",
"self",
".... | Create a new BigQuery dataset.
Parameters
----------
dataset_id : str
Unique ``str`` identifying the dataset with the project (the
referenceID of the dataset, not the integer id of the dataset)
friendly_name: str, optional
A human readable nam... | [
"Create",
"a",
"new",
"BigQuery",
"dataset",
"."
] | 88d99de42d954d49fc281460068f0e95003da098 | https://github.com/tylertreat/BigQuery-Python/blob/88d99de42d954d49fc281460068f0e95003da098/bigquery/client.py#L1782-L1835 |
7,509 | tylertreat/BigQuery-Python | bigquery/client.py | BigQueryClient.delete_dataset | def delete_dataset(self, dataset_id, delete_contents=False, project_id=None):
"""Delete a BigQuery dataset.
Parameters
----------
dataset_id : str
Unique ``str`` identifying the dataset with the project (the
referenceId of the dataset)
Unique ... | python | def delete_dataset(self, dataset_id, delete_contents=False, project_id=None):
"""Delete a BigQuery dataset.
Parameters
----------
dataset_id : str
Unique ``str`` identifying the dataset with the project (the
referenceId of the dataset)
Unique ... | [
"def",
"delete_dataset",
"(",
"self",
",",
"dataset_id",
",",
"delete_contents",
"=",
"False",
",",
"project_id",
"=",
"None",
")",
":",
"project_id",
"=",
"self",
".",
"_get_project_id",
"(",
"project_id",
")",
"try",
":",
"datasets",
"=",
"self",
".",
"b... | Delete a BigQuery dataset.
Parameters
----------
dataset_id : str
Unique ``str`` identifying the dataset with the project (the
referenceId of the dataset)
Unique ``str`` identifying the BigQuery project contains the dataset
delete_contents : b... | [
"Delete",
"a",
"BigQuery",
"dataset",
"."
] | 88d99de42d954d49fc281460068f0e95003da098 | https://github.com/tylertreat/BigQuery-Python/blob/88d99de42d954d49fc281460068f0e95003da098/bigquery/client.py#L1861-L1904 |
7,510 | tylertreat/BigQuery-Python | bigquery/client.py | BigQueryClient.update_dataset | def update_dataset(self, dataset_id, friendly_name=None, description=None,
access=None, project_id=None):
"""Updates information in an existing dataset. The update method
replaces the entire dataset resource, whereas the patch method only
replaces fields that are provided ... | python | def update_dataset(self, dataset_id, friendly_name=None, description=None,
access=None, project_id=None):
"""Updates information in an existing dataset. The update method
replaces the entire dataset resource, whereas the patch method only
replaces fields that are provided ... | [
"def",
"update_dataset",
"(",
"self",
",",
"dataset_id",
",",
"friendly_name",
"=",
"None",
",",
"description",
"=",
"None",
",",
"access",
"=",
"None",
",",
"project_id",
"=",
"None",
")",
":",
"project_id",
"=",
"self",
".",
"_get_project_id",
"(",
"proj... | Updates information in an existing dataset. The update method
replaces the entire dataset resource, whereas the patch method only
replaces fields that are provided in the submitted dataset resource.
Parameters
----------
dataset_id : str
Unique ``str`` identifying th... | [
"Updates",
"information",
"in",
"an",
"existing",
"dataset",
".",
"The",
"update",
"method",
"replaces",
"the",
"entire",
"dataset",
"resource",
"whereas",
"the",
"patch",
"method",
"only",
"replaces",
"fields",
"that",
"are",
"provided",
"in",
"the",
"submitted... | 88d99de42d954d49fc281460068f0e95003da098 | https://github.com/tylertreat/BigQuery-Python/blob/88d99de42d954d49fc281460068f0e95003da098/bigquery/client.py#L1906-L1956 |
7,511 | tylertreat/BigQuery-Python | bigquery/schema_builder.py | schema_from_record | def schema_from_record(record, timestamp_parser=default_timestamp_parser):
"""Generate a BigQuery schema given an example of a record that is to be
inserted into BigQuery.
Parameters
----------
record : dict
Example of a record that is to be inserted into BigQuery
timestamp_parser : fun... | python | def schema_from_record(record, timestamp_parser=default_timestamp_parser):
"""Generate a BigQuery schema given an example of a record that is to be
inserted into BigQuery.
Parameters
----------
record : dict
Example of a record that is to be inserted into BigQuery
timestamp_parser : fun... | [
"def",
"schema_from_record",
"(",
"record",
",",
"timestamp_parser",
"=",
"default_timestamp_parser",
")",
":",
"return",
"[",
"describe_field",
"(",
"k",
",",
"v",
",",
"timestamp_parser",
"=",
"timestamp_parser",
")",
"for",
"k",
",",
"v",
"in",
"list",
"(",... | Generate a BigQuery schema given an example of a record that is to be
inserted into BigQuery.
Parameters
----------
record : dict
Example of a record that is to be inserted into BigQuery
timestamp_parser : function, optional
Unary function taking a ``str`` and returning and ``bool``... | [
"Generate",
"a",
"BigQuery",
"schema",
"given",
"an",
"example",
"of",
"a",
"record",
"that",
"is",
"to",
"be",
"inserted",
"into",
"BigQuery",
"."
] | 88d99de42d954d49fc281460068f0e95003da098 | https://github.com/tylertreat/BigQuery-Python/blob/88d99de42d954d49fc281460068f0e95003da098/bigquery/schema_builder.py#L22-L39 |
7,512 | tylertreat/BigQuery-Python | bigquery/schema_builder.py | describe_field | def describe_field(k, v, timestamp_parser=default_timestamp_parser):
"""Given a key representing a column name and value representing the value
stored in the column, return a representation of the BigQuery schema
element describing that field. Raise errors if invalid value types are
provided.
Param... | python | def describe_field(k, v, timestamp_parser=default_timestamp_parser):
"""Given a key representing a column name and value representing the value
stored in the column, return a representation of the BigQuery schema
element describing that field. Raise errors if invalid value types are
provided.
Param... | [
"def",
"describe_field",
"(",
"k",
",",
"v",
",",
"timestamp_parser",
"=",
"default_timestamp_parser",
")",
":",
"def",
"bq_schema_field",
"(",
"name",
",",
"bq_type",
",",
"mode",
")",
":",
"return",
"{",
"\"name\"",
":",
"name",
",",
"\"type\"",
":",
"bq... | Given a key representing a column name and value representing the value
stored in the column, return a representation of the BigQuery schema
element describing that field. Raise errors if invalid value types are
provided.
Parameters
----------
k : Union[str, unicode]
Key representing th... | [
"Given",
"a",
"key",
"representing",
"a",
"column",
"name",
"and",
"value",
"representing",
"the",
"value",
"stored",
"in",
"the",
"column",
"return",
"a",
"representation",
"of",
"the",
"BigQuery",
"schema",
"element",
"describing",
"that",
"field",
".",
"Rai... | 88d99de42d954d49fc281460068f0e95003da098 | https://github.com/tylertreat/BigQuery-Python/blob/88d99de42d954d49fc281460068f0e95003da098/bigquery/schema_builder.py#L42-L98 |
7,513 | tylertreat/BigQuery-Python | bigquery/query_builder.py | render_query | def render_query(dataset, tables, select=None, conditions=None,
groupings=None, having=None, order_by=None, limit=None):
"""Render a query that will run over the given tables using the specified
parameters.
Parameters
----------
dataset : str
The BigQuery dataset to query d... | python | def render_query(dataset, tables, select=None, conditions=None,
groupings=None, having=None, order_by=None, limit=None):
"""Render a query that will run over the given tables using the specified
parameters.
Parameters
----------
dataset : str
The BigQuery dataset to query d... | [
"def",
"render_query",
"(",
"dataset",
",",
"tables",
",",
"select",
"=",
"None",
",",
"conditions",
"=",
"None",
",",
"groupings",
"=",
"None",
",",
"having",
"=",
"None",
",",
"order_by",
"=",
"None",
",",
"limit",
"=",
"None",
")",
":",
"if",
"Non... | Render a query that will run over the given tables using the specified
parameters.
Parameters
----------
dataset : str
The BigQuery dataset to query data from
tables : Union[dict, list]
The table in `dataset` to query.
select : dict, optional
The keys function as column ... | [
"Render",
"a",
"query",
"that",
"will",
"run",
"over",
"the",
"given",
"tables",
"using",
"the",
"specified",
"parameters",
"."
] | 88d99de42d954d49fc281460068f0e95003da098 | https://github.com/tylertreat/BigQuery-Python/blob/88d99de42d954d49fc281460068f0e95003da098/bigquery/query_builder.py#L7-L59 |
7,514 | tylertreat/BigQuery-Python | bigquery/query_builder.py | _render_select | def _render_select(selections):
"""Render the selection part of a query.
Parameters
----------
selections : dict
Selections for a table
Returns
-------
str
A string for the "select" part of a query
See Also
--------
render_query : Further clarification of `sele... | python | def _render_select(selections):
"""Render the selection part of a query.
Parameters
----------
selections : dict
Selections for a table
Returns
-------
str
A string for the "select" part of a query
See Also
--------
render_query : Further clarification of `sele... | [
"def",
"_render_select",
"(",
"selections",
")",
":",
"if",
"not",
"selections",
":",
"return",
"'SELECT *'",
"rendered_selections",
"=",
"[",
"]",
"for",
"name",
",",
"options",
"in",
"selections",
".",
"items",
"(",
")",
":",
"if",
"not",
"isinstance",
"... | Render the selection part of a query.
Parameters
----------
selections : dict
Selections for a table
Returns
-------
str
A string for the "select" part of a query
See Also
--------
render_query : Further clarification of `selections` dict formatting | [
"Render",
"the",
"selection",
"part",
"of",
"a",
"query",
"."
] | 88d99de42d954d49fc281460068f0e95003da098 | https://github.com/tylertreat/BigQuery-Python/blob/88d99de42d954d49fc281460068f0e95003da098/bigquery/query_builder.py#L62-L100 |
7,515 | tylertreat/BigQuery-Python | bigquery/query_builder.py | _format_select | def _format_select(formatter, name):
"""Modify the query selector by applying any formatters to it.
Parameters
----------
formatter : str
Hyphen-delimited formatter string where formatters are
applied inside-out, e.g. the formatter string
SEC_TO_MICRO-INTEGER-FORMAT_UTC_USEC applie... | python | def _format_select(formatter, name):
"""Modify the query selector by applying any formatters to it.
Parameters
----------
formatter : str
Hyphen-delimited formatter string where formatters are
applied inside-out, e.g. the formatter string
SEC_TO_MICRO-INTEGER-FORMAT_UTC_USEC applie... | [
"def",
"_format_select",
"(",
"formatter",
",",
"name",
")",
":",
"for",
"caster",
"in",
"formatter",
".",
"split",
"(",
"'-'",
")",
":",
"if",
"caster",
"==",
"'SEC_TO_MICRO'",
":",
"name",
"=",
"\"%s*1000000\"",
"%",
"name",
"elif",
"':'",
"in",
"caste... | Modify the query selector by applying any formatters to it.
Parameters
----------
formatter : str
Hyphen-delimited formatter string where formatters are
applied inside-out, e.g. the formatter string
SEC_TO_MICRO-INTEGER-FORMAT_UTC_USEC applied to the selector
foo would result in... | [
"Modify",
"the",
"query",
"selector",
"by",
"applying",
"any",
"formatters",
"to",
"it",
"."
] | 88d99de42d954d49fc281460068f0e95003da098 | https://github.com/tylertreat/BigQuery-Python/blob/88d99de42d954d49fc281460068f0e95003da098/bigquery/query_builder.py#L103-L131 |
7,516 | tylertreat/BigQuery-Python | bigquery/query_builder.py | _render_sources | def _render_sources(dataset, tables):
"""Render the source part of a query.
Parameters
----------
dataset : str
The data set to fetch log data from.
tables : Union[dict, list]
The tables to fetch log data from
Returns
-------
str
A string that represents the "fr... | python | def _render_sources(dataset, tables):
"""Render the source part of a query.
Parameters
----------
dataset : str
The data set to fetch log data from.
tables : Union[dict, list]
The tables to fetch log data from
Returns
-------
str
A string that represents the "fr... | [
"def",
"_render_sources",
"(",
"dataset",
",",
"tables",
")",
":",
"if",
"isinstance",
"(",
"tables",
",",
"dict",
")",
":",
"if",
"tables",
".",
"get",
"(",
"'date_range'",
",",
"False",
")",
":",
"try",
":",
"dataset_table",
"=",
"'.'",
".",
"join",
... | Render the source part of a query.
Parameters
----------
dataset : str
The data set to fetch log data from.
tables : Union[dict, list]
The tables to fetch log data from
Returns
-------
str
A string that represents the "from" part of a query. | [
"Render",
"the",
"source",
"part",
"of",
"a",
"query",
"."
] | 88d99de42d954d49fc281460068f0e95003da098 | https://github.com/tylertreat/BigQuery-Python/blob/88d99de42d954d49fc281460068f0e95003da098/bigquery/query_builder.py#L134-L164 |
7,517 | tylertreat/BigQuery-Python | bigquery/query_builder.py | _render_conditions | def _render_conditions(conditions):
"""Render the conditions part of a query.
Parameters
----------
conditions : list
A list of dictionary items to filter a table.
Returns
-------
str
A string that represents the "where" part of a query
See Also
--------
render... | python | def _render_conditions(conditions):
"""Render the conditions part of a query.
Parameters
----------
conditions : list
A list of dictionary items to filter a table.
Returns
-------
str
A string that represents the "where" part of a query
See Also
--------
render... | [
"def",
"_render_conditions",
"(",
"conditions",
")",
":",
"if",
"not",
"conditions",
":",
"return",
"\"\"",
"rendered_conditions",
"=",
"[",
"]",
"for",
"condition",
"in",
"conditions",
":",
"field",
"=",
"condition",
".",
"get",
"(",
"'field'",
")",
"field_... | Render the conditions part of a query.
Parameters
----------
conditions : list
A list of dictionary items to filter a table.
Returns
-------
str
A string that represents the "where" part of a query
See Also
--------
render_query : Further clarification of `conditio... | [
"Render",
"the",
"conditions",
"part",
"of",
"a",
"query",
"."
] | 88d99de42d954d49fc281460068f0e95003da098 | https://github.com/tylertreat/BigQuery-Python/blob/88d99de42d954d49fc281460068f0e95003da098/bigquery/query_builder.py#L167-L205 |
7,518 | tylertreat/BigQuery-Python | bigquery/query_builder.py | _render_condition | def _render_condition(field, field_type, comparators):
"""Render a single query condition.
Parameters
----------
field : str
The field the condition applies to
field_type : str
The data type of the field.
comparators : array_like
An iterable of logic operators to use.
... | python | def _render_condition(field, field_type, comparators):
"""Render a single query condition.
Parameters
----------
field : str
The field the condition applies to
field_type : str
The data type of the field.
comparators : array_like
An iterable of logic operators to use.
... | [
"def",
"_render_condition",
"(",
"field",
",",
"field_type",
",",
"comparators",
")",
":",
"field_type",
"=",
"field_type",
".",
"upper",
"(",
")",
"negated_conditions",
",",
"normal_conditions",
"=",
"[",
"]",
",",
"[",
"]",
"for",
"comparator",
"in",
"comp... | Render a single query condition.
Parameters
----------
field : str
The field the condition applies to
field_type : str
The data type of the field.
comparators : array_like
An iterable of logic operators to use.
Returns
-------
str
a condition string. | [
"Render",
"a",
"single",
"query",
"condition",
"."
] | 88d99de42d954d49fc281460068f0e95003da098 | https://github.com/tylertreat/BigQuery-Python/blob/88d99de42d954d49fc281460068f0e95003da098/bigquery/query_builder.py#L208-L272 |
7,519 | tylertreat/BigQuery-Python | bigquery/query_builder.py | _render_condition_value | def _render_condition_value(value, field_type):
"""Render a query condition value.
Parameters
----------
value : Union[bool, int, float, str, datetime]
The value of the condition
field_type : str
The data type of the field
Returns
-------
str
A value string.
... | python | def _render_condition_value(value, field_type):
"""Render a query condition value.
Parameters
----------
value : Union[bool, int, float, str, datetime]
The value of the condition
field_type : str
The data type of the field
Returns
-------
str
A value string.
... | [
"def",
"_render_condition_value",
"(",
"value",
",",
"field_type",
")",
":",
"# BigQuery cannot cast strings to booleans, convert to ints",
"if",
"field_type",
"==",
"\"BOOLEAN\"",
":",
"value",
"=",
"1",
"if",
"value",
"else",
"0",
"elif",
"field_type",
"in",
"(",
... | Render a query condition value.
Parameters
----------
value : Union[bool, int, float, str, datetime]
The value of the condition
field_type : str
The data type of the field
Returns
-------
str
A value string. | [
"Render",
"a",
"query",
"condition",
"value",
"."
] | 88d99de42d954d49fc281460068f0e95003da098 | https://github.com/tylertreat/BigQuery-Python/blob/88d99de42d954d49fc281460068f0e95003da098/bigquery/query_builder.py#L275-L298 |
7,520 | tylertreat/BigQuery-Python | bigquery/query_builder.py | _render_having | def _render_having(having_conditions):
"""Render the having part of a query.
Parameters
----------
having_conditions : list
A ``list`` of ``dict``s to filter the rows
Returns
-------
str
A string that represents the "having" part of a query.
See Also
--------
r... | python | def _render_having(having_conditions):
"""Render the having part of a query.
Parameters
----------
having_conditions : list
A ``list`` of ``dict``s to filter the rows
Returns
-------
str
A string that represents the "having" part of a query.
See Also
--------
r... | [
"def",
"_render_having",
"(",
"having_conditions",
")",
":",
"if",
"not",
"having_conditions",
":",
"return",
"\"\"",
"rendered_conditions",
"=",
"[",
"]",
"for",
"condition",
"in",
"having_conditions",
":",
"field",
"=",
"condition",
".",
"get",
"(",
"'field'",... | Render the having part of a query.
Parameters
----------
having_conditions : list
A ``list`` of ``dict``s to filter the rows
Returns
-------
str
A string that represents the "having" part of a query.
See Also
--------
render_query : Further clarification of `condit... | [
"Render",
"the",
"having",
"part",
"of",
"a",
"query",
"."
] | 88d99de42d954d49fc281460068f0e95003da098 | https://github.com/tylertreat/BigQuery-Python/blob/88d99de42d954d49fc281460068f0e95003da098/bigquery/query_builder.py#L321-L358 |
7,521 | stlehmann/Flask-MQTT | flask_mqtt/__init__.py | Mqtt.init_app | def init_app(self, app):
# type: (Flask) -> None
"""Init the Flask-MQTT addon."""
self.client_id = app.config.get("MQTT_CLIENT_ID", "")
if isinstance(self.client_id, unicode):
self.client._client_id = self.client_id.encode('utf-8')
else:
self.client._clie... | python | def init_app(self, app):
# type: (Flask) -> None
"""Init the Flask-MQTT addon."""
self.client_id = app.config.get("MQTT_CLIENT_ID", "")
if isinstance(self.client_id, unicode):
self.client._client_id = self.client_id.encode('utf-8')
else:
self.client._clie... | [
"def",
"init_app",
"(",
"self",
",",
"app",
")",
":",
"# type: (Flask) -> None",
"self",
".",
"client_id",
"=",
"app",
".",
"config",
".",
"get",
"(",
"\"MQTT_CLIENT_ID\"",
",",
"\"\"",
")",
"if",
"isinstance",
"(",
"self",
".",
"client_id",
",",
"unicode"... | Init the Flask-MQTT addon. | [
"Init",
"the",
"Flask",
"-",
"MQTT",
"addon",
"."
] | 77d474ab87484ae6eaef2fee3bf02406beee2e17 | https://github.com/stlehmann/Flask-MQTT/blob/77d474ab87484ae6eaef2fee3bf02406beee2e17/flask_mqtt/__init__.py#L87-L133 |
7,522 | stlehmann/Flask-MQTT | flask_mqtt/__init__.py | Mqtt.subscribe | def subscribe(self, topic, qos=0):
# type: (str, int) -> Tuple[int, int]
"""
Subscribe to a certain topic.
:param topic: a string specifying the subscription topic to
subscribe to.
:param qos: the desired quality of service level for the subscription.
... | python | def subscribe(self, topic, qos=0):
# type: (str, int) -> Tuple[int, int]
"""
Subscribe to a certain topic.
:param topic: a string specifying the subscription topic to
subscribe to.
:param qos: the desired quality of service level for the subscription.
... | [
"def",
"subscribe",
"(",
"self",
",",
"topic",
",",
"qos",
"=",
"0",
")",
":",
"# type: (str, int) -> Tuple[int, int]",
"# TODO: add support for list of topics",
"# don't subscribe if already subscribed",
"# try to subscribe",
"result",
",",
"mid",
"=",
"self",
".",
"clie... | Subscribe to a certain topic.
:param topic: a string specifying the subscription topic to
subscribe to.
:param qos: the desired quality of service level for the subscription.
Defaults to 0.
:rtype: (int, int)
:result: (result, mid)
A topic is a ... | [
"Subscribe",
"to",
"a",
"certain",
"topic",
"."
] | 77d474ab87484ae6eaef2fee3bf02406beee2e17 | https://github.com/stlehmann/Flask-MQTT/blob/77d474ab87484ae6eaef2fee3bf02406beee2e17/flask_mqtt/__init__.py#L225-L268 |
7,523 | stlehmann/Flask-MQTT | flask_mqtt/__init__.py | Mqtt.unsubscribe | def unsubscribe(self, topic):
# type: (str) -> Optional[Tuple[int, int]]
"""
Unsubscribe from a single topic.
:param topic: a single string that is the subscription topic to
unsubscribe from
:rtype: (int, int)
:result: (result, mid)
Return... | python | def unsubscribe(self, topic):
# type: (str) -> Optional[Tuple[int, int]]
"""
Unsubscribe from a single topic.
:param topic: a single string that is the subscription topic to
unsubscribe from
:rtype: (int, int)
:result: (result, mid)
Return... | [
"def",
"unsubscribe",
"(",
"self",
",",
"topic",
")",
":",
"# type: (str) -> Optional[Tuple[int, int]]",
"# don't unsubscribe if not in topics",
"if",
"topic",
"in",
"self",
".",
"topics",
":",
"result",
",",
"mid",
"=",
"self",
".",
"client",
".",
"unsubscribe",
... | Unsubscribe from a single topic.
:param topic: a single string that is the subscription topic to
unsubscribe from
:rtype: (int, int)
:result: (result, mid)
Returns a tuple (result, mid), where result is MQTT_ERR_SUCCESS
to indicate success or (MQTT_ERR_NO... | [
"Unsubscribe",
"from",
"a",
"single",
"topic",
"."
] | 77d474ab87484ae6eaef2fee3bf02406beee2e17 | https://github.com/stlehmann/Flask-MQTT/blob/77d474ab87484ae6eaef2fee3bf02406beee2e17/flask_mqtt/__init__.py#L270-L302 |
7,524 | stlehmann/Flask-MQTT | flask_mqtt/__init__.py | Mqtt.unsubscribe_all | def unsubscribe_all(self):
# type: () -> None
"""Unsubscribe from all topics."""
topics = list(self.topics.keys())
for topic in topics:
self.unsubscribe(topic) | python | def unsubscribe_all(self):
# type: () -> None
"""Unsubscribe from all topics."""
topics = list(self.topics.keys())
for topic in topics:
self.unsubscribe(topic) | [
"def",
"unsubscribe_all",
"(",
"self",
")",
":",
"# type: () -> None",
"topics",
"=",
"list",
"(",
"self",
".",
"topics",
".",
"keys",
"(",
")",
")",
"for",
"topic",
"in",
"topics",
":",
"self",
".",
"unsubscribe",
"(",
"topic",
")"
] | Unsubscribe from all topics. | [
"Unsubscribe",
"from",
"all",
"topics",
"."
] | 77d474ab87484ae6eaef2fee3bf02406beee2e17 | https://github.com/stlehmann/Flask-MQTT/blob/77d474ab87484ae6eaef2fee3bf02406beee2e17/flask_mqtt/__init__.py#L304-L309 |
7,525 | stlehmann/Flask-MQTT | flask_mqtt/__init__.py | Mqtt.publish | def publish(self, topic, payload=None, qos=0, retain=False):
# type: (str, bytes, int, bool) -> Tuple[int, int]
"""
Send a message to the broker.
:param topic: the topic that the message should be published on
:param payload: the actual message to send. If not given, or set to
... | python | def publish(self, topic, payload=None, qos=0, retain=False):
# type: (str, bytes, int, bool) -> Tuple[int, int]
"""
Send a message to the broker.
:param topic: the topic that the message should be published on
:param payload: the actual message to send. If not given, or set to
... | [
"def",
"publish",
"(",
"self",
",",
"topic",
",",
"payload",
"=",
"None",
",",
"qos",
"=",
"0",
",",
"retain",
"=",
"False",
")",
":",
"# type: (str, bytes, int, bool) -> Tuple[int, int]",
"if",
"not",
"self",
".",
"connected",
":",
"self",
".",
"client",
... | Send a message to the broker.
:param topic: the topic that the message should be published on
:param payload: the actual message to send. If not given, or set to
None a zero length message will be used. Passing an
int or float will result in the payload b... | [
"Send",
"a",
"message",
"to",
"the",
"broker",
"."
] | 77d474ab87484ae6eaef2fee3bf02406beee2e17 | https://github.com/stlehmann/Flask-MQTT/blob/77d474ab87484ae6eaef2fee3bf02406beee2e17/flask_mqtt/__init__.py#L311-L343 |
7,526 | stlehmann/Flask-MQTT | flask_mqtt/__init__.py | Mqtt.on_subscribe | def on_subscribe(self):
# type: () -> Callable
"""Decorate a callback function to handle subscritions.
**Usage:**::
@mqtt.on_subscribe()
def handle_subscribe(client, userdata, mid, granted_qos):
print('Subscription id {} granted with qos {}.'
... | python | def on_subscribe(self):
# type: () -> Callable
"""Decorate a callback function to handle subscritions.
**Usage:**::
@mqtt.on_subscribe()
def handle_subscribe(client, userdata, mid, granted_qos):
print('Subscription id {} granted with qos {}.'
... | [
"def",
"on_subscribe",
"(",
"self",
")",
":",
"# type: () -> Callable",
"def",
"decorator",
"(",
"handler",
")",
":",
"# type: (Callable) -> Callable",
"self",
".",
"client",
".",
"on_subscribe",
"=",
"handler",
"return",
"handler",
"return",
"decorator"
] | Decorate a callback function to handle subscritions.
**Usage:**::
@mqtt.on_subscribe()
def handle_subscribe(client, userdata, mid, granted_qos):
print('Subscription id {} granted with qos {}.'
.format(mid, granted_qos)) | [
"Decorate",
"a",
"callback",
"function",
"to",
"handle",
"subscritions",
"."
] | 77d474ab87484ae6eaef2fee3bf02406beee2e17 | https://github.com/stlehmann/Flask-MQTT/blob/77d474ab87484ae6eaef2fee3bf02406beee2e17/flask_mqtt/__init__.py#L421-L437 |
7,527 | stlehmann/Flask-MQTT | flask_mqtt/__init__.py | Mqtt.on_unsubscribe | def on_unsubscribe(self):
# type: () -> Callable
"""Decorate a callback funtion to handle unsubscribtions.
**Usage:**::
@mqtt.unsubscribe()
def handle_unsubscribe(client, userdata, mid)
print('Unsubscribed from topic (id: {})'
.form... | python | def on_unsubscribe(self):
# type: () -> Callable
"""Decorate a callback funtion to handle unsubscribtions.
**Usage:**::
@mqtt.unsubscribe()
def handle_unsubscribe(client, userdata, mid)
print('Unsubscribed from topic (id: {})'
.form... | [
"def",
"on_unsubscribe",
"(",
"self",
")",
":",
"# type: () -> Callable",
"def",
"decorator",
"(",
"handler",
")",
":",
"# type: (Callable) -> Callable",
"self",
".",
"client",
".",
"on_unsubscribe",
"=",
"handler",
"return",
"handler",
"return",
"decorator"
] | Decorate a callback funtion to handle unsubscribtions.
**Usage:**::
@mqtt.unsubscribe()
def handle_unsubscribe(client, userdata, mid)
print('Unsubscribed from topic (id: {})'
.format(mid)') | [
"Decorate",
"a",
"callback",
"funtion",
"to",
"handle",
"unsubscribtions",
"."
] | 77d474ab87484ae6eaef2fee3bf02406beee2e17 | https://github.com/stlehmann/Flask-MQTT/blob/77d474ab87484ae6eaef2fee3bf02406beee2e17/flask_mqtt/__init__.py#L439-L455 |
7,528 | stlehmann/Flask-MQTT | flask_mqtt/__init__.py | Mqtt.on_log | def on_log(self):
# type: () -> Callable
"""Decorate a callback function to handle MQTT logging.
**Example Usage:**
::
@mqtt.on_log()
def handle_logging(client, userdata, level, buf):
print(client, userdata, level, buf)
"""
def d... | python | def on_log(self):
# type: () -> Callable
"""Decorate a callback function to handle MQTT logging.
**Example Usage:**
::
@mqtt.on_log()
def handle_logging(client, userdata, level, buf):
print(client, userdata, level, buf)
"""
def d... | [
"def",
"on_log",
"(",
"self",
")",
":",
"# type: () -> Callable",
"def",
"decorator",
"(",
"handler",
")",
":",
"# type: (Callable) -> Callable",
"self",
".",
"client",
".",
"on_log",
"=",
"handler",
"return",
"handler",
"return",
"decorator"
] | Decorate a callback function to handle MQTT logging.
**Example Usage:**
::
@mqtt.on_log()
def handle_logging(client, userdata, level, buf):
print(client, userdata, level, buf) | [
"Decorate",
"a",
"callback",
"function",
"to",
"handle",
"MQTT",
"logging",
"."
] | 77d474ab87484ae6eaef2fee3bf02406beee2e17 | https://github.com/stlehmann/Flask-MQTT/blob/77d474ab87484ae6eaef2fee3bf02406beee2e17/flask_mqtt/__init__.py#L457-L474 |
7,529 | kennethreitz/bucketstore | bucketstore.py | list | def list():
"""Lists buckets, by name."""
s3 = boto3.resource('s3')
return [b.name for b in s3.buckets.all()] | python | def list():
"""Lists buckets, by name."""
s3 = boto3.resource('s3')
return [b.name for b in s3.buckets.all()] | [
"def",
"list",
"(",
")",
":",
"s3",
"=",
"boto3",
".",
"resource",
"(",
"'s3'",
")",
"return",
"[",
"b",
".",
"name",
"for",
"b",
"in",
"s3",
".",
"buckets",
".",
"all",
"(",
")",
"]"
] | Lists buckets, by name. | [
"Lists",
"buckets",
"by",
"name",
"."
] | 2d79584d44b9c422192d7fdf08a85a49addf83d5 | https://github.com/kennethreitz/bucketstore/blob/2d79584d44b9c422192d7fdf08a85a49addf83d5/bucketstore.py#L6-L9 |
7,530 | kennethreitz/bucketstore | bucketstore.py | S3Bucket.delete | def delete(self, key=None):
"""Deletes the given key, or the whole bucket."""
# Delete the whole bucket.
if key is None:
# Delete everything in the bucket.
for key in self.all():
key.delete()
# Delete the bucket.
return self._boto... | python | def delete(self, key=None):
"""Deletes the given key, or the whole bucket."""
# Delete the whole bucket.
if key is None:
# Delete everything in the bucket.
for key in self.all():
key.delete()
# Delete the bucket.
return self._boto... | [
"def",
"delete",
"(",
"self",
",",
"key",
"=",
"None",
")",
":",
"# Delete the whole bucket.",
"if",
"key",
"is",
"None",
":",
"# Delete everything in the bucket.",
"for",
"key",
"in",
"self",
".",
"all",
"(",
")",
":",
"key",
".",
"delete",
"(",
")",
"#... | Deletes the given key, or the whole bucket. | [
"Deletes",
"the",
"given",
"key",
"or",
"the",
"whole",
"bucket",
"."
] | 2d79584d44b9c422192d7fdf08a85a49addf83d5 | https://github.com/kennethreitz/bucketstore/blob/2d79584d44b9c422192d7fdf08a85a49addf83d5/bucketstore.py#L80-L94 |
7,531 | kennethreitz/bucketstore | bucketstore.py | S3Key.rename | def rename(self, new_name):
"""Renames the key to a given new name."""
# Write the new object.
self.bucket.set(new_name, self.get(), self.meta)
# Delete the current key.
self.delete()
# Set the new name.
self.name = new_name | python | def rename(self, new_name):
"""Renames the key to a given new name."""
# Write the new object.
self.bucket.set(new_name, self.get(), self.meta)
# Delete the current key.
self.delete()
# Set the new name.
self.name = new_name | [
"def",
"rename",
"(",
"self",
",",
"new_name",
")",
":",
"# Write the new object.",
"self",
".",
"bucket",
".",
"set",
"(",
"new_name",
",",
"self",
".",
"get",
"(",
")",
",",
"self",
".",
"meta",
")",
"# Delete the current key.",
"self",
".",
"delete",
... | Renames the key to a given new name. | [
"Renames",
"the",
"key",
"to",
"a",
"given",
"new",
"name",
"."
] | 2d79584d44b9c422192d7fdf08a85a49addf83d5 | https://github.com/kennethreitz/bucketstore/blob/2d79584d44b9c422192d7fdf08a85a49addf83d5/bucketstore.py#L126-L135 |
7,532 | kennethreitz/bucketstore | bucketstore.py | S3Key.is_public | def is_public(self):
"""Returns True if the public-read ACL is set for the Key."""
for grant in self._boto_object.Acl().grants:
if 'AllUsers' in grant['Grantee'].get('URI', ''):
if grant['Permission'] == 'READ':
return True
return False | python | def is_public(self):
"""Returns True if the public-read ACL is set for the Key."""
for grant in self._boto_object.Acl().grants:
if 'AllUsers' in grant['Grantee'].get('URI', ''):
if grant['Permission'] == 'READ':
return True
return False | [
"def",
"is_public",
"(",
"self",
")",
":",
"for",
"grant",
"in",
"self",
".",
"_boto_object",
".",
"Acl",
"(",
")",
".",
"grants",
":",
"if",
"'AllUsers'",
"in",
"grant",
"[",
"'Grantee'",
"]",
".",
"get",
"(",
"'URI'",
",",
"''",
")",
":",
"if",
... | Returns True if the public-read ACL is set for the Key. | [
"Returns",
"True",
"if",
"the",
"public",
"-",
"read",
"ACL",
"is",
"set",
"for",
"the",
"Key",
"."
] | 2d79584d44b9c422192d7fdf08a85a49addf83d5 | https://github.com/kennethreitz/bucketstore/blob/2d79584d44b9c422192d7fdf08a85a49addf83d5/bucketstore.py#L142-L149 |
7,533 | kennethreitz/bucketstore | bucketstore.py | S3Key.url | def url(self):
"""Returns the public URL for the given key."""
if self.is_public:
return '{0}/{1}/{2}'.format(
self.bucket._boto_s3.meta.client.meta.endpoint_url,
self.bucket.name,
self.name
)
else:
raise ValueEr... | python | def url(self):
"""Returns the public URL for the given key."""
if self.is_public:
return '{0}/{1}/{2}'.format(
self.bucket._boto_s3.meta.client.meta.endpoint_url,
self.bucket.name,
self.name
)
else:
raise ValueEr... | [
"def",
"url",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_public",
":",
"return",
"'{0}/{1}/{2}'",
".",
"format",
"(",
"self",
".",
"bucket",
".",
"_boto_s3",
".",
"meta",
".",
"client",
".",
"meta",
".",
"endpoint_url",
",",
"self",
".",
"bucket",
... | Returns the public URL for the given key. | [
"Returns",
"the",
"public",
"URL",
"for",
"the",
"given",
"key",
"."
] | 2d79584d44b9c422192d7fdf08a85a49addf83d5 | https://github.com/kennethreitz/bucketstore/blob/2d79584d44b9c422192d7fdf08a85a49addf83d5/bucketstore.py#L167-L178 |
7,534 | kennethreitz/bucketstore | bucketstore.py | S3Key.temp_url | def temp_url(self, duration=120):
"""Returns a temporary URL for the given key."""
return self.bucket._boto_s3.meta.client.generate_presigned_url(
'get_object',
Params={'Bucket': self.bucket.name, 'Key': self.name},
ExpiresIn=duration
) | python | def temp_url(self, duration=120):
"""Returns a temporary URL for the given key."""
return self.bucket._boto_s3.meta.client.generate_presigned_url(
'get_object',
Params={'Bucket': self.bucket.name, 'Key': self.name},
ExpiresIn=duration
) | [
"def",
"temp_url",
"(",
"self",
",",
"duration",
"=",
"120",
")",
":",
"return",
"self",
".",
"bucket",
".",
"_boto_s3",
".",
"meta",
".",
"client",
".",
"generate_presigned_url",
"(",
"'get_object'",
",",
"Params",
"=",
"{",
"'Bucket'",
":",
"self",
"."... | Returns a temporary URL for the given key. | [
"Returns",
"a",
"temporary",
"URL",
"for",
"the",
"given",
"key",
"."
] | 2d79584d44b9c422192d7fdf08a85a49addf83d5 | https://github.com/kennethreitz/bucketstore/blob/2d79584d44b9c422192d7fdf08a85a49addf83d5/bucketstore.py#L180-L186 |
7,535 | cs50/python-cs50 | src/cs50/cs50.py | eprint | def eprint(*args, **kwargs):
"""
Print an error message to standard error, prefixing it with
file name and line number from which method was called.
"""
end = kwargs.get("end", "\n")
sep = kwargs.get("sep", " ")
(filename, lineno) = inspect.stack()[1][1:3]
print("{}:{}: ".format(filename... | python | def eprint(*args, **kwargs):
"""
Print an error message to standard error, prefixing it with
file name and line number from which method was called.
"""
end = kwargs.get("end", "\n")
sep = kwargs.get("sep", " ")
(filename, lineno) = inspect.stack()[1][1:3]
print("{}:{}: ".format(filename... | [
"def",
"eprint",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"end",
"=",
"kwargs",
".",
"get",
"(",
"\"end\"",
",",
"\"\\n\"",
")",
"sep",
"=",
"kwargs",
".",
"get",
"(",
"\"sep\"",
",",
"\" \"",
")",
"(",
"filename",
",",
"lineno",
")",... | Print an error message to standard error, prefixing it with
file name and line number from which method was called. | [
"Print",
"an",
"error",
"message",
"to",
"standard",
"error",
"prefixing",
"it",
"with",
"file",
"name",
"and",
"line",
"number",
"from",
"which",
"method",
"was",
"called",
"."
] | f987e9036bcf1bf60adf50a2827cc2cd5b9fd08a | https://github.com/cs50/python-cs50/blob/f987e9036bcf1bf60adf50a2827cc2cd5b9fd08a/src/cs50/cs50.py#L35-L44 |
7,536 | cs50/python-cs50 | src/cs50/cs50.py | formatException | def formatException(type, value, tb):
"""
Format traceback, darkening entries from global site-packages directories
and user-specific site-packages directory.
https://stackoverflow.com/a/46071447/5156190
"""
# Absolute paths to site-packages
packages = tuple(join(abspath(p), "") for p in s... | python | def formatException(type, value, tb):
"""
Format traceback, darkening entries from global site-packages directories
and user-specific site-packages directory.
https://stackoverflow.com/a/46071447/5156190
"""
# Absolute paths to site-packages
packages = tuple(join(abspath(p), "") for p in s... | [
"def",
"formatException",
"(",
"type",
",",
"value",
",",
"tb",
")",
":",
"# Absolute paths to site-packages",
"packages",
"=",
"tuple",
"(",
"join",
"(",
"abspath",
"(",
"p",
")",
",",
"\"\"",
")",
"for",
"p",
"in",
"sys",
".",
"path",
"[",
"1",
":",
... | Format traceback, darkening entries from global site-packages directories
and user-specific site-packages directory.
https://stackoverflow.com/a/46071447/5156190 | [
"Format",
"traceback",
"darkening",
"entries",
"from",
"global",
"site",
"-",
"packages",
"directories",
"and",
"user",
"-",
"specific",
"site",
"-",
"packages",
"directory",
"."
] | f987e9036bcf1bf60adf50a2827cc2cd5b9fd08a | https://github.com/cs50/python-cs50/blob/f987e9036bcf1bf60adf50a2827cc2cd5b9fd08a/src/cs50/cs50.py#L47-L67 |
7,537 | cs50/python-cs50 | src/cs50/cs50.py | get_char | def get_char(prompt=None):
"""
Read a line of text from standard input and return the equivalent char;
if text is not a single char, user is prompted to retry. If line can't
be read, return None.
"""
while True:
s = get_string(prompt)
if s is None:
return None
... | python | def get_char(prompt=None):
"""
Read a line of text from standard input and return the equivalent char;
if text is not a single char, user is prompted to retry. If line can't
be read, return None.
"""
while True:
s = get_string(prompt)
if s is None:
return None
... | [
"def",
"get_char",
"(",
"prompt",
"=",
"None",
")",
":",
"while",
"True",
":",
"s",
"=",
"get_string",
"(",
"prompt",
")",
"if",
"s",
"is",
"None",
":",
"return",
"None",
"if",
"len",
"(",
"s",
")",
"==",
"1",
":",
"return",
"s",
"[",
"0",
"]",... | Read a line of text from standard input and return the equivalent char;
if text is not a single char, user is prompted to retry. If line can't
be read, return None. | [
"Read",
"a",
"line",
"of",
"text",
"from",
"standard",
"input",
"and",
"return",
"the",
"equivalent",
"char",
";",
"if",
"text",
"is",
"not",
"a",
"single",
"char",
"user",
"is",
"prompted",
"to",
"retry",
".",
"If",
"line",
"can",
"t",
"be",
"read",
... | f987e9036bcf1bf60adf50a2827cc2cd5b9fd08a | https://github.com/cs50/python-cs50/blob/f987e9036bcf1bf60adf50a2827cc2cd5b9fd08a/src/cs50/cs50.py#L73-L88 |
7,538 | cs50/python-cs50 | src/cs50/cs50.py | get_float | def get_float(prompt=None):
"""
Read a line of text from standard input and return the equivalent float
as precisely as possible; if text does not represent a double, user is
prompted to retry. If line can't be read, return None.
"""
while True:
s = get_string(prompt)
if s is Non... | python | def get_float(prompt=None):
"""
Read a line of text from standard input and return the equivalent float
as precisely as possible; if text does not represent a double, user is
prompted to retry. If line can't be read, return None.
"""
while True:
s = get_string(prompt)
if s is Non... | [
"def",
"get_float",
"(",
"prompt",
"=",
"None",
")",
":",
"while",
"True",
":",
"s",
"=",
"get_string",
"(",
"prompt",
")",
"if",
"s",
"is",
"None",
":",
"return",
"None",
"if",
"len",
"(",
"s",
")",
">",
"0",
"and",
"re",
".",
"search",
"(",
"... | Read a line of text from standard input and return the equivalent float
as precisely as possible; if text does not represent a double, user is
prompted to retry. If line can't be read, return None. | [
"Read",
"a",
"line",
"of",
"text",
"from",
"standard",
"input",
"and",
"return",
"the",
"equivalent",
"float",
"as",
"precisely",
"as",
"possible",
";",
"if",
"text",
"does",
"not",
"represent",
"a",
"double",
"user",
"is",
"prompted",
"to",
"retry",
".",
... | f987e9036bcf1bf60adf50a2827cc2cd5b9fd08a | https://github.com/cs50/python-cs50/blob/f987e9036bcf1bf60adf50a2827cc2cd5b9fd08a/src/cs50/cs50.py#L91-L109 |
7,539 | cs50/python-cs50 | src/cs50/cs50.py | get_int | def get_int(prompt=None):
"""
Read a line of text from standard input and return the equivalent int;
if text does not represent an int, user is prompted to retry. If line
can't be read, return None.
"""
while True:
s = get_string(prompt)
if s is None:
return None
... | python | def get_int(prompt=None):
"""
Read a line of text from standard input and return the equivalent int;
if text does not represent an int, user is prompted to retry. If line
can't be read, return None.
"""
while True:
s = get_string(prompt)
if s is None:
return None
... | [
"def",
"get_int",
"(",
"prompt",
"=",
"None",
")",
":",
"while",
"True",
":",
"s",
"=",
"get_string",
"(",
"prompt",
")",
"if",
"s",
"is",
"None",
":",
"return",
"None",
"if",
"re",
".",
"search",
"(",
"r\"^[+-]?\\d+$\"",
",",
"s",
")",
":",
"try",... | Read a line of text from standard input and return the equivalent int;
if text does not represent an int, user is prompted to retry. If line
can't be read, return None. | [
"Read",
"a",
"line",
"of",
"text",
"from",
"standard",
"input",
"and",
"return",
"the",
"equivalent",
"int",
";",
"if",
"text",
"does",
"not",
"represent",
"an",
"int",
"user",
"is",
"prompted",
"to",
"retry",
".",
"If",
"line",
"can",
"t",
"be",
"read... | f987e9036bcf1bf60adf50a2827cc2cd5b9fd08a | https://github.com/cs50/python-cs50/blob/f987e9036bcf1bf60adf50a2827cc2cd5b9fd08a/src/cs50/cs50.py#L112-L132 |
7,540 | cs50/python-cs50 | src/cs50/sql.py | _connect | def _connect(dbapi_connection, connection_record):
"""Enables foreign key support."""
# If back end is sqlite
if type(dbapi_connection) is sqlite3.Connection:
# Respect foreign key constraints by default
cursor = dbapi_connection.cursor()
cursor.execute("PRAGMA foreign_keys=ON")
... | python | def _connect(dbapi_connection, connection_record):
"""Enables foreign key support."""
# If back end is sqlite
if type(dbapi_connection) is sqlite3.Connection:
# Respect foreign key constraints by default
cursor = dbapi_connection.cursor()
cursor.execute("PRAGMA foreign_keys=ON")
... | [
"def",
"_connect",
"(",
"dbapi_connection",
",",
"connection_record",
")",
":",
"# If back end is sqlite",
"if",
"type",
"(",
"dbapi_connection",
")",
"is",
"sqlite3",
".",
"Connection",
":",
"# Respect foreign key constraints by default",
"cursor",
"=",
"dbapi_connection... | Enables foreign key support. | [
"Enables",
"foreign",
"key",
"support",
"."
] | f987e9036bcf1bf60adf50a2827cc2cd5b9fd08a | https://github.com/cs50/python-cs50/blob/f987e9036bcf1bf60adf50a2827cc2cd5b9fd08a/src/cs50/sql.py#L233-L242 |
7,541 | cs50/python-cs50 | src/cs50/sql.py | SQL._parse | def _parse(self, e):
"""Parses an exception, returns its message."""
# MySQL
matches = re.search(r"^\(_mysql_exceptions\.OperationalError\) \(\d+, \"(.+)\"\)$", str(e))
if matches:
return matches.group(1)
# PostgreSQL
matches = re.search(r"^\(psycopg2\.Opera... | python | def _parse(self, e):
"""Parses an exception, returns its message."""
# MySQL
matches = re.search(r"^\(_mysql_exceptions\.OperationalError\) \(\d+, \"(.+)\"\)$", str(e))
if matches:
return matches.group(1)
# PostgreSQL
matches = re.search(r"^\(psycopg2\.Opera... | [
"def",
"_parse",
"(",
"self",
",",
"e",
")",
":",
"# MySQL",
"matches",
"=",
"re",
".",
"search",
"(",
"r\"^\\(_mysql_exceptions\\.OperationalError\\) \\(\\d+, \\\"(.+)\\\"\\)$\"",
",",
"str",
"(",
"e",
")",
")",
"if",
"matches",
":",
"return",
"matches",
".",
... | Parses an exception, returns its message. | [
"Parses",
"an",
"exception",
"returns",
"its",
"message",
"."
] | f987e9036bcf1bf60adf50a2827cc2cd5b9fd08a | https://github.com/cs50/python-cs50/blob/f987e9036bcf1bf60adf50a2827cc2cd5b9fd08a/src/cs50/sql.py#L68-L87 |
7,542 | Azure/azure-cosmos-table-python | azure-cosmosdb-table/azure/cosmosdb/table/tableservice.py | TableService.get_table_service_stats | def get_table_service_stats(self, timeout=None):
'''
Retrieves statistics related to replication for the Table service. It is
only available when read-access geo-redundant replication is enabled for
the storage account.
With geo-redundant replication, Azure Storage maintains y... | python | def get_table_service_stats(self, timeout=None):
'''
Retrieves statistics related to replication for the Table service. It is
only available when read-access geo-redundant replication is enabled for
the storage account.
With geo-redundant replication, Azure Storage maintains y... | [
"def",
"get_table_service_stats",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"request",
"=",
"HTTPRequest",
"(",
")",
"request",
".",
"method",
"=",
"'GET'",
"request",
".",
"host_locations",
"=",
"self",
".",
"_get_host_locations",
"(",
"primary",
... | Retrieves statistics related to replication for the Table service. It is
only available when read-access geo-redundant replication is enabled for
the storage account.
With geo-redundant replication, Azure Storage maintains your data durable
in two locations. In both locations, Azure ... | [
"Retrieves",
"statistics",
"related",
"to",
"replication",
"for",
"the",
"Table",
"service",
".",
"It",
"is",
"only",
"available",
"when",
"read",
"-",
"access",
"geo",
"-",
"redundant",
"replication",
"is",
"enabled",
"for",
"the",
"storage",
"account",
"."
] | a7b618f6bddc465c9fdf899ea2971dfe4d04fcf0 | https://github.com/Azure/azure-cosmos-table-python/blob/a7b618f6bddc465c9fdf899ea2971dfe4d04fcf0/azure-cosmosdb-table/azure/cosmosdb/table/tableservice.py#L335-L369 |
7,543 | Azure/azure-cosmos-table-python | azure-cosmosdb-table/azure/cosmosdb/table/tableservice.py | TableService.get_table_service_properties | def get_table_service_properties(self, timeout=None):
'''
Gets the properties of a storage account's Table service, including
logging, analytics and CORS rules.
:param int timeout:
The server timeout, expressed in seconds.
:return: The table service properties.
... | python | def get_table_service_properties(self, timeout=None):
'''
Gets the properties of a storage account's Table service, including
logging, analytics and CORS rules.
:param int timeout:
The server timeout, expressed in seconds.
:return: The table service properties.
... | [
"def",
"get_table_service_properties",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"request",
"=",
"HTTPRequest",
"(",
")",
"request",
".",
"method",
"=",
"'GET'",
"request",
".",
"host_locations",
"=",
"self",
".",
"_get_host_locations",
"(",
"seconda... | Gets the properties of a storage account's Table service, including
logging, analytics and CORS rules.
:param int timeout:
The server timeout, expressed in seconds.
:return: The table service properties.
:rtype: :class:`~azure.storage.common.models.ServiceProperties` | [
"Gets",
"the",
"properties",
"of",
"a",
"storage",
"account",
"s",
"Table",
"service",
"including",
"logging",
"analytics",
"and",
"CORS",
"rules",
"."
] | a7b618f6bddc465c9fdf899ea2971dfe4d04fcf0 | https://github.com/Azure/azure-cosmos-table-python/blob/a7b618f6bddc465c9fdf899ea2971dfe4d04fcf0/azure-cosmosdb-table/azure/cosmosdb/table/tableservice.py#L371-L391 |
7,544 | Azure/azure-cosmos-table-python | azure-cosmosdb-table/azure/cosmosdb/table/tableservice.py | TableService.delete_table | def delete_table(self, table_name, fail_not_exist=False, timeout=None):
'''
Deletes the specified table and any data it contains.
When a table is successfully deleted, it is immediately marked for deletion
and is no longer accessible to clients. The table is later removed from
... | python | def delete_table(self, table_name, fail_not_exist=False, timeout=None):
'''
Deletes the specified table and any data it contains.
When a table is successfully deleted, it is immediately marked for deletion
and is no longer accessible to clients. The table is later removed from
... | [
"def",
"delete_table",
"(",
"self",
",",
"table_name",
",",
"fail_not_exist",
"=",
"False",
",",
"timeout",
"=",
"None",
")",
":",
"_validate_not_none",
"(",
"'table_name'",
",",
"table_name",
")",
"request",
"=",
"HTTPRequest",
"(",
")",
"request",
".",
"me... | Deletes the specified table and any data it contains.
When a table is successfully deleted, it is immediately marked for deletion
and is no longer accessible to clients. The table is later removed from
the Table service during garbage collection.
Note that deleting a table is likely ... | [
"Deletes",
"the",
"specified",
"table",
"and",
"any",
"data",
"it",
"contains",
"."
] | a7b618f6bddc465c9fdf899ea2971dfe4d04fcf0 | https://github.com/Azure/azure-cosmos-table-python/blob/a7b618f6bddc465c9fdf899ea2971dfe4d04fcf0/azure-cosmosdb-table/azure/cosmosdb/table/tableservice.py#L571-L611 |
7,545 | Azure/azure-cosmos-table-python | azure-cosmosdb-table/azure/cosmosdb/table/tableservice.py | TableService.query_entities | def query_entities(self, table_name, filter=None, select=None, num_results=None,
marker=None, accept=TablePayloadFormat.JSON_MINIMAL_METADATA,
property_resolver=None, timeout=None):
'''
Returns a generator to list the entities in the table specified. The
... | python | def query_entities(self, table_name, filter=None, select=None, num_results=None,
marker=None, accept=TablePayloadFormat.JSON_MINIMAL_METADATA,
property_resolver=None, timeout=None):
'''
Returns a generator to list the entities in the table specified. The
... | [
"def",
"query_entities",
"(",
"self",
",",
"table_name",
",",
"filter",
"=",
"None",
",",
"select",
"=",
"None",
",",
"num_results",
"=",
"None",
",",
"marker",
"=",
"None",
",",
"accept",
"=",
"TablePayloadFormat",
".",
"JSON_MINIMAL_METADATA",
",",
"proper... | Returns a generator to list the entities in the table specified. The
generator will lazily follow the continuation tokens returned by the
service and stop when all entities have been returned or num_results is
reached.
If num_results is specified and the account has more than that num... | [
"Returns",
"a",
"generator",
"to",
"list",
"the",
"entities",
"in",
"the",
"table",
"specified",
".",
"The",
"generator",
"will",
"lazily",
"follow",
"the",
"continuation",
"tokens",
"returned",
"by",
"the",
"service",
"and",
"stop",
"when",
"all",
"entities",... | a7b618f6bddc465c9fdf899ea2971dfe4d04fcf0 | https://github.com/Azure/azure-cosmos-table-python/blob/a7b618f6bddc465c9fdf899ea2971dfe4d04fcf0/azure-cosmosdb-table/azure/cosmosdb/table/tableservice.py#L678-L740 |
7,546 | Azure/azure-cosmos-table-python | azure-cosmosdb-table/azure/cosmosdb/table/tableservice.py | TableService.merge_entity | def merge_entity(self, table_name, entity, if_match='*', timeout=None):
'''
Updates an existing entity by merging the entity's properties. Throws
if the entity does not exist.
This operation does not replace the existing entity as the update_entity
operation does. A pr... | python | def merge_entity(self, table_name, entity, if_match='*', timeout=None):
'''
Updates an existing entity by merging the entity's properties. Throws
if the entity does not exist.
This operation does not replace the existing entity as the update_entity
operation does. A pr... | [
"def",
"merge_entity",
"(",
"self",
",",
"table_name",
",",
"entity",
",",
"if_match",
"=",
"'*'",
",",
"timeout",
"=",
"None",
")",
":",
"_validate_not_none",
"(",
"'table_name'",
",",
"table_name",
")",
"request",
"=",
"_merge_entity",
"(",
"entity",
",",
... | Updates an existing entity by merging the entity's properties. Throws
if the entity does not exist.
This operation does not replace the existing entity as the update_entity
operation does. A property cannot be removed with merge_entity.
Any properties with null values... | [
"Updates",
"an",
"existing",
"entity",
"by",
"merging",
"the",
"entity",
"s",
"properties",
".",
"Throws",
"if",
"the",
"entity",
"does",
"not",
"exist",
".",
"This",
"operation",
"does",
"not",
"replace",
"the",
"existing",
"entity",
"as",
"the",
"update_en... | a7b618f6bddc465c9fdf899ea2971dfe4d04fcf0 | https://github.com/Azure/azure-cosmos-table-python/blob/a7b618f6bddc465c9fdf899ea2971dfe4d04fcf0/azure-cosmosdb-table/azure/cosmosdb/table/tableservice.py#L969-L1008 |
7,547 | Azure/azure-cosmos-table-python | azure-cosmosdb-table/samples/table/table_usage.py | TableSamples.create_entity_class | def create_entity_class(self):
'''
Creates a class-based entity with fixed values, using all of the supported data types.
'''
entity = Entity()
# Partition key and row key must be strings and are required
entity.PartitionKey = 'pk{}'.format(str(uuid.uuid4()).replace('-',... | python | def create_entity_class(self):
'''
Creates a class-based entity with fixed values, using all of the supported data types.
'''
entity = Entity()
# Partition key and row key must be strings and are required
entity.PartitionKey = 'pk{}'.format(str(uuid.uuid4()).replace('-',... | [
"def",
"create_entity_class",
"(",
"self",
")",
":",
"entity",
"=",
"Entity",
"(",
")",
"# Partition key and row key must be strings and are required",
"entity",
".",
"PartitionKey",
"=",
"'pk{}'",
".",
"format",
"(",
"str",
"(",
"uuid",
".",
"uuid4",
"(",
")",
... | Creates a class-based entity with fixed values, using all of the supported data types. | [
"Creates",
"a",
"class",
"-",
"based",
"entity",
"with",
"fixed",
"values",
"using",
"all",
"of",
"the",
"supported",
"data",
"types",
"."
] | a7b618f6bddc465c9fdf899ea2971dfe4d04fcf0 | https://github.com/Azure/azure-cosmos-table-python/blob/a7b618f6bddc465c9fdf899ea2971dfe4d04fcf0/azure-cosmosdb-table/samples/table/table_usage.py#L203-L225 |
7,548 | Azure/azure-cosmos-table-python | azure-cosmosdb-table/samples/table/table_usage.py | TableSamples.create_entity_dict | def create_entity_dict(self):
'''
Creates a dict-based entity with fixed values, using all of the supported data types.
'''
entity = {}
# Partition key and row key must be strings and are required
entity['PartitionKey'] = 'pk{}'.format(str(uuid.uuid4()).replace('-', ''))... | python | def create_entity_dict(self):
'''
Creates a dict-based entity with fixed values, using all of the supported data types.
'''
entity = {}
# Partition key and row key must be strings and are required
entity['PartitionKey'] = 'pk{}'.format(str(uuid.uuid4()).replace('-', ''))... | [
"def",
"create_entity_dict",
"(",
"self",
")",
":",
"entity",
"=",
"{",
"}",
"# Partition key and row key must be strings and are required",
"entity",
"[",
"'PartitionKey'",
"]",
"=",
"'pk{}'",
".",
"format",
"(",
"str",
"(",
"uuid",
".",
"uuid4",
"(",
")",
")",... | Creates a dict-based entity with fixed values, using all of the supported data types. | [
"Creates",
"a",
"dict",
"-",
"based",
"entity",
"with",
"fixed",
"values",
"using",
"all",
"of",
"the",
"supported",
"data",
"types",
"."
] | a7b618f6bddc465c9fdf899ea2971dfe4d04fcf0 | https://github.com/Azure/azure-cosmos-table-python/blob/a7b618f6bddc465c9fdf899ea2971dfe4d04fcf0/azure-cosmosdb-table/samples/table/table_usage.py#L227-L249 |
7,549 | Azure/azure-cosmos-table-python | azure-cosmosdb-table/azure/cosmosdb/table/_serialization.py | _convert_batch_to_json | def _convert_batch_to_json(batch_requests):
'''
Create json to send for an array of batch requests.
batch_requests:
an array of requests
'''
batch_boundary = b'batch_' + _new_boundary()
changeset_boundary = b'changeset_' + _new_boundary()
body = [b'--' + batch_boundary + b'\n',
... | python | def _convert_batch_to_json(batch_requests):
'''
Create json to send for an array of batch requests.
batch_requests:
an array of requests
'''
batch_boundary = b'batch_' + _new_boundary()
changeset_boundary = b'changeset_' + _new_boundary()
body = [b'--' + batch_boundary + b'\n',
... | [
"def",
"_convert_batch_to_json",
"(",
"batch_requests",
")",
":",
"batch_boundary",
"=",
"b'batch_'",
"+",
"_new_boundary",
"(",
")",
"changeset_boundary",
"=",
"b'changeset_'",
"+",
"_new_boundary",
"(",
")",
"body",
"=",
"[",
"b'--'",
"+",
"batch_boundary",
"+",... | Create json to send for an array of batch requests.
batch_requests:
an array of requests | [
"Create",
"json",
"to",
"send",
"for",
"an",
"array",
"of",
"batch",
"requests",
"."
] | a7b618f6bddc465c9fdf899ea2971dfe4d04fcf0 | https://github.com/Azure/azure-cosmos-table-python/blob/a7b618f6bddc465c9fdf899ea2971dfe4d04fcf0/azure-cosmosdb-table/azure/cosmosdb/table/_serialization.py#L220-L266 |
7,550 | Azure/azure-cosmos-table-python | azure-cosmosdb-table/azure/cosmosdb/table/_encryption.py | _decrypt_entity | def _decrypt_entity(entity, encrypted_properties_list, content_encryption_key, entityIV, isJavaV1):
'''
Decrypts the specified entity using AES256 in CBC mode with 128 bit padding. Unwraps the CEK
using either the specified KEK or the key returned by the key_resolver. Properties
specified in the encry... | python | def _decrypt_entity(entity, encrypted_properties_list, content_encryption_key, entityIV, isJavaV1):
'''
Decrypts the specified entity using AES256 in CBC mode with 128 bit padding. Unwraps the CEK
using either the specified KEK or the key returned by the key_resolver. Properties
specified in the encry... | [
"def",
"_decrypt_entity",
"(",
"entity",
",",
"encrypted_properties_list",
",",
"content_encryption_key",
",",
"entityIV",
",",
"isJavaV1",
")",
":",
"_validate_not_none",
"(",
"'entity'",
",",
"entity",
")",
"decrypted_entity",
"=",
"deepcopy",
"(",
"entity",
")",
... | Decrypts the specified entity using AES256 in CBC mode with 128 bit padding. Unwraps the CEK
using either the specified KEK or the key returned by the key_resolver. Properties
specified in the encrypted_properties_list, will be decrypted and decoded to utf-8 strings.
:param entity:
The entity bei... | [
"Decrypts",
"the",
"specified",
"entity",
"using",
"AES256",
"in",
"CBC",
"mode",
"with",
"128",
"bit",
"padding",
".",
"Unwraps",
"the",
"CEK",
"using",
"either",
"the",
"specified",
"KEK",
"or",
"the",
"key",
"returned",
"by",
"the",
"key_resolver",
".",
... | a7b618f6bddc465c9fdf899ea2971dfe4d04fcf0 | https://github.com/Azure/azure-cosmos-table-python/blob/a7b618f6bddc465c9fdf899ea2971dfe4d04fcf0/azure-cosmosdb-table/azure/cosmosdb/table/_encryption.py#L163-L212 |
7,551 | Azure/azure-cosmos-table-python | azure-cosmosdb-table/azure/cosmosdb/table/_encryption.py | _generate_property_iv | def _generate_property_iv(entity_iv, pk, rk, property_name, isJavaV1):
'''
Uses the entity_iv, partition key, and row key to generate and return
the iv for the specified property.
'''
digest = Hash(SHA256(), default_backend())
if not isJavaV1:
digest.update(entity_iv +
... | python | def _generate_property_iv(entity_iv, pk, rk, property_name, isJavaV1):
'''
Uses the entity_iv, partition key, and row key to generate and return
the iv for the specified property.
'''
digest = Hash(SHA256(), default_backend())
if not isJavaV1:
digest.update(entity_iv +
... | [
"def",
"_generate_property_iv",
"(",
"entity_iv",
",",
"pk",
",",
"rk",
",",
"property_name",
",",
"isJavaV1",
")",
":",
"digest",
"=",
"Hash",
"(",
"SHA256",
"(",
")",
",",
"default_backend",
"(",
")",
")",
"if",
"not",
"isJavaV1",
":",
"digest",
".",
... | Uses the entity_iv, partition key, and row key to generate and return
the iv for the specified property. | [
"Uses",
"the",
"entity_iv",
"partition",
"key",
"and",
"row",
"key",
"to",
"generate",
"and",
"return",
"the",
"iv",
"for",
"the",
"specified",
"property",
"."
] | a7b618f6bddc465c9fdf899ea2971dfe4d04fcf0 | https://github.com/Azure/azure-cosmos-table-python/blob/a7b618f6bddc465c9fdf899ea2971dfe4d04fcf0/azure-cosmosdb-table/azure/cosmosdb/table/_encryption.py#L287-L300 |
7,552 | fuhrysteve/marshmallow-jsonschema | marshmallow_jsonschema/base.py | JSONSchema._get_default_mapping | def _get_default_mapping(self, obj):
"""Return default mapping if there are no special needs."""
mapping = {v: k for k, v in obj.TYPE_MAPPING.items()}
mapping.update({
fields.Email: text_type,
fields.Dict: dict,
fields.Url: text_type,
fields.List: ... | python | def _get_default_mapping(self, obj):
"""Return default mapping if there are no special needs."""
mapping = {v: k for k, v in obj.TYPE_MAPPING.items()}
mapping.update({
fields.Email: text_type,
fields.Dict: dict,
fields.Url: text_type,
fields.List: ... | [
"def",
"_get_default_mapping",
"(",
"self",
",",
"obj",
")",
":",
"mapping",
"=",
"{",
"v",
":",
"k",
"for",
"k",
",",
"v",
"in",
"obj",
".",
"TYPE_MAPPING",
".",
"items",
"(",
")",
"}",
"mapping",
".",
"update",
"(",
"{",
"fields",
".",
"Email",
... | Return default mapping if there are no special needs. | [
"Return",
"default",
"mapping",
"if",
"there",
"are",
"no",
"special",
"needs",
"."
] | 3e0891a79d586c49deb75188d9ee1728597d093b | https://github.com/fuhrysteve/marshmallow-jsonschema/blob/3e0891a79d586c49deb75188d9ee1728597d093b/marshmallow_jsonschema/base.py#L96-L107 |
7,553 | fuhrysteve/marshmallow-jsonschema | marshmallow_jsonschema/base.py | JSONSchema.get_properties | def get_properties(self, obj):
"""Fill out properties field."""
properties = {}
for field_name, field in sorted(obj.fields.items()):
schema = self._get_schema_for_field(obj, field)
properties[field.name] = schema
return properties | python | def get_properties(self, obj):
"""Fill out properties field."""
properties = {}
for field_name, field in sorted(obj.fields.items()):
schema = self._get_schema_for_field(obj, field)
properties[field.name] = schema
return properties | [
"def",
"get_properties",
"(",
"self",
",",
"obj",
")",
":",
"properties",
"=",
"{",
"}",
"for",
"field_name",
",",
"field",
"in",
"sorted",
"(",
"obj",
".",
"fields",
".",
"items",
"(",
")",
")",
":",
"schema",
"=",
"self",
".",
"_get_schema_for_field"... | Fill out properties field. | [
"Fill",
"out",
"properties",
"field",
"."
] | 3e0891a79d586c49deb75188d9ee1728597d093b | https://github.com/fuhrysteve/marshmallow-jsonschema/blob/3e0891a79d586c49deb75188d9ee1728597d093b/marshmallow_jsonschema/base.py#L109-L117 |
7,554 | fuhrysteve/marshmallow-jsonschema | marshmallow_jsonschema/base.py | JSONSchema.get_required | def get_required(self, obj):
"""Fill out required field."""
required = []
for field_name, field in sorted(obj.fields.items()):
if field.required:
required.append(field.name)
return required or missing | python | def get_required(self, obj):
"""Fill out required field."""
required = []
for field_name, field in sorted(obj.fields.items()):
if field.required:
required.append(field.name)
return required or missing | [
"def",
"get_required",
"(",
"self",
",",
"obj",
")",
":",
"required",
"=",
"[",
"]",
"for",
"field_name",
",",
"field",
"in",
"sorted",
"(",
"obj",
".",
"fields",
".",
"items",
"(",
")",
")",
":",
"if",
"field",
".",
"required",
":",
"required",
".... | Fill out required field. | [
"Fill",
"out",
"required",
"field",
"."
] | 3e0891a79d586c49deb75188d9ee1728597d093b | https://github.com/fuhrysteve/marshmallow-jsonschema/blob/3e0891a79d586c49deb75188d9ee1728597d093b/marshmallow_jsonschema/base.py#L119-L127 |
7,555 | fuhrysteve/marshmallow-jsonschema | marshmallow_jsonschema/base.py | JSONSchema._from_python_type | def _from_python_type(self, obj, field, pytype):
"""Get schema definition from python type."""
json_schema = {
'title': field.attribute or field.name,
}
for key, val in TYPE_MAP[pytype].items():
json_schema[key] = val
if field.dump_only:
json... | python | def _from_python_type(self, obj, field, pytype):
"""Get schema definition from python type."""
json_schema = {
'title': field.attribute or field.name,
}
for key, val in TYPE_MAP[pytype].items():
json_schema[key] = val
if field.dump_only:
json... | [
"def",
"_from_python_type",
"(",
"self",
",",
"obj",
",",
"field",
",",
"pytype",
")",
":",
"json_schema",
"=",
"{",
"'title'",
":",
"field",
".",
"attribute",
"or",
"field",
".",
"name",
",",
"}",
"for",
"key",
",",
"val",
"in",
"TYPE_MAP",
"[",
"py... | Get schema definition from python type. | [
"Get",
"schema",
"definition",
"from",
"python",
"type",
"."
] | 3e0891a79d586c49deb75188d9ee1728597d093b | https://github.com/fuhrysteve/marshmallow-jsonschema/blob/3e0891a79d586c49deb75188d9ee1728597d093b/marshmallow_jsonschema/base.py#L129-L157 |
7,556 | fuhrysteve/marshmallow-jsonschema | marshmallow_jsonschema/base.py | JSONSchema._get_schema_for_field | def _get_schema_for_field(self, obj, field):
"""Get schema and validators for field."""
mapping = self._get_default_mapping(obj)
if hasattr(field, '_jsonschema_type_mapping'):
schema = field._jsonschema_type_mapping()
elif '_jsonschema_type_mapping' in field.metadata:
... | python | def _get_schema_for_field(self, obj, field):
"""Get schema and validators for field."""
mapping = self._get_default_mapping(obj)
if hasattr(field, '_jsonschema_type_mapping'):
schema = field._jsonschema_type_mapping()
elif '_jsonschema_type_mapping' in field.metadata:
... | [
"def",
"_get_schema_for_field",
"(",
"self",
",",
"obj",
",",
"field",
")",
":",
"mapping",
"=",
"self",
".",
"_get_default_mapping",
"(",
"obj",
")",
"if",
"hasattr",
"(",
"field",
",",
"'_jsonschema_type_mapping'",
")",
":",
"schema",
"=",
"field",
".",
... | Get schema and validators for field. | [
"Get",
"schema",
"and",
"validators",
"for",
"field",
"."
] | 3e0891a79d586c49deb75188d9ee1728597d093b | https://github.com/fuhrysteve/marshmallow-jsonschema/blob/3e0891a79d586c49deb75188d9ee1728597d093b/marshmallow_jsonschema/base.py#L159-L183 |
7,557 | fuhrysteve/marshmallow-jsonschema | marshmallow_jsonschema/base.py | JSONSchema._from_nested_schema | def _from_nested_schema(self, obj, field):
"""Support nested field."""
if isinstance(field.nested, basestring):
nested = get_class(field.nested)
else:
nested = field.nested
name = nested.__name__
outer_name = obj.__class__.__name__
only = field.on... | python | def _from_nested_schema(self, obj, field):
"""Support nested field."""
if isinstance(field.nested, basestring):
nested = get_class(field.nested)
else:
nested = field.nested
name = nested.__name__
outer_name = obj.__class__.__name__
only = field.on... | [
"def",
"_from_nested_schema",
"(",
"self",
",",
"obj",
",",
"field",
")",
":",
"if",
"isinstance",
"(",
"field",
".",
"nested",
",",
"basestring",
")",
":",
"nested",
"=",
"get_class",
"(",
"field",
".",
"nested",
")",
"else",
":",
"nested",
"=",
"fiel... | Support nested field. | [
"Support",
"nested",
"field",
"."
] | 3e0891a79d586c49deb75188d9ee1728597d093b | https://github.com/fuhrysteve/marshmallow-jsonschema/blob/3e0891a79d586c49deb75188d9ee1728597d093b/marshmallow_jsonschema/base.py#L185-L236 |
7,558 | fuhrysteve/marshmallow-jsonschema | marshmallow_jsonschema/base.py | JSONSchema.wrap | def wrap(self, data):
"""Wrap this with the root schema definitions."""
if self.nested: # no need to wrap, will be in outer defs
return data
name = self.obj.__class__.__name__
self._nested_schema_classes[name] = data
root = {
'definitions': self._nested_... | python | def wrap(self, data):
"""Wrap this with the root schema definitions."""
if self.nested: # no need to wrap, will be in outer defs
return data
name = self.obj.__class__.__name__
self._nested_schema_classes[name] = data
root = {
'definitions': self._nested_... | [
"def",
"wrap",
"(",
"self",
",",
"data",
")",
":",
"if",
"self",
".",
"nested",
":",
"# no need to wrap, will be in outer defs",
"return",
"data",
"name",
"=",
"self",
".",
"obj",
".",
"__class__",
".",
"__name__",
"self",
".",
"_nested_schema_classes",
"[",
... | Wrap this with the root schema definitions. | [
"Wrap",
"this",
"with",
"the",
"root",
"schema",
"definitions",
"."
] | 3e0891a79d586c49deb75188d9ee1728597d093b | https://github.com/fuhrysteve/marshmallow-jsonschema/blob/3e0891a79d586c49deb75188d9ee1728597d093b/marshmallow_jsonschema/base.py#L244-L255 |
7,559 | fuhrysteve/marshmallow-jsonschema | marshmallow_jsonschema/validation.py | handle_length | def handle_length(schema, field, validator, parent_schema):
"""Adds validation logic for ``marshmallow.validate.Length``, setting the
values appropriately for ``fields.List``, ``fields.Nested``, and
``fields.String``.
Args:
schema (dict): The original JSON schema we generated. This is what we
... | python | def handle_length(schema, field, validator, parent_schema):
"""Adds validation logic for ``marshmallow.validate.Length``, setting the
values appropriately for ``fields.List``, ``fields.Nested``, and
``fields.String``.
Args:
schema (dict): The original JSON schema we generated. This is what we
... | [
"def",
"handle_length",
"(",
"schema",
",",
"field",
",",
"validator",
",",
"parent_schema",
")",
":",
"if",
"isinstance",
"(",
"field",
",",
"fields",
".",
"String",
")",
":",
"minKey",
"=",
"'minLength'",
"maxKey",
"=",
"'maxLength'",
"elif",
"isinstance",... | Adds validation logic for ``marshmallow.validate.Length``, setting the
values appropriately for ``fields.List``, ``fields.Nested``, and
``fields.String``.
Args:
schema (dict): The original JSON schema we generated. This is what we
want to post-process.
field (fields.Field): The ... | [
"Adds",
"validation",
"logic",
"for",
"marshmallow",
".",
"validate",
".",
"Length",
"setting",
"the",
"values",
"appropriately",
"for",
"fields",
".",
"List",
"fields",
".",
"Nested",
"and",
"fields",
".",
"String",
"."
] | 3e0891a79d586c49deb75188d9ee1728597d093b | https://github.com/fuhrysteve/marshmallow-jsonschema/blob/3e0891a79d586c49deb75188d9ee1728597d093b/marshmallow_jsonschema/validation.py#L4-L47 |
7,560 | fuhrysteve/marshmallow-jsonschema | marshmallow_jsonschema/validation.py | handle_one_of | def handle_one_of(schema, field, validator, parent_schema):
"""Adds the validation logic for ``marshmallow.validate.OneOf`` by setting
the JSONSchema `enum` property to the allowed choices in the validator.
Args:
schema (dict): The original JSON schema we generated. This is what we
want... | python | def handle_one_of(schema, field, validator, parent_schema):
"""Adds the validation logic for ``marshmallow.validate.OneOf`` by setting
the JSONSchema `enum` property to the allowed choices in the validator.
Args:
schema (dict): The original JSON schema we generated. This is what we
want... | [
"def",
"handle_one_of",
"(",
"schema",
",",
"field",
",",
"validator",
",",
"parent_schema",
")",
":",
"if",
"validator",
".",
"choices",
":",
"schema",
"[",
"'enum'",
"]",
"=",
"list",
"(",
"validator",
".",
"choices",
")",
"schema",
"[",
"'enumNames'",
... | Adds the validation logic for ``marshmallow.validate.OneOf`` by setting
the JSONSchema `enum` property to the allowed choices in the validator.
Args:
schema (dict): The original JSON schema we generated. This is what we
want to post-process.
field (fields.Field): The field that gene... | [
"Adds",
"the",
"validation",
"logic",
"for",
"marshmallow",
".",
"validate",
".",
"OneOf",
"by",
"setting",
"the",
"JSONSchema",
"enum",
"property",
"to",
"the",
"allowed",
"choices",
"in",
"the",
"validator",
"."
] | 3e0891a79d586c49deb75188d9ee1728597d093b | https://github.com/fuhrysteve/marshmallow-jsonschema/blob/3e0891a79d586c49deb75188d9ee1728597d093b/marshmallow_jsonschema/validation.py#L50-L72 |
7,561 | fuhrysteve/marshmallow-jsonschema | marshmallow_jsonschema/validation.py | handle_range | def handle_range(schema, field, validator, parent_schema):
"""Adds validation logic for ``marshmallow.validate.Range``, setting the
values appropriately ``fields.Number`` and it's subclasses.
Args:
schema (dict): The original JSON schema we generated. This is what we
want to post-proces... | python | def handle_range(schema, field, validator, parent_schema):
"""Adds validation logic for ``marshmallow.validate.Range``, setting the
values appropriately ``fields.Number`` and it's subclasses.
Args:
schema (dict): The original JSON schema we generated. This is what we
want to post-proces... | [
"def",
"handle_range",
"(",
"schema",
",",
"field",
",",
"validator",
",",
"parent_schema",
")",
":",
"if",
"not",
"isinstance",
"(",
"field",
",",
"fields",
".",
"Number",
")",
":",
"return",
"schema",
"if",
"validator",
".",
"min",
":",
"schema",
"[",
... | Adds validation logic for ``marshmallow.validate.Range``, setting the
values appropriately ``fields.Number`` and it's subclasses.
Args:
schema (dict): The original JSON schema we generated. This is what we
want to post-process.
field (fields.Field): The field that generated the orig... | [
"Adds",
"validation",
"logic",
"for",
"marshmallow",
".",
"validate",
".",
"Range",
"setting",
"the",
"values",
"appropriately",
"fields",
".",
"Number",
"and",
"it",
"s",
"subclasses",
"."
] | 3e0891a79d586c49deb75188d9ee1728597d093b | https://github.com/fuhrysteve/marshmallow-jsonschema/blob/3e0891a79d586c49deb75188d9ee1728597d093b/marshmallow_jsonschema/validation.py#L75-L107 |
7,562 | mmp2/megaman | megaman/utils/eigendecomp.py | check_eigen_solver | def check_eigen_solver(eigen_solver, solver_kwds, size=None, nvec=None):
"""Check that the selected eigensolver is valid
Parameters
----------
eigen_solver : string
string value to validate
size, nvec : int (optional)
if both provided, use the specified problem size and number of ve... | python | def check_eigen_solver(eigen_solver, solver_kwds, size=None, nvec=None):
"""Check that the selected eigensolver is valid
Parameters
----------
eigen_solver : string
string value to validate
size, nvec : int (optional)
if both provided, use the specified problem size and number of ve... | [
"def",
"check_eigen_solver",
"(",
"eigen_solver",
",",
"solver_kwds",
",",
"size",
"=",
"None",
",",
"nvec",
"=",
"None",
")",
":",
"if",
"eigen_solver",
"in",
"BAD_EIGEN_SOLVERS",
":",
"raise",
"ValueError",
"(",
"BAD_EIGEN_SOLVERS",
"[",
"eigen_solver",
"]",
... | Check that the selected eigensolver is valid
Parameters
----------
eigen_solver : string
string value to validate
size, nvec : int (optional)
if both provided, use the specified problem size and number of vectors
to determine the optimal method to use with eigen_solver='auto'
... | [
"Check",
"that",
"the",
"selected",
"eigensolver",
"is",
"valid"
] | faccaf267aad0a8b18ec8a705735fd9dd838ca1e | https://github.com/mmp2/megaman/blob/faccaf267aad0a8b18ec8a705735fd9dd838ca1e/megaman/utils/eigendecomp.py#L28-L72 |
7,563 | mmp2/megaman | megaman/relaxation/precomputed.py | precompute_optimzation_Y | def precompute_optimzation_Y(laplacian_matrix, n_samples, relaxation_kwds):
"""compute Lk, neighbors and subset to index map for projected == False"""
relaxation_kwds.setdefault('presave',False)
relaxation_kwds.setdefault('presave_name','pre_comp_current.npy')
relaxation_kwds.setdefault('verbose',False)... | python | def precompute_optimzation_Y(laplacian_matrix, n_samples, relaxation_kwds):
"""compute Lk, neighbors and subset to index map for projected == False"""
relaxation_kwds.setdefault('presave',False)
relaxation_kwds.setdefault('presave_name','pre_comp_current.npy')
relaxation_kwds.setdefault('verbose',False)... | [
"def",
"precompute_optimzation_Y",
"(",
"laplacian_matrix",
",",
"n_samples",
",",
"relaxation_kwds",
")",
":",
"relaxation_kwds",
".",
"setdefault",
"(",
"'presave'",
",",
"False",
")",
"relaxation_kwds",
".",
"setdefault",
"(",
"'presave_name'",
",",
"'pre_comp_curr... | compute Lk, neighbors and subset to index map for projected == False | [
"compute",
"Lk",
"neighbors",
"and",
"subset",
"to",
"index",
"map",
"for",
"projected",
"==",
"False"
] | faccaf267aad0a8b18ec8a705735fd9dd838ca1e | https://github.com/mmp2/megaman/blob/faccaf267aad0a8b18ec8a705735fd9dd838ca1e/megaman/relaxation/precomputed.py#L8-L19 |
7,564 | mmp2/megaman | megaman/relaxation/precomputed.py | compute_Lk | def compute_Lk(laplacian_matrix,n_samples,subset):
"""
Compute sparse L matrix, neighbors and subset to L matrix index map.
Returns
-------
Lk_tensor : array-like. Length = n
each component correspond to the sparse matrix of Lk, which is
generated by extracting the kth row of laplac... | python | def compute_Lk(laplacian_matrix,n_samples,subset):
"""
Compute sparse L matrix, neighbors and subset to L matrix index map.
Returns
-------
Lk_tensor : array-like. Length = n
each component correspond to the sparse matrix of Lk, which is
generated by extracting the kth row of laplac... | [
"def",
"compute_Lk",
"(",
"laplacian_matrix",
",",
"n_samples",
",",
"subset",
")",
":",
"Lk_tensor",
"=",
"[",
"]",
"nbk",
"=",
"[",
"]",
"row",
",",
"column",
"=",
"laplacian_matrix",
".",
"T",
".",
"nonzero",
"(",
")",
"nnz_val",
"=",
"np",
".",
"... | Compute sparse L matrix, neighbors and subset to L matrix index map.
Returns
-------
Lk_tensor : array-like. Length = n
each component correspond to the sparse matrix of Lk, which is
generated by extracting the kth row of laplacian and removing zeros.
nbk : array-like. Length = n
... | [
"Compute",
"sparse",
"L",
"matrix",
"neighbors",
"and",
"subset",
"to",
"L",
"matrix",
"index",
"map",
"."
] | faccaf267aad0a8b18ec8a705735fd9dd838ca1e | https://github.com/mmp2/megaman/blob/faccaf267aad0a8b18ec8a705735fd9dd838ca1e/megaman/relaxation/precomputed.py#L21-L71 |
7,565 | mmp2/megaman | megaman/relaxation/precomputed.py | precompute_optimzation_S | def precompute_optimzation_S(laplacian_matrix,n_samples,relaxation_kwds):
"""compute Rk, A, ATAinv, neighbors and pairs for projected mode"""
relaxation_kwds.setdefault('presave',False)
relaxation_kwds.setdefault('presave_name','pre_comp_current.npy')
relaxation_kwds.setdefault('verbose',False)
if r... | python | def precompute_optimzation_S(laplacian_matrix,n_samples,relaxation_kwds):
"""compute Rk, A, ATAinv, neighbors and pairs for projected mode"""
relaxation_kwds.setdefault('presave',False)
relaxation_kwds.setdefault('presave_name','pre_comp_current.npy')
relaxation_kwds.setdefault('verbose',False)
if r... | [
"def",
"precompute_optimzation_S",
"(",
"laplacian_matrix",
",",
"n_samples",
",",
"relaxation_kwds",
")",
":",
"relaxation_kwds",
".",
"setdefault",
"(",
"'presave'",
",",
"False",
")",
"relaxation_kwds",
".",
"setdefault",
"(",
"'presave_name'",
",",
"'pre_comp_curr... | compute Rk, A, ATAinv, neighbors and pairs for projected mode | [
"compute",
"Rk",
"A",
"ATAinv",
"neighbors",
"and",
"pairs",
"for",
"projected",
"mode"
] | faccaf267aad0a8b18ec8a705735fd9dd838ca1e | https://github.com/mmp2/megaman/blob/faccaf267aad0a8b18ec8a705735fd9dd838ca1e/megaman/relaxation/precomputed.py#L73-L92 |
7,566 | mmp2/megaman | megaman/relaxation/precomputed.py | compute_Rk | def compute_Rk(L,A,n_samples):
# TODO: need to inspect more into compute Rk.
"""
Compute sparse L matrix and neighbors.
Returns
-------
Rk_tensor : array-like. Length = n
each component correspond to the sparse matrix of Lk, which is
generated by extracting the kth row of laplac... | python | def compute_Rk(L,A,n_samples):
# TODO: need to inspect more into compute Rk.
"""
Compute sparse L matrix and neighbors.
Returns
-------
Rk_tensor : array-like. Length = n
each component correspond to the sparse matrix of Lk, which is
generated by extracting the kth row of laplac... | [
"def",
"compute_Rk",
"(",
"L",
",",
"A",
",",
"n_samples",
")",
":",
"# TODO: need to inspect more into compute Rk.",
"laplacian_matrix",
"=",
"L",
".",
"copy",
"(",
")",
"laplacian_matrix",
".",
"setdiag",
"(",
"0",
")",
"laplacian_matrix",
".",
"eliminate_zeros"... | Compute sparse L matrix and neighbors.
Returns
-------
Rk_tensor : array-like. Length = n
each component correspond to the sparse matrix of Lk, which is
generated by extracting the kth row of laplacian and removing zeros.
nbk : array-like. Length = n
each component correspond to... | [
"Compute",
"sparse",
"L",
"matrix",
"and",
"neighbors",
"."
] | faccaf267aad0a8b18ec8a705735fd9dd838ca1e | https://github.com/mmp2/megaman/blob/faccaf267aad0a8b18ec8a705735fd9dd838ca1e/megaman/relaxation/precomputed.py#L116-L161 |
7,567 | mmp2/megaman | doc/sphinxext/numpy_ext/automodapi.py | _mod_info | def _mod_info(modname, toskip=[], onlylocals=True):
"""
Determines if a module is a module or a package and whether or not
it has classes or functions.
"""
hascls = hasfunc = False
for localnm, fqnm, obj in zip(*find_mod_objs(modname, onlylocals=onlylocals)):
if localnm not in toskip:
... | python | def _mod_info(modname, toskip=[], onlylocals=True):
"""
Determines if a module is a module or a package and whether or not
it has classes or functions.
"""
hascls = hasfunc = False
for localnm, fqnm, obj in zip(*find_mod_objs(modname, onlylocals=onlylocals)):
if localnm not in toskip:
... | [
"def",
"_mod_info",
"(",
"modname",
",",
"toskip",
"=",
"[",
"]",
",",
"onlylocals",
"=",
"True",
")",
":",
"hascls",
"=",
"hasfunc",
"=",
"False",
"for",
"localnm",
",",
"fqnm",
",",
"obj",
"in",
"zip",
"(",
"*",
"find_mod_objs",
"(",
"modname",
","... | Determines if a module is a module or a package and whether or not
it has classes or functions. | [
"Determines",
"if",
"a",
"module",
"is",
"a",
"module",
"or",
"a",
"package",
"and",
"whether",
"or",
"not",
"it",
"has",
"classes",
"or",
"functions",
"."
] | faccaf267aad0a8b18ec8a705735fd9dd838ca1e | https://github.com/mmp2/megaman/blob/faccaf267aad0a8b18ec8a705735fd9dd838ca1e/doc/sphinxext/numpy_ext/automodapi.py#L328-L350 |
7,568 | mmp2/megaman | megaman/geometry/affinity.py | compute_affinity_matrix | def compute_affinity_matrix(adjacency_matrix, method='auto', **kwargs):
"""Compute the affinity matrix with the given method"""
if method == 'auto':
method = 'gaussian'
return Affinity.init(method, **kwargs).affinity_matrix(adjacency_matrix) | python | def compute_affinity_matrix(adjacency_matrix, method='auto', **kwargs):
"""Compute the affinity matrix with the given method"""
if method == 'auto':
method = 'gaussian'
return Affinity.init(method, **kwargs).affinity_matrix(adjacency_matrix) | [
"def",
"compute_affinity_matrix",
"(",
"adjacency_matrix",
",",
"method",
"=",
"'auto'",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"method",
"==",
"'auto'",
":",
"method",
"=",
"'gaussian'",
"return",
"Affinity",
".",
"init",
"(",
"method",
",",
"*",
"*",
... | Compute the affinity matrix with the given method | [
"Compute",
"the",
"affinity",
"matrix",
"with",
"the",
"given",
"method"
] | faccaf267aad0a8b18ec8a705735fd9dd838ca1e | https://github.com/mmp2/megaman/blob/faccaf267aad0a8b18ec8a705735fd9dd838ca1e/megaman/geometry/affinity.py#L11-L15 |
7,569 | mmp2/megaman | megaman/embedding/locally_linear.py | barycenter_graph | def barycenter_graph(distance_matrix, X, reg=1e-3):
"""
Computes the barycenter weighted graph for points in X
Parameters
----------
distance_matrix: sparse Ndarray, (N_obs, N_obs) pairwise distance matrix.
X : Ndarray (N_obs, N_dim) observed data matrix.
reg : float, optional
Amoun... | python | def barycenter_graph(distance_matrix, X, reg=1e-3):
"""
Computes the barycenter weighted graph for points in X
Parameters
----------
distance_matrix: sparse Ndarray, (N_obs, N_obs) pairwise distance matrix.
X : Ndarray (N_obs, N_dim) observed data matrix.
reg : float, optional
Amoun... | [
"def",
"barycenter_graph",
"(",
"distance_matrix",
",",
"X",
",",
"reg",
"=",
"1e-3",
")",
":",
"(",
"N",
",",
"d_in",
")",
"=",
"X",
".",
"shape",
"(",
"rows",
",",
"cols",
")",
"=",
"distance_matrix",
".",
"nonzero",
"(",
")",
"W",
"=",
"sparse",... | Computes the barycenter weighted graph for points in X
Parameters
----------
distance_matrix: sparse Ndarray, (N_obs, N_obs) pairwise distance matrix.
X : Ndarray (N_obs, N_dim) observed data matrix.
reg : float, optional
Amount of regularization when solving the least-squares
probl... | [
"Computes",
"the",
"barycenter",
"weighted",
"graph",
"for",
"points",
"in",
"X"
] | faccaf267aad0a8b18ec8a705735fd9dd838ca1e | https://github.com/mmp2/megaman/blob/faccaf267aad0a8b18ec8a705735fd9dd838ca1e/megaman/embedding/locally_linear.py#L22-L57 |
7,570 | mmp2/megaman | megaman/embedding/locally_linear.py | locally_linear_embedding | def locally_linear_embedding(geom, n_components, reg=1e-3,
eigen_solver='auto', random_state=None,
solver_kwds=None):
"""
Perform a Locally Linear Embedding analysis on the data.
Parameters
----------
geom : a Geometry object from megaman.geo... | python | def locally_linear_embedding(geom, n_components, reg=1e-3,
eigen_solver='auto', random_state=None,
solver_kwds=None):
"""
Perform a Locally Linear Embedding analysis on the data.
Parameters
----------
geom : a Geometry object from megaman.geo... | [
"def",
"locally_linear_embedding",
"(",
"geom",
",",
"n_components",
",",
"reg",
"=",
"1e-3",
",",
"eigen_solver",
"=",
"'auto'",
",",
"random_state",
"=",
"None",
",",
"solver_kwds",
"=",
"None",
")",
":",
"if",
"geom",
".",
"X",
"is",
"None",
":",
"rai... | Perform a Locally Linear Embedding analysis on the data.
Parameters
----------
geom : a Geometry object from megaman.geometry.geometry
n_components : integer
number of coordinates for the manifold.
reg : float
regularization constant, multiplies the trace of the local covariance
... | [
"Perform",
"a",
"Locally",
"Linear",
"Embedding",
"analysis",
"on",
"the",
"data",
"."
] | faccaf267aad0a8b18ec8a705735fd9dd838ca1e | https://github.com/mmp2/megaman/blob/faccaf267aad0a8b18ec8a705735fd9dd838ca1e/megaman/embedding/locally_linear.py#L60-L128 |
7,571 | mmp2/megaman | megaman/utils/validation.py | _num_samples | def _num_samples(x):
"""Return number of samples in array-like x."""
if hasattr(x, 'fit'):
# Don't get num_samples from an ensembles length!
raise TypeError('Expected sequence or array-like, got '
'estimator %s' % x)
if not hasattr(x, '__len__') and not hasattr(x, 'sh... | python | def _num_samples(x):
"""Return number of samples in array-like x."""
if hasattr(x, 'fit'):
# Don't get num_samples from an ensembles length!
raise TypeError('Expected sequence or array-like, got '
'estimator %s' % x)
if not hasattr(x, '__len__') and not hasattr(x, 'sh... | [
"def",
"_num_samples",
"(",
"x",
")",
":",
"if",
"hasattr",
"(",
"x",
",",
"'fit'",
")",
":",
"# Don't get num_samples from an ensembles length!",
"raise",
"TypeError",
"(",
"'Expected sequence or array-like, got '",
"'estimator %s'",
"%",
"x",
")",
"if",
"not",
"ha... | Return number of samples in array-like x. | [
"Return",
"number",
"of",
"samples",
"in",
"array",
"-",
"like",
"x",
"."
] | faccaf267aad0a8b18ec8a705735fd9dd838ca1e | https://github.com/mmp2/megaman/blob/faccaf267aad0a8b18ec8a705735fd9dd838ca1e/megaman/utils/validation.py#L68-L86 |
7,572 | mmp2/megaman | megaman/utils/spectral_clustering.py | spectral_clustering | def spectral_clustering(geom, K, eigen_solver = 'dense', random_state = None, solver_kwds = None,
renormalize = True, stabalize = True, additional_vectors = 0):
"""
Spectral clustering for find K clusters by using the eigenvectors of a
matrix which is derived from a set of similari... | python | def spectral_clustering(geom, K, eigen_solver = 'dense', random_state = None, solver_kwds = None,
renormalize = True, stabalize = True, additional_vectors = 0):
"""
Spectral clustering for find K clusters by using the eigenvectors of a
matrix which is derived from a set of similari... | [
"def",
"spectral_clustering",
"(",
"geom",
",",
"K",
",",
"eigen_solver",
"=",
"'dense'",
",",
"random_state",
"=",
"None",
",",
"solver_kwds",
"=",
"None",
",",
"renormalize",
"=",
"True",
",",
"stabalize",
"=",
"True",
",",
"additional_vectors",
"=",
"0",
... | Spectral clustering for find K clusters by using the eigenvectors of a
matrix which is derived from a set of similarities S.
Parameters
-----------
S: array-like,shape(n_sample,n_sample)
similarity matrix
K: integer
number of K clusters
eigen_solver : {'auto', 'dense', 'arpack... | [
"Spectral",
"clustering",
"for",
"find",
"K",
"clusters",
"by",
"using",
"the",
"eigenvectors",
"of",
"a",
"matrix",
"which",
"is",
"derived",
"from",
"a",
"set",
"of",
"similarities",
"S",
"."
] | faccaf267aad0a8b18ec8a705735fd9dd838ca1e | https://github.com/mmp2/megaman/blob/faccaf267aad0a8b18ec8a705735fd9dd838ca1e/megaman/utils/spectral_clustering.py#L94-L193 |
7,573 | mmp2/megaman | megaman/plotter/covar_plotter3.py | pathpatch_2d_to_3d | def pathpatch_2d_to_3d(pathpatch, z = 0, normal = 'z'):
"""
Transforms a 2D Patch to a 3D patch using the given normal vector.
The patch is projected into they XY plane, rotated about the origin
and finally translated by z.
"""
if type(normal) is str: #Translate strings to normal vectors
... | python | def pathpatch_2d_to_3d(pathpatch, z = 0, normal = 'z'):
"""
Transforms a 2D Patch to a 3D patch using the given normal vector.
The patch is projected into they XY plane, rotated about the origin
and finally translated by z.
"""
if type(normal) is str: #Translate strings to normal vectors
... | [
"def",
"pathpatch_2d_to_3d",
"(",
"pathpatch",
",",
"z",
"=",
"0",
",",
"normal",
"=",
"'z'",
")",
":",
"if",
"type",
"(",
"normal",
")",
"is",
"str",
":",
"#Translate strings to normal vectors",
"index",
"=",
"\"xyz\"",
".",
"index",
"(",
"normal",
")",
... | Transforms a 2D Patch to a 3D patch using the given normal vector.
The patch is projected into they XY plane, rotated about the origin
and finally translated by z. | [
"Transforms",
"a",
"2D",
"Patch",
"to",
"a",
"3D",
"patch",
"using",
"the",
"given",
"normal",
"vector",
"."
] | faccaf267aad0a8b18ec8a705735fd9dd838ca1e | https://github.com/mmp2/megaman/blob/faccaf267aad0a8b18ec8a705735fd9dd838ca1e/megaman/plotter/covar_plotter3.py#L44-L73 |
7,574 | mmp2/megaman | megaman/plotter/covar_plotter3.py | calc_2d_ellipse_properties | def calc_2d_ellipse_properties(cov,nstd=2):
"""Calculate the properties for 2d ellipse given the covariance matrix."""
def eigsorted(cov):
vals, vecs = np.linalg.eigh(cov)
order = vals.argsort()[::-1]
return vals[order], vecs[:,order]
vals, vecs = eigsorted(cov)
width, height = ... | python | def calc_2d_ellipse_properties(cov,nstd=2):
"""Calculate the properties for 2d ellipse given the covariance matrix."""
def eigsorted(cov):
vals, vecs = np.linalg.eigh(cov)
order = vals.argsort()[::-1]
return vals[order], vecs[:,order]
vals, vecs = eigsorted(cov)
width, height = ... | [
"def",
"calc_2d_ellipse_properties",
"(",
"cov",
",",
"nstd",
"=",
"2",
")",
":",
"def",
"eigsorted",
"(",
"cov",
")",
":",
"vals",
",",
"vecs",
"=",
"np",
".",
"linalg",
".",
"eigh",
"(",
"cov",
")",
"order",
"=",
"vals",
".",
"argsort",
"(",
")",... | Calculate the properties for 2d ellipse given the covariance matrix. | [
"Calculate",
"the",
"properties",
"for",
"2d",
"ellipse",
"given",
"the",
"covariance",
"matrix",
"."
] | faccaf267aad0a8b18ec8a705735fd9dd838ca1e | https://github.com/mmp2/megaman/blob/faccaf267aad0a8b18ec8a705735fd9dd838ca1e/megaman/plotter/covar_plotter3.py#L101-L116 |
7,575 | mmp2/megaman | megaman/plotter/covar_plotter3.py | rotation_matrix | def rotation_matrix(d):
"""
Calculates a rotation matrix given a vector d. The direction of d
corresponds to the rotation axis. The length of d corresponds to
the sin of the angle of rotation.
Variant of: http://mail.scipy.org/pipermail/numpy-discussion/2009-March/040806.html
"""
sin_angle ... | python | def rotation_matrix(d):
"""
Calculates a rotation matrix given a vector d. The direction of d
corresponds to the rotation axis. The length of d corresponds to
the sin of the angle of rotation.
Variant of: http://mail.scipy.org/pipermail/numpy-discussion/2009-March/040806.html
"""
sin_angle ... | [
"def",
"rotation_matrix",
"(",
"d",
")",
":",
"sin_angle",
"=",
"np",
".",
"linalg",
".",
"norm",
"(",
"d",
")",
"if",
"sin_angle",
"==",
"0",
":",
"return",
"np",
".",
"identity",
"(",
"3",
")",
"d",
"/=",
"sin_angle",
"eye",
"=",
"np",
".",
"ey... | Calculates a rotation matrix given a vector d. The direction of d
corresponds to the rotation axis. The length of d corresponds to
the sin of the angle of rotation.
Variant of: http://mail.scipy.org/pipermail/numpy-discussion/2009-March/040806.html | [
"Calculates",
"a",
"rotation",
"matrix",
"given",
"a",
"vector",
"d",
".",
"The",
"direction",
"of",
"d",
"corresponds",
"to",
"the",
"rotation",
"axis",
".",
"The",
"length",
"of",
"d",
"corresponds",
"to",
"the",
"sin",
"of",
"the",
"angle",
"of",
"rot... | faccaf267aad0a8b18ec8a705735fd9dd838ca1e | https://github.com/mmp2/megaman/blob/faccaf267aad0a8b18ec8a705735fd9dd838ca1e/megaman/plotter/covar_plotter3.py#L118-L140 |
7,576 | mmp2/megaman | megaman/plotter/covar_plotter3.py | create_ellipse | def create_ellipse(width,height,angle):
"""Create parametric ellipse from 200 points."""
angle = angle / 180.0 * np.pi
thetas = np.linspace(0,2*np.pi,200)
a = width / 2.0
b = height / 2.0
x = a*np.cos(thetas)*np.cos(angle) - b*np.sin(thetas)*np.sin(angle)
y = a*np.cos(thetas)*np.sin(angle) ... | python | def create_ellipse(width,height,angle):
"""Create parametric ellipse from 200 points."""
angle = angle / 180.0 * np.pi
thetas = np.linspace(0,2*np.pi,200)
a = width / 2.0
b = height / 2.0
x = a*np.cos(thetas)*np.cos(angle) - b*np.sin(thetas)*np.sin(angle)
y = a*np.cos(thetas)*np.sin(angle) ... | [
"def",
"create_ellipse",
"(",
"width",
",",
"height",
",",
"angle",
")",
":",
"angle",
"=",
"angle",
"/",
"180.0",
"*",
"np",
".",
"pi",
"thetas",
"=",
"np",
".",
"linspace",
"(",
"0",
",",
"2",
"*",
"np",
".",
"pi",
",",
"200",
")",
"a",
"=",
... | Create parametric ellipse from 200 points. | [
"Create",
"parametric",
"ellipse",
"from",
"200",
"points",
"."
] | faccaf267aad0a8b18ec8a705735fd9dd838ca1e | https://github.com/mmp2/megaman/blob/faccaf267aad0a8b18ec8a705735fd9dd838ca1e/megaman/plotter/covar_plotter3.py#L142-L152 |
7,577 | mmp2/megaman | megaman/plotter/covar_plotter3.py | transform_to_3d | def transform_to_3d(points,normal,z=0):
"""Project points into 3d from 2d points."""
d = np.cross(normal, (0, 0, 1))
M = rotation_matrix(d)
transformed_points = M.dot(points.T).T + z
return transformed_points | python | def transform_to_3d(points,normal,z=0):
"""Project points into 3d from 2d points."""
d = np.cross(normal, (0, 0, 1))
M = rotation_matrix(d)
transformed_points = M.dot(points.T).T + z
return transformed_points | [
"def",
"transform_to_3d",
"(",
"points",
",",
"normal",
",",
"z",
"=",
"0",
")",
":",
"d",
"=",
"np",
".",
"cross",
"(",
"normal",
",",
"(",
"0",
",",
"0",
",",
"1",
")",
")",
"M",
"=",
"rotation_matrix",
"(",
"d",
")",
"transformed_points",
"=",... | Project points into 3d from 2d points. | [
"Project",
"points",
"into",
"3d",
"from",
"2d",
"points",
"."
] | faccaf267aad0a8b18ec8a705735fd9dd838ca1e | https://github.com/mmp2/megaman/blob/faccaf267aad0a8b18ec8a705735fd9dd838ca1e/megaman/plotter/covar_plotter3.py#L154-L159 |
7,578 | mmp2/megaman | megaman/plotter/covar_plotter3.py | create_ellipse_mesh | def create_ellipse_mesh(points,**kwargs):
"""Visualize the ellipse by using the mesh of the points."""
import plotly.graph_objs as go
x,y,z = points.T
return (go.Mesh3d(x=x,y=y,z=z,**kwargs),
go.Scatter3d(x=x, y=y, z=z,
marker=dict(size=0.01),
... | python | def create_ellipse_mesh(points,**kwargs):
"""Visualize the ellipse by using the mesh of the points."""
import plotly.graph_objs as go
x,y,z = points.T
return (go.Mesh3d(x=x,y=y,z=z,**kwargs),
go.Scatter3d(x=x, y=y, z=z,
marker=dict(size=0.01),
... | [
"def",
"create_ellipse_mesh",
"(",
"points",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"plotly",
".",
"graph_objs",
"as",
"go",
"x",
",",
"y",
",",
"z",
"=",
"points",
".",
"T",
"return",
"(",
"go",
".",
"Mesh3d",
"(",
"x",
"=",
"x",
",",
"y",... | Visualize the ellipse by using the mesh of the points. | [
"Visualize",
"the",
"ellipse",
"by",
"using",
"the",
"mesh",
"of",
"the",
"points",
"."
] | faccaf267aad0a8b18ec8a705735fd9dd838ca1e | https://github.com/mmp2/megaman/blob/faccaf267aad0a8b18ec8a705735fd9dd838ca1e/megaman/plotter/covar_plotter3.py#L166-L177 |
7,579 | mmp2/megaman | megaman/embedding/ltsa.py | ltsa | def ltsa(geom, n_components, eigen_solver='auto',
random_state=None, solver_kwds=None):
"""
Perform a Local Tangent Space Alignment analysis on the data.
Parameters
----------
geom : a Geometry object from megaman.geometry.geometry
n_components : integer
number of coordinates f... | python | def ltsa(geom, n_components, eigen_solver='auto',
random_state=None, solver_kwds=None):
"""
Perform a Local Tangent Space Alignment analysis on the data.
Parameters
----------
geom : a Geometry object from megaman.geometry.geometry
n_components : integer
number of coordinates f... | [
"def",
"ltsa",
"(",
"geom",
",",
"n_components",
",",
"eigen_solver",
"=",
"'auto'",
",",
"random_state",
"=",
"None",
",",
"solver_kwds",
"=",
"None",
")",
":",
"if",
"geom",
".",
"X",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"Must pass data matri... | Perform a Local Tangent Space Alignment analysis on the data.
Parameters
----------
geom : a Geometry object from megaman.geometry.geometry
n_components : integer
number of coordinates for the manifold.
eigen_solver : {'auto', 'dense', 'arpack', 'lobpcg', or 'amg'}
'auto' :
... | [
"Perform",
"a",
"Local",
"Tangent",
"Space",
"Alignment",
"analysis",
"on",
"the",
"data",
"."
] | faccaf267aad0a8b18ec8a705735fd9dd838ca1e | https://github.com/mmp2/megaman/blob/faccaf267aad0a8b18ec8a705735fd9dd838ca1e/megaman/embedding/ltsa.py#L24-L111 |
7,580 | mmp2/megaman | megaman/relaxation/riemannian_relaxation.py | run_riemannian_relaxation | def run_riemannian_relaxation(laplacian, initial_guess,
intrinsic_dim, relaxation_kwds):
"""Helper function for creating a RiemannianRelaxation class."""
n, s = initial_guess.shape
relaxation_kwds = initialize_kwds(relaxation_kwds, n, s, intrinsic_dim)
if relaxation_kwds['s... | python | def run_riemannian_relaxation(laplacian, initial_guess,
intrinsic_dim, relaxation_kwds):
"""Helper function for creating a RiemannianRelaxation class."""
n, s = initial_guess.shape
relaxation_kwds = initialize_kwds(relaxation_kwds, n, s, intrinsic_dim)
if relaxation_kwds['s... | [
"def",
"run_riemannian_relaxation",
"(",
"laplacian",
",",
"initial_guess",
",",
"intrinsic_dim",
",",
"relaxation_kwds",
")",
":",
"n",
",",
"s",
"=",
"initial_guess",
".",
"shape",
"relaxation_kwds",
"=",
"initialize_kwds",
"(",
"relaxation_kwds",
",",
"n",
",",... | Helper function for creating a RiemannianRelaxation class. | [
"Helper",
"function",
"for",
"creating",
"a",
"RiemannianRelaxation",
"class",
"."
] | faccaf267aad0a8b18ec8a705735fd9dd838ca1e | https://github.com/mmp2/megaman/blob/faccaf267aad0a8b18ec8a705735fd9dd838ca1e/megaman/relaxation/riemannian_relaxation.py#L19-L32 |
7,581 | mmp2/megaman | megaman/relaxation/riemannian_relaxation.py | RiemannianRelaxation.relax_isometry | def relax_isometry(self):
"""Main function for doing riemannian relaxation."""
for ii in range(self.relaxation_kwds['niter']):
self.H = self.compute_dual_rmetric()
self.loss = self.rieman_loss()
self.trace_var.update(ii,self.H,self.Y,self.eta,self.loss)
s... | python | def relax_isometry(self):
"""Main function for doing riemannian relaxation."""
for ii in range(self.relaxation_kwds['niter']):
self.H = self.compute_dual_rmetric()
self.loss = self.rieman_loss()
self.trace_var.update(ii,self.H,self.Y,self.eta,self.loss)
s... | [
"def",
"relax_isometry",
"(",
"self",
")",
":",
"for",
"ii",
"in",
"range",
"(",
"self",
".",
"relaxation_kwds",
"[",
"'niter'",
"]",
")",
":",
"self",
".",
"H",
"=",
"self",
".",
"compute_dual_rmetric",
"(",
")",
"self",
".",
"loss",
"=",
"self",
".... | Main function for doing riemannian relaxation. | [
"Main",
"function",
"for",
"doing",
"riemannian",
"relaxation",
"."
] | faccaf267aad0a8b18ec8a705735fd9dd838ca1e | https://github.com/mmp2/megaman/blob/faccaf267aad0a8b18ec8a705735fd9dd838ca1e/megaman/relaxation/riemannian_relaxation.py#L77-L96 |
7,582 | mmp2/megaman | megaman/relaxation/riemannian_relaxation.py | RiemannianRelaxation.calc_loss | def calc_loss(self, embedding):
"""Helper function to calculate rieman loss given new embedding"""
Hnew = self.compute_dual_rmetric(Ynew=embedding)
return self.rieman_loss(Hnew=Hnew) | python | def calc_loss(self, embedding):
"""Helper function to calculate rieman loss given new embedding"""
Hnew = self.compute_dual_rmetric(Ynew=embedding)
return self.rieman_loss(Hnew=Hnew) | [
"def",
"calc_loss",
"(",
"self",
",",
"embedding",
")",
":",
"Hnew",
"=",
"self",
".",
"compute_dual_rmetric",
"(",
"Ynew",
"=",
"embedding",
")",
"return",
"self",
".",
"rieman_loss",
"(",
"Hnew",
"=",
"Hnew",
")"
] | Helper function to calculate rieman loss given new embedding | [
"Helper",
"function",
"to",
"calculate",
"rieman",
"loss",
"given",
"new",
"embedding"
] | faccaf267aad0a8b18ec8a705735fd9dd838ca1e | https://github.com/mmp2/megaman/blob/faccaf267aad0a8b18ec8a705735fd9dd838ca1e/megaman/relaxation/riemannian_relaxation.py#L98-L101 |
7,583 | mmp2/megaman | megaman/relaxation/riemannian_relaxation.py | RiemannianRelaxation.compute_dual_rmetric | def compute_dual_rmetric(self,Ynew=None):
"""Helper function to calculate the """
usedY = self.Y if Ynew is None else Ynew
rieman_metric = RiemannMetric(usedY, self.laplacian_matrix)
return rieman_metric.get_dual_rmetric() | python | def compute_dual_rmetric(self,Ynew=None):
"""Helper function to calculate the """
usedY = self.Y if Ynew is None else Ynew
rieman_metric = RiemannMetric(usedY, self.laplacian_matrix)
return rieman_metric.get_dual_rmetric() | [
"def",
"compute_dual_rmetric",
"(",
"self",
",",
"Ynew",
"=",
"None",
")",
":",
"usedY",
"=",
"self",
".",
"Y",
"if",
"Ynew",
"is",
"None",
"else",
"Ynew",
"rieman_metric",
"=",
"RiemannMetric",
"(",
"usedY",
",",
"self",
".",
"laplacian_matrix",
")",
"r... | Helper function to calculate the | [
"Helper",
"function",
"to",
"calculate",
"the"
] | faccaf267aad0a8b18ec8a705735fd9dd838ca1e | https://github.com/mmp2/megaman/blob/faccaf267aad0a8b18ec8a705735fd9dd838ca1e/megaman/relaxation/riemannian_relaxation.py#L103-L107 |
7,584 | mmp2/megaman | doc/sphinxext/numpy_ext/automodsumm.py | automodsumm_to_autosummary_lines | def automodsumm_to_autosummary_lines(fn, app):
"""
Generates lines from a file with an "automodsumm" entry suitable for
feeding into "autosummary".
Searches the provided file for `automodsumm` directives and returns
a list of lines specifying the `autosummary` commands for the modules
requested... | python | def automodsumm_to_autosummary_lines(fn, app):
"""
Generates lines from a file with an "automodsumm" entry suitable for
feeding into "autosummary".
Searches the provided file for `automodsumm` directives and returns
a list of lines specifying the `autosummary` commands for the modules
requested... | [
"def",
"automodsumm_to_autosummary_lines",
"(",
"fn",
",",
"app",
")",
":",
"fullfn",
"=",
"os",
".",
"path",
".",
"join",
"(",
"app",
".",
"builder",
".",
"env",
".",
"srcdir",
",",
"fn",
")",
"with",
"open",
"(",
"fullfn",
")",
"as",
"fr",
":",
"... | Generates lines from a file with an "automodsumm" entry suitable for
feeding into "autosummary".
Searches the provided file for `automodsumm` directives and returns
a list of lines specifying the `autosummary` commands for the modules
requested. This does *not* return the whole file contents - just an
... | [
"Generates",
"lines",
"from",
"a",
"file",
"with",
"an",
"automodsumm",
"entry",
"suitable",
"for",
"feeding",
"into",
"autosummary",
"."
] | faccaf267aad0a8b18ec8a705735fd9dd838ca1e | https://github.com/mmp2/megaman/blob/faccaf267aad0a8b18ec8a705735fd9dd838ca1e/doc/sphinxext/numpy_ext/automodsumm.py#L265-L369 |
7,585 | mmp2/megaman | megaman/geometry/adjacency.py | compute_adjacency_matrix | def compute_adjacency_matrix(X, method='auto', **kwargs):
"""Compute an adjacency matrix with the given method"""
if method == 'auto':
if X.shape[0] > 10000:
method = 'cyflann'
else:
method = 'kd_tree'
return Adjacency.init(method, **kwargs).adjacency_graph(X.astype('... | python | def compute_adjacency_matrix(X, method='auto', **kwargs):
"""Compute an adjacency matrix with the given method"""
if method == 'auto':
if X.shape[0] > 10000:
method = 'cyflann'
else:
method = 'kd_tree'
return Adjacency.init(method, **kwargs).adjacency_graph(X.astype('... | [
"def",
"compute_adjacency_matrix",
"(",
"X",
",",
"method",
"=",
"'auto'",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"method",
"==",
"'auto'",
":",
"if",
"X",
".",
"shape",
"[",
"0",
"]",
">",
"10000",
":",
"method",
"=",
"'cyflann'",
"else",
":",
"... | Compute an adjacency matrix with the given method | [
"Compute",
"an",
"adjacency",
"matrix",
"with",
"the",
"given",
"method"
] | faccaf267aad0a8b18ec8a705735fd9dd838ca1e | https://github.com/mmp2/megaman/blob/faccaf267aad0a8b18ec8a705735fd9dd838ca1e/megaman/geometry/adjacency.py#L17-L24 |
7,586 | mmp2/megaman | megaman/relaxation/utils.py | split_kwargs | def split_kwargs(relaxation_kwds):
"""Split relaxation keywords to keywords for optimizer and others"""
optimizer_keys_list = [
'step_method',
'linesearch',
'eta_max',
'eta',
'm',
'linesearch_first'
]
optimizer_kwargs = { k:relaxation_kwds.pop(k) for k in ... | python | def split_kwargs(relaxation_kwds):
"""Split relaxation keywords to keywords for optimizer and others"""
optimizer_keys_list = [
'step_method',
'linesearch',
'eta_max',
'eta',
'm',
'linesearch_first'
]
optimizer_kwargs = { k:relaxation_kwds.pop(k) for k in ... | [
"def",
"split_kwargs",
"(",
"relaxation_kwds",
")",
":",
"optimizer_keys_list",
"=",
"[",
"'step_method'",
",",
"'linesearch'",
",",
"'eta_max'",
",",
"'eta'",
",",
"'m'",
",",
"'linesearch_first'",
"]",
"optimizer_kwargs",
"=",
"{",
"k",
":",
"relaxation_kwds",
... | Split relaxation keywords to keywords for optimizer and others | [
"Split",
"relaxation",
"keywords",
"to",
"keywords",
"for",
"optimizer",
"and",
"others"
] | faccaf267aad0a8b18ec8a705735fd9dd838ca1e | https://github.com/mmp2/megaman/blob/faccaf267aad0a8b18ec8a705735fd9dd838ca1e/megaman/relaxation/utils.py#L10-L23 |
7,587 | mmp2/megaman | megaman/relaxation/utils.py | initialize_kwds | def initialize_kwds(relaxation_kwds, n_samples, n_components, intrinsic_dim):
"""
Initialize relaxation keywords.
Parameters
----------
relaxation_kwds : dict
weights : numpy array, the weights
step_method : string { 'fixed', 'momentum' }
which optimizers to use
... | python | def initialize_kwds(relaxation_kwds, n_samples, n_components, intrinsic_dim):
"""
Initialize relaxation keywords.
Parameters
----------
relaxation_kwds : dict
weights : numpy array, the weights
step_method : string { 'fixed', 'momentum' }
which optimizers to use
... | [
"def",
"initialize_kwds",
"(",
"relaxation_kwds",
",",
"n_samples",
",",
"n_components",
",",
"intrinsic_dim",
")",
":",
"new_relaxation_kwds",
"=",
"{",
"'weights'",
":",
"np",
".",
"array",
"(",
"[",
"]",
",",
"dtype",
"=",
"np",
".",
"float64",
")",
","... | Initialize relaxation keywords.
Parameters
----------
relaxation_kwds : dict
weights : numpy array, the weights
step_method : string { 'fixed', 'momentum' }
which optimizers to use
linesearch : bool
whether to do linesearch in search for eta in optimization
... | [
"Initialize",
"relaxation",
"keywords",
"."
] | faccaf267aad0a8b18ec8a705735fd9dd838ca1e | https://github.com/mmp2/megaman/blob/faccaf267aad0a8b18ec8a705735fd9dd838ca1e/megaman/relaxation/utils.py#L26-L127 |
7,588 | mmp2/megaman | megaman/embedding/spectral_embedding.py | _graph_connected_component | def _graph_connected_component(graph, node_id):
"""
Find the largest graph connected components the contains one
given node
Parameters
----------
graph : array-like, shape: (n_samples, n_samples)
adjacency matrix of the graph, non-zero weight means an edge
between the nodes
... | python | def _graph_connected_component(graph, node_id):
"""
Find the largest graph connected components the contains one
given node
Parameters
----------
graph : array-like, shape: (n_samples, n_samples)
adjacency matrix of the graph, non-zero weight means an edge
between the nodes
... | [
"def",
"_graph_connected_component",
"(",
"graph",
",",
"node_id",
")",
":",
"connected_components",
"=",
"np",
".",
"zeros",
"(",
"shape",
"=",
"(",
"graph",
".",
"shape",
"[",
"0",
"]",
")",
",",
"dtype",
"=",
"np",
".",
"bool",
")",
"connected_compone... | Find the largest graph connected components the contains one
given node
Parameters
----------
graph : array-like, shape: (n_samples, n_samples)
adjacency matrix of the graph, non-zero weight means an edge
between the nodes
node_id : int
The index of the query node of the gr... | [
"Find",
"the",
"largest",
"graph",
"connected",
"components",
"the",
"contains",
"one",
"given",
"node"
] | faccaf267aad0a8b18ec8a705735fd9dd838ca1e | https://github.com/mmp2/megaman/blob/faccaf267aad0a8b18ec8a705735fd9dd838ca1e/megaman/embedding/spectral_embedding.py#L28-L58 |
7,589 | mmp2/megaman | megaman/embedding/spectral_embedding.py | SpectralEmbedding.predict | def predict(self, X_test, y=None):
"""
Predict embedding on new data X_test given the existing embedding on training data
Uses the Nystrom Extension to estimate the eigenvectors.
Currently only works with input_type data (i.e. not affinity or distance)
"""
if not hasatt... | python | def predict(self, X_test, y=None):
"""
Predict embedding on new data X_test given the existing embedding on training data
Uses the Nystrom Extension to estimate the eigenvectors.
Currently only works with input_type data (i.e. not affinity or distance)
"""
if not hasatt... | [
"def",
"predict",
"(",
"self",
",",
"X_test",
",",
"y",
"=",
"None",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'geom_'",
")",
":",
"raise",
"RuntimeError",
"(",
"'the .fit() function must be called before the .predict() function'",
")",
"if",
"self",
... | Predict embedding on new data X_test given the existing embedding on training data
Uses the Nystrom Extension to estimate the eigenvectors.
Currently only works with input_type data (i.e. not affinity or distance) | [
"Predict",
"embedding",
"on",
"new",
"data",
"X_test",
"given",
"the",
"existing",
"embedding",
"on",
"training",
"data"
] | faccaf267aad0a8b18ec8a705735fd9dd838ca1e | https://github.com/mmp2/megaman/blob/faccaf267aad0a8b18ec8a705735fd9dd838ca1e/megaman/embedding/spectral_embedding.py#L408-L465 |
7,590 | mmp2/megaman | megaman/geometry/laplacian.py | compute_laplacian_matrix | def compute_laplacian_matrix(affinity_matrix, method='auto', **kwargs):
"""Compute the laplacian matrix with the given method"""
if method == 'auto':
method = 'geometric'
return Laplacian.init(method, **kwargs).laplacian_matrix(affinity_matrix) | python | def compute_laplacian_matrix(affinity_matrix, method='auto', **kwargs):
"""Compute the laplacian matrix with the given method"""
if method == 'auto':
method = 'geometric'
return Laplacian.init(method, **kwargs).laplacian_matrix(affinity_matrix) | [
"def",
"compute_laplacian_matrix",
"(",
"affinity_matrix",
",",
"method",
"=",
"'auto'",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"method",
"==",
"'auto'",
":",
"method",
"=",
"'geometric'",
"return",
"Laplacian",
".",
"init",
"(",
"method",
",",
"*",
"*",... | Compute the laplacian matrix with the given method | [
"Compute",
"the",
"laplacian",
"matrix",
"with",
"the",
"given",
"method"
] | faccaf267aad0a8b18ec8a705735fd9dd838ca1e | https://github.com/mmp2/megaman/blob/faccaf267aad0a8b18ec8a705735fd9dd838ca1e/megaman/geometry/laplacian.py#L10-L14 |
7,591 | mmp2/megaman | megaman/embedding/base.py | BaseEmbedding.fit_geometry | def fit_geometry(self, X=None, input_type='data'):
"""Inputs self.geom, and produces the fitted geometry self.geom_"""
if self.geom is None:
self.geom_ = Geometry()
elif isinstance(self.geom, Geometry):
self.geom_ = self.geom
else:
try:
... | python | def fit_geometry(self, X=None, input_type='data'):
"""Inputs self.geom, and produces the fitted geometry self.geom_"""
if self.geom is None:
self.geom_ = Geometry()
elif isinstance(self.geom, Geometry):
self.geom_ = self.geom
else:
try:
... | [
"def",
"fit_geometry",
"(",
"self",
",",
"X",
"=",
"None",
",",
"input_type",
"=",
"'data'",
")",
":",
"if",
"self",
".",
"geom",
"is",
"None",
":",
"self",
".",
"geom_",
"=",
"Geometry",
"(",
")",
"elif",
"isinstance",
"(",
"self",
".",
"geom",
",... | Inputs self.geom, and produces the fitted geometry self.geom_ | [
"Inputs",
"self",
".",
"geom",
"and",
"produces",
"the",
"fitted",
"geometry",
"self",
".",
"geom_"
] | faccaf267aad0a8b18ec8a705735fd9dd838ca1e | https://github.com/mmp2/megaman/blob/faccaf267aad0a8b18ec8a705735fd9dd838ca1e/megaman/embedding/base.py#L87-L115 |
7,592 | mmp2/megaman | megaman/geometry/geometry.py | Geometry.set_radius | def set_radius(self, radius, override=True, X=None, n_components=2):
"""Set the radius for the adjacency and affinity computation
By default, this will override keyword arguments provided on
initialization.
Parameters
----------
radius : float
radius to set ... | python | def set_radius(self, radius, override=True, X=None, n_components=2):
"""Set the radius for the adjacency and affinity computation
By default, this will override keyword arguments provided on
initialization.
Parameters
----------
radius : float
radius to set ... | [
"def",
"set_radius",
"(",
"self",
",",
"radius",
",",
"override",
"=",
"True",
",",
"X",
"=",
"None",
",",
"n_components",
"=",
"2",
")",
":",
"if",
"radius",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"\"radius must be non-negative\"",
")",
"if",
"overr... | Set the radius for the adjacency and affinity computation
By default, this will override keyword arguments provided on
initialization.
Parameters
----------
radius : float
radius to set for adjacency and affinity.
override : bool (default: True)
... | [
"Set",
"the",
"radius",
"for",
"the",
"adjacency",
"and",
"affinity",
"computation"
] | faccaf267aad0a8b18ec8a705735fd9dd838ca1e | https://github.com/mmp2/megaman/blob/faccaf267aad0a8b18ec8a705735fd9dd838ca1e/megaman/geometry/geometry.py#L114-L140 |
7,593 | mmp2/megaman | megaman/geometry/rmetric.py | RiemannMetric.get_rmetric | def get_rmetric( self, mode_inv = 'svd', return_svd = False ):
"""
Compute the Reimannian Metric
"""
if self.H is None:
self.H, self.G, self.Hvv, self.Hsval = riemann_metric(self.Y, self.L, self.mdimG, invert_h = True, mode_inv = mode_inv)
if self.G is None:
... | python | def get_rmetric( self, mode_inv = 'svd', return_svd = False ):
"""
Compute the Reimannian Metric
"""
if self.H is None:
self.H, self.G, self.Hvv, self.Hsval = riemann_metric(self.Y, self.L, self.mdimG, invert_h = True, mode_inv = mode_inv)
if self.G is None:
... | [
"def",
"get_rmetric",
"(",
"self",
",",
"mode_inv",
"=",
"'svd'",
",",
"return_svd",
"=",
"False",
")",
":",
"if",
"self",
".",
"H",
"is",
"None",
":",
"self",
".",
"H",
",",
"self",
".",
"G",
",",
"self",
".",
"Hvv",
",",
"self",
".",
"Hsval",
... | Compute the Reimannian Metric | [
"Compute",
"the",
"Reimannian",
"Metric"
] | faccaf267aad0a8b18ec8a705735fd9dd838ca1e | https://github.com/mmp2/megaman/blob/faccaf267aad0a8b18ec8a705735fd9dd838ca1e/megaman/geometry/rmetric.py#L270-L281 |
7,594 | mmp2/megaman | megaman/relaxation/trace_variable.py | TracingVariable.report_and_save_keywords | def report_and_save_keywords(self,relaxation_kwds,precomputed_kwds):
"""Save relaxation keywords to .txt and .pyc file"""
report_name = os.path.join(self.backup_dir,'relaxation_keywords.txt')
pretty_relax_kwds = pprint.pformat(relaxation_kwds,indent=4)
with open(report_name,'w') as wf:
... | python | def report_and_save_keywords(self,relaxation_kwds,precomputed_kwds):
"""Save relaxation keywords to .txt and .pyc file"""
report_name = os.path.join(self.backup_dir,'relaxation_keywords.txt')
pretty_relax_kwds = pprint.pformat(relaxation_kwds,indent=4)
with open(report_name,'w') as wf:
... | [
"def",
"report_and_save_keywords",
"(",
"self",
",",
"relaxation_kwds",
",",
"precomputed_kwds",
")",
":",
"report_name",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"backup_dir",
",",
"'relaxation_keywords.txt'",
")",
"pretty_relax_kwds",
"=",
"pprint"... | Save relaxation keywords to .txt and .pyc file | [
"Save",
"relaxation",
"keywords",
"to",
".",
"txt",
"and",
".",
"pyc",
"file"
] | faccaf267aad0a8b18ec8a705735fd9dd838ca1e | https://github.com/mmp2/megaman/blob/faccaf267aad0a8b18ec8a705735fd9dd838ca1e/megaman/relaxation/trace_variable.py#L36-L55 |
7,595 | mmp2/megaman | megaman/relaxation/trace_variable.py | TracingVariable.update | def update(self,iiter,H,Y,eta,loss):
"""Update the trace_var in new iteration"""
if iiter <= self.niter_trace+1:
self.H[iiter] = H
self.Y[iiter] = Y
elif iiter >self.niter - self.niter_trace + 1:
self.H[self.ltrace+iiter-self.niter-1] = H
self.Y[se... | python | def update(self,iiter,H,Y,eta,loss):
"""Update the trace_var in new iteration"""
if iiter <= self.niter_trace+1:
self.H[iiter] = H
self.Y[iiter] = Y
elif iiter >self.niter - self.niter_trace + 1:
self.H[self.ltrace+iiter-self.niter-1] = H
self.Y[se... | [
"def",
"update",
"(",
"self",
",",
"iiter",
",",
"H",
",",
"Y",
",",
"eta",
",",
"loss",
")",
":",
"if",
"iiter",
"<=",
"self",
".",
"niter_trace",
"+",
"1",
":",
"self",
".",
"H",
"[",
"iiter",
"]",
"=",
"H",
"self",
".",
"Y",
"[",
"iiter",
... | Update the trace_var in new iteration | [
"Update",
"the",
"trace_var",
"in",
"new",
"iteration"
] | faccaf267aad0a8b18ec8a705735fd9dd838ca1e | https://github.com/mmp2/megaman/blob/faccaf267aad0a8b18ec8a705735fd9dd838ca1e/megaman/relaxation/trace_variable.py#L57-L71 |
7,596 | mmp2/megaman | megaman/relaxation/trace_variable.py | TracingVariable.save | def save(cls,instance,filename):
"""Class method save for saving TracingVariable."""
filename = cls.correct_file_extension(filename)
try:
with open(filename,'wb') as f:
pickle.dump(instance,f,protocol=pickle.HIGHEST_PROTOCOL)
except MemoryError as e:
... | python | def save(cls,instance,filename):
"""Class method save for saving TracingVariable."""
filename = cls.correct_file_extension(filename)
try:
with open(filename,'wb') as f:
pickle.dump(instance,f,protocol=pickle.HIGHEST_PROTOCOL)
except MemoryError as e:
... | [
"def",
"save",
"(",
"cls",
",",
"instance",
",",
"filename",
")",
":",
"filename",
"=",
"cls",
".",
"correct_file_extension",
"(",
"filename",
")",
"try",
":",
"with",
"open",
"(",
"filename",
",",
"'wb'",
")",
"as",
"f",
":",
"pickle",
".",
"dump",
... | Class method save for saving TracingVariable. | [
"Class",
"method",
"save",
"for",
"saving",
"TracingVariable",
"."
] | faccaf267aad0a8b18ec8a705735fd9dd838ca1e | https://github.com/mmp2/megaman/blob/faccaf267aad0a8b18ec8a705735fd9dd838ca1e/megaman/relaxation/trace_variable.py#L93-L106 |
7,597 | mmp2/megaman | megaman/relaxation/trace_variable.py | TracingVariable.load | def load(cls,filename):
"""Load from stored files"""
filename = cls.correct_file_extension(filename)
with open(filename,'rb') as f:
return pickle.load(f) | python | def load(cls,filename):
"""Load from stored files"""
filename = cls.correct_file_extension(filename)
with open(filename,'rb') as f:
return pickle.load(f) | [
"def",
"load",
"(",
"cls",
",",
"filename",
")",
":",
"filename",
"=",
"cls",
".",
"correct_file_extension",
"(",
"filename",
")",
"with",
"open",
"(",
"filename",
",",
"'rb'",
")",
"as",
"f",
":",
"return",
"pickle",
".",
"load",
"(",
"f",
")"
] | Load from stored files | [
"Load",
"from",
"stored",
"files"
] | faccaf267aad0a8b18ec8a705735fd9dd838ca1e | https://github.com/mmp2/megaman/blob/faccaf267aad0a8b18ec8a705735fd9dd838ca1e/megaman/relaxation/trace_variable.py#L109-L113 |
7,598 | mmp2/megaman | doc/sphinxext/numpy_ext/utils.py | find_mod_objs | def find_mod_objs(modname, onlylocals=False):
""" Returns all the public attributes of a module referenced by name.
.. note::
The returned list *not* include subpackages or modules of
`modname`,nor does it include private attributes (those that
beginwith '_' or are not in `__all__`).
... | python | def find_mod_objs(modname, onlylocals=False):
""" Returns all the public attributes of a module referenced by name.
.. note::
The returned list *not* include subpackages or modules of
`modname`,nor does it include private attributes (those that
beginwith '_' or are not in `__all__`).
... | [
"def",
"find_mod_objs",
"(",
"modname",
",",
"onlylocals",
"=",
"False",
")",
":",
"__import__",
"(",
"modname",
")",
"mod",
"=",
"sys",
".",
"modules",
"[",
"modname",
"]",
"if",
"hasattr",
"(",
"mod",
",",
"'__all__'",
")",
":",
"pkgitems",
"=",
"[",... | Returns all the public attributes of a module referenced by name.
.. note::
The returned list *not* include subpackages or modules of
`modname`,nor does it include private attributes (those that
beginwith '_' or are not in `__all__`).
Parameters
----------
modname : str
... | [
"Returns",
"all",
"the",
"public",
"attributes",
"of",
"a",
"module",
"referenced",
"by",
"name",
"."
] | faccaf267aad0a8b18ec8a705735fd9dd838ca1e | https://github.com/mmp2/megaman/blob/faccaf267aad0a8b18ec8a705735fd9dd838ca1e/doc/sphinxext/numpy_ext/utils.py#L5-L65 |
7,599 | mmp2/megaman | megaman/datasets/datasets.py | get_megaman_image | def get_megaman_image(factor=1):
"""Return an RGBA representation of the megaman icon"""
imfile = os.path.join(os.path.dirname(__file__), 'megaman.png')
data = ndimage.imread(imfile) / 255
if factor > 1:
data = data.repeat(factor, axis=0).repeat(factor, axis=1)
return data | python | def get_megaman_image(factor=1):
"""Return an RGBA representation of the megaman icon"""
imfile = os.path.join(os.path.dirname(__file__), 'megaman.png')
data = ndimage.imread(imfile) / 255
if factor > 1:
data = data.repeat(factor, axis=0).repeat(factor, axis=1)
return data | [
"def",
"get_megaman_image",
"(",
"factor",
"=",
"1",
")",
":",
"imfile",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"'megaman.png'",
")",
"data",
"=",
"ndimage",
".",
"imread",
"(",
"imfile... | Return an RGBA representation of the megaman icon | [
"Return",
"an",
"RGBA",
"representation",
"of",
"the",
"megaman",
"icon"
] | faccaf267aad0a8b18ec8a705735fd9dd838ca1e | https://github.com/mmp2/megaman/blob/faccaf267aad0a8b18ec8a705735fd9dd838ca1e/megaman/datasets/datasets.py#L12-L18 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.