partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
get_bonds
Utility function to get indices (in pairs) of the bonds.
mmtf/utils/decoder_utils.py
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): """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
[ "Utility", "function", "to", "get", "indices", "(", "in", "pairs", ")", "of", "the", "bonds", "." ]
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/utils/decoder_utils.py#L162-L167
[ "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", "[",...
899bb877ca1b32a9396803d38c5bf38a2520754e
train
get_unique_groups
Function to get a unique list of groups.
mmtf/api/mmtf_writer.py
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): """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
[ "Function", "to", "get", "a", "unique", "list", "of", "groups", "." ]
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/mmtf_writer.py#L59-L65
[ "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" ]
899bb877ca1b32a9396803d38c5bf38a2520754e
train
Group.convert_to_dict
Convert the group object to an appropriate DICT
mmtf/api/mmtf_writer.py
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): """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...
[ "Convert", "the", "group", "object", "to", "an", "appropriate", "DICT" ]
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/mmtf_writer.py#L45-L56
[ "def", "convert_to_dict", "(", "self", ")", ":", "out_dict", "=", "{", "}", "out_dict", "[", "\"groupName\"", "]", "=", "self", ".", "group_name", "out_dict", "[", "\"atomNameList\"", "]", "=", "self", ".", "atom_name_list", "out_dict", "[", "\"elementList\"",...
899bb877ca1b32a9396803d38c5bf38a2520754e
train
TemplateEncoder.set_atom_info
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 ...
mmtf/api/mmtf_writer.py
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): """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...
[ "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", ...
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/mmtf_writer.py#L84-L98
[ "def", "set_atom_info", "(", "self", ",", "atom_name", ",", "serial_number", ",", "alternative_location_id", ",", "x", ",", "y", ",", "z", ",", "occupancy", ",", "temperature_factor", ",", "element", ",", "charge", ")", ":", "raise", "NotImplementedError" ]
899bb877ca1b32a9396803d38c5bf38a2520754e
train
TemplateEncoder.set_group_info
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....
mmtf/api/mmtf_writer.py
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): """Set the information for a group :param group_name: the name of this group,e.g. LYS ...
[ "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...
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/mmtf_writer.py#L121-L137
[ "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...
899bb877ca1b32a9396803d38c5bf38a2520754e
train
TemplateEncoder.set_header_info
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...
mmtf/api/mmtf_writer.py
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): """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...
[ "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...
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/mmtf_writer.py#L158-L169
[ "def", "set_header_info", "(", "self", ",", "r_free", ",", "r_work", ",", "resolution", ",", "title", ",", "deposition_date", ",", "release_date", ",", "experimental_methods", ")", ":", "raise", "NotImplementedError" ]
899bb877ca1b32a9396803d38c5bf38a2520754e
train
MMTFEncoder.encode_data
Encode the data back into a dict.
mmtf/api/mmtf_writer.py
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): """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...
[ "Encode", "the", "data", "back", "into", "a", "dict", "." ]
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/mmtf_writer.py#L209-L250
[ "def", "encode_data", "(", "self", ")", ":", "output_data", "=", "{", "}", "output_data", "[", "\"groupTypeList\"", "]", "=", "encode_array", "(", "self", ".", "group_type_list", ",", "4", ",", "0", ")", "output_data", "[", "\"xCoordList\"", "]", "=", "enc...
899bb877ca1b32a9396803d38c5bf38a2520754e
train
MMTFEncoder.init_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 total_num_groups: the number of groups in the structure :param total_num_chains: the number of chains in the structure ...
mmtf/api/mmtf_writer.py
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): """Initialise the structure object. :param total_num_bonds: the number of bonds in the structure :param total_num_atoms: t...
[ "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...
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/mmtf_writer.py#L263-L304
[ "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"...
899bb877ca1b32a9396803d38c5bf38a2520754e
train
MMTFEncoder.set_atom_info
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 ...
mmtf/api/mmtf_writer.py
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): """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...
[ "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", ...
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/mmtf_writer.py#L307-L331
[ "def", "set_atom_info", "(", "self", ",", "atom_name", ",", "serial_number", ",", "alternative_location_id", ",", "x", ",", "y", ",", "z", ",", "occupancy", ",", "temperature_factor", ",", "element", ",", "charge", ")", ":", "self", ".", "x_coord_list", ".",...
899bb877ca1b32a9396803d38c5bf38a2520754e
train
MMTFEncoder.set_chain_info
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
mmtf/api/mmtf_writer.py
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): """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...
[ "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...
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/mmtf_writer.py#L334-L342
[ "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...
899bb877ca1b32a9396803d38c5bf38a2520754e
train
MMTFEncoder.set_entity_info
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...
mmtf/api/mmtf_writer.py
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): """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...
[ "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", ...
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/mmtf_writer.py#L345-L352
[ "def", "set_entity_info", "(", "self", ",", "chain_indices", ",", "sequence", ",", "description", ",", "entity_type", ")", ":", "self", ".", "entity_list", ".", "append", "(", "make_entity_dict", "(", "chain_indices", ",", "sequence", ",", "description", ",", ...
899bb877ca1b32a9396803d38c5bf38a2520754e
train
MMTFEncoder.set_group_info
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....
mmtf/api/mmtf_writer.py
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): """Set the information for a group :param group_name: the name of this group,e.g. LYS ...
[ "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...
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/mmtf_writer.py#L355-L383
[ "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 ...
899bb877ca1b32a9396803d38c5bf38a2520754e
train
MMTFEncoder.set_xtal_info
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
mmtf/api/mmtf_writer.py
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): """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...
[ "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", ...
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/mmtf_writer.py#L394-L400
[ "def", "set_xtal_info", "(", "self", ",", "space_group", ",", "unit_cell", ")", ":", "self", ".", "space_group", "=", "space_group", "self", ".", "unit_cell", "=", "unit_cell" ]
899bb877ca1b32a9396803d38c5bf38a2520754e
train
MMTFEncoder.set_header_info
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...
mmtf/api/mmtf_writer.py
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): """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...
[ "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...
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/mmtf_writer.py#L402-L419
[ "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...
899bb877ca1b32a9396803d38c5bf38a2520754e
train
MMTFEncoder.set_bio_assembly_trans
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...
mmtf/api/mmtf_writer.py
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): """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...
[ "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...
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/mmtf_writer.py#L422-L437
[ "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'", "]", "==", ...
899bb877ca1b32a9396803d38c5bf38a2520754e
train
MMTFEncoder.finalize_structure
Any functions needed to cleanup the structure.
mmtf/api/mmtf_writer.py
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): """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...
[ "Any", "functions", "needed", "to", "cleanup", "the", "structure", "." ]
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/mmtf_writer.py#L440-L446
[ "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", ...
899bb877ca1b32a9396803d38c5bf38a2520754e
train
MMTFEncoder.set_group_bond
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
mmtf/api/mmtf_writer.py
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): """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 ...
[ "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...
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/mmtf_writer.py#L449-L457
[ "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", ...
899bb877ca1b32a9396803d38c5bf38a2520754e
train
MMTFEncoder.set_inter_group_bond
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
mmtf/api/mmtf_writer.py
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): """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...
[ "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...
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/mmtf_writer.py#L460-L468
[ "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", ...
899bb877ca1b32a9396803d38c5bf38a2520754e
train
run_length_encode
A function to run length decode an int array. :param in_array: the inptut array of integers :return the encoded integer array
mmtf/codecs/encoders/encoders.py
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): """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...
[ "A", "function", "to", "run", "length", "decode", "an", "int", "array", "." ]
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/codecs/encoders/encoders.py#L1-L21
[ "def", "run_length_encode", "(", "in_array", ")", ":", "if", "(", "len", "(", "in_array", ")", "==", "0", ")", ":", "return", "[", "]", "curr_ans", "=", "in_array", "[", "0", "]", "out_array", "=", "[", "curr_ans", "]", "counter", "=", "1", "for", ...
899bb877ca1b32a9396803d38c5bf38a2520754e
train
delta_encode
A function to delta decode an int array. :param in_array: the inut array to be delta encoded :return the encoded integer array
mmtf/codecs/encoders/encoders.py
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): """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...
[ "A", "function", "to", "delta", "decode", "an", "int", "array", "." ]
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/codecs/encoders/encoders.py#L23-L35
[ "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", ...
899bb877ca1b32a9396803d38c5bf38a2520754e
train
decode_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
mmtf/codecs/default_codec.py
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): """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...
[ "Parse", "the", "header", "of", "an", "input", "byte", "array", "and", "then", "decode", "using", "the", "input", "array", "the", "codec", "and", "the", "appropirate", "parameter", "." ]
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/codecs/default_codec.py#L12-L19
[ "def", "decode_array", "(", "input_array", ")", ":", "codec", ",", "length", ",", "param", ",", "input_array", "=", "parse_header", "(", "input_array", ")", "return", "codec_dict", "[", "codec", "]", ".", "decode", "(", "input_array", ",", "param", ")" ]
899bb877ca1b32a9396803d38c5bf38a2520754e
train
encode_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
mmtf/codecs/default_codec.py
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): """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...
[ "Encode", "the", "array", "using", "the", "method", "and", "then", "add", "the", "header", "to", "this", "array", "." ]
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/codecs/default_codec.py#L22-L29
[ "def", "encode_array", "(", "input_array", ",", "codec", ",", "param", ")", ":", "return", "add_header", "(", "codec_dict", "[", "codec", "]", ".", "encode", "(", "input_array", ",", "param", ")", ",", "codec", ",", "len", "(", "input_array", ")", ",", ...
899bb877ca1b32a9396803d38c5bf38a2520754e
train
run_length_decode
A function to run length decode an int array. :param in_array: the input array of integers :return the decoded array
mmtf/codecs/decoders/decoders.py
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): """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:...
[ "A", "function", "to", "run", "length", "decode", "an", "int", "array", ".", ":", "param", "in_array", ":", "the", "input", "array", "of", "integers", ":", "return", "the", "decoded", "array" ]
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/codecs/decoders/decoders.py#L1-L14
[ "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", ...
899bb877ca1b32a9396803d38c5bf38a2520754e
train
delta_decode
A function to delta decode an int array. :param in_array: the input array of integers :return the decoded array
mmtf/codecs/decoders/decoders.py
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): """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...
[ "A", "function", "to", "delta", "decode", "an", "int", "array", "." ]
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/codecs/decoders/decoders.py#L16-L28
[ "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", ",", ...
899bb877ca1b32a9396803d38c5bf38a2520754e
train
convert_bytes_to_ints
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
mmtf/converters/numpy_converters.py
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): """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...
[ "Convert", "a", "byte", "array", "into", "an", "integer", "array", ".", "The", "number", "of", "bytes", "forming", "an", "integer", "is", "defined", "by", "num" ]
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/converters/numpy_converters.py#L7-L15
[ "def", "convert_bytes_to_ints", "(", "in_bytes", ",", "num", ")", ":", "dt", "=", "numpy", ".", "dtype", "(", "'>i'", "+", "str", "(", "num", ")", ")", "return", "numpy", ".", "frombuffer", "(", "in_bytes", ",", "dt", ")" ]
899bb877ca1b32a9396803d38c5bf38a2520754e
train
decode_chain_list
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
mmtf/converters/numpy_converters.py
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): """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...
[ "Convert", "a", "list", "of", "bytes", "to", "a", "list", "of", "strings", ".", "Each", "string", "is", "of", "length", "mmtf", ".", "CHAIN_LEN" ]
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/converters/numpy_converters.py#L17-L23
[ "def", "decode_chain_list", "(", "in_bytes", ")", ":", "bstrings", "=", "numpy", ".", "frombuffer", "(", "in_bytes", ",", "numpy", ".", "dtype", "(", "'S'", "+", "str", "(", "mmtf", ".", "utils", ".", "constants", ".", "CHAIN_LEN", ")", ")", ")", "retu...
899bb877ca1b32a9396803d38c5bf38a2520754e
train
recursive_index_decode
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
mmtf/converters/numpy_converters.py
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): """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", "." ]
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/converters/numpy_converters.py#L32-L48
[ "def", "recursive_index_decode", "(", "int_array", ",", "max", "=", "32767", ",", "min", "=", "-", "32768", ")", ":", "out_arr", "=", "[", "]", "decoded_val", "=", "0", "for", "item", "in", "int_array", ".", "tolist", "(", ")", ":", "if", "item", "==...
899bb877ca1b32a9396803d38c5bf38a2520754e
train
MMTFDecoder.get_coords
Utility function to get the coordinates as a single list of tuples.
mmtf/api/mmtf_reader.py
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): """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
[ "Utility", "function", "to", "get", "the", "coordinates", "as", "a", "single", "list", "of", "tuples", "." ]
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/mmtf_reader.py#L14-L19
[ "def", "get_coords", "(", "self", ")", ":", "out_list", "=", "[", "]", "for", "i", "in", "range", "(", "len", "(", "self", ".", "x_coord_list", ")", ")", ":", "out_list", ".", "append", "(", "(", "self", ".", "x_coord_list", "[", "i", "]", ",", "...
899bb877ca1b32a9396803d38c5bf38a2520754e
train
MMTFDecoder.decode_data
Function to decode the input data and place it onto the class. :param input_data: the input data as a dict
mmtf/api/mmtf_reader.py
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): """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...
[ "Function", "to", "decode", "the", "input", "data", "and", "place", "it", "onto", "the", "class", ".", ":", "param", "input_data", ":", "the", "input", "data", "as", "a", "dict" ]
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/mmtf_reader.py#L25-L151
[ "def", "decode_data", "(", "self", ",", "input_data", ")", ":", "self", ".", "group_type_list", "=", "decode_array", "(", "input_data", "[", "\"groupTypeList\"", "]", ")", "self", ".", "x_coord_list", "=", "decode_array", "(", "input_data", "[", "\"xCoordList\""...
899bb877ca1b32a9396803d38c5bf38a2520754e
train
MMTFDecoder.pass_data_on
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
mmtf/api/mmtf_reader.py
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): """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....
[ "Write", "the", "data", "from", "the", "getters", "to", "the", "setters", "." ]
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/mmtf_reader.py#L154-L169
[ "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", ...
899bb877ca1b32a9396803d38c5bf38a2520754e
train
_internet_on
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.
mmtf/api/default_api.py
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): """ 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 ...
[ "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...
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/default_api.py#L15-L25
[ "def", "_internet_on", "(", "address", ")", ":", "try", ":", "urllib2", ".", "urlopen", "(", "address", ",", "timeout", "=", "1", ")", "return", "True", "except", "urllib2", ".", "URLError", "as", "err", ":", "return", "False" ]
899bb877ca1b32a9396803d38c5bf38a2520754e
train
write_mmtf
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
mmtf/api/default_api.py
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): """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...
[ "API", "function", "to", "write", "data", "as", "MMTF", "to", "a", "file" ]
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/default_api.py#L27-L36
[ "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", "(", "...
899bb877ca1b32a9396803d38c5bf38a2520754e
train
get_raw_data_from_url
Get the msgpack unpacked data given a PDB id. :param pdb_id: the input PDB id :return the unpacked data (a dict)
mmtf/api/default_api.py
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): """" 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...
[ "Get", "the", "msgpack", "unpacked", "data", "given", "a", "PDB", "id", "." ]
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/default_api.py#L48-L61
[ "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...
899bb877ca1b32a9396803d38c5bf38a2520754e
train
parse
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
mmtf/api/default_api.py
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): """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)) ...
[ "Return", "a", "decoded", "API", "to", "the", "data", "from", "a", "file", "path", "." ]
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/default_api.py#L87-L95
[ "def", "parse", "(", "file_path", ")", ":", "newDecoder", "=", "MMTFDecoder", "(", ")", "with", "open", "(", "file_path", ",", "\"rb\"", ")", "as", "fh", ":", "newDecoder", ".", "decode_data", "(", "_unpack", "(", "fh", ")", ")", "return", "newDecoder" ]
899bb877ca1b32a9396803d38c5bf38a2520754e
train
parse_gzip
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
mmtf/api/default_api.py
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): """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...
[ "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"...
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/default_api.py#L98-L104
[ "def", "parse_gzip", "(", "file_path", ")", ":", "newDecoder", "=", "MMTFDecoder", "(", ")", "newDecoder", ".", "decode_data", "(", "_unpack", "(", "gzip", ".", "open", "(", "file_path", ",", "\"rb\"", ")", ")", ")", "return", "newDecoder" ]
899bb877ca1b32a9396803d38c5bf38a2520754e
train
ungzip_data
Return a string of data after gzip decoding :param the input gziped data :return the gzip decoded data
mmtf/api/default_api.py
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): """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
[ "Return", "a", "string", "of", "data", "after", "gzip", "decoding" ]
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/default_api.py#L107-L114
[ "def", "ungzip_data", "(", "input_data", ")", ":", "buf", "=", "StringIO", "(", "input_data", ")", "f", "=", "gzip", ".", "GzipFile", "(", "fileobj", "=", "buf", ")", "return", "f" ]
899bb877ca1b32a9396803d38c5bf38a2520754e
train
parse_header
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
mmtf/utils/codec_utils.py
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): """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[...
[ "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", ...
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/utils/codec_utils.py#L7-L15
[ "def", "parse_header", "(", "input_array", ")", ":", "codec", "=", "struct", ".", "unpack", "(", "mmtf", ".", "utils", ".", "constants", ".", "NUM_DICT", "[", "4", "]", ",", "input_array", "[", "0", ":", "4", "]", ")", "[", "0", "]", "length", "=",...
899bb877ca1b32a9396803d38c5bf38a2520754e
train
add_header
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
mmtf/utils/codec_utils.py
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): """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", ...
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/utils/codec_utils.py#L18-L27
[ "def", "add_header", "(", "input_array", ",", "codec", ",", "length", ",", "param", ")", ":", "return", "struct", ".", "pack", "(", "mmtf", ".", "utils", ".", "constants", ".", "NUM_DICT", "[", "4", "]", ",", "codec", ")", "+", "struct", ".", "pack",...
899bb877ca1b32a9396803d38c5bf38a2520754e
train
convert_bytes_to_ints
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
mmtf/converters/converters.py
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): """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...
[ "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", "...
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/converters/converters.py#L9-L20
[ "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...
899bb877ca1b32a9396803d38c5bf38a2520754e
train
convert_ints_to_bytes
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
mmtf/converters/converters.py
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): """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: ...
[ "Convert", "an", "integer", "array", "into", "a", "byte", "arrays", ".", "The", "number", "of", "bytes", "forming", "an", "integer", "is", "defined", "by", "num" ]
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/converters/converters.py#L22-L32
[ "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", "]", ...
899bb877ca1b32a9396803d38c5bf38a2520754e
train
decode_chain_list
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
mmtf/converters/converters.py
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): """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...
[ "Convert", "a", "list", "of", "bytes", "to", "a", "list", "of", "strings", ".", "Each", "string", "is", "of", "length", "mmtf", ".", "CHAIN_LEN" ]
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/converters/converters.py#L34-L44
[ "def", "decode_chain_list", "(", "in_bytes", ")", ":", "tot_strings", "=", "len", "(", "in_bytes", ")", "//", "mmtf", ".", "utils", ".", "constants", ".", "CHAIN_LEN", "out_strings", "=", "[", "]", "for", "i", "in", "range", "(", "tot_strings", ")", ":",...
899bb877ca1b32a9396803d38c5bf38a2520754e
train
encode_chain_list
Convert a list of strings to a list of byte arrays. :param in_strings: the input strings :return the encoded list of byte arrays
mmtf/converters/converters.py
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): """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...
[ "Convert", "a", "list", "of", "strings", "to", "a", "list", "of", "byte", "arrays", "." ]
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/converters/converters.py#L47-L57
[ "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...
899bb877ca1b32a9396803d38c5bf38a2520754e
train
recursive_index_encode
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
mmtf/converters/converters.py
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): """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", "." ]
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/converters/converters.py#L90-L108
[ "def", "recursive_index_encode", "(", "int_array", ",", "max", "=", "32767", ",", "min", "=", "-", "32768", ")", ":", "out_arr", "=", "[", "]", "for", "curr", "in", "int_array", ":", "if", "curr", ">=", "0", ":", "while", "curr", ">=", "max", ":", ...
899bb877ca1b32a9396803d38c5bf38a2520754e
train
recursive_index_decode
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
mmtf/converters/converters.py
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): """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", "...
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/converters/converters.py#L110-L128
[ "def", "recursive_index_decode", "(", "int_array", ",", "max", "=", "32767", ",", "min", "=", "-", "32768", ")", ":", "out_arr", "=", "[", "]", "encoded_ind", "=", "0", "while", "encoded_ind", "<", "len", "(", "int_array", ")", ":", "decoded_val", "=", ...
899bb877ca1b32a9396803d38c5bf38a2520754e
train
run_length_decode
A function to run length decode an int array. :param in_array: the input array of integers :return the decoded array
mmtf/codecs/decoders/numpy_decoders.py
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): """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 ...
[ "A", "function", "to", "run", "length", "decode", "an", "int", "array", "." ]
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/codecs/decoders/numpy_decoders.py#L11-L26
[ "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", "=", ...
899bb877ca1b32a9396803d38c5bf38a2520754e
train
build
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.
examples/rosenbrock.py
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): '''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", "." ]
lmjohns3/downhill
python
https://github.com/lmjohns3/downhill/blob/42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d/examples/rosenbrock.py#L15-L33
[ "def", "build", "(", "algo", ",", "init", ")", ":", "x", "=", "theano", ".", "shared", "(", "np", ".", "array", "(", "init", ",", "FLOAT", ")", ",", "name", "=", "'x'", ")", "n", "=", "0.1", "*", "RandomStreams", "(", ")", ".", "normal", "(", ...
42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d
train
build_and_trace
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...
examples/rosenbrock.py
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): '''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...
[ "Run", "an", "optimizer", "on", "the", "rosenbrock", "function", ".", "Return", "xs", "ys", "and", "losses", "." ]
lmjohns3/downhill
python
https://github.com/lmjohns3/downhill/blob/42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d/examples/rosenbrock.py#L36-L55
[ "def", "build_and_trace", "(", "algo", ",", "init", ",", "limit", "=", "100", ",", "*", "*", "kwargs", ")", ":", "kw", "=", "dict", "(", "min_improvement", "=", "0", ",", "patience", "=", "0", ",", "max_gradient_norm", "=", "100", ")", "kw", ".", "...
42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d
train
minimize
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...
downhill/__init__.py
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=False, batch_size=32, train_batches=None, valid_batches=None, **kwargs): '''Minimize a loss function with respect to some symbolic parameters. Additional keyword ...
[ "Minimize", "a", "loss", "function", "with", "respect", "to", "some", "symbolic", "parameters", "." ]
lmjohns3/downhill
python
https://github.com/lmjohns3/downhill/blob/42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d/downhill/__init__.py#L9-L91
[ "def", "minimize", "(", "loss", ",", "train", ",", "valid", "=", "None", ",", "params", "=", "None", ",", "inputs", "=", "None", ",", "algo", "=", "'rmsprop'", ",", "updates", "=", "(", ")", ",", "monitors", "=", "(", ")", ",", "monitor_gradients", ...
42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d
train
make_label
Create a legend label for an optimization run.
examples/rosenbrock-2d.py
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): '''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...
[ "Create", "a", "legend", "label", "for", "an", "optimization", "run", "." ]
lmjohns3/downhill
python
https://github.com/lmjohns3/downhill/blob/42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d/examples/rosenbrock-2d.py#L25-L37
[ "def", "make_label", "(", "loss", ",", "key", ")", ":", "algo", ",", "rate", ",", "mu", ",", "half", ",", "reg", "=", "key", "slots", ",", "args", "=", "[", "'{:.3f}'", ",", "'{}'", ",", "'m={:.3f}'", "]", ",", "[", "loss", ",", "algo", ",", "m...
42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d
train
Dataset.iterate
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...
downhill/dataset.py
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): '''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...
[ "Iterate", "over", "batches", "in", "the", "dataset", "." ]
lmjohns3/downhill
python
https://github.com/lmjohns3/downhill/blob/42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d/downhill/dataset.py#L183-L205
[ "def", "iterate", "(", "self", ",", "shuffle", "=", "True", ")", ":", "for", "_", "in", "range", "(", "self", ".", "iteration_size", ")", ":", "if", "self", ".", "_callable", "is", "not", "None", ":", "yield", "self", ".", "_callable", "(", ")", "e...
42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d
train
shared_like
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...
downhill/util.py
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): '''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...
[ "Create", "a", "Theano", "shared", "variable", "like", "an", "existing", "parameter", "." ]
lmjohns3/downhill
python
https://github.com/lmjohns3/downhill/blob/42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d/downhill/util.py#L30-L49
[ "def", "shared_like", "(", "param", ",", "suffix", ",", "init", "=", "0", ")", ":", "return", "theano", ".", "shared", "(", "np", ".", "zeros_like", "(", "param", ".", "get_value", "(", ")", ")", "+", "init", ",", "name", "=", "'{}_{}'", ".", "form...
42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d
train
find_inputs_and_params
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...
downhill/util.py
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): '''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...
[ "Walk", "a", "computation", "graph", "and", "extract", "root", "variables", "." ]
lmjohns3/downhill
python
https://github.com/lmjohns3/downhill/blob/42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d/downhill/util.py#L68-L95
[ "def", "find_inputs_and_params", "(", "node", ")", ":", "queue", ",", "seen", ",", "inputs", ",", "params", "=", "[", "node", "]", ",", "set", "(", ")", ",", "set", "(", ")", ",", "set", "(", ")", "while", "queue", ":", "node", "=", "queue", ".",...
42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d
train
log
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.
downhill/util.py
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): '''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...
[ "Log", "a", "message", "to", "the", "console", "." ]
lmjohns3/downhill
python
https://github.com/lmjohns3/downhill/blob/42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d/downhill/util.py#L107-L129
[ "def", "log", "(", "msg", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "now", "=", "datetime", ".", "datetime", ".", "now", "(", ")", "module", "=", "'downhill'", "if", "_detailed_callsite", ":", "caller", "=", "inspect", ".", "stack", "(", ...
42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d
train
log_param
Log a parameter value to the console. Parameters ---------- name : str Name of the parameter being logged. value : any Value of the parameter being logged.
downhill/util.py
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 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...
[ "Log", "a", "parameter", "value", "to", "the", "console", "." ]
lmjohns3/downhill
python
https://github.com/lmjohns3/downhill/blob/42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d/downhill/util.py#L132-L143
[ "def", "log_param", "(", "name", ",", "value", ")", ":", "log", "(", "'setting {} = {}'", ",", "click", ".", "style", "(", "str", "(", "name", ")", ")", ",", "click", ".", "style", "(", "str", "(", "value", ")", ",", "fg", "=", "'yellow'", ")", "...
42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d
train
load_mnist
Load the MNIST digits dataset.
examples/mnist-sparse-factorization.py
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(): '''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 ...
[ "Load", "the", "MNIST", "digits", "dataset", "." ]
lmjohns3/downhill
python
https://github.com/lmjohns3/downhill/blob/42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d/examples/mnist-sparse-factorization.py#L11-L22
[ "def", "load_mnist", "(", ")", ":", "mnist", "=", "skdata", ".", "mnist", ".", "dataset", ".", "MNIST", "(", ")", "mnist", ".", "meta", "# trigger download if needed.", "def", "arr", "(", "n", ",", "dtype", ")", ":", "arr", "=", "mnist", ".", "arrays",...
42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d
train
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...
downhill/base.py
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): '''Construct an optimizer by name. Parameters ---------- algo : str The name of the optimization algorithm to build. loss : Theano expression Loss function to minimize. This ...
[ "Construct", "an", "optimizer", "by", "name", "." ]
lmjohns3/downhill
python
https://github.com/lmjohns3/downhill/blob/42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d/downhill/base.py#L15-L50
[ "def", "build", "(", "algo", ",", "loss", ",", "params", "=", "None", ",", "inputs", "=", "None", ",", "updates", "=", "(", ")", ",", "monitors", "=", "(", ")", ",", "monitor_gradients", "=", "False", ")", ":", "return", "Optimizer", ".", "build", ...
42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d
train
Optimizer._compile
Compile the Theano functions for evaluating and updating our model.
downhill/base.py
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): '''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, ...
[ "Compile", "the", "Theano", "functions", "for", "evaluating", "and", "updating", "our", "model", "." ]
lmjohns3/downhill
python
https://github.com/lmjohns3/downhill/blob/42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d/downhill/base.py#L153-L167
[ "def", "_compile", "(", "self", ",", "*", "*", "kwargs", ")", ":", "util", ".", "log", "(", "'compiling evaluation function'", ")", "self", ".", "f_eval", "=", "theano", ".", "function", "(", "self", ".", "_inputs", ",", "self", ".", "_monitor_exprs", ",...
42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d
train
Optimizer.get_updates
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...
downhill/base.py
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): '''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...
[ "Get", "parameter", "update", "expressions", "for", "performing", "optimization", "." ]
lmjohns3/downhill
python
https://github.com/lmjohns3/downhill/blob/42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d/downhill/base.py#L169-L202
[ "def", "get_updates", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_prepare", "(", "*", "*", "kwargs", ")", "for", "param", ",", "grad", "in", "self", ".", "_differentiate", "(", ")", ":", "for", "var", ",", "update", "in", "self",...
42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d
train
Optimizer._differentiate
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 ----------...
downhill/base.py
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): '''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...
[ "Return", "a", "sequence", "of", "gradients", "for", "our", "parameters", "." ]
lmjohns3/downhill
python
https://github.com/lmjohns3/downhill/blob/42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d/downhill/base.py#L214-L244
[ "def", "_differentiate", "(", "self", ",", "params", "=", "None", ")", ":", "if", "params", "is", "None", ":", "params", "=", "self", ".", "_params", "for", "param", ",", "grad", "in", "zip", "(", "params", ",", "TT", ".", "grad", "(", "self", ".",...
42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d
train
Optimizer.set_params
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.
downhill/base.py
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): '''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 ...
[ "Set", "the", "values", "of", "the", "parameters", "to", "the", "given", "target", "values", "." ]
lmjohns3/downhill
python
https://github.com/lmjohns3/downhill/blob/42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d/downhill/base.py#L246-L259
[ "def", "set_params", "(", "self", ",", "targets", "=", "None", ")", ":", "if", "not", "isinstance", "(", "targets", ",", "(", "list", ",", "tuple", ")", ")", ":", "targets", "=", "self", ".", "_best_params", "for", "param", ",", "target", "in", "zip"...
42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d
train
Optimizer._log
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. ...
downhill/base.py
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=''): '''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...
[ "Log", "the", "state", "of", "the", "optimizer", "on", "the", "console", "." ]
lmjohns3/downhill
python
https://github.com/lmjohns3/downhill/blob/42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d/downhill/base.py#L261-L279
[ "def", "_log", "(", "self", ",", "monitors", ",", "iteration", ",", "label", "=", "''", ",", "suffix", "=", "''", ")", ":", "label", "=", "label", "or", "self", ".", "__class__", ".", "__name__", "fields", "=", "(", "(", "'{}={:.6f}'", ")", ".", "f...
42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d
train
Optimizer.evaluate
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...
downhill/base.py
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): '''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 ...
[ "Evaluate", "the", "current", "model", "parameters", "on", "a", "dataset", "." ]
lmjohns3/downhill
python
https://github.com/lmjohns3/downhill/blob/42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d/downhill/base.py#L281-L301
[ "def", "evaluate", "(", "self", ",", "dataset", ")", ":", "if", "dataset", "is", "None", ":", "values", "=", "[", "self", ".", "f_eval", "(", ")", "]", "else", ":", "values", "=", "[", "self", ".", "f_eval", "(", "*", "x", ")", "for", "x", "in"...
42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d
train
Optimizer._prepare
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).
downhill/base.py
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): '''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...
[ "Set", "up", "properties", "for", "optimization", "." ]
lmjohns3/downhill
python
https://github.com/lmjohns3/downhill/blob/42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d/downhill/base.py#L329-L352
[ "def", "_prepare", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "learning_rate", "=", "util", ".", "as_float", "(", "kwargs", ".", "pop", "(", "'learning_rate'", ",", "1e-4", ")", ")", "self", ".", "momentum", "=", "kwargs", ".", "pop...
42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d
train
Optimizer.iterate
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...
downhill/base.py
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): 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...
[ "r", "Optimize", "a", "loss", "iteratively", "using", "a", "training", "and", "validation", "dataset", "." ]
lmjohns3/downhill
python
https://github.com/lmjohns3/downhill/blob/42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d/downhill/base.py#L354-L415
[ "def", "iterate", "(", "self", ",", "train", "=", "None", ",", "valid", "=", "None", ",", "max_updates", "=", "None", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_compile", "(", "*", "*", "kwargs", ")", "if", "valid", "is", "None", ":", "val...
42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d
train
Optimizer.minimize
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...
downhill/base.py
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): '''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...
[ "Optimize", "our", "loss", "exhaustively", "." ]
lmjohns3/downhill
python
https://github.com/lmjohns3/downhill/blob/42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d/downhill/base.py#L417-L436
[ "def", "minimize", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "monitors", "=", "None", "for", "monitors", "in", "self", ".", "iterate", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "pass", "return", "monitors" ]
42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d
train
Optimizer._step
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.
downhill/base.py
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): '''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...
[ "Advance", "the", "state", "of", "the", "optimizer", "by", "one", "step", "." ]
lmjohns3/downhill
python
https://github.com/lmjohns3/downhill/blob/42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d/downhill/base.py#L438-L456
[ "def", "_step", "(", "self", ",", "dataset", ")", ":", "if", "dataset", "is", "None", ":", "values", "=", "[", "self", ".", "f_step", "(", ")", "]", "else", ":", "values", "=", "[", "self", ".", "f_step", "(", "*", "x", ")", "for", "x", "in", ...
42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d
train
accept_arguments
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
connectable/base.py
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): """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...
[ "Returns", "True", "if", "the", "given", "method", "will", "accept", "the", "given", "number", "of", "arguments" ]
timothycrosley/connectable
python
https://github.com/timothycrosley/connectable/blob/d5958d974c04b16f410c602786809d0e2a6665d2/connectable/base.py#L98-L117
[ "def", "accept_arguments", "(", "method", ",", "number_of_arguments", "=", "1", ")", ":", "if", "'method'", "in", "method", ".", "__class__", ".", "__name__", ":", "number_of_arguments", "+=", "1", "func", "=", "getattr", "(", "method", ",", "'im_func'", ","...
d5958d974c04b16f410c602786809d0e2a6665d2
train
Connectable.emit
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...
connectable/base.py
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): """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...
[ "Emits", "a", "signal", "causing", "all", "slot", "methods", "connected", "with", "the", "signal", "to", "be", "called", "(", "optionally", "w", "/", "related", "value", ")" ]
timothycrosley/connectable
python
https://github.com/timothycrosley/connectable/blob/d5958d974c04b16f410c602786809d0e2a6665d2/connectable/base.py#L22-L57
[ "def", "emit", "(", "self", ",", "signal", ",", "value", "=", "None", ",", "gather", "=", "False", ")", ":", "results", "=", "[", "]", "if", "gather", "else", "True", "if", "hasattr", "(", "self", ",", "'connections'", ")", "and", "signal", "in", "...
d5958d974c04b16f410c602786809d0e2a6665d2
train
Connectable.connect
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...
connectable/base.py
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): """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 ...
[ "Defines", "a", "connection", "between", "this", "objects", "signal", "and", "another", "objects", "slot" ]
timothycrosley/connectable
python
https://github.com/timothycrosley/connectable/blob/d5958d974c04b16f410c602786809d0e2a6665d2/connectable/base.py#L59-L77
[ "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...
d5958d974c04b16f410c602786809d0e2a6665d2
train
Connectable.disconnect
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...
connectable/base.py
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): """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...
[ "Removes", "connection", "(", "s", ")", "between", "this", "objects", "signal", "and", "connected", "slot", "(", "s", ")" ]
timothycrosley/connectable
python
https://github.com/timothycrosley/connectable/blob/d5958d974c04b16f410c602786809d0e2a6665d2/connectable/base.py#L79-L95
[ "def", "disconnect", "(", "self", ",", "signal", "=", "None", ",", "slot", "=", "None", ",", "transform", "=", "None", ",", "condition", "=", "None", ")", ":", "if", "slot", ":", "self", ".", "connections", "[", "signal", "]", "[", "condition", "]", ...
d5958d974c04b16f410c602786809d0e2a6665d2
train
inventory_context.get
Returns context data for a given app, can be an ID or a case insensitive name
steam/sim.py
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): """ 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"]....
[ "Returns", "context", "data", "for", "a", "given", "app", "can", "be", "an", "ID", "or", "a", "case", "insensitive", "name" ]
Lagg/steamodd
python
https://github.com/Lagg/steamodd/blob/2e9ced4e7a6dbe3e09d5a648450bafc12b937b95/steam/sim.py#L35-L48
[ "def", "get", "(", "self", ",", "key", ")", ":", "keystr", "=", "str", "(", "key", ")", "res", "=", "None", "try", ":", "res", "=", "self", ".", "ctx", "[", "keystr", "]", "except", "KeyError", ":", "for", "k", ",", "v", "in", "self", ".", "c...
2e9ced4e7a6dbe3e09d5a648450bafc12b937b95
train
item.hash_name
The URL-friendly identifier for the item. Generates its own approximation if one isn't available
steam/sim.py
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): """ 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
[ "The", "URL", "-", "friendly", "identifier", "for", "the", "item", ".", "Generates", "its", "own", "approximation", "if", "one", "isn", "t", "available" ]
Lagg/steamodd
python
https://github.com/Lagg/steamodd/blob/2e9ced4e7a6dbe3e09d5a648450bafc12b937b95/steam/sim.py#L260-L267
[ "def", "hash_name", "(", "self", ")", ":", "name", "=", "self", ".", "_item", ".", "get", "(", "\"market_hash_name\"", ")", "if", "not", "name", ":", "name", "=", "\"{0.appid}-{0.name}\"", ".", "format", "(", "self", ")", "return", "name" ]
2e9ced4e7a6dbe3e09d5a648450bafc12b937b95
train
item.quality
Can't really trust presence of a schema here, but there is an ID sometimes
steam/sim.py
def quality(self): """ Can't really trust presence of a schema here, but there is an ID sometimes """ try: qid = int((self.tool_metadata or {}).get("quality", 0)) except: qid = 0 # We might be able to get the quality strings from the item's tags internal_...
def quality(self): """ Can't really trust presence of a schema here, but there is an ID sometimes """ try: qid = int((self.tool_metadata or {}).get("quality", 0)) except: qid = 0 # We might be able to get the quality strings from the item's tags internal_...
[ "Can", "t", "really", "trust", "presence", "of", "a", "schema", "here", "but", "there", "is", "an", "ID", "sometimes" ]
Lagg/steamodd
python
https://github.com/Lagg/steamodd/blob/2e9ced4e7a6dbe3e09d5a648450bafc12b937b95/steam/sim.py#L292-L306
[ "def", "quality", "(", "self", ")", ":", "try", ":", "qid", "=", "int", "(", "(", "self", ".", "tool_metadata", "or", "{", "}", ")", ".", "get", "(", "\"quality\"", ",", "0", ")", ")", "except", ":", "qid", "=", "0", "# We might be able to get the qu...
2e9ced4e7a6dbe3e09d5a648450bafc12b937b95
train
key.get
Get the current API key. if one has not been given via 'set' the env var STEAMODD_API_KEY will be checked instead.
steam/api.py
def get(cls): """Get the current API key. if one has not been given via 'set' the env var STEAMODD_API_KEY will be checked instead. """ apikey = cls.__api_key or cls.__api_key_env_var if apikey: return apikey else: raise APIKeyMissingError...
def get(cls): """Get the current API key. if one has not been given via 'set' the env var STEAMODD_API_KEY will be checked instead. """ apikey = cls.__api_key or cls.__api_key_env_var if apikey: return apikey else: raise APIKeyMissingError...
[ "Get", "the", "current", "API", "key", ".", "if", "one", "has", "not", "been", "given", "via", "set", "the", "env", "var", "STEAMODD_API_KEY", "will", "be", "checked", "instead", "." ]
Lagg/steamodd
python
https://github.com/Lagg/steamodd/blob/2e9ced4e7a6dbe3e09d5a648450bafc12b937b95/steam/api.py#L77-L87
[ "def", "get", "(", "cls", ")", ":", "apikey", "=", "cls", ".", "__api_key", "or", "cls", ".", "__api_key_env_var", "if", "apikey", ":", "return", "apikey", "else", ":", "raise", "APIKeyMissingError", "(", "\"API key not set\"", ")" ]
2e9ced4e7a6dbe3e09d5a648450bafc12b937b95
train
method_result.call
Make the API call again and fetch fresh data.
steam/api.py
def call(self): """ Make the API call again and fetch fresh data. """ data = self._downloader.download() # Only try to pass errors arg if supported if sys.version >= "2.7": data = data.decode("utf-8", errors="ignore") else: data = data.decode("utf-8") ...
def call(self): """ Make the API call again and fetch fresh data. """ data = self._downloader.download() # Only try to pass errors arg if supported if sys.version >= "2.7": data = data.decode("utf-8", errors="ignore") else: data = data.decode("utf-8") ...
[ "Make", "the", "API", "call", "again", "and", "fetch", "fresh", "data", "." ]
Lagg/steamodd
python
https://github.com/Lagg/steamodd/blob/2e9ced4e7a6dbe3e09d5a648450bafc12b937b95/steam/api.py#L248-L259
[ "def", "call", "(", "self", ")", ":", "data", "=", "self", ".", "_downloader", ".", "download", "(", ")", "# Only try to pass errors arg if supported", "if", "sys", ".", "version", ">=", "\"2.7\"", ":", "data", "=", "data", ".", "decode", "(", "\"utf-8\"", ...
2e9ced4e7a6dbe3e09d5a648450bafc12b937b95
train
schema._attribute_definition
Returns the attribute definition dict of a given attribute ID, can be the name or the integer ID
steam/items.py
def _attribute_definition(self, attrid): """ Returns the attribute definition dict of a given attribute ID, can be the name or the integer ID """ attrs = self._schema["attributes"] try: # Make a new dict to avoid side effects return dict(attrs[attrid]) ex...
def _attribute_definition(self, attrid): """ Returns the attribute definition dict of a given attribute ID, can be the name or the integer ID """ attrs = self._schema["attributes"] try: # Make a new dict to avoid side effects return dict(attrs[attrid]) ex...
[ "Returns", "the", "attribute", "definition", "dict", "of", "a", "given", "attribute", "ID", "can", "be", "the", "name", "or", "the", "integer", "ID" ]
Lagg/steamodd
python
https://github.com/Lagg/steamodd/blob/2e9ced4e7a6dbe3e09d5a648450bafc12b937b95/steam/items.py#L130-L145
[ "def", "_attribute_definition", "(", "self", ",", "attrid", ")", ":", "attrs", "=", "self", ".", "_schema", "[", "\"attributes\"", "]", "try", ":", "# Make a new dict to avoid side effects", "return", "dict", "(", "attrs", "[", "attrid", "]", ")", "except", "K...
2e9ced4e7a6dbe3e09d5a648450bafc12b937b95
train
schema._quality_definition
Returns the ID and localized name of the given quality, can be either ID type
steam/items.py
def _quality_definition(self, qid): """ Returns the ID and localized name of the given quality, can be either ID type """ qualities = self._schema["qualities"] try: return qualities[qid] except KeyError: qid = self._schema["quality_names"].get(str(qid).lower(), 0...
def _quality_definition(self, qid): """ Returns the ID and localized name of the given quality, can be either ID type """ qualities = self._schema["qualities"] try: return qualities[qid] except KeyError: qid = self._schema["quality_names"].get(str(qid).lower(), 0...
[ "Returns", "the", "ID", "and", "localized", "name", "of", "the", "given", "quality", "can", "be", "either", "ID", "type" ]
Lagg/steamodd
python
https://github.com/Lagg/steamodd/blob/2e9ced4e7a6dbe3e09d5a648450bafc12b937b95/steam/items.py#L147-L155
[ "def", "_quality_definition", "(", "self", ",", "qid", ")", ":", "qualities", "=", "self", ".", "_schema", "[", "\"qualities\"", "]", "try", ":", "return", "qualities", "[", "qid", "]", "except", "KeyError", ":", "qid", "=", "self", ".", "_schema", "[", ...
2e9ced4e7a6dbe3e09d5a648450bafc12b937b95
train
schema.attributes
Returns all attributes in the schema
steam/items.py
def attributes(self): """ Returns all attributes in the schema """ attrs = self._schema["attributes"] return [item_attribute(attr) for attr in sorted(attrs.values(), key=operator.itemgetter("defindex"))]
def attributes(self): """ Returns all attributes in the schema """ attrs = self._schema["attributes"] return [item_attribute(attr) for attr in sorted(attrs.values(), key=operator.itemgetter("defindex"))]
[ "Returns", "all", "attributes", "in", "the", "schema" ]
Lagg/steamodd
python
https://github.com/Lagg/steamodd/blob/2e9ced4e7a6dbe3e09d5a648450bafc12b937b95/steam/items.py#L158-L162
[ "def", "attributes", "(", "self", ")", ":", "attrs", "=", "self", ".", "_schema", "[", "\"attributes\"", "]", "return", "[", "item_attribute", "(", "attr", ")", "for", "attr", "in", "sorted", "(", "attrs", ".", "values", "(", ")", ",", "key", "=", "o...
2e9ced4e7a6dbe3e09d5a648450bafc12b937b95
train
schema.origin_id_to_name
Returns a localized origin name for a given ID
steam/items.py
def origin_id_to_name(self, origin): """ Returns a localized origin name for a given ID """ try: oid = int(origin) except (ValueError, TypeError): return None return self.origins.get(oid)
def origin_id_to_name(self, origin): """ Returns a localized origin name for a given ID """ try: oid = int(origin) except (ValueError, TypeError): return None return self.origins.get(oid)
[ "Returns", "a", "localized", "origin", "name", "for", "a", "given", "ID" ]
Lagg/steamodd
python
https://github.com/Lagg/steamodd/blob/2e9ced4e7a6dbe3e09d5a648450bafc12b937b95/steam/items.py#L195-L202
[ "def", "origin_id_to_name", "(", "self", ",", "origin", ")", ":", "try", ":", "oid", "=", "int", "(", "origin", ")", "except", "(", "ValueError", ",", "TypeError", ")", ":", "return", "None", "return", "self", ".", "origins", ".", "get", "(", "oid", ...
2e9ced4e7a6dbe3e09d5a648450bafc12b937b95
train
item.attributes
Returns a list of attributes
steam/items.py
def attributes(self): """ Returns a list of attributes """ overridden_attrs = self._attributes sortmap = {"neutral": 1, "positive": 2, "negative": 3} sortedattrs = list(overridden_attrs.values()) sortedattrs.sort(key=operator.itemgetter("defindex")) s...
def attributes(self): """ Returns a list of attributes """ overridden_attrs = self._attributes sortmap = {"neutral": 1, "positive": 2, "negative": 3} sortedattrs = list(overridden_attrs.values()) sortedattrs.sort(key=operator.itemgetter("defindex")) s...
[ "Returns", "a", "list", "of", "attributes" ]
Lagg/steamodd
python
https://github.com/Lagg/steamodd/blob/2e9ced4e7a6dbe3e09d5a648450bafc12b937b95/steam/items.py#L269-L280
[ "def", "attributes", "(", "self", ")", ":", "overridden_attrs", "=", "self", ".", "_attributes", "sortmap", "=", "{", "\"neutral\"", ":", "1", ",", "\"positive\"", ":", "2", ",", "\"negative\"", ":", "3", "}", "sortedattrs", "=", "list", "(", "overridden_a...
2e9ced4e7a6dbe3e09d5a648450bafc12b937b95
train
item.equipped
Returns a dict of classes that have the item equipped and in what slot
steam/items.py
def equipped(self): """ Returns a dict of classes that have the item equipped and in what slot """ equipped = self._item.get("equipped", []) # WORKAROUND: 0 is probably an off-by-one error # WORKAROUND: 65535 actually serves a purpose (according to Valve) return dict([(eq["class...
def equipped(self): """ Returns a dict of classes that have the item equipped and in what slot """ equipped = self._item.get("equipped", []) # WORKAROUND: 0 is probably an off-by-one error # WORKAROUND: 65535 actually serves a purpose (according to Valve) return dict([(eq["class...
[ "Returns", "a", "dict", "of", "classes", "that", "have", "the", "item", "equipped", "and", "in", "what", "slot" ]
Lagg/steamodd
python
https://github.com/Lagg/steamodd/blob/2e9ced4e7a6dbe3e09d5a648450bafc12b937b95/steam/items.py#L306-L312
[ "def", "equipped", "(", "self", ")", ":", "equipped", "=", "self", ".", "_item", ".", "get", "(", "\"equipped\"", ",", "[", "]", ")", "# WORKAROUND: 0 is probably an off-by-one error", "# WORKAROUND: 65535 actually serves a purpose (according to Valve)", "return", "dict",...
2e9ced4e7a6dbe3e09d5a648450bafc12b937b95
train
item.equipable_classes
Returns a list of classes that _can_ use the item.
steam/items.py
def equipable_classes(self): """ Returns a list of classes that _can_ use the item. """ sitem = self._schema_item return [c for c in sitem.get("used_by_classes", self.equipped.keys()) if c]
def equipable_classes(self): """ Returns a list of classes that _can_ use the item. """ sitem = self._schema_item return [c for c in sitem.get("used_by_classes", self.equipped.keys()) if c]
[ "Returns", "a", "list", "of", "classes", "that", "_can_", "use", "the", "item", "." ]
Lagg/steamodd
python
https://github.com/Lagg/steamodd/blob/2e9ced4e7a6dbe3e09d5a648450bafc12b937b95/steam/items.py#L315-L319
[ "def", "equipable_classes", "(", "self", ")", ":", "sitem", "=", "self", ".", "_schema_item", "return", "[", "c", "for", "c", "in", "sitem", ".", "get", "(", "\"used_by_classes\"", ",", "self", ".", "equipped", ".", "keys", "(", ")", ")", "if", "c", ...
2e9ced4e7a6dbe3e09d5a648450bafc12b937b95
train
item.contents
Returns the item in the container, if there is one. This will be a standard item object.
steam/items.py
def contents(self): """ Returns the item in the container, if there is one. This will be a standard item object. """ rawitem = self._item.get("contained_item") if rawitem: return self.__class__(rawitem, self._schema)
def contents(self): """ Returns the item in the container, if there is one. This will be a standard item object. """ rawitem = self._item.get("contained_item") if rawitem: return self.__class__(rawitem, self._schema)
[ "Returns", "the", "item", "in", "the", "container", "if", "there", "is", "one", ".", "This", "will", "be", "a", "standard", "item", "object", "." ]
Lagg/steamodd
python
https://github.com/Lagg/steamodd/blob/2e9ced4e7a6dbe3e09d5a648450bafc12b937b95/steam/items.py#L422-L427
[ "def", "contents", "(", "self", ")", ":", "rawitem", "=", "self", ".", "_item", ".", "get", "(", "\"contained_item\"", ")", "if", "rawitem", ":", "return", "self", ".", "__class__", "(", "rawitem", ",", "self", ".", "_schema", ")" ]
2e9ced4e7a6dbe3e09d5a648450bafc12b937b95
train
item.full_name
The full name of the item, generated depending on things such as its quality, rank, the schema language, and so on.
steam/items.py
def full_name(self): """ The full name of the item, generated depending on things such as its quality, rank, the schema language, and so on. """ qid, quality_str, pretty_quality_str = self.quality custom_name = self.custom_name item_name = self.name ...
def full_name(self): """ The full name of the item, generated depending on things such as its quality, rank, the schema language, and so on. """ qid, quality_str, pretty_quality_str = self.quality custom_name = self.custom_name item_name = self.name ...
[ "The", "full", "name", "of", "the", "item", "generated", "depending", "on", "things", "such", "as", "its", "quality", "rank", "the", "schema", "language", "and", "so", "on", "." ]
Lagg/steamodd
python
https://github.com/Lagg/steamodd/blob/2e9ced4e7a6dbe3e09d5a648450bafc12b937b95/steam/items.py#L444-L481
[ "def", "full_name", "(", "self", ")", ":", "qid", ",", "quality_str", ",", "pretty_quality_str", "=", "self", ".", "quality", "custom_name", "=", "self", ".", "custom_name", "item_name", "=", "self", ".", "name", "english", "=", "(", "self", ".", "_languag...
2e9ced4e7a6dbe3e09d5a648450bafc12b937b95
train
item.kill_eaters
Returns a list of tuples containing the proper localized kill eater type strings and their values according to set/type/value "order"
steam/items.py
def kill_eaters(self): """ Returns a list of tuples containing the proper localized kill eater type strings and their values according to set/type/value "order" """ eaters = {} ranktypes = self._kill_types for attr in self: aname = attr.name.strip() ...
def kill_eaters(self): """ Returns a list of tuples containing the proper localized kill eater type strings and their values according to set/type/value "order" """ eaters = {} ranktypes = self._kill_types for attr in self: aname = attr.name.strip() ...
[ "Returns", "a", "list", "of", "tuples", "containing", "the", "proper", "localized", "kill", "eater", "type", "strings", "and", "their", "values", "according", "to", "set", "/", "type", "/", "value", "order" ]
Lagg/steamodd
python
https://github.com/Lagg/steamodd/blob/2e9ced4e7a6dbe3e09d5a648450bafc12b937b95/steam/items.py#L484-L540
[ "def", "kill_eaters", "(", "self", ")", ":", "eaters", "=", "{", "}", "ranktypes", "=", "self", ".", "_kill_types", "for", "attr", "in", "self", ":", "aname", "=", "attr", ".", "name", ".", "strip", "(", ")", "aid", "=", "attr", ".", "id", "if", ...
2e9ced4e7a6dbe3e09d5a648450bafc12b937b95
train
item.rank
Returns the item's rank (if it has one) as a dict that includes required score, name, and level.
steam/items.py
def rank(self): """ Returns the item's rank (if it has one) as a dict that includes required score, name, and level. """ if self._rank != {}: # Don't bother doing attribute lookups again return self._rank try: # The eater determining ...
def rank(self): """ Returns the item's rank (if it has one) as a dict that includes required score, name, and level. """ if self._rank != {}: # Don't bother doing attribute lookups again return self._rank try: # The eater determining ...
[ "Returns", "the", "item", "s", "rank", "(", "if", "it", "has", "one", ")", "as", "a", "dict", "that", "includes", "required", "score", "name", "and", "level", "." ]
Lagg/steamodd
python
https://github.com/Lagg/steamodd/blob/2e9ced4e7a6dbe3e09d5a648450bafc12b937b95/steam/items.py#L543-L571
[ "def", "rank", "(", "self", ")", ":", "if", "self", ".", "_rank", "!=", "{", "}", ":", "# Don't bother doing attribute lookups again", "return", "self", ".", "_rank", "try", ":", "# The eater determining the rank", "levelkey", ",", "typename", ",", "count", "=",...
2e9ced4e7a6dbe3e09d5a648450bafc12b937b95
train
item.available_styles
Returns a list of all styles defined for the item
steam/items.py
def available_styles(self): """ Returns a list of all styles defined for the item """ styles = self._schema_item.get("styles", []) return list(map(operator.itemgetter("name"), styles))
def available_styles(self): """ Returns a list of all styles defined for the item """ styles = self._schema_item.get("styles", []) return list(map(operator.itemgetter("name"), styles))
[ "Returns", "a", "list", "of", "all", "styles", "defined", "for", "the", "item" ]
Lagg/steamodd
python
https://github.com/Lagg/steamodd/blob/2e9ced4e7a6dbe3e09d5a648450bafc12b937b95/steam/items.py#L574-L578
[ "def", "available_styles", "(", "self", ")", ":", "styles", "=", "self", ".", "_schema_item", ".", "get", "(", "\"styles\"", ",", "[", "]", ")", "return", "list", "(", "map", "(", "operator", ".", "itemgetter", "(", "\"name\"", ")", ",", "styles", ")",...
2e9ced4e7a6dbe3e09d5a648450bafc12b937b95
train
item_attribute.formatted_value
Returns a formatted value as a string
steam/items.py
def formatted_value(self): """ Returns a formatted value as a string""" # TODO: Cleanup all of this, it's just weird and unnatural maths val = self.value pval = val ftype = self.value_type if ftype == "percentage": pval = int(round(val * 100)) if...
def formatted_value(self): """ Returns a formatted value as a string""" # TODO: Cleanup all of this, it's just weird and unnatural maths val = self.value pval = val ftype = self.value_type if ftype == "percentage": pval = int(round(val * 100)) if...
[ "Returns", "a", "formatted", "value", "as", "a", "string" ]
Lagg/steamodd
python
https://github.com/Lagg/steamodd/blob/2e9ced4e7a6dbe3e09d5a648450bafc12b937b95/steam/items.py#L711-L741
[ "def", "formatted_value", "(", "self", ")", ":", "# TODO: Cleanup all of this, it's just weird and unnatural maths", "val", "=", "self", ".", "value", "pval", "=", "val", "ftype", "=", "self", ".", "value_type", "if", "ftype", "==", "\"percentage\"", ":", "pval", ...
2e9ced4e7a6dbe3e09d5a648450bafc12b937b95
train
item_attribute.formatted_description
Returns a formatted description string (%s* tokens replaced) or None if unavailable
steam/items.py
def formatted_description(self): """ Returns a formatted description string (%s* tokens replaced) or None if unavailable """ desc = self.description if desc: return desc.replace("%s1", self.formatted_value) else: return None
def formatted_description(self): """ Returns a formatted description string (%s* tokens replaced) or None if unavailable """ desc = self.description if desc: return desc.replace("%s1", self.formatted_value) else: return None
[ "Returns", "a", "formatted", "description", "string", "(", "%s", "*", "tokens", "replaced", ")", "or", "None", "if", "unavailable" ]
Lagg/steamodd
python
https://github.com/Lagg/steamodd/blob/2e9ced4e7a6dbe3e09d5a648450bafc12b937b95/steam/items.py#L744-L751
[ "def", "formatted_description", "(", "self", ")", ":", "desc", "=", "self", ".", "description", "if", "desc", ":", "return", "desc", ".", "replace", "(", "\"%s1\"", ",", "self", ".", "formatted_value", ")", "else", ":", "return", "None" ]
2e9ced4e7a6dbe3e09d5a648450bafc12b937b95
train
item_attribute.value_type
The attribute's type, note that this is the type of the attribute's value and not its affect on the item (i.e. negative or positive). See 'type' for that.
steam/items.py
def value_type(self): """ The attribute's type, note that this is the type of the attribute's value and not its affect on the item (i.e. negative or positive). See 'type' for that. """ redundantprefix = "value_is_" vtype = self._attribute.get("description_format") if vty...
def value_type(self): """ The attribute's type, note that this is the type of the attribute's value and not its affect on the item (i.e. negative or positive). See 'type' for that. """ redundantprefix = "value_is_" vtype = self._attribute.get("description_format") if vty...
[ "The", "attribute", "s", "type", "note", "that", "this", "is", "the", "type", "of", "the", "attribute", "s", "value", "and", "not", "its", "affect", "on", "the", "item", "(", "i", ".", "e", ".", "negative", "or", "positive", ")", ".", "See", "type", ...
Lagg/steamodd
python
https://github.com/Lagg/steamodd/blob/2e9ced4e7a6dbe3e09d5a648450bafc12b937b95/steam/items.py#L819-L829
[ "def", "value_type", "(", "self", ")", ":", "redundantprefix", "=", "\"value_is_\"", "vtype", "=", "self", ".", "_attribute", ".", "get", "(", "\"description_format\"", ")", "if", "vtype", "and", "vtype", ".", "startswith", "(", "redundantprefix", ")", ":", ...
2e9ced4e7a6dbe3e09d5a648450bafc12b937b95
train
item_attribute.account_info
Certain attributes have a user's account information associated with it such as a gifted or crafted item. A dict with two keys: 'persona' and 'id64'. None if the attribute has no account information attached to it.
steam/items.py
def account_info(self): """ Certain attributes have a user's account information associated with it such as a gifted or crafted item. A dict with two keys: 'persona' and 'id64'. None if the attribute has no account information attached to it. """ account_info = self._attribute.g...
def account_info(self): """ Certain attributes have a user's account information associated with it such as a gifted or crafted item. A dict with two keys: 'persona' and 'id64'. None if the attribute has no account information attached to it. """ account_info = self._attribute.g...
[ "Certain", "attributes", "have", "a", "user", "s", "account", "information", "associated", "with", "it", "such", "as", "a", "gifted", "or", "crafted", "item", "." ]
Lagg/steamodd
python
https://github.com/Lagg/steamodd/blob/2e9ced4e7a6dbe3e09d5a648450bafc12b937b95/steam/items.py#L839-L850
[ "def", "account_info", "(", "self", ")", ":", "account_info", "=", "self", ".", "_attribute", ".", "get", "(", "\"account_info\"", ")", "if", "account_info", ":", "return", "{", "\"persona\"", ":", "account_info", ".", "get", "(", "\"personaname\"", ",", "\"...
2e9ced4e7a6dbe3e09d5a648450bafc12b937b95
train
asset_item.tags
Returns a dict containing tags and their localized labels as values
steam/items.py
def tags(self): """ Returns a dict containing tags and their localized labels as values """ return dict([(t, self._catalog.tags.get(t, t)) for t in self._asset.get("tags", [])])
def tags(self): """ Returns a dict containing tags and their localized labels as values """ return dict([(t, self._catalog.tags.get(t, t)) for t in self._asset.get("tags", [])])
[ "Returns", "a", "dict", "containing", "tags", "and", "their", "localized", "labels", "as", "values" ]
Lagg/steamodd
python
https://github.com/Lagg/steamodd/blob/2e9ced4e7a6dbe3e09d5a648450bafc12b937b95/steam/items.py#L965-L967
[ "def", "tags", "(", "self", ")", ":", "return", "dict", "(", "[", "(", "t", ",", "self", ".", "_catalog", ".", "tags", ".", "get", "(", "t", ",", "t", ")", ")", "for", "t", "in", "self", ".", "_asset", ".", "get", "(", "\"tags\"", ",", "[", ...
2e9ced4e7a6dbe3e09d5a648450bafc12b937b95
train
profile.vanity
Returns the user's vanity url if it exists, None otherwise
steam/user.py
def vanity(self): """ Returns the user's vanity url if it exists, None otherwise """ purl = self.profile_url.strip('/') if purl.find("/id/") != -1: return os.path.basename(purl)
def vanity(self): """ Returns the user's vanity url if it exists, None otherwise """ purl = self.profile_url.strip('/') if purl.find("/id/") != -1: return os.path.basename(purl)
[ "Returns", "the", "user", "s", "vanity", "url", "if", "it", "exists", "None", "otherwise" ]
Lagg/steamodd
python
https://github.com/Lagg/steamodd/blob/2e9ced4e7a6dbe3e09d5a648450bafc12b937b95/steam/user.py#L90-L94
[ "def", "vanity", "(", "self", ")", ":", "purl", "=", "self", ".", "profile_url", ".", "strip", "(", "'/'", ")", "if", "purl", ".", "find", "(", "\"/id/\"", ")", "!=", "-", "1", ":", "return", "os", ".", "path", ".", "basename", "(", "purl", ")" ]
2e9ced4e7a6dbe3e09d5a648450bafc12b937b95
train
profile.creation_date
Returns the account creation date as a localtime time.struct_time struct if public
steam/user.py
def creation_date(self): """ Returns the account creation date as a localtime time.struct_time struct if public""" timestamp = self._prof.get("timecreated") if timestamp: return time.localtime(timestamp)
def creation_date(self): """ Returns the account creation date as a localtime time.struct_time struct if public""" timestamp = self._prof.get("timecreated") if timestamp: return time.localtime(timestamp)
[ "Returns", "the", "account", "creation", "date", "as", "a", "localtime", "time", ".", "struct_time", "struct", "if", "public" ]
Lagg/steamodd
python
https://github.com/Lagg/steamodd/blob/2e9ced4e7a6dbe3e09d5a648450bafc12b937b95/steam/user.py#L158-L163
[ "def", "creation_date", "(", "self", ")", ":", "timestamp", "=", "self", ".", "_prof", ".", "get", "(", "\"timecreated\"", ")", "if", "timestamp", ":", "return", "time", ".", "localtime", "(", "timestamp", ")" ]
2e9ced4e7a6dbe3e09d5a648450bafc12b937b95
train
profile.current_game
Returns a tuple of 3 elements (each of which may be None if not available): Current game app ID, server ip:port, misc. extra info (eg. game title)
steam/user.py
def current_game(self): """ Returns a tuple of 3 elements (each of which may be None if not available): Current game app ID, server ip:port, misc. extra info (eg. game title) """ obj = self._prof gameid = obj.get("gameid") gameserverip = obj.get("gameserverip") ...
def current_game(self): """ Returns a tuple of 3 elements (each of which may be None if not available): Current game app ID, server ip:port, misc. extra info (eg. game title) """ obj = self._prof gameid = obj.get("gameid") gameserverip = obj.get("gameserverip") ...
[ "Returns", "a", "tuple", "of", "3", "elements", "(", "each", "of", "which", "may", "be", "None", "if", "not", "available", ")", ":", "Current", "game", "app", "ID", "server", "ip", ":", "port", "misc", ".", "extra", "info", "(", "eg", ".", "game", ...
Lagg/steamodd
python
https://github.com/Lagg/steamodd/blob/2e9ced4e7a6dbe3e09d5a648450bafc12b937b95/steam/user.py#L166-L175
[ "def", "current_game", "(", "self", ")", ":", "obj", "=", "self", ".", "_prof", "gameid", "=", "obj", ".", "get", "(", "\"gameid\"", ")", "gameserverip", "=", "obj", ".", "get", "(", "\"gameserverip\"", ")", "gameextrainfo", "=", "obj", ".", "get", "("...
2e9ced4e7a6dbe3e09d5a648450bafc12b937b95
train
profile.level
Returns the the user's profile level, note that this runs a separate request because the profile level data isn't in the standard player summary output even though it should be. Which is also why it's not implemented as a separate class. You won't need this output and not the profile output
steam/user.py
def level(self): """ Returns the the user's profile level, note that this runs a separate request because the profile level data isn't in the standard player summary output even though it should be. Which is also why it's not implemented as a separate class. You won't need this o...
def level(self): """ Returns the the user's profile level, note that this runs a separate request because the profile level data isn't in the standard player summary output even though it should be. Which is also why it's not implemented as a separate class. You won't need this o...
[ "Returns", "the", "the", "user", "s", "profile", "level", "note", "that", "this", "runs", "a", "separate", "request", "because", "the", "profile", "level", "data", "isn", "t", "in", "the", "standard", "player", "summary", "output", "even", "though", "it", ...
Lagg/steamodd
python
https://github.com/Lagg/steamodd/blob/2e9ced4e7a6dbe3e09d5a648450bafc12b937b95/steam/user.py#L208-L226
[ "def", "level", "(", "self", ")", ":", "level_key", "=", "\"player_level\"", "if", "level_key", "in", "self", ".", "_api", "[", "\"response\"", "]", ":", "return", "self", ".", "_api", "[", "\"response\"", "]", "[", "level_key", "]", "try", ":", "lvl", ...
2e9ced4e7a6dbe3e09d5a648450bafc12b937b95
train
profile.from_def
Builds a profile object from a raw player summary object
steam/user.py
def from_def(cls, obj): """ Builds a profile object from a raw player summary object """ prof = cls(obj["steamid"]) prof._cache = obj return prof
def from_def(cls, obj): """ Builds a profile object from a raw player summary object """ prof = cls(obj["steamid"]) prof._cache = obj return prof
[ "Builds", "a", "profile", "object", "from", "a", "raw", "player", "summary", "object" ]
Lagg/steamodd
python
https://github.com/Lagg/steamodd/blob/2e9ced4e7a6dbe3e09d5a648450bafc12b937b95/steam/user.py#L229-L234
[ "def", "from_def", "(", "cls", ",", "obj", ")", ":", "prof", "=", "cls", "(", "obj", "[", "\"steamid\"", "]", ")", "prof", ".", "_cache", "=", "obj", "return", "prof" ]
2e9ced4e7a6dbe3e09d5a648450bafc12b937b95
train
JsonStreamListener.on_status_withheld
Called when a status is withheld
twitter_monitor/listener.py
def on_status_withheld(self, status_id, user_id, countries): """Called when a status is withheld""" logger.info('Status %s withheld for user %s', status_id, user_id) return True
def on_status_withheld(self, status_id, user_id, countries): """Called when a status is withheld""" logger.info('Status %s withheld for user %s', status_id, user_id) return True
[ "Called", "when", "a", "status", "is", "withheld" ]
michaelbrooks/twitter-monitor
python
https://github.com/michaelbrooks/twitter-monitor/blob/3f99cea8492d3bdaa16f28a038bc8cf6022222ba/twitter_monitor/listener.py#L91-L94
[ "def", "on_status_withheld", "(", "self", ",", "status_id", ",", "user_id", ",", "countries", ")", ":", "logger", ".", "info", "(", "'Status %s withheld for user %s'", ",", "status_id", ",", "user_id", ")", "return", "True" ]
3f99cea8492d3bdaa16f28a038bc8cf6022222ba
train
JsonStreamListener.on_disconnect
Called when a disconnect is received
twitter_monitor/listener.py
def on_disconnect(self, code, stream_name, reason): """Called when a disconnect is received""" logger.error('Disconnect message: %s %s %s', code, stream_name, reason) return True
def on_disconnect(self, code, stream_name, reason): """Called when a disconnect is received""" logger.error('Disconnect message: %s %s %s', code, stream_name, reason) return True
[ "Called", "when", "a", "disconnect", "is", "received" ]
michaelbrooks/twitter-monitor
python
https://github.com/michaelbrooks/twitter-monitor/blob/3f99cea8492d3bdaa16f28a038bc8cf6022222ba/twitter_monitor/listener.py#L101-L104
[ "def", "on_disconnect", "(", "self", ",", "code", ",", "stream_name", ",", "reason", ")", ":", "logger", ".", "error", "(", "'Disconnect message: %s %s %s'", ",", "code", ",", "stream_name", ",", "reason", ")", "return", "True" ]
3f99cea8492d3bdaa16f28a038bc8cf6022222ba
train
JsonStreamListener.on_error
Called when a non-200 status code is returned
twitter_monitor/listener.py
def on_error(self, status_code): """Called when a non-200 status code is returned""" logger.error('Twitter returned error code %s', status_code) self.error = status_code return False
def on_error(self, status_code): """Called when a non-200 status code is returned""" logger.error('Twitter returned error code %s', status_code) self.error = status_code return False
[ "Called", "when", "a", "non", "-", "200", "status", "code", "is", "returned" ]
michaelbrooks/twitter-monitor
python
https://github.com/michaelbrooks/twitter-monitor/blob/3f99cea8492d3bdaa16f28a038bc8cf6022222ba/twitter_monitor/listener.py#L110-L114
[ "def", "on_error", "(", "self", ",", "status_code", ")", ":", "logger", ".", "error", "(", "'Twitter returned error code %s'", ",", "status_code", ")", "self", ".", "error", "=", "status_code", "return", "False" ]
3f99cea8492d3bdaa16f28a038bc8cf6022222ba