id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
5,500 | i3visio/osrframework | osrframework/utils/platforms.py | Platform._getAuthenticated | def _getAuthenticated(self, browser, url):
"""
Getting authenticated.
This method may be overwritten.
TODO: update to version 2 of the wrappers.
Args:
-----
browser: The browser in which the user will be authenticated.
url: The URL to get authen... | python | def _getAuthenticated(self, browser, url):
"""
Getting authenticated.
This method may be overwritten.
TODO: update to version 2 of the wrappers.
Args:
-----
browser: The browser in which the user will be authenticated.
url: The URL to get authen... | [
"def",
"_getAuthenticated",
"(",
"self",
",",
"browser",
",",
"url",
")",
":",
"# check if we have creds",
"try",
":",
"if",
"len",
"(",
"self",
".",
"creds",
")",
">",
"0",
":",
"# TODO: in choosing a cred there is an uneeded nesting of arrays",
"c",
"=",
"random... | Getting authenticated.
This method may be overwritten.
TODO: update to version 2 of the wrappers.
Args:
-----
browser: The browser in which the user will be authenticated.
url: The URL to get authenticated in.
Return:
-------
True o... | [
"Getting",
"authenticated",
"."
] | 83437f4c14c9c08cb80a896bd9834c77f6567871 | https://github.com/i3visio/osrframework/blob/83437f4c14c9c08cb80a896bd9834c77f6567871/osrframework/utils/platforms.py#L234-L267 |
5,501 | i3visio/osrframework | osrframework/utils/platforms.py | Platform._isValidQuery | def _isValidQuery(self, query, mode="phonefy"):
"""
Method to verify if a given query is processable by the platform.
The system looks for the forbidden characters in self.Forbidden list.
Args:
-----
query: The query to be launched.
mode: To be chosen am... | python | def _isValidQuery(self, query, mode="phonefy"):
"""
Method to verify if a given query is processable by the platform.
The system looks for the forbidden characters in self.Forbidden list.
Args:
-----
query: The query to be launched.
mode: To be chosen am... | [
"def",
"_isValidQuery",
"(",
"self",
",",
"query",
",",
"mode",
"=",
"\"phonefy\"",
")",
":",
"try",
":",
"# Suport for version 2 of wrappers",
"validator",
"=",
"self",
".",
"modes",
"[",
"mode",
"]",
".",
"get",
"(",
"\"query_validator\"",
")",
"if",
"vali... | Method to verify if a given query is processable by the platform.
The system looks for the forbidden characters in self.Forbidden list.
Args:
-----
query: The query to be launched.
mode: To be chosen amongst mailfy, phonefy, usufy, searchfy.
Return:
----... | [
"Method",
"to",
"verify",
"if",
"a",
"given",
"query",
"is",
"processable",
"by",
"the",
"platform",
"."
] | 83437f4c14c9c08cb80a896bd9834c77f6567871 | https://github.com/i3visio/osrframework/blob/83437f4c14c9c08cb80a896bd9834c77f6567871/osrframework/utils/platforms.py#L270-L301 |
5,502 | i3visio/osrframework | osrframework/utils/platforms.py | Platform._somethingFound | def _somethingFound(self, data, mode="phonefy"):
"""
Verifying if something was found.
Args:
-----
data: Data where the self.notFoundText will be searched.
mode: Mode to be executed.
Return:
-------
True if exists.
"""
... | python | def _somethingFound(self, data, mode="phonefy"):
"""
Verifying if something was found.
Args:
-----
data: Data where the self.notFoundText will be searched.
mode: Mode to be executed.
Return:
-------
True if exists.
"""
... | [
"def",
"_somethingFound",
"(",
"self",
",",
"data",
",",
"mode",
"=",
"\"phonefy\"",
")",
":",
"if",
"data",
":",
"try",
":",
"for",
"text",
"in",
"self",
".",
"notFoundText",
"[",
"mode",
"]",
":",
"if",
"text",
"in",
"data",
":",
"return",
"False",... | Verifying if something was found.
Args:
-----
data: Data where the self.notFoundText will be searched.
mode: Mode to be executed.
Return:
-------
True if exists. | [
"Verifying",
"if",
"something",
"was",
"found",
"."
] | 83437f4c14c9c08cb80a896bd9834c77f6567871 | https://github.com/i3visio/osrframework/blob/83437f4c14c9c08cb80a896bd9834c77f6567871/osrframework/utils/platforms.py#L304-L331 |
5,503 | i3visio/osrframework | osrframework/utils/platforms.py | Platform.do_phonefy | def do_phonefy(self, query, **kwargs):
"""
Verifying a phonefy query in this platform.
This might be redefined in any class inheriting from Platform.
Args:
-----
query: The element to be searched.
Return:
-------
A list of elements to be... | python | def do_phonefy(self, query, **kwargs):
"""
Verifying a phonefy query in this platform.
This might be redefined in any class inheriting from Platform.
Args:
-----
query: The element to be searched.
Return:
-------
A list of elements to be... | [
"def",
"do_phonefy",
"(",
"self",
",",
"query",
",",
"*",
"*",
"kwargs",
")",
":",
"results",
"=",
"[",
"]",
"test",
"=",
"self",
".",
"check_phonefy",
"(",
"query",
",",
"kwargs",
")",
"if",
"test",
":",
"r",
"=",
"{",
"\"type\"",
":",
"\"i3visio.... | Verifying a phonefy query in this platform.
This might be redefined in any class inheriting from Platform.
Args:
-----
query: The element to be searched.
Return:
-------
A list of elements to be appended. | [
"Verifying",
"a",
"phonefy",
"query",
"in",
"this",
"platform",
"."
] | 83437f4c14c9c08cb80a896bd9834c77f6567871 | https://github.com/i3visio/osrframework/blob/83437f4c14c9c08cb80a896bd9834c77f6567871/osrframework/utils/platforms.py#L541-L587 |
5,504 | i3visio/osrframework | osrframework/utils/platforms.py | Platform.process_usufy | def process_usufy(self, data):
"""
Method to process and extract the entities of a usufy
Args:
-----
data: The information from which the info will be extracted.
Return:
-------
A list of the entities found.
"""
mode ... | python | def process_usufy(self, data):
"""
Method to process and extract the entities of a usufy
Args:
-----
data: The information from which the info will be extracted.
Return:
-------
A list of the entities found.
"""
mode ... | [
"def",
"process_usufy",
"(",
"self",
",",
"data",
")",
":",
"mode",
"=",
"\"usufy\"",
"info",
"=",
"[",
"]",
"try",
":",
"# v2",
"verifier",
"=",
"self",
".",
"modes",
".",
"get",
"(",
"mode",
",",
"{",
"}",
")",
".",
"get",
"(",
"\"extra_fields\""... | Method to process and extract the entities of a usufy
Args:
-----
data: The information from which the info will be extracted.
Return:
-------
A list of the entities found. | [
"Method",
"to",
"process",
"and",
"extract",
"the",
"entities",
"of",
"a",
"usufy"
] | 83437f4c14c9c08cb80a896bd9834c77f6567871 | https://github.com/i3visio/osrframework/blob/83437f4c14c9c08cb80a896bd9834c77f6567871/osrframework/utils/platforms.py#L723-L783 |
5,505 | i3visio/osrframework | osrframework/utils/benchmark.py | doBenchmark | def doBenchmark(plats):
'''
Perform the benchmark...
'''
logger = logging.getLogger("osrframework.utils")
# defining the results dict
res = {}
# args
args = []
#for p in plats:
# args.append( (str(p),) )
# selecting the number of tries to be performed
tries = [1, 4, 8 ,16, 24, 32, 40, 48, 56, 64]
... | python | def doBenchmark(plats):
'''
Perform the benchmark...
'''
logger = logging.getLogger("osrframework.utils")
# defining the results dict
res = {}
# args
args = []
#for p in plats:
# args.append( (str(p),) )
# selecting the number of tries to be performed
tries = [1, 4, 8 ,16, 24, 32, 40, 48, 56, 64]
... | [
"def",
"doBenchmark",
"(",
"plats",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"\"osrframework.utils\"",
")",
"# defining the results dict",
"res",
"=",
"{",
"}",
"# args",
"args",
"=",
"[",
"]",
"#for p in plats:",
"#\targs.append( (str(p),) )",
"... | Perform the benchmark... | [
"Perform",
"the",
"benchmark",
"..."
] | 83437f4c14c9c08cb80a896bd9834c77f6567871 | https://github.com/i3visio/osrframework/blob/83437f4c14c9c08cb80a896bd9834c77f6567871/osrframework/utils/benchmark.py#L55-L90 |
5,506 | i3visio/osrframework | osrframework/utils/configuration.py | changePermissionsRecursively | def changePermissionsRecursively(path, uid, gid):
"""
Function to recursively change the user id and group id.
It sets 700 permissions.
"""
os.chown(path, uid, gid)
for item in os.listdir(path):
itempath = os.path.join(path, item)
if os.path.isfile(itempath):
# Setti... | python | def changePermissionsRecursively(path, uid, gid):
"""
Function to recursively change the user id and group id.
It sets 700 permissions.
"""
os.chown(path, uid, gid)
for item in os.listdir(path):
itempath = os.path.join(path, item)
if os.path.isfile(itempath):
# Setti... | [
"def",
"changePermissionsRecursively",
"(",
"path",
",",
"uid",
",",
"gid",
")",
":",
"os",
".",
"chown",
"(",
"path",
",",
"uid",
",",
"gid",
")",
"for",
"item",
"in",
"os",
".",
"listdir",
"(",
"path",
")",
":",
"itempath",
"=",
"os",
".",
"path"... | Function to recursively change the user id and group id.
It sets 700 permissions. | [
"Function",
"to",
"recursively",
"change",
"the",
"user",
"id",
"and",
"group",
"id",
"."
] | 83437f4c14c9c08cb80a896bd9834c77f6567871 | https://github.com/i3visio/osrframework/blob/83437f4c14c9c08cb80a896bd9834c77f6567871/osrframework/utils/configuration.py#L33-L63 |
5,507 | i3visio/osrframework | osrframework/utils/configuration.py | getConfigPath | def getConfigPath(configFileName = None):
"""
Auxiliar function to get the configuration paths depending on the system
Args:
-----
configFileName: TODO.
Returns:
--------
A dictionary with the following keys: appPath, appPathDefaults,
appPathTransforms, appPathPlugi... | python | def getConfigPath(configFileName = None):
"""
Auxiliar function to get the configuration paths depending on the system
Args:
-----
configFileName: TODO.
Returns:
--------
A dictionary with the following keys: appPath, appPathDefaults,
appPathTransforms, appPathPlugi... | [
"def",
"getConfigPath",
"(",
"configFileName",
"=",
"None",
")",
":",
"paths",
"=",
"{",
"}",
"applicationPath",
"=",
"\"./\"",
"# Returning the path of the configuration folder",
"if",
"sys",
".",
"platform",
"==",
"'win32'",
":",
"applicationPath",
"=",
"os",
".... | Auxiliar function to get the configuration paths depending on the system
Args:
-----
configFileName: TODO.
Returns:
--------
A dictionary with the following keys: appPath, appPathDefaults,
appPathTransforms, appPathPlugins, appPathPatterns, appPathPatterns. | [
"Auxiliar",
"function",
"to",
"get",
"the",
"configuration",
"paths",
"depending",
"on",
"the",
"system"
] | 83437f4c14c9c08cb80a896bd9834c77f6567871 | https://github.com/i3visio/osrframework/blob/83437f4c14c9c08cb80a896bd9834c77f6567871/osrframework/utils/configuration.py#L66-L103 |
5,508 | i3visio/osrframework | osrframework/utils/configuration.py | returnListOfConfigurationValues | def returnListOfConfigurationValues(util):
"""
Method that recovers the configuration information about each program
TODO: Grab the default file from the package data instead of storing it in
the main folder.
Args:
-----
util: Any of the utils that are contained in the framework: domai... | python | def returnListOfConfigurationValues(util):
"""
Method that recovers the configuration information about each program
TODO: Grab the default file from the package data instead of storing it in
the main folder.
Args:
-----
util: Any of the utils that are contained in the framework: domai... | [
"def",
"returnListOfConfigurationValues",
"(",
"util",
")",
":",
"VALUES",
"=",
"{",
"}",
"# If a api_keys.cfg has not been found, creating it by copying from default",
"configPath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"getConfigPath",
"(",
")",
"[",
"\"appPath\""... | Method that recovers the configuration information about each program
TODO: Grab the default file from the package data instead of storing it in
the main folder.
Args:
-----
util: Any of the utils that are contained in the framework: domainfy,
entify, mailfy, phonefy, searchfy, usu... | [
"Method",
"that",
"recovers",
"the",
"configuration",
"information",
"about",
"each",
"program"
] | 83437f4c14c9c08cb80a896bd9834c77f6567871 | https://github.com/i3visio/osrframework/blob/83437f4c14c9c08cb80a896bd9834c77f6567871/osrframework/utils/configuration.py#L106-L195 |
5,509 | i3visio/osrframework | osrframework/searchfy.py | performSearch | def performSearch(platformNames=[], queries=[], process=False, excludePlatformNames=[]):
"""
Method to perform the search itself on the different platforms.
Args:
-----
platforms: List of <Platform> objects.
queries: List of queries to be performed.
process: Whether to process a... | python | def performSearch(platformNames=[], queries=[], process=False, excludePlatformNames=[]):
"""
Method to perform the search itself on the different platforms.
Args:
-----
platforms: List of <Platform> objects.
queries: List of queries to be performed.
process: Whether to process a... | [
"def",
"performSearch",
"(",
"platformNames",
"=",
"[",
"]",
",",
"queries",
"=",
"[",
"]",
",",
"process",
"=",
"False",
",",
"excludePlatformNames",
"=",
"[",
"]",
")",
":",
"# Grabbing the <Platform> objects",
"platforms",
"=",
"platform_selection",
".",
"g... | Method to perform the search itself on the different platforms.
Args:
-----
platforms: List of <Platform> objects.
queries: List of queries to be performed.
process: Whether to process all the profiles... SLOW!
Returns:
--------
A list with the entities collected. | [
"Method",
"to",
"perform",
"the",
"search",
"itself",
"on",
"the",
"different",
"platforms",
"."
] | 83437f4c14c9c08cb80a896bd9834c77f6567871 | https://github.com/i3visio/osrframework/blob/83437f4c14c9c08cb80a896bd9834c77f6567871/osrframework/searchfy.py#L37-L60 |
5,510 | i3visio/osrframework | osrframework/utils/platform_selection.py | getAllPlatformNames | def getAllPlatformNames(mode):
"""Method that defines the whole list of available parameters.
:param mode: The mode of the search. The following can be chosen: ["phonefy", "usufy", "searchfy"].
Return values:
Returns a list [] of strings for the platform objects.
"""
# Recov... | python | def getAllPlatformNames(mode):
"""Method that defines the whole list of available parameters.
:param mode: The mode of the search. The following can be chosen: ["phonefy", "usufy", "searchfy"].
Return values:
Returns a list [] of strings for the platform objects.
"""
# Recov... | [
"def",
"getAllPlatformNames",
"(",
"mode",
")",
":",
"# Recovering all the possible platforms installed",
"platOptions",
"=",
"[",
"]",
"if",
"mode",
"in",
"[",
"\"phonefy\"",
",",
"\"usufy\"",
",",
"\"searchfy\"",
",",
"\"mailfy\"",
"]",
":",
"allPlatforms",
"=",
... | Method that defines the whole list of available parameters.
:param mode: The mode of the search. The following can be chosen: ["phonefy", "usufy", "searchfy"].
Return values:
Returns a list [] of strings for the platform objects. | [
"Method",
"that",
"defines",
"the",
"whole",
"list",
"of",
"available",
"parameters",
"."
] | 83437f4c14c9c08cb80a896bd9834c77f6567871 | https://github.com/i3visio/osrframework/blob/83437f4c14c9c08cb80a896bd9834c77f6567871/osrframework/utils/platform_selection.py#L35-L62 |
5,511 | i3visio/osrframework | osrframework/thirdparties/pipl_com/lib/utils.py | Serializable.from_json | def from_json(cls, json_str):
"""Deserialize the object from a JSON string."""
d = json.loads(json_str)
return cls.from_dict(d) | python | def from_json(cls, json_str):
"""Deserialize the object from a JSON string."""
d = json.loads(json_str)
return cls.from_dict(d) | [
"def",
"from_json",
"(",
"cls",
",",
"json_str",
")",
":",
"d",
"=",
"json",
".",
"loads",
"(",
"json_str",
")",
"return",
"cls",
".",
"from_dict",
"(",
"d",
")"
] | Deserialize the object from a JSON string. | [
"Deserialize",
"the",
"object",
"from",
"a",
"JSON",
"string",
"."
] | 83437f4c14c9c08cb80a896bd9834c77f6567871 | https://github.com/i3visio/osrframework/blob/83437f4c14c9c08cb80a896bd9834c77f6567871/osrframework/thirdparties/pipl_com/lib/utils.py#L33-L36 |
5,512 | i3visio/osrframework | osrframework/checkfy.py | createEmails | def createEmails(nicks=None, nicksFile=None):
"""
Method that globally permits to generate the emails to be checked.
Args:
-----
nicks: List of aliases.
nicksFile: The filepath to the aliases file.
Returns:
--------
list: list of emails to be checked.
"""
candid... | python | def createEmails(nicks=None, nicksFile=None):
"""
Method that globally permits to generate the emails to be checked.
Args:
-----
nicks: List of aliases.
nicksFile: The filepath to the aliases file.
Returns:
--------
list: list of emails to be checked.
"""
candid... | [
"def",
"createEmails",
"(",
"nicks",
"=",
"None",
",",
"nicksFile",
"=",
"None",
")",
":",
"candidate_emails",
"=",
"set",
"(",
")",
"if",
"nicks",
"!=",
"None",
":",
"for",
"n",
"in",
"nicks",
":",
"for",
"e",
"in",
"email_providers",
".",
"domains",
... | Method that globally permits to generate the emails to be checked.
Args:
-----
nicks: List of aliases.
nicksFile: The filepath to the aliases file.
Returns:
--------
list: list of emails to be checked. | [
"Method",
"that",
"globally",
"permits",
"to",
"generate",
"the",
"emails",
"to",
"be",
"checked",
"."
] | 83437f4c14c9c08cb80a896bd9834c77f6567871 | https://github.com/i3visio/osrframework/blob/83437f4c14c9c08cb80a896bd9834c77f6567871/osrframework/checkfy.py#L39-L63 |
5,513 | i3visio/osrframework | osrframework/thirdparties/resolvethem_com/processing.py | checkIPFromAlias | def checkIPFromAlias(alias=None):
'''
Method that checks if the given alias is currently connected to Skype and returns its IP address.
:param alias: Alias to be searched.
:return: Python structure for the Json received. It has the following structure:
{
"type": "i3visio.ip",
... | python | def checkIPFromAlias(alias=None):
'''
Method that checks if the given alias is currently connected to Skype and returns its IP address.
:param alias: Alias to be searched.
:return: Python structure for the Json received. It has the following structure:
{
"type": "i3visio.ip",
... | [
"def",
"checkIPFromAlias",
"(",
"alias",
"=",
"None",
")",
":",
"headers",
"=",
"{",
"\"Content-type\"",
":",
"\"text/html\"",
",",
"\"Accept\"",
":",
"\"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\"",
",",
"\"Accept-Encoding\"",
":",
"\" gzip, deflate\"... | Method that checks if the given alias is currently connected to Skype and returns its IP address.
:param alias: Alias to be searched.
:return: Python structure for the Json received. It has the following structure:
{
"type": "i3visio.ip",
"value": "1.1.1.1",
"at... | [
"Method",
"that",
"checks",
"if",
"the",
"given",
"alias",
"is",
"currently",
"connected",
"to",
"Skype",
"and",
"returns",
"its",
"IP",
"address",
"."
] | 83437f4c14c9c08cb80a896bd9834c77f6567871 | https://github.com/i3visio/osrframework/blob/83437f4c14c9c08cb80a896bd9834c77f6567871/osrframework/thirdparties/resolvethem_com/processing.py#L26-L65 |
5,514 | jrief/djangocms-cascade | cmsplugin_cascade/sharable/forms.py | SharableGlossaryMixin.get_form | def get_form(self, request, obj=None, **kwargs):
"""
Extend the form for the given plugin with the form SharableCascadeForm
"""
Form = type(str('ExtSharableForm'), (SharableCascadeForm, kwargs.pop('form', self.form)), {})
Form.base_fields['shared_glossary'].limit_choices_to = dic... | python | def get_form(self, request, obj=None, **kwargs):
"""
Extend the form for the given plugin with the form SharableCascadeForm
"""
Form = type(str('ExtSharableForm'), (SharableCascadeForm, kwargs.pop('form', self.form)), {})
Form.base_fields['shared_glossary'].limit_choices_to = dic... | [
"def",
"get_form",
"(",
"self",
",",
"request",
",",
"obj",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"Form",
"=",
"type",
"(",
"str",
"(",
"'ExtSharableForm'",
")",
",",
"(",
"SharableCascadeForm",
",",
"kwargs",
".",
"pop",
"(",
"'form'",
","... | Extend the form for the given plugin with the form SharableCascadeForm | [
"Extend",
"the",
"form",
"for",
"the",
"given",
"plugin",
"with",
"the",
"form",
"SharableCascadeForm"
] | 58996f990c4068e5d50f0db6030a5c0e06b682e5 | https://github.com/jrief/djangocms-cascade/blob/58996f990c4068e5d50f0db6030a5c0e06b682e5/cmsplugin_cascade/sharable/forms.py#L122-L129 |
5,515 | jrief/djangocms-cascade | cmsplugin_cascade/bootstrap4/grid.py | Bootstrap4Column.get_min_max_bounds | def get_min_max_bounds(self):
"""
Return a dict of min- and max-values for the given column.
This is required to estimate the bounds of images.
"""
bound = Bound(999999.0, 0.0)
for bp in Breakpoint:
bound.extend(self.get_bound(bp))
return {'min': bound... | python | def get_min_max_bounds(self):
"""
Return a dict of min- and max-values for the given column.
This is required to estimate the bounds of images.
"""
bound = Bound(999999.0, 0.0)
for bp in Breakpoint:
bound.extend(self.get_bound(bp))
return {'min': bound... | [
"def",
"get_min_max_bounds",
"(",
"self",
")",
":",
"bound",
"=",
"Bound",
"(",
"999999.0",
",",
"0.0",
")",
"for",
"bp",
"in",
"Breakpoint",
":",
"bound",
".",
"extend",
"(",
"self",
".",
"get_bound",
"(",
"bp",
")",
")",
"return",
"{",
"'min'",
":"... | Return a dict of min- and max-values for the given column.
This is required to estimate the bounds of images. | [
"Return",
"a",
"dict",
"of",
"min",
"-",
"and",
"max",
"-",
"values",
"for",
"the",
"given",
"column",
".",
"This",
"is",
"required",
"to",
"estimate",
"the",
"bounds",
"of",
"images",
"."
] | 58996f990c4068e5d50f0db6030a5c0e06b682e5 | https://github.com/jrief/djangocms-cascade/blob/58996f990c4068e5d50f0db6030a5c0e06b682e5/cmsplugin_cascade/bootstrap4/grid.py#L306-L314 |
5,516 | jrief/djangocms-cascade | cmsplugin_cascade/plugin_base.py | create_proxy_model | def create_proxy_model(name, model_mixins, base_model, attrs=None, module=None):
"""
Create a Django Proxy Model on the fly, to be used by any Cascade Plugin.
"""
from django.apps import apps
class Meta:
proxy = True
app_label = 'cmsplugin_cascade'
name = str(name + 'Model')
... | python | def create_proxy_model(name, model_mixins, base_model, attrs=None, module=None):
"""
Create a Django Proxy Model on the fly, to be used by any Cascade Plugin.
"""
from django.apps import apps
class Meta:
proxy = True
app_label = 'cmsplugin_cascade'
name = str(name + 'Model')
... | [
"def",
"create_proxy_model",
"(",
"name",
",",
"model_mixins",
",",
"base_model",
",",
"attrs",
"=",
"None",
",",
"module",
"=",
"None",
")",
":",
"from",
"django",
".",
"apps",
"import",
"apps",
"class",
"Meta",
":",
"proxy",
"=",
"True",
"app_label",
"... | Create a Django Proxy Model on the fly, to be used by any Cascade Plugin. | [
"Create",
"a",
"Django",
"Proxy",
"Model",
"on",
"the",
"fly",
"to",
"be",
"used",
"by",
"any",
"Cascade",
"Plugin",
"."
] | 58996f990c4068e5d50f0db6030a5c0e06b682e5 | https://github.com/jrief/djangocms-cascade/blob/58996f990c4068e5d50f0db6030a5c0e06b682e5/cmsplugin_cascade/plugin_base.py#L35-L53 |
5,517 | jrief/djangocms-cascade | cmsplugin_cascade/plugin_base.py | CascadePluginBase._get_parent_classes_transparent | def _get_parent_classes_transparent(cls, slot, page, instance=None):
"""
Return all parent classes including those marked as "transparent".
"""
parent_classes = super(CascadePluginBase, cls).get_parent_classes(slot, page, instance)
if parent_classes is None:
if cls.ge... | python | def _get_parent_classes_transparent(cls, slot, page, instance=None):
"""
Return all parent classes including those marked as "transparent".
"""
parent_classes = super(CascadePluginBase, cls).get_parent_classes(slot, page, instance)
if parent_classes is None:
if cls.ge... | [
"def",
"_get_parent_classes_transparent",
"(",
"cls",
",",
"slot",
",",
"page",
",",
"instance",
"=",
"None",
")",
":",
"parent_classes",
"=",
"super",
"(",
"CascadePluginBase",
",",
"cls",
")",
".",
"get_parent_classes",
"(",
"slot",
",",
"page",
",",
"inst... | Return all parent classes including those marked as "transparent". | [
"Return",
"all",
"parent",
"classes",
"including",
"those",
"marked",
"as",
"transparent",
"."
] | 58996f990c4068e5d50f0db6030a5c0e06b682e5 | https://github.com/jrief/djangocms-cascade/blob/58996f990c4068e5d50f0db6030a5c0e06b682e5/cmsplugin_cascade/plugin_base.py#L282-L295 |
5,518 | jrief/djangocms-cascade | cmsplugin_cascade/plugin_base.py | CascadePluginBase.extend_children | def extend_children(self, parent, wanted_children, child_class, child_glossary=None):
"""
Extend the number of children so that the parent object contains wanted children.
No child will be removed if wanted_children is smaller than the current number of children.
"""
from cms.api... | python | def extend_children(self, parent, wanted_children, child_class, child_glossary=None):
"""
Extend the number of children so that the parent object contains wanted children.
No child will be removed if wanted_children is smaller than the current number of children.
"""
from cms.api... | [
"def",
"extend_children",
"(",
"self",
",",
"parent",
",",
"wanted_children",
",",
"child_class",
",",
"child_glossary",
"=",
"None",
")",
":",
"from",
"cms",
".",
"api",
"import",
"add_plugin",
"current_children",
"=",
"parent",
".",
"get_num_children",
"(",
... | Extend the number of children so that the parent object contains wanted children.
No child will be removed if wanted_children is smaller than the current number of children. | [
"Extend",
"the",
"number",
"of",
"children",
"so",
"that",
"the",
"parent",
"object",
"contains",
"wanted",
"children",
".",
"No",
"child",
"will",
"be",
"removed",
"if",
"wanted_children",
"is",
"smaller",
"than",
"the",
"current",
"number",
"of",
"children",... | 58996f990c4068e5d50f0db6030a5c0e06b682e5 | https://github.com/jrief/djangocms-cascade/blob/58996f990c4068e5d50f0db6030a5c0e06b682e5/cmsplugin_cascade/plugin_base.py#L360-L371 |
5,519 | jrief/djangocms-cascade | cmsplugin_cascade/plugin_base.py | CascadePluginBase.get_parent_instance | def get_parent_instance(self, request=None, obj=None):
"""
Get the parent model instance corresponding to this plugin. When adding a new plugin, the
parent might not be available. Therefore as fallback, pass in the request object.
"""
try:
parent_id = obj.parent_id
... | python | def get_parent_instance(self, request=None, obj=None):
"""
Get the parent model instance corresponding to this plugin. When adding a new plugin, the
parent might not be available. Therefore as fallback, pass in the request object.
"""
try:
parent_id = obj.parent_id
... | [
"def",
"get_parent_instance",
"(",
"self",
",",
"request",
"=",
"None",
",",
"obj",
"=",
"None",
")",
":",
"try",
":",
"parent_id",
"=",
"obj",
".",
"parent_id",
"except",
"AttributeError",
":",
"try",
":",
"# TODO: self.parent presumably is not used anymore in CM... | Get the parent model instance corresponding to this plugin. When adding a new plugin, the
parent might not be available. Therefore as fallback, pass in the request object. | [
"Get",
"the",
"parent",
"model",
"instance",
"corresponding",
"to",
"this",
"plugin",
".",
"When",
"adding",
"a",
"new",
"plugin",
"the",
"parent",
"might",
"not",
"be",
"available",
".",
"Therefore",
"as",
"fallback",
"pass",
"in",
"the",
"request",
"object... | 58996f990c4068e5d50f0db6030a5c0e06b682e5 | https://github.com/jrief/djangocms-cascade/blob/58996f990c4068e5d50f0db6030a5c0e06b682e5/cmsplugin_cascade/plugin_base.py#L403-L432 |
5,520 | jrief/djangocms-cascade | cmsplugin_cascade/plugin_base.py | CascadePluginBase.in_edit_mode | def in_edit_mode(self, request, placeholder):
"""
Returns True, if the plugin is in "edit mode".
"""
toolbar = getattr(request, 'toolbar', None)
edit_mode = getattr(toolbar, 'edit_mode', False) and getattr(placeholder, 'is_editable', True)
if edit_mode:
edit_m... | python | def in_edit_mode(self, request, placeholder):
"""
Returns True, if the plugin is in "edit mode".
"""
toolbar = getattr(request, 'toolbar', None)
edit_mode = getattr(toolbar, 'edit_mode', False) and getattr(placeholder, 'is_editable', True)
if edit_mode:
edit_m... | [
"def",
"in_edit_mode",
"(",
"self",
",",
"request",
",",
"placeholder",
")",
":",
"toolbar",
"=",
"getattr",
"(",
"request",
",",
"'toolbar'",
",",
"None",
")",
"edit_mode",
"=",
"getattr",
"(",
"toolbar",
",",
"'edit_mode'",
",",
"False",
")",
"and",
"g... | Returns True, if the plugin is in "edit mode". | [
"Returns",
"True",
"if",
"the",
"plugin",
"is",
"in",
"edit",
"mode",
"."
] | 58996f990c4068e5d50f0db6030a5c0e06b682e5 | https://github.com/jrief/djangocms-cascade/blob/58996f990c4068e5d50f0db6030a5c0e06b682e5/cmsplugin_cascade/plugin_base.py#L480-L488 |
5,521 | jrief/djangocms-cascade | cmsplugin_cascade/segmentation/cms_plugins.py | SegmentPlugin._get_previous_open_tag | def _get_previous_open_tag(self, obj):
"""
Return the open tag of the previous sibling
"""
prev_instance = self.get_previous_instance(obj)
if prev_instance and prev_instance.plugin_type == self.__class__.__name__:
return prev_instance.glossary.get('open_tag') | python | def _get_previous_open_tag(self, obj):
"""
Return the open tag of the previous sibling
"""
prev_instance = self.get_previous_instance(obj)
if prev_instance and prev_instance.plugin_type == self.__class__.__name__:
return prev_instance.glossary.get('open_tag') | [
"def",
"_get_previous_open_tag",
"(",
"self",
",",
"obj",
")",
":",
"prev_instance",
"=",
"self",
".",
"get_previous_instance",
"(",
"obj",
")",
"if",
"prev_instance",
"and",
"prev_instance",
".",
"plugin_type",
"==",
"self",
".",
"__class__",
".",
"__name__",
... | Return the open tag of the previous sibling | [
"Return",
"the",
"open",
"tag",
"of",
"the",
"previous",
"sibling"
] | 58996f990c4068e5d50f0db6030a5c0e06b682e5 | https://github.com/jrief/djangocms-cascade/blob/58996f990c4068e5d50f0db6030a5c0e06b682e5/cmsplugin_cascade/segmentation/cms_plugins.py#L170-L176 |
5,522 | jrief/djangocms-cascade | cmsplugin_cascade/generic/mixins.py | SectionForm.check_unique_element_id | def check_unique_element_id(cls, instance, element_id):
"""
Check for uniqueness of the given element_id for the current page.
Return None if instance is not yet associated with a page.
"""
try:
element_ids = instance.placeholder.page.cascadepage.glossary.get('element... | python | def check_unique_element_id(cls, instance, element_id):
"""
Check for uniqueness of the given element_id for the current page.
Return None if instance is not yet associated with a page.
"""
try:
element_ids = instance.placeholder.page.cascadepage.glossary.get('element... | [
"def",
"check_unique_element_id",
"(",
"cls",
",",
"instance",
",",
"element_id",
")",
":",
"try",
":",
"element_ids",
"=",
"instance",
".",
"placeholder",
".",
"page",
".",
"cascadepage",
".",
"glossary",
".",
"get",
"(",
"'element_ids'",
",",
"{",
"}",
"... | Check for uniqueness of the given element_id for the current page.
Return None if instance is not yet associated with a page. | [
"Check",
"for",
"uniqueness",
"of",
"the",
"given",
"element_id",
"for",
"the",
"current",
"page",
".",
"Return",
"None",
"if",
"instance",
"is",
"not",
"yet",
"associated",
"with",
"a",
"page",
"."
] | 58996f990c4068e5d50f0db6030a5c0e06b682e5 | https://github.com/jrief/djangocms-cascade/blob/58996f990c4068e5d50f0db6030a5c0e06b682e5/cmsplugin_cascade/generic/mixins.py#L20-L34 |
5,523 | jrief/djangocms-cascade | cmsplugin_cascade/utils.py | rectify_partial_form_field | def rectify_partial_form_field(base_field, partial_form_fields):
"""
In base_field reset the attributes label and help_text, since they are overriden by the
partial field. Additionally, from the list, or list of lists of partial_form_fields
append the bound validator methods to the given base field.
... | python | def rectify_partial_form_field(base_field, partial_form_fields):
"""
In base_field reset the attributes label and help_text, since they are overriden by the
partial field. Additionally, from the list, or list of lists of partial_form_fields
append the bound validator methods to the given base field.
... | [
"def",
"rectify_partial_form_field",
"(",
"base_field",
",",
"partial_form_fields",
")",
":",
"base_field",
".",
"label",
"=",
"''",
"base_field",
".",
"help_text",
"=",
"''",
"for",
"fieldset",
"in",
"partial_form_fields",
":",
"if",
"not",
"isinstance",
"(",
"... | In base_field reset the attributes label and help_text, since they are overriden by the
partial field. Additionally, from the list, or list of lists of partial_form_fields
append the bound validator methods to the given base field. | [
"In",
"base_field",
"reset",
"the",
"attributes",
"label",
"and",
"help_text",
"since",
"they",
"are",
"overriden",
"by",
"the",
"partial",
"field",
".",
"Additionally",
"from",
"the",
"list",
"or",
"list",
"of",
"lists",
"of",
"partial_form_fields",
"append",
... | 58996f990c4068e5d50f0db6030a5c0e06b682e5 | https://github.com/jrief/djangocms-cascade/blob/58996f990c4068e5d50f0db6030a5c0e06b682e5/cmsplugin_cascade/utils.py#L16-L28 |
5,524 | jrief/djangocms-cascade | cmsplugin_cascade/utils.py | validate_link | def validate_link(link_data):
"""
Check if the given model exists, otherwise raise a Validation error
"""
from django.apps import apps
try:
Model = apps.get_model(*link_data['model'].split('.'))
Model.objects.get(pk=link_data['pk'])
except Model.DoesNotExist:
raise Valid... | python | def validate_link(link_data):
"""
Check if the given model exists, otherwise raise a Validation error
"""
from django.apps import apps
try:
Model = apps.get_model(*link_data['model'].split('.'))
Model.objects.get(pk=link_data['pk'])
except Model.DoesNotExist:
raise Valid... | [
"def",
"validate_link",
"(",
"link_data",
")",
":",
"from",
"django",
".",
"apps",
"import",
"apps",
"try",
":",
"Model",
"=",
"apps",
".",
"get_model",
"(",
"*",
"link_data",
"[",
"'model'",
"]",
".",
"split",
"(",
"'.'",
")",
")",
"Model",
".",
"ob... | Check if the given model exists, otherwise raise a Validation error | [
"Check",
"if",
"the",
"given",
"model",
"exists",
"otherwise",
"raise",
"a",
"Validation",
"error"
] | 58996f990c4068e5d50f0db6030a5c0e06b682e5 | https://github.com/jrief/djangocms-cascade/blob/58996f990c4068e5d50f0db6030a5c0e06b682e5/cmsplugin_cascade/utils.py#L30-L40 |
5,525 | jrief/djangocms-cascade | cmsplugin_cascade/utils.py | parse_responsive_length | def parse_responsive_length(responsive_length):
"""
Takes a string containing a length definition in pixels or percent and parses it to obtain
a computational length. It returns a tuple where the first element is the length in pixels and
the second element is its length in percent divided by 100.
No... | python | def parse_responsive_length(responsive_length):
"""
Takes a string containing a length definition in pixels or percent and parses it to obtain
a computational length. It returns a tuple where the first element is the length in pixels and
the second element is its length in percent divided by 100.
No... | [
"def",
"parse_responsive_length",
"(",
"responsive_length",
")",
":",
"responsive_length",
"=",
"responsive_length",
".",
"strip",
"(",
")",
"if",
"responsive_length",
".",
"endswith",
"(",
"'px'",
")",
":",
"return",
"(",
"int",
"(",
"responsive_length",
".",
"... | Takes a string containing a length definition in pixels or percent and parses it to obtain
a computational length. It returns a tuple where the first element is the length in pixels and
the second element is its length in percent divided by 100.
Note that one of both returned elements is None. | [
"Takes",
"a",
"string",
"containing",
"a",
"length",
"definition",
"in",
"pixels",
"or",
"percent",
"and",
"parses",
"it",
"to",
"obtain",
"a",
"computational",
"length",
".",
"It",
"returns",
"a",
"tuple",
"where",
"the",
"first",
"element",
"is",
"the",
... | 58996f990c4068e5d50f0db6030a5c0e06b682e5 | https://github.com/jrief/djangocms-cascade/blob/58996f990c4068e5d50f0db6030a5c0e06b682e5/cmsplugin_cascade/utils.py#L71-L83 |
5,526 | jrief/djangocms-cascade | cmsplugin_cascade/mixins.py | CascadePluginMixin.get_css_classes | def get_css_classes(cls, instance):
"""
Returns a list of CSS classes to be added as class="..." to the current HTML tag.
"""
css_classes = []
if hasattr(cls, 'default_css_class'):
css_classes.append(cls.default_css_class)
for attr in getattr(cls, 'default_css... | python | def get_css_classes(cls, instance):
"""
Returns a list of CSS classes to be added as class="..." to the current HTML tag.
"""
css_classes = []
if hasattr(cls, 'default_css_class'):
css_classes.append(cls.default_css_class)
for attr in getattr(cls, 'default_css... | [
"def",
"get_css_classes",
"(",
"cls",
",",
"instance",
")",
":",
"css_classes",
"=",
"[",
"]",
"if",
"hasattr",
"(",
"cls",
",",
"'default_css_class'",
")",
":",
"css_classes",
".",
"append",
"(",
"cls",
".",
"default_css_class",
")",
"for",
"attr",
"in",
... | Returns a list of CSS classes to be added as class="..." to the current HTML tag. | [
"Returns",
"a",
"list",
"of",
"CSS",
"classes",
"to",
"be",
"added",
"as",
"class",
"=",
"...",
"to",
"the",
"current",
"HTML",
"tag",
"."
] | 58996f990c4068e5d50f0db6030a5c0e06b682e5 | https://github.com/jrief/djangocms-cascade/blob/58996f990c4068e5d50f0db6030a5c0e06b682e5/cmsplugin_cascade/mixins.py#L27-L40 |
5,527 | jrief/djangocms-cascade | cmsplugin_cascade/mixins.py | CascadePluginMixin.get_inline_styles | def get_inline_styles(cls, instance):
"""
Returns a dictionary of CSS attributes to be added as style="..." to the current HTML tag.
"""
inline_styles = getattr(cls, 'default_inline_styles', {})
css_style = instance.glossary.get('inline_styles')
if css_style:
... | python | def get_inline_styles(cls, instance):
"""
Returns a dictionary of CSS attributes to be added as style="..." to the current HTML tag.
"""
inline_styles = getattr(cls, 'default_inline_styles', {})
css_style = instance.glossary.get('inline_styles')
if css_style:
... | [
"def",
"get_inline_styles",
"(",
"cls",
",",
"instance",
")",
":",
"inline_styles",
"=",
"getattr",
"(",
"cls",
",",
"'default_inline_styles'",
",",
"{",
"}",
")",
"css_style",
"=",
"instance",
".",
"glossary",
".",
"get",
"(",
"'inline_styles'",
")",
"if",
... | Returns a dictionary of CSS attributes to be added as style="..." to the current HTML tag. | [
"Returns",
"a",
"dictionary",
"of",
"CSS",
"attributes",
"to",
"be",
"added",
"as",
"style",
"=",
"...",
"to",
"the",
"current",
"HTML",
"tag",
"."
] | 58996f990c4068e5d50f0db6030a5c0e06b682e5 | https://github.com/jrief/djangocms-cascade/blob/58996f990c4068e5d50f0db6030a5c0e06b682e5/cmsplugin_cascade/mixins.py#L43-L51 |
5,528 | jrief/djangocms-cascade | cmsplugin_cascade/mixins.py | CascadePluginMixin.get_html_tag_attributes | def get_html_tag_attributes(cls, instance):
"""
Returns a dictionary of attributes, which shall be added to the current HTML tag.
This method normally is called by the models's property method ``html_tag_ attributes``,
which enriches the HTML tag with those attributes converted to a list... | python | def get_html_tag_attributes(cls, instance):
"""
Returns a dictionary of attributes, which shall be added to the current HTML tag.
This method normally is called by the models's property method ``html_tag_ attributes``,
which enriches the HTML tag with those attributes converted to a list... | [
"def",
"get_html_tag_attributes",
"(",
"cls",
",",
"instance",
")",
":",
"attributes",
"=",
"getattr",
"(",
"cls",
",",
"'html_tag_attributes'",
",",
"{",
"}",
")",
"return",
"dict",
"(",
"(",
"attr",
",",
"instance",
".",
"glossary",
".",
"get",
"(",
"k... | Returns a dictionary of attributes, which shall be added to the current HTML tag.
This method normally is called by the models's property method ``html_tag_ attributes``,
which enriches the HTML tag with those attributes converted to a list as
``attr1="val1" attr2="val2" ...``. | [
"Returns",
"a",
"dictionary",
"of",
"attributes",
"which",
"shall",
"be",
"added",
"to",
"the",
"current",
"HTML",
"tag",
".",
"This",
"method",
"normally",
"is",
"called",
"by",
"the",
"models",
"s",
"property",
"method",
"html_tag_",
"attributes",
"which",
... | 58996f990c4068e5d50f0db6030a5c0e06b682e5 | https://github.com/jrief/djangocms-cascade/blob/58996f990c4068e5d50f0db6030a5c0e06b682e5/cmsplugin_cascade/mixins.py#L54-L62 |
5,529 | jrief/djangocms-cascade | cmsplugin_cascade/widgets.py | CascadingSizeWidgetMixin.compile_validation_pattern | def compile_validation_pattern(self, units=None):
"""
Assure that passed in units are valid size units, or if missing, use all possible units.
Return a tuple with a regular expression to be used for validating and an error message
in case this validation failed.
"""
if un... | python | def compile_validation_pattern(self, units=None):
"""
Assure that passed in units are valid size units, or if missing, use all possible units.
Return a tuple with a regular expression to be used for validating and an error message
in case this validation failed.
"""
if un... | [
"def",
"compile_validation_pattern",
"(",
"self",
",",
"units",
"=",
"None",
")",
":",
"if",
"units",
"is",
"None",
":",
"units",
"=",
"list",
"(",
"self",
".",
"POSSIBLE_UNITS",
")",
"else",
":",
"for",
"u",
"in",
"units",
":",
"if",
"u",
"not",
"in... | Assure that passed in units are valid size units, or if missing, use all possible units.
Return a tuple with a regular expression to be used for validating and an error message
in case this validation failed. | [
"Assure",
"that",
"passed",
"in",
"units",
"are",
"valid",
"size",
"units",
"or",
"if",
"missing",
"use",
"all",
"possible",
"units",
".",
"Return",
"a",
"tuple",
"with",
"a",
"regular",
"expression",
"to",
"be",
"used",
"for",
"validating",
"and",
"an",
... | 58996f990c4068e5d50f0db6030a5c0e06b682e5 | https://github.com/jrief/djangocms-cascade/blob/58996f990c4068e5d50f0db6030a5c0e06b682e5/cmsplugin_cascade/widgets.py#L108-L123 |
5,530 | jrief/djangocms-cascade | cmsplugin_cascade/link/forms.py | LinkForm.unset_required_for | def unset_required_for(cls, sharable_fields):
"""
Fields borrowed by `SharedGlossaryAdmin` to build its temporary change form, only are
required if they are declared in `sharable_fields`. Otherwise just deactivate them.
"""
if 'link_content' in cls.base_fields and 'link_content' ... | python | def unset_required_for(cls, sharable_fields):
"""
Fields borrowed by `SharedGlossaryAdmin` to build its temporary change form, only are
required if they are declared in `sharable_fields`. Otherwise just deactivate them.
"""
if 'link_content' in cls.base_fields and 'link_content' ... | [
"def",
"unset_required_for",
"(",
"cls",
",",
"sharable_fields",
")",
":",
"if",
"'link_content'",
"in",
"cls",
".",
"base_fields",
"and",
"'link_content'",
"not",
"in",
"sharable_fields",
":",
"cls",
".",
"base_fields",
"[",
"'link_content'",
"]",
".",
"require... | Fields borrowed by `SharedGlossaryAdmin` to build its temporary change form, only are
required if they are declared in `sharable_fields`. Otherwise just deactivate them. | [
"Fields",
"borrowed",
"by",
"SharedGlossaryAdmin",
"to",
"build",
"its",
"temporary",
"change",
"form",
"only",
"are",
"required",
"if",
"they",
"are",
"declared",
"in",
"sharable_fields",
".",
"Otherwise",
"just",
"deactivate",
"them",
"."
] | 58996f990c4068e5d50f0db6030a5c0e06b682e5 | https://github.com/jrief/djangocms-cascade/blob/58996f990c4068e5d50f0db6030a5c0e06b682e5/cmsplugin_cascade/link/forms.py#L260-L268 |
5,531 | jrief/djangocms-cascade | cmsplugin_cascade/models.py | CascadePage.assure_relation | def assure_relation(cls, cms_page):
"""
Assure that we have a foreign key relation, pointing from CascadePage onto CMSPage.
"""
try:
cms_page.cascadepage
except cls.DoesNotExist:
cls.objects.create(extended_object=cms_page) | python | def assure_relation(cls, cms_page):
"""
Assure that we have a foreign key relation, pointing from CascadePage onto CMSPage.
"""
try:
cms_page.cascadepage
except cls.DoesNotExist:
cls.objects.create(extended_object=cms_page) | [
"def",
"assure_relation",
"(",
"cls",
",",
"cms_page",
")",
":",
"try",
":",
"cms_page",
".",
"cascadepage",
"except",
"cls",
".",
"DoesNotExist",
":",
"cls",
".",
"objects",
".",
"create",
"(",
"extended_object",
"=",
"cms_page",
")"
] | Assure that we have a foreign key relation, pointing from CascadePage onto CMSPage. | [
"Assure",
"that",
"we",
"have",
"a",
"foreign",
"key",
"relation",
"pointing",
"from",
"CascadePage",
"onto",
"CMSPage",
"."
] | 58996f990c4068e5d50f0db6030a5c0e06b682e5 | https://github.com/jrief/djangocms-cascade/blob/58996f990c4068e5d50f0db6030a5c0e06b682e5/cmsplugin_cascade/models.py#L371-L378 |
5,532 | jrief/djangocms-cascade | cmsplugin_cascade/bootstrap3/utils.py | compute_media_queries | def compute_media_queries(element):
"""
For e given Cascade element, compute the current media queries for each breakpoint,
even for nested containers, rows and columns.
"""
parent_glossary = element.get_parent_glossary()
# compute the max width and the required media queries for each chosen bre... | python | def compute_media_queries(element):
"""
For e given Cascade element, compute the current media queries for each breakpoint,
even for nested containers, rows and columns.
"""
parent_glossary = element.get_parent_glossary()
# compute the max width and the required media queries for each chosen bre... | [
"def",
"compute_media_queries",
"(",
"element",
")",
":",
"parent_glossary",
"=",
"element",
".",
"get_parent_glossary",
"(",
")",
"# compute the max width and the required media queries for each chosen breakpoint",
"element",
".",
"glossary",
"[",
"'container_max_widths'",
"]"... | For e given Cascade element, compute the current media queries for each breakpoint,
even for nested containers, rows and columns. | [
"For",
"e",
"given",
"Cascade",
"element",
"compute",
"the",
"current",
"media",
"queries",
"for",
"each",
"breakpoint",
"even",
"for",
"nested",
"containers",
"rows",
"and",
"columns",
"."
] | 58996f990c4068e5d50f0db6030a5c0e06b682e5 | https://github.com/jrief/djangocms-cascade/blob/58996f990c4068e5d50f0db6030a5c0e06b682e5/cmsplugin_cascade/bootstrap3/utils.py#L63-L90 |
5,533 | jrief/djangocms-cascade | cmsplugin_cascade/fields.py | GlossaryField.get_element_ids | def get_element_ids(self, prefix_id):
"""
Returns a single or a list of element ids, one for each input widget of this field
"""
if isinstance(self.widget, widgets.MultiWidget):
ids = ['{0}_{1}_{2}'.format(prefix_id, self.name, field_name) for field_name in self.widget]
... | python | def get_element_ids(self, prefix_id):
"""
Returns a single or a list of element ids, one for each input widget of this field
"""
if isinstance(self.widget, widgets.MultiWidget):
ids = ['{0}_{1}_{2}'.format(prefix_id, self.name, field_name) for field_name in self.widget]
... | [
"def",
"get_element_ids",
"(",
"self",
",",
"prefix_id",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"widget",
",",
"widgets",
".",
"MultiWidget",
")",
":",
"ids",
"=",
"[",
"'{0}_{1}_{2}'",
".",
"format",
"(",
"prefix_id",
",",
"self",
".",
"name",
... | Returns a single or a list of element ids, one for each input widget of this field | [
"Returns",
"a",
"single",
"or",
"a",
"list",
"of",
"element",
"ids",
"one",
"for",
"each",
"input",
"widget",
"of",
"this",
"field"
] | 58996f990c4068e5d50f0db6030a5c0e06b682e5 | https://github.com/jrief/djangocms-cascade/blob/58996f990c4068e5d50f0db6030a5c0e06b682e5/cmsplugin_cascade/fields.py#L50-L60 |
5,534 | jrief/djangocms-cascade | cmsplugin_cascade/segmentation/mixins.py | EmulateUserModelMixin.get_context_override | def get_context_override(self, request):
"""
Override the request object with an emulated user.
"""
context_override = super(EmulateUserModelMixin, self).get_context_override(request)
try:
if request.user.is_staff:
user = self.UserModel.objects.get(pk=... | python | def get_context_override(self, request):
"""
Override the request object with an emulated user.
"""
context_override = super(EmulateUserModelMixin, self).get_context_override(request)
try:
if request.user.is_staff:
user = self.UserModel.objects.get(pk=... | [
"def",
"get_context_override",
"(",
"self",
",",
"request",
")",
":",
"context_override",
"=",
"super",
"(",
"EmulateUserModelMixin",
",",
"self",
")",
".",
"get_context_override",
"(",
"request",
")",
"try",
":",
"if",
"request",
".",
"user",
".",
"is_staff",... | Override the request object with an emulated user. | [
"Override",
"the",
"request",
"object",
"with",
"an",
"emulated",
"user",
"."
] | 58996f990c4068e5d50f0db6030a5c0e06b682e5 | https://github.com/jrief/djangocms-cascade/blob/58996f990c4068e5d50f0db6030a5c0e06b682e5/cmsplugin_cascade/segmentation/mixins.py#L48-L59 |
5,535 | jrief/djangocms-cascade | cmsplugin_cascade/segmentation/mixins.py | EmulateUserAdminMixin.emulate_users | def emulate_users(self, request):
"""
The list view
"""
def display_as_link(self, obj):
try:
identifier = getattr(user_model_admin, list_display_link)(obj)
except AttributeError:
identifier = admin.utils.lookup_field(list_display_li... | python | def emulate_users(self, request):
"""
The list view
"""
def display_as_link(self, obj):
try:
identifier = getattr(user_model_admin, list_display_link)(obj)
except AttributeError:
identifier = admin.utils.lookup_field(list_display_li... | [
"def",
"emulate_users",
"(",
"self",
",",
"request",
")",
":",
"def",
"display_as_link",
"(",
"self",
",",
"obj",
")",
":",
"try",
":",
"identifier",
"=",
"getattr",
"(",
"user_model_admin",
",",
"list_display_link",
")",
"(",
"obj",
")",
"except",
"Attrib... | The list view | [
"The",
"list",
"view"
] | 58996f990c4068e5d50f0db6030a5c0e06b682e5 | https://github.com/jrief/djangocms-cascade/blob/58996f990c4068e5d50f0db6030a5c0e06b682e5/cmsplugin_cascade/segmentation/mixins.py#L88-L159 |
5,536 | jrief/djangocms-cascade | cmsplugin_cascade/apps.py | CascadeConfig.pre_migrate | def pre_migrate(cls, sender=None, **kwargs):
"""
Iterate over contenttypes and remove those not in proxy models
"""
ContentType = apps.get_model('contenttypes', 'ContentType')
try:
queryset = ContentType.objects.filter(app_label=sender.label)
for ctype in ... | python | def pre_migrate(cls, sender=None, **kwargs):
"""
Iterate over contenttypes and remove those not in proxy models
"""
ContentType = apps.get_model('contenttypes', 'ContentType')
try:
queryset = ContentType.objects.filter(app_label=sender.label)
for ctype in ... | [
"def",
"pre_migrate",
"(",
"cls",
",",
"sender",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"ContentType",
"=",
"apps",
".",
"get_model",
"(",
"'contenttypes'",
",",
"'ContentType'",
")",
"try",
":",
"queryset",
"=",
"ContentType",
".",
"objects",
"... | Iterate over contenttypes and remove those not in proxy models | [
"Iterate",
"over",
"contenttypes",
"and",
"remove",
"those",
"not",
"in",
"proxy",
"models"
] | 58996f990c4068e5d50f0db6030a5c0e06b682e5 | https://github.com/jrief/djangocms-cascade/blob/58996f990c4068e5d50f0db6030a5c0e06b682e5/cmsplugin_cascade/apps.py#L29-L42 |
5,537 | jrief/djangocms-cascade | cmsplugin_cascade/apps.py | CascadeConfig.post_migrate | def post_migrate(cls, sender=None, **kwargs):
"""
Iterate over fake_proxy_models and add contenttypes and permissions for missing proxy
models, if this has not been done by Django yet
"""
ContentType = apps.get_model('contenttypes', 'ContentType')
for model_name, proxy_m... | python | def post_migrate(cls, sender=None, **kwargs):
"""
Iterate over fake_proxy_models and add contenttypes and permissions for missing proxy
models, if this has not been done by Django yet
"""
ContentType = apps.get_model('contenttypes', 'ContentType')
for model_name, proxy_m... | [
"def",
"post_migrate",
"(",
"cls",
",",
"sender",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"ContentType",
"=",
"apps",
".",
"get_model",
"(",
"'contenttypes'",
",",
"'ContentType'",
")",
"for",
"model_name",
",",
"proxy_model",
"in",
"sender",
".",
... | Iterate over fake_proxy_models and add contenttypes and permissions for missing proxy
models, if this has not been done by Django yet | [
"Iterate",
"over",
"fake_proxy_models",
"and",
"add",
"contenttypes",
"and",
"permissions",
"for",
"missing",
"proxy",
"models",
"if",
"this",
"has",
"not",
"been",
"done",
"by",
"Django",
"yet"
] | 58996f990c4068e5d50f0db6030a5c0e06b682e5 | https://github.com/jrief/djangocms-cascade/blob/58996f990c4068e5d50f0db6030a5c0e06b682e5/cmsplugin_cascade/apps.py#L45-L55 |
5,538 | jrief/djangocms-cascade | cmsplugin_cascade/apps.py | CascadeConfig.grant_permissions | def grant_permissions(self, proxy_model):
"""
Create the default permissions for the just added proxy model
"""
ContentType = apps.get_model('contenttypes', 'ContentType')
try:
Permission = apps.get_model('auth', 'Permission')
except LookupError:
r... | python | def grant_permissions(self, proxy_model):
"""
Create the default permissions for the just added proxy model
"""
ContentType = apps.get_model('contenttypes', 'ContentType')
try:
Permission = apps.get_model('auth', 'Permission')
except LookupError:
r... | [
"def",
"grant_permissions",
"(",
"self",
",",
"proxy_model",
")",
":",
"ContentType",
"=",
"apps",
".",
"get_model",
"(",
"'contenttypes'",
",",
"'ContentType'",
")",
"try",
":",
"Permission",
"=",
"apps",
".",
"get_model",
"(",
"'auth'",
",",
"'Permission'",
... | Create the default permissions for the just added proxy model | [
"Create",
"the",
"default",
"permissions",
"for",
"the",
"just",
"added",
"proxy",
"model"
] | 58996f990c4068e5d50f0db6030a5c0e06b682e5 | https://github.com/jrief/djangocms-cascade/blob/58996f990c4068e5d50f0db6030a5c0e06b682e5/cmsplugin_cascade/apps.py#L67-L95 |
5,539 | jrief/djangocms-cascade | cmsplugin_cascade/apps.py | CascadeConfig.revoke_permissions | def revoke_permissions(self, ctype):
"""
Remove all permissions for the content type to be removed
"""
ContentType = apps.get_model('contenttypes', 'ContentType')
try:
Permission = apps.get_model('auth', 'Permission')
except LookupError:
return
... | python | def revoke_permissions(self, ctype):
"""
Remove all permissions for the content type to be removed
"""
ContentType = apps.get_model('contenttypes', 'ContentType')
try:
Permission = apps.get_model('auth', 'Permission')
except LookupError:
return
... | [
"def",
"revoke_permissions",
"(",
"self",
",",
"ctype",
")",
":",
"ContentType",
"=",
"apps",
".",
"get_model",
"(",
"'contenttypes'",
",",
"'ContentType'",
")",
"try",
":",
"Permission",
"=",
"apps",
".",
"get_model",
"(",
"'auth'",
",",
"'Permission'",
")"... | Remove all permissions for the content type to be removed | [
"Remove",
"all",
"permissions",
"for",
"the",
"content",
"type",
"to",
"be",
"removed"
] | 58996f990c4068e5d50f0db6030a5c0e06b682e5 | https://github.com/jrief/djangocms-cascade/blob/58996f990c4068e5d50f0db6030a5c0e06b682e5/cmsplugin_cascade/apps.py#L97-L110 |
5,540 | adamreeve/npTDMS | nptdms/writer.py | to_file | def to_file(file, array):
"""Wrapper around ndarray.tofile to support any file-like object"""
try:
array.tofile(file)
except (TypeError, IOError, UnsupportedOperation):
# tostring actually returns bytes
file.write(array.tostring()) | python | def to_file(file, array):
"""Wrapper around ndarray.tofile to support any file-like object"""
try:
array.tofile(file)
except (TypeError, IOError, UnsupportedOperation):
# tostring actually returns bytes
file.write(array.tostring()) | [
"def",
"to_file",
"(",
"file",
",",
"array",
")",
":",
"try",
":",
"array",
".",
"tofile",
"(",
"file",
")",
"except",
"(",
"TypeError",
",",
"IOError",
",",
"UnsupportedOperation",
")",
":",
"# tostring actually returns bytes",
"file",
".",
"write",
"(",
... | Wrapper around ndarray.tofile to support any file-like object | [
"Wrapper",
"around",
"ndarray",
".",
"tofile",
"to",
"support",
"any",
"file",
"-",
"like",
"object"
] | d7d6632d4ebc2e78ed941477c2f1c56bd7493d74 | https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/writer.py#L317-L324 |
5,541 | adamreeve/npTDMS | nptdms/writer.py | TdmsWriter.write_segment | def write_segment(self, objects):
""" Write a segment of data to a TDMS file
:param objects: A list of TdmsObject instances to write
"""
segment = TdmsSegment(objects)
segment.write(self._file) | python | def write_segment(self, objects):
""" Write a segment of data to a TDMS file
:param objects: A list of TdmsObject instances to write
"""
segment = TdmsSegment(objects)
segment.write(self._file) | [
"def",
"write_segment",
"(",
"self",
",",
"objects",
")",
":",
"segment",
"=",
"TdmsSegment",
"(",
"objects",
")",
"segment",
".",
"write",
"(",
"self",
".",
"_file",
")"
] | Write a segment of data to a TDMS file
:param objects: A list of TdmsObject instances to write | [
"Write",
"a",
"segment",
"of",
"data",
"to",
"a",
"TDMS",
"file"
] | d7d6632d4ebc2e78ed941477c2f1c56bd7493d74 | https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/writer.py#L63-L69 |
5,542 | adamreeve/npTDMS | nptdms/tdms.py | fromfile | def fromfile(file, dtype, count, *args, **kwargs):
"""Wrapper around np.fromfile to support any file-like object"""
try:
return np.fromfile(file, dtype=dtype, count=count, *args, **kwargs)
except (TypeError, IOError, UnsupportedOperation):
return np.frombuffer(
file.read(count *... | python | def fromfile(file, dtype, count, *args, **kwargs):
"""Wrapper around np.fromfile to support any file-like object"""
try:
return np.fromfile(file, dtype=dtype, count=count, *args, **kwargs)
except (TypeError, IOError, UnsupportedOperation):
return np.frombuffer(
file.read(count *... | [
"def",
"fromfile",
"(",
"file",
",",
"dtype",
",",
"count",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"return",
"np",
".",
"fromfile",
"(",
"file",
",",
"dtype",
"=",
"dtype",
",",
"count",
"=",
"count",
",",
"*",
"args",
... | Wrapper around np.fromfile to support any file-like object | [
"Wrapper",
"around",
"np",
".",
"fromfile",
"to",
"support",
"any",
"file",
"-",
"like",
"object"
] | d7d6632d4ebc2e78ed941477c2f1c56bd7493d74 | https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/tdms.py#L43-L51 |
5,543 | adamreeve/npTDMS | nptdms/tdms.py | read_property | def read_property(f, endianness="<"):
""" Read a property from a segment's metadata """
prop_name = types.String.read(f, endianness)
prop_data_type = types.tds_data_types[types.Uint32.read(f, endianness)]
value = prop_data_type.read(f, endianness)
log.debug("Property %s: %r", prop_name, value)
... | python | def read_property(f, endianness="<"):
""" Read a property from a segment's metadata """
prop_name = types.String.read(f, endianness)
prop_data_type = types.tds_data_types[types.Uint32.read(f, endianness)]
value = prop_data_type.read(f, endianness)
log.debug("Property %s: %r", prop_name, value)
... | [
"def",
"read_property",
"(",
"f",
",",
"endianness",
"=",
"\"<\"",
")",
":",
"prop_name",
"=",
"types",
".",
"String",
".",
"read",
"(",
"f",
",",
"endianness",
")",
"prop_data_type",
"=",
"types",
".",
"tds_data_types",
"[",
"types",
".",
"Uint32",
".",... | Read a property from a segment's metadata | [
"Read",
"a",
"property",
"from",
"a",
"segment",
"s",
"metadata"
] | d7d6632d4ebc2e78ed941477c2f1c56bd7493d74 | https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/tdms.py#L54-L61 |
5,544 | adamreeve/npTDMS | nptdms/tdms.py | read_string_data | def read_string_data(file, number_values, endianness):
""" Read string raw data
This is stored as an array of offsets
followed by the contiguous string data.
"""
offsets = [0]
for i in range(number_values):
offsets.append(types.Uint32.read(file, endianness))
strings = []
... | python | def read_string_data(file, number_values, endianness):
""" Read string raw data
This is stored as an array of offsets
followed by the contiguous string data.
"""
offsets = [0]
for i in range(number_values):
offsets.append(types.Uint32.read(file, endianness))
strings = []
... | [
"def",
"read_string_data",
"(",
"file",
",",
"number_values",
",",
"endianness",
")",
":",
"offsets",
"=",
"[",
"0",
"]",
"for",
"i",
"in",
"range",
"(",
"number_values",
")",
":",
"offsets",
".",
"append",
"(",
"types",
".",
"Uint32",
".",
"read",
"("... | Read string raw data
This is stored as an array of offsets
followed by the contiguous string data. | [
"Read",
"string",
"raw",
"data"
] | d7d6632d4ebc2e78ed941477c2f1c56bd7493d74 | https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/tdms.py#L1049-L1062 |
5,545 | adamreeve/npTDMS | nptdms/tdms.py | path_components | def path_components(path):
"""Convert a path into group and channel name components"""
def yield_components(path):
# Iterate over each character and the next character
chars = zip_longest(path, path[1:])
try:
# Iterate over components
while True:
... | python | def path_components(path):
"""Convert a path into group and channel name components"""
def yield_components(path):
# Iterate over each character and the next character
chars = zip_longest(path, path[1:])
try:
# Iterate over components
while True:
... | [
"def",
"path_components",
"(",
"path",
")",
":",
"def",
"yield_components",
"(",
"path",
")",
":",
"# Iterate over each character and the next character",
"chars",
"=",
"zip_longest",
"(",
"path",
",",
"path",
"[",
"1",
":",
"]",
")",
"try",
":",
"# Iterate over... | Convert a path into group and channel name components | [
"Convert",
"a",
"path",
"into",
"group",
"and",
"channel",
"name",
"components"
] | d7d6632d4ebc2e78ed941477c2f1c56bd7493d74 | https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/tdms.py#L1065-L1098 |
5,546 | adamreeve/npTDMS | nptdms/tdms.py | TdmsFile.object | def object(self, *path):
"""Get a TDMS object from the file
:param path: The object group and channel. Providing no channel
returns a group object, and providing no channel or group
will return the root object.
:rtype: :class:`TdmsObject`
For example, to get the... | python | def object(self, *path):
"""Get a TDMS object from the file
:param path: The object group and channel. Providing no channel
returns a group object, and providing no channel or group
will return the root object.
:rtype: :class:`TdmsObject`
For example, to get the... | [
"def",
"object",
"(",
"self",
",",
"*",
"path",
")",
":",
"object_path",
"=",
"self",
".",
"_path",
"(",
"*",
"path",
")",
"try",
":",
"return",
"self",
".",
"objects",
"[",
"object_path",
"]",
"except",
"KeyError",
":",
"raise",
"KeyError",
"(",
"\"... | Get a TDMS object from the file
:param path: The object group and channel. Providing no channel
returns a group object, and providing no channel or group
will return the root object.
:rtype: :class:`TdmsObject`
For example, to get the root object::
object()... | [
"Get",
"a",
"TDMS",
"object",
"from",
"the",
"file"
] | d7d6632d4ebc2e78ed941477c2f1c56bd7493d74 | https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/tdms.py#L132-L157 |
5,547 | adamreeve/npTDMS | nptdms/tdms.py | TdmsFile.groups | def groups(self):
"""Return the names of groups in the file
Note that there is not necessarily a TDMS object associated with
each group name.
:rtype: List of strings.
"""
# Split paths into components and take the first (group) component.
object_paths = (
... | python | def groups(self):
"""Return the names of groups in the file
Note that there is not necessarily a TDMS object associated with
each group name.
:rtype: List of strings.
"""
# Split paths into components and take the first (group) component.
object_paths = (
... | [
"def",
"groups",
"(",
"self",
")",
":",
"# Split paths into components and take the first (group) component.",
"object_paths",
"=",
"(",
"path_components",
"(",
"path",
")",
"for",
"path",
"in",
"self",
".",
"objects",
")",
"group_names",
"=",
"(",
"path",
"[",
"0... | Return the names of groups in the file
Note that there is not necessarily a TDMS object associated with
each group name.
:rtype: List of strings. | [
"Return",
"the",
"names",
"of",
"groups",
"in",
"the",
"file"
] | d7d6632d4ebc2e78ed941477c2f1c56bd7493d74 | https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/tdms.py#L159-L180 |
5,548 | adamreeve/npTDMS | nptdms/tdms.py | TdmsFile.group_channels | def group_channels(self, group):
"""Returns a list of channel objects for the given group
:param group: Name of the group to get channels for.
:rtype: List of :class:`TdmsObject` objects.
"""
path = self._path(group)
return [
self.objects[p]
for... | python | def group_channels(self, group):
"""Returns a list of channel objects for the given group
:param group: Name of the group to get channels for.
:rtype: List of :class:`TdmsObject` objects.
"""
path = self._path(group)
return [
self.objects[p]
for... | [
"def",
"group_channels",
"(",
"self",
",",
"group",
")",
":",
"path",
"=",
"self",
".",
"_path",
"(",
"group",
")",
"return",
"[",
"self",
".",
"objects",
"[",
"p",
"]",
"for",
"p",
"in",
"self",
".",
"objects",
"if",
"p",
".",
"startswith",
"(",
... | Returns a list of channel objects for the given group
:param group: Name of the group to get channels for.
:rtype: List of :class:`TdmsObject` objects. | [
"Returns",
"a",
"list",
"of",
"channel",
"objects",
"for",
"the",
"given",
"group"
] | d7d6632d4ebc2e78ed941477c2f1c56bd7493d74 | https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/tdms.py#L182-L194 |
5,549 | adamreeve/npTDMS | nptdms/tdms.py | TdmsFile.as_dataframe | def as_dataframe(self, time_index=False, absolute_time=False):
"""
Converts the TDMS file to a DataFrame
:param time_index: Whether to include a time index for the dataframe.
:param absolute_time: If time_index is true, whether the time index
values are absolute times or rel... | python | def as_dataframe(self, time_index=False, absolute_time=False):
"""
Converts the TDMS file to a DataFrame
:param time_index: Whether to include a time index for the dataframe.
:param absolute_time: If time_index is true, whether the time index
values are absolute times or rel... | [
"def",
"as_dataframe",
"(",
"self",
",",
"time_index",
"=",
"False",
",",
"absolute_time",
"=",
"False",
")",
":",
"import",
"pandas",
"as",
"pd",
"dataframe_dict",
"=",
"OrderedDict",
"(",
")",
"for",
"key",
",",
"value",
"in",
"self",
".",
"objects",
"... | Converts the TDMS file to a DataFrame
:param time_index: Whether to include a time index for the dataframe.
:param absolute_time: If time_index is true, whether the time index
values are absolute times or relative to the start time.
:return: The full TDMS file data.
:rtype: ... | [
"Converts",
"the",
"TDMS",
"file",
"to",
"a",
"DataFrame"
] | d7d6632d4ebc2e78ed941477c2f1c56bd7493d74 | https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/tdms.py#L208-L226 |
5,550 | adamreeve/npTDMS | nptdms/tdms.py | TdmsFile.as_hdf | def as_hdf(self, filepath, mode='w', group='/'):
"""
Converts the TDMS file into an HDF5 file
:param filepath: The path of the HDF5 file you want to write to.
:param mode: The write mode of the HDF5 file. This can be w, a ...
:param group: A group in the HDF5 file that will cont... | python | def as_hdf(self, filepath, mode='w', group='/'):
"""
Converts the TDMS file into an HDF5 file
:param filepath: The path of the HDF5 file you want to write to.
:param mode: The write mode of the HDF5 file. This can be w, a ...
:param group: A group in the HDF5 file that will cont... | [
"def",
"as_hdf",
"(",
"self",
",",
"filepath",
",",
"mode",
"=",
"'w'",
",",
"group",
"=",
"'/'",
")",
":",
"import",
"h5py",
"# Groups in TDMS are mapped to the first level of the HDF5 hierarchy",
"# Channels in TDMS are then mapped to the second level of the HDF5",
"# hiera... | Converts the TDMS file into an HDF5 file
:param filepath: The path of the HDF5 file you want to write to.
:param mode: The write mode of the HDF5 file. This can be w, a ...
:param group: A group in the HDF5 file that will contain the TDMS data. | [
"Converts",
"the",
"TDMS",
"file",
"into",
"an",
"HDF5",
"file"
] | d7d6632d4ebc2e78ed941477c2f1c56bd7493d74 | https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/tdms.py#L228-L284 |
5,551 | adamreeve/npTDMS | nptdms/tdms.py | _TdmsSegment.read_metadata | def read_metadata(self, f, objects, previous_segment=None):
"""Read segment metadata section and update object information"""
if not self.toc["kTocMetaData"]:
try:
self.ordered_objects = previous_segment.ordered_objects
except AttributeError:
rais... | python | def read_metadata(self, f, objects, previous_segment=None):
"""Read segment metadata section and update object information"""
if not self.toc["kTocMetaData"]:
try:
self.ordered_objects = previous_segment.ordered_objects
except AttributeError:
rais... | [
"def",
"read_metadata",
"(",
"self",
",",
"f",
",",
"objects",
",",
"previous_segment",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"toc",
"[",
"\"kTocMetaData\"",
"]",
":",
"try",
":",
"self",
".",
"ordered_objects",
"=",
"previous_segment",
".",
"... | Read segment metadata section and update object information | [
"Read",
"segment",
"metadata",
"section",
"and",
"update",
"object",
"information"
] | d7d6632d4ebc2e78ed941477c2f1c56bd7493d74 | https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/tdms.py#L359-L423 |
5,552 | adamreeve/npTDMS | nptdms/tdms.py | _TdmsSegment.calculate_chunks | def calculate_chunks(self):
"""
Work out the number of chunks the data is in, for cases
where the meta data doesn't change at all so there is no
lead in.
Also increments the number of values for objects in this
segment, based on the number of chunks.
"""
... | python | def calculate_chunks(self):
"""
Work out the number of chunks the data is in, for cases
where the meta data doesn't change at all so there is no
lead in.
Also increments the number of values for objects in this
segment, based on the number of chunks.
"""
... | [
"def",
"calculate_chunks",
"(",
"self",
")",
":",
"if",
"self",
".",
"toc",
"[",
"'kTocDAQmxRawData'",
"]",
":",
"# chunks defined differently for DAQmxRawData format",
"try",
":",
"data_size",
"=",
"next",
"(",
"o",
".",
"number_values",
"*",
"o",
".",
"raw_dat... | Work out the number of chunks the data is in, for cases
where the meta data doesn't change at all so there is no
lead in.
Also increments the number of values for objects in this
segment, based on the number of chunks. | [
"Work",
"out",
"the",
"number",
"of",
"chunks",
"the",
"data",
"is",
"in",
"for",
"cases",
"where",
"the",
"meta",
"data",
"doesn",
"t",
"change",
"at",
"all",
"so",
"there",
"is",
"no",
"lead",
"in",
"."
] | d7d6632d4ebc2e78ed941477c2f1c56bd7493d74 | https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/tdms.py#L425-L485 |
5,553 | adamreeve/npTDMS | nptdms/tdms.py | _TdmsSegment.read_raw_data | def read_raw_data(self, f):
"""Read signal data from file"""
if not self.toc["kTocRawData"]:
return
f.seek(self.data_position)
total_data_size = self.next_segment_offset - self.raw_data_offset
log.debug(
"Reading %d bytes of data at %d in %d chunks" %
... | python | def read_raw_data(self, f):
"""Read signal data from file"""
if not self.toc["kTocRawData"]:
return
f.seek(self.data_position)
total_data_size = self.next_segment_offset - self.raw_data_offset
log.debug(
"Reading %d bytes of data at %d in %d chunks" %
... | [
"def",
"read_raw_data",
"(",
"self",
",",
"f",
")",
":",
"if",
"not",
"self",
".",
"toc",
"[",
"\"kTocRawData\"",
"]",
":",
"return",
"f",
".",
"seek",
"(",
"self",
".",
"data_position",
")",
"total_data_size",
"=",
"self",
".",
"next_segment_offset",
"-... | Read signal data from file | [
"Read",
"signal",
"data",
"from",
"file"
] | d7d6632d4ebc2e78ed941477c2f1c56bd7493d74 | https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/tdms.py#L487-L532 |
5,554 | adamreeve/npTDMS | nptdms/tdms.py | _TdmsSegment._read_interleaved_numpy | def _read_interleaved_numpy(self, f, data_objects):
"""Read interleaved data where all channels have a numpy type"""
log.debug("Reading interleaved data all at once")
# Read all data into 1 byte unsigned ints first
all_channel_bytes = data_objects[0].raw_data_width
if all_channe... | python | def _read_interleaved_numpy(self, f, data_objects):
"""Read interleaved data where all channels have a numpy type"""
log.debug("Reading interleaved data all at once")
# Read all data into 1 byte unsigned ints first
all_channel_bytes = data_objects[0].raw_data_width
if all_channe... | [
"def",
"_read_interleaved_numpy",
"(",
"self",
",",
"f",
",",
"data_objects",
")",
":",
"log",
".",
"debug",
"(",
"\"Reading interleaved data all at once\"",
")",
"# Read all data into 1 byte unsigned ints first",
"all_channel_bytes",
"=",
"data_objects",
"[",
"0",
"]",
... | Read interleaved data where all channels have a numpy type | [
"Read",
"interleaved",
"data",
"where",
"all",
"channels",
"have",
"a",
"numpy",
"type"
] | d7d6632d4ebc2e78ed941477c2f1c56bd7493d74 | https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/tdms.py#L534-L562 |
5,555 | adamreeve/npTDMS | nptdms/tdms.py | _TdmsSegment._read_interleaved | def _read_interleaved(self, f, data_objects):
"""Read interleaved data that doesn't have a numpy type"""
log.debug("Reading interleaved data point by point")
object_data = {}
points_added = {}
for obj in data_objects:
object_data[obj.path] = obj._new_segment_data()
... | python | def _read_interleaved(self, f, data_objects):
"""Read interleaved data that doesn't have a numpy type"""
log.debug("Reading interleaved data point by point")
object_data = {}
points_added = {}
for obj in data_objects:
object_data[obj.path] = obj._new_segment_data()
... | [
"def",
"_read_interleaved",
"(",
"self",
",",
"f",
",",
"data_objects",
")",
":",
"log",
".",
"debug",
"(",
"\"Reading interleaved data point by point\"",
")",
"object_data",
"=",
"{",
"}",
"points_added",
"=",
"{",
"}",
"for",
"obj",
"in",
"data_objects",
":"... | Read interleaved data that doesn't have a numpy type | [
"Read",
"interleaved",
"data",
"that",
"doesn",
"t",
"have",
"a",
"numpy",
"type"
] | d7d6632d4ebc2e78ed941477c2f1c56bd7493d74 | https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/tdms.py#L564-L581 |
5,556 | adamreeve/npTDMS | nptdms/tdms.py | TdmsObject.time_track | def time_track(self, absolute_time=False, accuracy='ns'):
"""Return an array of time or the independent variable for this channel
This depends on the object having the wf_increment
and wf_start_offset properties defined.
Note that wf_start_offset is usually zero for time-series data.
... | python | def time_track(self, absolute_time=False, accuracy='ns'):
"""Return an array of time or the independent variable for this channel
This depends on the object having the wf_increment
and wf_start_offset properties defined.
Note that wf_start_offset is usually zero for time-series data.
... | [
"def",
"time_track",
"(",
"self",
",",
"absolute_time",
"=",
"False",
",",
"accuracy",
"=",
"'ns'",
")",
":",
"try",
":",
"increment",
"=",
"self",
".",
"property",
"(",
"'wf_increment'",
")",
"offset",
"=",
"self",
".",
"property",
"(",
"'wf_start_offset'... | Return an array of time or the independent variable for this channel
This depends on the object having the wf_increment
and wf_start_offset properties defined.
Note that wf_start_offset is usually zero for time-series data.
If you have time-series data channels with different start time... | [
"Return",
"an",
"array",
"of",
"time",
"or",
"the",
"independent",
"variable",
"for",
"this",
"channel"
] | d7d6632d4ebc2e78ed941477c2f1c56bd7493d74 | https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/tdms.py#L645-L706 |
5,557 | adamreeve/npTDMS | nptdms/tdms.py | TdmsObject._initialise_data | def _initialise_data(self, memmap_dir=None):
"""Initialise data array to zeros"""
if self.number_values == 0:
pass
elif self.data_type.nptype is None:
self._data = []
else:
if memmap_dir:
memmap_file = tempfile.NamedTemporaryFile(
... | python | def _initialise_data(self, memmap_dir=None):
"""Initialise data array to zeros"""
if self.number_values == 0:
pass
elif self.data_type.nptype is None:
self._data = []
else:
if memmap_dir:
memmap_file = tempfile.NamedTemporaryFile(
... | [
"def",
"_initialise_data",
"(",
"self",
",",
"memmap_dir",
"=",
"None",
")",
":",
"if",
"self",
".",
"number_values",
"==",
"0",
":",
"pass",
"elif",
"self",
".",
"data_type",
".",
"nptype",
"is",
"None",
":",
"self",
".",
"_data",
"=",
"[",
"]",
"el... | Initialise data array to zeros | [
"Initialise",
"data",
"array",
"to",
"zeros"
] | d7d6632d4ebc2e78ed941477c2f1c56bd7493d74 | https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/tdms.py#L708-L732 |
5,558 | adamreeve/npTDMS | nptdms/tdms.py | TdmsObject._update_data | def _update_data(self, new_data):
"""Update the object data with a new array of data"""
log.debug("Adding %d data points to data for %s" %
(len(new_data), self.path))
if self._data is None:
self._data = new_data
else:
if self.data_type.nptype is... | python | def _update_data(self, new_data):
"""Update the object data with a new array of data"""
log.debug("Adding %d data points to data for %s" %
(len(new_data), self.path))
if self._data is None:
self._data = new_data
else:
if self.data_type.nptype is... | [
"def",
"_update_data",
"(",
"self",
",",
"new_data",
")",
":",
"log",
".",
"debug",
"(",
"\"Adding %d data points to data for %s\"",
"%",
"(",
"len",
"(",
"new_data",
")",
",",
"self",
".",
"path",
")",
")",
"if",
"self",
".",
"_data",
"is",
"None",
":",... | Update the object data with a new array of data | [
"Update",
"the",
"object",
"data",
"with",
"a",
"new",
"array",
"of",
"data"
] | d7d6632d4ebc2e78ed941477c2f1c56bd7493d74 | https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/tdms.py#L734-L749 |
5,559 | adamreeve/npTDMS | nptdms/tdms.py | TdmsObject.as_dataframe | def as_dataframe(self, absolute_time=False):
"""
Converts the TDMS object to a DataFrame
:param absolute_time: Whether times should be absolute rather than
relative to the start time.
:return: The TDMS object data.
:rtype: pandas.DataFrame
"""
import... | python | def as_dataframe(self, absolute_time=False):
"""
Converts the TDMS object to a DataFrame
:param absolute_time: Whether times should be absolute rather than
relative to the start time.
:return: The TDMS object data.
:rtype: pandas.DataFrame
"""
import... | [
"def",
"as_dataframe",
"(",
"self",
",",
"absolute_time",
"=",
"False",
")",
":",
"import",
"pandas",
"as",
"pd",
"# When absolute_time is True,",
"# use the wf_start_time as offset for the time_track()",
"try",
":",
"time",
"=",
"self",
".",
"time_track",
"(",
"absol... | Converts the TDMS object to a DataFrame
:param absolute_time: Whether times should be absolute rather than
relative to the start time.
:return: The TDMS object data.
:rtype: pandas.DataFrame | [
"Converts",
"the",
"TDMS",
"object",
"to",
"a",
"DataFrame"
] | d7d6632d4ebc2e78ed941477c2f1c56bd7493d74 | https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/tdms.py#L751-L774 |
5,560 | adamreeve/npTDMS | nptdms/tdms.py | TdmsObject.data | def data(self):
"""
NumPy array containing data if there is data for this object,
otherwise None.
"""
if self._data is None:
# self._data is None if data segment is empty
return np.empty((0, 1))
if self._data_scaled is None:
scale = sca... | python | def data(self):
"""
NumPy array containing data if there is data for this object,
otherwise None.
"""
if self._data is None:
# self._data is None if data segment is empty
return np.empty((0, 1))
if self._data_scaled is None:
scale = sca... | [
"def",
"data",
"(",
"self",
")",
":",
"if",
"self",
".",
"_data",
"is",
"None",
":",
"# self._data is None if data segment is empty",
"return",
"np",
".",
"empty",
"(",
"(",
"0",
",",
"1",
")",
")",
"if",
"self",
".",
"_data_scaled",
"is",
"None",
":",
... | NumPy array containing data if there is data for this object,
otherwise None. | [
"NumPy",
"array",
"containing",
"data",
"if",
"there",
"is",
"data",
"for",
"this",
"object",
"otherwise",
"None",
"."
] | d7d6632d4ebc2e78ed941477c2f1c56bd7493d74 | https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/tdms.py#L777-L792 |
5,561 | adamreeve/npTDMS | nptdms/tdms.py | _TdmsmxDAQMetadata._read_metadata | def _read_metadata(self, f, endianness):
"""
Read the metadata for a DAQmx raw segment. This is the raw
DAQmx-specific portion of the raw data index.
"""
self.data_type = types.tds_data_types[0xFFFFFFFF]
self.dimension = types.Uint32.read(f, endianness)
# In TDMS... | python | def _read_metadata(self, f, endianness):
"""
Read the metadata for a DAQmx raw segment. This is the raw
DAQmx-specific portion of the raw data index.
"""
self.data_type = types.tds_data_types[0xFFFFFFFF]
self.dimension = types.Uint32.read(f, endianness)
# In TDMS... | [
"def",
"_read_metadata",
"(",
"self",
",",
"f",
",",
"endianness",
")",
":",
"self",
".",
"data_type",
"=",
"types",
".",
"tds_data_types",
"[",
"0xFFFFFFFF",
"]",
"self",
".",
"dimension",
"=",
"types",
".",
"Uint32",
".",
"read",
"(",
"f",
",",
"endi... | Read the metadata for a DAQmx raw segment. This is the raw
DAQmx-specific portion of the raw data index. | [
"Read",
"the",
"metadata",
"for",
"a",
"DAQmx",
"raw",
"segment",
".",
"This",
"is",
"the",
"raw",
"DAQmx",
"-",
"specific",
"portion",
"of",
"the",
"raw",
"data",
"index",
"."
] | d7d6632d4ebc2e78ed941477c2f1c56bd7493d74 | https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/tdms.py#L832-L869 |
5,562 | adamreeve/npTDMS | nptdms/tdms.py | _TdmsSegmentObject._read_metadata | def _read_metadata(self, f):
"""Read object metadata and update object information"""
raw_data_index = types.Uint32.read(f, self.endianness)
log.debug("Reading metadata for object %s", self.tdms_object.path)
# Object has no data in this segment
if raw_data_index == 0xFFFFFFFF:... | python | def _read_metadata(self, f):
"""Read object metadata and update object information"""
raw_data_index = types.Uint32.read(f, self.endianness)
log.debug("Reading metadata for object %s", self.tdms_object.path)
# Object has no data in this segment
if raw_data_index == 0xFFFFFFFF:... | [
"def",
"_read_metadata",
"(",
"self",
",",
"f",
")",
":",
"raw_data_index",
"=",
"types",
".",
"Uint32",
".",
"read",
"(",
"f",
",",
"self",
".",
"endianness",
")",
"log",
".",
"debug",
"(",
"\"Reading metadata for object %s\"",
",",
"self",
".",
"tdms_obj... | Read object metadata and update object information | [
"Read",
"object",
"metadata",
"and",
"update",
"object",
"information"
] | d7d6632d4ebc2e78ed941477c2f1c56bd7493d74 | https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/tdms.py#L919-L1011 |
5,563 | adamreeve/npTDMS | nptdms/tdms.py | _TdmsSegmentObject._read_value | def _read_value(self, file):
"""Read a single value from the given file"""
if self.data_type.nptype is not None:
dtype = (np.dtype(self.data_type.nptype).newbyteorder(
self.endianness))
return fromfile(file, dtype=dtype, count=1)
return self.data_type.rea... | python | def _read_value(self, file):
"""Read a single value from the given file"""
if self.data_type.nptype is not None:
dtype = (np.dtype(self.data_type.nptype).newbyteorder(
self.endianness))
return fromfile(file, dtype=dtype, count=1)
return self.data_type.rea... | [
"def",
"_read_value",
"(",
"self",
",",
"file",
")",
":",
"if",
"self",
".",
"data_type",
".",
"nptype",
"is",
"not",
"None",
":",
"dtype",
"=",
"(",
"np",
".",
"dtype",
"(",
"self",
".",
"data_type",
".",
"nptype",
")",
".",
"newbyteorder",
"(",
"... | Read a single value from the given file | [
"Read",
"a",
"single",
"value",
"from",
"the",
"given",
"file"
] | d7d6632d4ebc2e78ed941477c2f1c56bd7493d74 | https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/tdms.py#L1017-L1024 |
5,564 | adamreeve/npTDMS | nptdms/tdms.py | _TdmsSegmentObject._read_values | def _read_values(self, file, number_values):
"""Read all values for this object from a contiguous segment"""
if self.data_type.nptype is not None:
dtype = (np.dtype(self.data_type.nptype).newbyteorder(
self.endianness))
return fromfile(file, dtype=dtype, count=nu... | python | def _read_values(self, file, number_values):
"""Read all values for this object from a contiguous segment"""
if self.data_type.nptype is not None:
dtype = (np.dtype(self.data_type.nptype).newbyteorder(
self.endianness))
return fromfile(file, dtype=dtype, count=nu... | [
"def",
"_read_values",
"(",
"self",
",",
"file",
",",
"number_values",
")",
":",
"if",
"self",
".",
"data_type",
".",
"nptype",
"is",
"not",
"None",
":",
"dtype",
"=",
"(",
"np",
".",
"dtype",
"(",
"self",
".",
"data_type",
".",
"nptype",
")",
".",
... | Read all values for this object from a contiguous segment | [
"Read",
"all",
"values",
"for",
"this",
"object",
"from",
"a",
"contiguous",
"segment"
] | d7d6632d4ebc2e78ed941477c2f1c56bd7493d74 | https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/tdms.py#L1026-L1038 |
5,565 | adamreeve/npTDMS | nptdms/tdms.py | _TdmsSegmentObject._new_segment_data | def _new_segment_data(self):
"""Return a new array to read the data of the current section into"""
if self.data_type.nptype is not None:
return np.zeros(self.number_values, dtype=self.data_type.nptype)
else:
return [None] * self.number_values | python | def _new_segment_data(self):
"""Return a new array to read the data of the current section into"""
if self.data_type.nptype is not None:
return np.zeros(self.number_values, dtype=self.data_type.nptype)
else:
return [None] * self.number_values | [
"def",
"_new_segment_data",
"(",
"self",
")",
":",
"if",
"self",
".",
"data_type",
".",
"nptype",
"is",
"not",
"None",
":",
"return",
"np",
".",
"zeros",
"(",
"self",
".",
"number_values",
",",
"dtype",
"=",
"self",
".",
"data_type",
".",
"nptype",
")"... | Return a new array to read the data of the current section into | [
"Return",
"a",
"new",
"array",
"to",
"read",
"the",
"data",
"of",
"the",
"current",
"section",
"into"
] | d7d6632d4ebc2e78ed941477c2f1c56bd7493d74 | https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/tdms.py#L1040-L1046 |
5,566 | apriha/lineage | src/lineage/snps.py | detect_build | def detect_build(snps):
""" Detect build of SNPs.
Use the coordinates of common SNPs to identify the build / assembly of a genotype file
that is being loaded.
Notes
-----
rs3094315 : plus strand in 36, 37, and 38
rs11928389 : plus strand in 36, minus strand in 37 and 38
rs2500347 : plu... | python | def detect_build(snps):
""" Detect build of SNPs.
Use the coordinates of common SNPs to identify the build / assembly of a genotype file
that is being loaded.
Notes
-----
rs3094315 : plus strand in 36, 37, and 38
rs11928389 : plus strand in 36, minus strand in 37 and 38
rs2500347 : plu... | [
"def",
"detect_build",
"(",
"snps",
")",
":",
"def",
"lookup_build_with_snp_pos",
"(",
"pos",
",",
"s",
")",
":",
"try",
":",
"return",
"s",
".",
"loc",
"[",
"s",
"==",
"pos",
"]",
".",
"index",
"[",
"0",
"]",
"except",
":",
"return",
"None",
"buil... | Detect build of SNPs.
Use the coordinates of common SNPs to identify the build / assembly of a genotype file
that is being loaded.
Notes
-----
rs3094315 : plus strand in 36, 37, and 38
rs11928389 : plus strand in 36, minus strand in 37 and 38
rs2500347 : plus strand in 36 and 37, minus str... | [
"Detect",
"build",
"of",
"SNPs",
"."
] | 13106a62a959a80ac26c68d1566422de08aa877b | https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/snps.py#L491-L553 |
5,567 | apriha/lineage | src/lineage/snps.py | get_chromosomes | def get_chromosomes(snps):
""" Get the chromosomes of SNPs.
Parameters
----------
snps : pandas.DataFrame
Returns
-------
list
list of str chromosomes (e.g., ['1', '2', '3', 'MT'], empty list if no chromosomes
"""
if isinstance(snps, pd.DataFrame):
return list(pd.u... | python | def get_chromosomes(snps):
""" Get the chromosomes of SNPs.
Parameters
----------
snps : pandas.DataFrame
Returns
-------
list
list of str chromosomes (e.g., ['1', '2', '3', 'MT'], empty list if no chromosomes
"""
if isinstance(snps, pd.DataFrame):
return list(pd.u... | [
"def",
"get_chromosomes",
"(",
"snps",
")",
":",
"if",
"isinstance",
"(",
"snps",
",",
"pd",
".",
"DataFrame",
")",
":",
"return",
"list",
"(",
"pd",
".",
"unique",
"(",
"snps",
"[",
"\"chrom\"",
"]",
")",
")",
"else",
":",
"return",
"[",
"]"
] | Get the chromosomes of SNPs.
Parameters
----------
snps : pandas.DataFrame
Returns
-------
list
list of str chromosomes (e.g., ['1', '2', '3', 'MT'], empty list if no chromosomes | [
"Get",
"the",
"chromosomes",
"of",
"SNPs",
"."
] | 13106a62a959a80ac26c68d1566422de08aa877b | https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/snps.py#L597-L613 |
5,568 | apriha/lineage | src/lineage/snps.py | get_chromosomes_summary | def get_chromosomes_summary(snps):
""" Summary of the chromosomes of SNPs.
Parameters
----------
snps : pandas.DataFrame
Returns
-------
str
human-readable listing of chromosomes (e.g., '1-3, MT'), empty str if no chromosomes
"""
if isinstance(snps, pd.DataFrame):
... | python | def get_chromosomes_summary(snps):
""" Summary of the chromosomes of SNPs.
Parameters
----------
snps : pandas.DataFrame
Returns
-------
str
human-readable listing of chromosomes (e.g., '1-3, MT'), empty str if no chromosomes
"""
if isinstance(snps, pd.DataFrame):
... | [
"def",
"get_chromosomes_summary",
"(",
"snps",
")",
":",
"if",
"isinstance",
"(",
"snps",
",",
"pd",
".",
"DataFrame",
")",
":",
"chroms",
"=",
"list",
"(",
"pd",
".",
"unique",
"(",
"snps",
"[",
"\"chrom\"",
"]",
")",
")",
"int_chroms",
"=",
"[",
"i... | Summary of the chromosomes of SNPs.
Parameters
----------
snps : pandas.DataFrame
Returns
-------
str
human-readable listing of chromosomes (e.g., '1-3, MT'), empty str if no chromosomes | [
"Summary",
"of",
"the",
"chromosomes",
"of",
"SNPs",
"."
] | 13106a62a959a80ac26c68d1566422de08aa877b | https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/snps.py#L616-L655 |
5,569 | apriha/lineage | src/lineage/snps.py | determine_sex | def determine_sex(
snps, y_snps_not_null_threshold=0.1, heterozygous_x_snps_threshold=0.01
):
""" Determine sex from SNPs using thresholds.
Parameters
----------
snps : pandas.DataFrame
y_snps_not_null_threshold : float
percentage Y SNPs that are not null; above this threshold, Male is ... | python | def determine_sex(
snps, y_snps_not_null_threshold=0.1, heterozygous_x_snps_threshold=0.01
):
""" Determine sex from SNPs using thresholds.
Parameters
----------
snps : pandas.DataFrame
y_snps_not_null_threshold : float
percentage Y SNPs that are not null; above this threshold, Male is ... | [
"def",
"determine_sex",
"(",
"snps",
",",
"y_snps_not_null_threshold",
"=",
"0.1",
",",
"heterozygous_x_snps_threshold",
"=",
"0.01",
")",
":",
"if",
"isinstance",
"(",
"snps",
",",
"pd",
".",
"DataFrame",
")",
":",
"y_snps",
"=",
"len",
"(",
"snps",
".",
... | Determine sex from SNPs using thresholds.
Parameters
----------
snps : pandas.DataFrame
y_snps_not_null_threshold : float
percentage Y SNPs that are not null; above this threshold, Male is determined
heterozygous_x_snps_threshold : float
percentage heterozygous X SNPs; above this th... | [
"Determine",
"sex",
"from",
"SNPs",
"using",
"thresholds",
"."
] | 13106a62a959a80ac26c68d1566422de08aa877b | https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/snps.py#L658-L708 |
5,570 | apriha/lineage | src/lineage/snps.py | sort_snps | def sort_snps(snps):
""" Sort SNPs based on ordered chromosome list and position. """
sorted_list = sorted(snps["chrom"].unique(), key=_natural_sort_key)
# move PAR and MT to the end of the dataframe
if "PAR" in sorted_list:
sorted_list.remove("PAR")
sorted_list.append("PAR")
if "... | python | def sort_snps(snps):
""" Sort SNPs based on ordered chromosome list and position. """
sorted_list = sorted(snps["chrom"].unique(), key=_natural_sort_key)
# move PAR and MT to the end of the dataframe
if "PAR" in sorted_list:
sorted_list.remove("PAR")
sorted_list.append("PAR")
if "... | [
"def",
"sort_snps",
"(",
"snps",
")",
":",
"sorted_list",
"=",
"sorted",
"(",
"snps",
"[",
"\"chrom\"",
"]",
".",
"unique",
"(",
")",
",",
"key",
"=",
"_natural_sort_key",
")",
"# move PAR and MT to the end of the dataframe",
"if",
"\"PAR\"",
"in",
"sorted_list"... | Sort SNPs based on ordered chromosome list and position. | [
"Sort",
"SNPs",
"based",
"on",
"ordered",
"chromosome",
"list",
"and",
"position",
"."
] | 13106a62a959a80ac26c68d1566422de08aa877b | https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/snps.py#L711-L737 |
5,571 | apriha/lineage | src/lineage/snps.py | SNPs.get_summary | def get_summary(self):
""" Get summary of ``SNPs``.
Returns
-------
dict
summary info, else None if ``SNPs`` is not valid
"""
if not self.is_valid():
return None
else:
return {
"source": self.source,
... | python | def get_summary(self):
""" Get summary of ``SNPs``.
Returns
-------
dict
summary info, else None if ``SNPs`` is not valid
"""
if not self.is_valid():
return None
else:
return {
"source": self.source,
... | [
"def",
"get_summary",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"is_valid",
"(",
")",
":",
"return",
"None",
"else",
":",
"return",
"{",
"\"source\"",
":",
"self",
".",
"source",
",",
"\"assembly\"",
":",
"self",
".",
"assembly",
",",
"\"build\"... | Get summary of ``SNPs``.
Returns
-------
dict
summary info, else None if ``SNPs`` is not valid | [
"Get",
"summary",
"of",
"SNPs",
"."
] | 13106a62a959a80ac26c68d1566422de08aa877b | https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/snps.py#L113-L132 |
5,572 | apriha/lineage | src/lineage/snps.py | SNPs._read_23andme | def _read_23andme(file):
""" Read and parse 23andMe file.
https://www.23andme.com
Parameters
----------
file : str
path to file
Returns
-------
pandas.DataFrame
individual's genetic data normalized for use with `lineage`
... | python | def _read_23andme(file):
""" Read and parse 23andMe file.
https://www.23andme.com
Parameters
----------
file : str
path to file
Returns
-------
pandas.DataFrame
individual's genetic data normalized for use with `lineage`
... | [
"def",
"_read_23andme",
"(",
"file",
")",
":",
"df",
"=",
"pd",
".",
"read_csv",
"(",
"file",
",",
"comment",
"=",
"\"#\"",
",",
"sep",
"=",
"\"\\t\"",
",",
"na_values",
"=",
"\"--\"",
",",
"names",
"=",
"[",
"\"rsid\"",
",",
"\"chrom\"",
",",
"\"pos... | Read and parse 23andMe file.
https://www.23andme.com
Parameters
----------
file : str
path to file
Returns
-------
pandas.DataFrame
individual's genetic data normalized for use with `lineage`
str
name of data source | [
"Read",
"and",
"parse",
"23andMe",
"file",
"."
] | 13106a62a959a80ac26c68d1566422de08aa877b | https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/snps.py#L204-L231 |
5,573 | apriha/lineage | src/lineage/snps.py | SNPs._read_lineage_csv | def _read_lineage_csv(file, comments):
""" Read and parse CSV file generated by lineage.
Parameters
----------
file : str
path to file
comments : str
comments at beginning of file
Returns
-------
pandas.DataFrame
indiv... | python | def _read_lineage_csv(file, comments):
""" Read and parse CSV file generated by lineage.
Parameters
----------
file : str
path to file
comments : str
comments at beginning of file
Returns
-------
pandas.DataFrame
indiv... | [
"def",
"_read_lineage_csv",
"(",
"file",
",",
"comments",
")",
":",
"source",
"=",
"\"\"",
"for",
"comment",
"in",
"comments",
".",
"split",
"(",
"\"\\n\"",
")",
":",
"if",
"\"Source(s):\"",
"in",
"comment",
":",
"source",
"=",
"comment",
".",
"split",
"... | Read and parse CSV file generated by lineage.
Parameters
----------
file : str
path to file
comments : str
comments at beginning of file
Returns
-------
pandas.DataFrame
individual's genetic data normalized for use with `linea... | [
"Read",
"and",
"parse",
"CSV",
"file",
"generated",
"by",
"lineage",
"."
] | 13106a62a959a80ac26c68d1566422de08aa877b | https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/snps.py#L354-L387 |
5,574 | apriha/lineage | src/lineage/snps.py | SNPs._read_generic_csv | def _read_generic_csv(file):
""" Read and parse generic CSV file.
Notes
-----
Assumes columns are 'rsid', 'chrom' / 'chromosome', 'pos' / 'position', and 'genotype';
values are comma separated; unreported genotypes are indicated by '--'; and one header row
precedes data.... | python | def _read_generic_csv(file):
""" Read and parse generic CSV file.
Notes
-----
Assumes columns are 'rsid', 'chrom' / 'chromosome', 'pos' / 'position', and 'genotype';
values are comma separated; unreported genotypes are indicated by '--'; and one header row
precedes data.... | [
"def",
"_read_generic_csv",
"(",
"file",
")",
":",
"df",
"=",
"pd",
".",
"read_csv",
"(",
"file",
",",
"skiprows",
"=",
"1",
",",
"na_values",
"=",
"\"--\"",
",",
"names",
"=",
"[",
"\"rsid\"",
",",
"\"chrom\"",
",",
"\"pos\"",
",",
"\"genotype\"",
"]"... | Read and parse generic CSV file.
Notes
-----
Assumes columns are 'rsid', 'chrom' / 'chromosome', 'pos' / 'position', and 'genotype';
values are comma separated; unreported genotypes are indicated by '--'; and one header row
precedes data. For example:
rsid,chromosom... | [
"Read",
"and",
"parse",
"generic",
"CSV",
"file",
"."
] | 13106a62a959a80ac26c68d1566422de08aa877b | https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/snps.py#L390-L425 |
5,575 | apriha/lineage | src/lineage/snps.py | SNPs._assign_par_snps | def _assign_par_snps(self):
""" Assign PAR SNPs to the X or Y chromosome using SNP position.
References
-----
..[1] National Center for Biotechnology Information, Variation Services, RefSNP,
https://api.ncbi.nlm.nih.gov/variation/v0/
..[2] Yates et. al. (doi:10.1093/bi... | python | def _assign_par_snps(self):
""" Assign PAR SNPs to the X or Y chromosome using SNP position.
References
-----
..[1] National Center for Biotechnology Information, Variation Services, RefSNP,
https://api.ncbi.nlm.nih.gov/variation/v0/
..[2] Yates et. al. (doi:10.1093/bi... | [
"def",
"_assign_par_snps",
"(",
"self",
")",
":",
"rest_client",
"=",
"EnsemblRestClient",
"(",
"server",
"=",
"\"https://api.ncbi.nlm.nih.gov\"",
")",
"for",
"rsid",
"in",
"self",
".",
"snps",
".",
"loc",
"[",
"self",
".",
"snps",
"[",
"\"chrom\"",
"]",
"==... | Assign PAR SNPs to the X or Y chromosome using SNP position.
References
-----
..[1] National Center for Biotechnology Information, Variation Services, RefSNP,
https://api.ncbi.nlm.nih.gov/variation/v0/
..[2] Yates et. al. (doi:10.1093/bioinformatics/btu613),
http://e... | [
"Assign",
"PAR",
"SNPs",
"to",
"the",
"X",
"or",
"Y",
"chromosome",
"using",
"SNP",
"position",
"."
] | 13106a62a959a80ac26c68d1566422de08aa877b | https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/snps.py#L427-L472 |
5,576 | apriha/lineage | src/lineage/visualization.py | plot_chromosomes | def plot_chromosomes(one_chrom_match, two_chrom_match, cytobands, path, title, build):
""" Plots chromosomes with designated markers.
Parameters
----------
one_chrom_match : list of dicts
segments to highlight on the chromosomes representing one shared chromosome
two_chrom_match : list of d... | python | def plot_chromosomes(one_chrom_match, two_chrom_match, cytobands, path, title, build):
""" Plots chromosomes with designated markers.
Parameters
----------
one_chrom_match : list of dicts
segments to highlight on the chromosomes representing one shared chromosome
two_chrom_match : list of d... | [
"def",
"plot_chromosomes",
"(",
"one_chrom_match",
",",
"two_chrom_match",
",",
"cytobands",
",",
"path",
",",
"title",
",",
"build",
")",
":",
"# Height of each chromosome",
"chrom_height",
"=",
"1.25",
"# Spacing between consecutive chromosomes",
"chrom_spacing",
"=",
... | Plots chromosomes with designated markers.
Parameters
----------
one_chrom_match : list of dicts
segments to highlight on the chromosomes representing one shared chromosome
two_chrom_match : list of dicts
segments to highlight on the chromosomes representing two shared chromosomes
c... | [
"Plots",
"chromosomes",
"with",
"designated",
"markers",
"."
] | 13106a62a959a80ac26c68d1566422de08aa877b | https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/visualization.py#L69-L169 |
5,577 | apriha/lineage | src/lineage/__init__.py | create_dir | def create_dir(path):
""" Create directory specified by `path` if it doesn't already exist.
Parameters
----------
path : str
path to directory
Returns
-------
bool
True if `path` exists
"""
# https://stackoverflow.com/a/5032238
try:
os.makedirs(path, exi... | python | def create_dir(path):
""" Create directory specified by `path` if it doesn't already exist.
Parameters
----------
path : str
path to directory
Returns
-------
bool
True if `path` exists
"""
# https://stackoverflow.com/a/5032238
try:
os.makedirs(path, exi... | [
"def",
"create_dir",
"(",
"path",
")",
":",
"# https://stackoverflow.com/a/5032238",
"try",
":",
"os",
".",
"makedirs",
"(",
"path",
",",
"exist_ok",
"=",
"True",
")",
"except",
"Exception",
"as",
"err",
":",
"print",
"(",
"err",
")",
"return",
"False",
"i... | Create directory specified by `path` if it doesn't already exist.
Parameters
----------
path : str
path to directory
Returns
-------
bool
True if `path` exists | [
"Create",
"directory",
"specified",
"by",
"path",
"if",
"it",
"doesn",
"t",
"already",
"exist",
"."
] | 13106a62a959a80ac26c68d1566422de08aa877b | https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/__init__.py#L859-L882 |
5,578 | apriha/lineage | src/lineage/__init__.py | save_df_as_csv | def save_df_as_csv(df, path, filename, comment=None, **kwargs):
""" Save dataframe to a CSV file.
Parameters
----------
df : pandas.DataFrame
dataframe to save
path : str
path to directory where to save CSV file
filename : str
filename of CSV file
comment : str
... | python | def save_df_as_csv(df, path, filename, comment=None, **kwargs):
""" Save dataframe to a CSV file.
Parameters
----------
df : pandas.DataFrame
dataframe to save
path : str
path to directory where to save CSV file
filename : str
filename of CSV file
comment : str
... | [
"def",
"save_df_as_csv",
"(",
"df",
",",
"path",
",",
"filename",
",",
"comment",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"df",
",",
"pd",
".",
"DataFrame",
")",
"and",
"len",
"(",
"df",
")",
">",
"0",
":",
"try",... | Save dataframe to a CSV file.
Parameters
----------
df : pandas.DataFrame
dataframe to save
path : str
path to directory where to save CSV file
filename : str
filename of CSV file
comment : str
header comment(s); one or more lines starting with '#'
**kwargs
... | [
"Save",
"dataframe",
"to",
"a",
"CSV",
"file",
"."
] | 13106a62a959a80ac26c68d1566422de08aa877b | https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/__init__.py#L885-L940 |
5,579 | apriha/lineage | src/lineage/resources.py | Resources.get_genetic_map_HapMapII_GRCh37 | def get_genetic_map_HapMapII_GRCh37(self):
""" Get International HapMap Consortium HapMap Phase II genetic map for Build 37.
Returns
-------
dict
dict of pandas.DataFrame HapMapII genetic maps if loading was successful, else None
"""
if self._genetic_map_HapM... | python | def get_genetic_map_HapMapII_GRCh37(self):
""" Get International HapMap Consortium HapMap Phase II genetic map for Build 37.
Returns
-------
dict
dict of pandas.DataFrame HapMapII genetic maps if loading was successful, else None
"""
if self._genetic_map_HapM... | [
"def",
"get_genetic_map_HapMapII_GRCh37",
"(",
"self",
")",
":",
"if",
"self",
".",
"_genetic_map_HapMapII_GRCh37",
"is",
"None",
":",
"self",
".",
"_genetic_map_HapMapII_GRCh37",
"=",
"self",
".",
"_load_genetic_map",
"(",
"self",
".",
"_get_path_genetic_map_HapMapII_G... | Get International HapMap Consortium HapMap Phase II genetic map for Build 37.
Returns
-------
dict
dict of pandas.DataFrame HapMapII genetic maps if loading was successful, else None | [
"Get",
"International",
"HapMap",
"Consortium",
"HapMap",
"Phase",
"II",
"genetic",
"map",
"for",
"Build",
"37",
"."
] | 13106a62a959a80ac26c68d1566422de08aa877b | https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/resources.py#L83-L96 |
5,580 | apriha/lineage | src/lineage/resources.py | Resources.get_cytoBand_hg19 | def get_cytoBand_hg19(self):
""" Get UCSC cytoBand table for Build 37.
Returns
-------
pandas.DataFrame
cytoBand table if loading was successful, else None
"""
if self._cytoBand_hg19 is None:
self._cytoBand_hg19 = self._load_cytoBand(self._get_pat... | python | def get_cytoBand_hg19(self):
""" Get UCSC cytoBand table for Build 37.
Returns
-------
pandas.DataFrame
cytoBand table if loading was successful, else None
"""
if self._cytoBand_hg19 is None:
self._cytoBand_hg19 = self._load_cytoBand(self._get_pat... | [
"def",
"get_cytoBand_hg19",
"(",
"self",
")",
":",
"if",
"self",
".",
"_cytoBand_hg19",
"is",
"None",
":",
"self",
".",
"_cytoBand_hg19",
"=",
"self",
".",
"_load_cytoBand",
"(",
"self",
".",
"_get_path_cytoBand_hg19",
"(",
")",
")",
"return",
"self",
".",
... | Get UCSC cytoBand table for Build 37.
Returns
-------
pandas.DataFrame
cytoBand table if loading was successful, else None | [
"Get",
"UCSC",
"cytoBand",
"table",
"for",
"Build",
"37",
"."
] | 13106a62a959a80ac26c68d1566422de08aa877b | https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/resources.py#L98-L109 |
5,581 | apriha/lineage | src/lineage/resources.py | Resources.get_knownGene_hg19 | def get_knownGene_hg19(self):
""" Get UCSC knownGene table for Build 37.
Returns
-------
pandas.DataFrame
knownGene table if loading was successful, else None
"""
if self._knownGene_hg19 is None:
self._knownGene_hg19 = self._load_knownGene(self._g... | python | def get_knownGene_hg19(self):
""" Get UCSC knownGene table for Build 37.
Returns
-------
pandas.DataFrame
knownGene table if loading was successful, else None
"""
if self._knownGene_hg19 is None:
self._knownGene_hg19 = self._load_knownGene(self._g... | [
"def",
"get_knownGene_hg19",
"(",
"self",
")",
":",
"if",
"self",
".",
"_knownGene_hg19",
"is",
"None",
":",
"self",
".",
"_knownGene_hg19",
"=",
"self",
".",
"_load_knownGene",
"(",
"self",
".",
"_get_path_knownGene_hg19",
"(",
")",
")",
"return",
"self",
"... | Get UCSC knownGene table for Build 37.
Returns
-------
pandas.DataFrame
knownGene table if loading was successful, else None | [
"Get",
"UCSC",
"knownGene",
"table",
"for",
"Build",
"37",
"."
] | 13106a62a959a80ac26c68d1566422de08aa877b | https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/resources.py#L111-L122 |
5,582 | apriha/lineage | src/lineage/resources.py | Resources.get_kgXref_hg19 | def get_kgXref_hg19(self):
""" Get UCSC kgXref table for Build 37.
Returns
-------
pandas.DataFrame
kgXref table if loading was successful, else None
"""
if self._kgXref_hg19 is None:
self._kgXref_hg19 = self._load_kgXref(self._get_path_kgXref_hg1... | python | def get_kgXref_hg19(self):
""" Get UCSC kgXref table for Build 37.
Returns
-------
pandas.DataFrame
kgXref table if loading was successful, else None
"""
if self._kgXref_hg19 is None:
self._kgXref_hg19 = self._load_kgXref(self._get_path_kgXref_hg1... | [
"def",
"get_kgXref_hg19",
"(",
"self",
")",
":",
"if",
"self",
".",
"_kgXref_hg19",
"is",
"None",
":",
"self",
".",
"_kgXref_hg19",
"=",
"self",
".",
"_load_kgXref",
"(",
"self",
".",
"_get_path_kgXref_hg19",
"(",
")",
")",
"return",
"self",
".",
"_kgXref_... | Get UCSC kgXref table for Build 37.
Returns
-------
pandas.DataFrame
kgXref table if loading was successful, else None | [
"Get",
"UCSC",
"kgXref",
"table",
"for",
"Build",
"37",
"."
] | 13106a62a959a80ac26c68d1566422de08aa877b | https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/resources.py#L124-L135 |
5,583 | apriha/lineage | src/lineage/resources.py | Resources.get_assembly_mapping_data | def get_assembly_mapping_data(self, source_assembly, target_assembly):
""" Get assembly mapping data.
Parameters
----------
source_assembly : {'NCBI36', 'GRCh37', 'GRCh38'}
assembly to remap from
target_assembly : {'NCBI36', 'GRCh37', 'GRCh38'}
assembly t... | python | def get_assembly_mapping_data(self, source_assembly, target_assembly):
""" Get assembly mapping data.
Parameters
----------
source_assembly : {'NCBI36', 'GRCh37', 'GRCh38'}
assembly to remap from
target_assembly : {'NCBI36', 'GRCh37', 'GRCh38'}
assembly t... | [
"def",
"get_assembly_mapping_data",
"(",
"self",
",",
"source_assembly",
",",
"target_assembly",
")",
":",
"return",
"self",
".",
"_load_assembly_mapping_data",
"(",
"self",
".",
"_get_path_assembly_mapping_data",
"(",
"source_assembly",
",",
"target_assembly",
")",
")"... | Get assembly mapping data.
Parameters
----------
source_assembly : {'NCBI36', 'GRCh37', 'GRCh38'}
assembly to remap from
target_assembly : {'NCBI36', 'GRCh37', 'GRCh38'}
assembly to remap to
Returns
-------
dict
dict of json a... | [
"Get",
"assembly",
"mapping",
"data",
"."
] | 13106a62a959a80ac26c68d1566422de08aa877b | https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/resources.py#L137-L154 |
5,584 | apriha/lineage | src/lineage/resources.py | Resources._load_assembly_mapping_data | def _load_assembly_mapping_data(filename):
""" Load assembly mapping data.
Parameters
----------
filename : str
path to compressed archive with assembly mapping data
Returns
-------
assembly_mapping_data : dict
dict of assembly maps if lo... | python | def _load_assembly_mapping_data(filename):
""" Load assembly mapping data.
Parameters
----------
filename : str
path to compressed archive with assembly mapping data
Returns
-------
assembly_mapping_data : dict
dict of assembly maps if lo... | [
"def",
"_load_assembly_mapping_data",
"(",
"filename",
")",
":",
"try",
":",
"assembly_mapping_data",
"=",
"{",
"}",
"with",
"tarfile",
".",
"open",
"(",
"filename",
",",
"\"r\"",
")",
"as",
"tar",
":",
"# http://stackoverflow.com/a/2018576",
"for",
"member",
"i... | Load assembly mapping data.
Parameters
----------
filename : str
path to compressed archive with assembly mapping data
Returns
-------
assembly_mapping_data : dict
dict of assembly maps if loading was successful, else None
Notes
... | [
"Load",
"assembly",
"mapping",
"data",
"."
] | 13106a62a959a80ac26c68d1566422de08aa877b | https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/resources.py#L312-L346 |
5,585 | apriha/lineage | src/lineage/resources.py | Resources._load_cytoBand | def _load_cytoBand(filename):
""" Load UCSC cytoBand table.
Parameters
----------
filename : str
path to cytoBand file
Returns
-------
df : pandas.DataFrame
cytoBand table if loading was successful, else None
References
-... | python | def _load_cytoBand(filename):
""" Load UCSC cytoBand table.
Parameters
----------
filename : str
path to cytoBand file
Returns
-------
df : pandas.DataFrame
cytoBand table if loading was successful, else None
References
-... | [
"def",
"_load_cytoBand",
"(",
"filename",
")",
":",
"try",
":",
"# adapted from chromosome plotting code (see [1]_)",
"df",
"=",
"pd",
".",
"read_table",
"(",
"filename",
",",
"names",
"=",
"[",
"\"chrom\"",
",",
"\"start\"",
",",
"\"end\"",
",",
"\"name\"",
","... | Load UCSC cytoBand table.
Parameters
----------
filename : str
path to cytoBand file
Returns
-------
df : pandas.DataFrame
cytoBand table if loading was successful, else None
References
----------
..[1] Ryan Dale, GitHub ... | [
"Load",
"UCSC",
"cytoBand",
"table",
"."
] | 13106a62a959a80ac26c68d1566422de08aa877b | https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/resources.py#L349-L376 |
5,586 | apriha/lineage | src/lineage/resources.py | Resources._load_knownGene | def _load_knownGene(filename):
""" Load UCSC knownGene table.
Parameters
----------
filename : str
path to knownGene file
Returns
-------
df : pandas.DataFrame
knownGene table if loading was successful, else None
"""
try:
... | python | def _load_knownGene(filename):
""" Load UCSC knownGene table.
Parameters
----------
filename : str
path to knownGene file
Returns
-------
df : pandas.DataFrame
knownGene table if loading was successful, else None
"""
try:
... | [
"def",
"_load_knownGene",
"(",
"filename",
")",
":",
"try",
":",
"df",
"=",
"pd",
".",
"read_table",
"(",
"filename",
",",
"names",
"=",
"[",
"\"name\"",
",",
"\"chrom\"",
",",
"\"strand\"",
",",
"\"txStart\"",
",",
"\"txEnd\"",
",",
"\"cdsStart\"",
",",
... | Load UCSC knownGene table.
Parameters
----------
filename : str
path to knownGene file
Returns
-------
df : pandas.DataFrame
knownGene table if loading was successful, else None | [
"Load",
"UCSC",
"knownGene",
"table",
"."
] | 13106a62a959a80ac26c68d1566422de08aa877b | https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/resources.py#L379-L415 |
5,587 | apriha/lineage | src/lineage/resources.py | Resources._load_kgXref | def _load_kgXref(filename):
""" Load UCSC kgXref table.
Parameters
----------
filename : str
path to kgXref file
Returns
-------
df : pandas.DataFrame
kgXref table if loading was successful, else None
"""
try:
... | python | def _load_kgXref(filename):
""" Load UCSC kgXref table.
Parameters
----------
filename : str
path to kgXref file
Returns
-------
df : pandas.DataFrame
kgXref table if loading was successful, else None
"""
try:
... | [
"def",
"_load_kgXref",
"(",
"filename",
")",
":",
"try",
":",
"df",
"=",
"pd",
".",
"read_table",
"(",
"filename",
",",
"names",
"=",
"[",
"\"kgID\"",
",",
"\"mRNA\"",
",",
"\"spID\"",
",",
"\"spDisplayID\"",
",",
"\"geneSymbol\"",
",",
"\"refseq\"",
",",
... | Load UCSC kgXref table.
Parameters
----------
filename : str
path to kgXref file
Returns
-------
df : pandas.DataFrame
kgXref table if loading was successful, else None | [
"Load",
"UCSC",
"kgXref",
"table",
"."
] | 13106a62a959a80ac26c68d1566422de08aa877b | https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/resources.py#L418-L452 |
5,588 | apriha/lineage | src/lineage/resources.py | Resources._get_path_assembly_mapping_data | def _get_path_assembly_mapping_data(
self, source_assembly, target_assembly, retries=10
):
""" Get local path to assembly mapping data, downloading if necessary.
Parameters
----------
source_assembly : {'NCBI36', 'GRCh37', 'GRCh38'}
assembly to remap from
... | python | def _get_path_assembly_mapping_data(
self, source_assembly, target_assembly, retries=10
):
""" Get local path to assembly mapping data, downloading if necessary.
Parameters
----------
source_assembly : {'NCBI36', 'GRCh37', 'GRCh38'}
assembly to remap from
... | [
"def",
"_get_path_assembly_mapping_data",
"(",
"self",
",",
"source_assembly",
",",
"target_assembly",
",",
"retries",
"=",
"10",
")",
":",
"if",
"not",
"lineage",
".",
"create_dir",
"(",
"self",
".",
"_resources_dir",
")",
":",
"return",
"None",
"chroms",
"="... | Get local path to assembly mapping data, downloading if necessary.
Parameters
----------
source_assembly : {'NCBI36', 'GRCh37', 'GRCh38'}
assembly to remap from
target_assembly : {'NCBI36', 'GRCh37', 'GRCh38'}
assembly to remap to
retries : int
... | [
"Get",
"local",
"path",
"to",
"assembly",
"mapping",
"data",
"downloading",
"if",
"necessary",
"."
] | 13106a62a959a80ac26c68d1566422de08aa877b | https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/resources.py#L517-L626 |
5,589 | apriha/lineage | src/lineage/resources.py | Resources._download_file | def _download_file(self, url, filename, compress=False, timeout=30):
""" Download a file to the resources folder.
Download data from `url`, save as `filename`, and optionally compress with gzip.
Parameters
----------
url : str
URL to download data from
filen... | python | def _download_file(self, url, filename, compress=False, timeout=30):
""" Download a file to the resources folder.
Download data from `url`, save as `filename`, and optionally compress with gzip.
Parameters
----------
url : str
URL to download data from
filen... | [
"def",
"_download_file",
"(",
"self",
",",
"url",
",",
"filename",
",",
"compress",
"=",
"False",
",",
"timeout",
"=",
"30",
")",
":",
"if",
"not",
"lineage",
".",
"create_dir",
"(",
"self",
".",
"_resources_dir",
")",
":",
"return",
"None",
"if",
"com... | Download a file to the resources folder.
Download data from `url`, save as `filename`, and optionally compress with gzip.
Parameters
----------
url : str
URL to download data from
filename : str
name of file to save; if compress, ensure '.gz' is appended... | [
"Download",
"a",
"file",
"to",
"the",
"resources",
"folder",
"."
] | 13106a62a959a80ac26c68d1566422de08aa877b | https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/resources.py#L642-L701 |
5,590 | apriha/lineage | src/lineage/individual.py | Individual.load_snps | def load_snps(
self,
raw_data,
discrepant_snp_positions_threshold=100,
discrepant_genotypes_threshold=500,
save_output=False,
):
""" Load raw genotype data.
Parameters
----------
raw_data : list or str
path(s) to file(s) with raw g... | python | def load_snps(
self,
raw_data,
discrepant_snp_positions_threshold=100,
discrepant_genotypes_threshold=500,
save_output=False,
):
""" Load raw genotype data.
Parameters
----------
raw_data : list or str
path(s) to file(s) with raw g... | [
"def",
"load_snps",
"(",
"self",
",",
"raw_data",
",",
"discrepant_snp_positions_threshold",
"=",
"100",
",",
"discrepant_genotypes_threshold",
"=",
"500",
",",
"save_output",
"=",
"False",
",",
")",
":",
"if",
"type",
"(",
"raw_data",
")",
"is",
"list",
":",
... | Load raw genotype data.
Parameters
----------
raw_data : list or str
path(s) to file(s) with raw genotype data
discrepant_snp_positions_threshold : int
threshold for discrepant SNP positions between existing data and data to be loaded,
a large value c... | [
"Load",
"raw",
"genotype",
"data",
"."
] | 13106a62a959a80ac26c68d1566422de08aa877b | https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/individual.py#L205-L243 |
5,591 | apriha/lineage | src/lineage/individual.py | Individual.save_snps | def save_snps(self, filename=None):
""" Save SNPs to file.
Parameters
----------
filename : str
filename for file to save
Returns
-------
str
path to file in output directory if SNPs were saved, else empty str
"""
comment ... | python | def save_snps(self, filename=None):
""" Save SNPs to file.
Parameters
----------
filename : str
filename for file to save
Returns
-------
str
path to file in output directory if SNPs were saved, else empty str
"""
comment ... | [
"def",
"save_snps",
"(",
"self",
",",
"filename",
"=",
"None",
")",
":",
"comment",
"=",
"(",
"\"# Source(s): {}\\n\"",
"\"# Assembly: {}\\n\"",
"\"# SNPs: {}\\n\"",
"\"# Chromosomes: {}\\n\"",
".",
"format",
"(",
"self",
".",
"source",
",",
"self",
".",
"assembly... | Save SNPs to file.
Parameters
----------
filename : str
filename for file to save
Returns
-------
str
path to file in output directory if SNPs were saved, else empty str | [
"Save",
"SNPs",
"to",
"file",
"."
] | 13106a62a959a80ac26c68d1566422de08aa877b | https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/individual.py#L267-L298 |
5,592 | apriha/lineage | src/lineage/individual.py | Individual.remap_snps | def remap_snps(self, target_assembly, complement_bases=True):
""" Remap the SNP coordinates of this ``Individual`` from one assembly to another.
This method is a wrapper for `remap_snps` in the ``Lineage`` class.
This method uses the assembly map endpoint of the Ensembl REST API service to con... | python | def remap_snps(self, target_assembly, complement_bases=True):
""" Remap the SNP coordinates of this ``Individual`` from one assembly to another.
This method is a wrapper for `remap_snps` in the ``Lineage`` class.
This method uses the assembly map endpoint of the Ensembl REST API service to con... | [
"def",
"remap_snps",
"(",
"self",
",",
"target_assembly",
",",
"complement_bases",
"=",
"True",
")",
":",
"from",
"lineage",
"import",
"Lineage",
"l",
"=",
"Lineage",
"(",
")",
"return",
"l",
".",
"remap_snps",
"(",
"self",
",",
"target_assembly",
",",
"co... | Remap the SNP coordinates of this ``Individual`` from one assembly to another.
This method is a wrapper for `remap_snps` in the ``Lineage`` class.
This method uses the assembly map endpoint of the Ensembl REST API service to convert SNP
coordinates / positions from one assembly to another. Aft... | [
"Remap",
"the",
"SNP",
"coordinates",
"of",
"this",
"Individual",
"from",
"one",
"assembly",
"to",
"another",
"."
] | 13106a62a959a80ac26c68d1566422de08aa877b | https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/individual.py#L382-L427 |
5,593 | apriha/lineage | src/lineage/individual.py | Individual._set_snps | def _set_snps(self, snps, build=37):
""" Set `_snps` and `_build` properties of this ``Individual``.
Notes
-----
Intended to be used internally to `lineage`.
Parameters
----------
snps : pandas.DataFrame
individual's genetic data normalized for use w... | python | def _set_snps(self, snps, build=37):
""" Set `_snps` and `_build` properties of this ``Individual``.
Notes
-----
Intended to be used internally to `lineage`.
Parameters
----------
snps : pandas.DataFrame
individual's genetic data normalized for use w... | [
"def",
"_set_snps",
"(",
"self",
",",
"snps",
",",
"build",
"=",
"37",
")",
":",
"self",
".",
"_snps",
"=",
"snps",
"self",
".",
"_build",
"=",
"build"
] | Set `_snps` and `_build` properties of this ``Individual``.
Notes
-----
Intended to be used internally to `lineage`.
Parameters
----------
snps : pandas.DataFrame
individual's genetic data normalized for use with `lineage`
build : int
bui... | [
"Set",
"_snps",
"and",
"_build",
"properties",
"of",
"this",
"Individual",
"."
] | 13106a62a959a80ac26c68d1566422de08aa877b | https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/individual.py#L429-L444 |
5,594 | apriha/lineage | src/lineage/individual.py | Individual._double_single_alleles | def _double_single_alleles(df, chrom):
""" Double any single alleles in the specified chromosome.
Parameters
----------
df : pandas.DataFrame
SNPs
chrom : str
chromosome of alleles to double
Returns
-------
df : pandas.DataFrame
... | python | def _double_single_alleles(df, chrom):
""" Double any single alleles in the specified chromosome.
Parameters
----------
df : pandas.DataFrame
SNPs
chrom : str
chromosome of alleles to double
Returns
-------
df : pandas.DataFrame
... | [
"def",
"_double_single_alleles",
"(",
"df",
",",
"chrom",
")",
":",
"# find all single alleles of the specified chromosome",
"single_alleles",
"=",
"np",
".",
"where",
"(",
"(",
"df",
"[",
"\"chrom\"",
"]",
"==",
"chrom",
")",
"&",
"(",
"df",
"[",
"\"genotype\""... | Double any single alleles in the specified chromosome.
Parameters
----------
df : pandas.DataFrame
SNPs
chrom : str
chromosome of alleles to double
Returns
-------
df : pandas.DataFrame
SNPs with specified chromosome's single ... | [
"Double",
"any",
"single",
"alleles",
"in",
"the",
"specified",
"chromosome",
"."
] | 13106a62a959a80ac26c68d1566422de08aa877b | https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/individual.py#L605-L628 |
5,595 | tBuLi/symfit | symfit/core/support.py | seperate_symbols | def seperate_symbols(func):
"""
Seperate the symbols in symbolic function func. Return them in alphabetical
order.
:param func: scipy symbolic function.
:return: (vars, params), a tuple of all variables and parameters, each
sorted in alphabetical order.
:raises TypeError: only symfit V... | python | def seperate_symbols(func):
"""
Seperate the symbols in symbolic function func. Return them in alphabetical
order.
:param func: scipy symbolic function.
:return: (vars, params), a tuple of all variables and parameters, each
sorted in alphabetical order.
:raises TypeError: only symfit V... | [
"def",
"seperate_symbols",
"(",
"func",
")",
":",
"params",
"=",
"[",
"]",
"vars",
"=",
"[",
"]",
"for",
"symbol",
"in",
"func",
".",
"free_symbols",
":",
"if",
"not",
"isidentifier",
"(",
"str",
"(",
"symbol",
")",
")",
":",
"continue",
"# E.g. Indexe... | Seperate the symbols in symbolic function func. Return them in alphabetical
order.
:param func: scipy symbolic function.
:return: (vars, params), a tuple of all variables and parameters, each
sorted in alphabetical order.
:raises TypeError: only symfit Variable and Parameter are allowed, not s... | [
"Seperate",
"the",
"symbols",
"in",
"symbolic",
"function",
"func",
".",
"Return",
"them",
"in",
"alphabetical",
"order",
"."
] | 759dd3d1d4270510d651f40b23dd26b1b10eee83 | https://github.com/tBuLi/symfit/blob/759dd3d1d4270510d651f40b23dd26b1b10eee83/symfit/core/support.py#L69-L106 |
5,596 | tBuLi/symfit | symfit/core/support.py | sympy_to_py | def sympy_to_py(func, args):
"""
Turn a symbolic expression into a Python lambda function,
which has the names of the variables and parameters as it's argument names.
:param func: sympy expression
:param args: variables and parameters in this model
:return: lambda function to be used for numeri... | python | def sympy_to_py(func, args):
"""
Turn a symbolic expression into a Python lambda function,
which has the names of the variables and parameters as it's argument names.
:param func: sympy expression
:param args: variables and parameters in this model
:return: lambda function to be used for numeri... | [
"def",
"sympy_to_py",
"(",
"func",
",",
"args",
")",
":",
"# replace the derivatives with printable variables.",
"derivatives",
"=",
"{",
"var",
":",
"Variable",
"(",
"var",
".",
"name",
")",
"for",
"var",
"in",
"args",
"if",
"isinstance",
"(",
"var",
",",
"... | Turn a symbolic expression into a Python lambda function,
which has the names of the variables and parameters as it's argument names.
:param func: sympy expression
:param args: variables and parameters in this model
:return: lambda function to be used for numerical evaluation of the model. | [
"Turn",
"a",
"symbolic",
"expression",
"into",
"a",
"Python",
"lambda",
"function",
"which",
"has",
"the",
"names",
"of",
"the",
"variables",
"and",
"parameters",
"as",
"it",
"s",
"argument",
"names",
"."
] | 759dd3d1d4270510d651f40b23dd26b1b10eee83 | https://github.com/tBuLi/symfit/blob/759dd3d1d4270510d651f40b23dd26b1b10eee83/symfit/core/support.py#L108-L160 |
5,597 | tBuLi/symfit | symfit/core/support.py | sympy_to_scipy | def sympy_to_scipy(func, vars, params):
"""
Convert a symbolic expression to one scipy digs. Not used by ``symfit`` any more.
:param func: sympy expression
:param vars: variables
:param params: parameters
:return: Scipy-style function to be used for numerical evaluation of the model.
"""
... | python | def sympy_to_scipy(func, vars, params):
"""
Convert a symbolic expression to one scipy digs. Not used by ``symfit`` any more.
:param func: sympy expression
:param vars: variables
:param params: parameters
:return: Scipy-style function to be used for numerical evaluation of the model.
"""
... | [
"def",
"sympy_to_scipy",
"(",
"func",
",",
"vars",
",",
"params",
")",
":",
"lambda_func",
"=",
"sympy_to_py",
"(",
"func",
",",
"vars",
",",
"params",
")",
"def",
"f",
"(",
"x",
",",
"p",
")",
":",
"\"\"\"\n Scipy style function.\n\n :param x: l... | Convert a symbolic expression to one scipy digs. Not used by ``symfit`` any more.
:param func: sympy expression
:param vars: variables
:param params: parameters
:return: Scipy-style function to be used for numerical evaluation of the model. | [
"Convert",
"a",
"symbolic",
"expression",
"to",
"one",
"scipy",
"digs",
".",
"Not",
"used",
"by",
"symfit",
"any",
"more",
"."
] | 759dd3d1d4270510d651f40b23dd26b1b10eee83 | https://github.com/tBuLi/symfit/blob/759dd3d1d4270510d651f40b23dd26b1b10eee83/symfit/core/support.py#L162-L188 |
5,598 | tBuLi/symfit | symfit/core/support.py | jacobian | def jacobian(expr, symbols):
"""
Derive a symbolic expr w.r.t. each symbol in symbols. This returns a symbolic jacobian vector.
:param expr: A sympy Expr.
:param symbols: The symbols w.r.t. which to derive.
"""
jac = []
for symbol in symbols:
# Differentiate to every param
f... | python | def jacobian(expr, symbols):
"""
Derive a symbolic expr w.r.t. each symbol in symbols. This returns a symbolic jacobian vector.
:param expr: A sympy Expr.
:param symbols: The symbols w.r.t. which to derive.
"""
jac = []
for symbol in symbols:
# Differentiate to every param
f... | [
"def",
"jacobian",
"(",
"expr",
",",
"symbols",
")",
":",
"jac",
"=",
"[",
"]",
"for",
"symbol",
"in",
"symbols",
":",
"# Differentiate to every param",
"f",
"=",
"sympy",
".",
"diff",
"(",
"expr",
",",
"symbol",
")",
"jac",
".",
"append",
"(",
"f",
... | Derive a symbolic expr w.r.t. each symbol in symbols. This returns a symbolic jacobian vector.
:param expr: A sympy Expr.
:param symbols: The symbols w.r.t. which to derive. | [
"Derive",
"a",
"symbolic",
"expr",
"w",
".",
"r",
".",
"t",
".",
"each",
"symbol",
"in",
"symbols",
".",
"This",
"returns",
"a",
"symbolic",
"jacobian",
"vector",
"."
] | 759dd3d1d4270510d651f40b23dd26b1b10eee83 | https://github.com/tBuLi/symfit/blob/759dd3d1d4270510d651f40b23dd26b1b10eee83/symfit/core/support.py#L300-L312 |
5,599 | tBuLi/symfit | symfit/core/support.py | name | def name(self):
"""
Save name which can be used for alphabetic sorting and can be turned
into a kwarg.
"""
base_str = 'd{}{}_'.format(self.derivative_count if
self.derivative_count > 1 else '', self.expr)
for var, count in self.variable_count:
base_str += '... | python | def name(self):
"""
Save name which can be used for alphabetic sorting and can be turned
into a kwarg.
"""
base_str = 'd{}{}_'.format(self.derivative_count if
self.derivative_count > 1 else '', self.expr)
for var, count in self.variable_count:
base_str += '... | [
"def",
"name",
"(",
"self",
")",
":",
"base_str",
"=",
"'d{}{}_'",
".",
"format",
"(",
"self",
".",
"derivative_count",
"if",
"self",
".",
"derivative_count",
">",
"1",
"else",
"''",
",",
"self",
".",
"expr",
")",
"for",
"var",
",",
"count",
"in",
"s... | Save name which can be used for alphabetic sorting and can be turned
into a kwarg. | [
"Save",
"name",
"which",
"can",
"be",
"used",
"for",
"alphabetic",
"sorting",
"and",
"can",
"be",
"turned",
"into",
"a",
"kwarg",
"."
] | 759dd3d1d4270510d651f40b23dd26b1b10eee83 | https://github.com/tBuLi/symfit/blob/759dd3d1d4270510d651f40b23dd26b1b10eee83/symfit/core/support.py#L433-L442 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.