repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
gcrahay/python-wer | src/wer/schema.py | DictMixin.to_dict | def to_dict(self):
"""
Recusively exports object values to a dict
:return: `dict`of values
"""
if not hasattr(self, '_fields'):
return self.__dict__
result = dict()
for field_name, field in self._fields.items():
if isinstance(field, xmlmap... | python | def to_dict(self):
"""
Recusively exports object values to a dict
:return: `dict`of values
"""
if not hasattr(self, '_fields'):
return self.__dict__
result = dict()
for field_name, field in self._fields.items():
if isinstance(field, xmlmap... | [
"def",
"to_dict",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_fields'",
")",
":",
"return",
"self",
".",
"__dict__",
"result",
"=",
"dict",
"(",
")",
"for",
"field_name",
",",
"field",
"in",
"self",
".",
"_fields",
".",
"items... | Recusively exports object values to a dict
:return: `dict`of values | [
"Recusively",
"exports",
"object",
"values",
"to",
"a",
"dict"
] | train | https://github.com/gcrahay/python-wer/blob/fad6bc4e379ec96a9483d32079098f19dfff1be5/src/wer/schema.py#L28-L56 |
gcrahay/python-wer | src/wer/schema.py | LoaderMixin.from_file | def from_file(cls, file_path, validate=True):
""" Creates a Python object from a XML file
:param file_path: Path to the XML file
:param validate: XML should be validated against the embedded XSD definition
:type validate: Boolean
:returns: the Python object
"""
r... | python | def from_file(cls, file_path, validate=True):
""" Creates a Python object from a XML file
:param file_path: Path to the XML file
:param validate: XML should be validated against the embedded XSD definition
:type validate: Boolean
:returns: the Python object
"""
r... | [
"def",
"from_file",
"(",
"cls",
",",
"file_path",
",",
"validate",
"=",
"True",
")",
":",
"return",
"xmlmap",
".",
"load_xmlobject_from_file",
"(",
"file_path",
",",
"xmlclass",
"=",
"cls",
",",
"validate",
"=",
"validate",
")"
] | Creates a Python object from a XML file
:param file_path: Path to the XML file
:param validate: XML should be validated against the embedded XSD definition
:type validate: Boolean
:returns: the Python object | [
"Creates",
"a",
"Python",
"object",
"from",
"a",
"XML",
"file"
] | train | https://github.com/gcrahay/python-wer/blob/fad6bc4e379ec96a9483d32079098f19dfff1be5/src/wer/schema.py#L65-L73 |
gcrahay/python-wer | src/wer/schema.py | LoaderMixin.from_string | def from_string(cls, xml_string, validate=True):
""" Creates a Python object from a XML string
:param xml_string: XML string
:param validate: XML should be validated against the embedded XSD definition
:type validate: Boolean
:returns: the Python object
"""
retur... | python | def from_string(cls, xml_string, validate=True):
""" Creates a Python object from a XML string
:param xml_string: XML string
:param validate: XML should be validated against the embedded XSD definition
:type validate: Boolean
:returns: the Python object
"""
retur... | [
"def",
"from_string",
"(",
"cls",
",",
"xml_string",
",",
"validate",
"=",
"True",
")",
":",
"return",
"xmlmap",
".",
"load_xmlobject_from_string",
"(",
"xml_string",
",",
"xmlclass",
"=",
"cls",
",",
"validate",
"=",
"validate",
")"
] | Creates a Python object from a XML string
:param xml_string: XML string
:param validate: XML should be validated against the embedded XSD definition
:type validate: Boolean
:returns: the Python object | [
"Creates",
"a",
"Python",
"object",
"from",
"a",
"XML",
"string"
] | train | https://github.com/gcrahay/python-wer/blob/fad6bc4e379ec96a9483d32079098f19dfff1be5/src/wer/schema.py#L76-L84 |
gcrahay/python-wer | src/wer/schema.py | Report.id | def id(self):
"""
Computes the signature of the record, a SHA-512 of significant values
:return: SHa-512 Hex string
"""
h = hashlib.new('sha512')
for value in (self.machine.name, self.machine.os, self.user, self.application.name,
self.application.pa... | python | def id(self):
"""
Computes the signature of the record, a SHA-512 of significant values
:return: SHa-512 Hex string
"""
h = hashlib.new('sha512')
for value in (self.machine.name, self.machine.os, self.user, self.application.name,
self.application.pa... | [
"def",
"id",
"(",
"self",
")",
":",
"h",
"=",
"hashlib",
".",
"new",
"(",
"'sha512'",
")",
"for",
"value",
"in",
"(",
"self",
".",
"machine",
".",
"name",
",",
"self",
".",
"machine",
".",
"os",
",",
"self",
".",
"user",
",",
"self",
".",
"appl... | Computes the signature of the record, a SHA-512 of significant values
:return: SHa-512 Hex string | [
"Computes",
"the",
"signature",
"of",
"the",
"record",
"a",
"SHA",
"-",
"512",
"of",
"significant",
"values"
] | train | https://github.com/gcrahay/python-wer/blob/fad6bc4e379ec96a9483d32079098f19dfff1be5/src/wer/schema.py#L186-L199 |
textbook/flash | flash/flash.py | scratchpad | def scratchpad():
"""Dummy page for styling tests."""
return render_template(
'demo.html',
config=dict(
project_name='Scratchpad',
style=request.args.get('style', 'default'),
),
title='Style Scratchpad',
) | python | def scratchpad():
"""Dummy page for styling tests."""
return render_template(
'demo.html',
config=dict(
project_name='Scratchpad',
style=request.args.get('style', 'default'),
),
title='Style Scratchpad',
) | [
"def",
"scratchpad",
"(",
")",
":",
"return",
"render_template",
"(",
"'demo.html'",
",",
"config",
"=",
"dict",
"(",
"project_name",
"=",
"'Scratchpad'",
",",
"style",
"=",
"request",
".",
"args",
".",
"get",
"(",
"'style'",
",",
"'default'",
")",
",",
... | Dummy page for styling tests. | [
"Dummy",
"page",
"for",
"styling",
"tests",
"."
] | train | https://github.com/textbook/flash/blob/ee93f0976a1a6bf11a995f1fbbe24c6c66d0aa1f/flash/flash.py#L36-L45 |
textbook/flash | flash/flash.py | update_service | def update_service(name, service_map):
"""Get an update from the specified service.
Arguments:
name (:py:class:`str`): The name of the service.
service_map (:py:class:`dict`): A mapping of service names to
:py:class:`flash.service.core.Service` instances.
Returns:
:py:class:`dict... | python | def update_service(name, service_map):
"""Get an update from the specified service.
Arguments:
name (:py:class:`str`): The name of the service.
service_map (:py:class:`dict`): A mapping of service names to
:py:class:`flash.service.core.Service` instances.
Returns:
:py:class:`dict... | [
"def",
"update_service",
"(",
"name",
",",
"service_map",
")",
":",
"if",
"name",
"in",
"service_map",
":",
"service",
"=",
"service_map",
"[",
"name",
"]",
"data",
"=",
"service",
".",
"update",
"(",
")",
"if",
"not",
"data",
":",
"logger",
".",
"warn... | Get an update from the specified service.
Arguments:
name (:py:class:`str`): The name of the service.
service_map (:py:class:`dict`): A mapping of service names to
:py:class:`flash.service.core.Service` instances.
Returns:
:py:class:`dict`: The updated data. | [
"Get",
"an",
"update",
"from",
"the",
"specified",
"service",
"."
] | train | https://github.com/textbook/flash/blob/ee93f0976a1a6bf11a995f1fbbe24c6c66d0aa1f/flash/flash.py#L59-L83 |
textbook/flash | flash/flash.py | add_time | def add_time(data):
"""And a friendly update time to the supplied data.
Arguments:
data (:py:class:`dict`): The response data and its update time.
Returns:
:py:class:`dict`: The data with a friendly update time.
"""
payload = data['data']
updated = data['updated'].date()
if up... | python | def add_time(data):
"""And a friendly update time to the supplied data.
Arguments:
data (:py:class:`dict`): The response data and its update time.
Returns:
:py:class:`dict`: The data with a friendly update time.
"""
payload = data['data']
updated = data['updated'].date()
if up... | [
"def",
"add_time",
"(",
"data",
")",
":",
"payload",
"=",
"data",
"[",
"'data'",
"]",
"updated",
"=",
"data",
"[",
"'updated'",
"]",
".",
"date",
"(",
")",
"if",
"updated",
"==",
"date",
".",
"today",
"(",
")",
":",
"payload",
"[",
"'last_updated'",
... | And a friendly update time to the supplied data.
Arguments:
data (:py:class:`dict`): The response data and its update time.
Returns:
:py:class:`dict`: The data with a friendly update time. | [
"And",
"a",
"friendly",
"update",
"time",
"to",
"the",
"supplied",
"data",
"."
] | train | https://github.com/textbook/flash/blob/ee93f0976a1a6bf11a995f1fbbe24c6c66d0aa1f/flash/flash.py#L86-L106 |
radujica/baloo | baloo/core/frame.py | DataFrame.dtypes | def dtypes(self):
"""Series of NumPy dtypes present in the DataFrame with index of column names.
Returns
-------
Series
"""
return Series(np.array(list(self._gather_dtypes().values()), dtype=np.bytes_),
self.keys()) | python | def dtypes(self):
"""Series of NumPy dtypes present in the DataFrame with index of column names.
Returns
-------
Series
"""
return Series(np.array(list(self._gather_dtypes().values()), dtype=np.bytes_),
self.keys()) | [
"def",
"dtypes",
"(",
"self",
")",
":",
"return",
"Series",
"(",
"np",
".",
"array",
"(",
"list",
"(",
"self",
".",
"_gather_dtypes",
"(",
")",
".",
"values",
"(",
")",
")",
",",
"dtype",
"=",
"np",
".",
"bytes_",
")",
",",
"self",
".",
"keys",
... | Series of NumPy dtypes present in the DataFrame with index of column names.
Returns
-------
Series | [
"Series",
"of",
"NumPy",
"dtypes",
"present",
"in",
"the",
"DataFrame",
"with",
"index",
"of",
"column",
"names",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/core/frame.py#L168-L177 |
radujica/baloo | baloo/core/frame.py | DataFrame.columns | def columns(self):
"""Index of the column names present in the DataFrame in order.
Returns
-------
Index
"""
return Index(np.array(self._gather_column_names(), dtype=np.bytes_), np.dtype(np.bytes_)) | python | def columns(self):
"""Index of the column names present in the DataFrame in order.
Returns
-------
Index
"""
return Index(np.array(self._gather_column_names(), dtype=np.bytes_), np.dtype(np.bytes_)) | [
"def",
"columns",
"(",
"self",
")",
":",
"return",
"Index",
"(",
"np",
".",
"array",
"(",
"self",
".",
"_gather_column_names",
"(",
")",
",",
"dtype",
"=",
"np",
".",
"bytes_",
")",
",",
"np",
".",
"dtype",
"(",
"np",
".",
"bytes_",
")",
")"
] | Index of the column names present in the DataFrame in order.
Returns
-------
Index | [
"Index",
"of",
"the",
"column",
"names",
"present",
"in",
"the",
"DataFrame",
"in",
"order",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/core/frame.py#L183-L191 |
radujica/baloo | baloo/core/frame.py | DataFrame.astype | def astype(self, dtype):
"""Cast DataFrame columns to given dtype.
Parameters
----------
dtype : numpy.dtype or dict
Dtype or column_name -> dtype mapping to cast columns to. Note index is excluded.
Returns
-------
DataFrame
With casted c... | python | def astype(self, dtype):
"""Cast DataFrame columns to given dtype.
Parameters
----------
dtype : numpy.dtype or dict
Dtype or column_name -> dtype mapping to cast columns to. Note index is excluded.
Returns
-------
DataFrame
With casted c... | [
"def",
"astype",
"(",
"self",
",",
"dtype",
")",
":",
"if",
"isinstance",
"(",
"dtype",
",",
"np",
".",
"dtype",
")",
":",
"new_data",
"=",
"OrderedDict",
"(",
"(",
"column",
".",
"name",
",",
"column",
".",
"astype",
"(",
"dtype",
")",
")",
"for",... | Cast DataFrame columns to given dtype.
Parameters
----------
dtype : numpy.dtype or dict
Dtype or column_name -> dtype mapping to cast columns to. Note index is excluded.
Returns
-------
DataFrame
With casted columns. | [
"Cast",
"DataFrame",
"columns",
"to",
"given",
"dtype",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/core/frame.py#L291-L321 |
radujica/baloo | baloo/core/frame.py | DataFrame.evaluate | def evaluate(self, verbose=False, decode=True, passes=None, num_threads=1, apply_experimental=True):
"""Evaluates by creating a DataFrame containing evaluated data and index.
See `LazyResult`
Returns
-------
DataFrame
DataFrame with evaluated data and index.
... | python | def evaluate(self, verbose=False, decode=True, passes=None, num_threads=1, apply_experimental=True):
"""Evaluates by creating a DataFrame containing evaluated data and index.
See `LazyResult`
Returns
-------
DataFrame
DataFrame with evaluated data and index.
... | [
"def",
"evaluate",
"(",
"self",
",",
"verbose",
"=",
"False",
",",
"decode",
"=",
"True",
",",
"passes",
"=",
"None",
",",
"num_threads",
"=",
"1",
",",
"apply_experimental",
"=",
"True",
")",
":",
"evaluated_index",
"=",
"self",
".",
"index",
".",
"ev... | Evaluates by creating a DataFrame containing evaluated data and index.
See `LazyResult`
Returns
-------
DataFrame
DataFrame with evaluated data and index. | [
"Evaluates",
"by",
"creating",
"a",
"DataFrame",
"containing",
"evaluated",
"data",
"and",
"index",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/core/frame.py#L442-L458 |
radujica/baloo | baloo/core/frame.py | DataFrame.tail | def tail(self, n=5):
"""Return DataFrame with last n values per column.
Parameters
----------
n : int
Number of values.
Returns
-------
DataFrame
DataFrame containing the last n values per column.
Examples
--------
... | python | def tail(self, n=5):
"""Return DataFrame with last n values per column.
Parameters
----------
n : int
Number of values.
Returns
-------
DataFrame
DataFrame containing the last n values per column.
Examples
--------
... | [
"def",
"tail",
"(",
"self",
",",
"n",
"=",
"5",
")",
":",
"length",
"=",
"_obtain_length",
"(",
"self",
".",
"_length",
",",
"self",
".",
"_data",
")",
"new_index",
"=",
"self",
".",
"index",
".",
"tail",
"(",
"n",
")",
"new_data",
"=",
"OrderedDic... | Return DataFrame with last n values per column.
Parameters
----------
n : int
Number of values.
Returns
-------
DataFrame
DataFrame containing the last n values per column.
Examples
--------
>>> df = bl.DataFrame(OrderedD... | [
"Return",
"DataFrame",
"with",
"last",
"n",
"values",
"per",
"column",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/core/frame.py#L485-L514 |
radujica/baloo | baloo/core/frame.py | DataFrame.rename | def rename(self, columns):
"""Returns a new DataFrame with renamed columns.
Currently a simplified version of Pandas' rename.
Parameters
----------
columns : dict
Old names to new names.
Returns
-------
DataFrame
With columns ren... | python | def rename(self, columns):
"""Returns a new DataFrame with renamed columns.
Currently a simplified version of Pandas' rename.
Parameters
----------
columns : dict
Old names to new names.
Returns
-------
DataFrame
With columns ren... | [
"def",
"rename",
"(",
"self",
",",
"columns",
")",
":",
"new_data",
"=",
"OrderedDict",
"(",
")",
"for",
"column_name",
"in",
"self",
":",
"if",
"column_name",
"in",
"columns",
".",
"keys",
"(",
")",
":",
"column",
"=",
"self",
".",
"_data",
"[",
"co... | Returns a new DataFrame with renamed columns.
Currently a simplified version of Pandas' rename.
Parameters
----------
columns : dict
Old names to new names.
Returns
-------
DataFrame
With columns renamed, if found. | [
"Returns",
"a",
"new",
"DataFrame",
"with",
"renamed",
"columns",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/core/frame.py#L527-L552 |
radujica/baloo | baloo/core/frame.py | DataFrame.drop | def drop(self, columns):
"""Drop 1 or more columns. Any column which does not exist in the DataFrame is skipped, i.e. not removed,
without raising an exception.
Unlike Pandas' drop, this is currently restricted to dropping columns.
Parameters
----------
columns : str or... | python | def drop(self, columns):
"""Drop 1 or more columns. Any column which does not exist in the DataFrame is skipped, i.e. not removed,
without raising an exception.
Unlike Pandas' drop, this is currently restricted to dropping columns.
Parameters
----------
columns : str or... | [
"def",
"drop",
"(",
"self",
",",
"columns",
")",
":",
"if",
"isinstance",
"(",
"columns",
",",
"str",
")",
":",
"new_data",
"=",
"OrderedDict",
"(",
")",
"if",
"columns",
"not",
"in",
"self",
".",
"_gather_column_names",
"(",
")",
":",
"raise",
"KeyErr... | Drop 1 or more columns. Any column which does not exist in the DataFrame is skipped, i.e. not removed,
without raising an exception.
Unlike Pandas' drop, this is currently restricted to dropping columns.
Parameters
----------
columns : str or list of str
Column name... | [
"Drop",
"1",
"or",
"more",
"columns",
".",
"Any",
"column",
"which",
"does",
"not",
"exist",
"in",
"the",
"DataFrame",
"is",
"skipped",
"i",
".",
"e",
".",
"not",
"removed",
"without",
"raising",
"an",
"exception",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/core/frame.py#L554-L590 |
radujica/baloo | baloo/core/frame.py | DataFrame.agg | def agg(self, aggregations):
"""Multiple aggregations optimized.
Parameters
----------
aggregations : list of str
Which aggregations to perform.
Returns
-------
DataFrame
DataFrame with the aggregations per column.
"""
ch... | python | def agg(self, aggregations):
"""Multiple aggregations optimized.
Parameters
----------
aggregations : list of str
Which aggregations to perform.
Returns
-------
DataFrame
DataFrame with the aggregations per column.
"""
ch... | [
"def",
"agg",
"(",
"self",
",",
"aggregations",
")",
":",
"check_type",
"(",
"aggregations",
",",
"list",
")",
"df",
"=",
"_drop_str_columns",
"(",
"self",
")",
"if",
"len",
"(",
"df",
".",
"_data",
")",
"==",
"0",
":",
"# conforming to what pandas does",
... | Multiple aggregations optimized.
Parameters
----------
aggregations : list of str
Which aggregations to perform.
Returns
-------
DataFrame
DataFrame with the aggregations per column. | [
"Multiple",
"aggregations",
"optimized",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/core/frame.py#L641-L666 |
radujica/baloo | baloo/core/frame.py | DataFrame.reset_index | def reset_index(self):
"""Returns a new DataFrame with previous index as column(s).
Returns
-------
DataFrame
DataFrame with the new index a RangeIndex of its length.
"""
new_columns = OrderedDict()
new_index = default_index(_obtain_length(self._len... | python | def reset_index(self):
"""Returns a new DataFrame with previous index as column(s).
Returns
-------
DataFrame
DataFrame with the new index a RangeIndex of its length.
"""
new_columns = OrderedDict()
new_index = default_index(_obtain_length(self._len... | [
"def",
"reset_index",
"(",
"self",
")",
":",
"new_columns",
"=",
"OrderedDict",
"(",
")",
"new_index",
"=",
"default_index",
"(",
"_obtain_length",
"(",
"self",
".",
"_length",
",",
"self",
".",
"_data",
")",
")",
"new_columns",
".",
"update",
"(",
"(",
... | Returns a new DataFrame with previous index as column(s).
Returns
-------
DataFrame
DataFrame with the new index a RangeIndex of its length. | [
"Returns",
"a",
"new",
"DataFrame",
"with",
"previous",
"index",
"as",
"column",
"(",
"s",
")",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/core/frame.py#L668-L688 |
radujica/baloo | baloo/core/frame.py | DataFrame.set_index | def set_index(self, keys):
"""Set the index of the DataFrame to be the keys columns.
Note this means that the old index is removed.
Parameters
----------
keys : str or list of str
Which column(s) to set as the index.
Returns
-------
DataFram... | python | def set_index(self, keys):
"""Set the index of the DataFrame to be the keys columns.
Note this means that the old index is removed.
Parameters
----------
keys : str or list of str
Which column(s) to set as the index.
Returns
-------
DataFram... | [
"def",
"set_index",
"(",
"self",
",",
"keys",
")",
":",
"if",
"isinstance",
"(",
"keys",
",",
"str",
")",
":",
"column",
"=",
"self",
".",
"_data",
"[",
"keys",
"]",
"new_index",
"=",
"Index",
"(",
"column",
".",
"values",
",",
"column",
".",
"dtyp... | Set the index of the DataFrame to be the keys columns.
Note this means that the old index is removed.
Parameters
----------
keys : str or list of str
Which column(s) to set as the index.
Returns
-------
DataFrame
DataFrame with the index... | [
"Set",
"the",
"index",
"of",
"the",
"DataFrame",
"to",
"be",
"the",
"keys",
"columns",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/core/frame.py#L690-L731 |
radujica/baloo | baloo/core/frame.py | DataFrame.sort_index | def sort_index(self, ascending=True):
"""Sort the index of the DataFrame.
Currently MultiIndex is not supported since Weld is missing multiple-column sort.
Note this is an expensive operation (brings all data to Weld).
Parameters
----------
ascending : bool, optional
... | python | def sort_index(self, ascending=True):
"""Sort the index of the DataFrame.
Currently MultiIndex is not supported since Weld is missing multiple-column sort.
Note this is an expensive operation (brings all data to Weld).
Parameters
----------
ascending : bool, optional
... | [
"def",
"sort_index",
"(",
"self",
",",
"ascending",
"=",
"True",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"index",
",",
"MultiIndex",
")",
":",
"raise",
"NotImplementedError",
"(",
"'Weld does not yet support sorting on multiple columns'",
")",
"return",
"s... | Sort the index of the DataFrame.
Currently MultiIndex is not supported since Weld is missing multiple-column sort.
Note this is an expensive operation (brings all data to Weld).
Parameters
----------
ascending : bool, optional
Returns
-------
DataFrame... | [
"Sort",
"the",
"index",
"of",
"the",
"DataFrame",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/core/frame.py#L733-L753 |
radujica/baloo | baloo/core/frame.py | DataFrame.sort_values | def sort_values(self, by, ascending=True):
"""Sort the DataFrame based on a column.
Unlike Pandas, one can sort by data from both index and regular columns.
Currently possible to sort only on a single column since Weld is missing multiple-column sort.
Note this is an expensive operatio... | python | def sort_values(self, by, ascending=True):
"""Sort the DataFrame based on a column.
Unlike Pandas, one can sort by data from both index and regular columns.
Currently possible to sort only on a single column since Weld is missing multiple-column sort.
Note this is an expensive operatio... | [
"def",
"sort_values",
"(",
"self",
",",
"by",
",",
"ascending",
"=",
"True",
")",
":",
"check_type",
"(",
"ascending",
",",
"bool",
")",
"check_str_or_list_str",
"(",
"by",
")",
"by",
"=",
"as_list",
"(",
"by",
")",
"if",
"len",
"(",
"by",
")",
">",
... | Sort the DataFrame based on a column.
Unlike Pandas, one can sort by data from both index and regular columns.
Currently possible to sort only on a single column since Weld is missing multiple-column sort.
Note this is an expensive operation (brings all data to Weld).
Parameters
... | [
"Sort",
"the",
"DataFrame",
"based",
"on",
"a",
"column",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/core/frame.py#L755-L796 |
radujica/baloo | baloo/core/frame.py | DataFrame.merge | def merge(self, other, how='inner', on=None, suffixes=('_x', '_y'),
algorithm='merge', is_on_sorted=False, is_on_unique=True):
"""Database-like join this DataFrame with the other DataFrame.
Currently assumes the on-column(s) values are unique!
Note there's no automatic cast if th... | python | def merge(self, other, how='inner', on=None, suffixes=('_x', '_y'),
algorithm='merge', is_on_sorted=False, is_on_unique=True):
"""Database-like join this DataFrame with the other DataFrame.
Currently assumes the on-column(s) values are unique!
Note there's no automatic cast if th... | [
"def",
"merge",
"(",
"self",
",",
"other",
",",
"how",
"=",
"'inner'",
",",
"on",
"=",
"None",
",",
"suffixes",
"=",
"(",
"'_x'",
",",
"'_y'",
")",
",",
"algorithm",
"=",
"'merge'",
",",
"is_on_sorted",
"=",
"False",
",",
"is_on_unique",
"=",
"True",... | Database-like join this DataFrame with the other DataFrame.
Currently assumes the on-column(s) values are unique!
Note there's no automatic cast if the type of the on columns differs.
Algorithms and limitations:
- Merge algorithms: merge-join or hash-join. Typical pros and cons apply... | [
"Database",
"-",
"like",
"join",
"this",
"DataFrame",
"with",
"the",
"other",
"DataFrame",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/core/frame.py#L798-L925 |
radujica/baloo | baloo/core/frame.py | DataFrame.join | def join(self, other, on=None, how='left', lsuffix=None, rsuffix=None,
algorithm='merge', is_on_sorted=True, is_on_unique=True):
"""Database-like join this DataFrame with the other DataFrame.
Currently assumes the `on` columns are sorted and the on-column(s) values are unique!
Next... | python | def join(self, other, on=None, how='left', lsuffix=None, rsuffix=None,
algorithm='merge', is_on_sorted=True, is_on_unique=True):
"""Database-like join this DataFrame with the other DataFrame.
Currently assumes the `on` columns are sorted and the on-column(s) values are unique!
Next... | [
"def",
"join",
"(",
"self",
",",
"other",
",",
"on",
"=",
"None",
",",
"how",
"=",
"'left'",
",",
"lsuffix",
"=",
"None",
",",
"rsuffix",
"=",
"None",
",",
"algorithm",
"=",
"'merge'",
",",
"is_on_sorted",
"=",
"True",
",",
"is_on_unique",
"=",
"True... | Database-like join this DataFrame with the other DataFrame.
Currently assumes the `on` columns are sorted and the on-column(s) values are unique!
Next work handles the other cases.
Note there's no automatic cast if the type of the on columns differs.
Check DataFrame.merge() for more d... | [
"Database",
"-",
"like",
"join",
"this",
"DataFrame",
"with",
"the",
"other",
"DataFrame",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/core/frame.py#L927-L980 |
radujica/baloo | baloo/core/frame.py | DataFrame.drop_duplicates | def drop_duplicates(self, subset=None, keep='min'):
"""Return DataFrame with duplicate rows (excluding index) removed,
optionally only considering subset columns.
Note that the row order is NOT maintained due to hashing.
Parameters
----------
subset : list of str, optio... | python | def drop_duplicates(self, subset=None, keep='min'):
"""Return DataFrame with duplicate rows (excluding index) removed,
optionally only considering subset columns.
Note that the row order is NOT maintained due to hashing.
Parameters
----------
subset : list of str, optio... | [
"def",
"drop_duplicates",
"(",
"self",
",",
"subset",
"=",
"None",
",",
"keep",
"=",
"'min'",
")",
":",
"subset",
"=",
"check_and_obtain_subset_columns",
"(",
"subset",
",",
"self",
")",
"df",
"=",
"self",
".",
"reset_index",
"(",
")",
"df_names",
"=",
"... | Return DataFrame with duplicate rows (excluding index) removed,
optionally only considering subset columns.
Note that the row order is NOT maintained due to hashing.
Parameters
----------
subset : list of str, optional
Which columns to consider
keep : {'+', ... | [
"Return",
"DataFrame",
"with",
"duplicate",
"rows",
"(",
"excluding",
"index",
")",
"removed",
"optionally",
"only",
"considering",
"subset",
"columns",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/core/frame.py#L982-L1024 |
radujica/baloo | baloo/core/frame.py | DataFrame.dropna | def dropna(self, subset=None):
"""Remove missing values according to Baloo's convention.
Parameters
----------
subset : list of str, optional
Which columns to check for missing values in.
Returns
-------
DataFrame
DataFrame with no null v... | python | def dropna(self, subset=None):
"""Remove missing values according to Baloo's convention.
Parameters
----------
subset : list of str, optional
Which columns to check for missing values in.
Returns
-------
DataFrame
DataFrame with no null v... | [
"def",
"dropna",
"(",
"self",
",",
"subset",
"=",
"None",
")",
":",
"subset",
"=",
"check_and_obtain_subset_columns",
"(",
"subset",
",",
"self",
")",
"not_nas",
"=",
"[",
"v",
".",
"notna",
"(",
")",
"for",
"v",
"in",
"self",
"[",
"subset",
"]",
"."... | Remove missing values according to Baloo's convention.
Parameters
----------
subset : list of str, optional
Which columns to check for missing values in.
Returns
-------
DataFrame
DataFrame with no null values in columns. | [
"Remove",
"missing",
"values",
"according",
"to",
"Baloo",
"s",
"convention",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/core/frame.py#L1026-L1044 |
radujica/baloo | baloo/core/frame.py | DataFrame.fillna | def fillna(self, value):
"""Returns DataFrame with missing values replaced with value.
Parameters
----------
value : {int, float, bytes, bool} or dict
Scalar value to replace missing values with. If dict, replaces missing values
only in the key columns with the v... | python | def fillna(self, value):
"""Returns DataFrame with missing values replaced with value.
Parameters
----------
value : {int, float, bytes, bool} or dict
Scalar value to replace missing values with. If dict, replaces missing values
only in the key columns with the v... | [
"def",
"fillna",
"(",
"self",
",",
"value",
")",
":",
"if",
"is_scalar",
"(",
"value",
")",
":",
"new_data",
"=",
"OrderedDict",
"(",
"(",
"column",
".",
"name",
",",
"column",
".",
"fillna",
"(",
"value",
")",
")",
"for",
"column",
"in",
"self",
"... | Returns DataFrame with missing values replaced with value.
Parameters
----------
value : {int, float, bytes, bool} or dict
Scalar value to replace missing values with. If dict, replaces missing values
only in the key columns with the value scalar.
Returns
... | [
"Returns",
"DataFrame",
"with",
"missing",
"values",
"replaced",
"with",
"value",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/core/frame.py#L1046-L1072 |
radujica/baloo | baloo/core/frame.py | DataFrame.groupby | def groupby(self, by):
"""Group by certain columns, excluding index.
Simply reset_index if desiring to group by some index column too.
Parameters
----------
by : str or list of str
Column(s) to groupby.
Returns
-------
DataFrameGroupBy
... | python | def groupby(self, by):
"""Group by certain columns, excluding index.
Simply reset_index if desiring to group by some index column too.
Parameters
----------
by : str or list of str
Column(s) to groupby.
Returns
-------
DataFrameGroupBy
... | [
"def",
"groupby",
"(",
"self",
",",
"by",
")",
":",
"check_str_or_list_str",
"(",
"by",
")",
"by",
"=",
"as_list",
"(",
"by",
")",
"if",
"len",
"(",
"set",
"(",
"by",
")",
")",
"==",
"len",
"(",
"self",
".",
"_data",
")",
":",
"raise",
"ValueErro... | Group by certain columns, excluding index.
Simply reset_index if desiring to group by some index column too.
Parameters
----------
by : str or list of str
Column(s) to groupby.
Returns
-------
DataFrameGroupBy
Object encoding the groupb... | [
"Group",
"by",
"certain",
"columns",
"excluding",
"index",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/core/frame.py#L1074-L1097 |
radujica/baloo | baloo/core/frame.py | DataFrame.from_pandas | def from_pandas(cls, df):
"""Create baloo DataFrame from pandas DataFrame.
Parameters
----------
df : pandas.frame.DataFrame
Returns
-------
DataFrame
"""
from pandas import DataFrame as PandasDataFrame, Index as PandasIndex, MultiIndex as Panda... | python | def from_pandas(cls, df):
"""Create baloo DataFrame from pandas DataFrame.
Parameters
----------
df : pandas.frame.DataFrame
Returns
-------
DataFrame
"""
from pandas import DataFrame as PandasDataFrame, Index as PandasIndex, MultiIndex as Panda... | [
"def",
"from_pandas",
"(",
"cls",
",",
"df",
")",
":",
"from",
"pandas",
"import",
"DataFrame",
"as",
"PandasDataFrame",
",",
"Index",
"as",
"PandasIndex",
",",
"MultiIndex",
"as",
"PandasMultiIndex",
"check_type",
"(",
"df",
",",
"PandasDataFrame",
")",
"if",... | Create baloo DataFrame from pandas DataFrame.
Parameters
----------
df : pandas.frame.DataFrame
Returns
-------
DataFrame | [
"Create",
"baloo",
"DataFrame",
"from",
"pandas",
"DataFrame",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/core/frame.py#L1100-L1126 |
radujica/baloo | baloo/core/frame.py | DataFrame.to_pandas | def to_pandas(self):
"""Convert to pandas DataFrame.
Note the data is expected to be evaluated.
Returns
-------
pandas.frame.DataFrame
"""
from pandas import DataFrame as PandasDataFrame
pandas_index = self.index.to_pandas()
pandas_data = Order... | python | def to_pandas(self):
"""Convert to pandas DataFrame.
Note the data is expected to be evaluated.
Returns
-------
pandas.frame.DataFrame
"""
from pandas import DataFrame as PandasDataFrame
pandas_index = self.index.to_pandas()
pandas_data = Order... | [
"def",
"to_pandas",
"(",
"self",
")",
":",
"from",
"pandas",
"import",
"DataFrame",
"as",
"PandasDataFrame",
"pandas_index",
"=",
"self",
".",
"index",
".",
"to_pandas",
"(",
")",
"pandas_data",
"=",
"OrderedDict",
"(",
"(",
"column",
".",
"name",
",",
"co... | Convert to pandas DataFrame.
Note the data is expected to be evaluated.
Returns
-------
pandas.frame.DataFrame | [
"Convert",
"to",
"pandas",
"DataFrame",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/core/frame.py#L1128-L1144 |
radujica/baloo | baloo/core/frame.py | DataFrame.to_csv | def to_csv(self, filepath, sep=',', header=True, index=True):
"""Save DataFrame as csv.
Parameters
----------
filepath : str
sep : str, optional
Separator used between values.
header : bool, optional
Whether to save the header.
index : boo... | python | def to_csv(self, filepath, sep=',', header=True, index=True):
"""Save DataFrame as csv.
Parameters
----------
filepath : str
sep : str, optional
Separator used between values.
header : bool, optional
Whether to save the header.
index : boo... | [
"def",
"to_csv",
"(",
"self",
",",
"filepath",
",",
"sep",
"=",
"','",
",",
"header",
"=",
"True",
",",
"index",
"=",
"True",
")",
":",
"from",
".",
".",
"io",
"import",
"to_csv",
"return",
"to_csv",
"(",
"self",
",",
"filepath",
",",
"sep",
"=",
... | Save DataFrame as csv.
Parameters
----------
filepath : str
sep : str, optional
Separator used between values.
header : bool, optional
Whether to save the header.
index : bool, optional
Whether to save the index columns.
Retur... | [
"Save",
"DataFrame",
"as",
"csv",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/core/frame.py#L1147-L1167 |
fbngrm/babelpy | babelpy/babelfy.py | BabelfyClient.babelfy | def babelfy(self, text, params=None):
"""make a request to the babelfy api and babelfy param text
set self._data with the babelfied text as json object
"""
self._entities = list()
self._all_entities = list()
self._merged_entities = list()
self._all_merged_entities... | python | def babelfy(self, text, params=None):
"""make a request to the babelfy api and babelfy param text
set self._data with the babelfied text as json object
"""
self._entities = list()
self._all_entities = list()
self._merged_entities = list()
self._all_merged_entities... | [
"def",
"babelfy",
"(",
"self",
",",
"text",
",",
"params",
"=",
"None",
")",
":",
"self",
".",
"_entities",
"=",
"list",
"(",
")",
"self",
".",
"_all_entities",
"=",
"list",
"(",
")",
"self",
".",
"_merged_entities",
"=",
"list",
"(",
")",
"self",
... | make a request to the babelfy api and babelfy param text
set self._data with the babelfied text as json object | [
"make",
"a",
"request",
"to",
"the",
"babelfy",
"api",
"and",
"babelfy",
"param",
"text",
"set",
"self",
".",
"_data",
"with",
"the",
"babelfied",
"text",
"as",
"json",
"object"
] | train | https://github.com/fbngrm/babelpy/blob/ff305abecddd66aed40c32f0010485cf192e5f17/babelpy/babelfy.py#L80-L106 |
fbngrm/babelpy | babelpy/babelfy.py | BabelfyClient._parse_entities | def _parse_entities(self):
"""enrich the babelfied data with the text an the isEntity items
set self._entities with the enriched data
"""
entities = list()
for result in self._data:
entity = dict()
char_fragment = result.get('charFragment')
st... | python | def _parse_entities(self):
"""enrich the babelfied data with the text an the isEntity items
set self._entities with the enriched data
"""
entities = list()
for result in self._data:
entity = dict()
char_fragment = result.get('charFragment')
st... | [
"def",
"_parse_entities",
"(",
"self",
")",
":",
"entities",
"=",
"list",
"(",
")",
"for",
"result",
"in",
"self",
".",
"_data",
":",
"entity",
"=",
"dict",
"(",
")",
"char_fragment",
"=",
"result",
".",
"get",
"(",
"'charFragment'",
")",
"start",
"=",... | enrich the babelfied data with the text an the isEntity items
set self._entities with the enriched data | [
"enrich",
"the",
"babelfied",
"data",
"with",
"the",
"text",
"an",
"the",
"isEntity",
"items",
"set",
"self",
".",
"_entities",
"with",
"the",
"enriched",
"data"
] | train | https://github.com/fbngrm/babelpy/blob/ff305abecddd66aed40c32f0010485cf192e5f17/babelpy/babelfy.py#L108-L128 |
fbngrm/babelpy | babelpy/babelfy.py | BabelfyClient._parse_non_entities | def _parse_non_entities(self):
"""create data for all non-entities in the babelfied text
set self._all_entities with merged entity and non-entity data
"""
def _differ(tokens):
inner, outer = tokens
not_same_start = inner.get('start') != outer.get('start')
... | python | def _parse_non_entities(self):
"""create data for all non-entities in the babelfied text
set self._all_entities with merged entity and non-entity data
"""
def _differ(tokens):
inner, outer = tokens
not_same_start = inner.get('start') != outer.get('start')
... | [
"def",
"_parse_non_entities",
"(",
"self",
")",
":",
"def",
"_differ",
"(",
"tokens",
")",
":",
"inner",
",",
"outer",
"=",
"tokens",
"not_same_start",
"=",
"inner",
".",
"get",
"(",
"'start'",
")",
"!=",
"outer",
".",
"get",
"(",
"'start'",
")",
"not_... | create data for all non-entities in the babelfied text
set self._all_entities with merged entity and non-entity data | [
"create",
"data",
"for",
"all",
"non",
"-",
"entities",
"in",
"the",
"babelfied",
"text",
"set",
"self",
".",
"_all_entities",
"with",
"merged",
"entity",
"and",
"non",
"-",
"entity",
"data"
] | train | https://github.com/fbngrm/babelpy/blob/ff305abecddd66aed40c32f0010485cf192e5f17/babelpy/babelfy.py#L130-L194 |
fbngrm/babelpy | babelpy/babelfy.py | BabelfyClient._parse_merged_entities | def _parse_merged_entities(self):
"""set self._merged_entities to the longest possible(wrapping) tokens
"""
self._merged_entities = list(filterfalse(
lambda token: self._is_wrapped(token, self.entities),
self.entities)) | python | def _parse_merged_entities(self):
"""set self._merged_entities to the longest possible(wrapping) tokens
"""
self._merged_entities = list(filterfalse(
lambda token: self._is_wrapped(token, self.entities),
self.entities)) | [
"def",
"_parse_merged_entities",
"(",
"self",
")",
":",
"self",
".",
"_merged_entities",
"=",
"list",
"(",
"filterfalse",
"(",
"lambda",
"token",
":",
"self",
".",
"_is_wrapped",
"(",
"token",
",",
"self",
".",
"entities",
")",
",",
"self",
".",
"entities"... | set self._merged_entities to the longest possible(wrapping) tokens | [
"set",
"self",
".",
"_merged_entities",
"to",
"the",
"longest",
"possible",
"(",
"wrapping",
")",
"tokens"
] | train | https://github.com/fbngrm/babelpy/blob/ff305abecddd66aed40c32f0010485cf192e5f17/babelpy/babelfy.py#L196-L201 |
fbngrm/babelpy | babelpy/babelfy.py | BabelfyClient._parse_all_merged_entities | def _parse_all_merged_entities(self):
"""set self._all_merged_entities to the longest possible(wrapping)
tokens including non-entity tokens
"""
self._all_merged_entities = list(filterfalse(
lambda token: self._is_wrapped(token, self.all_entities),
self.all_entitie... | python | def _parse_all_merged_entities(self):
"""set self._all_merged_entities to the longest possible(wrapping)
tokens including non-entity tokens
"""
self._all_merged_entities = list(filterfalse(
lambda token: self._is_wrapped(token, self.all_entities),
self.all_entitie... | [
"def",
"_parse_all_merged_entities",
"(",
"self",
")",
":",
"self",
".",
"_all_merged_entities",
"=",
"list",
"(",
"filterfalse",
"(",
"lambda",
"token",
":",
"self",
".",
"_is_wrapped",
"(",
"token",
",",
"self",
".",
"all_entities",
")",
",",
"self",
".",
... | set self._all_merged_entities to the longest possible(wrapping)
tokens including non-entity tokens | [
"set",
"self",
".",
"_all_merged_entities",
"to",
"the",
"longest",
"possible",
"(",
"wrapping",
")",
"tokens",
"including",
"non",
"-",
"entity",
"tokens"
] | train | https://github.com/fbngrm/babelpy/blob/ff305abecddd66aed40c32f0010485cf192e5f17/babelpy/babelfy.py#L203-L209 |
fbngrm/babelpy | babelpy/babelfy.py | BabelfyClient._wraps | def _wraps(self, tokens):
"""determine if a token is wrapped by another token
"""
def _differ(tokens):
inner, outer = tokens
not_same_start = inner.get('start') != outer.get('start')
not_same_end = inner.get('end') != outer.get('end')
return not_sa... | python | def _wraps(self, tokens):
"""determine if a token is wrapped by another token
"""
def _differ(tokens):
inner, outer = tokens
not_same_start = inner.get('start') != outer.get('start')
not_same_end = inner.get('end') != outer.get('end')
return not_sa... | [
"def",
"_wraps",
"(",
"self",
",",
"tokens",
")",
":",
"def",
"_differ",
"(",
"tokens",
")",
":",
"inner",
",",
"outer",
"=",
"tokens",
"not_same_start",
"=",
"inner",
".",
"get",
"(",
"'start'",
")",
"!=",
"outer",
".",
"get",
"(",
"'start'",
")",
... | determine if a token is wrapped by another token | [
"determine",
"if",
"a",
"token",
"is",
"wrapped",
"by",
"another",
"token"
] | train | https://github.com/fbngrm/babelpy/blob/ff305abecddd66aed40c32f0010485cf192e5f17/babelpy/babelfy.py#L211-L231 |
fbngrm/babelpy | babelpy/babelfy.py | BabelfyClient._is_wrapped | def _is_wrapped(self, token, tokens):
"""check if param token is wrapped by any token in tokens
"""
for t in tokens:
is_wrapped = self._wraps((token, t))
if is_wrapped:
return True
return False | python | def _is_wrapped(self, token, tokens):
"""check if param token is wrapped by any token in tokens
"""
for t in tokens:
is_wrapped = self._wraps((token, t))
if is_wrapped:
return True
return False | [
"def",
"_is_wrapped",
"(",
"self",
",",
"token",
",",
"tokens",
")",
":",
"for",
"t",
"in",
"tokens",
":",
"is_wrapped",
"=",
"self",
".",
"_wraps",
"(",
"(",
"token",
",",
"t",
")",
")",
"if",
"is_wrapped",
":",
"return",
"True",
"return",
"False"
] | check if param token is wrapped by any token in tokens | [
"check",
"if",
"param",
"token",
"is",
"wrapped",
"by",
"any",
"token",
"in",
"tokens"
] | train | https://github.com/fbngrm/babelpy/blob/ff305abecddd66aed40c32f0010485cf192e5f17/babelpy/babelfy.py#L233-L240 |
b3j0f/aop | b3j0f/aop/advice/utils.py | Advice.apply | def apply(self, joinpoint):
"""Apply this advice on input joinpoint.
TODO: improve with internal methods instead of conditional test.
"""
if self._enable:
result = self._impl(joinpoint)
else:
result = joinpoint.proceed()
return result | python | def apply(self, joinpoint):
"""Apply this advice on input joinpoint.
TODO: improve with internal methods instead of conditional test.
"""
if self._enable:
result = self._impl(joinpoint)
else:
result = joinpoint.proceed()
return result | [
"def",
"apply",
"(",
"self",
",",
"joinpoint",
")",
":",
"if",
"self",
".",
"_enable",
":",
"result",
"=",
"self",
".",
"_impl",
"(",
"joinpoint",
")",
"else",
":",
"result",
"=",
"joinpoint",
".",
"proceed",
"(",
")",
"return",
"result"
] | Apply this advice on input joinpoint.
TODO: improve with internal methods instead of conditional test. | [
"Apply",
"this",
"advice",
"on",
"input",
"joinpoint",
"."
] | train | https://github.com/b3j0f/aop/blob/22b9ba335d103edd929c25eb6dbb94037d3615bc/b3j0f/aop/advice/utils.py#L70-L82 |
b3j0f/aop | b3j0f/aop/advice/utils.py | Advice.set_enable | def set_enable(target, enable=True, advice_ids=None):
"""Enable or disable all target Advices designated by input advice_ids.
If advice_ids is None, apply (dis|en)able state to all advices.
"""
advices = get_advices(target)
for advice in advices:
try:
... | python | def set_enable(target, enable=True, advice_ids=None):
"""Enable or disable all target Advices designated by input advice_ids.
If advice_ids is None, apply (dis|en)able state to all advices.
"""
advices = get_advices(target)
for advice in advices:
try:
... | [
"def",
"set_enable",
"(",
"target",
",",
"enable",
"=",
"True",
",",
"advice_ids",
"=",
"None",
")",
":",
"advices",
"=",
"get_advices",
"(",
"target",
")",
"for",
"advice",
"in",
"advices",
":",
"try",
":",
"if",
"isinstance",
"(",
"Advice",
")",
"and... | Enable or disable all target Advices designated by input advice_ids.
If advice_ids is None, apply (dis|en)able state to all advices. | [
"Enable",
"or",
"disable",
"all",
"target",
"Advices",
"designated",
"by",
"input",
"advice_ids",
"."
] | train | https://github.com/b3j0f/aop/blob/22b9ba335d103edd929c25eb6dbb94037d3615bc/b3j0f/aop/advice/utils.py#L85-L99 |
b3j0f/aop | b3j0f/aop/advice/utils.py | Advice.weave | def weave(target, advices, pointcut=None, depth=1, public=False):
"""Weave advices such as Advice objects."""
advices = (
advice if isinstance(advice, Advice) else Advice(advice)
for advice in advices
)
weave(
target=target, advices=advices, pointcut... | python | def weave(target, advices, pointcut=None, depth=1, public=False):
"""Weave advices such as Advice objects."""
advices = (
advice if isinstance(advice, Advice) else Advice(advice)
for advice in advices
)
weave(
target=target, advices=advices, pointcut... | [
"def",
"weave",
"(",
"target",
",",
"advices",
",",
"pointcut",
"=",
"None",
",",
"depth",
"=",
"1",
",",
"public",
"=",
"False",
")",
":",
"advices",
"=",
"(",
"advice",
"if",
"isinstance",
"(",
"advice",
",",
"Advice",
")",
"else",
"Advice",
"(",
... | Weave advices such as Advice objects. | [
"Weave",
"advices",
"such",
"as",
"Advice",
"objects",
"."
] | train | https://github.com/b3j0f/aop/blob/22b9ba335d103edd929c25eb6dbb94037d3615bc/b3j0f/aop/advice/utils.py#L102-L113 |
b3j0f/aop | b3j0f/aop/advice/utils.py | Advice.unweave | def unweave(target, *advices):
"""Unweave advices from input target."""
advices = (
advice if isinstance(advice, Advice) else Advice(advice)
for advice in advices
)
unweave(target=target, *advices) | python | def unweave(target, *advices):
"""Unweave advices from input target."""
advices = (
advice if isinstance(advice, Advice) else Advice(advice)
for advice in advices
)
unweave(target=target, *advices) | [
"def",
"unweave",
"(",
"target",
",",
"*",
"advices",
")",
":",
"advices",
"=",
"(",
"advice",
"if",
"isinstance",
"(",
"advice",
",",
"Advice",
")",
"else",
"Advice",
"(",
"advice",
")",
"for",
"advice",
"in",
"advices",
")",
"unweave",
"(",
"target",... | Unweave advices from input target. | [
"Unweave",
"advices",
"from",
"input",
"target",
"."
] | train | https://github.com/b3j0f/aop/blob/22b9ba335d103edd929c25eb6dbb94037d3615bc/b3j0f/aop/advice/utils.py#L116-L124 |
simoninireland/epyc | epyc/summaryexperiment.py | SummaryExperiment.summarise | def summarise( self, results ):
"""Generate a summary of results from a list of result dicts
returned by running the underlying experiment. By default we generate
mean, median, variance, and extrema for each value recorded.
Override this method to create different or extra summary stati... | python | def summarise( self, results ):
"""Generate a summary of results from a list of result dicts
returned by running the underlying experiment. By default we generate
mean, median, variance, and extrema for each value recorded.
Override this method to create different or extra summary stati... | [
"def",
"summarise",
"(",
"self",
",",
"results",
")",
":",
"if",
"len",
"(",
"results",
")",
"==",
"0",
":",
"return",
"dict",
"(",
")",
"else",
":",
"summary",
"=",
"dict",
"(",
")",
"# work out the fields to summarise",
"allKeys",
"=",
"results",
"[",
... | Generate a summary of results from a list of result dicts
returned by running the underlying experiment. By default we generate
mean, median, variance, and extrema for each value recorded.
Override this method to create different or extra summary statistics.
:param results: an array of... | [
"Generate",
"a",
"summary",
"of",
"results",
"from",
"a",
"list",
"of",
"result",
"dicts",
"returned",
"by",
"running",
"the",
"underlying",
"experiment",
".",
"By",
"default",
"we",
"generate",
"mean",
"median",
"variance",
"and",
"extrema",
"for",
"each",
... | train | https://github.com/simoninireland/epyc/blob/b3b61007741a0ab3de64df89070a6f30de8ec268/epyc/summaryexperiment.py#L76-L110 |
simoninireland/epyc | epyc/summaryexperiment.py | SummaryExperiment.do | def do( self, params ):
"""Perform the underlying experiment and summarise its results.
Our results are the summary statistics extracted from the results of
the instances of the underlying experiment that we performed.
We drop from the calculations any experiments whose completion statu... | python | def do( self, params ):
"""Perform the underlying experiment and summarise its results.
Our results are the summary statistics extracted from the results of
the instances of the underlying experiment that we performed.
We drop from the calculations any experiments whose completion statu... | [
"def",
"do",
"(",
"self",
",",
"params",
")",
":",
"# perform the underlying experiment",
"rc",
"=",
"self",
".",
"experiment",
"(",
")",
".",
"run",
"(",
")",
"# extract the result dicts as a list",
"results",
"=",
"rc",
"[",
"Experiment",
".",
"RESULTS",
"]"... | Perform the underlying experiment and summarise its results.
Our results are the summary statistics extracted from the results of
the instances of the underlying experiment that we performed.
We drop from the calculations any experiments whose completion status
was False, indicating an ... | [
"Perform",
"the",
"underlying",
"experiment",
"and",
"summarise",
"its",
"results",
".",
"Our",
"results",
"are",
"the",
"summary",
"statistics",
"extracted",
"from",
"the",
"results",
"of",
"the",
"instances",
"of",
"the",
"underlying",
"experiment",
"that",
"w... | train | https://github.com/simoninireland/epyc/blob/b3b61007741a0ab3de64df89070a6f30de8ec268/epyc/summaryexperiment.py#L112-L147 |
joequant/ethercalc-python | ethercalc/__init__.py | ss_to_xy | def ss_to_xy(s: str):
"""convert spreadsheet coordinates to zero-index xy coordinates.
return None if input is invalid"""
result = re.match(r'\$*([A-Z]+)\$*([0-9]+)', s, re.I)
if result == None:
return None
xstring = result.group(1).upper()
multiplier = 1
x = 0
for i in xstring:
... | python | def ss_to_xy(s: str):
"""convert spreadsheet coordinates to zero-index xy coordinates.
return None if input is invalid"""
result = re.match(r'\$*([A-Z]+)\$*([0-9]+)', s, re.I)
if result == None:
return None
xstring = result.group(1).upper()
multiplier = 1
x = 0
for i in xstring:
... | [
"def",
"ss_to_xy",
"(",
"s",
":",
"str",
")",
":",
"result",
"=",
"re",
".",
"match",
"(",
"r'\\$*([A-Z]+)\\$*([0-9]+)'",
",",
"s",
",",
"re",
".",
"I",
")",
"if",
"result",
"==",
"None",
":",
"return",
"None",
"xstring",
"=",
"result",
".",
"group",... | convert spreadsheet coordinates to zero-index xy coordinates.
return None if input is invalid | [
"convert",
"spreadsheet",
"coordinates",
"to",
"zero",
"-",
"index",
"xy",
"coordinates",
".",
"return",
"None",
"if",
"input",
"is",
"invalid"
] | train | https://github.com/joequant/ethercalc-python/blob/23d557963dd8ba142c6cedd84fea12a4b9fe605b/ethercalc/__init__.py#L39-L53 |
simoninireland/epyc | epyc/sqlitelabnotebook.py | SqliteLabNotebook.open | def open( self ):
"""Open the database connection."""
if self._connection is None:
self._connection = sqlite3.connect(self._dbfile) | python | def open( self ):
"""Open the database connection."""
if self._connection is None:
self._connection = sqlite3.connect(self._dbfile) | [
"def",
"open",
"(",
"self",
")",
":",
"if",
"self",
".",
"_connection",
"is",
"None",
":",
"self",
".",
"_connection",
"=",
"sqlite3",
".",
"connect",
"(",
"self",
".",
"_dbfile",
")"
] | Open the database connection. | [
"Open",
"the",
"database",
"connection",
"."
] | train | https://github.com/simoninireland/epyc/blob/b3b61007741a0ab3de64df89070a6f30de8ec268/epyc/sqlitelabnotebook.py#L58-L61 |
simoninireland/epyc | epyc/sqlitelabnotebook.py | SqliteLabNotebook._createDatabase | def _createDatabase( self ):
"""Private method to create the SQLite database file."""
# create experiment metadata table
command = """
CREATE TABLE {tn} (
{k} INT PRIMARY KEY NOT NULL,
START_TIME INT NOT NULL,
... | python | def _createDatabase( self ):
"""Private method to create the SQLite database file."""
# create experiment metadata table
command = """
CREATE TABLE {tn} (
{k} INT PRIMARY KEY NOT NULL,
START_TIME INT NOT NULL,
... | [
"def",
"_createDatabase",
"(",
"self",
")",
":",
"# create experiment metadata table",
"command",
"=",
"\"\"\"\n CREATE TABLE {tn} (\n {k} INT PRIMARY KEY NOT NULL,\n START_TIME INT NOT NULL,\n END_TIM... | Private method to create the SQLite database file. | [
"Private",
"method",
"to",
"create",
"the",
"SQLite",
"database",
"file",
"."
] | train | https://github.com/simoninireland/epyc/blob/b3b61007741a0ab3de64df89070a6f30de8ec268/epyc/sqlitelabnotebook.py#L73-L92 |
xen/webcraft | webcraft/apiview.py | alchemyencoder | def alchemyencoder(obj):
"""JSON encoder function for SQLAlchemy special classes."""
if isinstance(obj, datetime.date):
return obj.isoformat()
elif isinstance(obj, decimal.Decimal):
return float(obj) | python | def alchemyencoder(obj):
"""JSON encoder function for SQLAlchemy special classes."""
if isinstance(obj, datetime.date):
return obj.isoformat()
elif isinstance(obj, decimal.Decimal):
return float(obj) | [
"def",
"alchemyencoder",
"(",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"datetime",
".",
"date",
")",
":",
"return",
"obj",
".",
"isoformat",
"(",
")",
"elif",
"isinstance",
"(",
"obj",
",",
"decimal",
".",
"Decimal",
")",
":",
"return",
... | JSON encoder function for SQLAlchemy special classes. | [
"JSON",
"encoder",
"function",
"for",
"SQLAlchemy",
"special",
"classes",
"."
] | train | https://github.com/xen/webcraft/blob/74ff1e5b253048d9260446bfbc95de2e402a8005/webcraft/apiview.py#L10-L15 |
wichmannpas/django-rest-authtoken | rest_authtoken/auth.py | AuthTokenAuthentication.authenticate | def authenticate(self, request):
"""
Authenticate the request and return a two-tuple of (user, token).
"""
auth = get_authorization_header(request).split()
if not auth or auth[0].lower() != b'token':
return None
if len(auth) == 1:
msg = _('Invali... | python | def authenticate(self, request):
"""
Authenticate the request and return a two-tuple of (user, token).
"""
auth = get_authorization_header(request).split()
if not auth or auth[0].lower() != b'token':
return None
if len(auth) == 1:
msg = _('Invali... | [
"def",
"authenticate",
"(",
"self",
",",
"request",
")",
":",
"auth",
"=",
"get_authorization_header",
"(",
"request",
")",
".",
"split",
"(",
")",
"if",
"not",
"auth",
"or",
"auth",
"[",
"0",
"]",
".",
"lower",
"(",
")",
"!=",
"b'token'",
":",
"retu... | Authenticate the request and return a two-tuple of (user, token). | [
"Authenticate",
"the",
"request",
"and",
"return",
"a",
"two",
"-",
"tuple",
"of",
"(",
"user",
"token",
")",
"."
] | train | https://github.com/wichmannpas/django-rest-authtoken/blob/ef9153a64bfa5c30be10b0c53a74bd1d11f02cc6/rest_authtoken/auth.py#L13-L35 |
wichmannpas/django-rest-authtoken | rest_authtoken/auth.py | AuthTokenAuthentication.authenticate_credentials | def authenticate_credentials(self, token: bytes, request=None):
"""
Authenticate the token with optional request for context.
"""
user = AuthToken.get_user_for_token(token)
if user is None:
raise AuthenticationFailed(_('Invalid auth token.'))
if not user.is_... | python | def authenticate_credentials(self, token: bytes, request=None):
"""
Authenticate the token with optional request for context.
"""
user = AuthToken.get_user_for_token(token)
if user is None:
raise AuthenticationFailed(_('Invalid auth token.'))
if not user.is_... | [
"def",
"authenticate_credentials",
"(",
"self",
",",
"token",
":",
"bytes",
",",
"request",
"=",
"None",
")",
":",
"user",
"=",
"AuthToken",
".",
"get_user_for_token",
"(",
"token",
")",
"if",
"user",
"is",
"None",
":",
"raise",
"AuthenticationFailed",
"(",
... | Authenticate the token with optional request for context. | [
"Authenticate",
"the",
"token",
"with",
"optional",
"request",
"for",
"context",
"."
] | train | https://github.com/wichmannpas/django-rest-authtoken/blob/ef9153a64bfa5c30be10b0c53a74bd1d11f02cc6/rest_authtoken/auth.py#L37-L49 |
photo/openphoto-python | trovebox/api/api_action.py | ApiAction.create | def create(self, target, target_type=None, **kwds):
"""
Endpoint: /action/<target_id>/<target_type>/create.json
Creates a new action and returns it.
The target parameter can either be an id or a Trovebox object.
If a Trovebox object is used, the target type is inferred
a... | python | def create(self, target, target_type=None, **kwds):
"""
Endpoint: /action/<target_id>/<target_type>/create.json
Creates a new action and returns it.
The target parameter can either be an id or a Trovebox object.
If a Trovebox object is used, the target type is inferred
a... | [
"def",
"create",
"(",
"self",
",",
"target",
",",
"target_type",
"=",
"None",
",",
"*",
"*",
"kwds",
")",
":",
"# Extract the target type",
"if",
"target_type",
"is",
"None",
":",
"target_type",
"=",
"target",
".",
"get_type",
"(",
")",
"# Extract the target... | Endpoint: /action/<target_id>/<target_type>/create.json
Creates a new action and returns it.
The target parameter can either be an id or a Trovebox object.
If a Trovebox object is used, the target type is inferred
automatically. | [
"Endpoint",
":",
"/",
"action",
"/",
"<target_id",
">",
"/",
"<target_type",
">",
"/",
"create",
".",
"json"
] | train | https://github.com/photo/openphoto-python/blob/209a1da27c8d8c88dbcf4ea6c6f57031ea1bc44b/trovebox/api/api_action.py#L9-L31 |
photo/openphoto-python | trovebox/api/api_action.py | ApiAction.delete | def delete(self, action, **kwds):
"""
Endpoint: /action/<id>/delete.json
Deletes an action.
Returns True if successful.
Raises a TroveboxError if not.
"""
return self._client.post("/action/%s/delete.json" %
self._extract_id(action... | python | def delete(self, action, **kwds):
"""
Endpoint: /action/<id>/delete.json
Deletes an action.
Returns True if successful.
Raises a TroveboxError if not.
"""
return self._client.post("/action/%s/delete.json" %
self._extract_id(action... | [
"def",
"delete",
"(",
"self",
",",
"action",
",",
"*",
"*",
"kwds",
")",
":",
"return",
"self",
".",
"_client",
".",
"post",
"(",
"\"/action/%s/delete.json\"",
"%",
"self",
".",
"_extract_id",
"(",
"action",
")",
",",
"*",
"*",
"kwds",
")",
"[",
"\"r... | Endpoint: /action/<id>/delete.json
Deletes an action.
Returns True if successful.
Raises a TroveboxError if not. | [
"Endpoint",
":",
"/",
"action",
"/",
"<id",
">",
"/",
"delete",
".",
"json"
] | train | https://github.com/photo/openphoto-python/blob/209a1da27c8d8c88dbcf4ea6c6f57031ea1bc44b/trovebox/api/api_action.py#L33-L43 |
photo/openphoto-python | trovebox/api/api_action.py | ApiAction.view | def view(self, action, **kwds):
"""
Endpoint: /action/<id>/view.json
Requests all properties of an action.
Returns the requested action object.
"""
result = self._client.get("/action/%s/view.json" %
self._extract_id(action),
... | python | def view(self, action, **kwds):
"""
Endpoint: /action/<id>/view.json
Requests all properties of an action.
Returns the requested action object.
"""
result = self._client.get("/action/%s/view.json" %
self._extract_id(action),
... | [
"def",
"view",
"(",
"self",
",",
"action",
",",
"*",
"*",
"kwds",
")",
":",
"result",
"=",
"self",
".",
"_client",
".",
"get",
"(",
"\"/action/%s/view.json\"",
"%",
"self",
".",
"_extract_id",
"(",
"action",
")",
",",
"*",
"*",
"kwds",
")",
"[",
"\... | Endpoint: /action/<id>/view.json
Requests all properties of an action.
Returns the requested action object. | [
"Endpoint",
":",
"/",
"action",
"/",
"<id",
">",
"/",
"view",
".",
"json"
] | train | https://github.com/photo/openphoto-python/blob/209a1da27c8d8c88dbcf4ea6c6f57031ea1bc44b/trovebox/api/api_action.py#L45-L55 |
yola/hashcache | hashcache/hashcache.py | Hashcache.set | def set(self, key, *args):
"""Hash the key and set it in the cache"""
return self.cache.set(self._hashed(key), *args) | python | def set(self, key, *args):
"""Hash the key and set it in the cache"""
return self.cache.set(self._hashed(key), *args) | [
"def",
"set",
"(",
"self",
",",
"key",
",",
"*",
"args",
")",
":",
"return",
"self",
".",
"cache",
".",
"set",
"(",
"self",
".",
"_hashed",
"(",
"key",
")",
",",
"*",
"args",
")"
] | Hash the key and set it in the cache | [
"Hash",
"the",
"key",
"and",
"set",
"it",
"in",
"the",
"cache"
] | train | https://github.com/yola/hashcache/blob/0a42e3f7f0bd7ada2a34266d4aa06b8d61b2f038/hashcache/hashcache.py#L29-L31 |
flyingfrog81/fixreal | fixreal.py | get_conv | def get_conv(bits, bin_point, signed=False, scaling=1.0):
"""
Creates a I{conversion structure} implented as a dictionary containing all parameters
needed to switch between number representations.
@param bits: the number of bits
@param bin_point: binary point position
@param signed: True if Fix,... | python | def get_conv(bits, bin_point, signed=False, scaling=1.0):
"""
Creates a I{conversion structure} implented as a dictionary containing all parameters
needed to switch between number representations.
@param bits: the number of bits
@param bin_point: binary point position
@param signed: True if Fix,... | [
"def",
"get_conv",
"(",
"bits",
",",
"bin_point",
",",
"signed",
"=",
"False",
",",
"scaling",
"=",
"1.0",
")",
":",
"conversion_t",
"=",
"{",
"}",
"conversion_t",
"[",
"\"bits\"",
"]",
"=",
"bits",
"conversion_t",
"[",
"\"bin_point\"",
"]",
"=",
"bin_po... | Creates a I{conversion structure} implented as a dictionary containing all parameters
needed to switch between number representations.
@param bits: the number of bits
@param bin_point: binary point position
@param signed: True if Fix, False if UFix
@param scaling: optional scaling to be applied afte... | [
"Creates",
"a",
"I",
"{",
"conversion",
"structure",
"}",
"implented",
"as",
"a",
"dictionary",
"containing",
"all",
"parameters",
"needed",
"to",
"switch",
"between",
"number",
"representations",
"."
] | train | https://github.com/flyingfrog81/fixreal/blob/dc0c1c66b0b94357e4c181607fa385bfb5ccc5f8/fixreal.py#L83-L114 |
flyingfrog81/fixreal | fixreal.py | conv_from_name | def conv_from_name(name):
"""
Understand simulink syntax for fixed types and returns the proper
conversion structure.
@param name: the type name as in simulin (i.e. UFix_8_7 ... )
@raise ConversionError: When cannot decode the string
"""
_match = re.match(r"^(?P<signed>u?fix)_(?P<bits>\d+)_... | python | def conv_from_name(name):
"""
Understand simulink syntax for fixed types and returns the proper
conversion structure.
@param name: the type name as in simulin (i.e. UFix_8_7 ... )
@raise ConversionError: When cannot decode the string
"""
_match = re.match(r"^(?P<signed>u?fix)_(?P<bits>\d+)_... | [
"def",
"conv_from_name",
"(",
"name",
")",
":",
"_match",
"=",
"re",
".",
"match",
"(",
"r\"^(?P<signed>u?fix)_(?P<bits>\\d+)_(?P<binary>\\d+)\"",
",",
"name",
",",
"flags",
"=",
"re",
".",
"I",
")",
"if",
"not",
"_match",
":",
"raise",
"ConversionError",
"(",... | Understand simulink syntax for fixed types and returns the proper
conversion structure.
@param name: the type name as in simulin (i.e. UFix_8_7 ... )
@raise ConversionError: When cannot decode the string | [
"Understand",
"simulink",
"syntax",
"for",
"fixed",
"types",
"and",
"returns",
"the",
"proper",
"conversion",
"structure",
"."
] | train | https://github.com/flyingfrog81/fixreal/blob/dc0c1c66b0b94357e4c181607fa385bfb5ccc5f8/fixreal.py#L116-L134 |
flyingfrog81/fixreal | fixreal.py | _get_unsigned_params | def _get_unsigned_params(conv):
"""
Fill the sign-dependent params of the conv structure in case of unsigned
conversion
@param conv: the structure to be filled
"""
conv["sign_mask"] = 0
conv["int_min"] = 0
conv["int_mask"] = sum([2 ** i for i in range(conv["bin_point"],
conv["b... | python | def _get_unsigned_params(conv):
"""
Fill the sign-dependent params of the conv structure in case of unsigned
conversion
@param conv: the structure to be filled
"""
conv["sign_mask"] = 0
conv["int_min"] = 0
conv["int_mask"] = sum([2 ** i for i in range(conv["bin_point"],
conv["b... | [
"def",
"_get_unsigned_params",
"(",
"conv",
")",
":",
"conv",
"[",
"\"sign_mask\"",
"]",
"=",
"0",
"conv",
"[",
"\"int_min\"",
"]",
"=",
"0",
"conv",
"[",
"\"int_mask\"",
"]",
"=",
"sum",
"(",
"[",
"2",
"**",
"i",
"for",
"i",
"in",
"range",
"(",
"c... | Fill the sign-dependent params of the conv structure in case of unsigned
conversion
@param conv: the structure to be filled | [
"Fill",
"the",
"sign",
"-",
"dependent",
"params",
"of",
"the",
"conv",
"structure",
"in",
"case",
"of",
"unsigned",
"conversion"
] | train | https://github.com/flyingfrog81/fixreal/blob/dc0c1c66b0b94357e4c181607fa385bfb5ccc5f8/fixreal.py#L136-L147 |
flyingfrog81/fixreal | fixreal.py | _get_signed_params | def _get_signed_params(conv):
"""
Fill the sign-dependent params of the conv structure in case of signed
conversion
@param conv: the structure to be filled
"""
conv["sign_mask"] = 2 ** (conv["bits"] - 1)
conv["int_min"] = -1 * (2 ** (conv["bits"] - 1 - conv["bin_point"]))
conv["int_mask... | python | def _get_signed_params(conv):
"""
Fill the sign-dependent params of the conv structure in case of signed
conversion
@param conv: the structure to be filled
"""
conv["sign_mask"] = 2 ** (conv["bits"] - 1)
conv["int_min"] = -1 * (2 ** (conv["bits"] - 1 - conv["bin_point"]))
conv["int_mask... | [
"def",
"_get_signed_params",
"(",
"conv",
")",
":",
"conv",
"[",
"\"sign_mask\"",
"]",
"=",
"2",
"**",
"(",
"conv",
"[",
"\"bits\"",
"]",
"-",
"1",
")",
"conv",
"[",
"\"int_min\"",
"]",
"=",
"-",
"1",
"*",
"(",
"2",
"**",
"(",
"conv",
"[",
"\"bit... | Fill the sign-dependent params of the conv structure in case of signed
conversion
@param conv: the structure to be filled | [
"Fill",
"the",
"sign",
"-",
"dependent",
"params",
"of",
"the",
"conv",
"structure",
"in",
"case",
"of",
"signed",
"conversion"
] | train | https://github.com/flyingfrog81/fixreal/blob/dc0c1c66b0b94357e4c181607fa385bfb5ccc5f8/fixreal.py#L149-L160 |
flyingfrog81/fixreal | fixreal.py | fix2real | def fix2real(uval, conv):
"""
Convert a 32 bit unsigned int register into the value it represents in its Fixed arithmetic form.
@param uval: the numeric unsigned value in simulink representation
@param conv: conv structure with conversion specs as generated by I{get_conv}
@return: the real number re... | python | def fix2real(uval, conv):
"""
Convert a 32 bit unsigned int register into the value it represents in its Fixed arithmetic form.
@param uval: the numeric unsigned value in simulink representation
@param conv: conv structure with conversion specs as generated by I{get_conv}
@return: the real number re... | [
"def",
"fix2real",
"(",
"uval",
",",
"conv",
")",
":",
"res",
"=",
"0",
"int_val",
"=",
"(",
"(",
"uval",
"&",
"conv",
"[",
"\"int_mask\"",
"]",
")",
">>",
"conv",
"[",
"\"bin_point\"",
"]",
")",
"dec_val",
"=",
"conv",
"[",
"\"dec_step\"",
"]",
"*... | Convert a 32 bit unsigned int register into the value it represents in its Fixed arithmetic form.
@param uval: the numeric unsigned value in simulink representation
@param conv: conv structure with conversion specs as generated by I{get_conv}
@return: the real number represented by the Fixed arithmetic defi... | [
"Convert",
"a",
"32",
"bit",
"unsigned",
"int",
"register",
"into",
"the",
"value",
"it",
"represents",
"in",
"its",
"Fixed",
"arithmetic",
"form",
"."
] | train | https://github.com/flyingfrog81/fixreal/blob/dc0c1c66b0b94357e4c181607fa385bfb5ccc5f8/fixreal.py#L162-L177 |
flyingfrog81/fixreal | fixreal.py | bin2real | def bin2real(binary_string, conv, endianness="@"):
"""
Converts a binary string representing a number to its Fixed arithmetic representation
@param binary_string: binary number in simulink representation
@param conv: conv structure containing conversion specs
@param endianness: optionally specify by... | python | def bin2real(binary_string, conv, endianness="@"):
"""
Converts a binary string representing a number to its Fixed arithmetic representation
@param binary_string: binary number in simulink representation
@param conv: conv structure containing conversion specs
@param endianness: optionally specify by... | [
"def",
"bin2real",
"(",
"binary_string",
",",
"conv",
",",
"endianness",
"=",
"\"@\"",
")",
":",
"data",
"=",
"struct",
".",
"unpack",
"(",
"endianness",
"+",
"conv",
"[",
"\"fmt\"",
"]",
",",
"binary_string",
")",
"[",
"0",
"]",
"return",
"fix2real",
... | Converts a binary string representing a number to its Fixed arithmetic representation
@param binary_string: binary number in simulink representation
@param conv: conv structure containing conversion specs
@param endianness: optionally specify bytes endianness for unpacking
@return: the real number repre... | [
"Converts",
"a",
"binary",
"string",
"representing",
"a",
"number",
"to",
"its",
"Fixed",
"arithmetic",
"representation"
] | train | https://github.com/flyingfrog81/fixreal/blob/dc0c1c66b0b94357e4c181607fa385bfb5ccc5f8/fixreal.py#L179-L191 |
flyingfrog81/fixreal | fixreal.py | stream2real | def stream2real(binary_stream, conv, endianness="@"):
"""
Converts a binary stream into a sequence of real numbers
@param binary_stream: a binary string representing a sequence of numbers
@param conv: conv structure containing conversion specs
@param endianness: optionally specify bytes endianness f... | python | def stream2real(binary_stream, conv, endianness="@"):
"""
Converts a binary stream into a sequence of real numbers
@param binary_stream: a binary string representing a sequence of numbers
@param conv: conv structure containing conversion specs
@param endianness: optionally specify bytes endianness f... | [
"def",
"stream2real",
"(",
"binary_stream",
",",
"conv",
",",
"endianness",
"=",
"\"@\"",
")",
":",
"size",
"=",
"len",
"(",
"binary_stream",
")",
"//",
"(",
"conv",
"[",
"\"bits\"",
"]",
"//",
"8",
")",
"fmt",
"=",
"endianness",
"+",
"str",
"(",
"si... | Converts a binary stream into a sequence of real numbers
@param binary_stream: a binary string representing a sequence of numbers
@param conv: conv structure containing conversion specs
@param endianness: optionally specify bytes endianness for unpacking
@return: the list of real data represented | [
"Converts",
"a",
"binary",
"stream",
"into",
"a",
"sequence",
"of",
"real",
"numbers"
] | train | https://github.com/flyingfrog81/fixreal/blob/dc0c1c66b0b94357e4c181607fa385bfb5ccc5f8/fixreal.py#L193-L205 |
flyingfrog81/fixreal | fixreal.py | real2fix | def real2fix(real, conv):
"""
Convert a real number to its fixed representation so
that it can be written into a 32 bit register.
@param real: the real number to be converted into fixed representation
@param conv: conv structre with conversion specs
@return: the fixed representation of the real... | python | def real2fix(real, conv):
"""
Convert a real number to its fixed representation so
that it can be written into a 32 bit register.
@param real: the real number to be converted into fixed representation
@param conv: conv structre with conversion specs
@return: the fixed representation of the real... | [
"def",
"real2fix",
"(",
"real",
",",
"conv",
")",
":",
"if",
"not",
"conv",
"[",
"\"signed\"",
"]",
"and",
"real",
"<",
"0",
":",
"raise",
"ConversionError",
"(",
"\"cannot convert \"",
"+",
"str",
"(",
"real",
")",
"+",
"\" to unsigned representation\"",
... | Convert a real number to its fixed representation so
that it can be written into a 32 bit register.
@param real: the real number to be converted into fixed representation
@param conv: conv structre with conversion specs
@return: the fixed representation of the real number
@raise ConverisonError: i... | [
"Convert",
"a",
"real",
"number",
"to",
"its",
"fixed",
"representation",
"so",
"that",
"it",
"can",
"be",
"written",
"into",
"a",
"32",
"bit",
"register",
"."
] | train | https://github.com/flyingfrog81/fixreal/blob/dc0c1c66b0b94357e4c181607fa385bfb5ccc5f8/fixreal.py#L207-L242 |
ask/ghettoq | ghettoq/messaging.py | QueueSet._emulated | def _emulated(self, timeout=None):
"""Get the next message avaiable in the queue.
:returns: The message and the name of the queue it came from as
a tuple.
:raises Empty: If there are no more items in any of the queues.
"""
# A set of queues we've already tried.
... | python | def _emulated(self, timeout=None):
"""Get the next message avaiable in the queue.
:returns: The message and the name of the queue it came from as
a tuple.
:raises Empty: If there are no more items in any of the queues.
"""
# A set of queues we've already tried.
... | [
"def",
"_emulated",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"# A set of queues we've already tried.",
"tried",
"=",
"set",
"(",
")",
"while",
"True",
":",
"# Get the next queue in the cycle, and try to get an item off it.",
"try",
":",
"queue",
"=",
"self"... | Get the next message avaiable in the queue.
:returns: The message and the name of the queue it came from as
a tuple.
:raises Empty: If there are no more items in any of the queues. | [
"Get",
"the",
"next",
"message",
"avaiable",
"in",
"the",
"queue",
"."
] | train | https://github.com/ask/ghettoq/blob/22a0fcd865b618cbbbfd102efd88a7983507c24e/ghettoq/messaging.py#L55-L81 |
ssato/python-anytemplate | anytemplate/engines/base.py | fallback_render | def fallback_render(template, context, at_paths=None,
at_encoding=anytemplate.compat.ENCODING,
**kwargs):
"""
Render from given template and context.
This is a basic implementation actually does nothing and just returns
the content of given template file `templat... | python | def fallback_render(template, context, at_paths=None,
at_encoding=anytemplate.compat.ENCODING,
**kwargs):
"""
Render from given template and context.
This is a basic implementation actually does nothing and just returns
the content of given template file `templat... | [
"def",
"fallback_render",
"(",
"template",
",",
"context",
",",
"at_paths",
"=",
"None",
",",
"at_encoding",
"=",
"anytemplate",
".",
"compat",
".",
"ENCODING",
",",
"*",
"*",
"kwargs",
")",
":",
"tmpl",
"=",
"anytemplate",
".",
"utils",
".",
"find_templat... | Render from given template and context.
This is a basic implementation actually does nothing and just returns
the content of given template file `template`.
:param template: Template file path
:param context: A dict or dict-like object to instantiate given
template file
:param at_paths: Te... | [
"Render",
"from",
"given",
"template",
"and",
"context",
"."
] | train | https://github.com/ssato/python-anytemplate/blob/3e56baa914bd47f044083b20e33100f836443596/anytemplate/engines/base.py#L66-L92 |
ssato/python-anytemplate | anytemplate/engines/base.py | filter_kwargs | def filter_kwargs(keys, kwargs):
"""
:param keys: A iterable key names to select items
:param kwargs: A dict or dict-like object reprensents keyword args
>>> list(filter_kwargs(("a", "b"), dict(a=1, b=2, c=3, d=4)))
[('a', 1), ('b', 2)]
"""
for k in keys:
if k in kwargs:
... | python | def filter_kwargs(keys, kwargs):
"""
:param keys: A iterable key names to select items
:param kwargs: A dict or dict-like object reprensents keyword args
>>> list(filter_kwargs(("a", "b"), dict(a=1, b=2, c=3, d=4)))
[('a', 1), ('b', 2)]
"""
for k in keys:
if k in kwargs:
... | [
"def",
"filter_kwargs",
"(",
"keys",
",",
"kwargs",
")",
":",
"for",
"k",
"in",
"keys",
":",
"if",
"k",
"in",
"kwargs",
":",
"yield",
"(",
"k",
",",
"kwargs",
"[",
"k",
"]",
")"
] | :param keys: A iterable key names to select items
:param kwargs: A dict or dict-like object reprensents keyword args
>>> list(filter_kwargs(("a", "b"), dict(a=1, b=2, c=3, d=4)))
[('a', 1), ('b', 2)] | [
":",
"param",
"keys",
":",
"A",
"iterable",
"key",
"names",
"to",
"select",
"items",
":",
"param",
"kwargs",
":",
"A",
"dict",
"or",
"dict",
"-",
"like",
"object",
"reprensents",
"keyword",
"args"
] | train | https://github.com/ssato/python-anytemplate/blob/3e56baa914bd47f044083b20e33100f836443596/anytemplate/engines/base.py#L95-L105 |
ssato/python-anytemplate | anytemplate/engines/base.py | Engine.filter_options | def filter_options(cls, kwargs, keys):
"""
Make optional kwargs valid and optimized for each template engines.
:param kwargs: keyword arguements to process
:param keys: optional argument names
>>> Engine.filter_options(dict(aaa=1, bbb=2), ("aaa", ))
{'aaa': 1}
>... | python | def filter_options(cls, kwargs, keys):
"""
Make optional kwargs valid and optimized for each template engines.
:param kwargs: keyword arguements to process
:param keys: optional argument names
>>> Engine.filter_options(dict(aaa=1, bbb=2), ("aaa", ))
{'aaa': 1}
>... | [
"def",
"filter_options",
"(",
"cls",
",",
"kwargs",
",",
"keys",
")",
":",
"return",
"dict",
"(",
"(",
"k",
",",
"v",
")",
"for",
"k",
",",
"v",
"in",
"filter_kwargs",
"(",
"keys",
",",
"kwargs",
")",
")"
] | Make optional kwargs valid and optimized for each template engines.
:param kwargs: keyword arguements to process
:param keys: optional argument names
>>> Engine.filter_options(dict(aaa=1, bbb=2), ("aaa", ))
{'aaa': 1}
>>> Engine.filter_options(dict(bbb=2), ("aaa", ))
{} | [
"Make",
"optional",
"kwargs",
"valid",
"and",
"optimized",
"for",
"each",
"template",
"engines",
"."
] | train | https://github.com/ssato/python-anytemplate/blob/3e56baa914bd47f044083b20e33100f836443596/anytemplate/engines/base.py#L162-L174 |
ssato/python-anytemplate | anytemplate/engines/base.py | Engine.renders | def renders(self, template_content, context=None, at_paths=None,
at_encoding=anytemplate.compat.ENCODING, **kwargs):
"""
:param template_content: Template content
:param context: A dict or dict-like object to instantiate given
template file or None
:param at_p... | python | def renders(self, template_content, context=None, at_paths=None,
at_encoding=anytemplate.compat.ENCODING, **kwargs):
"""
:param template_content: Template content
:param context: A dict or dict-like object to instantiate given
template file or None
:param at_p... | [
"def",
"renders",
"(",
"self",
",",
"template_content",
",",
"context",
"=",
"None",
",",
"at_paths",
"=",
"None",
",",
"at_encoding",
"=",
"anytemplate",
".",
"compat",
".",
"ENCODING",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"=",
"self",
".",
"f... | :param template_content: Template content
:param context: A dict or dict-like object to instantiate given
template file or None
:param at_paths: Template search paths
:param at_encoding: Template encoding
:param kwargs: Keyword arguments passed to the template engine to
... | [
":",
"param",
"template_content",
":",
"Template",
"content",
":",
"param",
"context",
":",
"A",
"dict",
"or",
"dict",
"-",
"like",
"object",
"to",
"instantiate",
"given",
"template",
"file",
"or",
"None",
":",
"param",
"at_paths",
":",
"Template",
"search",... | train | https://github.com/ssato/python-anytemplate/blob/3e56baa914bd47f044083b20e33100f836443596/anytemplate/engines/base.py#L189-L212 |
ssato/python-anytemplate | anytemplate/engines/base.py | Engine.render | def render(self, template, context=None, at_paths=None,
at_encoding=anytemplate.compat.ENCODING, **kwargs):
"""
:param template: Template file path
:param context: A dict or dict-like object to instantiate given
template file
:param at_paths: Template search pa... | python | def render(self, template, context=None, at_paths=None,
at_encoding=anytemplate.compat.ENCODING, **kwargs):
"""
:param template: Template file path
:param context: A dict or dict-like object to instantiate given
template file
:param at_paths: Template search pa... | [
"def",
"render",
"(",
"self",
",",
"template",
",",
"context",
"=",
"None",
",",
"at_paths",
"=",
"None",
",",
"at_encoding",
"=",
"anytemplate",
".",
"compat",
".",
"ENCODING",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"=",
"self",
".",
"filter_opt... | :param template: Template file path
:param context: A dict or dict-like object to instantiate given
template file
:param at_paths: Template search paths
:param at_encoding: Template encoding
:param kwargs: Keyword arguments passed to the template engine to
render ... | [
":",
"param",
"template",
":",
"Template",
"file",
"path",
":",
"param",
"context",
":",
"A",
"dict",
"or",
"dict",
"-",
"like",
"object",
"to",
"instantiate",
"given",
"template",
"file",
":",
"param",
"at_paths",
":",
"Template",
"search",
"paths",
":",
... | train | https://github.com/ssato/python-anytemplate/blob/3e56baa914bd47f044083b20e33100f836443596/anytemplate/engines/base.py#L214-L236 |
PMBio/limix-backup | limix/stats/pca.py | PCA | def PCA(Y, components):
"""
run PCA, retrieving the first (components) principle components
return [s0, eig, w0]
s0: factors
w0: weights
"""
N,D = Y.shape
sv = linalg.svd(Y, full_matrices=0);
[s0, w0] = [sv[0][:, 0:components], np.dot(np.diag(sv[1]), sv[2]).T[:, 0:components]]
v = s0.std(axis=0)
s0 /= v;
w... | python | def PCA(Y, components):
"""
run PCA, retrieving the first (components) principle components
return [s0, eig, w0]
s0: factors
w0: weights
"""
N,D = Y.shape
sv = linalg.svd(Y, full_matrices=0);
[s0, w0] = [sv[0][:, 0:components], np.dot(np.diag(sv[1]), sv[2]).T[:, 0:components]]
v = s0.std(axis=0)
s0 /= v;
w... | [
"def",
"PCA",
"(",
"Y",
",",
"components",
")",
":",
"N",
",",
"D",
"=",
"Y",
".",
"shape",
"sv",
"=",
"linalg",
".",
"svd",
"(",
"Y",
",",
"full_matrices",
"=",
"0",
")",
"[",
"s0",
",",
"w0",
"]",
"=",
"[",
"sv",
"[",
"0",
"]",
"[",
":"... | run PCA, retrieving the first (components) principle components
return [s0, eig, w0]
s0: factors
w0: weights | [
"run",
"PCA",
"retrieving",
"the",
"first",
"(",
"components",
")",
"principle",
"components",
"return",
"[",
"s0",
"eig",
"w0",
"]",
"s0",
":",
"factors",
"w0",
":",
"weights"
] | train | https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/stats/pca.py#L24-L54 |
PMBio/limix-backup | limix/stats/pca.py | PC_varExplained | def PC_varExplained(Y,standardized=True):
"""
Run PCA and calculate the cumulative fraction of variance
Args:
Y: phenotype values
standardize: if True, phenotypes are standardized
Returns:
var: cumulative distribution of variance explained
"""
# figuring out the number of... | python | def PC_varExplained(Y,standardized=True):
"""
Run PCA and calculate the cumulative fraction of variance
Args:
Y: phenotype values
standardize: if True, phenotypes are standardized
Returns:
var: cumulative distribution of variance explained
"""
# figuring out the number of... | [
"def",
"PC_varExplained",
"(",
"Y",
",",
"standardized",
"=",
"True",
")",
":",
"# figuring out the number of latent factors",
"if",
"standardized",
":",
"Y",
"-=",
"Y",
".",
"mean",
"(",
"0",
")",
"Y",
"/=",
"Y",
".",
"std",
"(",
"0",
")",
"covY",
"=",
... | Run PCA and calculate the cumulative fraction of variance
Args:
Y: phenotype values
standardize: if True, phenotypes are standardized
Returns:
var: cumulative distribution of variance explained | [
"Run",
"PCA",
"and",
"calculate",
"the",
"cumulative",
"fraction",
"of",
"variance",
"Args",
":",
"Y",
":",
"phenotype",
"values",
"standardize",
":",
"if",
"True",
"phenotypes",
"are",
"standardized",
"Returns",
":",
"var",
":",
"cumulative",
"distribution",
... | train | https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/stats/pca.py#L56-L74 |
fchauvel/flap | flap/ui.py | main | def main(tex_file, output, verbose):
"""
FLaP merges your LaTeX projects into a single LaTeX file that
refers to images in the same directory.
It reads the given root TEX_FILE and generates a flatten version in the
given OUTPUT directory. It inlines the content of any TeX files refered by
\\inp... | python | def main(tex_file, output, verbose):
"""
FLaP merges your LaTeX projects into a single LaTeX file that
refers to images in the same directory.
It reads the given root TEX_FILE and generates a flatten version in the
given OUTPUT directory. It inlines the content of any TeX files refered by
\\inp... | [
"def",
"main",
"(",
"tex_file",
",",
"output",
",",
"verbose",
")",
":",
"Controller",
"(",
"OSFileSystem",
"(",
")",
",",
"Display",
"(",
"sys",
".",
"stdout",
",",
"verbose",
")",
")",
".",
"run",
"(",
"tex_file",
",",
"output",
")"
] | FLaP merges your LaTeX projects into a single LaTeX file that
refers to images in the same directory.
It reads the given root TEX_FILE and generates a flatten version in the
given OUTPUT directory. It inlines the content of any TeX files refered by
\\input or \\include but also copies resources such as... | [
"FLaP",
"merges",
"your",
"LaTeX",
"projects",
"into",
"a",
"single",
"LaTeX",
"file",
"that",
"refers",
"to",
"images",
"in",
"the",
"same",
"directory",
"."
] | train | https://github.com/fchauvel/flap/blob/c7425544244cdf899ad8c4a76c1a9520f48867f6/flap/ui.py#L91-L102 |
bretth/woven | woven/api.py | deploy | def deploy(overwrite=False):
"""
deploy a versioned project on the host
"""
check_settings()
if overwrite:
rmvirtualenv()
deploy_funcs = [deploy_project,deploy_templates, deploy_static, deploy_media, deploy_webconf, deploy_wsgi]
if not patch_project() or overwrite:
deploy_fu... | python | def deploy(overwrite=False):
"""
deploy a versioned project on the host
"""
check_settings()
if overwrite:
rmvirtualenv()
deploy_funcs = [deploy_project,deploy_templates, deploy_static, deploy_media, deploy_webconf, deploy_wsgi]
if not patch_project() or overwrite:
deploy_fu... | [
"def",
"deploy",
"(",
"overwrite",
"=",
"False",
")",
":",
"check_settings",
"(",
")",
"if",
"overwrite",
":",
"rmvirtualenv",
"(",
")",
"deploy_funcs",
"=",
"[",
"deploy_project",
",",
"deploy_templates",
",",
"deploy_static",
",",
"deploy_media",
",",
"deplo... | deploy a versioned project on the host | [
"deploy",
"a",
"versioned",
"project",
"on",
"the",
"host"
] | train | https://github.com/bretth/woven/blob/ec1da7b401a335f43129e7115fe7a4d145649f1e/woven/api.py#L32-L42 |
bretth/woven | woven/api.py | setupnode | def setupnode(overwrite=False):
"""
Install a baseline host. Can be run multiple times
"""
if not port_is_open():
if not skip_disable_root():
disable_root()
port_changed = change_ssh_port()
#avoid trying to take shortcuts if setupnode did not finish
#on previous exe... | python | def setupnode(overwrite=False):
"""
Install a baseline host. Can be run multiple times
"""
if not port_is_open():
if not skip_disable_root():
disable_root()
port_changed = change_ssh_port()
#avoid trying to take shortcuts if setupnode did not finish
#on previous exe... | [
"def",
"setupnode",
"(",
"overwrite",
"=",
"False",
")",
":",
"if",
"not",
"port_is_open",
"(",
")",
":",
"if",
"not",
"skip_disable_root",
"(",
")",
":",
"disable_root",
"(",
")",
"port_changed",
"=",
"change_ssh_port",
"(",
")",
"#avoid trying to take shortc... | Install a baseline host. Can be run multiple times | [
"Install",
"a",
"baseline",
"host",
".",
"Can",
"be",
"run",
"multiple",
"times"
] | train | https://github.com/bretth/woven/blob/ec1da7b401a335f43129e7115fe7a4d145649f1e/woven/api.py#L45-L75 |
PMBio/limix-backup | limix/mtSet/core/splitter_bed.py | splitGeno | def splitGeno(pos,method='slidingWindow',size=5e4,step=None,annotation_file=None,cis=1e4,funct=None,out_file=None):
"""
split geno into windows and store output in csv file
Args:
pos: genomic position in the format (chrom,pos)
method: method used to slit the windows:
... | python | def splitGeno(pos,method='slidingWindow',size=5e4,step=None,annotation_file=None,cis=1e4,funct=None,out_file=None):
"""
split geno into windows and store output in csv file
Args:
pos: genomic position in the format (chrom,pos)
method: method used to slit the windows:
... | [
"def",
"splitGeno",
"(",
"pos",
",",
"method",
"=",
"'slidingWindow'",
",",
"size",
"=",
"5e4",
",",
"step",
"=",
"None",
",",
"annotation_file",
"=",
"None",
",",
"cis",
"=",
"1e4",
",",
"funct",
"=",
"None",
",",
"out_file",
"=",
"None",
")",
":",
... | split geno into windows and store output in csv file
Args:
pos: genomic position in the format (chrom,pos)
method: method used to slit the windows:
'slidingWindow': uses a sliding window
'geneWindow': uses windows centered on genes
size... | [
"split",
"geno",
"into",
"windows",
"and",
"store",
"output",
"in",
"csv",
"file",
"Args",
":",
"pos",
":",
"genomic",
"position",
"in",
"the",
"format",
"(",
"chrom",
"pos",
")",
"method",
":",
"method",
"used",
"to",
"slit",
"the",
"windows",
":",
"s... | train | https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/mtSet/core/splitter_bed.py#L13-L39 |
PMBio/limix-backup | limix/mtSet/core/splitter_bed.py | splitGenoSlidingWindow | def splitGenoSlidingWindow(pos,out_file,size=5e4,step=None):
"""
split into windows using a slide criterion
Args:
size: window size
step: moving step (default: 0.5*size)
Returns:
wnd_i: number of windows
nSnps: vector of per-window number of SNPs
... | python | def splitGenoSlidingWindow(pos,out_file,size=5e4,step=None):
"""
split into windows using a slide criterion
Args:
size: window size
step: moving step (default: 0.5*size)
Returns:
wnd_i: number of windows
nSnps: vector of per-window number of SNPs
... | [
"def",
"splitGenoSlidingWindow",
"(",
"pos",
",",
"out_file",
",",
"size",
"=",
"5e4",
",",
"step",
"=",
"None",
")",
":",
"if",
"step",
"is",
"None",
":",
"step",
"=",
"0.5",
"*",
"size",
"chroms",
"=",
"SP",
".",
"unique",
"(",
"pos",
"[",
":",
... | split into windows using a slide criterion
Args:
size: window size
step: moving step (default: 0.5*size)
Returns:
wnd_i: number of windows
nSnps: vector of per-window number of SNPs | [
"split",
"into",
"windows",
"using",
"a",
"slide",
"criterion",
"Args",
":",
"size",
":",
"window",
"size",
"step",
":",
"moving",
"step",
"(",
"default",
":",
"0",
".",
"5",
"*",
"size",
")",
"Returns",
":",
"wnd_i",
":",
"number",
"of",
"windows",
... | train | https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/mtSet/core/splitter_bed.py#L41-L77 |
basilfx/flask-daapserver | daapserver/bonjour.py | Bonjour.publish | def publish(self, daap_server, preferred_database=None):
"""
Publish a given `DAAPServer` instance.
The given instances should be fully configured, including the provider.
By default Zeroconf only advertises the first database, but the DAAP
protocol has support for multiple data... | python | def publish(self, daap_server, preferred_database=None):
"""
Publish a given `DAAPServer` instance.
The given instances should be fully configured, including the provider.
By default Zeroconf only advertises the first database, but the DAAP
protocol has support for multiple data... | [
"def",
"publish",
"(",
"self",
",",
"daap_server",
",",
"preferred_database",
"=",
"None",
")",
":",
"if",
"daap_server",
"in",
"self",
".",
"daap_servers",
":",
"self",
".",
"unpublish",
"(",
"daap_server",
")",
"# Zeroconf can advertise the information for one dat... | Publish a given `DAAPServer` instance.
The given instances should be fully configured, including the provider.
By default Zeroconf only advertises the first database, but the DAAP
protocol has support for multiple databases. Therefore, the parameter
`preferred_database` can be set to ch... | [
"Publish",
"a",
"given",
"DAAPServer",
"instance",
"."
] | train | https://github.com/basilfx/flask-daapserver/blob/ca595fcbc5b657cba826eccd3be5cebba0a1db0e/daapserver/bonjour.py#L21-L101 |
basilfx/flask-daapserver | daapserver/bonjour.py | Bonjour.unpublish | def unpublish(self, daap_server):
"""
Unpublish a given server.
If the server was not published, this method will not do anything.
:param DAAPServer daap_server: DAAP Server instance to publish.
"""
if daap_server not in self.daap_servers:
return
s... | python | def unpublish(self, daap_server):
"""
Unpublish a given server.
If the server was not published, this method will not do anything.
:param DAAPServer daap_server: DAAP Server instance to publish.
"""
if daap_server not in self.daap_servers:
return
s... | [
"def",
"unpublish",
"(",
"self",
",",
"daap_server",
")",
":",
"if",
"daap_server",
"not",
"in",
"self",
".",
"daap_servers",
":",
"return",
"self",
".",
"zeroconf",
".",
"unregister_service",
"(",
"self",
".",
"daap_servers",
"[",
"daap_server",
"]",
")",
... | Unpublish a given server.
If the server was not published, this method will not do anything.
:param DAAPServer daap_server: DAAP Server instance to publish. | [
"Unpublish",
"a",
"given",
"server",
"."
] | train | https://github.com/basilfx/flask-daapserver/blob/ca595fcbc5b657cba826eccd3be5cebba0a1db0e/daapserver/bonjour.py#L103-L117 |
PMBio/limix-backup | limix/varDecomp/varianceDecomposition.py | VarianceDecomposition.addRandomEffect | def addRandomEffect(self, K=None, is_noise=False, normalize=False, Kcross=None, trait_covar_type='freeform', rank=1, fixed_trait_covar=None, jitter=1e-4):
"""
Add random effects term.
Args:
K: Sample Covariance Matrix [N, N]
is_noise: Boolean indicator specifying ... | python | def addRandomEffect(self, K=None, is_noise=False, normalize=False, Kcross=None, trait_covar_type='freeform', rank=1, fixed_trait_covar=None, jitter=1e-4):
"""
Add random effects term.
Args:
K: Sample Covariance Matrix [N, N]
is_noise: Boolean indicator specifying ... | [
"def",
"addRandomEffect",
"(",
"self",
",",
"K",
"=",
"None",
",",
"is_noise",
"=",
"False",
",",
"normalize",
"=",
"False",
",",
"Kcross",
"=",
"None",
",",
"trait_covar_type",
"=",
"'freeform'",
",",
"rank",
"=",
"1",
",",
"fixed_trait_covar",
"=",
"No... | Add random effects term.
Args:
K: Sample Covariance Matrix [N, N]
is_noise: Boolean indicator specifying if the matrix is homoscedastic noise (weighted identity covariance) (default False)
normalize: Boolean indicator specifying if K has to be normalized such that K.... | [
"Add",
"random",
"effects",
"term",
"."
] | train | https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/varDecomp/varianceDecomposition.py#L123-L174 |
PMBio/limix-backup | limix/varDecomp/varianceDecomposition.py | VarianceDecomposition.addFixedEffect | def addFixedEffect(self, F=None, A=None, Ftest=None):
"""
add fixed effect term to the model
Args:
F: sample design matrix for the fixed effect [N,K]
A: trait design matrix for the fixed effect (e.g. sp.ones((1,P)) common effect; sp.eye(P) any effect) [L,P]
... | python | def addFixedEffect(self, F=None, A=None, Ftest=None):
"""
add fixed effect term to the model
Args:
F: sample design matrix for the fixed effect [N,K]
A: trait design matrix for the fixed effect (e.g. sp.ones((1,P)) common effect; sp.eye(P) any effect) [L,P]
... | [
"def",
"addFixedEffect",
"(",
"self",
",",
"F",
"=",
"None",
",",
"A",
"=",
"None",
",",
"Ftest",
"=",
"None",
")",
":",
"if",
"A",
"is",
"None",
":",
"A",
"=",
"sp",
".",
"eye",
"(",
"self",
".",
"P",
")",
"if",
"F",
"is",
"None",
":",
"F"... | add fixed effect term to the model
Args:
F: sample design matrix for the fixed effect [N,K]
A: trait design matrix for the fixed effect (e.g. sp.ones((1,P)) common effect; sp.eye(P) any effect) [L,P]
Ftest: sample design matrix for test samples [Ntest,K] | [
"add",
"fixed",
"effect",
"term",
"to",
"the",
"model"
] | train | https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/varDecomp/varianceDecomposition.py#L176-L205 |
PMBio/limix-backup | limix/varDecomp/varianceDecomposition.py | VarianceDecomposition.optimize | def optimize(self, init_method='default', inference=None, n_times=10, perturb=False, pertSize=1e-3, verbose=None):
"""
Train the model using the specified initialization strategy
Args:
init_method: initialization strategy:
'default': variance is eq... | python | def optimize(self, init_method='default', inference=None, n_times=10, perturb=False, pertSize=1e-3, verbose=None):
"""
Train the model using the specified initialization strategy
Args:
init_method: initialization strategy:
'default': variance is eq... | [
"def",
"optimize",
"(",
"self",
",",
"init_method",
"=",
"'default'",
",",
"inference",
"=",
"None",
",",
"n_times",
"=",
"10",
",",
"perturb",
"=",
"False",
",",
"pertSize",
"=",
"1e-3",
",",
"verbose",
"=",
"None",
")",
":",
"#verbose = dlimix.getVerbose... | Train the model using the specified initialization strategy
Args:
init_method: initialization strategy:
'default': variance is equally split across the different random effect terms. For mulit-trait models the empirical covariance between traits is used
... | [
"Train",
"the",
"model",
"using",
"the",
"specified",
"initialization",
"strategy"
] | train | https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/varDecomp/varianceDecomposition.py#L208-L255 |
PMBio/limix-backup | limix/varDecomp/varianceDecomposition.py | VarianceDecomposition.getWeights | def getWeights(self, term_i=None):
"""
Return weights for fixed effect term term_i
Args:
term_i: fixed effect term index
Returns:
weights of the spefied fixed effect term.
The output will be a KxL matrix of weights will be returned,
wh... | python | def getWeights(self, term_i=None):
"""
Return weights for fixed effect term term_i
Args:
term_i: fixed effect term index
Returns:
weights of the spefied fixed effect term.
The output will be a KxL matrix of weights will be returned,
wh... | [
"def",
"getWeights",
"(",
"self",
",",
"term_i",
"=",
"None",
")",
":",
"assert",
"self",
".",
"init",
",",
"'GP not initialised'",
"if",
"term_i",
"==",
"None",
":",
"if",
"self",
".",
"gp",
".",
"mean",
".",
"n_terms",
"==",
"1",
":",
"term_i",
"="... | Return weights for fixed effect term term_i
Args:
term_i: fixed effect term index
Returns:
weights of the spefied fixed effect term.
The output will be a KxL matrix of weights will be returned,
where K is F.shape[1] and L is A.shape[1] of the correspo... | [
"Return",
"weights",
"for",
"fixed",
"effect",
"term",
"term_i"
] | train | https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/varDecomp/varianceDecomposition.py#L273-L291 |
PMBio/limix-backup | limix/varDecomp/varianceDecomposition.py | VarianceDecomposition.getTraitCovar | def getTraitCovar(self, term_i=None):
"""
Return the estimated trait covariance matrix for term_i (or the total if term_i is None)
To retrieve the matrix of correlation coefficient use \see getTraitCorrCoef
Args:
term_i: index of the random effect term we want to ret... | python | def getTraitCovar(self, term_i=None):
"""
Return the estimated trait covariance matrix for term_i (or the total if term_i is None)
To retrieve the matrix of correlation coefficient use \see getTraitCorrCoef
Args:
term_i: index of the random effect term we want to ret... | [
"def",
"getTraitCovar",
"(",
"self",
",",
"term_i",
"=",
"None",
")",
":",
"assert",
"term_i",
"<",
"self",
".",
"n_randEffs",
",",
"'VarianceDecomposition:: specied term out of range'",
"if",
"term_i",
"is",
"None",
":",
"RV",
"=",
"sp",
".",
"zeros",
"(",
... | Return the estimated trait covariance matrix for term_i (or the total if term_i is None)
To retrieve the matrix of correlation coefficient use \see getTraitCorrCoef
Args:
term_i: index of the random effect term we want to retrieve the covariance matrix
Returns:
e... | [
"Return",
"the",
"estimated",
"trait",
"covariance",
"matrix",
"for",
"term_i",
"(",
"or",
"the",
"total",
"if",
"term_i",
"is",
"None",
")",
"To",
"retrieve",
"the",
"matrix",
"of",
"correlation",
"coefficient",
"use",
"\\",
"see",
"getTraitCorrCoef"
] | train | https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/varDecomp/varianceDecomposition.py#L306-L325 |
PMBio/limix-backup | limix/varDecomp/varianceDecomposition.py | VarianceDecomposition.getTraitCorrCoef | def getTraitCorrCoef(self,term_i=None):
"""
Return the estimated trait correlation coefficient matrix for term_i (or the total if term_i is None)
To retrieve the trait covariance matrix use \see getTraitCovar
Args:
term_i: index of the random effect term we want to r... | python | def getTraitCorrCoef(self,term_i=None):
"""
Return the estimated trait correlation coefficient matrix for term_i (or the total if term_i is None)
To retrieve the trait covariance matrix use \see getTraitCovar
Args:
term_i: index of the random effect term we want to r... | [
"def",
"getTraitCorrCoef",
"(",
"self",
",",
"term_i",
"=",
"None",
")",
":",
"cov",
"=",
"self",
".",
"getTraitCovar",
"(",
"term_i",
")",
"stds",
"=",
"sp",
".",
"sqrt",
"(",
"cov",
".",
"diagonal",
"(",
")",
")",
"[",
":",
",",
"sp",
".",
"new... | Return the estimated trait correlation coefficient matrix for term_i (or the total if term_i is None)
To retrieve the trait covariance matrix use \see getTraitCovar
Args:
term_i: index of the random effect term we want to retrieve the correlation coefficients
Returns:
... | [
"Return",
"the",
"estimated",
"trait",
"correlation",
"coefficient",
"matrix",
"for",
"term_i",
"(",
"or",
"the",
"total",
"if",
"term_i",
"is",
"None",
")",
"To",
"retrieve",
"the",
"trait",
"covariance",
"matrix",
"use",
"\\",
"see",
"getTraitCovar"
] | train | https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/varDecomp/varianceDecomposition.py#L328-L341 |
PMBio/limix-backup | limix/varDecomp/varianceDecomposition.py | VarianceDecomposition.getVarianceComps | def getVarianceComps(self, univariance=False):
"""
Return the estimated variance components
Args:
univariance: Boolean indicator, if True variance components are normalized to sum up to 1 for each trait
Returns:
variance components of all random effects on all ... | python | def getVarianceComps(self, univariance=False):
"""
Return the estimated variance components
Args:
univariance: Boolean indicator, if True variance components are normalized to sum up to 1 for each trait
Returns:
variance components of all random effects on all ... | [
"def",
"getVarianceComps",
"(",
"self",
",",
"univariance",
"=",
"False",
")",
":",
"RV",
"=",
"sp",
".",
"zeros",
"(",
"(",
"self",
".",
"P",
",",
"self",
".",
"n_randEffs",
")",
")",
"for",
"term_i",
"in",
"range",
"(",
"self",
".",
"n_randEffs",
... | Return the estimated variance components
Args:
univariance: Boolean indicator, if True variance components are normalized to sum up to 1 for each trait
Returns:
variance components of all random effects on all phenotypes [P, n_randEffs matrix] | [
"Return",
"the",
"estimated",
"variance",
"components"
] | train | https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/varDecomp/varianceDecomposition.py#L344-L358 |
PMBio/limix-backup | limix/varDecomp/varianceDecomposition.py | VarianceDecomposition._init_params_default | def _init_params_default(self):
"""
Internal method for default parameter initialization
"""
# if there are some nan -> mean impute
Yimp = self.Y.copy()
Inan = sp.isnan(Yimp)
Yimp[Inan] = Yimp[~Inan].mean()
if self.P==1: C = sp.array([[Yimp.var()]])
... | python | def _init_params_default(self):
"""
Internal method for default parameter initialization
"""
# if there are some nan -> mean impute
Yimp = self.Y.copy()
Inan = sp.isnan(Yimp)
Yimp[Inan] = Yimp[~Inan].mean()
if self.P==1: C = sp.array([[Yimp.var()]])
... | [
"def",
"_init_params_default",
"(",
"self",
")",
":",
"# if there are some nan -> mean impute",
"Yimp",
"=",
"self",
".",
"Y",
".",
"copy",
"(",
")",
"Inan",
"=",
"sp",
".",
"isnan",
"(",
"Yimp",
")",
"Yimp",
"[",
"Inan",
"]",
"=",
"Yimp",
"[",
"~",
"I... | Internal method for default parameter initialization | [
"Internal",
"method",
"for",
"default",
"parameter",
"initialization"
] | train | https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/varDecomp/varianceDecomposition.py#L371-L383 |
PMBio/limix-backup | limix/varDecomp/varianceDecomposition.py | VarianceDecomposition._det_inference | def _det_inference(self):
"""
Internal method for determining the inference method
"""
# 2 random effects with complete design -> gp2KronSum
# TODO: add check for low-rankness, use GP3KronSumLR and GP2KronSumLR when possible
if (self.n_randEffs==2) and (~sp.isnan(self.Y).... | python | def _det_inference(self):
"""
Internal method for determining the inference method
"""
# 2 random effects with complete design -> gp2KronSum
# TODO: add check for low-rankness, use GP3KronSumLR and GP2KronSumLR when possible
if (self.n_randEffs==2) and (~sp.isnan(self.Y).... | [
"def",
"_det_inference",
"(",
"self",
")",
":",
"# 2 random effects with complete design -> gp2KronSum",
"# TODO: add check for low-rankness, use GP3KronSumLR and GP2KronSumLR when possible",
"if",
"(",
"self",
".",
"n_randEffs",
"==",
"2",
")",
"and",
"(",
"~",
"sp",
".",
... | Internal method for determining the inference method | [
"Internal",
"method",
"for",
"determining",
"the",
"inference",
"method"
] | train | https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/varDecomp/varianceDecomposition.py#L385-L395 |
PMBio/limix-backup | limix/varDecomp/varianceDecomposition.py | VarianceDecomposition._check_inference | def _check_inference(self, inference):
"""
Internal method for checking that the selected inference scheme is compatible with the specified model
"""
if inference=='GP2KronSum':
assert self.n_randEffs==2, 'VarianceDecomposition: for fast inference number of random effect term... | python | def _check_inference(self, inference):
"""
Internal method for checking that the selected inference scheme is compatible with the specified model
"""
if inference=='GP2KronSum':
assert self.n_randEffs==2, 'VarianceDecomposition: for fast inference number of random effect term... | [
"def",
"_check_inference",
"(",
"self",
",",
"inference",
")",
":",
"if",
"inference",
"==",
"'GP2KronSum'",
":",
"assert",
"self",
".",
"n_randEffs",
"==",
"2",
",",
"'VarianceDecomposition: for fast inference number of random effect terms must be == 2'",
"assert",
"not"... | Internal method for checking that the selected inference scheme is compatible with the specified model | [
"Internal",
"method",
"for",
"checking",
"that",
"the",
"selected",
"inference",
"scheme",
"is",
"compatible",
"with",
"the",
"specified",
"model"
] | train | https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/varDecomp/varianceDecomposition.py#L397-L403 |
PMBio/limix-backup | limix/varDecomp/varianceDecomposition.py | VarianceDecomposition._initGP | def _initGP(self):
"""
Internal method for initialization of the GP inference objetct
"""
if self._inference=='GP2KronSum':
signalPos = sp.where(sp.arange(self.n_randEffs)!=self.noisPos)[0][0]
gp = GP2KronSum(Y=self.Y, F=self.sample_designs, A=self.trait_designs,... | python | def _initGP(self):
"""
Internal method for initialization of the GP inference objetct
"""
if self._inference=='GP2KronSum':
signalPos = sp.where(sp.arange(self.n_randEffs)!=self.noisPos)[0][0]
gp = GP2KronSum(Y=self.Y, F=self.sample_designs, A=self.trait_designs,... | [
"def",
"_initGP",
"(",
"self",
")",
":",
"if",
"self",
".",
"_inference",
"==",
"'GP2KronSum'",
":",
"signalPos",
"=",
"sp",
".",
"where",
"(",
"sp",
".",
"arange",
"(",
"self",
".",
"n_randEffs",
")",
"!=",
"self",
".",
"noisPos",
")",
"[",
"0",
"... | Internal method for initialization of the GP inference objetct | [
"Internal",
"method",
"for",
"initialization",
"of",
"the",
"GP",
"inference",
"objetct"
] | train | https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/varDecomp/varianceDecomposition.py#L407-L422 |
PMBio/limix-backup | limix/varDecomp/varianceDecomposition.py | VarianceDecomposition._buildTraitCovar | def _buildTraitCovar(self, trait_covar_type='freeform', rank=1, fixed_trait_covar=None, jitter=1e-4):
"""
Internal functions that builds the trait covariance matrix using the LIMIX framework
Args:
trait_covar_type: type of covaraince to use. Default 'freeform'. possible values are
... | python | def _buildTraitCovar(self, trait_covar_type='freeform', rank=1, fixed_trait_covar=None, jitter=1e-4):
"""
Internal functions that builds the trait covariance matrix using the LIMIX framework
Args:
trait_covar_type: type of covaraince to use. Default 'freeform'. possible values are
... | [
"def",
"_buildTraitCovar",
"(",
"self",
",",
"trait_covar_type",
"=",
"'freeform'",
",",
"rank",
"=",
"1",
",",
"fixed_trait_covar",
"=",
"None",
",",
"jitter",
"=",
"1e-4",
")",
":",
"assert",
"trait_covar_type",
"in",
"[",
"'freeform'",
",",
"'diag'",
",",... | Internal functions that builds the trait covariance matrix using the LIMIX framework
Args:
trait_covar_type: type of covaraince to use. Default 'freeform'. possible values are
rank: rank of a possible lowrank component (default 1)
fixed_trait_covar: PxP matr... | [
"Internal",
"functions",
"that",
"builds",
"the",
"trait",
"covariance",
"matrix",
"using",
"the",
"LIMIX",
"framework"
] | train | https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/varDecomp/varianceDecomposition.py#L425-L464 |
PMBio/limix-backup | limix/varDecomp/varianceDecomposition.py | VarianceDecomposition.optimize_with_repeates | def optimize_with_repeates(self,fast=None,verbose=None,n_times=10,lambd=None,lambd_g=None,lambd_n=None):
"""
Train the model repeadly up to a number specified by the users with random restarts and
return a list of all relative minima that have been found. This list is sorted according to
... | python | def optimize_with_repeates(self,fast=None,verbose=None,n_times=10,lambd=None,lambd_g=None,lambd_n=None):
"""
Train the model repeadly up to a number specified by the users with random restarts and
return a list of all relative minima that have been found. This list is sorted according to
... | [
"def",
"optimize_with_repeates",
"(",
"self",
",",
"fast",
"=",
"None",
",",
"verbose",
"=",
"None",
",",
"n_times",
"=",
"10",
",",
"lambd",
"=",
"None",
",",
"lambd_g",
"=",
"None",
",",
"lambd_n",
"=",
"None",
")",
":",
"verbose",
"=",
"dlimix",
"... | Train the model repeadly up to a number specified by the users with random restarts and
return a list of all relative minima that have been found. This list is sorted according to
least likelihood. Each list term is a dictionary with keys "counter", "LML", and "scales".
After running this funct... | [
"Train",
"the",
"model",
"repeadly",
"up",
"to",
"a",
"number",
"specified",
"by",
"the",
"users",
"with",
"random",
"restarts",
"and",
"return",
"a",
"list",
"of",
"all",
"relative",
"minima",
"that",
"have",
"been",
"found",
".",
"This",
"list",
"is",
... | train | https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/varDecomp/varianceDecomposition.py#L472-L534 |
PMBio/limix-backup | limix/varDecomp/varianceDecomposition.py | VarianceDecomposition.getTraitCovarStdErrors | def getTraitCovarStdErrors(self,term_i):
"""
Returns standard errors on trait covariances from term_i (for the covariance estimate \see getTraitCovar)
Args:
term_i: index of the term we are interested in
"""
assert self.init, 'GP not initialised'
a... | python | def getTraitCovarStdErrors(self,term_i):
"""
Returns standard errors on trait covariances from term_i (for the covariance estimate \see getTraitCovar)
Args:
term_i: index of the term we are interested in
"""
assert self.init, 'GP not initialised'
a... | [
"def",
"getTraitCovarStdErrors",
"(",
"self",
",",
"term_i",
")",
":",
"assert",
"self",
".",
"init",
",",
"'GP not initialised'",
"assert",
"self",
".",
"fast",
"==",
"False",
",",
"'Not supported for fast implementation'",
"if",
"self",
".",
"P",
"==",
"1",
... | Returns standard errors on trait covariances from term_i (for the covariance estimate \see getTraitCovar)
Args:
term_i: index of the term we are interested in | [
"Returns",
"standard",
"errors",
"on",
"trait",
"covariances",
"from",
"term_i",
"(",
"for",
"the",
"covariance",
"estimate",
"\\",
"see",
"getTraitCovar",
")"
] | train | https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/varDecomp/varianceDecomposition.py#L538-L563 |
PMBio/limix-backup | limix/varDecomp/varianceDecomposition.py | VarianceDecomposition.getVarianceCompStdErrors | def getVarianceCompStdErrors(self,univariance=False):
"""
Return the standard errors on the estimated variance components (for variance component estimates \see getVarianceComps)
Args:
univariance: Boolean indicator, if True variance components are normalized to sum up to 1 for ea... | python | def getVarianceCompStdErrors(self,univariance=False):
"""
Return the standard errors on the estimated variance components (for variance component estimates \see getVarianceComps)
Args:
univariance: Boolean indicator, if True variance components are normalized to sum up to 1 for ea... | [
"def",
"getVarianceCompStdErrors",
"(",
"self",
",",
"univariance",
"=",
"False",
")",
":",
"RV",
"=",
"sp",
".",
"zeros",
"(",
"(",
"self",
".",
"P",
",",
"self",
".",
"n_randEffs",
")",
")",
"for",
"term_i",
"in",
"range",
"(",
"self",
".",
"n_rand... | Return the standard errors on the estimated variance components (for variance component estimates \see getVarianceComps)
Args:
univariance: Boolean indicator, if True variance components are normalized to sum up to 1 for each trait
Returns:
standard errors on variance componen... | [
"Return",
"the",
"standard",
"errors",
"on",
"the",
"estimated",
"variance",
"components",
"(",
"for",
"variance",
"component",
"estimates",
"\\",
"see",
"getVarianceComps",
")"
] | train | https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/varDecomp/varianceDecomposition.py#L565-L581 |
PMBio/limix-backup | limix/varDecomp/varianceDecomposition.py | VarianceDecomposition.predictPhenos | def predictPhenos(self,use_fixed=None,use_random=None):
"""
predict the conditional mean (BLUP)
Args:
use_fixed: list of fixed effect indeces to use for predictions
use_random: list of random effect indeces to use for predictions
Returns:
... | python | def predictPhenos(self,use_fixed=None,use_random=None):
"""
predict the conditional mean (BLUP)
Args:
use_fixed: list of fixed effect indeces to use for predictions
use_random: list of random effect indeces to use for predictions
Returns:
... | [
"def",
"predictPhenos",
"(",
"self",
",",
"use_fixed",
"=",
"None",
",",
"use_random",
"=",
"None",
")",
":",
"assert",
"self",
".",
"noisPos",
"is",
"not",
"None",
",",
"'No noise element'",
"assert",
"self",
".",
"init",
",",
"'GP not initialised'",
"asser... | predict the conditional mean (BLUP)
Args:
use_fixed: list of fixed effect indeces to use for predictions
use_random: list of random effect indeces to use for predictions
Returns:
predictions (BLUP) | [
"predict",
"the",
"conditional",
"mean",
"(",
"BLUP",
")"
] | train | https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/varDecomp/varianceDecomposition.py#L586-L641 |
PMBio/limix-backup | limix/varDecomp/varianceDecomposition.py | VarianceDecomposition.crossValidation | def crossValidation(self,seed=0,n_folds=10,fullVector=True,verbose=None,D=None,**keywords):
"""
Split the dataset in n folds, predict each fold after training the model on all the others
Args:
seed: seed
n_folds: number of folds to train the model on
... | python | def crossValidation(self,seed=0,n_folds=10,fullVector=True,verbose=None,D=None,**keywords):
"""
Split the dataset in n folds, predict each fold after training the model on all the others
Args:
seed: seed
n_folds: number of folds to train the model on
... | [
"def",
"crossValidation",
"(",
"self",
",",
"seed",
"=",
"0",
",",
"n_folds",
"=",
"10",
",",
"fullVector",
"=",
"True",
",",
"verbose",
"=",
"None",
",",
"D",
"=",
"None",
",",
"*",
"*",
"keywords",
")",
":",
"verbose",
"=",
"dlimix",
".",
"getVer... | Split the dataset in n folds, predict each fold after training the model on all the others
Args:
seed: seed
n_folds: number of folds to train the model on
fullVector: Bolean indicator, if true it stops if no convergence is observed for one of the folds, otherwise... | [
"Split",
"the",
"dataset",
"in",
"n",
"folds",
"predict",
"each",
"fold",
"after",
"training",
"the",
"model",
"on",
"all",
"the",
"others"
] | train | https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/varDecomp/varianceDecomposition.py#L644-L726 |
PMBio/limix-backup | limix/varDecomp/varianceDecomposition.py | VarianceDecomposition._getH2singleTrait | def _getH2singleTrait(self, K, verbose=None):
"""
Internal function for parameter initialization
estimate variance components and fixed effect using a linear mixed model with an intercept and 2 random effects (one is noise)
Args:
K: covariance matrix of the non-noise r... | python | def _getH2singleTrait(self, K, verbose=None):
"""
Internal function for parameter initialization
estimate variance components and fixed effect using a linear mixed model with an intercept and 2 random effects (one is noise)
Args:
K: covariance matrix of the non-noise r... | [
"def",
"_getH2singleTrait",
"(",
"self",
",",
"K",
",",
"verbose",
"=",
"None",
")",
":",
"verbose",
"=",
"dlimix",
".",
"getVerbose",
"(",
"verbose",
")",
"# Fit single trait model",
"varg",
"=",
"sp",
".",
"zeros",
"(",
"self",
".",
"P",
")",
"varn",
... | Internal function for parameter initialization
estimate variance components and fixed effect using a linear mixed model with an intercept and 2 random effects (one is noise)
Args:
K: covariance matrix of the non-noise random effect term | [
"Internal",
"function",
"for",
"parameter",
"initialization",
"estimate",
"variance",
"components",
"and",
"fixed",
"effect",
"using",
"a",
"linear",
"mixed",
"model",
"with",
"an",
"intercept",
"and",
"2",
"random",
"effects",
"(",
"one",
"is",
"noise",
")",
... | train | https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/varDecomp/varianceDecomposition.py#L731-L774 |
PMBio/limix-backup | limix/varDecomp/varianceDecomposition.py | VarianceDecomposition._getScalesDiag | def _getScalesDiag(self,termx=0):
"""
Internal function for parameter initialization
Uses 2 term single trait model to get covar params for initialization
Args:
termx: non-noise term terms that is used for initialization
"""
assert self.P>1, 'VarianceDec... | python | def _getScalesDiag(self,termx=0):
"""
Internal function for parameter initialization
Uses 2 term single trait model to get covar params for initialization
Args:
termx: non-noise term terms that is used for initialization
"""
assert self.P>1, 'VarianceDec... | [
"def",
"_getScalesDiag",
"(",
"self",
",",
"termx",
"=",
"0",
")",
":",
"assert",
"self",
".",
"P",
">",
"1",
",",
"'VarianceDecomposition:: diagonal init_method allowed only for multi trait models'",
"assert",
"self",
".",
"noisPos",
"is",
"not",
"None",
",",
"'V... | Internal function for parameter initialization
Uses 2 term single trait model to get covar params for initialization
Args:
termx: non-noise term terms that is used for initialization | [
"Internal",
"function",
"for",
"parameter",
"initialization",
"Uses",
"2",
"term",
"single",
"trait",
"model",
"to",
"get",
"covar",
"params",
"for",
"initialization"
] | train | https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/varDecomp/varianceDecomposition.py#L776-L803 |
PMBio/limix-backup | limix/varDecomp/varianceDecomposition.py | VarianceDecomposition._getScalesPairwise | def _getScalesPairwise(self,verbose=False, initDiagonal=False):
"""
Internal function for parameter initialization
Uses a single trait model for initializing variances and
a pairwise model to initialize correlations
"""
var = sp.zeros((self.P,2))
if initDiagonal:... | python | def _getScalesPairwise(self,verbose=False, initDiagonal=False):
"""
Internal function for parameter initialization
Uses a single trait model for initializing variances and
a pairwise model to initialize correlations
"""
var = sp.zeros((self.P,2))
if initDiagonal:... | [
"def",
"_getScalesPairwise",
"(",
"self",
",",
"verbose",
"=",
"False",
",",
"initDiagonal",
"=",
"False",
")",
":",
"var",
"=",
"sp",
".",
"zeros",
"(",
"(",
"self",
".",
"P",
",",
"2",
")",
")",
"if",
"initDiagonal",
":",
"#1. fit single trait model",
... | Internal function for parameter initialization
Uses a single trait model for initializing variances and
a pairwise model to initialize correlations | [
"Internal",
"function",
"for",
"parameter",
"initialization",
"Uses",
"a",
"single",
"trait",
"model",
"for",
"initializing",
"variances",
"and",
"a",
"pairwise",
"model",
"to",
"initialize",
"correlations"
] | train | https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/varDecomp/varianceDecomposition.py#L805-L897 |
PMBio/limix-backup | limix/varDecomp/varianceDecomposition.py | VarianceDecomposition._getScalesRand | def _getScalesRand(self):
"""
Internal function for parameter initialization
Return a vector of random scales
"""
if self.P>1:
scales = []
for term_i in range(self.n_randEffs):
_scales = sp.randn(self.diag[term_i].shape[0])
... | python | def _getScalesRand(self):
"""
Internal function for parameter initialization
Return a vector of random scales
"""
if self.P>1:
scales = []
for term_i in range(self.n_randEffs):
_scales = sp.randn(self.diag[term_i].shape[0])
... | [
"def",
"_getScalesRand",
"(",
"self",
")",
":",
"if",
"self",
".",
"P",
">",
"1",
":",
"scales",
"=",
"[",
"]",
"for",
"term_i",
"in",
"range",
"(",
"self",
".",
"n_randEffs",
")",
":",
"_scales",
"=",
"sp",
".",
"randn",
"(",
"self",
".",
"diag"... | Internal function for parameter initialization
Return a vector of random scales | [
"Internal",
"function",
"for",
"parameter",
"initialization",
"Return",
"a",
"vector",
"of",
"random",
"scales"
] | train | https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/varDecomp/varianceDecomposition.py#L900-L915 |
PMBio/limix-backup | limix/varDecomp/varianceDecomposition.py | VarianceDecomposition._perturbation | def _perturbation(self):
"""
Internal function for parameter initialization
Returns Gaussian perturbation
"""
if self.P>1:
scales = []
for term_i in range(self.n_randEffs):
_scales = sp.randn(self.diag[term_i].shape[0])
if s... | python | def _perturbation(self):
"""
Internal function for parameter initialization
Returns Gaussian perturbation
"""
if self.P>1:
scales = []
for term_i in range(self.n_randEffs):
_scales = sp.randn(self.diag[term_i].shape[0])
if s... | [
"def",
"_perturbation",
"(",
"self",
")",
":",
"if",
"self",
".",
"P",
">",
"1",
":",
"scales",
"=",
"[",
"]",
"for",
"term_i",
"in",
"range",
"(",
"self",
".",
"n_randEffs",
")",
":",
"_scales",
"=",
"sp",
".",
"randn",
"(",
"self",
".",
"diag",... | Internal function for parameter initialization
Returns Gaussian perturbation | [
"Internal",
"function",
"for",
"parameter",
"initialization",
"Returns",
"Gaussian",
"perturbation"
] | train | https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/varDecomp/varianceDecomposition.py#L917-L932 |
PMBio/limix-backup | limix/varDecomp/varianceDecomposition.py | VarianceDecomposition._getHessian | def _getHessian(self):
"""
Internal function for estimating parameter uncertainty
COMPUTES OF HESSIAN OF E(\theta) = - log L(\theta | X, y)
"""
assert self.init, 'GP not initialised'
assert self.fast==False, 'Not supported for fast implementation'
if self.... | python | def _getHessian(self):
"""
Internal function for estimating parameter uncertainty
COMPUTES OF HESSIAN OF E(\theta) = - log L(\theta | X, y)
"""
assert self.init, 'GP not initialised'
assert self.fast==False, 'Not supported for fast implementation'
if self.... | [
"def",
"_getHessian",
"(",
"self",
")",
":",
"assert",
"self",
".",
"init",
",",
"'GP not initialised'",
"assert",
"self",
".",
"fast",
"==",
"False",
",",
"'Not supported for fast implementation'",
"if",
"self",
".",
"cache",
"[",
"'Hessian'",
"]",
"is",
"Non... | Internal function for estimating parameter uncertainty
COMPUTES OF HESSIAN OF E(\theta) = - log L(\theta | X, y) | [
"Internal",
"function",
"for",
"estimating",
"parameter",
"uncertainty",
"COMPUTES",
"OF",
"HESSIAN",
"OF",
"E",
"(",
"\\",
"theta",
")",
"=",
"-",
"log",
"L",
"(",
"\\",
"theta",
"|",
"X",
"y",
")"
] | train | https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/varDecomp/varianceDecomposition.py#L936-L951 |
PMBio/limix-backup | limix/varDecomp/varianceDecomposition.py | VarianceDecomposition._getLaplaceCovar | def _getLaplaceCovar(self):
"""
Internal function for estimating parameter uncertainty
Returns:
the
"""
assert self.init, 'GP not initialised'
assert self.fast==False, 'Not supported for fast implementation'
if self.cache['Sigma'] is None:
... | python | def _getLaplaceCovar(self):
"""
Internal function for estimating parameter uncertainty
Returns:
the
"""
assert self.init, 'GP not initialised'
assert self.fast==False, 'Not supported for fast implementation'
if self.cache['Sigma'] is None:
... | [
"def",
"_getLaplaceCovar",
"(",
"self",
")",
":",
"assert",
"self",
".",
"init",
",",
"'GP not initialised'",
"assert",
"self",
".",
"fast",
"==",
"False",
",",
"'Not supported for fast implementation'",
"if",
"self",
".",
"cache",
"[",
"'Sigma'",
"]",
"is",
"... | Internal function for estimating parameter uncertainty
Returns:
the | [
"Internal",
"function",
"for",
"estimating",
"parameter",
"uncertainty",
"Returns",
":",
"the"
] | train | https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/varDecomp/varianceDecomposition.py#L954-L965 |
PMBio/limix-backup | limix/varDecomp/varianceDecomposition.py | VarianceDecomposition._getModelPosterior | def _getModelPosterior(self,min):
"""
USES LAPLACE APPROXIMATION TO CALCULATE THE BAYESIAN MODEL POSTERIOR
"""
Sigma = self._getLaplaceCovar(min)
n_params = self.vd.getNumberScales()
ModCompl = 0.5*n_params*sp.log(2*sp.pi)+0.5*sp.log(sp.linalg.det(Sigma))
RV = min... | python | def _getModelPosterior(self,min):
"""
USES LAPLACE APPROXIMATION TO CALCULATE THE BAYESIAN MODEL POSTERIOR
"""
Sigma = self._getLaplaceCovar(min)
n_params = self.vd.getNumberScales()
ModCompl = 0.5*n_params*sp.log(2*sp.pi)+0.5*sp.log(sp.linalg.det(Sigma))
RV = min... | [
"def",
"_getModelPosterior",
"(",
"self",
",",
"min",
")",
":",
"Sigma",
"=",
"self",
".",
"_getLaplaceCovar",
"(",
"min",
")",
"n_params",
"=",
"self",
".",
"vd",
".",
"getNumberScales",
"(",
")",
"ModCompl",
"=",
"0.5",
"*",
"n_params",
"*",
"sp",
".... | USES LAPLACE APPROXIMATION TO CALCULATE THE BAYESIAN MODEL POSTERIOR | [
"USES",
"LAPLACE",
"APPROXIMATION",
"TO",
"CALCULATE",
"THE",
"BAYESIAN",
"MODEL",
"POSTERIOR"
] | train | https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/varDecomp/varianceDecomposition.py#L985-L993 |
wilzbach/smarkov | examples/text.py | join_tokens_to_sentences | def join_tokens_to_sentences(tokens):
""" Correctly joins tokens to multiple sentences
Instead of always placing white-space between the tokens, it will distinguish
between the next symbol and *not* insert whitespace if it is a sentence
symbol (e.g. '.', or '?')
Args:
tokens: array of stri... | python | def join_tokens_to_sentences(tokens):
""" Correctly joins tokens to multiple sentences
Instead of always placing white-space between the tokens, it will distinguish
between the next symbol and *not* insert whitespace if it is a sentence
symbol (e.g. '.', or '?')
Args:
tokens: array of stri... | [
"def",
"join_tokens_to_sentences",
"(",
"tokens",
")",
":",
"text",
"=",
"\"\"",
"for",
"(",
"entry",
",",
"next_entry",
")",
"in",
"zip",
"(",
"tokens",
",",
"tokens",
"[",
"1",
":",
"]",
")",
":",
"text",
"+=",
"entry",
"if",
"next_entry",
"not",
"... | Correctly joins tokens to multiple sentences
Instead of always placing white-space between the tokens, it will distinguish
between the next symbol and *not* insert whitespace if it is a sentence
symbol (e.g. '.', or '?')
Args:
tokens: array of string tokens
Returns:
Joint sentences... | [
"Correctly",
"joins",
"tokens",
"to",
"multiple",
"sentences"
] | train | https://github.com/wilzbach/smarkov/blob/c98c08cc432e18c5c87fb9a6e013b1b8eaa54d37/examples/text.py#L15-L34 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.