repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
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", ...
train
https://github.com/jrief/djangocms-cascade/blob/58996f990c4068e5d50f0db6030a5c0e06b682e5/cmsplugin_cascade/mixins.py#L54-L62
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", ...
train
https://github.com/jrief/djangocms-cascade/blob/58996f990c4068e5d50f0db6030a5c0e06b682e5/cmsplugin_cascade/widgets.py#L108-L123
jrief/djangocms-cascade
cmsplugin_cascade/sphinx/cms_menus.py
DocumentationMenu.get_nodes
def get_nodes(self, request): """ This method is used to build the menu tree. """ nodes = [] docsmap_file = os.path.join(settings.SPHINX_DOCS_ROOT, 'docsmap.json') if not os.path.exists(docsmap_file): return nodes with io.open(docsmap_file) as fh: ...
python
def get_nodes(self, request): """ This method is used to build the menu tree. """ nodes = [] docsmap_file = os.path.join(settings.SPHINX_DOCS_ROOT, 'docsmap.json') if not os.path.exists(docsmap_file): return nodes with io.open(docsmap_file) as fh: ...
[ "def", "get_nodes", "(", "self", ",", "request", ")", ":", "nodes", "=", "[", "]", "docsmap_file", "=", "os", ".", "path", ".", "join", "(", "settings", ".", "SPHINX_DOCS_ROOT", ",", "'docsmap.json'", ")", "if", "not", "os", ".", "path", ".", "exists",...
This method is used to build the menu tree.
[ "This", "method", "is", "used", "to", "build", "the", "menu", "tree", "." ]
train
https://github.com/jrief/djangocms-cascade/blob/58996f990c4068e5d50f0db6030a5c0e06b682e5/cmsplugin_cascade/sphinx/cms_menus.py#L20-L41
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", "." ]
train
https://github.com/jrief/djangocms-cascade/blob/58996f990c4068e5d50f0db6030a5c0e06b682e5/cmsplugin_cascade/link/forms.py#L260-L268
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", "." ]
train
https://github.com/jrief/djangocms-cascade/blob/58996f990c4068e5d50f0db6030a5c0e06b682e5/cmsplugin_cascade/models.py#L371-L378
jrief/djangocms-cascade
cmsplugin_cascade/bootstrap3/utils.py
reduce_breakpoints
def reduce_breakpoints(plugin, field_name, request=None, obj=None): """ Narrow down the number of breakpoints in the widget of the named glossary_field. This is useful in case the container was defined with a subset of these breakpoints: xs, sm, md, lg. """ if not isinstance(plugin, CascadePluginBas...
python
def reduce_breakpoints(plugin, field_name, request=None, obj=None): """ Narrow down the number of breakpoints in the widget of the named glossary_field. This is useful in case the container was defined with a subset of these breakpoints: xs, sm, md, lg. """ if not isinstance(plugin, CascadePluginBas...
[ "def", "reduce_breakpoints", "(", "plugin", ",", "field_name", ",", "request", "=", "None", ",", "obj", "=", "None", ")", ":", "if", "not", "isinstance", "(", "plugin", ",", "CascadePluginBase", ")", ":", "raise", "ValueError", "(", "'Plugin is not of type Cas...
Narrow down the number of breakpoints in the widget of the named glossary_field. This is useful in case the container was defined with a subset of these breakpoints: xs, sm, md, lg.
[ "Narrow", "down", "the", "number", "of", "breakpoints", "in", "the", "widget", "of", "the", "named", "glossary_field", ".", "This", "is", "useful", "in", "case", "the", "container", "was", "defined", "with", "a", "subset", "of", "these", "breakpoints", ":", ...
train
https://github.com/jrief/djangocms-cascade/blob/58996f990c4068e5d50f0db6030a5c0e06b682e5/cmsplugin_cascade/bootstrap3/utils.py#L39-L60
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", "." ]
train
https://github.com/jrief/djangocms-cascade/blob/58996f990c4068e5d50f0db6030a5c0e06b682e5/cmsplugin_cascade/bootstrap3/utils.py#L63-L90
jrief/djangocms-cascade
cmsplugin_cascade/bootstrap3/utils.py
get_image_tags
def get_image_tags(context, instance, options): """ Create a context returning the tags to render an <img ...> element: ``sizes``, ``srcset``, a fallback ``src`` and if required inline styles. """ if hasattr(instance, 'image') and hasattr(instance.image, 'exif'): aspect_ratio = compute_aspec...
python
def get_image_tags(context, instance, options): """ Create a context returning the tags to render an <img ...> element: ``sizes``, ``srcset``, a fallback ``src`` and if required inline styles. """ if hasattr(instance, 'image') and hasattr(instance.image, 'exif'): aspect_ratio = compute_aspec...
[ "def", "get_image_tags", "(", "context", ",", "instance", ",", "options", ")", ":", "if", "hasattr", "(", "instance", ",", "'image'", ")", "and", "hasattr", "(", "instance", ".", "image", ",", "'exif'", ")", ":", "aspect_ratio", "=", "compute_aspect_ratio", ...
Create a context returning the tags to render an <img ...> element: ``sizes``, ``srcset``, a fallback ``src`` and if required inline styles.
[ "Create", "a", "context", "returning", "the", "tags", "to", "render", "an", "<img", "...", ">", "element", ":", "sizes", "srcset", "a", "fallback", "src", "and", "if", "required", "inline", "styles", "." ]
train
https://github.com/jrief/djangocms-cascade/blob/58996f990c4068e5d50f0db6030a5c0e06b682e5/cmsplugin_cascade/bootstrap3/utils.py#L93-L164
jrief/djangocms-cascade
cmsplugin_cascade/bootstrap3/utils.py
get_picture_elements
def get_picture_elements(context, instance): """ Create a context, used to render a <picture> together with all its ``<source>`` elements: It returns a list of HTML elements, each containing the information to render a ``<source>`` element. The purpose of this HTML entity is to display images with a...
python
def get_picture_elements(context, instance): """ Create a context, used to render a <picture> together with all its ``<source>`` elements: It returns a list of HTML elements, each containing the information to render a ``<source>`` element. The purpose of this HTML entity is to display images with a...
[ "def", "get_picture_elements", "(", "context", ",", "instance", ")", ":", "if", "hasattr", "(", "instance", ",", "'image'", ")", "and", "hasattr", "(", "instance", ".", "image", ",", "'exif'", ")", ":", "aspect_ratio", "=", "compute_aspect_ratio", "(", "inst...
Create a context, used to render a <picture> together with all its ``<source>`` elements: It returns a list of HTML elements, each containing the information to render a ``<source>`` element. The purpose of this HTML entity is to display images with art directions. For normal images use the ``<img>`` el...
[ "Create", "a", "context", "used", "to", "render", "a", "<picture", ">", "together", "with", "all", "its", "<source", ">", "elements", ":", "It", "returns", "a", "list", "of", "HTML", "elements", "each", "containing", "the", "information", "to", "render", "...
train
https://github.com/jrief/djangocms-cascade/blob/58996f990c4068e5d50f0db6030a5c0e06b682e5/cmsplugin_cascade/bootstrap3/utils.py#L179-L258
jrief/djangocms-cascade
cmsplugin_cascade/bootstrap4/card.py
BootstrapCardPlugin.get_child_classes
def get_child_classes(cls, slot, page, instance=None): """Restrict child classes of Card to one of each: Header, Body and Footer""" child_classes = super(BootstrapCardPlugin, cls).get_child_classes(slot, page, instance) # allow only one child of type Header, Body, Footer for child in ins...
python
def get_child_classes(cls, slot, page, instance=None): """Restrict child classes of Card to one of each: Header, Body and Footer""" child_classes = super(BootstrapCardPlugin, cls).get_child_classes(slot, page, instance) # allow only one child of type Header, Body, Footer for child in ins...
[ "def", "get_child_classes", "(", "cls", ",", "slot", ",", "page", ",", "instance", "=", "None", ")", ":", "child_classes", "=", "super", "(", "BootstrapCardPlugin", ",", "cls", ")", ".", "get_child_classes", "(", "slot", ",", "page", ",", "instance", ")", ...
Restrict child classes of Card to one of each: Header, Body and Footer
[ "Restrict", "child", "classes", "of", "Card", "to", "one", "of", "each", ":", "Header", "Body", "and", "Footer" ]
train
https://github.com/jrief/djangocms-cascade/blob/58996f990c4068e5d50f0db6030a5c0e06b682e5/cmsplugin_cascade/bootstrap4/card.py#L62-L69
jrief/djangocms-cascade
cmsplugin_cascade/extra_fields/admin.py
PluginExtraFieldsAdmin.get_form
def get_form(self, request, obj=None, **kwargs): """ Build the form used for changing the model. """ kwargs.update(widgets={ 'plugin_type': widgets.Select(choices=self.plugins_for_site), 'css_classes': JSONMultiWidget(self.classname_fields), 'inline_st...
python
def get_form(self, request, obj=None, **kwargs): """ Build the form used for changing the model. """ kwargs.update(widgets={ 'plugin_type': widgets.Select(choices=self.plugins_for_site), 'css_classes': JSONMultiWidget(self.classname_fields), 'inline_st...
[ "def", "get_form", "(", "self", ",", "request", ",", "obj", "=", "None", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "update", "(", "widgets", "=", "{", "'plugin_type'", ":", "widgets", ".", "Select", "(", "choices", "=", "self", ".", "plugins_...
Build the form used for changing the model.
[ "Build", "the", "form", "used", "for", "changing", "the", "model", "." ]
train
https://github.com/jrief/djangocms-cascade/blob/58996f990c4068e5d50f0db6030a5c0e06b682e5/cmsplugin_cascade/extra_fields/admin.py#L107-L121
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" ]
train
https://github.com/jrief/djangocms-cascade/blob/58996f990c4068e5d50f0db6030a5c0e06b682e5/cmsplugin_cascade/fields.py#L50-L60
jrief/djangocms-cascade
examples/bs4demo/utils.py
find_django_migrations_module
def find_django_migrations_module(module_name): """ Tries to locate <module_name>.migrations_django (without actually importing it). Appends either ".migrations_django" or ".migrations" to module_name. For details why: https://docs.djangoproject.com/en/1.7/topics/migrations/#libraries-third-party-apps...
python
def find_django_migrations_module(module_name): """ Tries to locate <module_name>.migrations_django (without actually importing it). Appends either ".migrations_django" or ".migrations" to module_name. For details why: https://docs.djangoproject.com/en/1.7/topics/migrations/#libraries-third-party-apps...
[ "def", "find_django_migrations_module", "(", "module_name", ")", ":", "import", "imp", "try", ":", "module_info", "=", "imp", ".", "find_module", "(", "module_name", ")", "module", "=", "imp", ".", "load_module", "(", "module_name", ",", "*", "module_info", ")...
Tries to locate <module_name>.migrations_django (without actually importing it). Appends either ".migrations_django" or ".migrations" to module_name. For details why: https://docs.djangoproject.com/en/1.7/topics/migrations/#libraries-third-party-apps
[ "Tries", "to", "locate", "<module_name", ">", ".", "migrations_django", "(", "without", "actually", "importing", "it", ")", ".", "Appends", "either", ".", "migrations_django", "or", ".", "migrations", "to", "module_name", ".", "For", "details", "why", ":", "ht...
train
https://github.com/jrief/djangocms-cascade/blob/58996f990c4068e5d50f0db6030a5c0e06b682e5/examples/bs4demo/utils.py#L2-L15
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", "." ]
train
https://github.com/jrief/djangocms-cascade/blob/58996f990c4068e5d50f0db6030a5c0e06b682e5/cmsplugin_cascade/segmentation/mixins.py#L48-L59
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" ]
train
https://github.com/jrief/djangocms-cascade/blob/58996f990c4068e5d50f0db6030a5c0e06b682e5/cmsplugin_cascade/segmentation/mixins.py#L88-L159
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" ]
train
https://github.com/jrief/djangocms-cascade/blob/58996f990c4068e5d50f0db6030a5c0e06b682e5/cmsplugin_cascade/apps.py#L29-L42
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" ]
train
https://github.com/jrief/djangocms-cascade/blob/58996f990c4068e5d50f0db6030a5c0e06b682e5/cmsplugin_cascade/apps.py#L45-L55
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" ]
train
https://github.com/jrief/djangocms-cascade/blob/58996f990c4068e5d50f0db6030a5c0e06b682e5/cmsplugin_cascade/apps.py#L67-L95
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" ]
train
https://github.com/jrief/djangocms-cascade/blob/58996f990c4068e5d50f0db6030a5c0e06b682e5/cmsplugin_cascade/apps.py#L97-L110
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" ]
train
https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/writer.py#L317-L324
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" ]
train
https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/writer.py#L63-L69
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" ]
train
https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/tdms.py#L43-L51
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" ]
train
https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/tdms.py#L54-L61
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" ]
train
https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/tdms.py#L1049-L1062
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" ]
train
https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/tdms.py#L1065-L1098
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" ]
train
https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/tdms.py#L132-L157
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" ]
train
https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/tdms.py#L159-L180
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" ]
train
https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/tdms.py#L182-L194
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" ]
train
https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/tdms.py#L208-L226
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" ]
train
https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/tdms.py#L228-L284
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" ]
train
https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/tdms.py#L359-L423
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", "." ]
train
https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/tdms.py#L425-L485
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" ]
train
https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/tdms.py#L487-L532
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" ]
train
https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/tdms.py#L534-L562
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" ]
train
https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/tdms.py#L564-L581
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" ]
train
https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/tdms.py#L645-L706
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" ]
train
https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/tdms.py#L708-L732
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" ]
train
https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/tdms.py#L734-L749
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" ]
train
https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/tdms.py#L751-L774
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", "." ]
train
https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/tdms.py#L777-L792
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", "." ]
train
https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/tdms.py#L832-L869
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" ]
train
https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/tdms.py#L919-L1011
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" ]
train
https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/tdms.py#L1017-L1024
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" ]
train
https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/tdms.py#L1026-L1038
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" ]
train
https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/tdms.py#L1040-L1046
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", "." ]
train
https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/snps.py#L491-L553
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", "." ]
train
https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/snps.py#L597-L613
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", "." ]
train
https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/snps.py#L616-L655
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", "." ]
train
https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/snps.py#L658-L708
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", "." ]
train
https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/snps.py#L711-L737
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", "." ]
train
https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/snps.py#L113-L132
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", "." ]
train
https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/snps.py#L204-L231
apriha/lineage
src/lineage/snps.py
SNPs._read_ftdna
def _read_ftdna(file): """ Read and parse Family Tree DNA (FTDNA) file. https://www.familytreedna.com Parameters ---------- file : str path to file Returns ------- pandas.DataFrame individual's genetic data normalized for use wit...
python
def _read_ftdna(file): """ Read and parse Family Tree DNA (FTDNA) file. https://www.familytreedna.com Parameters ---------- file : str path to file Returns ------- pandas.DataFrame individual's genetic data normalized for use wit...
[ "def", "_read_ftdna", "(", "file", ")", ":", "df", "=", "pd", ".", "read_csv", "(", "file", ",", "skiprows", "=", "1", ",", "na_values", "=", "\"--\"", ",", "names", "=", "[", "\"rsid\"", ",", "\"chrom\"", ",", "\"pos\"", ",", "\"genotype\"", "]", ",...
Read and parse Family Tree DNA (FTDNA) file. https://www.familytreedna.com Parameters ---------- file : str path to file Returns ------- pandas.DataFrame individual's genetic data normalized for use with `lineage` str ...
[ "Read", "and", "parse", "Family", "Tree", "DNA", "(", "FTDNA", ")", "file", "." ]
train
https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/snps.py#L234-L269
apriha/lineage
src/lineage/snps.py
SNPs._read_ftdna_famfinder
def _read_ftdna_famfinder(file): """ Read and parse Family Tree DNA (FTDNA) "famfinder" file. https://www.familytreedna.com Parameters ---------- file : str path to file Returns ------- pandas.DataFrame individual's genetic data ...
python
def _read_ftdna_famfinder(file): """ Read and parse Family Tree DNA (FTDNA) "famfinder" file. https://www.familytreedna.com Parameters ---------- file : str path to file Returns ------- pandas.DataFrame individual's genetic data ...
[ "def", "_read_ftdna_famfinder", "(", "file", ")", ":", "df", "=", "pd", ".", "read_csv", "(", "file", ",", "comment", "=", "\"#\"", ",", "na_values", "=", "\"-\"", ",", "names", "=", "[", "\"rsid\"", ",", "\"chrom\"", ",", "\"pos\"", ",", "\"allele1\"", ...
Read and parse Family Tree DNA (FTDNA) "famfinder" file. https://www.familytreedna.com Parameters ---------- file : str path to file Returns ------- pandas.DataFrame individual's genetic data normalized for use with `lineage` str...
[ "Read", "and", "parse", "Family", "Tree", "DNA", "(", "FTDNA", ")", "famfinder", "file", "." ]
train
https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/snps.py#L272-L306
apriha/lineage
src/lineage/snps.py
SNPs._read_ancestry
def _read_ancestry(file): """ Read and parse Ancestry.com file. http://www.ancestry.com Parameters ---------- file : str path to file Returns ------- pandas.DataFrame individual's genetic data normalized for use with `lineage` ...
python
def _read_ancestry(file): """ Read and parse Ancestry.com file. http://www.ancestry.com Parameters ---------- file : str path to file Returns ------- pandas.DataFrame individual's genetic data normalized for use with `lineage` ...
[ "def", "_read_ancestry", "(", "file", ")", ":", "df", "=", "pd", ".", "read_csv", "(", "file", ",", "comment", "=", "\"#\"", ",", "header", "=", "0", ",", "sep", "=", "\"\\t\"", ",", "na_values", "=", "0", ",", "names", "=", "[", "\"rsid\"", ",", ...
Read and parse Ancestry.com file. http://www.ancestry.com Parameters ---------- file : str path to file Returns ------- pandas.DataFrame individual's genetic data normalized for use with `lineage` str name of data sou...
[ "Read", "and", "parse", "Ancestry", ".", "com", "file", "." ]
train
https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/snps.py#L309-L351
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", "." ]
train
https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/snps.py#L354-L387
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", "." ]
train
https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/snps.py#L390-L425
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", "." ]
train
https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/snps.py#L427-L472
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", "." ]
train
https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/visualization.py#L69-L169
apriha/lineage
src/lineage/visualization.py
_patch_chromosomal_features
def _patch_chromosomal_features(cytobands, one_chrom_match, two_chrom_match): """ Highlight positions for each chromosome segment / feature. Parameters ---------- cytobands : pandas.DataFrame cytoband table from UCSC one_chrom_match : list of dicts segments to highlight on the chrom...
python
def _patch_chromosomal_features(cytobands, one_chrom_match, two_chrom_match): """ Highlight positions for each chromosome segment / feature. Parameters ---------- cytobands : pandas.DataFrame cytoband table from UCSC one_chrom_match : list of dicts segments to highlight on the chrom...
[ "def", "_patch_chromosomal_features", "(", "cytobands", ",", "one_chrom_match", ",", "two_chrom_match", ")", ":", "chromosomes", "=", "cytobands", "[", "\"chrom\"", "]", ".", "unique", "(", ")", "df", "=", "pd", ".", "DataFrame", "(", ")", "for", "chromosome",...
Highlight positions for each chromosome segment / feature. Parameters ---------- cytobands : pandas.DataFrame cytoband table from UCSC one_chrom_match : list of dicts segments to highlight on the chromosomes representing one shared chromosome two_chrom_match : list of dicts ...
[ "Highlight", "positions", "for", "each", "chromosome", "segment", "/", "feature", "." ]
train
https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/visualization.py#L208-L292
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", "." ]
train
https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/__init__.py#L859-L882
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", "." ]
train
https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/__init__.py#L885-L940
apriha/lineage
src/lineage/__init__.py
Lineage.remap_snps
def remap_snps(self, individual, target_assembly, complement_bases=True): """ Remap the SNP coordinates of an individual from one assembly to another. This method uses the assembly map endpoint of the Ensembl REST API service (via ``Resources``'s ``EnsemblRestClient``) to convert SNP coordinate...
python
def remap_snps(self, individual, target_assembly, complement_bases=True): """ Remap the SNP coordinates of an individual from one assembly to another. This method uses the assembly map endpoint of the Ensembl REST API service (via ``Resources``'s ``EnsemblRestClient``) to convert SNP coordinate...
[ "def", "remap_snps", "(", "self", ",", "individual", ",", "target_assembly", ",", "complement_bases", "=", "True", ")", ":", "chromosomes_remapped", "=", "[", "]", "chromosomes_not_remapped", "=", "[", "]", "snps", "=", "individual", ".", "snps", "if", "snps",...
Remap the SNP coordinates of an individual from one assembly to another. This method uses the assembly map endpoint of the Ensembl REST API service (via ``Resources``'s ``EnsemblRestClient``) to convert SNP coordinates / positions from one assembly to another. After remapping, the coordinates /...
[ "Remap", "the", "SNP", "coordinates", "of", "an", "individual", "from", "one", "assembly", "to", "another", "." ]
train
https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/__init__.py#L104-L265
apriha/lineage
src/lineage/__init__.py
Lineage.find_discordant_snps
def find_discordant_snps( self, individual1, individual2, individual3=None, save_output=False ): """ Find discordant SNPs between two or three individuals. Parameters ---------- individual1 : Individual reference individual (child if `individual2` and `individual...
python
def find_discordant_snps( self, individual1, individual2, individual3=None, save_output=False ): """ Find discordant SNPs between two or three individuals. Parameters ---------- individual1 : Individual reference individual (child if `individual2` and `individual...
[ "def", "find_discordant_snps", "(", "self", ",", "individual1", ",", "individual2", ",", "individual3", "=", "None", ",", "save_output", "=", "False", ")", ":", "self", ".", "_remap_snps_to_GRCh37", "(", "[", "individual1", ",", "individual2", ",", "individual3"...
Find discordant SNPs between two or three individuals. Parameters ---------- individual1 : Individual reference individual (child if `individual2` and `individual3` are parents) individual2 : Individual comparison individual individual3 : Individual ...
[ "Find", "discordant", "SNPs", "between", "two", "or", "three", "individuals", "." ]
train
https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/__init__.py#L287-L431
apriha/lineage
src/lineage/__init__.py
Lineage.find_shared_dna
def find_shared_dna( self, individual1, individual2, cM_threshold=0.75, snp_threshold=1100, shared_genes=False, save_output=True, ): """ Find the shared DNA between two individuals. Computes the genetic distance in centiMorgans (cMs) between S...
python
def find_shared_dna( self, individual1, individual2, cM_threshold=0.75, snp_threshold=1100, shared_genes=False, save_output=True, ): """ Find the shared DNA between two individuals. Computes the genetic distance in centiMorgans (cMs) between S...
[ "def", "find_shared_dna", "(", "self", ",", "individual1", ",", "individual2", ",", "cM_threshold", "=", "0.75", ",", "snp_threshold", "=", "1100", ",", "shared_genes", "=", "False", ",", "save_output", "=", "True", ",", ")", ":", "one_chrom_shared_genes", "="...
Find the shared DNA between two individuals. Computes the genetic distance in centiMorgans (cMs) between SNPs using the HapMap Phase II GRCh37 genetic map. Applies thresholds to determine the shared DNA. Plots shared DNA. Optionally determines shared genes (i.e., genes that are transcribed from...
[ "Find", "the", "shared", "DNA", "between", "two", "individuals", "." ]
train
https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/__init__.py#L433-L597
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", "." ]
train
https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/resources.py#L83-L96
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", "." ]
train
https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/resources.py#L98-L109
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", "." ]
train
https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/resources.py#L111-L122
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", "." ]
train
https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/resources.py#L124-L135
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", "." ]
train
https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/resources.py#L137-L154
apriha/lineage
src/lineage/resources.py
Resources.download_example_datasets
def download_example_datasets(self): """ Download example datasets from `openSNP <https://opensnp.org>`_. Per openSNP, "the data is donated into the public domain using `CC0 1.0 <http://creativecommons.org/publicdomain/zero/1.0/>`_." Returns ------- paths : list of str ...
python
def download_example_datasets(self): """ Download example datasets from `openSNP <https://opensnp.org>`_. Per openSNP, "the data is donated into the public domain using `CC0 1.0 <http://creativecommons.org/publicdomain/zero/1.0/>`_." Returns ------- paths : list of str ...
[ "def", "download_example_datasets", "(", "self", ")", ":", "paths", "=", "[", "]", "paths", ".", "append", "(", "self", ".", "_download_file", "(", "\"https://opensnp.org/data/662.23andme.304\"", ",", "\"662.23andme.304.txt.gz\"", ",", "compress", "=", "True", ",", ...
Download example datasets from `openSNP <https://opensnp.org>`_. Per openSNP, "the data is donated into the public domain using `CC0 1.0 <http://creativecommons.org/publicdomain/zero/1.0/>`_." Returns ------- paths : list of str or None paths to example datasets ...
[ "Download", "example", "datasets", "from", "openSNP", "<https", ":", "//", "opensnp", ".", "org", ">", "_", "." ]
train
https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/resources.py#L156-L238
apriha/lineage
src/lineage/resources.py
Resources.get_all_resources
def get_all_resources(self): """ Get / download all resources used throughout `lineage`. Returns ------- dict dict of resources """ resources = {} resources[ "genetic_map_HapMapII_GRCh37" ] = self.get_genetic_map_HapMapII_GRCh37() ...
python
def get_all_resources(self): """ Get / download all resources used throughout `lineage`. Returns ------- dict dict of resources """ resources = {} resources[ "genetic_map_HapMapII_GRCh37" ] = self.get_genetic_map_HapMapII_GRCh37() ...
[ "def", "get_all_resources", "(", "self", ")", ":", "resources", "=", "{", "}", "resources", "[", "\"genetic_map_HapMapII_GRCh37\"", "]", "=", "self", ".", "get_genetic_map_HapMapII_GRCh37", "(", ")", "resources", "[", "\"cytoBand_hg19\"", "]", "=", "self", ".", ...
Get / download all resources used throughout `lineage`. Returns ------- dict dict of resources
[ "Get", "/", "download", "all", "resources", "used", "throughout", "lineage", "." ]
train
https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/resources.py#L240-L259
apriha/lineage
src/lineage/resources.py
Resources._load_genetic_map
def _load_genetic_map(filename): """ Load genetic map (e.g. HapMapII). Parameters ---------- filename : str path to compressed archive with genetic map data Returns ------- genetic_map : dict dict of pandas.DataFrame genetic maps if loadi...
python
def _load_genetic_map(filename): """ Load genetic map (e.g. HapMapII). Parameters ---------- filename : str path to compressed archive with genetic map data Returns ------- genetic_map : dict dict of pandas.DataFrame genetic maps if loadi...
[ "def", "_load_genetic_map", "(", "filename", ")", ":", "try", ":", "genetic_map", "=", "{", "}", "with", "tarfile", ".", "open", "(", "filename", ",", "\"r\"", ")", "as", "tar", ":", "# http://stackoverflow.com/a/2018576", "for", "member", "in", "tar", ".", ...
Load genetic map (e.g. HapMapII). Parameters ---------- filename : str path to compressed archive with genetic map data Returns ------- genetic_map : dict dict of pandas.DataFrame genetic maps if loading was successful, else None Notes ...
[ "Load", "genetic", "map", "(", "e", ".", "g", ".", "HapMapII", ")", "." ]
train
https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/resources.py#L262-L309
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", "." ]
train
https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/resources.py#L312-L346
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", "." ]
train
https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/resources.py#L349-L376
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", "." ]
train
https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/resources.py#L379-L415
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", "." ]
train
https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/resources.py#L418-L452
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", "." ]
train
https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/resources.py#L517-L626
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", "." ]
train
https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/resources.py#L642-L701
apriha/lineage
src/lineage/individual.py
Individual.discrepant_snps
def discrepant_snps(self): """ SNPs with discrepant positions and / or genotypes discovered while loading SNPs. Returns ------- pandas.DataFrame """ df = self._discrepant_positions.append(self._discrepant_genotypes) if len(df) > 1: df = df.drop_duplic...
python
def discrepant_snps(self): """ SNPs with discrepant positions and / or genotypes discovered while loading SNPs. Returns ------- pandas.DataFrame """ df = self._discrepant_positions.append(self._discrepant_genotypes) if len(df) > 1: df = df.drop_duplic...
[ "def", "discrepant_snps", "(", "self", ")", ":", "df", "=", "self", ".", "_discrepant_positions", ".", "append", "(", "self", ".", "_discrepant_genotypes", ")", "if", "len", "(", "df", ")", ">", "1", ":", "df", "=", "df", ".", "drop_duplicates", "(", "...
SNPs with discrepant positions and / or genotypes discovered while loading SNPs. Returns ------- pandas.DataFrame
[ "SNPs", "with", "discrepant", "positions", "and", "/", "or", "genotypes", "discovered", "while", "loading", "SNPs", "." ]
train
https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/individual.py#L193-L203
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", "." ]
train
https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/individual.py#L205-L243
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", "." ]
train
https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/individual.py#L267-L298
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", "." ]
train
https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/individual.py#L382-L427
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", "." ]
train
https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/individual.py#L429-L444
apriha/lineage
src/lineage/individual.py
Individual._add_snps
def _add_snps( self, snps, discrepant_snp_positions_threshold, discrepant_genotypes_threshold, save_output, ): """ Add SNPs to this Individual. Parameters ---------- snps : SNPs SNPs to add discrepant_snp_positions_threshol...
python
def _add_snps( self, snps, discrepant_snp_positions_threshold, discrepant_genotypes_threshold, save_output, ): """ Add SNPs to this Individual. Parameters ---------- snps : SNPs SNPs to add discrepant_snp_positions_threshol...
[ "def", "_add_snps", "(", "self", ",", "snps", ",", "discrepant_snp_positions_threshold", ",", "discrepant_genotypes_threshold", ",", "save_output", ",", ")", ":", "discrepant_positions", "=", "pd", ".", "DataFrame", "(", ")", "discrepant_genotypes", "=", "pd", ".", ...
Add SNPs to this Individual. Parameters ---------- snps : SNPs SNPs to add discrepant_snp_positions_threshold : int see above discrepant_genotypes_threshold : int see above save_output see above Returns ---...
[ "Add", "SNPs", "to", "this", "Individual", "." ]
train
https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/individual.py#L446-L602
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", "." ]
train
https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/individual.py#L605-L628
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", "." ]
train
https://github.com/tBuLi/symfit/blob/759dd3d1d4270510d651f40b23dd26b1b10eee83/symfit/core/support.py#L69-L106
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", "." ]
train
https://github.com/tBuLi/symfit/blob/759dd3d1d4270510d651f40b23dd26b1b10eee83/symfit/core/support.py#L108-L160
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", "." ]
train
https://github.com/tBuLi/symfit/blob/759dd3d1d4270510d651f40b23dd26b1b10eee83/symfit/core/support.py#L162-L188
tBuLi/symfit
symfit/core/support.py
variables
def variables(names, **kwargs): """ Convenience function for the creation of multiple variables. For more control, consider using ``symbols(names, cls=Variable, **kwargs)`` directly. :param names: string of variable names. Example: x, y = variables('x, y') :param kwargs: kwargs to be passed...
python
def variables(names, **kwargs): """ Convenience function for the creation of multiple variables. For more control, consider using ``symbols(names, cls=Variable, **kwargs)`` directly. :param names: string of variable names. Example: x, y = variables('x, y') :param kwargs: kwargs to be passed...
[ "def", "variables", "(", "names", ",", "*", "*", "kwargs", ")", ":", "return", "symbols", "(", "names", ",", "cls", "=", "Variable", ",", "seq", "=", "True", ",", "*", "*", "kwargs", ")" ]
Convenience function for the creation of multiple variables. For more control, consider using ``symbols(names, cls=Variable, **kwargs)`` directly. :param names: string of variable names. Example: x, y = variables('x, y') :param kwargs: kwargs to be passed onto :func:`sympy.core.symbol.symbols` ...
[ "Convenience", "function", "for", "the", "creation", "of", "multiple", "variables", ".", "For", "more", "control", "consider", "using", "symbols", "(", "names", "cls", "=", "Variable", "**", "kwargs", ")", "directly", "." ]
train
https://github.com/tBuLi/symfit/blob/759dd3d1d4270510d651f40b23dd26b1b10eee83/symfit/core/support.py#L190-L200
tBuLi/symfit
symfit/core/support.py
parameters
def parameters(names, **kwargs): """ Convenience function for the creation of multiple parameters. For more control, consider using ``symbols(names, cls=Parameter, **kwargs)`` directly. The `Parameter` attributes `value`, `min`, `max` and `fixed` can also be provided directly. If given as a single ...
python
def parameters(names, **kwargs): """ Convenience function for the creation of multiple parameters. For more control, consider using ``symbols(names, cls=Parameter, **kwargs)`` directly. The `Parameter` attributes `value`, `min`, `max` and `fixed` can also be provided directly. If given as a single ...
[ "def", "parameters", "(", "names", ",", "*", "*", "kwargs", ")", ":", "sequence_fields", "=", "[", "'value'", ",", "'min'", ",", "'max'", ",", "'fixed'", "]", "sequences", "=", "{", "}", "for", "attr", "in", "sequence_fields", ":", "try", ":", "iter", ...
Convenience function for the creation of multiple parameters. For more control, consider using ``symbols(names, cls=Parameter, **kwargs)`` directly. The `Parameter` attributes `value`, `min`, `max` and `fixed` can also be provided directly. If given as a single value, the same value will be set for all ...
[ "Convenience", "function", "for", "the", "creation", "of", "multiple", "parameters", ".", "For", "more", "control", "consider", "using", "symbols", "(", "names", "cls", "=", "Parameter", "**", "kwargs", ")", "directly", "." ]
train
https://github.com/tBuLi/symfit/blob/759dd3d1d4270510d651f40b23dd26b1b10eee83/symfit/core/support.py#L202-L253
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", "." ]
train
https://github.com/tBuLi/symfit/blob/759dd3d1d4270510d651f40b23dd26b1b10eee83/symfit/core/support.py#L300-L312
tBuLi/symfit
symfit/core/support.py
key2str
def key2str(target): """ In ``symfit`` there are many dicts with symbol: value pairs. These can not be used immediately as \*\*kwargs, even though this would make a lot of sense from the context. This function wraps such dict to make them usable as \*\*kwargs immediately. :param target: `Mappin...
python
def key2str(target): """ In ``symfit`` there are many dicts with symbol: value pairs. These can not be used immediately as \*\*kwargs, even though this would make a lot of sense from the context. This function wraps such dict to make them usable as \*\*kwargs immediately. :param target: `Mappin...
[ "def", "key2str", "(", "target", ")", ":", "return", "target", ".", "__class__", "(", "(", "str", "(", "symbol", ")", ",", "value", ")", "for", "symbol", ",", "value", "in", "target", ".", "items", "(", ")", ")" ]
In ``symfit`` there are many dicts with symbol: value pairs. These can not be used immediately as \*\*kwargs, even though this would make a lot of sense from the context. This function wraps such dict to make them usable as \*\*kwargs immediately. :param target: `Mapping` to be made save :return: `...
[ "In", "symfit", "there", "are", "many", "dicts", "with", "symbol", ":", "value", "pairs", ".", "These", "can", "not", "be", "used", "immediately", "as", "\\", "*", "\\", "*", "kwargs", "even", "though", "this", "would", "make", "a", "lot", "of", "sense...
train
https://github.com/tBuLi/symfit/blob/759dd3d1d4270510d651f40b23dd26b1b10eee83/symfit/core/support.py#L314-L324
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", "." ]
train
https://github.com/tBuLi/symfit/blob/759dd3d1d4270510d651f40b23dd26b1b10eee83/symfit/core/support.py#L433-L442
tBuLi/symfit
symfit/core/minimizers.py
BaseMinimizer._baseobjective_from_callable
def _baseobjective_from_callable(self, func, objective_type=MinimizeModel): """ symfit works with BaseObjective subclasses internally. If a custom objective is provided, we wrap it into a BaseObjective, MinimizeModel by default. :param func: Callable. If already an instance of B...
python
def _baseobjective_from_callable(self, func, objective_type=MinimizeModel): """ symfit works with BaseObjective subclasses internally. If a custom objective is provided, we wrap it into a BaseObjective, MinimizeModel by default. :param func: Callable. If already an instance of B...
[ "def", "_baseobjective_from_callable", "(", "self", ",", "func", ",", "objective_type", "=", "MinimizeModel", ")", ":", "if", "isinstance", "(", "func", ",", "BaseObjective", ")", "or", "(", "hasattr", "(", "func", ",", "'__self__'", ")", "and", "isinstance", ...
symfit works with BaseObjective subclasses internally. If a custom objective is provided, we wrap it into a BaseObjective, MinimizeModel by default. :param func: Callable. If already an instance of BaseObjective, it is returned immediately. If not, it is turned into a BaseObjective ...
[ "symfit", "works", "with", "BaseObjective", "subclasses", "internally", ".", "If", "a", "custom", "objective", "is", "provided", "we", "wrap", "it", "into", "a", "BaseObjective", "MinimizeModel", "by", "default", "." ]
train
https://github.com/tBuLi/symfit/blob/759dd3d1d4270510d651f40b23dd26b1b10eee83/symfit/core/minimizers.py#L44-L74
tBuLi/symfit
symfit/core/minimizers.py
GradientMinimizer.resize_jac
def resize_jac(self, func): """ Removes values with identical indices to fixed parameters from the output of func. func has to return the jacobian of a scalar function. :param func: Jacobian function to be wrapped. Is assumed to be the jacobian of a scalar function. ...
python
def resize_jac(self, func): """ Removes values with identical indices to fixed parameters from the output of func. func has to return the jacobian of a scalar function. :param func: Jacobian function to be wrapped. Is assumed to be the jacobian of a scalar function. ...
[ "def", "resize_jac", "(", "self", ",", "func", ")", ":", "if", "func", "is", "None", ":", "return", "None", "@", "wraps", "(", "func", ")", "def", "resized", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "out", "=", "func", "(", "*", "ar...
Removes values with identical indices to fixed parameters from the output of func. func has to return the jacobian of a scalar function. :param func: Jacobian function to be wrapped. Is assumed to be the jacobian of a scalar function. :return: Jacobian corresponding to non-fixed par...
[ "Removes", "values", "with", "identical", "indices", "to", "fixed", "parameters", "from", "the", "output", "of", "func", ".", "func", "has", "to", "return", "the", "jacobian", "of", "a", "scalar", "function", "." ]
train
https://github.com/tBuLi/symfit/blob/759dd3d1d4270510d651f40b23dd26b1b10eee83/symfit/core/minimizers.py#L143-L161
tBuLi/symfit
symfit/core/minimizers.py
HessianMinimizer.resize_hess
def resize_hess(self, func): """ Removes values with identical indices to fixed parameters from the output of func. func has to return the Hessian of a scalar function. :param func: Hessian function to be wrapped. Is assumed to be the Hessian of a scalar function. :r...
python
def resize_hess(self, func): """ Removes values with identical indices to fixed parameters from the output of func. func has to return the Hessian of a scalar function. :param func: Hessian function to be wrapped. Is assumed to be the Hessian of a scalar function. :r...
[ "def", "resize_hess", "(", "self", ",", "func", ")", ":", "if", "func", "is", "None", ":", "return", "None", "@", "wraps", "(", "func", ")", "def", "resized", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "out", "=", "func", "(", "*", "a...
Removes values with identical indices to fixed parameters from the output of func. func has to return the Hessian of a scalar function. :param func: Hessian function to be wrapped. Is assumed to be the Hessian of a scalar function. :return: Hessian corresponding to free parameters o...
[ "Removes", "values", "with", "identical", "indices", "to", "fixed", "parameters", "from", "the", "output", "of", "func", ".", "func", "has", "to", "return", "the", "Hessian", "of", "a", "scalar", "function", "." ]
train
https://github.com/tBuLi/symfit/blob/759dd3d1d4270510d651f40b23dd26b1b10eee83/symfit/core/minimizers.py#L179-L197
tBuLi/symfit
symfit/core/minimizers.py
ChainedMinimizer.execute
def execute(self, **minimizer_kwargs): """ Execute the chained-minimization. In order to pass options to the seperate minimizers, they can be passed by using the names of the minimizers as keywords. For example:: fit = Fit(self.model, self.xx, self.yy, self.ydata, ...
python
def execute(self, **minimizer_kwargs): """ Execute the chained-minimization. In order to pass options to the seperate minimizers, they can be passed by using the names of the minimizers as keywords. For example:: fit = Fit(self.model, self.xx, self.yy, self.ydata, ...
[ "def", "execute", "(", "self", ",", "*", "*", "minimizer_kwargs", ")", ":", "bound_arguments", "=", "self", ".", "__signature__", ".", "bind", "(", "*", "*", "minimizer_kwargs", ")", "# Include default values in bound_argument object.", "# Start from a new OrderedDict t...
Execute the chained-minimization. In order to pass options to the seperate minimizers, they can be passed by using the names of the minimizers as keywords. For example:: fit = Fit(self.model, self.xx, self.yy, self.ydata, minimizer=[DifferentialEvolution, BFGS]) ...
[ "Execute", "the", "chained", "-", "minimization", ".", "In", "order", "to", "pass", "options", "to", "the", "seperate", "minimizers", "they", "can", "be", "passed", "by", "using", "the", "names", "of", "the", "minimizers", "as", "keywords", ".", "For", "ex...
train
https://github.com/tBuLi/symfit/blob/759dd3d1d4270510d651f40b23dd26b1b10eee83/symfit/core/minimizers.py#L231-L279
tBuLi/symfit
symfit/core/minimizers.py
ChainedMinimizer._make_signature
def _make_signature(self): """ Create a signature for `execute` based on the minimizers this `ChainedMinimizer` was initiated with. For the format, see the docstring of :meth:`ChainedMinimizer.execute`. :return: :class:`inspect.Signature` instance. """ # Create K...
python
def _make_signature(self): """ Create a signature for `execute` based on the minimizers this `ChainedMinimizer` was initiated with. For the format, see the docstring of :meth:`ChainedMinimizer.execute`. :return: :class:`inspect.Signature` instance. """ # Create K...
[ "def", "_make_signature", "(", "self", ")", ":", "# Create KEYWORD_ONLY arguments with the names of the minimizers.", "name", "=", "lambda", "x", ":", "x", ".", "__class__", ".", "__name__", "count", "=", "Counter", "(", "[", "name", "(", "minimizer", ")", "for", ...
Create a signature for `execute` based on the minimizers this `ChainedMinimizer` was initiated with. For the format, see the docstring of :meth:`ChainedMinimizer.execute`. :return: :class:`inspect.Signature` instance.
[ "Create", "a", "signature", "for", "execute", "based", "on", "the", "minimizers", "this", "ChainedMinimizer", "was", "initiated", "with", ".", "For", "the", "format", "see", "the", "docstring", "of", ":", "meth", ":", "ChainedMinimizer", ".", "execute", "." ]
train
https://github.com/tBuLi/symfit/blob/759dd3d1d4270510d651f40b23dd26b1b10eee83/symfit/core/minimizers.py#L281-L313
tBuLi/symfit
symfit/core/minimizers.py
ScipyMinimize.execute
def execute(self, bounds=None, jacobian=None, hessian=None, constraints=None, **minimize_options): """ Calls the wrapped algorithm. :param bounds: The bounds for the parameters. Usually filled by :class:`~symfit.core.minimizers.BoundedMinimizer`. :param jacobian: The Jacobia...
python
def execute(self, bounds=None, jacobian=None, hessian=None, constraints=None, **minimize_options): """ Calls the wrapped algorithm. :param bounds: The bounds for the parameters. Usually filled by :class:`~symfit.core.minimizers.BoundedMinimizer`. :param jacobian: The Jacobia...
[ "def", "execute", "(", "self", ",", "bounds", "=", "None", ",", "jacobian", "=", "None", ",", "hessian", "=", "None", ",", "constraints", "=", "None", ",", "*", "*", "minimize_options", ")", ":", "ans", "=", "minimize", "(", "self", ".", "objective", ...
Calls the wrapped algorithm. :param bounds: The bounds for the parameters. Usually filled by :class:`~symfit.core.minimizers.BoundedMinimizer`. :param jacobian: The Jacobian. Usually filled by :class:`~symfit.core.minimizers.ScipyGradientMinimize`. :param \*\*minimize_op...
[ "Calls", "the", "wrapped", "algorithm", "." ]
train
https://github.com/tBuLi/symfit/blob/759dd3d1d4270510d651f40b23dd26b1b10eee83/symfit/core/minimizers.py#L331-L353