repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
nyaruka/smartmin
smartmin/views.py
SmartFormMixin.derive_readonly
def derive_readonly(self): """ Figures out what fields should be readonly. We iterate our field_config to find all that have a readonly of true """ readonly = list(self.readonly) for key, value in self.field_config.items(): if 'readonly' in value and value['r...
python
def derive_readonly(self): """ Figures out what fields should be readonly. We iterate our field_config to find all that have a readonly of true """ readonly = list(self.readonly) for key, value in self.field_config.items(): if 'readonly' in value and value['r...
[ "def", "derive_readonly", "(", "self", ")", ":", "readonly", "=", "list", "(", "self", ".", "readonly", ")", "for", "key", ",", "value", "in", "self", ".", "field_config", ".", "items", "(", ")", ":", "if", "'readonly'", "in", "value", "and", "value", ...
Figures out what fields should be readonly. We iterate our field_config to find all that have a readonly of true
[ "Figures", "out", "what", "fields", "should", "be", "readonly", ".", "We", "iterate", "our", "field_config", "to", "find", "all", "that", "have", "a", "readonly", "of", "true" ]
488a676a4960555e4d216a7b95d6e01a4ad4efd8
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L914-L924
train
Derives the list of readonly items from the field_config
nyaruka/smartmin
smartmin/views.py
SmartFormMixin.derive_fields
def derive_fields(self): """ Derives our fields. """ if self.fields is not None: fields = list(self.fields) else: form = self.form fields = [] for field in form: fields.append(field.name) # this is sligh...
python
def derive_fields(self): """ Derives our fields. """ if self.fields is not None: fields = list(self.fields) else: form = self.form fields = [] for field in form: fields.append(field.name) # this is sligh...
[ "def", "derive_fields", "(", "self", ")", ":", "if", "self", ".", "fields", "is", "not", "None", ":", "fields", "=", "list", "(", "self", ".", "fields", ")", "else", ":", "form", "=", "self", ".", "form", "fields", "=", "[", "]", "for", "field", ...
Derives our fields.
[ "Derives", "our", "fields", "." ]
488a676a4960555e4d216a7b95d6e01a4ad4efd8
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L926-L949
train
Derives our fields.
nyaruka/smartmin
smartmin/views.py
SmartFormMixin.get_form_class
def get_form_class(self): """ Returns the form class to use in this view """ if self.form_class: form_class = self.form_class else: if self.model is not None: # If a model has been explicitly provided, use it model = self.m...
python
def get_form_class(self): """ Returns the form class to use in this view """ if self.form_class: form_class = self.form_class else: if self.model is not None: # If a model has been explicitly provided, use it model = self.m...
[ "def", "get_form_class", "(", "self", ")", ":", "if", "self", ".", "form_class", ":", "form_class", "=", "self", ".", "form_class", "else", ":", "if", "self", ".", "model", "is", "not", "None", ":", "# If a model has been explicitly provided, use it", "model", ...
Returns the form class to use in this view
[ "Returns", "the", "form", "class", "to", "use", "in", "this", "view" ]
488a676a4960555e4d216a7b95d6e01a4ad4efd8
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L951-L975
train
Returns the form class to use in this view
nyaruka/smartmin
smartmin/views.py
SmartFormMixin.get_factory_kwargs
def get_factory_kwargs(self): """ Let's us specify any extra parameters we might want to call for our form factory. These can include: 'form', 'fields', 'exclude' or 'formfield_callback' """ params = dict() exclude = self.derive_exclude() exclude += self.derive_...
python
def get_factory_kwargs(self): """ Let's us specify any extra parameters we might want to call for our form factory. These can include: 'form', 'fields', 'exclude' or 'formfield_callback' """ params = dict() exclude = self.derive_exclude() exclude += self.derive_...
[ "def", "get_factory_kwargs", "(", "self", ")", ":", "params", "=", "dict", "(", ")", "exclude", "=", "self", ".", "derive_exclude", "(", ")", "exclude", "+=", "self", ".", "derive_readonly", "(", ")", "if", "self", ".", "fields", ":", "fields", "=", "l...
Let's us specify any extra parameters we might want to call for our form factory. These can include: 'form', 'fields', 'exclude' or 'formfield_callback'
[ "Let", "s", "us", "specify", "any", "extra", "parameters", "we", "might", "want", "to", "call", "for", "our", "form", "factory", "." ]
488a676a4960555e4d216a7b95d6e01a4ad4efd8
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L977-L999
train
Return a dictionary of keyword arguments that can be passed to the form factory function.
nyaruka/smartmin
smartmin/views.py
SmartFormMixin.get_success_url
def get_success_url(self): """ By default we use the referer that was stuffed in our form when it was created """ if self.success_url: # if our smart url references an object, pass that in if self.success_url.find('@') > 0: return smart_url...
python
def get_success_url(self): """ By default we use the referer that was stuffed in our form when it was created """ if self.success_url: # if our smart url references an object, pass that in if self.success_url.find('@') > 0: return smart_url...
[ "def", "get_success_url", "(", "self", ")", ":", "if", "self", ".", "success_url", ":", "# if our smart url references an object, pass that in", "if", "self", ".", "success_url", ".", "find", "(", "'@'", ")", ">", "0", ":", "return", "smart_url", "(", "self", ...
By default we use the referer that was stuffed in our form when it was created
[ "By", "default", "we", "use", "the", "referer", "that", "was", "stuffed", "in", "our", "form", "when", "it", "was", "created" ]
488a676a4960555e4d216a7b95d6e01a4ad4efd8
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L1001-L1016
train
Get the url that was stuffed in ourCOOKIE and the object that was created.
nyaruka/smartmin
smartmin/views.py
SmartFormMixin.get_form_kwargs
def get_form_kwargs(self): """ We override this, using only those fields specified if they are specified. Otherwise we include all fields in a standard ModelForm. """ kwargs = super(SmartFormMixin, self).get_form_kwargs() kwargs['initial'] = self.derive_initial() ...
python
def get_form_kwargs(self): """ We override this, using only those fields specified if they are specified. Otherwise we include all fields in a standard ModelForm. """ kwargs = super(SmartFormMixin, self).get_form_kwargs() kwargs['initial'] = self.derive_initial() ...
[ "def", "get_form_kwargs", "(", "self", ")", ":", "kwargs", "=", "super", "(", "SmartFormMixin", ",", "self", ")", ".", "get_form_kwargs", "(", ")", "kwargs", "[", "'initial'", "]", "=", "self", ".", "derive_initial", "(", ")", "return", "kwargs" ]
We override this, using only those fields specified if they are specified. Otherwise we include all fields in a standard ModelForm.
[ "We", "override", "this", "using", "only", "those", "fields", "specified", "if", "they", "are", "specified", "." ]
488a676a4960555e4d216a7b95d6e01a4ad4efd8
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L1024-L1032
train
Override this to include only those fields specified in the form.
nyaruka/smartmin
smartmin/views.py
SmartCreateView.derive_title
def derive_title(self): """ Derives our title from our object """ if not self.title: return _("Create %s") % force_text(self.model._meta.verbose_name).title() else: return self.title
python
def derive_title(self): """ Derives our title from our object """ if not self.title: return _("Create %s") % force_text(self.model._meta.verbose_name).title() else: return self.title
[ "def", "derive_title", "(", "self", ")", ":", "if", "not", "self", ".", "title", ":", "return", "_", "(", "\"Create %s\"", ")", "%", "force_text", "(", "self", ".", "model", ".", "_meta", ".", "verbose_name", ")", ".", "title", "(", ")", "else", ":",...
Derives our title from our object
[ "Derives", "our", "title", "from", "our", "object" ]
488a676a4960555e4d216a7b95d6e01a4ad4efd8
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L1276-L1283
train
Derives our title from our object
nyaruka/smartmin
smartmin/views.py
SmartCRUDL.permission_for_action
def permission_for_action(self, action): """ Returns the permission to use for the passed in action """ return "%s.%s_%s" % (self.app_name.lower(), self.model_name.lower(), action)
python
def permission_for_action(self, action): """ Returns the permission to use for the passed in action """ return "%s.%s_%s" % (self.app_name.lower(), self.model_name.lower(), action)
[ "def", "permission_for_action", "(", "self", ",", "action", ")", ":", "return", "\"%s.%s_%s\"", "%", "(", "self", ".", "app_name", ".", "lower", "(", ")", ",", "self", ".", "model_name", ".", "lower", "(", ")", ",", "action", ")" ]
Returns the permission to use for the passed in action
[ "Returns", "the", "permission", "to", "use", "for", "the", "passed", "in", "action" ]
488a676a4960555e4d216a7b95d6e01a4ad4efd8
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L1349-L1353
train
Returns the permission to use for the passed in action
nyaruka/smartmin
smartmin/views.py
SmartCRUDL.template_for_action
def template_for_action(self, action): """ Returns the template to use for the passed in action """ return "%s/%s_%s.html" % (self.module_name.lower(), self.model_name.lower(), action)
python
def template_for_action(self, action): """ Returns the template to use for the passed in action """ return "%s/%s_%s.html" % (self.module_name.lower(), self.model_name.lower(), action)
[ "def", "template_for_action", "(", "self", ",", "action", ")", ":", "return", "\"%s/%s_%s.html\"", "%", "(", "self", ".", "module_name", ".", "lower", "(", ")", ",", "self", ".", "model_name", ".", "lower", "(", ")", ",", "action", ")" ]
Returns the template to use for the passed in action
[ "Returns", "the", "template", "to", "use", "for", "the", "passed", "in", "action" ]
488a676a4960555e4d216a7b95d6e01a4ad4efd8
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L1355-L1359
train
Returns the template to use for the passed in action
nyaruka/smartmin
smartmin/views.py
SmartCRUDL.url_name_for_action
def url_name_for_action(self, action): """ Returns the reverse name for this action """ return "%s.%s_%s" % (self.module_name.lower(), self.model_name.lower(), action)
python
def url_name_for_action(self, action): """ Returns the reverse name for this action """ return "%s.%s_%s" % (self.module_name.lower(), self.model_name.lower(), action)
[ "def", "url_name_for_action", "(", "self", ",", "action", ")", ":", "return", "\"%s.%s_%s\"", "%", "(", "self", ".", "module_name", ".", "lower", "(", ")", ",", "self", ".", "model_name", ".", "lower", "(", ")", ",", "action", ")" ]
Returns the reverse name for this action
[ "Returns", "the", "reverse", "name", "for", "this", "action" ]
488a676a4960555e4d216a7b95d6e01a4ad4efd8
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L1361-L1365
train
Returns the reverse name for this action
nyaruka/smartmin
smartmin/views.py
SmartCRUDL.view_for_action
def view_for_action(self, action): """ Returns the appropriate view class for the passed in action """ # this turns replace_foo into ReplaceFoo and read into Read class_name = "".join([word.capitalize() for word in action.split("_")]) view = None # see if we have...
python
def view_for_action(self, action): """ Returns the appropriate view class for the passed in action """ # this turns replace_foo into ReplaceFoo and read into Read class_name = "".join([word.capitalize() for word in action.split("_")]) view = None # see if we have...
[ "def", "view_for_action", "(", "self", ",", "action", ")", ":", "# this turns replace_foo into ReplaceFoo and read into Read", "class_name", "=", "\"\"", ".", "join", "(", "[", "word", ".", "capitalize", "(", ")", "for", "word", "in", "action", ".", "split", "("...
Returns the appropriate view class for the passed in action
[ "Returns", "the", "appropriate", "view", "class", "for", "the", "passed", "in", "action" ]
488a676a4960555e4d216a7b95d6e01a4ad4efd8
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L1367-L1478
train
Returns the appropriate view class for the passed in action.
nyaruka/smartmin
smartmin/views.py
SmartCRUDL.pattern_for_view
def pattern_for_view(self, view, action): """ Returns the URL pattern for the passed in action. """ # if this view knows how to define a URL pattern, call that if getattr(view, 'derive_url_pattern', None): return view.derive_url_pattern(self.path, action) # o...
python
def pattern_for_view(self, view, action): """ Returns the URL pattern for the passed in action. """ # if this view knows how to define a URL pattern, call that if getattr(view, 'derive_url_pattern', None): return view.derive_url_pattern(self.path, action) # o...
[ "def", "pattern_for_view", "(", "self", ",", "view", ",", "action", ")", ":", "# if this view knows how to define a URL pattern, call that", "if", "getattr", "(", "view", ",", "'derive_url_pattern'", ",", "None", ")", ":", "return", "view", ".", "derive_url_pattern", ...
Returns the URL pattern for the passed in action.
[ "Returns", "the", "URL", "pattern", "for", "the", "passed", "in", "action", "." ]
488a676a4960555e4d216a7b95d6e01a4ad4efd8
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L1480-L1490
train
Returns the URL pattern for the passed in action.
nyaruka/smartmin
smartmin/views.py
SmartCRUDL.as_urlpatterns
def as_urlpatterns(self): """ Creates the appropriate URLs for this object. """ urls = [] # for each of our actions for action in self.actions: view_class = self.view_for_action(action) view_pattern = self.pattern_for_view(view_class, action) ...
python
def as_urlpatterns(self): """ Creates the appropriate URLs for this object. """ urls = [] # for each of our actions for action in self.actions: view_class = self.view_for_action(action) view_pattern = self.pattern_for_view(view_class, action) ...
[ "def", "as_urlpatterns", "(", "self", ")", ":", "urls", "=", "[", "]", "# for each of our actions", "for", "action", "in", "self", ".", "actions", ":", "view_class", "=", "self", ".", "view_for_action", "(", "action", ")", "view_pattern", "=", "self", ".", ...
Creates the appropriate URLs for this object.
[ "Creates", "the", "appropriate", "URLs", "for", "this", "object", "." ]
488a676a4960555e4d216a7b95d6e01a4ad4efd8
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L1492-L1505
train
Creates the appropriate URLs for this object.
nyaruka/smartmin
smartmin/management/commands/collect_sql.py
Command.load_migrations
def load_migrations(self): # pragma: no cover """ Loads all migrations in the order they would be applied to a clean database """ executor = MigrationExecutor(connection=None) # create the forwards plan Django would follow on an empty database plan = executor.migration_...
python
def load_migrations(self): # pragma: no cover """ Loads all migrations in the order they would be applied to a clean database """ executor = MigrationExecutor(connection=None) # create the forwards plan Django would follow on an empty database plan = executor.migration_...
[ "def", "load_migrations", "(", "self", ")", ":", "# pragma: no cover", "executor", "=", "MigrationExecutor", "(", "connection", "=", "None", ")", "# create the forwards plan Django would follow on an empty database", "plan", "=", "executor", ".", "migration_plan", "(", "e...
Loads all migrations in the order they would be applied to a clean database
[ "Loads", "all", "migrations", "in", "the", "order", "they", "would", "be", "applied", "to", "a", "clean", "database" ]
488a676a4960555e4d216a7b95d6e01a4ad4efd8
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/management/commands/collect_sql.py#L120-L133
train
Load all migrations in the order they would be applied to a clean database.
nyaruka/smartmin
smartmin/management/commands/collect_sql.py
Command.extract_operations
def extract_operations(self, migrations): """ Extract SQL operations from the given migrations """ operations = [] for migration in migrations: for operation in migration.operations: if isinstance(operation, RunSQL): statements = s...
python
def extract_operations(self, migrations): """ Extract SQL operations from the given migrations """ operations = [] for migration in migrations: for operation in migration.operations: if isinstance(operation, RunSQL): statements = s...
[ "def", "extract_operations", "(", "self", ",", "migrations", ")", ":", "operations", "=", "[", "]", "for", "migration", "in", "migrations", ":", "for", "operation", "in", "migration", ".", "operations", ":", "if", "isinstance", "(", "operation", ",", "RunSQL...
Extract SQL operations from the given migrations
[ "Extract", "SQL", "operations", "from", "the", "given", "migrations" ]
488a676a4960555e4d216a7b95d6e01a4ad4efd8
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/management/commands/collect_sql.py#L135-L154
train
Extract SQL operations from the given migrations.
nyaruka/smartmin
smartmin/management/commands/collect_sql.py
Command.normalize_operations
def normalize_operations(self, operations): """ Removes redundant SQL operations - e.g. a CREATE X followed by a DROP X """ normalized = OrderedDict() for operation in operations: op_key = (operation.sql_type, operation.obj_name) # do we already have an ...
python
def normalize_operations(self, operations): """ Removes redundant SQL operations - e.g. a CREATE X followed by a DROP X """ normalized = OrderedDict() for operation in operations: op_key = (operation.sql_type, operation.obj_name) # do we already have an ...
[ "def", "normalize_operations", "(", "self", ",", "operations", ")", ":", "normalized", "=", "OrderedDict", "(", ")", "for", "operation", "in", "operations", ":", "op_key", "=", "(", "operation", ".", "sql_type", ",", "operation", ".", "obj_name", ")", "# do ...
Removes redundant SQL operations - e.g. a CREATE X followed by a DROP X
[ "Removes", "redundant", "SQL", "operations", "-", "e", ".", "g", ".", "a", "CREATE", "X", "followed", "by", "a", "DROP", "X" ]
488a676a4960555e4d216a7b95d6e01a4ad4efd8
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/management/commands/collect_sql.py#L156-L178
train
Normalizes SQL operations for the object.
nyaruka/smartmin
smartmin/management/commands/collect_sql.py
Command.write_type_dumps
def write_type_dumps(self, operations, preserve_order, output_dir): """ Splits the list of SQL operations by type and dumps these to separate files """ by_type = {SqlType.INDEX: [], SqlType.FUNCTION: [], SqlType.TRIGGER: []} for operation in operations: by_type[operat...
python
def write_type_dumps(self, operations, preserve_order, output_dir): """ Splits the list of SQL operations by type and dumps these to separate files """ by_type = {SqlType.INDEX: [], SqlType.FUNCTION: [], SqlType.TRIGGER: []} for operation in operations: by_type[operat...
[ "def", "write_type_dumps", "(", "self", ",", "operations", ",", "preserve_order", ",", "output_dir", ")", ":", "by_type", "=", "{", "SqlType", ".", "INDEX", ":", "[", "]", ",", "SqlType", ".", "FUNCTION", ":", "[", "]", ",", "SqlType", ".", "TRIGGER", ...
Splits the list of SQL operations by type and dumps these to separate files
[ "Splits", "the", "list", "of", "SQL", "operations", "by", "type", "and", "dumps", "these", "to", "separate", "files" ]
488a676a4960555e4d216a7b95d6e01a4ad4efd8
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/management/commands/collect_sql.py#L180-L198
train
Splits the list of SQL operations by type and dumps them to separate files
nyaruka/smartmin
smartmin/widgets.py
VisibleHiddenWidget.render
def render(self, name, value, attrs=None, renderer=None): """ Returns this Widget rendered as HTML, as a Unicode string. The 'value' given is not guaranteed to be valid input, so subclass implementations should program defensively. """ html = '' html += '%s' % va...
python
def render(self, name, value, attrs=None, renderer=None): """ Returns this Widget rendered as HTML, as a Unicode string. The 'value' given is not guaranteed to be valid input, so subclass implementations should program defensively. """ html = '' html += '%s' % va...
[ "def", "render", "(", "self", ",", "name", ",", "value", ",", "attrs", "=", "None", ",", "renderer", "=", "None", ")", ":", "html", "=", "''", "html", "+=", "'%s'", "%", "value", "html", "+=", "'<input type=\"hidden\" name=\"%s\" value=\"%s\">'", "%", "(",...
Returns this Widget rendered as HTML, as a Unicode string. The 'value' given is not guaranteed to be valid input, so subclass implementations should program defensively.
[ "Returns", "this", "Widget", "rendered", "as", "HTML", "as", "a", "Unicode", "string", "." ]
488a676a4960555e4d216a7b95d6e01a4ad4efd8
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/widgets.py#L9-L19
train
Returns this Widget rendered as HTML as a Unicode string.
rcsb/mmtf-python
mmtf/utils/decoder_utils.py
add_atom_data
def add_atom_data(data_api, data_setters, atom_names, element_names, atom_charges, group_atom_ind): """Add the atomic data to the DataTransferInterface. :param data_api the data api from where to get the data :param data_setters the class to push the data to :param atom_nams the list of atom names for t...
python
def add_atom_data(data_api, data_setters, atom_names, element_names, atom_charges, group_atom_ind): """Add the atomic data to the DataTransferInterface. :param data_api the data api from where to get the data :param data_setters the class to push the data to :param atom_nams the list of atom names for t...
[ "def", "add_atom_data", "(", "data_api", ",", "data_setters", ",", "atom_names", ",", "element_names", ",", "atom_charges", ",", "group_atom_ind", ")", ":", "atom_name", "=", "atom_names", "[", "group_atom_ind", "]", "element", "=", "element_names", "[", "group_at...
Add the atomic data to the DataTransferInterface. :param data_api the data api from where to get the data :param data_setters the class to push the data to :param atom_nams the list of atom names for the group :param element_names the list of element names for this group :param atom_charges the list...
[ "Add", "the", "atomic", "data", "to", "the", "DataTransferInterface", ".", ":", "param", "data_api", "the", "data", "api", "from", "where", "to", "get", "the", "data", ":", "param", "data_setters", "the", "class", "to", "push", "the", "data", "to", ":", ...
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/utils/decoder_utils.py#L4-L23
train
Adds the atom data to the data_setters class
rcsb/mmtf-python
mmtf/utils/decoder_utils.py
add_group_bonds
def add_group_bonds(data_setters, bond_indices, bond_orders): """Add the bonds for this group. :param data_setters the class to push the data to :param bond_indices the indices of the atoms in the group that are bonded (in pairs) :param bond_orders the orders of the bonds""" for bond_index in ra...
python
def add_group_bonds(data_setters, bond_indices, bond_orders): """Add the bonds for this group. :param data_setters the class to push the data to :param bond_indices the indices of the atoms in the group that are bonded (in pairs) :param bond_orders the orders of the bonds""" for bond_index in ra...
[ "def", "add_group_bonds", "(", "data_setters", ",", "bond_indices", ",", "bond_orders", ")", ":", "for", "bond_index", "in", "range", "(", "len", "(", "bond_orders", ")", ")", ":", "data_setters", ".", "set_group_bond", "(", "bond_indices", "[", "bond_index", ...
Add the bonds for this group. :param data_setters the class to push the data to :param bond_indices the indices of the atoms in the group that are bonded (in pairs) :param bond_orders the orders of the bonds
[ "Add", "the", "bonds", "for", "this", "group", ".", ":", "param", "data_setters", "the", "class", "to", "push", "the", "data", "to", ":", "param", "bond_indices", "the", "indices", "of", "the", "atoms", "in", "the", "group", "that", "are", "bonded", "(",...
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/utils/decoder_utils.py#L26-L33
train
Adds the bonds to the group.
rcsb/mmtf-python
mmtf/utils/decoder_utils.py
add_group
def add_group(data_api, data_setters, group_index): """Add the data for a whole group. :param data_api the data api from where to get the data :param data_setters the class to push the data to :param group_index the index for this group""" group_type_ind = data_api.group_type_list[group_index] a...
python
def add_group(data_api, data_setters, group_index): """Add the data for a whole group. :param data_api the data api from where to get the data :param data_setters the class to push the data to :param group_index the index for this group""" group_type_ind = data_api.group_type_list[group_index] a...
[ "def", "add_group", "(", "data_api", ",", "data_setters", ",", "group_index", ")", ":", "group_type_ind", "=", "data_api", ".", "group_type_list", "[", "group_index", "]", "atom_count", "=", "len", "(", "data_api", ".", "group_list", "[", "group_type_ind", "]", ...
Add the data for a whole group. :param data_api the data api from where to get the data :param data_setters the class to push the data to :param group_index the index for this group
[ "Add", "the", "data", "for", "a", "whole", "group", ".", ":", "param", "data_api", "the", "data", "api", "from", "where", "to", "get", "the", "data", ":", "param", "data_setters", "the", "class", "to", "push", "the", "data", "to", ":", "param", "group_...
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/utils/decoder_utils.py#L36-L61
train
Adds the data for a whole group to the group_list
rcsb/mmtf-python
mmtf/utils/decoder_utils.py
add_chain_info
def add_chain_info(data_api, data_setters, chain_index): """Add the data for a whole chain. :param data_api the data api from where to get the data :param data_setters the class to push the data to :param chain_index the index for this chain""" chain_id = data_api.chain_id_list[chain_index] chai...
python
def add_chain_info(data_api, data_setters, chain_index): """Add the data for a whole chain. :param data_api the data api from where to get the data :param data_setters the class to push the data to :param chain_index the index for this chain""" chain_id = data_api.chain_id_list[chain_index] chai...
[ "def", "add_chain_info", "(", "data_api", ",", "data_setters", ",", "chain_index", ")", ":", "chain_id", "=", "data_api", ".", "chain_id_list", "[", "chain_index", "]", "chain_name", "=", "data_api", ".", "chain_name_list", "[", "chain_index", "]", "num_groups", ...
Add the data for a whole chain. :param data_api the data api from where to get the data :param data_setters the class to push the data to :param chain_index the index for this chain
[ "Add", "the", "data", "for", "a", "whole", "chain", ".", ":", "param", "data_api", "the", "data", "api", "from", "where", "to", "get", "the", "data", ":", "param", "data_setters", "the", "class", "to", "push", "the", "data", "to", ":", "param", "chain_...
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/utils/decoder_utils.py#L64-L78
train
Add the data for a whole chain.
rcsb/mmtf-python
mmtf/utils/decoder_utils.py
add_atomic_information
def add_atomic_information(data_api, data_setters): """Add all the structural information. :param data_api the data api from where to get the data :param data_setters the class to push the data to""" for model_chains in data_api.chains_per_model: data_setters.set_model_info(data_api.model_counte...
python
def add_atomic_information(data_api, data_setters): """Add all the structural information. :param data_api the data api from where to get the data :param data_setters the class to push the data to""" for model_chains in data_api.chains_per_model: data_setters.set_model_info(data_api.model_counte...
[ "def", "add_atomic_information", "(", "data_api", ",", "data_setters", ")", ":", "for", "model_chains", "in", "data_api", ".", "chains_per_model", ":", "data_setters", ".", "set_model_info", "(", "data_api", ".", "model_counter", ",", "model_chains", ")", "tot_chain...
Add all the structural information. :param data_api the data api from where to get the data :param data_setters the class to push the data to
[ "Add", "all", "the", "structural", "information", ".", ":", "param", "data_api", "the", "data", "api", "from", "where", "to", "get", "the", "data", ":", "param", "data_setters", "the", "class", "to", "push", "the", "data", "to" ]
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/utils/decoder_utils.py#L81-L91
train
Add all the atomic information to the data_api
rcsb/mmtf-python
mmtf/utils/decoder_utils.py
generate_bio_assembly
def generate_bio_assembly(data_api, struct_inflator): """Generate the bioassembly data. :param data_api the interface to the decoded data :param struct_inflator the interface to put the data into the client object""" bioassembly_count = 0 for bioassembly in data_api.bio_assembly: bioassembly...
python
def generate_bio_assembly(data_api, struct_inflator): """Generate the bioassembly data. :param data_api the interface to the decoded data :param struct_inflator the interface to put the data into the client object""" bioassembly_count = 0 for bioassembly in data_api.bio_assembly: bioassembly...
[ "def", "generate_bio_assembly", "(", "data_api", ",", "struct_inflator", ")", ":", "bioassembly_count", "=", "0", "for", "bioassembly", "in", "data_api", ".", "bio_assembly", ":", "bioassembly_count", "+=", "1", "for", "transform", "in", "bioassembly", "[", "\"tra...
Generate the bioassembly data. :param data_api the interface to the decoded data :param struct_inflator the interface to put the data into the client object
[ "Generate", "the", "bioassembly", "data", ".", ":", "param", "data_api", "the", "interface", "to", "the", "decoded", "data", ":", "param", "struct_inflator", "the", "interface", "to", "put", "the", "data", "into", "the", "client", "object" ]
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/utils/decoder_utils.py#L94-L104
train
Generate the bioassembly data.
rcsb/mmtf-python
mmtf/utils/decoder_utils.py
add_inter_group_bonds
def add_inter_group_bonds(data_api, struct_inflator): """ Generate inter group bonds. Bond indices are specified within the whole structure and start at 0. :param data_api the interface to the decoded data :param struct_inflator the interface to put the data into the client object""" for i in range(len(d...
python
def add_inter_group_bonds(data_api, struct_inflator): """ Generate inter group bonds. Bond indices are specified within the whole structure and start at 0. :param data_api the interface to the decoded data :param struct_inflator the interface to put the data into the client object""" for i in range(len(d...
[ "def", "add_inter_group_bonds", "(", "data_api", ",", "struct_inflator", ")", ":", "for", "i", "in", "range", "(", "len", "(", "data_api", ".", "bond_order_list", ")", ")", ":", "struct_inflator", ".", "set_inter_group_bond", "(", "data_api", ".", "bond_atom_lis...
Generate inter group bonds. Bond indices are specified within the whole structure and start at 0. :param data_api the interface to the decoded data :param struct_inflator the interface to put the data into the client object
[ "Generate", "inter", "group", "bonds", ".", "Bond", "indices", "are", "specified", "within", "the", "whole", "structure", "and", "start", "at", "0", ".", ":", "param", "data_api", "the", "interface", "to", "the", "decoded", "data", ":", "param", "struct_infl...
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/utils/decoder_utils.py#L106-L114
train
Generate inter group bonds.
rcsb/mmtf-python
mmtf/utils/decoder_utils.py
add_header_info
def add_header_info(data_api, struct_inflator): """ Add ancilliary header information to the structure. :param data_api the interface to the decoded data :param struct_inflator the interface to put the data into the client object """ struct_inflator.set_header_info(data_api.r_free, ...
python
def add_header_info(data_api, struct_inflator): """ Add ancilliary header information to the structure. :param data_api the interface to the decoded data :param struct_inflator the interface to put the data into the client object """ struct_inflator.set_header_info(data_api.r_free, ...
[ "def", "add_header_info", "(", "data_api", ",", "struct_inflator", ")", ":", "struct_inflator", ".", "set_header_info", "(", "data_api", ".", "r_free", ",", "data_api", ".", "r_work", ",", "data_api", ".", "resolution", ",", "data_api", ".", "title", ",", "dat...
Add ancilliary header information to the structure. :param data_api the interface to the decoded data :param struct_inflator the interface to put the data into the client object
[ "Add", "ancilliary", "header", "information", "to", "the", "structure", ".", ":", "param", "data_api", "the", "interface", "to", "the", "decoded", "data", ":", "param", "struct_inflator", "the", "interface", "to", "put", "the", "data", "into", "the", "client",...
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/utils/decoder_utils.py#L118-L129
train
Add ancilliary header information to the structure.
rcsb/mmtf-python
mmtf/utils/decoder_utils.py
add_xtalographic_info
def add_xtalographic_info(data_api, struct_inflator): """ Add the crystallographic data to the structure. :param data_api the interface to the decoded data :param struct_inflator the interface to put the data into the client object""" if data_api.unit_cell == None and data_api.space_group is not None: ...
python
def add_xtalographic_info(data_api, struct_inflator): """ Add the crystallographic data to the structure. :param data_api the interface to the decoded data :param struct_inflator the interface to put the data into the client object""" if data_api.unit_cell == None and data_api.space_group is not None: ...
[ "def", "add_xtalographic_info", "(", "data_api", ",", "struct_inflator", ")", ":", "if", "data_api", ".", "unit_cell", "==", "None", "and", "data_api", ".", "space_group", "is", "not", "None", ":", "struct_inflator", ".", "set_xtal_info", "(", "data_api", ".", ...
Add the crystallographic data to the structure. :param data_api the interface to the decoded data :param struct_inflator the interface to put the data into the client object
[ "Add", "the", "crystallographic", "data", "to", "the", "structure", ".", ":", "param", "data_api", "the", "interface", "to", "the", "decoded", "data", ":", "param", "struct_inflator", "the", "interface", "to", "put", "the", "data", "into", "the", "client", "...
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/utils/decoder_utils.py#L133-L148
train
Add the crystallographic data to the structure.
rcsb/mmtf-python
mmtf/utils/decoder_utils.py
add_entity_info
def add_entity_info( data_api, struct_inflator): """Add the entity info to the structure. :param data_api the interface to the decoded data :param struct_inflator the interface to put the data into the client object """ for entity in data_api.entity_list: struct_inflator.set_entity_info(enti...
python
def add_entity_info( data_api, struct_inflator): """Add the entity info to the structure. :param data_api the interface to the decoded data :param struct_inflator the interface to put the data into the client object """ for entity in data_api.entity_list: struct_inflator.set_entity_info(enti...
[ "def", "add_entity_info", "(", "data_api", ",", "struct_inflator", ")", ":", "for", "entity", "in", "data_api", ".", "entity_list", ":", "struct_inflator", ".", "set_entity_info", "(", "entity", "[", "\"chainIndexList\"", "]", ",", "entity", "[", "\"sequence\"", ...
Add the entity info to the structure. :param data_api the interface to the decoded data :param struct_inflator the interface to put the data into the client object
[ "Add", "the", "entity", "info", "to", "the", "structure", ".", ":", "param", "data_api", "the", "interface", "to", "the", "decoded", "data", ":", "param", "struct_inflator", "the", "interface", "to", "put", "the", "data", "into", "the", "client", "object" ]
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/utils/decoder_utils.py#L150-L159
train
Add the entity info to the structure.
rcsb/mmtf-python
mmtf/utils/decoder_utils.py
get_bonds
def get_bonds(input_group): """Utility function to get indices (in pairs) of the bonds.""" out_list = [] for i in range(len(input_group.bond_order_list)): out_list.append((input_group.bond_atom_list[i * 2], input_group.bond_atom_list[i * 2 + 1],)) return out_list
python
def get_bonds(input_group): """Utility function to get indices (in pairs) of the bonds.""" out_list = [] for i in range(len(input_group.bond_order_list)): out_list.append((input_group.bond_atom_list[i * 2], input_group.bond_atom_list[i * 2 + 1],)) return out_list
[ "def", "get_bonds", "(", "input_group", ")", ":", "out_list", "=", "[", "]", "for", "i", "in", "range", "(", "len", "(", "input_group", ".", "bond_order_list", ")", ")", ":", "out_list", ".", "append", "(", "(", "input_group", ".", "bond_atom_list", "[",...
Utility function to get indices (in pairs) of the bonds.
[ "Utility", "function", "to", "get", "indices", "(", "in", "pairs", ")", "of", "the", "bonds", "." ]
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/utils/decoder_utils.py#L162-L167
train
Utility function to get indices of the bonds.
rcsb/mmtf-python
mmtf/api/mmtf_writer.py
get_unique_groups
def get_unique_groups(input_list): """Function to get a unique list of groups.""" out_list = [] for item in input_list: if item not in out_list: out_list.append(item) return out_list
python
def get_unique_groups(input_list): """Function to get a unique list of groups.""" out_list = [] for item in input_list: if item not in out_list: out_list.append(item) return out_list
[ "def", "get_unique_groups", "(", "input_list", ")", ":", "out_list", "=", "[", "]", "for", "item", "in", "input_list", ":", "if", "item", "not", "in", "out_list", ":", "out_list", ".", "append", "(", "item", ")", "return", "out_list" ]
Function to get a unique list of groups.
[ "Function", "to", "get", "a", "unique", "list", "of", "groups", "." ]
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/mmtf_writer.py#L59-L65
train
Function to get a unique list of groups.
rcsb/mmtf-python
mmtf/api/mmtf_writer.py
Group.convert_to_dict
def convert_to_dict(self): """Convert the group object to an appropriate DICT""" out_dict = {} out_dict["groupName"] = self.group_name out_dict["atomNameList"] = self.atom_name_list out_dict["elementList"] = self.element_list out_dict["bondOrderList"] = self.bond_order_li...
python
def convert_to_dict(self): """Convert the group object to an appropriate DICT""" out_dict = {} out_dict["groupName"] = self.group_name out_dict["atomNameList"] = self.atom_name_list out_dict["elementList"] = self.element_list out_dict["bondOrderList"] = self.bond_order_li...
[ "def", "convert_to_dict", "(", "self", ")", ":", "out_dict", "=", "{", "}", "out_dict", "[", "\"groupName\"", "]", "=", "self", ".", "group_name", "out_dict", "[", "\"atomNameList\"", "]", "=", "self", ".", "atom_name_list", "out_dict", "[", "\"elementList\"",...
Convert the group object to an appropriate DICT
[ "Convert", "the", "group", "object", "to", "an", "appropriate", "DICT" ]
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/mmtf_writer.py#L45-L56
train
Convert the group object to a dictionary
rcsb/mmtf-python
mmtf/api/mmtf_writer.py
TemplateEncoder.set_atom_info
def set_atom_info(self, atom_name, serial_number, alternative_location_id, x, y, z, occupancy, temperature_factor, element, charge): """Create an atom object an set the information. :param atom_name: the atom name, e.g. CA for this atom :param serial_number: the serial id o...
python
def set_atom_info(self, atom_name, serial_number, alternative_location_id, x, y, z, occupancy, temperature_factor, element, charge): """Create an atom object an set the information. :param atom_name: the atom name, e.g. CA for this atom :param serial_number: the serial id o...
[ "def", "set_atom_info", "(", "self", ",", "atom_name", ",", "serial_number", ",", "alternative_location_id", ",", "x", ",", "y", ",", "z", ",", "occupancy", ",", "temperature_factor", ",", "element", ",", "charge", ")", ":", "raise", "NotImplementedError" ]
Create an atom object an set the information. :param atom_name: the atom name, e.g. CA for this atom :param serial_number: the serial id of the atom (e.g. 1) :param alternative_location_id: the alternative location id for the atom, if present :param x: the x coordiante of the atom ...
[ "Create", "an", "atom", "object", "an", "set", "the", "information", ".", ":", "param", "atom_name", ":", "the", "atom", "name", "e", ".", "g", ".", "CA", "for", "this", "atom", ":", "param", "serial_number", ":", "the", "serial", "id", "of", "the", ...
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/mmtf_writer.py#L84-L98
train
Create an atom object and set the information.
rcsb/mmtf-python
mmtf/api/mmtf_writer.py
TemplateEncoder.set_group_info
def set_group_info(self, group_name, group_number, insertion_code, group_type, atom_count, bond_count, single_letter_code, sequence_index, secondary_structure_type): """Set the information for a group :param group_name: the name of this group,e.g. LYS ...
python
def set_group_info(self, group_name, group_number, insertion_code, group_type, atom_count, bond_count, single_letter_code, sequence_index, secondary_structure_type): """Set the information for a group :param group_name: the name of this group,e.g. LYS ...
[ "def", "set_group_info", "(", "self", ",", "group_name", ",", "group_number", ",", "insertion_code", ",", "group_type", ",", "atom_count", ",", "bond_count", ",", "single_letter_code", ",", "sequence_index", ",", "secondary_structure_type", ")", ":", "raise", "NotIm...
Set the information for a group :param group_name: the name of this group,e.g. LYS :param group_number: the residue number of this group :param insertion_code: the insertion code for this group :param group_type: a string indicating the type of group (as found in the chemcomp dictionary....
[ "Set", "the", "information", "for", "a", "group", ":", "param", "group_name", ":", "the", "name", "of", "this", "group", "e", ".", "g", ".", "LYS", ":", "param", "group_number", ":", "the", "residue", "number", "of", "this", "group", ":", "param", "ins...
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/mmtf_writer.py#L121-L137
train
Set the group information for a specific entry in the chemical dictionary.
rcsb/mmtf-python
mmtf/api/mmtf_writer.py
TemplateEncoder.set_header_info
def set_header_info(self, r_free, r_work, resolution, title, deposition_date, release_date, experimental_methods): """Sets the header information. :param r_free: the measured R-Free for the structure :param r_work: the measure R-Work for the structure :param resol...
python
def set_header_info(self, r_free, r_work, resolution, title, deposition_date, release_date, experimental_methods): """Sets the header information. :param r_free: the measured R-Free for the structure :param r_work: the measure R-Work for the structure :param resol...
[ "def", "set_header_info", "(", "self", ",", "r_free", ",", "r_work", ",", "resolution", ",", "title", ",", "deposition_date", ",", "release_date", ",", "experimental_methods", ")", ":", "raise", "NotImplementedError" ]
Sets the header information. :param r_free: the measured R-Free for the structure :param r_work: the measure R-Work for the structure :param resolution: the resolution of the structure :param title: the title of the structure :param deposition_date: the deposition date of the str...
[ "Sets", "the", "header", "information", ".", ":", "param", "r_free", ":", "the", "measured", "R", "-", "Free", "for", "the", "structure", ":", "param", "r_work", ":", "the", "measure", "R", "-", "Work", "for", "the", "structure", ":", "param", "resolutio...
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/mmtf_writer.py#L158-L169
train
Sets the header information for the structure containing the structure containing the header information.
rcsb/mmtf-python
mmtf/api/mmtf_writer.py
MMTFEncoder.encode_data
def encode_data(self): """Encode the data back into a dict.""" output_data = {} output_data["groupTypeList"] = encode_array(self.group_type_list, 4, 0) output_data["xCoordList"] = encode_array(self.x_coord_list, 10, 1000) output_data["yCoordList"] = encode_array(self.y_coord_list...
python
def encode_data(self): """Encode the data back into a dict.""" output_data = {} output_data["groupTypeList"] = encode_array(self.group_type_list, 4, 0) output_data["xCoordList"] = encode_array(self.x_coord_list, 10, 1000) output_data["yCoordList"] = encode_array(self.y_coord_list...
[ "def", "encode_data", "(", "self", ")", ":", "output_data", "=", "{", "}", "output_data", "[", "\"groupTypeList\"", "]", "=", "encode_array", "(", "self", ".", "group_type_list", ",", "4", ",", "0", ")", "output_data", "[", "\"xCoordList\"", "]", "=", "enc...
Encode the data back into a dict.
[ "Encode", "the", "data", "back", "into", "a", "dict", "." ]
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/mmtf_writer.py#L209-L250
train
Encode the data back into a dict.
rcsb/mmtf-python
mmtf/api/mmtf_writer.py
MMTFEncoder.init_structure
def init_structure(self, total_num_bonds, total_num_atoms, total_num_groups, total_num_chains, total_num_models, structure_id): """Initialise the structure object. :param total_num_bonds: the number of bonds in the structure :param total_num_atoms: t...
python
def init_structure(self, total_num_bonds, total_num_atoms, total_num_groups, total_num_chains, total_num_models, structure_id): """Initialise the structure object. :param total_num_bonds: the number of bonds in the structure :param total_num_atoms: t...
[ "def", "init_structure", "(", "self", ",", "total_num_bonds", ",", "total_num_atoms", ",", "total_num_groups", ",", "total_num_chains", ",", "total_num_models", ",", "structure_id", ")", ":", "self", ".", "mmtf_version", "=", "constants", ".", "MMTF_VERSION", "self"...
Initialise the structure object. :param total_num_bonds: the number of bonds in the structure :param total_num_atoms: the number of atoms in the structure :param total_num_groups: the number of groups in the structure :param total_num_chains: the number of chains in the structure ...
[ "Initialise", "the", "structure", "object", ".", ":", "param", "total_num_bonds", ":", "the", "number", "of", "bonds", "in", "the", "structure", ":", "param", "total_num_atoms", ":", "the", "number", "of", "atoms", "in", "the", "structure", ":", "param", "to...
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/mmtf_writer.py#L263-L304
train
Initialise the structure object.
rcsb/mmtf-python
mmtf/api/mmtf_writer.py
MMTFEncoder.set_atom_info
def set_atom_info(self, atom_name, serial_number, alternative_location_id, x, y, z, occupancy, temperature_factor, element, charge): """Create an atom object an set the information. :param atom_name: the atom name, e.g. CA for this atom :param serial_number: the serial id o...
python
def set_atom_info(self, atom_name, serial_number, alternative_location_id, x, y, z, occupancy, temperature_factor, element, charge): """Create an atom object an set the information. :param atom_name: the atom name, e.g. CA for this atom :param serial_number: the serial id o...
[ "def", "set_atom_info", "(", "self", ",", "atom_name", ",", "serial_number", ",", "alternative_location_id", ",", "x", ",", "y", ",", "z", ",", "occupancy", ",", "temperature_factor", ",", "element", ",", "charge", ")", ":", "self", ".", "x_coord_list", ".",...
Create an atom object an set the information. :param atom_name: the atom name, e.g. CA for this atom :param serial_number: the serial id of the atom (e.g. 1) :param alternative_location_id: the alternative location id for the atom, if present :param x: the x coordiante of the atom ...
[ "Create", "an", "atom", "object", "an", "set", "the", "information", ".", ":", "param", "atom_name", ":", "the", "atom", "name", "e", ".", "g", ".", "CA", "for", "this", "atom", ":", "param", "serial_number", ":", "the", "serial", "id", "of", "the", ...
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/mmtf_writer.py#L307-L331
train
Create an atom object and set the information.
rcsb/mmtf-python
mmtf/api/mmtf_writer.py
MMTFEncoder.set_chain_info
def set_chain_info(self, chain_id, chain_name, num_groups): """Set the chain information. :param chain_id: the asym chain id from mmCIF :param chain_name: the auth chain id from mmCIF :param num_groups: the number of groups this chain has """ self.chain_id_list.append(cha...
python
def set_chain_info(self, chain_id, chain_name, num_groups): """Set the chain information. :param chain_id: the asym chain id from mmCIF :param chain_name: the auth chain id from mmCIF :param num_groups: the number of groups this chain has """ self.chain_id_list.append(cha...
[ "def", "set_chain_info", "(", "self", ",", "chain_id", ",", "chain_name", ",", "num_groups", ")", ":", "self", ".", "chain_id_list", ".", "append", "(", "chain_id", ")", "self", ".", "chain_name_list", ".", "append", "(", "chain_name", ")", "self", ".", "g...
Set the chain information. :param chain_id: the asym chain id from mmCIF :param chain_name: the auth chain id from mmCIF :param num_groups: the number of groups this chain has
[ "Set", "the", "chain", "information", ".", ":", "param", "chain_id", ":", "the", "asym", "chain", "id", "from", "mmCIF", ":", "param", "chain_name", ":", "the", "auth", "chain", "id", "from", "mmCIF", ":", "param", "num_groups", ":", "the", "number", "of...
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/mmtf_writer.py#L334-L342
train
Set the chain information.
rcsb/mmtf-python
mmtf/api/mmtf_writer.py
MMTFEncoder.set_entity_info
def set_entity_info(self, chain_indices, sequence, description, entity_type): """Set the entity level information for the structure. :param chain_indices: the indices of the chains for this entity :param sequence: the one letter code sequence for this entity :param description: the descr...
python
def set_entity_info(self, chain_indices, sequence, description, entity_type): """Set the entity level information for the structure. :param chain_indices: the indices of the chains for this entity :param sequence: the one letter code sequence for this entity :param description: the descr...
[ "def", "set_entity_info", "(", "self", ",", "chain_indices", ",", "sequence", ",", "description", ",", "entity_type", ")", ":", "self", ".", "entity_list", ".", "append", "(", "make_entity_dict", "(", "chain_indices", ",", "sequence", ",", "description", ",", ...
Set the entity level information for the structure. :param chain_indices: the indices of the chains for this entity :param sequence: the one letter code sequence for this entity :param description: the description for this entity :param entity_type: the entity type (polymer,non-polymer,w...
[ "Set", "the", "entity", "level", "information", "for", "the", "structure", ".", ":", "param", "chain_indices", ":", "the", "indices", "of", "the", "chains", "for", "this", "entity", ":", "param", "sequence", ":", "the", "one", "letter", "code", "sequence", ...
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/mmtf_writer.py#L345-L352
train
Set the entity level information for the structure.
rcsb/mmtf-python
mmtf/api/mmtf_writer.py
MMTFEncoder.set_group_info
def set_group_info(self, group_name, group_number, insertion_code, group_type, atom_count, bond_count, single_letter_code, sequence_index, secondary_structure_type): """Set the information for a group :param group_name: the name of this group,e.g. LYS ...
python
def set_group_info(self, group_name, group_number, insertion_code, group_type, atom_count, bond_count, single_letter_code, sequence_index, secondary_structure_type): """Set the information for a group :param group_name: the name of this group,e.g. LYS ...
[ "def", "set_group_info", "(", "self", ",", "group_name", ",", "group_number", ",", "insertion_code", ",", "group_type", ",", "atom_count", ",", "bond_count", ",", "single_letter_code", ",", "sequence_index", ",", "secondary_structure_type", ")", ":", "# Add the group ...
Set the information for a group :param group_name: the name of this group,e.g. LYS :param group_number: the residue number of this group :param insertion_code: the insertion code for this group :param group_type: a string indicating the type of group (as found in the chemcomp dictionary....
[ "Set", "the", "information", "for", "a", "group", ":", "param", "group_name", ":", "the", "name", "of", "this", "group", "e", ".", "g", ".", "LYS", ":", "param", "group_number", ":", "the", "residue", "number", "of", "this", "group", ":", "param", "ins...
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/mmtf_writer.py#L355-L383
train
Set the group level information for a group
rcsb/mmtf-python
mmtf/api/mmtf_writer.py
MMTFEncoder.set_xtal_info
def set_xtal_info(self, space_group, unit_cell): """Set the crystallographic information for the structure :param space_group: the space group name, e.g. "P 21 21 21" :param unit_cell: an array of length 6 with the unit cell parameters in order: a, b, c, alpha, beta, gamma """ se...
python
def set_xtal_info(self, space_group, unit_cell): """Set the crystallographic information for the structure :param space_group: the space group name, e.g. "P 21 21 21" :param unit_cell: an array of length 6 with the unit cell parameters in order: a, b, c, alpha, beta, gamma """ se...
[ "def", "set_xtal_info", "(", "self", ",", "space_group", ",", "unit_cell", ")", ":", "self", ".", "space_group", "=", "space_group", "self", ".", "unit_cell", "=", "unit_cell" ]
Set the crystallographic information for the structure :param space_group: the space group name, e.g. "P 21 21 21" :param unit_cell: an array of length 6 with the unit cell parameters in order: a, b, c, alpha, beta, gamma
[ "Set", "the", "crystallographic", "information", "for", "the", "structure", ":", "param", "space_group", ":", "the", "space", "group", "name", "e", ".", "g", ".", "P", "21", "21", "21", ":", "param", "unit_cell", ":", "an", "array", "of", "length", "6", ...
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/mmtf_writer.py#L394-L400
train
Set the crystallographic information for the structure
rcsb/mmtf-python
mmtf/api/mmtf_writer.py
MMTFEncoder.set_header_info
def set_header_info(self, r_free, r_work, resolution, title, deposition_date, release_date, experimental_methods): """Sets the header information. :param r_free: the measured R-Free for the structure :param r_work: the measure R-Work for the structure :param resol...
python
def set_header_info(self, r_free, r_work, resolution, title, deposition_date, release_date, experimental_methods): """Sets the header information. :param r_free: the measured R-Free for the structure :param r_work: the measure R-Work for the structure :param resol...
[ "def", "set_header_info", "(", "self", ",", "r_free", ",", "r_work", ",", "resolution", ",", "title", ",", "deposition_date", ",", "release_date", ",", "experimental_methods", ")", ":", "self", ".", "r_free", "=", "r_free", "self", ".", "r_work", "=", "r_wor...
Sets the header information. :param r_free: the measured R-Free for the structure :param r_work: the measure R-Work for the structure :param resolution: the resolution of the structure :param title: the title of the structure :param deposition_date: the deposition date of the str...
[ "Sets", "the", "header", "information", ".", ":", "param", "r_free", ":", "the", "measured", "R", "-", "Free", "for", "the", "structure", ":", "param", "r_work", ":", "the", "measure", "R", "-", "Work", "for", "the", "structure", ":", "param", "resolutio...
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/mmtf_writer.py#L402-L419
train
Sets the header information for the structure containing the entries in the structure containing the header information.
rcsb/mmtf-python
mmtf/api/mmtf_writer.py
MMTFEncoder.set_bio_assembly_trans
def set_bio_assembly_trans(self, bio_assembly_index, input_chain_indices, input_transform): """Set the Bioassembly transformation information. A single bioassembly can have multiple transforms, :param bio_assembly_index: the integer index of the bioassembly :param input_chain_indices: the list o...
python
def set_bio_assembly_trans(self, bio_assembly_index, input_chain_indices, input_transform): """Set the Bioassembly transformation information. A single bioassembly can have multiple transforms, :param bio_assembly_index: the integer index of the bioassembly :param input_chain_indices: the list o...
[ "def", "set_bio_assembly_trans", "(", "self", ",", "bio_assembly_index", ",", "input_chain_indices", ",", "input_transform", ")", ":", "this_bioass", "=", "None", "for", "bioass", "in", "self", ".", "bio_assembly", ":", "if", "bioass", "[", "'name'", "]", "==", ...
Set the Bioassembly transformation information. A single bioassembly can have multiple transforms, :param bio_assembly_index: the integer index of the bioassembly :param input_chain_indices: the list of integer indices for the chains of this bioassembly :param input_transformation: the list of d...
[ "Set", "the", "Bioassembly", "transformation", "information", ".", "A", "single", "bioassembly", "can", "have", "multiple", "transforms", ":", "param", "bio_assembly_index", ":", "the", "integer", "index", "of", "the", "bioassembly", ":", "param", "input_chain_indic...
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/mmtf_writer.py#L422-L437
train
Set the Bioassembly transformation information. A single bioassembly can have multiple transforms.
rcsb/mmtf-python
mmtf/api/mmtf_writer.py
MMTFEncoder.finalize_structure
def finalize_structure(self): """Any functions needed to cleanup the structure.""" self.group_list.append(self.current_group) group_set = get_unique_groups(self.group_list) for item in self.group_list: self.group_type_list.append(group_set.index(item)) self.group_list...
python
def finalize_structure(self): """Any functions needed to cleanup the structure.""" self.group_list.append(self.current_group) group_set = get_unique_groups(self.group_list) for item in self.group_list: self.group_type_list.append(group_set.index(item)) self.group_list...
[ "def", "finalize_structure", "(", "self", ")", ":", "self", ".", "group_list", ".", "append", "(", "self", ".", "current_group", ")", "group_set", "=", "get_unique_groups", "(", "self", ".", "group_list", ")", "for", "item", "in", "self", ".", "group_list", ...
Any functions needed to cleanup the structure.
[ "Any", "functions", "needed", "to", "cleanup", "the", "structure", "." ]
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/mmtf_writer.py#L440-L446
train
Any functions needed to cleanup the structure.
rcsb/mmtf-python
mmtf/api/mmtf_writer.py
MMTFEncoder.set_group_bond
def set_group_bond(self, atom_index_one, atom_index_two, bond_order): """Add bonds within a group. :param atom_index_one: the integer atom index (in the group) of the first partner in the bond :param atom_index_two: the integer atom index (in the group) of the second partner in the bond ...
python
def set_group_bond(self, atom_index_one, atom_index_two, bond_order): """Add bonds within a group. :param atom_index_one: the integer atom index (in the group) of the first partner in the bond :param atom_index_two: the integer atom index (in the group) of the second partner in the bond ...
[ "def", "set_group_bond", "(", "self", ",", "atom_index_one", ",", "atom_index_two", ",", "bond_order", ")", ":", "self", ".", "current_group", ".", "bond_atom_list", ".", "append", "(", "atom_index_one", ")", "self", ".", "current_group", ".", "bond_atom_list", ...
Add bonds within a group. :param atom_index_one: the integer atom index (in the group) of the first partner in the bond :param atom_index_two: the integer atom index (in the group) of the second partner in the bond :param bond_order: the integer bond order
[ "Add", "bonds", "within", "a", "group", ".", ":", "param", "atom_index_one", ":", "the", "integer", "atom", "index", "(", "in", "the", "group", ")", "of", "the", "first", "partner", "in", "the", "bond", ":", "param", "atom_index_two", ":", "the", "intege...
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/mmtf_writer.py#L449-L457
train
Add bonds within a group.
rcsb/mmtf-python
mmtf/api/mmtf_writer.py
MMTFEncoder.set_inter_group_bond
def set_inter_group_bond(self, atom_index_one, atom_index_two, bond_order): """Add bonds between groups. :param atom_index_one: the integer atom index (in the structure) of the first partner in the bond :param atom_index_two: the integer atom index (in the structure) of the second partner in the...
python
def set_inter_group_bond(self, atom_index_one, atom_index_two, bond_order): """Add bonds between groups. :param atom_index_one: the integer atom index (in the structure) of the first partner in the bond :param atom_index_two: the integer atom index (in the structure) of the second partner in the...
[ "def", "set_inter_group_bond", "(", "self", ",", "atom_index_one", ",", "atom_index_two", ",", "bond_order", ")", ":", "self", ".", "bond_atom_list", ".", "append", "(", "atom_index_one", ")", "self", ".", "bond_atom_list", ".", "append", "(", "atom_index_two", ...
Add bonds between groups. :param atom_index_one: the integer atom index (in the structure) of the first partner in the bond :param atom_index_two: the integer atom index (in the structure) of the second partner in the bond :param bond_order the bond order
[ "Add", "bonds", "between", "groups", ".", ":", "param", "atom_index_one", ":", "the", "integer", "atom", "index", "(", "in", "the", "structure", ")", "of", "the", "first", "partner", "in", "the", "bond", ":", "param", "atom_index_two", ":", "the", "integer...
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/mmtf_writer.py#L460-L468
train
Add bonds between groups. A bond is added to the list of bonds that are connected to the first and second partner in the bond. A bond is added to the list of bonds that are connected to the second partner in the bond.
rcsb/mmtf-python
mmtf/codecs/encoders/encoders.py
run_length_encode
def run_length_encode(in_array): """A function to run length decode an int array. :param in_array: the inptut array of integers :return the encoded integer array""" if(len(in_array)==0): return [] curr_ans = in_array[0] out_array = [curr_ans] counter = 1 for in_int in in_array[1...
python
def run_length_encode(in_array): """A function to run length decode an int array. :param in_array: the inptut array of integers :return the encoded integer array""" if(len(in_array)==0): return [] curr_ans = in_array[0] out_array = [curr_ans] counter = 1 for in_int in in_array[1...
[ "def", "run_length_encode", "(", "in_array", ")", ":", "if", "(", "len", "(", "in_array", ")", "==", "0", ")", ":", "return", "[", "]", "curr_ans", "=", "in_array", "[", "0", "]", "out_array", "=", "[", "curr_ans", "]", "counter", "=", "1", "for", ...
A function to run length decode an int array. :param in_array: the inptut array of integers :return the encoded integer array
[ "A", "function", "to", "run", "length", "decode", "an", "int", "array", "." ]
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/codecs/encoders/encoders.py#L1-L21
train
A function to run length decode an integer array.
rcsb/mmtf-python
mmtf/codecs/encoders/encoders.py
delta_encode
def delta_encode(in_array): """A function to delta decode an int array. :param in_array: the inut array to be delta encoded :return the encoded integer array""" if(len(in_array)==0): return [] curr_ans = in_array[0] out_array = [curr_ans] for in_int in in_array[1:]: out_arra...
python
def delta_encode(in_array): """A function to delta decode an int array. :param in_array: the inut array to be delta encoded :return the encoded integer array""" if(len(in_array)==0): return [] curr_ans = in_array[0] out_array = [curr_ans] for in_int in in_array[1:]: out_arra...
[ "def", "delta_encode", "(", "in_array", ")", ":", "if", "(", "len", "(", "in_array", ")", "==", "0", ")", ":", "return", "[", "]", "curr_ans", "=", "in_array", "[", "0", "]", "out_array", "=", "[", "curr_ans", "]", "for", "in_int", "in", "in_array", ...
A function to delta decode an int array. :param in_array: the inut array to be delta encoded :return the encoded integer array
[ "A", "function", "to", "delta", "decode", "an", "int", "array", "." ]
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/codecs/encoders/encoders.py#L23-L35
train
A function to delta decode an integer array.
rcsb/mmtf-python
mmtf/codecs/default_codec.py
decode_array
def decode_array(input_array): """Parse the header of an input byte array and then decode using the input array, the codec and the appropirate parameter. :param input_array: the array to be decoded :return the decoded array""" codec, length, param, input_array = parse_header(input_array) return...
python
def decode_array(input_array): """Parse the header of an input byte array and then decode using the input array, the codec and the appropirate parameter. :param input_array: the array to be decoded :return the decoded array""" codec, length, param, input_array = parse_header(input_array) return...
[ "def", "decode_array", "(", "input_array", ")", ":", "codec", ",", "length", ",", "param", ",", "input_array", "=", "parse_header", "(", "input_array", ")", "return", "codec_dict", "[", "codec", "]", ".", "decode", "(", "input_array", ",", "param", ")" ]
Parse the header of an input byte array and then decode using the input array, the codec and the appropirate parameter. :param input_array: the array to be decoded :return the decoded array
[ "Parse", "the", "header", "of", "an", "input", "byte", "array", "and", "then", "decode", "using", "the", "input", "array", "the", "codec", "and", "the", "appropirate", "parameter", "." ]
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/codecs/default_codec.py#L12-L19
train
Parses the input byte array and then decodes using the codec and the appropirate parameter.
rcsb/mmtf-python
mmtf/codecs/default_codec.py
encode_array
def encode_array(input_array, codec, param): """Encode the array using the method and then add the header to this array. :param input_array: the array to be encoded :param codec: the integer index of the codec to use :param param: the integer parameter to use in the function :return an array with t...
python
def encode_array(input_array, codec, param): """Encode the array using the method and then add the header to this array. :param input_array: the array to be encoded :param codec: the integer index of the codec to use :param param: the integer parameter to use in the function :return an array with t...
[ "def", "encode_array", "(", "input_array", ",", "codec", ",", "param", ")", ":", "return", "add_header", "(", "codec_dict", "[", "codec", "]", ".", "encode", "(", "input_array", ",", "param", ")", ",", "codec", ",", "len", "(", "input_array", ")", ",", ...
Encode the array using the method and then add the header to this array. :param input_array: the array to be encoded :param codec: the integer index of the codec to use :param param: the integer parameter to use in the function :return an array with the header added to the fornt
[ "Encode", "the", "array", "using", "the", "method", "and", "then", "add", "the", "header", "to", "this", "array", "." ]
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/codecs/default_codec.py#L22-L29
train
Encode the array using the method and then add the header to the fornt
rcsb/mmtf-python
mmtf/codecs/decoders/decoders.py
run_length_decode
def run_length_decode(in_array): """A function to run length decode an int array. :param in_array: the input array of integers :return the decoded array""" switch=False out_array=[] for item in in_array: if switch==False: this_item = item switch=True else:...
python
def run_length_decode(in_array): """A function to run length decode an int array. :param in_array: the input array of integers :return the decoded array""" switch=False out_array=[] for item in in_array: if switch==False: this_item = item switch=True else:...
[ "def", "run_length_decode", "(", "in_array", ")", ":", "switch", "=", "False", "out_array", "=", "[", "]", "for", "item", "in", "in_array", ":", "if", "switch", "==", "False", ":", "this_item", "=", "item", "switch", "=", "True", "else", ":", "switch", ...
A function to run length decode an int array. :param in_array: the input array of integers :return the decoded array
[ "A", "function", "to", "run", "length", "decode", "an", "int", "array", ".", ":", "param", "in_array", ":", "the", "input", "array", "of", "integers", ":", "return", "the", "decoded", "array" ]
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/codecs/decoders/decoders.py#L1-L14
train
A function to run length decode an int array.
rcsb/mmtf-python
mmtf/codecs/decoders/decoders.py
delta_decode
def delta_decode(in_array): """A function to delta decode an int array. :param in_array: the input array of integers :return the decoded array""" if len(in_array) == 0: return [] this_ans = in_array[0] out_array = [this_ans] for i in range(1, len(in_array)): this_ans += in_a...
python
def delta_decode(in_array): """A function to delta decode an int array. :param in_array: the input array of integers :return the decoded array""" if len(in_array) == 0: return [] this_ans = in_array[0] out_array = [this_ans] for i in range(1, len(in_array)): this_ans += in_a...
[ "def", "delta_decode", "(", "in_array", ")", ":", "if", "len", "(", "in_array", ")", "==", "0", ":", "return", "[", "]", "this_ans", "=", "in_array", "[", "0", "]", "out_array", "=", "[", "this_ans", "]", "for", "i", "in", "range", "(", "1", ",", ...
A function to delta decode an int array. :param in_array: the input array of integers :return the decoded array
[ "A", "function", "to", "delta", "decode", "an", "int", "array", "." ]
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/codecs/decoders/decoders.py#L16-L28
train
A function to delta decode an int array.
rcsb/mmtf-python
mmtf/converters/numpy_converters.py
convert_bytes_to_ints
def convert_bytes_to_ints(in_bytes, num): """Convert a byte array into an integer array. The number of bytes forming an integer is defined by num :param in_bytes: the input bytes :param num: the number of bytes per int :return the integer array""" dt = numpy.dtype('>i' + str(num)) return nu...
python
def convert_bytes_to_ints(in_bytes, num): """Convert a byte array into an integer array. The number of bytes forming an integer is defined by num :param in_bytes: the input bytes :param num: the number of bytes per int :return the integer array""" dt = numpy.dtype('>i' + str(num)) return nu...
[ "def", "convert_bytes_to_ints", "(", "in_bytes", ",", "num", ")", ":", "dt", "=", "numpy", ".", "dtype", "(", "'>i'", "+", "str", "(", "num", ")", ")", "return", "numpy", ".", "frombuffer", "(", "in_bytes", ",", "dt", ")" ]
Convert a byte array into an integer array. The number of bytes forming an integer is defined by num :param in_bytes: the input bytes :param num: the number of bytes per int :return the integer array
[ "Convert", "a", "byte", "array", "into", "an", "integer", "array", ".", "The", "number", "of", "bytes", "forming", "an", "integer", "is", "defined", "by", "num" ]
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/converters/numpy_converters.py#L7-L15
train
Convert a byte array into an integer array.
rcsb/mmtf-python
mmtf/converters/numpy_converters.py
decode_chain_list
def decode_chain_list(in_bytes): """Convert a list of bytes to a list of strings. Each string is of length mmtf.CHAIN_LEN :param in_bytes: the input bytes :return the decoded list of strings""" bstrings = numpy.frombuffer(in_bytes, numpy.dtype('S' + str(mmtf.utils.constants.CHAIN_LEN))) return [s.d...
python
def decode_chain_list(in_bytes): """Convert a list of bytes to a list of strings. Each string is of length mmtf.CHAIN_LEN :param in_bytes: the input bytes :return the decoded list of strings""" bstrings = numpy.frombuffer(in_bytes, numpy.dtype('S' + str(mmtf.utils.constants.CHAIN_LEN))) return [s.d...
[ "def", "decode_chain_list", "(", "in_bytes", ")", ":", "bstrings", "=", "numpy", ".", "frombuffer", "(", "in_bytes", ",", "numpy", ".", "dtype", "(", "'S'", "+", "str", "(", "mmtf", ".", "utils", ".", "constants", ".", "CHAIN_LEN", ")", ")", ")", "retu...
Convert a list of bytes to a list of strings. Each string is of length mmtf.CHAIN_LEN :param in_bytes: the input bytes :return the decoded list of strings
[ "Convert", "a", "list", "of", "bytes", "to", "a", "list", "of", "strings", ".", "Each", "string", "is", "of", "length", "mmtf", ".", "CHAIN_LEN" ]
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/converters/numpy_converters.py#L17-L23
train
Convert a list of bytes to a list of strings. Each string is of length mmtf. CHAIN_LEN .
rcsb/mmtf-python
mmtf/converters/numpy_converters.py
recursive_index_decode
def recursive_index_decode(int_array, max=32767, min=-32768): """Unpack an array of integers using recursive indexing. :param int_array: the input array of integers :param max: the maximum integer size :param min: the minimum integer size :return the array of integers after recursive index decoding...
python
def recursive_index_decode(int_array, max=32767, min=-32768): """Unpack an array of integers using recursive indexing. :param int_array: the input array of integers :param max: the maximum integer size :param min: the minimum integer size :return the array of integers after recursive index decoding...
[ "def", "recursive_index_decode", "(", "int_array", ",", "max", "=", "32767", ",", "min", "=", "-", "32768", ")", ":", "out_arr", "=", "[", "]", "decoded_val", "=", "0", "for", "item", "in", "int_array", ".", "tolist", "(", ")", ":", "if", "item", "==...
Unpack an array of integers using recursive indexing. :param int_array: the input array of integers :param max: the maximum integer size :param min: the minimum integer size :return the array of integers after recursive index decoding
[ "Unpack", "an", "array", "of", "integers", "using", "recursive", "indexing", "." ]
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/converters/numpy_converters.py#L32-L48
train
Unpack an array of integers using recursive indexing.
rcsb/mmtf-python
mmtf/api/mmtf_reader.py
MMTFDecoder.get_coords
def get_coords(self): """Utility function to get the coordinates as a single list of tuples.""" out_list = [] for i in range(len(self.x_coord_list)): out_list.append((self.x_coord_list[i],self.y_coord_list[i],self.z_coord_list[i],)) return out_list
python
def get_coords(self): """Utility function to get the coordinates as a single list of tuples.""" out_list = [] for i in range(len(self.x_coord_list)): out_list.append((self.x_coord_list[i],self.y_coord_list[i],self.z_coord_list[i],)) return out_list
[ "def", "get_coords", "(", "self", ")", ":", "out_list", "=", "[", "]", "for", "i", "in", "range", "(", "len", "(", "self", ".", "x_coord_list", ")", ")", ":", "out_list", ".", "append", "(", "(", "self", ".", "x_coord_list", "[", "i", "]", ",", "...
Utility function to get the coordinates as a single list of tuples.
[ "Utility", "function", "to", "get", "the", "coordinates", "as", "a", "single", "list", "of", "tuples", "." ]
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/mmtf_reader.py#L14-L19
train
Utility function to get the coordinates as a single list of tuples.
rcsb/mmtf-python
mmtf/api/mmtf_reader.py
MMTFDecoder.decode_data
def decode_data(self, input_data): """Function to decode the input data and place it onto the class. :param input_data: the input data as a dict""" self.group_type_list = decode_array(input_data["groupTypeList"]) self.x_coord_list = decode_array(input_data["xCoordList"]) self.y_c...
python
def decode_data(self, input_data): """Function to decode the input data and place it onto the class. :param input_data: the input data as a dict""" self.group_type_list = decode_array(input_data["groupTypeList"]) self.x_coord_list = decode_array(input_data["xCoordList"]) self.y_c...
[ "def", "decode_data", "(", "self", ",", "input_data", ")", ":", "self", ".", "group_type_list", "=", "decode_array", "(", "input_data", "[", "\"groupTypeList\"", "]", ")", "self", ".", "x_coord_list", "=", "decode_array", "(", "input_data", "[", "\"xCoordList\""...
Function to decode the input data and place it onto the class. :param input_data: the input data as a dict
[ "Function", "to", "decode", "the", "input", "data", "and", "place", "it", "onto", "the", "class", ".", ":", "param", "input_data", ":", "the", "input", "data", "as", "a", "dict" ]
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/mmtf_reader.py#L25-L151
train
Function to decode the input data and place it onto the class.
rcsb/mmtf-python
mmtf/api/mmtf_reader.py
MMTFDecoder.pass_data_on
def pass_data_on(self, data_setters): """Write the data from the getters to the setters. :param data_setters: a series of functions that can fill a chemical data structure :type data_setters: DataTransferInterface """ data_setters.init_structure(self.num_bonds, len(self....
python
def pass_data_on(self, data_setters): """Write the data from the getters to the setters. :param data_setters: a series of functions that can fill a chemical data structure :type data_setters: DataTransferInterface """ data_setters.init_structure(self.num_bonds, len(self....
[ "def", "pass_data_on", "(", "self", ",", "data_setters", ")", ":", "data_setters", ".", "init_structure", "(", "self", ".", "num_bonds", ",", "len", "(", "self", ".", "x_coord_list", ")", ",", "len", "(", "self", ".", "group_type_list", ")", ",", "len", ...
Write the data from the getters to the setters. :param data_setters: a series of functions that can fill a chemical data structure :type data_setters: DataTransferInterface
[ "Write", "the", "data", "from", "the", "getters", "to", "the", "setters", "." ]
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/mmtf_reader.py#L154-L169
train
Write the data from the getters to the setters.
rcsb/mmtf-python
mmtf/api/default_api.py
_internet_on
def _internet_on(address): """ Check to see if the internet is on by pinging a set address. :param address: the IP or address to hit :return: a boolean - true if can be reached, false if not. """ try: urllib2.urlopen(address, timeout=1) return True except urllib2.URLError as ...
python
def _internet_on(address): """ Check to see if the internet is on by pinging a set address. :param address: the IP or address to hit :return: a boolean - true if can be reached, false if not. """ try: urllib2.urlopen(address, timeout=1) return True except urllib2.URLError as ...
[ "def", "_internet_on", "(", "address", ")", ":", "try", ":", "urllib2", ".", "urlopen", "(", "address", ",", "timeout", "=", "1", ")", "return", "True", "except", "urllib2", ".", "URLError", "as", "err", ":", "return", "False" ]
Check to see if the internet is on by pinging a set address. :param address: the IP or address to hit :return: a boolean - true if can be reached, false if not.
[ "Check", "to", "see", "if", "the", "internet", "is", "on", "by", "pinging", "a", "set", "address", ".", ":", "param", "address", ":", "the", "IP", "or", "address", "to", "hit", ":", "return", ":", "a", "boolean", "-", "true", "if", "can", "be", "re...
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/default_api.py#L15-L25
train
Checks to see if the internet is on by pinging the given IP or address.
rcsb/mmtf-python
mmtf/api/default_api.py
write_mmtf
def write_mmtf(file_path, input_data, input_function): """API function to write data as MMTF to a file :param file_path the path of the file to write :param input_data the input data in any user format :param input_function a function to converte input_data to an output format. Must contain all methods...
python
def write_mmtf(file_path, input_data, input_function): """API function to write data as MMTF to a file :param file_path the path of the file to write :param input_data the input data in any user format :param input_function a function to converte input_data to an output format. Must contain all methods...
[ "def", "write_mmtf", "(", "file_path", ",", "input_data", ",", "input_function", ")", ":", "mmtf_encoder", "=", "MMTFEncoder", "(", ")", "pass_data_on", "(", "input_data", ",", "input_function", ",", "mmtf_encoder", ")", "mmtf_encoder", ".", "write_file", "(", "...
API function to write data as MMTF to a file :param file_path the path of the file to write :param input_data the input data in any user format :param input_function a function to converte input_data to an output format. Must contain all methods in TemplateEncoder
[ "API", "function", "to", "write", "data", "as", "MMTF", "to", "a", "file" ]
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/default_api.py#L27-L36
train
API function to write data as MMTF to a file
rcsb/mmtf-python
mmtf/api/default_api.py
get_raw_data_from_url
def get_raw_data_from_url(pdb_id, reduced=False): """" Get the msgpack unpacked data given a PDB id. :param pdb_id: the input PDB id :return the unpacked data (a dict) """ url = get_url(pdb_id,reduced) request = urllib2.Request(url) request.add_header('Accept-encoding', 'gzip') response = u...
python
def get_raw_data_from_url(pdb_id, reduced=False): """" Get the msgpack unpacked data given a PDB id. :param pdb_id: the input PDB id :return the unpacked data (a dict) """ url = get_url(pdb_id,reduced) request = urllib2.Request(url) request.add_header('Accept-encoding', 'gzip') response = u...
[ "def", "get_raw_data_from_url", "(", "pdb_id", ",", "reduced", "=", "False", ")", ":", "url", "=", "get_url", "(", "pdb_id", ",", "reduced", ")", "request", "=", "urllib2", ".", "Request", "(", "url", ")", "request", ".", "add_header", "(", "'Accept-encodi...
Get the msgpack unpacked data given a PDB id. :param pdb_id: the input PDB id :return the unpacked data (a dict)
[ "Get", "the", "msgpack", "unpacked", "data", "given", "a", "PDB", "id", "." ]
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/default_api.py#L48-L61
train
Get the msgpack unpacked data given a PDB id.
rcsb/mmtf-python
mmtf/api/default_api.py
parse
def parse(file_path): """Return a decoded API to the data from a file path. :param file_path: the input file path. Data is not entropy compressed (e.g. gzip) :return an API to decoded data """ newDecoder = MMTFDecoder() with open(file_path, "rb") as fh: newDecoder.decode_data(_unpack(fh)) ...
python
def parse(file_path): """Return a decoded API to the data from a file path. :param file_path: the input file path. Data is not entropy compressed (e.g. gzip) :return an API to decoded data """ newDecoder = MMTFDecoder() with open(file_path, "rb") as fh: newDecoder.decode_data(_unpack(fh)) ...
[ "def", "parse", "(", "file_path", ")", ":", "newDecoder", "=", "MMTFDecoder", "(", ")", "with", "open", "(", "file_path", ",", "\"rb\"", ")", "as", "fh", ":", "newDecoder", ".", "decode_data", "(", "_unpack", "(", "fh", ")", ")", "return", "newDecoder" ]
Return a decoded API to the data from a file path. :param file_path: the input file path. Data is not entropy compressed (e.g. gzip) :return an API to decoded data
[ "Return", "a", "decoded", "API", "to", "the", "data", "from", "a", "file", "path", "." ]
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/default_api.py#L87-L95
train
Return a decoded API to the data from a file path.
rcsb/mmtf-python
mmtf/api/default_api.py
parse_gzip
def parse_gzip(file_path): """Return a decoded API to the data from a file path. File is gzip compressed. :param file_path: the input file path. Data is gzip compressed. :return an API to decoded data""" newDecoder = MMTFDecoder() newDecoder.decode_data(_unpack(gzip.open(file_path, "rb"))) retur...
python
def parse_gzip(file_path): """Return a decoded API to the data from a file path. File is gzip compressed. :param file_path: the input file path. Data is gzip compressed. :return an API to decoded data""" newDecoder = MMTFDecoder() newDecoder.decode_data(_unpack(gzip.open(file_path, "rb"))) retur...
[ "def", "parse_gzip", "(", "file_path", ")", ":", "newDecoder", "=", "MMTFDecoder", "(", ")", "newDecoder", ".", "decode_data", "(", "_unpack", "(", "gzip", ".", "open", "(", "file_path", ",", "\"rb\"", ")", ")", ")", "return", "newDecoder" ]
Return a decoded API to the data from a file path. File is gzip compressed. :param file_path: the input file path. Data is gzip compressed. :return an API to decoded data
[ "Return", "a", "decoded", "API", "to", "the", "data", "from", "a", "file", "path", ".", "File", "is", "gzip", "compressed", ".", ":", "param", "file_path", ":", "the", "input", "file", "path", ".", "Data", "is", "gzip", "compressed", ".", ":", "return"...
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/default_api.py#L98-L104
train
Return a decoded API to the data from a gzip compressed file.
rcsb/mmtf-python
mmtf/api/default_api.py
ungzip_data
def ungzip_data(input_data): """Return a string of data after gzip decoding :param the input gziped data :return the gzip decoded data""" buf = StringIO(input_data) f = gzip.GzipFile(fileobj=buf) return f
python
def ungzip_data(input_data): """Return a string of data after gzip decoding :param the input gziped data :return the gzip decoded data""" buf = StringIO(input_data) f = gzip.GzipFile(fileobj=buf) return f
[ "def", "ungzip_data", "(", "input_data", ")", ":", "buf", "=", "StringIO", "(", "input_data", ")", "f", "=", "gzip", ".", "GzipFile", "(", "fileobj", "=", "buf", ")", "return", "f" ]
Return a string of data after gzip decoding :param the input gziped data :return the gzip decoded data
[ "Return", "a", "string", "of", "data", "after", "gzip", "decoding" ]
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/default_api.py#L107-L114
train
Returns a string of data after gzip decoding
rcsb/mmtf-python
mmtf/utils/codec_utils.py
parse_header
def parse_header(input_array): """Parse the header and return it along with the input array minus the header. :param input_array the array to parse :return the codec, the length of the decoded array, the parameter and the remainder of the array""" codec = struct.unpack(mmtf.utils.constants.NUM_DICT[...
python
def parse_header(input_array): """Parse the header and return it along with the input array minus the header. :param input_array the array to parse :return the codec, the length of the decoded array, the parameter and the remainder of the array""" codec = struct.unpack(mmtf.utils.constants.NUM_DICT[...
[ "def", "parse_header", "(", "input_array", ")", ":", "codec", "=", "struct", ".", "unpack", "(", "mmtf", ".", "utils", ".", "constants", ".", "NUM_DICT", "[", "4", "]", ",", "input_array", "[", "0", ":", "4", "]", ")", "[", "0", "]", "length", "=",...
Parse the header and return it along with the input array minus the header. :param input_array the array to parse :return the codec, the length of the decoded array, the parameter and the remainder of the array
[ "Parse", "the", "header", "and", "return", "it", "along", "with", "the", "input", "array", "minus", "the", "header", ".", ":", "param", "input_array", "the", "array", "to", "parse", ":", "return", "the", "codec", "the", "length", "of", "the", "decoded", ...
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/utils/codec_utils.py#L7-L15
train
Parse the header and return it along with the input array minus the header.
rcsb/mmtf-python
mmtf/utils/codec_utils.py
add_header
def add_header(input_array, codec, length, param): """Add the header to the appropriate array. :param the encoded array to add the header to :param the codec being used :param the length of the decoded array :param the parameter to add to the header :return the prepended encoded byte array""" ...
python
def add_header(input_array, codec, length, param): """Add the header to the appropriate array. :param the encoded array to add the header to :param the codec being used :param the length of the decoded array :param the parameter to add to the header :return the prepended encoded byte array""" ...
[ "def", "add_header", "(", "input_array", ",", "codec", ",", "length", ",", "param", ")", ":", "return", "struct", ".", "pack", "(", "mmtf", ".", "utils", ".", "constants", ".", "NUM_DICT", "[", "4", "]", ",", "codec", ")", "+", "struct", ".", "pack",...
Add the header to the appropriate array. :param the encoded array to add the header to :param the codec being used :param the length of the decoded array :param the parameter to add to the header :return the prepended encoded byte array
[ "Add", "the", "header", "to", "the", "appropriate", "array", ".", ":", "param", "the", "encoded", "array", "to", "add", "the", "header", "to", ":", "param", "the", "codec", "being", "used", ":", "param", "the", "length", "of", "the", "decoded", "array", ...
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/utils/codec_utils.py#L18-L27
train
Add the header to the appropriate array.
rcsb/mmtf-python
mmtf/converters/converters.py
convert_bytes_to_ints
def convert_bytes_to_ints(in_bytes, num): """Convert a byte array into an integer array. The number of bytes forming an integer is defined by num :param in_bytes: the input bytes :param num: the number of bytes per int :return the integer array""" out_arr = [] for i in range(len(in_bytes)//n...
python
def convert_bytes_to_ints(in_bytes, num): """Convert a byte array into an integer array. The number of bytes forming an integer is defined by num :param in_bytes: the input bytes :param num: the number of bytes per int :return the integer array""" out_arr = [] for i in range(len(in_bytes)//n...
[ "def", "convert_bytes_to_ints", "(", "in_bytes", ",", "num", ")", ":", "out_arr", "=", "[", "]", "for", "i", "in", "range", "(", "len", "(", "in_bytes", ")", "//", "num", ")", ":", "val", "=", "in_bytes", "[", "i", "*", "num", ":", "i", "*", "num...
Convert a byte array into an integer array. The number of bytes forming an integer is defined by num :param in_bytes: the input bytes :param num: the number of bytes per int :return the integer array
[ "Convert", "a", "byte", "array", "into", "an", "integer", "array", ".", "The", "number", "of", "bytes", "forming", "an", "integer", "is", "defined", "by", "num", ":", "param", "in_bytes", ":", "the", "input", "bytes", ":", "param", "num", ":", "the", "...
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/converters/converters.py#L9-L20
train
Convert a byte array into an integer array.
rcsb/mmtf-python
mmtf/converters/converters.py
convert_ints_to_bytes
def convert_ints_to_bytes(in_ints, num): """Convert an integer array into a byte arrays. The number of bytes forming an integer is defined by num :param in_ints: the input integers :param num: the number of bytes per int :return the integer array""" out_bytes= b"" for val in in_ints: ...
python
def convert_ints_to_bytes(in_ints, num): """Convert an integer array into a byte arrays. The number of bytes forming an integer is defined by num :param in_ints: the input integers :param num: the number of bytes per int :return the integer array""" out_bytes= b"" for val in in_ints: ...
[ "def", "convert_ints_to_bytes", "(", "in_ints", ",", "num", ")", ":", "out_bytes", "=", "b\"\"", "for", "val", "in", "in_ints", ":", "out_bytes", "+=", "struct", ".", "pack", "(", "mmtf", ".", "utils", ".", "constants", ".", "NUM_DICT", "[", "num", "]", ...
Convert an integer array into a byte arrays. The number of bytes forming an integer is defined by num :param in_ints: the input integers :param num: the number of bytes per int :return the integer array
[ "Convert", "an", "integer", "array", "into", "a", "byte", "arrays", ".", "The", "number", "of", "bytes", "forming", "an", "integer", "is", "defined", "by", "num" ]
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/converters/converters.py#L22-L32
train
Convert an integer array into a byte array.
rcsb/mmtf-python
mmtf/converters/converters.py
decode_chain_list
def decode_chain_list(in_bytes): """Convert a list of bytes to a list of strings. Each string is of length mmtf.CHAIN_LEN :param in_bytes: the input bytes :return the decoded list of strings""" tot_strings = len(in_bytes) // mmtf.utils.constants.CHAIN_LEN out_strings = [] for i in range(tot_str...
python
def decode_chain_list(in_bytes): """Convert a list of bytes to a list of strings. Each string is of length mmtf.CHAIN_LEN :param in_bytes: the input bytes :return the decoded list of strings""" tot_strings = len(in_bytes) // mmtf.utils.constants.CHAIN_LEN out_strings = [] for i in range(tot_str...
[ "def", "decode_chain_list", "(", "in_bytes", ")", ":", "tot_strings", "=", "len", "(", "in_bytes", ")", "//", "mmtf", ".", "utils", ".", "constants", ".", "CHAIN_LEN", "out_strings", "=", "[", "]", "for", "i", "in", "range", "(", "tot_strings", ")", ":",...
Convert a list of bytes to a list of strings. Each string is of length mmtf.CHAIN_LEN :param in_bytes: the input bytes :return the decoded list of strings
[ "Convert", "a", "list", "of", "bytes", "to", "a", "list", "of", "strings", ".", "Each", "string", "is", "of", "length", "mmtf", ".", "CHAIN_LEN" ]
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/converters/converters.py#L34-L44
train
Convert a list of bytes to a list of strings. Each string is of length mmtf. CHAIN_LEN .
rcsb/mmtf-python
mmtf/converters/converters.py
encode_chain_list
def encode_chain_list(in_strings): """Convert a list of strings to a list of byte arrays. :param in_strings: the input strings :return the encoded list of byte arrays""" out_bytes = b"" for in_s in in_strings: out_bytes+=in_s.encode('ascii') for i in range(mmtf.utils.constants.CHAIN...
python
def encode_chain_list(in_strings): """Convert a list of strings to a list of byte arrays. :param in_strings: the input strings :return the encoded list of byte arrays""" out_bytes = b"" for in_s in in_strings: out_bytes+=in_s.encode('ascii') for i in range(mmtf.utils.constants.CHAIN...
[ "def", "encode_chain_list", "(", "in_strings", ")", ":", "out_bytes", "=", "b\"\"", "for", "in_s", "in", "in_strings", ":", "out_bytes", "+=", "in_s", ".", "encode", "(", "'ascii'", ")", "for", "i", "in", "range", "(", "mmtf", ".", "utils", ".", "constan...
Convert a list of strings to a list of byte arrays. :param in_strings: the input strings :return the encoded list of byte arrays
[ "Convert", "a", "list", "of", "strings", "to", "a", "list", "of", "byte", "arrays", "." ]
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/converters/converters.py#L47-L57
train
Convert a list of strings to a list of byte arrays.
rcsb/mmtf-python
mmtf/converters/converters.py
recursive_index_encode
def recursive_index_encode(int_array, max=32767, min=-32768): """Pack an integer array using recursive indexing. :param int_array: the input array of integers :param max: the maximum integer size :param min: the minimum integer size :return the array of integers after recursive index encoding""" ...
python
def recursive_index_encode(int_array, max=32767, min=-32768): """Pack an integer array using recursive indexing. :param int_array: the input array of integers :param max: the maximum integer size :param min: the minimum integer size :return the array of integers after recursive index encoding""" ...
[ "def", "recursive_index_encode", "(", "int_array", ",", "max", "=", "32767", ",", "min", "=", "-", "32768", ")", ":", "out_arr", "=", "[", "]", "for", "curr", "in", "int_array", ":", "if", "curr", ">=", "0", ":", "while", "curr", ">=", "max", ":", ...
Pack an integer array using recursive indexing. :param int_array: the input array of integers :param max: the maximum integer size :param min: the minimum integer size :return the array of integers after recursive index encoding
[ "Pack", "an", "integer", "array", "using", "recursive", "indexing", "." ]
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/converters/converters.py#L90-L108
train
Pack an integer array using recursive indexing.
rcsb/mmtf-python
mmtf/converters/converters.py
recursive_index_decode
def recursive_index_decode(int_array, max=32767, min=-32768): """Unpack an array of integers using recursive indexing. :param int_array: the input array of integers :param max: the maximum integer size :param min: the minimum integer size :return the array of integers after recursive index decoding"...
python
def recursive_index_decode(int_array, max=32767, min=-32768): """Unpack an array of integers using recursive indexing. :param int_array: the input array of integers :param max: the maximum integer size :param min: the minimum integer size :return the array of integers after recursive index decoding"...
[ "def", "recursive_index_decode", "(", "int_array", ",", "max", "=", "32767", ",", "min", "=", "-", "32768", ")", ":", "out_arr", "=", "[", "]", "encoded_ind", "=", "0", "while", "encoded_ind", "<", "len", "(", "int_array", ")", ":", "decoded_val", "=", ...
Unpack an array of integers using recursive indexing. :param int_array: the input array of integers :param max: the maximum integer size :param min: the minimum integer size :return the array of integers after recursive index decoding
[ "Unpack", "an", "array", "of", "integers", "using", "recursive", "indexing", ".", ":", "param", "int_array", ":", "the", "input", "array", "of", "integers", ":", "param", "max", ":", "the", "maximum", "integer", "size", ":", "param", "min", ":", "the", "...
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/converters/converters.py#L110-L128
train
Unpack an array of integers using recursive indexing.
rcsb/mmtf-python
mmtf/codecs/decoders/numpy_decoders.py
run_length_decode
def run_length_decode(in_array): """A function to run length decode an int array. :param in_array: the input array of integers :return the decoded array""" switch=False out_array=[] in_array = in_array.tolist() for item in in_array: if switch==False: this_item = item ...
python
def run_length_decode(in_array): """A function to run length decode an int array. :param in_array: the input array of integers :return the decoded array""" switch=False out_array=[] in_array = in_array.tolist() for item in in_array: if switch==False: this_item = item ...
[ "def", "run_length_decode", "(", "in_array", ")", ":", "switch", "=", "False", "out_array", "=", "[", "]", "in_array", "=", "in_array", ".", "tolist", "(", ")", "for", "item", "in", "in_array", ":", "if", "switch", "==", "False", ":", "this_item", "=", ...
A function to run length decode an int array. :param in_array: the input array of integers :return the decoded array
[ "A", "function", "to", "run", "length", "decode", "an", "int", "array", "." ]
899bb877ca1b32a9396803d38c5bf38a2520754e
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/codecs/decoders/numpy_decoders.py#L11-L26
train
A function to run length decode an int array.
lmjohns3/downhill
examples/rosenbrock.py
build
def build(algo, init): '''Build and return an optimizer for the rosenbrock function. In downhill, an optimizer can be constructed using the build() top-level function. This function requires several Theano quantities such as the loss being optimized and the parameters to update during optimization. ...
python
def build(algo, init): '''Build and return an optimizer for the rosenbrock function. In downhill, an optimizer can be constructed using the build() top-level function. This function requires several Theano quantities such as the loss being optimized and the parameters to update during optimization. ...
[ "def", "build", "(", "algo", ",", "init", ")", ":", "x", "=", "theano", ".", "shared", "(", "np", ".", "array", "(", "init", ",", "FLOAT", ")", ",", "name", "=", "'x'", ")", "n", "=", "0.1", "*", "RandomStreams", "(", ")", ".", "normal", "(", ...
Build and return an optimizer for the rosenbrock function. In downhill, an optimizer can be constructed using the build() top-level function. This function requires several Theano quantities such as the loss being optimized and the parameters to update during optimization.
[ "Build", "and", "return", "an", "optimizer", "for", "the", "rosenbrock", "function", "." ]
42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d
https://github.com/lmjohns3/downhill/blob/42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d/examples/rosenbrock.py#L15-L33
train
Build and return an optimizer for the rosenbrock function.
lmjohns3/downhill
examples/rosenbrock.py
build_and_trace
def build_and_trace(algo, init, limit=100, **kwargs): '''Run an optimizer on the rosenbrock function. Return xs, ys, and losses. In downhill, optimization algorithms can be iterated over to progressively minimize the loss. At each iteration, the optimizer yields a dictionary of monitor values that were...
python
def build_and_trace(algo, init, limit=100, **kwargs): '''Run an optimizer on the rosenbrock function. Return xs, ys, and losses. In downhill, optimization algorithms can be iterated over to progressively minimize the loss. At each iteration, the optimizer yields a dictionary of monitor values that were...
[ "def", "build_and_trace", "(", "algo", ",", "init", ",", "limit", "=", "100", ",", "*", "*", "kwargs", ")", ":", "kw", "=", "dict", "(", "min_improvement", "=", "0", ",", "patience", "=", "0", ",", "max_gradient_norm", "=", "100", ")", "kw", ".", "...
Run an optimizer on the rosenbrock function. Return xs, ys, and losses. In downhill, optimization algorithms can be iterated over to progressively minimize the loss. At each iteration, the optimizer yields a dictionary of monitor values that were computed during that iteration. Here we build an optimiz...
[ "Run", "an", "optimizer", "on", "the", "rosenbrock", "function", ".", "Return", "xs", "ys", "and", "losses", "." ]
42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d
https://github.com/lmjohns3/downhill/blob/42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d/examples/rosenbrock.py#L36-L55
train
Run an optimizer on the rosenbrock function. Return xs ys and losses.
lmjohns3/downhill
downhill/__init__.py
minimize
def minimize(loss, train, valid=None, params=None, inputs=None, algo='rmsprop', updates=(), monitors=(), monitor_gradients=False, batch_size=32, train_batches=None, valid_batches=None, **kwargs): '''Minimize a loss function with respect to some symbolic parameters. Additional keyword ...
python
def minimize(loss, train, valid=None, params=None, inputs=None, algo='rmsprop', updates=(), monitors=(), monitor_gradients=False, batch_size=32, train_batches=None, valid_batches=None, **kwargs): '''Minimize a loss function with respect to some symbolic parameters. Additional keyword ...
[ "def", "minimize", "(", "loss", ",", "train", ",", "valid", "=", "None", ",", "params", "=", "None", ",", "inputs", "=", "None", ",", "algo", "=", "'rmsprop'", ",", "updates", "=", "(", ")", ",", "monitors", "=", "(", ")", ",", "monitor_gradients", ...
Minimize a loss function with respect to some symbolic parameters. Additional keyword arguments are passed to the underlying :class:`Optimizer <downhill.base.Optimizer>` instance. Parameters ---------- loss : Theano expression Loss function to minimize. This must be a scalar-valued express...
[ "Minimize", "a", "loss", "function", "with", "respect", "to", "some", "symbolic", "parameters", "." ]
42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d
https://github.com/lmjohns3/downhill/blob/42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d/downhill/__init__.py#L9-L91
train
Minimize a loss function with respect to some symbolic parameters.
lmjohns3/downhill
examples/rosenbrock-2d.py
make_label
def make_label(loss, key): '''Create a legend label for an optimization run.''' algo, rate, mu, half, reg = key slots, args = ['{:.3f}', '{}', 'm={:.3f}'], [loss, algo, mu] if algo in 'SGD NAG RMSProp Adam ESGD'.split(): slots.append('lr={:.2e}') args.append(rate) if algo in 'RMSProp...
python
def make_label(loss, key): '''Create a legend label for an optimization run.''' algo, rate, mu, half, reg = key slots, args = ['{:.3f}', '{}', 'm={:.3f}'], [loss, algo, mu] if algo in 'SGD NAG RMSProp Adam ESGD'.split(): slots.append('lr={:.2e}') args.append(rate) if algo in 'RMSProp...
[ "def", "make_label", "(", "loss", ",", "key", ")", ":", "algo", ",", "rate", ",", "mu", ",", "half", ",", "reg", "=", "key", "slots", ",", "args", "=", "[", "'{:.3f}'", ",", "'{}'", ",", "'m={:.3f}'", "]", ",", "[", "loss", ",", "algo", ",", "m...
Create a legend label for an optimization run.
[ "Create", "a", "legend", "label", "for", "an", "optimization", "run", "." ]
42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d
https://github.com/lmjohns3/downhill/blob/42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d/examples/rosenbrock-2d.py#L25-L37
train
Create a legend label for an optimization run.
lmjohns3/downhill
downhill/dataset.py
Dataset.iterate
def iterate(self, shuffle=True): '''Iterate over batches in the dataset. This method generates ``iteration_size`` batches from the dataset and then returns. Parameters ---------- shuffle : bool, optional Shuffle the batches in this dataset if the iteration r...
python
def iterate(self, shuffle=True): '''Iterate over batches in the dataset. This method generates ``iteration_size`` batches from the dataset and then returns. Parameters ---------- shuffle : bool, optional Shuffle the batches in this dataset if the iteration r...
[ "def", "iterate", "(", "self", ",", "shuffle", "=", "True", ")", ":", "for", "_", "in", "range", "(", "self", ".", "iteration_size", ")", ":", "if", "self", ".", "_callable", "is", "not", "None", ":", "yield", "self", ".", "_callable", "(", ")", "e...
Iterate over batches in the dataset. This method generates ``iteration_size`` batches from the dataset and then returns. Parameters ---------- shuffle : bool, optional Shuffle the batches in this dataset if the iteration reaches the end of the batch list...
[ "Iterate", "over", "batches", "in", "the", "dataset", "." ]
42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d
https://github.com/lmjohns3/downhill/blob/42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d/downhill/dataset.py#L183-L205
train
Iterate over batches in the dataset and return them as a generator.
lmjohns3/downhill
downhill/util.py
shared_like
def shared_like(param, suffix, init=0): '''Create a Theano shared variable like an existing parameter. Parameters ---------- param : Theano variable Theano variable to use for shape information. suffix : str Suffix to append to the parameter's name for the new variable. init : f...
python
def shared_like(param, suffix, init=0): '''Create a Theano shared variable like an existing parameter. Parameters ---------- param : Theano variable Theano variable to use for shape information. suffix : str Suffix to append to the parameter's name for the new variable. init : f...
[ "def", "shared_like", "(", "param", ",", "suffix", ",", "init", "=", "0", ")", ":", "return", "theano", ".", "shared", "(", "np", ".", "zeros_like", "(", "param", ".", "get_value", "(", ")", ")", "+", "init", ",", "name", "=", "'{}_{}'", ".", "form...
Create a Theano shared variable like an existing parameter. Parameters ---------- param : Theano variable Theano variable to use for shape information. suffix : str Suffix to append to the parameter's name for the new variable. init : float or ndarray, optional Initial value...
[ "Create", "a", "Theano", "shared", "variable", "like", "an", "existing", "parameter", "." ]
42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d
https://github.com/lmjohns3/downhill/blob/42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d/downhill/util.py#L30-L49
train
Create a Theano shared variable like an existing parameter.
lmjohns3/downhill
downhill/util.py
find_inputs_and_params
def find_inputs_and_params(node): '''Walk a computation graph and extract root variables. Parameters ---------- node : Theano expression A symbolic Theano expression to walk. Returns ------- inputs : list Theano variables A list of candidate inputs for this graph. Inputs ar...
python
def find_inputs_and_params(node): '''Walk a computation graph and extract root variables. Parameters ---------- node : Theano expression A symbolic Theano expression to walk. Returns ------- inputs : list Theano variables A list of candidate inputs for this graph. Inputs ar...
[ "def", "find_inputs_and_params", "(", "node", ")", ":", "queue", ",", "seen", ",", "inputs", ",", "params", "=", "[", "node", "]", ",", "set", "(", ")", ",", "set", "(", ")", ",", "set", "(", ")", "while", "queue", ":", "node", "=", "queue", ".",...
Walk a computation graph and extract root variables. Parameters ---------- node : Theano expression A symbolic Theano expression to walk. Returns ------- inputs : list Theano variables A list of candidate inputs for this graph. Inputs are nodes in the graph with no pare...
[ "Walk", "a", "computation", "graph", "and", "extract", "root", "variables", "." ]
42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d
https://github.com/lmjohns3/downhill/blob/42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d/downhill/util.py#L68-L95
train
Walk a computation graph and extract root variables.
lmjohns3/downhill
downhill/util.py
log
def log(msg, *args, **kwargs): '''Log a message to the console. Parameters ---------- msg : str A string to display on the console. This can contain {}-style formatting commands; the remaining positional and keyword arguments will be used to fill them in. ''' now = datet...
python
def log(msg, *args, **kwargs): '''Log a message to the console. Parameters ---------- msg : str A string to display on the console. This can contain {}-style formatting commands; the remaining positional and keyword arguments will be used to fill them in. ''' now = datet...
[ "def", "log", "(", "msg", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "now", "=", "datetime", ".", "datetime", ".", "now", "(", ")", "module", "=", "'downhill'", "if", "_detailed_callsite", ":", "caller", "=", "inspect", ".", "stack", "(", ...
Log a message to the console. Parameters ---------- msg : str A string to display on the console. This can contain {}-style formatting commands; the remaining positional and keyword arguments will be used to fill them in.
[ "Log", "a", "message", "to", "the", "console", "." ]
42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d
https://github.com/lmjohns3/downhill/blob/42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d/downhill/util.py#L107-L129
train
Log a message to the console.
lmjohns3/downhill
downhill/util.py
log_param
def log_param(name, value): '''Log a parameter value to the console. Parameters ---------- name : str Name of the parameter being logged. value : any Value of the parameter being logged. ''' log('setting {} = {}', click.style(str(name)), click.style(str(value), fg='y...
python
def log_param(name, value): '''Log a parameter value to the console. Parameters ---------- name : str Name of the parameter being logged. value : any Value of the parameter being logged. ''' log('setting {} = {}', click.style(str(name)), click.style(str(value), fg='y...
[ "def", "log_param", "(", "name", ",", "value", ")", ":", "log", "(", "'setting {} = {}'", ",", "click", ".", "style", "(", "str", "(", "name", ")", ")", ",", "click", ".", "style", "(", "str", "(", "value", ")", ",", "fg", "=", "'yellow'", ")", "...
Log a parameter value to the console. Parameters ---------- name : str Name of the parameter being logged. value : any Value of the parameter being logged.
[ "Log", "a", "parameter", "value", "to", "the", "console", "." ]
42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d
https://github.com/lmjohns3/downhill/blob/42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d/downhill/util.py#L132-L143
train
Log a parameter value to the console.
lmjohns3/downhill
examples/mnist-sparse-factorization.py
load_mnist
def load_mnist(): '''Load the MNIST digits dataset.''' mnist = skdata.mnist.dataset.MNIST() mnist.meta # trigger download if needed. def arr(n, dtype): arr = mnist.arrays[n] return arr.reshape((len(arr), -1)).astype(dtype) train_images = arr('train_images', np.float32) / 128 - 1 ...
python
def load_mnist(): '''Load the MNIST digits dataset.''' mnist = skdata.mnist.dataset.MNIST() mnist.meta # trigger download if needed. def arr(n, dtype): arr = mnist.arrays[n] return arr.reshape((len(arr), -1)).astype(dtype) train_images = arr('train_images', np.float32) / 128 - 1 ...
[ "def", "load_mnist", "(", ")", ":", "mnist", "=", "skdata", ".", "mnist", ".", "dataset", ".", "MNIST", "(", ")", "mnist", ".", "meta", "# trigger download if needed.", "def", "arr", "(", "n", ",", "dtype", ")", ":", "arr", "=", "mnist", ".", "arrays",...
Load the MNIST digits dataset.
[ "Load", "the", "MNIST", "digits", "dataset", "." ]
42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d
https://github.com/lmjohns3/downhill/blob/42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d/examples/mnist-sparse-factorization.py#L11-L22
train
Load the MNIST digits dataset.
lmjohns3/downhill
downhill/base.py
build
def build(algo, loss, params=None, inputs=None, updates=(), monitors=(), monitor_gradients=False): '''Construct an optimizer by name. Parameters ---------- algo : str The name of the optimization algorithm to build. loss : Theano expression Loss function to minimize. This ...
python
def build(algo, loss, params=None, inputs=None, updates=(), monitors=(), monitor_gradients=False): '''Construct an optimizer by name. Parameters ---------- algo : str The name of the optimization algorithm to build. loss : Theano expression Loss function to minimize. This ...
[ "def", "build", "(", "algo", ",", "loss", ",", "params", "=", "None", ",", "inputs", "=", "None", ",", "updates", "=", "(", ")", ",", "monitors", "=", "(", ")", ",", "monitor_gradients", "=", "False", ")", ":", "return", "Optimizer", ".", "build", ...
Construct an optimizer by name. Parameters ---------- algo : str The name of the optimization algorithm to build. loss : Theano expression Loss function to minimize. This must be a scalar-valued expression. params : list of Theano variables, optional Symbolic variables to ad...
[ "Construct", "an", "optimizer", "by", "name", "." ]
42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d
https://github.com/lmjohns3/downhill/blob/42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d/downhill/base.py#L15-L50
train
Construct an optimizer by name.
lmjohns3/downhill
downhill/base.py
Optimizer._compile
def _compile(self, **kwargs): '''Compile the Theano functions for evaluating and updating our model. ''' util.log('compiling evaluation function') self.f_eval = theano.function(self._inputs, self._monitor_exprs, ...
python
def _compile(self, **kwargs): '''Compile the Theano functions for evaluating and updating our model. ''' util.log('compiling evaluation function') self.f_eval = theano.function(self._inputs, self._monitor_exprs, ...
[ "def", "_compile", "(", "self", ",", "*", "*", "kwargs", ")", ":", "util", ".", "log", "(", "'compiling evaluation function'", ")", "self", ".", "f_eval", "=", "theano", ".", "function", "(", "self", ".", "_inputs", ",", "self", ".", "_monitor_exprs", ",...
Compile the Theano functions for evaluating and updating our model.
[ "Compile", "the", "Theano", "functions", "for", "evaluating", "and", "updating", "our", "model", "." ]
42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d
https://github.com/lmjohns3/downhill/blob/42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d/downhill/base.py#L153-L167
train
Compile the Theano functions for evaluating and updating our model.
lmjohns3/downhill
downhill/base.py
Optimizer.get_updates
def get_updates(self, **kwargs): '''Get parameter update expressions for performing optimization. Keyword arguments can be applied here to set any of the global optimizer attributes. Yields ------ updates : (parameter, expression) tuples A sequence of parame...
python
def get_updates(self, **kwargs): '''Get parameter update expressions for performing optimization. Keyword arguments can be applied here to set any of the global optimizer attributes. Yields ------ updates : (parameter, expression) tuples A sequence of parame...
[ "def", "get_updates", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_prepare", "(", "*", "*", "kwargs", ")", "for", "param", ",", "grad", "in", "self", ".", "_differentiate", "(", ")", ":", "for", "var", ",", "update", "in", "self",...
Get parameter update expressions for performing optimization. Keyword arguments can be applied here to set any of the global optimizer attributes. Yields ------ updates : (parameter, expression) tuples A sequence of parameter updates to be applied during optimizatio...
[ "Get", "parameter", "update", "expressions", "for", "performing", "optimization", "." ]
42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d
https://github.com/lmjohns3/downhill/blob/42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d/downhill/base.py#L169-L202
train
Yields the set of parameter updates for performing optimization.
lmjohns3/downhill
downhill/base.py
Optimizer._differentiate
def _differentiate(self, params=None): '''Return a sequence of gradients for our parameters. If this optimizer has been configured with a gradient norm limit, or with elementwise gradient clipping, this method applies the appropriate rescaling and clipping operations before returning th...
python
def _differentiate(self, params=None): '''Return a sequence of gradients for our parameters. If this optimizer has been configured with a gradient norm limit, or with elementwise gradient clipping, this method applies the appropriate rescaling and clipping operations before returning th...
[ "def", "_differentiate", "(", "self", ",", "params", "=", "None", ")", ":", "if", "params", "is", "None", ":", "params", "=", "self", ".", "_params", "for", "param", ",", "grad", "in", "zip", "(", "params", ",", "TT", ".", "grad", "(", "self", ".",...
Return a sequence of gradients for our parameters. If this optimizer has been configured with a gradient norm limit, or with elementwise gradient clipping, this method applies the appropriate rescaling and clipping operations before returning the gradient. Parameters ----------...
[ "Return", "a", "sequence", "of", "gradients", "for", "our", "parameters", "." ]
42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d
https://github.com/lmjohns3/downhill/blob/42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d/downhill/base.py#L214-L244
train
Returns a sequence of gradients for our parameters.
lmjohns3/downhill
downhill/base.py
Optimizer.set_params
def set_params(self, targets=None): '''Set the values of the parameters to the given target values. Parameters ---------- targets : sequence of ndarray, optional Arrays for setting the parameters of our model. If this is not provided, the current best parameters ...
python
def set_params(self, targets=None): '''Set the values of the parameters to the given target values. Parameters ---------- targets : sequence of ndarray, optional Arrays for setting the parameters of our model. If this is not provided, the current best parameters ...
[ "def", "set_params", "(", "self", ",", "targets", "=", "None", ")", ":", "if", "not", "isinstance", "(", "targets", ",", "(", "list", ",", "tuple", ")", ")", ":", "targets", "=", "self", ".", "_best_params", "for", "param", ",", "target", "in", "zip"...
Set the values of the parameters to the given target values. Parameters ---------- targets : sequence of ndarray, optional Arrays for setting the parameters of our model. If this is not provided, the current best parameters for this optimizer will be used.
[ "Set", "the", "values", "of", "the", "parameters", "to", "the", "given", "target", "values", "." ]
42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d
https://github.com/lmjohns3/downhill/blob/42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d/downhill/base.py#L246-L259
train
Set the values of the parameters to the given target values.
lmjohns3/downhill
downhill/base.py
Optimizer._log
def _log(self, monitors, iteration, label='', suffix=''): '''Log the state of the optimizer on the console. Parameters ---------- monitors : OrderedDict A dictionary of monitor names mapped to values. These names and values are what is being logged. itera...
python
def _log(self, monitors, iteration, label='', suffix=''): '''Log the state of the optimizer on the console. Parameters ---------- monitors : OrderedDict A dictionary of monitor names mapped to values. These names and values are what is being logged. itera...
[ "def", "_log", "(", "self", ",", "monitors", ",", "iteration", ",", "label", "=", "''", ",", "suffix", "=", "''", ")", ":", "label", "=", "label", "or", "self", ".", "__class__", ".", "__name__", "fields", "=", "(", "(", "'{}={:.6f}'", ")", ".", "f...
Log the state of the optimizer on the console. Parameters ---------- monitors : OrderedDict A dictionary of monitor names mapped to values. These names and values are what is being logged. iteration : int Optimization iteration that we are logging. ...
[ "Log", "the", "state", "of", "the", "optimizer", "on", "the", "console", "." ]
42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d
https://github.com/lmjohns3/downhill/blob/42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d/downhill/base.py#L261-L279
train
Log the state of the optimizer on the console.
lmjohns3/downhill
downhill/base.py
Optimizer.evaluate
def evaluate(self, dataset): '''Evaluate the current model parameters on a dataset. Parameters ---------- dataset : :class:`Dataset <downhill.dataset.Dataset>` A set of data to use for evaluating the model. Returns ------- monitors : OrderedDict ...
python
def evaluate(self, dataset): '''Evaluate the current model parameters on a dataset. Parameters ---------- dataset : :class:`Dataset <downhill.dataset.Dataset>` A set of data to use for evaluating the model. Returns ------- monitors : OrderedDict ...
[ "def", "evaluate", "(", "self", ",", "dataset", ")", ":", "if", "dataset", "is", "None", ":", "values", "=", "[", "self", ".", "f_eval", "(", ")", "]", "else", ":", "values", "=", "[", "self", ".", "f_eval", "(", "*", "x", ")", "for", "x", "in"...
Evaluate the current model parameters on a dataset. Parameters ---------- dataset : :class:`Dataset <downhill.dataset.Dataset>` A set of data to use for evaluating the model. Returns ------- monitors : OrderedDict A dictionary mapping monitor nam...
[ "Evaluate", "the", "current", "model", "parameters", "on", "a", "dataset", "." ]
42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d
https://github.com/lmjohns3/downhill/blob/42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d/downhill/base.py#L281-L301
train
Evaluate the current model parameters on a dataset.
lmjohns3/downhill
downhill/base.py
Optimizer._prepare
def _prepare(self, **kwargs): '''Set up properties for optimization. This method can be overridden by base classes to provide parameters that are specific to a particular optimization technique (e.g., setting up a learning rate value). ''' self.learning_rate = util.as_fl...
python
def _prepare(self, **kwargs): '''Set up properties for optimization. This method can be overridden by base classes to provide parameters that are specific to a particular optimization technique (e.g., setting up a learning rate value). ''' self.learning_rate = util.as_fl...
[ "def", "_prepare", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "learning_rate", "=", "util", ".", "as_float", "(", "kwargs", ".", "pop", "(", "'learning_rate'", ",", "1e-4", ")", ")", "self", ".", "momentum", "=", "kwargs", ".", "pop...
Set up properties for optimization. This method can be overridden by base classes to provide parameters that are specific to a particular optimization technique (e.g., setting up a learning rate value).
[ "Set", "up", "properties", "for", "optimization", "." ]
42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d
https://github.com/lmjohns3/downhill/blob/42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d/downhill/base.py#L329-L352
train
Set up properties for optimization.
lmjohns3/downhill
downhill/base.py
Optimizer.iterate
def iterate(self, train=None, valid=None, max_updates=None, **kwargs): r'''Optimize a loss iteratively using a training and validation dataset. This method yields a series of monitor values to the caller. After every optimization epoch, a pair of monitor dictionaries is generated: one e...
python
def iterate(self, train=None, valid=None, max_updates=None, **kwargs): r'''Optimize a loss iteratively using a training and validation dataset. This method yields a series of monitor values to the caller. After every optimization epoch, a pair of monitor dictionaries is generated: one e...
[ "def", "iterate", "(", "self", ",", "train", "=", "None", ",", "valid", "=", "None", ",", "max_updates", "=", "None", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_compile", "(", "*", "*", "kwargs", ")", "if", "valid", "is", "None", ":", "val...
r'''Optimize a loss iteratively using a training and validation dataset. This method yields a series of monitor values to the caller. After every optimization epoch, a pair of monitor dictionaries is generated: one evaluated on the training dataset during the epoch, and another evaluate...
[ "r", "Optimize", "a", "loss", "iteratively", "using", "a", "training", "and", "validation", "dataset", "." ]
42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d
https://github.com/lmjohns3/downhill/blob/42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d/downhill/base.py#L354-L415
train
This method is used to iterate over the training and validation data for a single iteration of the optimization.
lmjohns3/downhill
downhill/base.py
Optimizer.minimize
def minimize(self, *args, **kwargs): '''Optimize our loss exhaustively. This method is a thin wrapper over the :func:`iterate` method. It simply exhausts the iterative optimization process and returns the final monitor values. Returns ------- train_monitors : di...
python
def minimize(self, *args, **kwargs): '''Optimize our loss exhaustively. This method is a thin wrapper over the :func:`iterate` method. It simply exhausts the iterative optimization process and returns the final monitor values. Returns ------- train_monitors : di...
[ "def", "minimize", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "monitors", "=", "None", "for", "monitors", "in", "self", ".", "iterate", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "pass", "return", "monitors" ]
Optimize our loss exhaustively. This method is a thin wrapper over the :func:`iterate` method. It simply exhausts the iterative optimization process and returns the final monitor values. Returns ------- train_monitors : dict A dictionary mapping monitor name...
[ "Optimize", "our", "loss", "exhaustively", "." ]
42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d
https://github.com/lmjohns3/downhill/blob/42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d/downhill/base.py#L417-L436
train
Optimize our loss exhaustively.
lmjohns3/downhill
downhill/base.py
Optimizer._step
def _step(self, dataset): '''Advance the state of the optimizer by one step. Parameters ---------- dataset : :class:`Dataset <downhill.dataset.Dataset>` A dataset for optimizing the model. Returns ------- train_monitors : dict A dictionar...
python
def _step(self, dataset): '''Advance the state of the optimizer by one step. Parameters ---------- dataset : :class:`Dataset <downhill.dataset.Dataset>` A dataset for optimizing the model. Returns ------- train_monitors : dict A dictionar...
[ "def", "_step", "(", "self", ",", "dataset", ")", ":", "if", "dataset", "is", "None", ":", "values", "=", "[", "self", ".", "f_step", "(", ")", "]", "else", ":", "values", "=", "[", "self", ".", "f_step", "(", "*", "x", ")", "for", "x", "in", ...
Advance the state of the optimizer by one step. Parameters ---------- dataset : :class:`Dataset <downhill.dataset.Dataset>` A dataset for optimizing the model. Returns ------- train_monitors : dict A dictionary mapping monitor names to values.
[ "Advance", "the", "state", "of", "the", "optimizer", "by", "one", "step", "." ]
42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d
https://github.com/lmjohns3/downhill/blob/42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d/downhill/base.py#L438-L456
train
Advance the state of the optimizer by one step.
timothycrosley/connectable
connectable/base.py
accept_arguments
def accept_arguments(method, number_of_arguments=1): """Returns True if the given method will accept the given number of arguments method: the method to perform introspection on number_of_arguments: the number_of_arguments """ if 'method' in method.__class__.__name__: number_of_argume...
python
def accept_arguments(method, number_of_arguments=1): """Returns True if the given method will accept the given number of arguments method: the method to perform introspection on number_of_arguments: the number_of_arguments """ if 'method' in method.__class__.__name__: number_of_argume...
[ "def", "accept_arguments", "(", "method", ",", "number_of_arguments", "=", "1", ")", ":", "if", "'method'", "in", "method", ".", "__class__", ".", "__name__", ":", "number_of_arguments", "+=", "1", "func", "=", "getattr", "(", "method", ",", "'im_func'", ","...
Returns True if the given method will accept the given number of arguments method: the method to perform introspection on number_of_arguments: the number_of_arguments
[ "Returns", "True", "if", "the", "given", "method", "will", "accept", "the", "given", "number", "of", "arguments" ]
d5958d974c04b16f410c602786809d0e2a6665d2
https://github.com/timothycrosley/connectable/blob/d5958d974c04b16f410c602786809d0e2a6665d2/connectable/base.py#L98-L117
train
Returns True if the given method will accept the given number of arguments AttributeNames
timothycrosley/connectable
connectable/base.py
Connectable.emit
def emit(self, signal, value=None, gather=False): """Emits a signal, causing all slot methods connected with the signal to be called (optionally w/ related value) signal: the name of the signal to emit, must be defined in the classes 'signals' list. value: the value to pass to all connect...
python
def emit(self, signal, value=None, gather=False): """Emits a signal, causing all slot methods connected with the signal to be called (optionally w/ related value) signal: the name of the signal to emit, must be defined in the classes 'signals' list. value: the value to pass to all connect...
[ "def", "emit", "(", "self", ",", "signal", ",", "value", "=", "None", ",", "gather", "=", "False", ")", ":", "results", "=", "[", "]", "if", "gather", "else", "True", "if", "hasattr", "(", "self", ",", "'connections'", ")", "and", "signal", "in", "...
Emits a signal, causing all slot methods connected with the signal to be called (optionally w/ related value) signal: the name of the signal to emit, must be defined in the classes 'signals' list. value: the value to pass to all connected slot methods. gather: if set, causes emit to re...
[ "Emits", "a", "signal", "causing", "all", "slot", "methods", "connected", "with", "the", "signal", "to", "be", "called", "(", "optionally", "w", "/", "related", "value", ")" ]
d5958d974c04b16f410c602786809d0e2a6665d2
https://github.com/timothycrosley/connectable/blob/d5958d974c04b16f410c602786809d0e2a6665d2/connectable/base.py#L22-L57
train
Emits a signal causing all slot methods connected with the signal to be called with the given value.
timothycrosley/connectable
connectable/base.py
Connectable.connect
def connect(self, signal, slot, transform=None, condition=None): """Defines a connection between this objects signal and another objects slot signal: the signal this class will emit, to cause the slot method to be called receiver: the object containing the slot method to be called ...
python
def connect(self, signal, slot, transform=None, condition=None): """Defines a connection between this objects signal and another objects slot signal: the signal this class will emit, to cause the slot method to be called receiver: the object containing the slot method to be called ...
[ "def", "connect", "(", "self", ",", "signal", ",", "slot", ",", "transform", "=", "None", ",", "condition", "=", "None", ")", ":", "if", "not", "signal", "in", "self", ".", "signals", ":", "print", "(", "\"WARNING: {0} is trying to connect a slot to an undefin...
Defines a connection between this objects signal and another objects slot signal: the signal this class will emit, to cause the slot method to be called receiver: the object containing the slot method to be called slot: the slot method to call transform: an optional value ov...
[ "Defines", "a", "connection", "between", "this", "objects", "signal", "and", "another", "objects", "slot" ]
d5958d974c04b16f410c602786809d0e2a6665d2
https://github.com/timothycrosley/connectable/blob/d5958d974c04b16f410c602786809d0e2a6665d2/connectable/base.py#L59-L77
train
Defines a connection between this object and another object.
timothycrosley/connectable
connectable/base.py
Connectable.disconnect
def disconnect(self, signal=None, slot=None, transform=None, condition=None): """Removes connection(s) between this objects signal and connected slot(s) signal: the signal this class will emit, to cause the slot method to be called receiver: the object containing the slot method to be cal...
python
def disconnect(self, signal=None, slot=None, transform=None, condition=None): """Removes connection(s) between this objects signal and connected slot(s) signal: the signal this class will emit, to cause the slot method to be called receiver: the object containing the slot method to be cal...
[ "def", "disconnect", "(", "self", ",", "signal", "=", "None", ",", "slot", "=", "None", ",", "transform", "=", "None", ",", "condition", "=", "None", ")", ":", "if", "slot", ":", "self", ".", "connections", "[", "signal", "]", "[", "condition", "]", ...
Removes connection(s) between this objects signal and connected slot(s) signal: the signal this class will emit, to cause the slot method to be called receiver: the object containing the slot method to be called slot: the slot method or function to call transform: an optiona...
[ "Removes", "connection", "(", "s", ")", "between", "this", "objects", "signal", "and", "connected", "slot", "(", "s", ")" ]
d5958d974c04b16f410c602786809d0e2a6665d2
https://github.com/timothycrosley/connectable/blob/d5958d974c04b16f410c602786809d0e2a6665d2/connectable/base.py#L79-L95
train
Removes all connections between this object signal and connected slot ( s
Lagg/steamodd
steam/sim.py
inventory_context.get
def get(self, key): """ Returns context data for a given app, can be an ID or a case insensitive name """ keystr = str(key) res = None try: res = self.ctx[keystr] except KeyError: for k, v in self.ctx.items(): if "name" in v and v["name"]....
python
def get(self, key): """ Returns context data for a given app, can be an ID or a case insensitive name """ keystr = str(key) res = None try: res = self.ctx[keystr] except KeyError: for k, v in self.ctx.items(): if "name" in v and v["name"]....
[ "def", "get", "(", "self", ",", "key", ")", ":", "keystr", "=", "str", "(", "key", ")", "res", "=", "None", "try", ":", "res", "=", "self", ".", "ctx", "[", "keystr", "]", "except", "KeyError", ":", "for", "k", ",", "v", "in", "self", ".", "c...
Returns context data for a given app, can be an ID or a case insensitive name
[ "Returns", "context", "data", "for", "a", "given", "app", "can", "be", "an", "ID", "or", "a", "case", "insensitive", "name" ]
2e9ced4e7a6dbe3e09d5a648450bafc12b937b95
https://github.com/Lagg/steamodd/blob/2e9ced4e7a6dbe3e09d5a648450bafc12b937b95/steam/sim.py#L35-L48
train
Returns the context data for a given app. Can be an ID or a case insensitive name.
Lagg/steamodd
steam/sim.py
item.hash_name
def hash_name(self): """ The URL-friendly identifier for the item. Generates its own approximation if one isn't available """ name = self._item.get("market_hash_name") if not name: name = "{0.appid}-{0.name}".format(self) return name
python
def hash_name(self): """ The URL-friendly identifier for the item. Generates its own approximation if one isn't available """ name = self._item.get("market_hash_name") if not name: name = "{0.appid}-{0.name}".format(self) return name
[ "def", "hash_name", "(", "self", ")", ":", "name", "=", "self", ".", "_item", ".", "get", "(", "\"market_hash_name\"", ")", "if", "not", "name", ":", "name", "=", "\"{0.appid}-{0.name}\"", ".", "format", "(", "self", ")", "return", "name" ]
The URL-friendly identifier for the item. Generates its own approximation if one isn't available
[ "The", "URL", "-", "friendly", "identifier", "for", "the", "item", ".", "Generates", "its", "own", "approximation", "if", "one", "isn", "t", "available" ]
2e9ced4e7a6dbe3e09d5a648450bafc12b937b95
https://github.com/Lagg/steamodd/blob/2e9ced4e7a6dbe3e09d5a648450bafc12b937b95/steam/sim.py#L260-L267
train
The URL - friendly identifier for the item. Generates its own approximation if one isn t available.