repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
assamite/creamas
creamas/examples/spiro/spiro_agent_mp.py
SpiroAgent.invent
def invent(self, n): '''Invent new spirograph by taking n random steps from current position (spirograph generation parameters) and selecting the best one based on the agent's evaluation (hedonic function). :param int n: how many spirographs are created for evaluation :returns: ...
python
def invent(self, n): '''Invent new spirograph by taking n random steps from current position (spirograph generation parameters) and selecting the best one based on the agent's evaluation (hedonic function). :param int n: how many spirographs are created for evaluation :returns: ...
[ "def", "invent", "(", "self", ",", "n", ")", ":", "args", "=", "self", ".", "randomize_args", "(", ")", "img", "=", "self", ".", "create", "(", "args", "[", "0", "]", ",", "args", "[", "1", "]", ")", "best_artifact", "=", "SpiroArtifact", "(", "s...
Invent new spirograph by taking n random steps from current position (spirograph generation parameters) and selecting the best one based on the agent's evaluation (hedonic function). :param int n: how many spirographs are created for evaluation :returns: Best created artifact. :...
[ "Invent", "new", "spirograph", "by", "taking", "n", "random", "steps", "from", "current", "position", "(", "spirograph", "generation", "parameters", ")", "and", "selecting", "the", "best", "one", "based", "on", "the", "agent", "s", "evaluation", "(", "hedonic"...
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/examples/spiro/spiro_agent_mp.py#L195-L221
train
Invent new spirograph by taking n random steps from current position and selecting the best one based on the agent s evaluation function.
assamite/creamas
creamas/examples/spiro/spiro_agent_mp.py
SpiroAgent.learn
def learn(self, spiro, iterations=1): '''Train short term memory with given spirograph. :param spiro: :py:class:`SpiroArtifact` object ''' for i in range(iterations): self.stmem.train_cycle(spiro.obj.flatten())
python
def learn(self, spiro, iterations=1): '''Train short term memory with given spirograph. :param spiro: :py:class:`SpiroArtifact` object ''' for i in range(iterations): self.stmem.train_cycle(spiro.obj.flatten())
[ "def", "learn", "(", "self", ",", "spiro", ",", "iterations", "=", "1", ")", ":", "for", "i", "in", "range", "(", "iterations", ")", ":", "self", ".", "stmem", ".", "train_cycle", "(", "spiro", ".", "obj", ".", "flatten", "(", ")", ")" ]
Train short term memory with given spirograph. :param spiro: :py:class:`SpiroArtifact` object
[ "Train", "short", "term", "memory", "with", "given", "spirograph", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/examples/spiro/spiro_agent_mp.py#L292-L299
train
Train short term memory with given spirograph.
assamite/creamas
creamas/examples/spiro/spiro_agent_mp.py
SpiroAgent.plot_places
def plot_places(self): '''Plot places where the agent has been and generated a spirograph. ''' from matplotlib import pyplot as plt fig, ax = plt.subplots() x = [] y = [] if len(self.arg_history) > 1: xs = [] ys = [] for p in s...
python
def plot_places(self): '''Plot places where the agent has been and generated a spirograph. ''' from matplotlib import pyplot as plt fig, ax = plt.subplots() x = [] y = [] if len(self.arg_history) > 1: xs = [] ys = [] for p in s...
[ "def", "plot_places", "(", "self", ")", ":", "from", "matplotlib", "import", "pyplot", "as", "plt", "fig", ",", "ax", "=", "plt", ".", "subplots", "(", ")", "x", "=", "[", "]", "y", "=", "[", "]", "if", "len", "(", "self", ".", "arg_history", ")"...
Plot places where the agent has been and generated a spirograph.
[ "Plot", "places", "where", "the", "agent", "has", "been", "and", "generated", "a", "spirograph", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/examples/spiro/spiro_agent_mp.py#L398-L445
train
Plot places where the agent has been generated a spirograph.
assamite/creamas
creamas/examples/spiro/spiro_agent_mp.py
SpiroMultiEnvironment.plot_places
def plot_places(self): '''Plot places (in the parameter space) of all the generated artifacts and the artifacts accepted to the domain. ''' from matplotlib import pyplot as plt fig, ax = plt.subplots() title = "Agent places, artifacts and env artifacts ({} env artifacts)"...
python
def plot_places(self): '''Plot places (in the parameter space) of all the generated artifacts and the artifacts accepted to the domain. ''' from matplotlib import pyplot as plt fig, ax = plt.subplots() title = "Agent places, artifacts and env artifacts ({} env artifacts)"...
[ "def", "plot_places", "(", "self", ")", ":", "from", "matplotlib", "import", "pyplot", "as", "plt", "fig", ",", "ax", "=", "plt", ".", "subplots", "(", ")", "title", "=", "\"Agent places, artifacts and env artifacts ({} env artifacts)\"", ".", "format", "(", "le...
Plot places (in the parameter space) of all the generated artifacts and the artifacts accepted to the domain.
[ "Plot", "places", "(", "in", "the", "parameter", "space", ")", "of", "all", "the", "generated", "artifacts", "and", "the", "artifacts", "accepted", "to", "the", "domain", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/examples/spiro/spiro_agent_mp.py#L651-L702
train
Plot places of all the generated artifacts and the artifacts accepted to the domain.
assamite/creamas
creamas/examples/spiro/spiro_agent_mp.py
SpiroMultiEnvironment.destroy
def destroy(self, folder=None): '''Destroy the environment and the subprocesses. ''' ameans = [(0, 0, 0) for _ in range(3)] ret = [self.save_info(folder, ameans)] aiomas.run(until=self.stop_slaves(folder)) # Close and join the process pool nicely. self._pool.close...
python
def destroy(self, folder=None): '''Destroy the environment and the subprocesses. ''' ameans = [(0, 0, 0) for _ in range(3)] ret = [self.save_info(folder, ameans)] aiomas.run(until=self.stop_slaves(folder)) # Close and join the process pool nicely. self._pool.close...
[ "def", "destroy", "(", "self", ",", "folder", "=", "None", ")", ":", "ameans", "=", "[", "(", "0", ",", "0", ",", "0", ")", "for", "_", "in", "range", "(", "3", ")", "]", "ret", "=", "[", "self", ".", "save_info", "(", "folder", ",", "ameans"...
Destroy the environment and the subprocesses.
[ "Destroy", "the", "environment", "and", "the", "subprocesses", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/examples/spiro/spiro_agent_mp.py#L704-L715
train
Destroy the environment and the subprocesses.
Kortemme-Lab/klab
klab/bio/basics.py
translate_codons
def translate_codons(sequence): '''Return the translated protein from 'sequence' assuming +1 reading frame Source - http://adamcoster.com/2011/01/13/python-clean-up-and-translate-nucleotide-sequences/ ''' return ''.join([gencode.get(sequence[3*i:3*i+3],'X') for i in range(len(sequence)//3)])
python
def translate_codons(sequence): '''Return the translated protein from 'sequence' assuming +1 reading frame Source - http://adamcoster.com/2011/01/13/python-clean-up-and-translate-nucleotide-sequences/ ''' return ''.join([gencode.get(sequence[3*i:3*i+3],'X') for i in range(len(sequence)//3)])
[ "def", "translate_codons", "(", "sequence", ")", ":", "return", "''", ".", "join", "(", "[", "gencode", ".", "get", "(", "sequence", "[", "3", "*", "i", ":", "3", "*", "i", "+", "3", "]", ",", "'X'", ")", "for", "i", "in", "range", "(", "len", ...
Return the translated protein from 'sequence' assuming +1 reading frame Source - http://adamcoster.com/2011/01/13/python-clean-up-and-translate-nucleotide-sequences/
[ "Return", "the", "translated", "protein", "from", "sequence", "assuming", "+", "1", "reading", "frame", "Source", "-", "http", ":", "//", "adamcoster", ".", "com", "/", "2011", "/", "01", "/", "13", "/", "python", "-", "clean", "-", "up", "-", "and", ...
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/basics.py#L270-L274
train
Return the translated protein from sequence assuming + 1 reading frame Source - http://adamcoster. com / 2013 - 01 - 13 / python - clean - up - and - translate - nucleotide - sequences
Kortemme-Lab/klab
klab/bio/basics.py
pdb_atom_name_to_element
def pdb_atom_name_to_element(s): '''s should be a string taken from columns 12-15 (zero-indexed) inclusive of a PDB coordinate line.''' assert(len(s) == 4) if len(s.strip()) == 4: assert(s[0] == 'H' or s[0] == 'C' or s[0] == 'O') # "If the name of a hydrogen has four characters, it is left-justified...
python
def pdb_atom_name_to_element(s): '''s should be a string taken from columns 12-15 (zero-indexed) inclusive of a PDB coordinate line.''' assert(len(s) == 4) if len(s.strip()) == 4: assert(s[0] == 'H' or s[0] == 'C' or s[0] == 'O') # "If the name of a hydrogen has four characters, it is left-justified...
[ "def", "pdb_atom_name_to_element", "(", "s", ")", ":", "assert", "(", "len", "(", "s", ")", "==", "4", ")", "if", "len", "(", "s", ".", "strip", "(", ")", ")", "==", "4", ":", "assert", "(", "s", "[", "0", "]", "==", "'H'", "or", "s", "[", ...
s should be a string taken from columns 12-15 (zero-indexed) inclusive of a PDB coordinate line.
[ "s", "should", "be", "a", "string", "taken", "from", "columns", "12", "-", "15", "(", "zero", "-", "indexed", ")", "inclusive", "of", "a", "PDB", "coordinate", "line", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/basics.py#L283-L290
train
Returns the element ID of the given atom name.
Kortemme-Lab/klab
klab/bio/basics.py
mutation_combinations
def mutation_combinations(mutations): '''A generator which returns all non-empty combinations of ChainMutation objects, respecting residue position i.e. if two residues have the same chain and residue ID then we do not return a combination with both residues. Note: You need to use ChainMutation object...
python
def mutation_combinations(mutations): '''A generator which returns all non-empty combinations of ChainMutation objects, respecting residue position i.e. if two residues have the same chain and residue ID then we do not return a combination with both residues. Note: You need to use ChainMutation object...
[ "def", "mutation_combinations", "(", "mutations", ")", ":", "mutations", "=", "sorted", "(", "mutations", ")", "combntn", "=", "itertools", ".", "chain", ".", "from_iterable", "(", "itertools", ".", "combinations", "(", "mutations", ",", "x", ")", "for", "x"...
A generator which returns all non-empty combinations of ChainMutation objects, respecting residue position i.e. if two residues have the same chain and residue ID then we do not return a combination with both residues. Note: You need to use ChainMutation objects here as their equality considers the chain ...
[ "A", "generator", "which", "returns", "all", "non", "-", "empty", "combinations", "of", "ChainMutation", "objects", "respecting", "residue", "position", "i", ".", "e", ".", "if", "two", "residues", "have", "the", "same", "chain", "and", "residue", "ID", "the...
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/basics.py#L998-L1009
train
A generator which returns all non - empty combinations of ChainMutation objects respecting residue position i. e. all residues in the chain are in the same residue ID.
Kortemme-Lab/klab
klab/bio/basics.py
Sequence.add
def add(self, r): '''Takes an id and a Residue r and adds them to the Sequence.''' id = r.get_residue_id() if self.order: last_id = self.order[-1] # KAB - allow for multiresidue noncanonicals if id in self.order: raise colortext.Exception('War...
python
def add(self, r): '''Takes an id and a Residue r and adds them to the Sequence.''' id = r.get_residue_id() if self.order: last_id = self.order[-1] # KAB - allow for multiresidue noncanonicals if id in self.order: raise colortext.Exception('War...
[ "def", "add", "(", "self", ",", "r", ")", ":", "id", "=", "r", ".", "get_residue_id", "(", ")", "if", "self", ".", "order", ":", "last_id", "=", "self", ".", "order", "[", "-", "1", "]", "# KAB - allow for multiresidue noncanonicals", "if", "id", "in",...
Takes an id and a Residue r and adds them to the Sequence.
[ "Takes", "an", "id", "and", "a", "Residue", "r", "and", "adds", "them", "to", "the", "Sequence", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/basics.py#L381-L396
train
Takes an id and a Residue r and adds them to the Sequence.
Kortemme-Lab/klab
klab/bio/basics.py
Sequence.set_type
def set_type(self, sequence_type): '''Set the type of a Sequence if it has not been set.''' if not(self.sequence_type): for id, r in self.sequence.iteritems(): assert(r.residue_type == None) r.residue_type = sequence_type self.sequence_type = seque...
python
def set_type(self, sequence_type): '''Set the type of a Sequence if it has not been set.''' if not(self.sequence_type): for id, r in self.sequence.iteritems(): assert(r.residue_type == None) r.residue_type = sequence_type self.sequence_type = seque...
[ "def", "set_type", "(", "self", ",", "sequence_type", ")", ":", "if", "not", "(", "self", ".", "sequence_type", ")", ":", "for", "id", ",", "r", "in", "self", ".", "sequence", ".", "iteritems", "(", ")", ":", "assert", "(", "r", ".", "residue_type", ...
Set the type of a Sequence if it has not been set.
[ "Set", "the", "type", "of", "a", "Sequence", "if", "it", "has", "not", "been", "set", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/basics.py#L398-L404
train
Set the type of a Sequence if it has not been set.
Kortemme-Lab/klab
klab/bio/basics.py
Sequence.from_sequence
def from_sequence(chain, list_of_residues, sequence_type = None): '''Takes in a chain identifier and protein sequence and returns a Sequence object of Residues, indexed from 1.''' s = Sequence(sequence_type) count = 1 for ResidueAA in list_of_residues: s.add(Residue(chain, co...
python
def from_sequence(chain, list_of_residues, sequence_type = None): '''Takes in a chain identifier and protein sequence and returns a Sequence object of Residues, indexed from 1.''' s = Sequence(sequence_type) count = 1 for ResidueAA in list_of_residues: s.add(Residue(chain, co...
[ "def", "from_sequence", "(", "chain", ",", "list_of_residues", ",", "sequence_type", "=", "None", ")", ":", "s", "=", "Sequence", "(", "sequence_type", ")", "count", "=", "1", "for", "ResidueAA", "in", "list_of_residues", ":", "s", ".", "add", "(", "Residu...
Takes in a chain identifier and protein sequence and returns a Sequence object of Residues, indexed from 1.
[ "Takes", "in", "a", "chain", "identifier", "and", "protein", "sequence", "and", "returns", "a", "Sequence", "object", "of", "Residues", "indexed", "from", "1", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/basics.py#L413-L420
train
Takes in a chain identifier and protein sequence and returns a Sequence object of Residues indexed from 1.
Kortemme-Lab/klab
klab/bio/basics.py
SequenceMap.substitution_scores_match
def substitution_scores_match(self, other): '''Check to make sure that the substitution scores agree. If one map has a null score and the other has a non-null score, we trust the other's score and vice versa.''' overlap = set(self.substitution_scores.keys()).intersection(set(other.substitution_scores.ke...
python
def substitution_scores_match(self, other): '''Check to make sure that the substitution scores agree. If one map has a null score and the other has a non-null score, we trust the other's score and vice versa.''' overlap = set(self.substitution_scores.keys()).intersection(set(other.substitution_scores.ke...
[ "def", "substitution_scores_match", "(", "self", ",", "other", ")", ":", "overlap", "=", "set", "(", "self", ".", "substitution_scores", ".", "keys", "(", ")", ")", ".", "intersection", "(", "set", "(", "other", ".", "substitution_scores", ".", "keys", "("...
Check to make sure that the substitution scores agree. If one map has a null score and the other has a non-null score, we trust the other's score and vice versa.
[ "Check", "to", "make", "sure", "that", "the", "substitution", "scores", "agree", ".", "If", "one", "map", "has", "a", "null", "score", "and", "the", "other", "has", "a", "non", "-", "null", "score", "we", "trust", "the", "other", "s", "score", "and", ...
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/basics.py#L465-L472
train
Check to make sure that the substitution scores agree.
Kortemme-Lab/klab
klab/bio/basics.py
ElementCounter.merge
def merge(self, other): '''Merge two element counters. For all elements, we take the max count from both counters.''' our_element_frequencies = self.items their_element_frequencies = other.items for element_name, freq in sorted(our_element_frequencies.iteritems()): our_elemen...
python
def merge(self, other): '''Merge two element counters. For all elements, we take the max count from both counters.''' our_element_frequencies = self.items their_element_frequencies = other.items for element_name, freq in sorted(our_element_frequencies.iteritems()): our_elemen...
[ "def", "merge", "(", "self", ",", "other", ")", ":", "our_element_frequencies", "=", "self", ".", "items", "their_element_frequencies", "=", "other", ".", "items", "for", "element_name", ",", "freq", "in", "sorted", "(", "our_element_frequencies", ".", "iteritem...
Merge two element counters. For all elements, we take the max count from both counters.
[ "Merge", "two", "element", "counters", ".", "For", "all", "elements", "we", "take", "the", "max", "count", "from", "both", "counters", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/basics.py#L721-L729
train
Merge two element counters. For all elements we take the max count from both counters. For all elements we take the max count from both counters. For all elements we take the max count from both counters. For all elements we take the max count from both counters.
gamechanger/avro_codec
avro_codec/__init__.py
AvroCodec.dump
def dump(self, obj, fp): """ Serializes obj as an avro-format byte stream to the provided fp file-like object stream. """ if not validate(obj, self._raw_schema): raise AvroTypeException(self._avro_schema, obj) fastavro_write_data(fp, obj, self._raw_schema)
python
def dump(self, obj, fp): """ Serializes obj as an avro-format byte stream to the provided fp file-like object stream. """ if not validate(obj, self._raw_schema): raise AvroTypeException(self._avro_schema, obj) fastavro_write_data(fp, obj, self._raw_schema)
[ "def", "dump", "(", "self", ",", "obj", ",", "fp", ")", ":", "if", "not", "validate", "(", "obj", ",", "self", ".", "_raw_schema", ")", ":", "raise", "AvroTypeException", "(", "self", ".", "_avro_schema", ",", "obj", ")", "fastavro_write_data", "(", "f...
Serializes obj as an avro-format byte stream to the provided fp file-like object stream.
[ "Serializes", "obj", "as", "an", "avro", "-", "format", "byte", "stream", "to", "the", "provided", "fp", "file", "-", "like", "object", "stream", "." ]
57468bee8972a26b31b16a3437b3eeaa5ace2af6
https://github.com/gamechanger/avro_codec/blob/57468bee8972a26b31b16a3437b3eeaa5ace2af6/avro_codec/__init__.py#L14-L21
train
Serializes obj as an avro - format byte stream to the provided fp file - like object stream.
gamechanger/avro_codec
avro_codec/__init__.py
AvroCodec.dumps
def dumps(self, obj): """ Serializes obj to an avro-format byte array and returns it. """ out = BytesIO() try: self.dump(obj, out) return out.getvalue() finally: out.close()
python
def dumps(self, obj): """ Serializes obj to an avro-format byte array and returns it. """ out = BytesIO() try: self.dump(obj, out) return out.getvalue() finally: out.close()
[ "def", "dumps", "(", "self", ",", "obj", ")", ":", "out", "=", "BytesIO", "(", ")", "try", ":", "self", ".", "dump", "(", "obj", ",", "out", ")", "return", "out", ".", "getvalue", "(", ")", "finally", ":", "out", ".", "close", "(", ")" ]
Serializes obj to an avro-format byte array and returns it.
[ "Serializes", "obj", "to", "an", "avro", "-", "format", "byte", "array", "and", "returns", "it", "." ]
57468bee8972a26b31b16a3437b3eeaa5ace2af6
https://github.com/gamechanger/avro_codec/blob/57468bee8972a26b31b16a3437b3eeaa5ace2af6/avro_codec/__init__.py#L23-L32
train
Serializes obj to an avro - format byte array and returns it.
gamechanger/avro_codec
avro_codec/__init__.py
AvroCodec.loads
def loads(self, data): """ Deserializes the given byte array into an object and returns it. """ st = BytesIO(data) try: return self.load(st) finally: st.close()
python
def loads(self, data): """ Deserializes the given byte array into an object and returns it. """ st = BytesIO(data) try: return self.load(st) finally: st.close()
[ "def", "loads", "(", "self", ",", "data", ")", ":", "st", "=", "BytesIO", "(", "data", ")", "try", ":", "return", "self", ".", "load", "(", "st", ")", "finally", ":", "st", ".", "close", "(", ")" ]
Deserializes the given byte array into an object and returns it.
[ "Deserializes", "the", "given", "byte", "array", "into", "an", "object", "and", "returns", "it", "." ]
57468bee8972a26b31b16a3437b3eeaa5ace2af6
https://github.com/gamechanger/avro_codec/blob/57468bee8972a26b31b16a3437b3eeaa5ace2af6/avro_codec/__init__.py#L41-L49
train
Deserializes the given byte array into an object and returns it.
speechinformaticslab/vfclust
vfclust/TextGridParser.py
TextGrid.parse_phones
def parse_phones(self): """Parse TextGrid phone intervals. This method parses the phone intervals in a TextGrid to extract each phone and each phone's start and end times in the audio recording. For each phone, it instantiates the class Phone(), with the phone and its st...
python
def parse_phones(self): """Parse TextGrid phone intervals. This method parses the phone intervals in a TextGrid to extract each phone and each phone's start and end times in the audio recording. For each phone, it instantiates the class Phone(), with the phone and its st...
[ "def", "parse_phones", "(", "self", ")", ":", "phones", "=", "[", "]", "for", "i", "in", "self", ".", "phone_intervals", ":", "start", "=", "float", "(", "i", "[", "i", ".", "index", "(", "'xmin = '", ")", "+", "7", ":", "i", ".", "index", "(", ...
Parse TextGrid phone intervals. This method parses the phone intervals in a TextGrid to extract each phone and each phone's start and end times in the audio recording. For each phone, it instantiates the class Phone(), with the phone and its start and end times as attributes of ...
[ "Parse", "TextGrid", "phone", "intervals", ".", "This", "method", "parses", "the", "phone", "intervals", "in", "a", "TextGrid", "to", "extract", "each", "phone", "and", "each", "phone", "s", "start", "and", "end", "times", "in", "the", "audio", "recording", ...
7ca733dea4782c828024765726cce65de095d33c
https://github.com/speechinformaticslab/vfclust/blob/7ca733dea4782c828024765726cce65de095d33c/vfclust/TextGridParser.py#L32-L51
train
Parse the phone intervals in a TextGrid and return a list of Phone objects.
speechinformaticslab/vfclust
vfclust/TextGridParser.py
TextGrid.parse_words
def parse_words(self): """Parse TextGrid word intervals. This method parses the word intervals in a TextGrid to extract each word and each word's start and end times in the audio recording. For each word, it instantiates the class Word(), with the word and its start and ...
python
def parse_words(self): """Parse TextGrid word intervals. This method parses the word intervals in a TextGrid to extract each word and each word's start and end times in the audio recording. For each word, it instantiates the class Word(), with the word and its start and ...
[ "def", "parse_words", "(", "self", ")", ":", "phones", "=", "self", ".", "parse_phones", "(", ")", "words", "=", "[", "]", "for", "i", "in", "self", ".", "word_intervals", ":", "start", "=", "float", "(", "i", "[", "i", ".", "index", "(", "'xmin = ...
Parse TextGrid word intervals. This method parses the word intervals in a TextGrid to extract each word and each word's start and end times in the audio recording. For each word, it instantiates the class Word(), with the word and its start and end times as attributes of that cl...
[ "Parse", "TextGrid", "word", "intervals", ".", "This", "method", "parses", "the", "word", "intervals", "in", "a", "TextGrid", "to", "extract", "each", "word", "and", "each", "word", "s", "start", "and", "end", "times", "in", "the", "audio", "recording", "....
7ca733dea4782c828024765726cce65de095d33c
https://github.com/speechinformaticslab/vfclust/blob/7ca733dea4782c828024765726cce65de095d33c/vfclust/TextGridParser.py#L54-L82
train
Parse the word intervals in a TextGrid and return a list of Word objects.
inveniosoftware/invenio-pidrelations
invenio_pidrelations/models.py
PIDRelation.create
def create(cls, parent, child, relation_type, index=None): """Create a PID relation for given parent and child.""" try: with db.session.begin_nested(): obj = cls(parent_id=parent.id, child_id=child.id, relation_type=relation...
python
def create(cls, parent, child, relation_type, index=None): """Create a PID relation for given parent and child.""" try: with db.session.begin_nested(): obj = cls(parent_id=parent.id, child_id=child.id, relation_type=relation...
[ "def", "create", "(", "cls", ",", "parent", ",", "child", ",", "relation_type", ",", "index", "=", "None", ")", ":", "try", ":", "with", "db", ".", "session", ".", "begin_nested", "(", ")", ":", "obj", "=", "cls", "(", "parent_id", "=", "parent", "...
Create a PID relation for given parent and child.
[ "Create", "a", "PID", "relation", "for", "given", "parent", "and", "child", "." ]
a49f3725cf595b663c5b04814280b231f88bc333
https://github.com/inveniosoftware/invenio-pidrelations/blob/a49f3725cf595b663c5b04814280b231f88bc333/invenio_pidrelations/models.py#L106-L122
train
Create a PID relation for given parent and child.
inveniosoftware/invenio-pidrelations
invenio_pidrelations/models.py
PIDRelation.relation_exists
def relation_exists(self, parent, child, relation_type): """Determine if given relation already exists.""" return PIDRelation.query.filter_by( child_pid_id=child.id, parent_pid_id=parent.id, relation_type=relation_type).count() > 0
python
def relation_exists(self, parent, child, relation_type): """Determine if given relation already exists.""" return PIDRelation.query.filter_by( child_pid_id=child.id, parent_pid_id=parent.id, relation_type=relation_type).count() > 0
[ "def", "relation_exists", "(", "self", ",", "parent", ",", "child", ",", "relation_type", ")", ":", "return", "PIDRelation", ".", "query", ".", "filter_by", "(", "child_pid_id", "=", "child", ".", "id", ",", "parent_pid_id", "=", "parent", ".", "id", ",", ...
Determine if given relation already exists.
[ "Determine", "if", "given", "relation", "already", "exists", "." ]
a49f3725cf595b663c5b04814280b231f88bc333
https://github.com/inveniosoftware/invenio-pidrelations/blob/a49f3725cf595b663c5b04814280b231f88bc333/invenio_pidrelations/models.py#L125-L130
train
Determine if given relation already exists.
Kortemme-Lab/klab
klab/fs/stats.py
df
def df(unit = 'GB'): '''A wrapper for the df shell command.''' details = {} headers = ['Filesystem', 'Type', 'Size', 'Used', 'Available', 'Capacity', 'MountedOn'] n = len(headers) unit = df_conversions[unit] p = subprocess.Popen(args = ['df', '-TP'], stdout = subprocess.PIPE) # -P prevents line...
python
def df(unit = 'GB'): '''A wrapper for the df shell command.''' details = {} headers = ['Filesystem', 'Type', 'Size', 'Used', 'Available', 'Capacity', 'MountedOn'] n = len(headers) unit = df_conversions[unit] p = subprocess.Popen(args = ['df', '-TP'], stdout = subprocess.PIPE) # -P prevents line...
[ "def", "df", "(", "unit", "=", "'GB'", ")", ":", "details", "=", "{", "}", "headers", "=", "[", "'Filesystem'", ",", "'Type'", ",", "'Size'", ",", "'Used'", ",", "'Available'", ",", "'Capacity'", ",", "'MountedOn'", "]", "n", "=", "len", "(", "header...
A wrapper for the df shell command.
[ "A", "wrapper", "for", "the", "df", "shell", "command", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/fs/stats.py#L26-L69
train
A wrapper for the df shell command.
joe513/django-cool-pagination
django_cool_paginator/templatetags/paginator_tags.py
url_replace
def url_replace(context, field, value): """ To avoid GET params losing :param context: context_obj :param field: str :param value: str :return: dict-like object """ query_string = context['request'].GET.copy() query_string[field] = value return query_string.urlencode()
python
def url_replace(context, field, value): """ To avoid GET params losing :param context: context_obj :param field: str :param value: str :return: dict-like object """ query_string = context['request'].GET.copy() query_string[field] = value return query_string.urlencode()
[ "def", "url_replace", "(", "context", ",", "field", ",", "value", ")", ":", "query_string", "=", "context", "[", "'request'", "]", ".", "GET", ".", "copy", "(", ")", "query_string", "[", "field", "]", "=", "value", "return", "query_string", ".", "urlenco...
To avoid GET params losing :param context: context_obj :param field: str :param value: str :return: dict-like object
[ "To", "avoid", "GET", "params", "losing" ]
ed75a151a016aef0f5216fdb1e3610597872a3ef
https://github.com/joe513/django-cool-pagination/blob/ed75a151a016aef0f5216fdb1e3610597872a3ef/django_cool_paginator/templatetags/paginator_tags.py#L57-L70
train
Replace the field in the GET params of the object
joe513/django-cool-pagination
django_cool_paginator/templatetags/paginator_tags.py
ellipsis_or_number
def ellipsis_or_number(context, paginator, current_page): """ To avoid display a long pagination bar :param context: template context :param paginator: paginator_obj :param current_page: int :return: str or None """ # Checks is it first page chosen_page = int(context['request'].GET...
python
def ellipsis_or_number(context, paginator, current_page): """ To avoid display a long pagination bar :param context: template context :param paginator: paginator_obj :param current_page: int :return: str or None """ # Checks is it first page chosen_page = int(context['request'].GET...
[ "def", "ellipsis_or_number", "(", "context", ",", "paginator", ",", "current_page", ")", ":", "# Checks is it first page", "chosen_page", "=", "int", "(", "context", "[", "'request'", "]", ".", "GET", "[", "'page'", "]", ")", "if", "'page'", "in", "context", ...
To avoid display a long pagination bar :param context: template context :param paginator: paginator_obj :param current_page: int :return: str or None
[ "To", "avoid", "display", "a", "long", "pagination", "bar" ]
ed75a151a016aef0f5216fdb1e3610597872a3ef
https://github.com/joe513/django-cool-pagination/blob/ed75a151a016aef0f5216fdb1e3610597872a3ef/django_cool_paginator/templatetags/paginator_tags.py#L75-L93
train
Returns ellipsis or number depending on current page
berkeley-cocosci/Wallace
examples/mcmcp/experiment.py
MCMCP.setup
def setup(self): """Setup the networks.""" if not self.networks(): super(MCMCP, self).setup() for net in self.networks(): AnimalSource(network=net)
python
def setup(self): """Setup the networks.""" if not self.networks(): super(MCMCP, self).setup() for net in self.networks(): AnimalSource(network=net)
[ "def", "setup", "(", "self", ")", ":", "if", "not", "self", ".", "networks", "(", ")", ":", "super", "(", "MCMCP", ",", "self", ")", ".", "setup", "(", ")", "for", "net", "in", "self", ".", "networks", "(", ")", ":", "AnimalSource", "(", "network...
Setup the networks.
[ "Setup", "the", "networks", "." ]
3650c0bc3b0804d0adb1d178c5eba9992babb1b0
https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/examples/mcmcp/experiment.py#L31-L36
train
Setup the networks.
adaptive-learning/proso-apps
proso_tasks/models.py
create_items
def create_items(sender, instance, **kwargs): """ When one of the defined objects is created, initialize also its item. """ if instance.item_id is None and instance.item is None: item = Item() if hasattr(instance, 'active'): item.active = getattr(instance, 'active') i...
python
def create_items(sender, instance, **kwargs): """ When one of the defined objects is created, initialize also its item. """ if instance.item_id is None and instance.item is None: item = Item() if hasattr(instance, 'active'): item.active = getattr(instance, 'active') i...
[ "def", "create_items", "(", "sender", ",", "instance", ",", "*", "*", "kwargs", ")", ":", "if", "instance", ".", "item_id", "is", "None", "and", "instance", ".", "item", "is", "None", ":", "item", "=", "Item", "(", ")", "if", "hasattr", "(", "instanc...
When one of the defined objects is created, initialize also its item.
[ "When", "one", "of", "the", "defined", "objects", "is", "created", "initialize", "also", "its", "item", "." ]
8278c72e498d6ef8d392cc47b48473f4ec037142
https://github.com/adaptive-learning/proso-apps/blob/8278c72e498d6ef8d392cc47b48473f4ec037142/proso_tasks/models.py#L196-L205
train
When one of the items is created initialize also its item.
adaptive-learning/proso-apps
proso_tasks/models.py
add_parent
def add_parent(sender, instance, **kwargs): """ When a task instance is created, create also an item relation. """ if not kwargs['created']: return for att in ['task', 'context']: parent = getattr(instance, att).item_id child = instance.item_id ItemRelation.objects.ge...
python
def add_parent(sender, instance, **kwargs): """ When a task instance is created, create also an item relation. """ if not kwargs['created']: return for att in ['task', 'context']: parent = getattr(instance, att).item_id child = instance.item_id ItemRelation.objects.ge...
[ "def", "add_parent", "(", "sender", ",", "instance", ",", "*", "*", "kwargs", ")", ":", "if", "not", "kwargs", "[", "'created'", "]", ":", "return", "for", "att", "in", "[", "'task'", ",", "'context'", "]", ":", "parent", "=", "getattr", "(", "instan...
When a task instance is created, create also an item relation.
[ "When", "a", "task", "instance", "is", "created", "create", "also", "an", "item", "relation", "." ]
8278c72e498d6ef8d392cc47b48473f4ec037142
https://github.com/adaptive-learning/proso-apps/blob/8278c72e498d6ef8d392cc47b48473f4ec037142/proso_tasks/models.py#L221-L234
train
When a task instance is created create also an item relation.
adaptive-learning/proso-apps
proso_tasks/models.py
change_parent
def change_parent(sender, instance, **kwargs): """ When the given task instance has changed. Look at task and context and change the corresponding item relation. """ if instance.id is None: return if len({'task', 'task_id'} & set(instance.changed_fields)) != 0: diff = instance.di...
python
def change_parent(sender, instance, **kwargs): """ When the given task instance has changed. Look at task and context and change the corresponding item relation. """ if instance.id is None: return if len({'task', 'task_id'} & set(instance.changed_fields)) != 0: diff = instance.di...
[ "def", "change_parent", "(", "sender", ",", "instance", ",", "*", "*", "kwargs", ")", ":", "if", "instance", ".", "id", "is", "None", ":", "return", "if", "len", "(", "{", "'task'", ",", "'task_id'", "}", "&", "set", "(", "instance", ".", "changed_fi...
When the given task instance has changed. Look at task and context and change the corresponding item relation.
[ "When", "the", "given", "task", "instance", "has", "changed", ".", "Look", "at", "task", "and", "context", "and", "change", "the", "corresponding", "item", "relation", "." ]
8278c72e498d6ef8d392cc47b48473f4ec037142
https://github.com/adaptive-learning/proso-apps/blob/8278c72e498d6ef8d392cc47b48473f4ec037142/proso_tasks/models.py#L239-L259
train
When the given task instance has changed look at task and context and change the corresponding item relation.
adaptive-learning/proso-apps
proso_tasks/models.py
delete_parent
def delete_parent(sender, instance, **kwargs): """ When the given task instance is deleted, delete also the corresponding item relations. """ ItemRelation.objects.filter(child_id=instance.item_id).delete()
python
def delete_parent(sender, instance, **kwargs): """ When the given task instance is deleted, delete also the corresponding item relations. """ ItemRelation.objects.filter(child_id=instance.item_id).delete()
[ "def", "delete_parent", "(", "sender", ",", "instance", ",", "*", "*", "kwargs", ")", ":", "ItemRelation", ".", "objects", ".", "filter", "(", "child_id", "=", "instance", ".", "item_id", ")", ".", "delete", "(", ")" ]
When the given task instance is deleted, delete also the corresponding item relations.
[ "When", "the", "given", "task", "instance", "is", "deleted", "delete", "also", "the", "corresponding", "item", "relations", "." ]
8278c72e498d6ef8d392cc47b48473f4ec037142
https://github.com/adaptive-learning/proso-apps/blob/8278c72e498d6ef8d392cc47b48473f4ec037142/proso_tasks/models.py#L264-L269
train
When the given task instance is deleted delete also the corresponding item relations.
Kortemme-Lab/klab
klab/bio/smallmolecule.py
Molecule.align_to_other
def align_to_other(self, other, mapping, self_root_pair, other_root_pair = None): ''' root atoms are atom which all other unmapped atoms will be mapped off of ''' if other_root_pair == None: other_root_pair = self_root_pair assert( len(self_root_pair) == len(other_ro...
python
def align_to_other(self, other, mapping, self_root_pair, other_root_pair = None): ''' root atoms are atom which all other unmapped atoms will be mapped off of ''' if other_root_pair == None: other_root_pair = self_root_pair assert( len(self_root_pair) == len(other_ro...
[ "def", "align_to_other", "(", "self", ",", "other", ",", "mapping", ",", "self_root_pair", ",", "other_root_pair", "=", "None", ")", ":", "if", "other_root_pair", "==", "None", ":", "other_root_pair", "=", "self_root_pair", "assert", "(", "len", "(", "self_roo...
root atoms are atom which all other unmapped atoms will be mapped off of
[ "root", "atoms", "are", "atom", "which", "all", "other", "unmapped", "atoms", "will", "be", "mapped", "off", "of" ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/smallmolecule.py#L110-L145
train
Aligns the species to the species of the other species.
systori/bericht
bericht/html/parser.py
pumper
def pumper(html_generator): """ Pulls HTML from source generator, feeds it to the parser and yields DOM elements. """ source = html_generator() parser = etree.HTMLPullParser( events=('start', 'end'), remove_comments=True ) while True: for element in parser.rea...
python
def pumper(html_generator): """ Pulls HTML from source generator, feeds it to the parser and yields DOM elements. """ source = html_generator() parser = etree.HTMLPullParser( events=('start', 'end'), remove_comments=True ) while True: for element in parser.rea...
[ "def", "pumper", "(", "html_generator", ")", ":", "source", "=", "html_generator", "(", ")", "parser", "=", "etree", ".", "HTMLPullParser", "(", "events", "=", "(", "'start'", ",", "'end'", ")", ",", "remove_comments", "=", "True", ")", "while", "True", ...
Pulls HTML from source generator, feeds it to the parser and yields DOM elements.
[ "Pulls", "HTML", "from", "source", "generator", "feeds", "it", "to", "the", "parser", "and", "yields", "DOM", "elements", "." ]
e2b835784926fca86f94f06d0415ca2e4f2d4cb1
https://github.com/systori/bericht/blob/e2b835784926fca86f94f06d0415ca2e4f2d4cb1/bericht/html/parser.py#L8-L29
train
Yields DOM elements from source generator.
systori/bericht
bericht/html/parser.py
HTMLParser.parse
def parse(self, parent): """ https://www.w3.org/TR/html5/syntax.html See: 8.2.5 Tree construction """ last_child = None for event, element in self.stream: tag = element.tag if event == 'start': last_child = element ...
python
def parse(self, parent): """ https://www.w3.org/TR/html5/syntax.html See: 8.2.5 Tree construction """ last_child = None for event, element in self.stream: tag = element.tag if event == 'start': last_child = element ...
[ "def", "parse", "(", "self", ",", "parent", ")", ":", "last_child", "=", "None", "for", "event", ",", "element", "in", "self", ".", "stream", ":", "tag", "=", "element", ".", "tag", "if", "event", "==", "'start'", ":", "last_child", "=", "element", "...
https://www.w3.org/TR/html5/syntax.html See: 8.2.5 Tree construction
[ "https", ":", "//", "www", ".", "w3", ".", "org", "/", "TR", "/", "html5", "/", "syntax", ".", "html", "See", ":", "8", ".", "2", ".", "5", "Tree", "construction" ]
e2b835784926fca86f94f06d0415ca2e4f2d4cb1
https://github.com/systori/bericht/blob/e2b835784926fca86f94f06d0415ca2e4f2d4cb1/bericht/html/parser.py#L63-L150
train
Parse the XML tree.
Kortemme-Lab/klab
klab/general/date_ext.py
date_to_long_form_string
def date_to_long_form_string(dt, locale_ = 'en_US.utf8'): '''dt should be a datetime.date object.''' if locale_: old_locale = locale.getlocale() locale.setlocale(locale.LC_ALL, locale_) v = dt.strftime("%A %B %d %Y") if locale_: locale.setlocale(locale.LC_ALL, old_locale) ret...
python
def date_to_long_form_string(dt, locale_ = 'en_US.utf8'): '''dt should be a datetime.date object.''' if locale_: old_locale = locale.getlocale() locale.setlocale(locale.LC_ALL, locale_) v = dt.strftime("%A %B %d %Y") if locale_: locale.setlocale(locale.LC_ALL, old_locale) ret...
[ "def", "date_to_long_form_string", "(", "dt", ",", "locale_", "=", "'en_US.utf8'", ")", ":", "if", "locale_", ":", "old_locale", "=", "locale", ".", "getlocale", "(", ")", "locale", ".", "setlocale", "(", "locale", ".", "LC_ALL", ",", "locale_", ")", "v", ...
dt should be a datetime.date object.
[ "dt", "should", "be", "a", "datetime", ".", "date", "object", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/general/date_ext.py#L14-L22
train
converts a datetime. date object to a long form string.
Kortemme-Lab/klab
klab/bio/cache.py
BioCache.static_get_pdb_object
def static_get_pdb_object(pdb_id, bio_cache = None, cache_dir = None): '''This method does not necessarily use a BioCache but it seems to fit here.''' pdb_id = pdb_id.upper() if bio_cache: return bio_cache.get_pdb_object(pdb_id) if cache_dir: # Check to see whet...
python
def static_get_pdb_object(pdb_id, bio_cache = None, cache_dir = None): '''This method does not necessarily use a BioCache but it seems to fit here.''' pdb_id = pdb_id.upper() if bio_cache: return bio_cache.get_pdb_object(pdb_id) if cache_dir: # Check to see whet...
[ "def", "static_get_pdb_object", "(", "pdb_id", ",", "bio_cache", "=", "None", ",", "cache_dir", "=", "None", ")", ":", "pdb_id", "=", "pdb_id", ".", "upper", "(", ")", "if", "bio_cache", ":", "return", "bio_cache", ".", "get_pdb_object", "(", "pdb_id", ")"...
This method does not necessarily use a BioCache but it seems to fit here.
[ "This", "method", "does", "not", "necessarily", "use", "a", "BioCache", "but", "it", "seems", "to", "fit", "here", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/cache.py#L336-L353
train
This method returns a PDB object from the RCSB or a BioCache object.
cozy/python_cozy_management
cozy_management/migration.py
rebuild_app
def rebuild_app(app_name, quiet=False, force=True, without_exec=False, restart=False): ''' Rebuild cozy apps with deletion of npm directory & new npm build ''' user = 'cozy-{app_name}'.format(app_name=app_name) home = '{prefix}/{app_name}'.format(prefix=PREFIX, app_name=app_name)...
python
def rebuild_app(app_name, quiet=False, force=True, without_exec=False, restart=False): ''' Rebuild cozy apps with deletion of npm directory & new npm build ''' user = 'cozy-{app_name}'.format(app_name=app_name) home = '{prefix}/{app_name}'.format(prefix=PREFIX, app_name=app_name)...
[ "def", "rebuild_app", "(", "app_name", ",", "quiet", "=", "False", ",", "force", "=", "True", ",", "without_exec", "=", "False", ",", "restart", "=", "False", ")", ":", "user", "=", "'cozy-{app_name}'", ".", "format", "(", "app_name", "=", "app_name", ")...
Rebuild cozy apps with deletion of npm directory & new npm build
[ "Rebuild", "cozy", "apps", "with", "deletion", "of", "npm", "directory", "&", "new", "npm", "build" ]
820cea58458ae3e067fa8cc2da38edbda4681dac
https://github.com/cozy/python_cozy_management/blob/820cea58458ae3e067fa8cc2da38edbda4681dac/cozy_management/migration.py#L14-L46
train
Rebuild cozy apps with deletion of npm directory & new npm build
cozy/python_cozy_management
cozy_management/migration.py
rebuild_all_apps
def rebuild_all_apps(force=True, restart=False): ''' Get all cozy apps & rebuild npm repository ''' cozy_apps = monitor.status(only_cozy=True) for app in cozy_apps.keys(): rebuild_app(app, force=force, restart=restart)
python
def rebuild_all_apps(force=True, restart=False): ''' Get all cozy apps & rebuild npm repository ''' cozy_apps = monitor.status(only_cozy=True) for app in cozy_apps.keys(): rebuild_app(app, force=force, restart=restart)
[ "def", "rebuild_all_apps", "(", "force", "=", "True", ",", "restart", "=", "False", ")", ":", "cozy_apps", "=", "monitor", ".", "status", "(", "only_cozy", "=", "True", ")", "for", "app", "in", "cozy_apps", ".", "keys", "(", ")", ":", "rebuild_app", "(...
Get all cozy apps & rebuild npm repository
[ "Get", "all", "cozy", "apps", "&", "rebuild", "npm", "repository" ]
820cea58458ae3e067fa8cc2da38edbda4681dac
https://github.com/cozy/python_cozy_management/blob/820cea58458ae3e067fa8cc2da38edbda4681dac/cozy_management/migration.py#L49-L55
train
Rebuild npm repository for all cozy apps
cozy/python_cozy_management
cozy_management/migration.py
restart_stopped_apps
def restart_stopped_apps(): ''' Restart all apps in stopped state ''' cozy_apps = monitor.status(only_cozy=True) for app in cozy_apps.keys(): state = cozy_apps[app] if state == 'up': next elif state == 'down': print 'Start {}'.format(app) ...
python
def restart_stopped_apps(): ''' Restart all apps in stopped state ''' cozy_apps = monitor.status(only_cozy=True) for app in cozy_apps.keys(): state = cozy_apps[app] if state == 'up': next elif state == 'down': print 'Start {}'.format(app) ...
[ "def", "restart_stopped_apps", "(", ")", ":", "cozy_apps", "=", "monitor", ".", "status", "(", "only_cozy", "=", "True", ")", "for", "app", "in", "cozy_apps", ".", "keys", "(", ")", ":", "state", "=", "cozy_apps", "[", "app", "]", "if", "state", "==", ...
Restart all apps in stopped state
[ "Restart", "all", "apps", "in", "stopped", "state" ]
820cea58458ae3e067fa8cc2da38edbda4681dac
https://github.com/cozy/python_cozy_management/blob/820cea58458ae3e067fa8cc2da38edbda4681dac/cozy_management/migration.py#L58-L70
train
Restart all apps in stopped state Restart all apps in stopped state
cozy/python_cozy_management
cozy_management/migration.py
migrate_2_node4
def migrate_2_node4(): ''' Migrate existing cozy to node4 ''' helpers.cmd_exec('npm install -g cozy-monitor cozy-controller', show_output=True) helpers.cmd_exec('update-cozy-stack', show_output=True) helpers.cmd_exec('update-all', show_output=True) helpers.cmd_exec('...
python
def migrate_2_node4(): ''' Migrate existing cozy to node4 ''' helpers.cmd_exec('npm install -g cozy-monitor cozy-controller', show_output=True) helpers.cmd_exec('update-cozy-stack', show_output=True) helpers.cmd_exec('update-all', show_output=True) helpers.cmd_exec('...
[ "def", "migrate_2_node4", "(", ")", ":", "helpers", ".", "cmd_exec", "(", "'npm install -g cozy-monitor cozy-controller'", ",", "show_output", "=", "True", ")", "helpers", ".", "cmd_exec", "(", "'update-cozy-stack'", ",", "show_output", "=", "True", ")", "helpers", ...
Migrate existing cozy to node4
[ "Migrate", "existing", "cozy", "to", "node4" ]
820cea58458ae3e067fa8cc2da38edbda4681dac
https://github.com/cozy/python_cozy_management/blob/820cea58458ae3e067fa8cc2da38edbda4681dac/cozy_management/migration.py#L73-L106
train
Migrate existing cozy to node4 cozy
cozy/python_cozy_management
cozy_management/migration.py
install_requirements
def install_requirements(): ''' Install cozy requirements ''' helpers.cmd_exec( 'echo "cozy cozy/nodejs_apt_list text " | debconf-set-selections', show_output=True) helpers.cmd_exec('apt-get install -y cozy-apt-node-list', show_output=True) helpers.cmd_exec('apt-get update', ...
python
def install_requirements(): ''' Install cozy requirements ''' helpers.cmd_exec( 'echo "cozy cozy/nodejs_apt_list text " | debconf-set-selections', show_output=True) helpers.cmd_exec('apt-get install -y cozy-apt-node-list', show_output=True) helpers.cmd_exec('apt-get update', ...
[ "def", "install_requirements", "(", ")", ":", "helpers", ".", "cmd_exec", "(", "'echo \"cozy cozy/nodejs_apt_list text \" | debconf-set-selections'", ",", "show_output", "=", "True", ")", "helpers", ".", "cmd_exec", "(", "'apt-get install -y cozy-apt-node-list'", ",", "show...
Install cozy requirements
[ "Install", "cozy", "requirements" ]
820cea58458ae3e067fa8cc2da38edbda4681dac
https://github.com/cozy/python_cozy_management/blob/820cea58458ae3e067fa8cc2da38edbda4681dac/cozy_management/migration.py#L109-L123
train
Install cozy requirements
trendels/rhino
rhino/ext/session.py
SessionObject.add_message
def add_message(self, text, type=None): """Add a message with an optional type.""" key = self._msg_key self.setdefault(key, []) self[key].append(message(type, text)) self.save()
python
def add_message(self, text, type=None): """Add a message with an optional type.""" key = self._msg_key self.setdefault(key, []) self[key].append(message(type, text)) self.save()
[ "def", "add_message", "(", "self", ",", "text", ",", "type", "=", "None", ")", ":", "key", "=", "self", ".", "_msg_key", "self", ".", "setdefault", "(", "key", ",", "[", "]", ")", "self", "[", "key", "]", ".", "append", "(", "message", "(", "type...
Add a message with an optional type.
[ "Add", "a", "message", "with", "an", "optional", "type", "." ]
f1f0ef21b6080a2bd130b38b5bef163074c94aed
https://github.com/trendels/rhino/blob/f1f0ef21b6080a2bd130b38b5bef163074c94aed/rhino/ext/session.py#L43-L48
train
Add a message with an optional type.
trendels/rhino
rhino/ext/session.py
SessionObject.pop_messages
def pop_messages(self, type=None): """Retrieve stored messages and remove them from the session. Return all messages with a specific type, or all messages when `type` is None. Messages are returned in the order they were added. All messages returned in this way are removed from the sess...
python
def pop_messages(self, type=None): """Retrieve stored messages and remove them from the session. Return all messages with a specific type, or all messages when `type` is None. Messages are returned in the order they were added. All messages returned in this way are removed from the sess...
[ "def", "pop_messages", "(", "self", ",", "type", "=", "None", ")", ":", "key", "=", "self", ".", "_msg_key", "messages", "=", "[", "]", "if", "type", "is", "None", ":", "messages", "=", "self", ".", "pop", "(", "key", ",", "[", "]", ")", "else", ...
Retrieve stored messages and remove them from the session. Return all messages with a specific type, or all messages when `type` is None. Messages are returned in the order they were added. All messages returned in this way are removed from the session and will not be returned in subseq...
[ "Retrieve", "stored", "messages", "and", "remove", "them", "from", "the", "session", "." ]
f1f0ef21b6080a2bd130b38b5bef163074c94aed
https://github.com/trendels/rhino/blob/f1f0ef21b6080a2bd130b38b5bef163074c94aed/rhino/ext/session.py#L50-L78
train
Retrieve stored messages and remove them from the session.
assamite/creamas
creamas/vote.py
vote_random
def vote_random(candidates, votes, n_winners): """Select random winners from the candidates. This voting method bypasses the given votes completely. :param candidates: All candidates in the vote :param votes: Votes from the agents :param int n_winners: The number of vote winners """ rcands...
python
def vote_random(candidates, votes, n_winners): """Select random winners from the candidates. This voting method bypasses the given votes completely. :param candidates: All candidates in the vote :param votes: Votes from the agents :param int n_winners: The number of vote winners """ rcands...
[ "def", "vote_random", "(", "candidates", ",", "votes", ",", "n_winners", ")", ":", "rcands", "=", "list", "(", "candidates", ")", "shuffle", "(", "rcands", ")", "rcands", "=", "rcands", "[", ":", "min", "(", "n_winners", ",", "len", "(", "rcands", ")",...
Select random winners from the candidates. This voting method bypasses the given votes completely. :param candidates: All candidates in the vote :param votes: Votes from the agents :param int n_winners: The number of vote winners
[ "Select", "random", "winners", "from", "the", "candidates", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/vote.py#L439-L452
train
This voting method bypasses the given votes completely.
assamite/creamas
creamas/vote.py
vote_least_worst
def vote_least_worst(candidates, votes, n_winners): """Select "least worst" artifact as the winner of the vote. Least worst artifact is the artifact with the best worst evaluation, i.e. its worst evaluation is the best among all of the artifacts. Ties are resolved randomly. :param candidates: All...
python
def vote_least_worst(candidates, votes, n_winners): """Select "least worst" artifact as the winner of the vote. Least worst artifact is the artifact with the best worst evaluation, i.e. its worst evaluation is the best among all of the artifacts. Ties are resolved randomly. :param candidates: All...
[ "def", "vote_least_worst", "(", "candidates", ",", "votes", ",", "n_winners", ")", ":", "worsts", "=", "{", "str", "(", "c", ")", ":", "100000000.0", "for", "c", "in", "candidates", "}", "for", "v", "in", "votes", ":", "for", "e", "in", "v", ":", "...
Select "least worst" artifact as the winner of the vote. Least worst artifact is the artifact with the best worst evaluation, i.e. its worst evaluation is the best among all of the artifacts. Ties are resolved randomly. :param candidates: All candidates in the vote :param votes: Votes from the ag...
[ "Select", "least", "worst", "artifact", "as", "the", "winner", "of", "the", "vote", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/vote.py#L455-L479
train
Select the least worst artifact as the winner of the vote.
assamite/creamas
creamas/vote.py
vote_best
def vote_best(candidates, votes, n_winners): """Select the artifact with the single best evaluation as the winner of the vote. Ties are resolved randomly. :param candidates: All candidates in the vote :param votes: Votes from the agents :param int n_winners: The number of vote winners """ ...
python
def vote_best(candidates, votes, n_winners): """Select the artifact with the single best evaluation as the winner of the vote. Ties are resolved randomly. :param candidates: All candidates in the vote :param votes: Votes from the agents :param int n_winners: The number of vote winners """ ...
[ "def", "vote_best", "(", "candidates", ",", "votes", ",", "n_winners", ")", ":", "best", "=", "[", "votes", "[", "0", "]", "[", "0", "]", "]", "for", "v", "in", "votes", "[", "1", ":", "]", ":", "if", "v", "[", "0", "]", "[", "1", "]", ">",...
Select the artifact with the single best evaluation as the winner of the vote. Ties are resolved randomly. :param candidates: All candidates in the vote :param votes: Votes from the agents :param int n_winners: The number of vote winners
[ "Select", "the", "artifact", "with", "the", "single", "best", "evaluation", "as", "the", "winner", "of", "the", "vote", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/vote.py#L482-L496
train
Select the artifact with the single best evaluation as the winner of
assamite/creamas
creamas/vote.py
_remove_zeros
def _remove_zeros(votes, fpl, cl, ranking): """Remove zeros in IRV voting. """ for v in votes: for r in v: if r not in fpl: v.remove(r) for c in cl: if c not in fpl: if c not in ranking: ranking.append((c, 0))
python
def _remove_zeros(votes, fpl, cl, ranking): """Remove zeros in IRV voting. """ for v in votes: for r in v: if r not in fpl: v.remove(r) for c in cl: if c not in fpl: if c not in ranking: ranking.append((c, 0))
[ "def", "_remove_zeros", "(", "votes", ",", "fpl", ",", "cl", ",", "ranking", ")", ":", "for", "v", "in", "votes", ":", "for", "r", "in", "v", ":", "if", "r", "not", "in", "fpl", ":", "v", ".", "remove", "(", "r", ")", "for", "c", "in", "cl", ...
Remove zeros in IRV voting.
[ "Remove", "zeros", "in", "IRV", "voting", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/vote.py#L499-L509
train
Remove zeros in IRV voting.
assamite/creamas
creamas/vote.py
_remove_last
def _remove_last(votes, fpl, cl, ranking): """Remove last candidate in IRV voting. """ for v in votes: for r in v: if r == fpl[-1]: v.remove(r) for c in cl: if c == fpl[-1]: if c not in ranking: ranking.append((c, len(ranking) + 1))
python
def _remove_last(votes, fpl, cl, ranking): """Remove last candidate in IRV voting. """ for v in votes: for r in v: if r == fpl[-1]: v.remove(r) for c in cl: if c == fpl[-1]: if c not in ranking: ranking.append((c, len(ranking) + 1))
[ "def", "_remove_last", "(", "votes", ",", "fpl", ",", "cl", ",", "ranking", ")", ":", "for", "v", "in", "votes", ":", "for", "r", "in", "v", ":", "if", "r", "==", "fpl", "[", "-", "1", "]", ":", "v", ".", "remove", "(", "r", ")", "for", "c"...
Remove last candidate in IRV voting.
[ "Remove", "last", "candidate", "in", "IRV", "voting", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/vote.py#L512-L522
train
Remove the last candidate in the list of votes.
assamite/creamas
creamas/vote.py
vote_IRV
def vote_IRV(candidates, votes, n_winners): """Perform IRV voting based on votes. Ties are resolved randomly. :param candidates: All candidates in the vote :param votes: Votes from the agents :param int n_winners: The number of vote winners """ # TODO: Check what is wrong in here. vote...
python
def vote_IRV(candidates, votes, n_winners): """Perform IRV voting based on votes. Ties are resolved randomly. :param candidates: All candidates in the vote :param votes: Votes from the agents :param int n_winners: The number of vote winners """ # TODO: Check what is wrong in here. vote...
[ "def", "vote_IRV", "(", "candidates", ",", "votes", ",", "n_winners", ")", ":", "# TODO: Check what is wrong in here.", "votes", "=", "[", "[", "e", "[", "0", "]", "for", "e", "in", "v", "]", "for", "v", "in", "votes", "]", "f", "=", "lambda", "x", "...
Perform IRV voting based on votes. Ties are resolved randomly. :param candidates: All candidates in the vote :param votes: Votes from the agents :param int n_winners: The number of vote winners
[ "Perform", "IRV", "voting", "based", "on", "votes", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/vote.py#L525-L551
train
Perform IRV voting based on votes.
assamite/creamas
creamas/vote.py
vote_mean
def vote_mean(candidates, votes, n_winners): """Perform mean voting based on votes. Mean voting computes the mean preference for each of the artifact candidates from the votes and sorts the candidates in the mean preference order. Ties are resolved randomly. :param candidates: All candidates ...
python
def vote_mean(candidates, votes, n_winners): """Perform mean voting based on votes. Mean voting computes the mean preference for each of the artifact candidates from the votes and sorts the candidates in the mean preference order. Ties are resolved randomly. :param candidates: All candidates ...
[ "def", "vote_mean", "(", "candidates", ",", "votes", ",", "n_winners", ")", ":", "sums", "=", "{", "str", "(", "candidate", ")", ":", "[", "]", "for", "candidate", "in", "candidates", "}", "for", "vote", "in", "votes", ":", "for", "v", "in", "vote", ...
Perform mean voting based on votes. Mean voting computes the mean preference for each of the artifact candidates from the votes and sorts the candidates in the mean preference order. Ties are resolved randomly. :param candidates: All candidates in the vote :param votes: Votes from the agents ...
[ "Perform", "mean", "voting", "based", "on", "votes", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/vote.py#L554-L581
train
Perform mean voting based on votes.
assamite/creamas
creamas/vote.py
VoteAgent.vote
def vote(self, candidates): """Rank artifact candidates. The voting is needed for the agents living in societies using social decision making. The function should return a sorted list of (candidate, evaluation)-tuples. Depending on the social choice function used, the evaluation...
python
def vote(self, candidates): """Rank artifact candidates. The voting is needed for the agents living in societies using social decision making. The function should return a sorted list of (candidate, evaluation)-tuples. Depending on the social choice function used, the evaluation...
[ "def", "vote", "(", "self", ",", "candidates", ")", ":", "ranks", "=", "[", "(", "c", ",", "self", ".", "evaluate", "(", "c", ")", "[", "0", "]", ")", "for", "c", "in", "candidates", "]", "ranks", ".", "sort", "(", "key", "=", "operator", ".", ...
Rank artifact candidates. The voting is needed for the agents living in societies using social decision making. The function should return a sorted list of (candidate, evaluation)-tuples. Depending on the social choice function used, the evaluation might be omitted from the actual decis...
[ "Rank", "artifact", "candidates", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/vote.py#L75-L97
train
Rank artifact candidates based on the decision function.
assamite/creamas
creamas/vote.py
VoteEnvironment.add_candidate
def add_candidate(self, artifact): """Add candidate artifact to the list of current candidates. """ self.candidates.append(artifact) self._log(logging.DEBUG, "CANDIDATES appended:'{}'" .format(artifact))
python
def add_candidate(self, artifact): """Add candidate artifact to the list of current candidates. """ self.candidates.append(artifact) self._log(logging.DEBUG, "CANDIDATES appended:'{}'" .format(artifact))
[ "def", "add_candidate", "(", "self", ",", "artifact", ")", ":", "self", ".", "candidates", ".", "append", "(", "artifact", ")", "self", ".", "_log", "(", "logging", ".", "DEBUG", ",", "\"CANDIDATES appended:'{}'\"", ".", "format", "(", "artifact", ")", ")"...
Add candidate artifact to the list of current candidates.
[ "Add", "candidate", "artifact", "to", "the", "list", "of", "current", "candidates", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/vote.py#L129-L134
train
Add candidate artifact to the list of candidates.
assamite/creamas
creamas/vote.py
VoteEnvironment.validate_candidates
def validate_candidates(self, candidates): """Validate the candidate artifacts with the agents in the environment. In larger societies this method might be costly, as it calls each agents' :meth:`validate`. :returns: A list of candidates that are validated by all agents in ...
python
def validate_candidates(self, candidates): """Validate the candidate artifacts with the agents in the environment. In larger societies this method might be costly, as it calls each agents' :meth:`validate`. :returns: A list of candidates that are validated by all agents in ...
[ "def", "validate_candidates", "(", "self", ",", "candidates", ")", ":", "valid_candidates", "=", "set", "(", "candidates", ")", "for", "a", "in", "self", ".", "get_agents", "(", "addr", "=", "False", ")", ":", "vc", "=", "set", "(", "a", ".", "validate...
Validate the candidate artifacts with the agents in the environment. In larger societies this method might be costly, as it calls each agents' :meth:`validate`. :returns: A list of candidates that are validated by all agents in the environment.
[ "Validate", "the", "candidate", "artifacts", "with", "the", "agents", "in", "the", "environment", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/vote.py#L136-L151
train
Validate the candidate artifacts with the agents in the environment.
assamite/creamas
creamas/vote.py
VoteEnvironment.gather_votes
def gather_votes(self, candidates): """Gather votes for the given candidates from the agents in the environment. Returned votes are anonymous, i.e. they cannot be tracked to any individual agent afterwards. :returns: A list of votes. Each vote is a list of ``(artifa...
python
def gather_votes(self, candidates): """Gather votes for the given candidates from the agents in the environment. Returned votes are anonymous, i.e. they cannot be tracked to any individual agent afterwards. :returns: A list of votes. Each vote is a list of ``(artifa...
[ "def", "gather_votes", "(", "self", ",", "candidates", ")", ":", "votes", "=", "[", "]", "for", "a", "in", "self", ".", "get_agents", "(", "addr", "=", "False", ")", ":", "vote", "=", "a", ".", "vote", "(", "candidates", ")", "votes", ".", "append"...
Gather votes for the given candidates from the agents in the environment. Returned votes are anonymous, i.e. they cannot be tracked to any individual agent afterwards. :returns: A list of votes. Each vote is a list of ``(artifact, preference)`` -tuples sorted in...
[ "Gather", "votes", "for", "the", "given", "candidates", "from", "the", "agents", "in", "the", "environment", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/vote.py#L153-L168
train
Gather votes for the given candidates from the agents in the environment.
assamite/creamas
creamas/vote.py
VoteOrganizer.get_managers
def get_managers(self): """Get managers for the slave environments. """ if self._single_env: return None if not hasattr(self, '_managers'): self._managers = self.env.get_slave_managers() return self._managers
python
def get_managers(self): """Get managers for the slave environments. """ if self._single_env: return None if not hasattr(self, '_managers'): self._managers = self.env.get_slave_managers() return self._managers
[ "def", "get_managers", "(", "self", ")", ":", "if", "self", ".", "_single_env", ":", "return", "None", "if", "not", "hasattr", "(", "self", ",", "'_managers'", ")", ":", "self", ".", "_managers", "=", "self", ".", "env", ".", "get_slave_managers", "(", ...
Get managers for the slave environments.
[ "Get", "managers", "for", "the", "slave", "environments", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/vote.py#L265-L272
train
Get the managers for the slave environments.
assamite/creamas
creamas/vote.py
VoteOrganizer.gather_votes
def gather_votes(self): """Gather votes from all the underlying slave environments for the current list of candidates. The votes are stored in :attr:`votes`, overriding any previous votes. """ async def slave_task(addr, candidates): r_manager = await self.env.connect...
python
def gather_votes(self): """Gather votes from all the underlying slave environments for the current list of candidates. The votes are stored in :attr:`votes`, overriding any previous votes. """ async def slave_task(addr, candidates): r_manager = await self.env.connect...
[ "def", "gather_votes", "(", "self", ")", ":", "async", "def", "slave_task", "(", "addr", ",", "candidates", ")", ":", "r_manager", "=", "await", "self", ".", "env", ".", "connect", "(", "addr", ")", "return", "await", "r_manager", ".", "gather_votes", "(...
Gather votes from all the underlying slave environments for the current list of candidates. The votes are stored in :attr:`votes`, overriding any previous votes.
[ "Gather", "votes", "from", "all", "the", "underlying", "slave", "environments", "for", "the", "current", "list", "of", "candidates", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/vote.py#L274-L297
train
Gather votes from all the underlying slave environments for the current list of candidates.
assamite/creamas
creamas/vote.py
VoteOrganizer.gather_candidates
def gather_candidates(self): """Gather candidates from the slave environments. The candidates are stored in :attr:`candidates`, overriding any previous candidates. """ async def slave_task(addr): r_manager = await self.env.connect(addr) return await r_man...
python
def gather_candidates(self): """Gather candidates from the slave environments. The candidates are stored in :attr:`candidates`, overriding any previous candidates. """ async def slave_task(addr): r_manager = await self.env.connect(addr) return await r_man...
[ "def", "gather_candidates", "(", "self", ")", ":", "async", "def", "slave_task", "(", "addr", ")", ":", "r_manager", "=", "await", "self", ".", "env", ".", "connect", "(", "addr", ")", "return", "await", "r_manager", ".", "get_candidates", "(", ")", "if"...
Gather candidates from the slave environments. The candidates are stored in :attr:`candidates`, overriding any previous candidates.
[ "Gather", "candidates", "from", "the", "slave", "environments", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/vote.py#L299-L314
train
Gather candidates from the slave environments.
assamite/creamas
creamas/vote.py
VoteOrganizer.clear_candidates
def clear_candidates(self, clear_env=True): """Clear the current candidates. :param bool clear_env: If ``True``, clears also environment's (or its underlying slave environments') candidates. """ async def slave_task(addr): r_manager = await self.env.c...
python
def clear_candidates(self, clear_env=True): """Clear the current candidates. :param bool clear_env: If ``True``, clears also environment's (or its underlying slave environments') candidates. """ async def slave_task(addr): r_manager = await self.env.c...
[ "def", "clear_candidates", "(", "self", ",", "clear_env", "=", "True", ")", ":", "async", "def", "slave_task", "(", "addr", ")", ":", "r_manager", "=", "await", "self", ".", "env", ".", "connect", "(", "addr", ")", "return", "await", "r_manager", ".", ...
Clear the current candidates. :param bool clear_env: If ``True``, clears also environment's (or its underlying slave environments') candidates.
[ "Clear", "the", "current", "candidates", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/vote.py#L316-L333
train
Clears the current candidates.
assamite/creamas
creamas/vote.py
VoteOrganizer.validate_candidates
def validate_candidates(self): """Validate current candidates. This method validates the current candidate list in all the agents in the environment (or underlying slave environments) and replaces the current :attr:`candidates` with the list of validated candidates. The artifac...
python
def validate_candidates(self): """Validate current candidates. This method validates the current candidate list in all the agents in the environment (or underlying slave environments) and replaces the current :attr:`candidates` with the list of validated candidates. The artifac...
[ "def", "validate_candidates", "(", "self", ")", ":", "async", "def", "slave_task", "(", "addr", ",", "candidates", ")", ":", "r_manager", "=", "await", "self", ".", "env", ".", "connect", "(", "addr", ")", "return", "await", "r_manager", ".", "validate_can...
Validate current candidates. This method validates the current candidate list in all the agents in the environment (or underlying slave environments) and replaces the current :attr:`candidates` with the list of validated candidates. The artifact candidates must be hashable and have a :...
[ "Validate", "current", "candidates", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/vote.py#L335-L366
train
Validate the current candidates.
assamite/creamas
creamas/vote.py
VoteOrganizer.gather_and_vote
def gather_and_vote(self, voting_method, validate=False, winners=1, **kwargs): """Convenience function to gathering candidates and votes and performing voting using them. Additional ``**kwargs`` are passed down to voting method. :param voting_method: ...
python
def gather_and_vote(self, voting_method, validate=False, winners=1, **kwargs): """Convenience function to gathering candidates and votes and performing voting using them. Additional ``**kwargs`` are passed down to voting method. :param voting_method: ...
[ "def", "gather_and_vote", "(", "self", ",", "voting_method", ",", "validate", "=", "False", ",", "winners", "=", "1", ",", "*", "*", "kwargs", ")", ":", "self", ".", "gather_candidates", "(", ")", "if", "validate", ":", "self", ".", "validate_candidates", ...
Convenience function to gathering candidates and votes and performing voting using them. Additional ``**kwargs`` are passed down to voting method. :param voting_method: The voting method to use, see :meth:`~creamas.vote.VoteOrganizer.compute_results` for details. ...
[ "Convenience", "function", "to", "gathering", "candidates", "and", "votes", "and", "performing", "voting", "using", "them", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/vote.py#L368-L389
train
Convenience function to gather candidates and votes and return the winners of the candidates and votes.
assamite/creamas
creamas/vote.py
VoteOrganizer.compute_results
def compute_results(self, voting_method, votes=None, winners=1, **kwargs): """Compute voting results to decide the winner(s) from the :attr:`votes`. The votes should have been made for the current :attr:`~creamas.vote.VoteOrganizer.candidates`. :param voting_method: ...
python
def compute_results(self, voting_method, votes=None, winners=1, **kwargs): """Compute voting results to decide the winner(s) from the :attr:`votes`. The votes should have been made for the current :attr:`~creamas.vote.VoteOrganizer.candidates`. :param voting_method: ...
[ "def", "compute_results", "(", "self", ",", "voting_method", ",", "votes", "=", "None", ",", "winners", "=", "1", ",", "*", "*", "kwargs", ")", ":", "if", "votes", "is", "None", ":", "votes", "=", "self", ".", "votes", "if", "len", "(", "votes", ")...
Compute voting results to decide the winner(s) from the :attr:`votes`. The votes should have been made for the current :attr:`~creamas.vote.VoteOrganizer.candidates`. :param voting_method: A function which computes the results from the votes. Should accept at le...
[ "Compute", "voting", "results", "to", "decide", "the", "winner", "(", "s", ")", "from", "the", ":", "attr", ":", "votes", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/vote.py#L391-L432
train
Compute the results of voting_method on the current set of candidate entries votes and winners.
uogbuji/versa
tools/py/writer/ntriples.py
write
def write(models, out=None, base=None, logger=logging): ''' models - one or more input Versa models from which output is generated. ''' assert out is not None #Output stream required if not isinstance(models, list): models = [models] for m in models: for link in m.match(): s,...
python
def write(models, out=None, base=None, logger=logging): ''' models - one or more input Versa models from which output is generated. ''' assert out is not None #Output stream required if not isinstance(models, list): models = [models] for m in models: for link in m.match(): s,...
[ "def", "write", "(", "models", ",", "out", "=", "None", ",", "base", "=", "None", ",", "logger", "=", "logging", ")", ":", "assert", "out", "is", "not", "None", "#Output stream required", "if", "not", "isinstance", "(", "models", ",", "list", ")", ":",...
models - one or more input Versa models from which output is generated.
[ "models", "-", "one", "or", "more", "input", "Versa", "models", "from", "which", "output", "is", "generated", "." ]
f092ffc7ed363a5b170890955168500f32de0dd5
https://github.com/uogbuji/versa/blob/f092ffc7ed363a5b170890955168500f32de0dd5/tools/py/writer/ntriples.py#L33-L49
train
Write Versa models to a file.
TheGhouls/oct
oct/utilities/run_device.py
start_device
def start_device(name, frontend, backend): """Start specified device :param str name: name of the device, MUST match one of ['forwarder', 'streamer'] :param int frontend: frontend bind port for device :param int backend: backend bind port for device """ device = getattr(devices, name) devic...
python
def start_device(name, frontend, backend): """Start specified device :param str name: name of the device, MUST match one of ['forwarder', 'streamer'] :param int frontend: frontend bind port for device :param int backend: backend bind port for device """ device = getattr(devices, name) devic...
[ "def", "start_device", "(", "name", ",", "frontend", ",", "backend", ")", ":", "device", "=", "getattr", "(", "devices", ",", "name", ")", "device", "(", "frontend", ",", "backend", ")" ]
Start specified device :param str name: name of the device, MUST match one of ['forwarder', 'streamer'] :param int frontend: frontend bind port for device :param int backend: backend bind port for device
[ "Start", "specified", "device" ]
7e9bddeb3b8495a26442b1c86744e9fb187fe88f
https://github.com/TheGhouls/oct/blob/7e9bddeb3b8495a26442b1c86744e9fb187fe88f/oct/utilities/run_device.py#L8-L16
train
Start a device in the cluster.
TheGhouls/oct
oct/utilities/run_device.py
run_device_command
def run_device_command(sp): """ Main function to run oct tests. """ parser = sp.add_parser('run-device', help="run an oct device for multi-HQ tests") parser.add_argument('device', help="The project directory", choices=['forwarder', 'streamer']) parser.add_argument('-f', '--frontend', help="front...
python
def run_device_command(sp): """ Main function to run oct tests. """ parser = sp.add_parser('run-device', help="run an oct device for multi-HQ tests") parser.add_argument('device', help="The project directory", choices=['forwarder', 'streamer']) parser.add_argument('-f', '--frontend', help="front...
[ "def", "run_device_command", "(", "sp", ")", ":", "parser", "=", "sp", ".", "add_parser", "(", "'run-device'", ",", "help", "=", "\"run an oct device for multi-HQ tests\"", ")", "parser", ".", "add_argument", "(", "'device'", ",", "help", "=", "\"The project direc...
Main function to run oct tests.
[ "Main", "function", "to", "run", "oct", "tests", "." ]
7e9bddeb3b8495a26442b1c86744e9fb187fe88f
https://github.com/TheGhouls/oct/blob/7e9bddeb3b8495a26442b1c86744e9fb187fe88f/oct/utilities/run_device.py#L23-L32
train
Command line interface for oct device
TheGhouls/oct
oct/core/turrets_manager.py
TurretsManager.start
def start(self, transaction_context=None): """Publish start message to all turrets """ transaction_context = transaction_context or {} context_cmd = {'command': 'set_transaction_context', 'msg': transaction_context} self.publish(context_cmd) self.pu...
python
def start(self, transaction_context=None): """Publish start message to all turrets """ transaction_context = transaction_context or {} context_cmd = {'command': 'set_transaction_context', 'msg': transaction_context} self.publish(context_cmd) self.pu...
[ "def", "start", "(", "self", ",", "transaction_context", "=", "None", ")", ":", "transaction_context", "=", "transaction_context", "or", "{", "}", "context_cmd", "=", "{", "'command'", ":", "'set_transaction_context'", ",", "'msg'", ":", "transaction_context", "}"...
Publish start message to all turrets
[ "Publish", "start", "message", "to", "all", "turrets" ]
7e9bddeb3b8495a26442b1c86744e9fb187fe88f
https://github.com/TheGhouls/oct/blob/7e9bddeb3b8495a26442b1c86744e9fb187fe88f/oct/core/turrets_manager.py#L32-L39
train
Publish start message to all turrets
TheGhouls/oct
oct/core/turrets_manager.py
TurretsManager.process_message
def process_message(self, message, is_started=False): """Process incomming message from turret :param dict message: incomming message :param bool is_started: test started indicator """ if not self.master: return False if 'status' not in message: ...
python
def process_message(self, message, is_started=False): """Process incomming message from turret :param dict message: incomming message :param bool is_started: test started indicator """ if not self.master: return False if 'status' not in message: ...
[ "def", "process_message", "(", "self", ",", "message", ",", "is_started", "=", "False", ")", ":", "if", "not", "self", ".", "master", ":", "return", "False", "if", "'status'", "not", "in", "message", ":", "return", "False", "message", "[", "'name'", "]",...
Process incomming message from turret :param dict message: incomming message :param bool is_started: test started indicator
[ "Process", "incomming", "message", "from", "turret" ]
7e9bddeb3b8495a26442b1c86744e9fb187fe88f
https://github.com/TheGhouls/oct/blob/7e9bddeb3b8495a26442b1c86744e9fb187fe88f/oct/core/turrets_manager.py#L51-L66
train
Process a message from the master
TheGhouls/oct
oct/core/turrets_manager.py
TurretsManager.add
def add(self, turret_data, is_started=False): """Add a turret object to current turrets configuration :param dict turret_data: the data of the turret to add :param bool is_started: tell if test are already runing """ if turret_data.get('uuid') in self.turrets: return...
python
def add(self, turret_data, is_started=False): """Add a turret object to current turrets configuration :param dict turret_data: the data of the turret to add :param bool is_started: tell if test are already runing """ if turret_data.get('uuid') in self.turrets: return...
[ "def", "add", "(", "self", ",", "turret_data", ",", "is_started", "=", "False", ")", ":", "if", "turret_data", ".", "get", "(", "'uuid'", ")", "in", "self", ".", "turrets", ":", "return", "False", "turret", "=", "Turret", "(", "*", "*", "turret_data", ...
Add a turret object to current turrets configuration :param dict turret_data: the data of the turret to add :param bool is_started: tell if test are already runing
[ "Add", "a", "turret", "object", "to", "current", "turrets", "configuration" ]
7e9bddeb3b8495a26442b1c86744e9fb187fe88f
https://github.com/TheGhouls/oct/blob/7e9bddeb3b8495a26442b1c86744e9fb187fe88f/oct/core/turrets_manager.py#L68-L84
train
Adds a turret object to the current turrets configuration
TheGhouls/oct
oct/core/turrets_manager.py
TurretsManager.update
def update(self, turret_data): """Update a given turret :param dict turret_data: the data of the turret to update """ if turret_data.get('uuid') not in self.turrets: return False turret = self.turrets[turret_data.get('uuid')] turret.update(**turret_data) ...
python
def update(self, turret_data): """Update a given turret :param dict turret_data: the data of the turret to update """ if turret_data.get('uuid') not in self.turrets: return False turret = self.turrets[turret_data.get('uuid')] turret.update(**turret_data) ...
[ "def", "update", "(", "self", ",", "turret_data", ")", ":", "if", "turret_data", ".", "get", "(", "'uuid'", ")", "not", "in", "self", ".", "turrets", ":", "return", "False", "turret", "=", "self", ".", "turrets", "[", "turret_data", ".", "get", "(", ...
Update a given turret :param dict turret_data: the data of the turret to update
[ "Update", "a", "given", "turret" ]
7e9bddeb3b8495a26442b1c86744e9fb187fe88f
https://github.com/TheGhouls/oct/blob/7e9bddeb3b8495a26442b1c86744e9fb187fe88f/oct/core/turrets_manager.py#L86-L96
train
Update a given turret with the given data
TheGhouls/oct
oct/core/turrets_manager.py
TurretsManager.publish
def publish(self, message, channel=None): """Publish a message for all turrets :param dict message: message to send to turrets :pram str channel: channel to send message, default to empty string """ if not self.master: return channel = channel or '' d...
python
def publish(self, message, channel=None): """Publish a message for all turrets :param dict message: message to send to turrets :pram str channel: channel to send message, default to empty string """ if not self.master: return channel = channel or '' d...
[ "def", "publish", "(", "self", ",", "message", ",", "channel", "=", "None", ")", ":", "if", "not", "self", ".", "master", ":", "return", "channel", "=", "channel", "or", "''", "data", "=", "json", ".", "dumps", "(", "message", ")", "self", ".", "pu...
Publish a message for all turrets :param dict message: message to send to turrets :pram str channel: channel to send message, default to empty string
[ "Publish", "a", "message", "for", "all", "turrets" ]
7e9bddeb3b8495a26442b1c86744e9fb187fe88f
https://github.com/TheGhouls/oct/blob/7e9bddeb3b8495a26442b1c86744e9fb187fe88f/oct/core/turrets_manager.py#L106-L116
train
Publish a message to all turrets
berkeley-cocosci/Wallace
wallace/recruiters.py
SimulatedRecruiter.recruit_participants
def recruit_participants(self, n=1, exp=None): """Recruit n participants.""" for i in xrange(n): newcomer = exp.agent_type() exp.newcomer_arrival_trigger(newcomer)
python
def recruit_participants(self, n=1, exp=None): """Recruit n participants.""" for i in xrange(n): newcomer = exp.agent_type() exp.newcomer_arrival_trigger(newcomer)
[ "def", "recruit_participants", "(", "self", ",", "n", "=", "1", ",", "exp", "=", "None", ")", ":", "for", "i", "in", "xrange", "(", "n", ")", ":", "newcomer", "=", "exp", ".", "agent_type", "(", ")", "exp", ".", "newcomer_arrival_trigger", "(", "newc...
Recruit n participants.
[ "Recruit", "n", "participants", "." ]
3650c0bc3b0804d0adb1d178c5eba9992babb1b0
https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/wallace/recruiters.py#L63-L67
train
Recruit n participants.
berkeley-cocosci/Wallace
wallace/recruiters.py
PsiTurkRecruiter.open_recruitment
def open_recruitment(self, n=1): """Open recruitment for the first HIT, unless it's already open.""" from psiturk.amt_services import MTurkServices, RDSServices from psiturk.psiturk_shell import PsiturkNetworkShell from psiturk.psiturk_org_services import PsiturkOrgServices psit...
python
def open_recruitment(self, n=1): """Open recruitment for the first HIT, unless it's already open.""" from psiturk.amt_services import MTurkServices, RDSServices from psiturk.psiturk_shell import PsiturkNetworkShell from psiturk.psiturk_org_services import PsiturkOrgServices psit...
[ "def", "open_recruitment", "(", "self", ",", "n", "=", "1", ")", ":", "from", "psiturk", ".", "amt_services", "import", "MTurkServices", ",", "RDSServices", "from", "psiturk", ".", "psiturk_shell", "import", "PsiturkNetworkShell", "from", "psiturk", ".", "psitur...
Open recruitment for the first HIT, unless it's already open.
[ "Open", "recruitment", "for", "the", "first", "HIT", "unless", "it", "s", "already", "open", "." ]
3650c0bc3b0804d0adb1d178c5eba9992babb1b0
https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/wallace/recruiters.py#L102-L150
train
Open recruitment for the first HIT unless it s already open.
berkeley-cocosci/Wallace
wallace/recruiters.py
PsiTurkRecruiter.recruit_participants
def recruit_participants(self, n=1): """Recruit n participants.""" auto_recruit = os.environ['auto_recruit'] == 'true' if auto_recruit: print "Starting Wallace's recruit_participants." hit_id = str( Participant.query. with_entities(Parti...
python
def recruit_participants(self, n=1): """Recruit n participants.""" auto_recruit = os.environ['auto_recruit'] == 'true' if auto_recruit: print "Starting Wallace's recruit_participants." hit_id = str( Participant.query. with_entities(Parti...
[ "def", "recruit_participants", "(", "self", ",", "n", "=", "1", ")", ":", "auto_recruit", "=", "os", ".", "environ", "[", "'auto_recruit'", "]", "==", "'true'", "if", "auto_recruit", ":", "print", "\"Starting Wallace's recruit_participants.\"", "hit_id", "=", "s...
Recruit n participants.
[ "Recruit", "n", "participants", "." ]
3650c0bc3b0804d0adb1d178c5eba9992babb1b0
https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/wallace/recruiters.py#L152-L194
train
Recruit n participants.
berkeley-cocosci/Wallace
wallace/recruiters.py
PsiTurkRecruiter.approve_hit
def approve_hit(self, assignment_id): """Approve the HIT.""" from psiturk.amt_services import MTurkServices self.amt_services = MTurkServices( self.aws_access_key_id, self.aws_secret_access_key, self.config.getboolean( 'Shell Parameters', 'lau...
python
def approve_hit(self, assignment_id): """Approve the HIT.""" from psiturk.amt_services import MTurkServices self.amt_services = MTurkServices( self.aws_access_key_id, self.aws_secret_access_key, self.config.getboolean( 'Shell Parameters', 'lau...
[ "def", "approve_hit", "(", "self", ",", "assignment_id", ")", ":", "from", "psiturk", ".", "amt_services", "import", "MTurkServices", "self", ".", "amt_services", "=", "MTurkServices", "(", "self", ".", "aws_access_key_id", ",", "self", ".", "aws_secret_access_key...
Approve the HIT.
[ "Approve", "the", "HIT", "." ]
3650c0bc3b0804d0adb1d178c5eba9992babb1b0
https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/wallace/recruiters.py#L196-L205
train
Approve the HIT.
berkeley-cocosci/Wallace
wallace/recruiters.py
PsiTurkRecruiter.reward_bonus
def reward_bonus(self, assignment_id, amount, reason): """Reward the Turker with a bonus.""" from psiturk.amt_services import MTurkServices self.amt_services = MTurkServices( self.aws_access_key_id, self.aws_secret_access_key, self.config.getboolean( ...
python
def reward_bonus(self, assignment_id, amount, reason): """Reward the Turker with a bonus.""" from psiturk.amt_services import MTurkServices self.amt_services = MTurkServices( self.aws_access_key_id, self.aws_secret_access_key, self.config.getboolean( ...
[ "def", "reward_bonus", "(", "self", ",", "assignment_id", ",", "amount", ",", "reason", ")", ":", "from", "psiturk", ".", "amt_services", "import", "MTurkServices", "self", ".", "amt_services", "=", "MTurkServices", "(", "self", ".", "aws_access_key_id", ",", ...
Reward the Turker with a bonus.
[ "Reward", "the", "Turker", "with", "a", "bonus", "." ]
3650c0bc3b0804d0adb1d178c5eba9992babb1b0
https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/wallace/recruiters.py#L207-L216
train
Reward the Turker with a bonus.
MacHu-GWU/sqlalchemy_mate-project
sqlalchemy_mate/orm/extended_declarative_base.py
ExtendedBase.keys
def keys(cls): """ return list of all declared columns. :rtype: List[str] """ if cls._cache_keys is None: cls._cache_keys = [c.name for c in cls.__table__._columns] return cls._cache_keys
python
def keys(cls): """ return list of all declared columns. :rtype: List[str] """ if cls._cache_keys is None: cls._cache_keys = [c.name for c in cls.__table__._columns] return cls._cache_keys
[ "def", "keys", "(", "cls", ")", ":", "if", "cls", ".", "_cache_keys", "is", "None", ":", "cls", ".", "_cache_keys", "=", "[", "c", ".", "name", "for", "c", "in", "cls", ".", "__table__", ".", "_columns", "]", "return", "cls", ".", "_cache_keys" ]
return list of all declared columns. :rtype: List[str]
[ "return", "list", "of", "all", "declared", "columns", "." ]
946754744c8870f083fd7b4339fca15d1d6128b2
https://github.com/MacHu-GWU/sqlalchemy_mate-project/blob/946754744c8870f083fd7b4339fca15d1d6128b2/sqlalchemy_mate/orm/extended_declarative_base.py#L134-L142
train
return list of all declared columns
MacHu-GWU/sqlalchemy_mate-project
sqlalchemy_mate/orm/extended_declarative_base.py
ExtendedBase.glance
def glance(self): # pragma: no cover """ Print itself, only display attributes defined in :attr:`ExtendedBase._settings_major_attrs` """ if self._settings_major_attrs is None: msg = ("Please specify attributes you want to include " "in `class._sett...
python
def glance(self): # pragma: no cover """ Print itself, only display attributes defined in :attr:`ExtendedBase._settings_major_attrs` """ if self._settings_major_attrs is None: msg = ("Please specify attributes you want to include " "in `class._sett...
[ "def", "glance", "(", "self", ")", ":", "# pragma: no cover", "if", "self", ".", "_settings_major_attrs", "is", "None", ":", "msg", "=", "(", "\"Please specify attributes you want to include \"", "\"in `class._settings_major_attrs`!\"", ")", "raise", "NotImplementedError", ...
Print itself, only display attributes defined in :attr:`ExtendedBase._settings_major_attrs`
[ "Print", "itself", "only", "display", "attributes", "defined", "in", ":", "attr", ":", "ExtendedBase", ".", "_settings_major_attrs" ]
946754744c8870f083fd7b4339fca15d1d6128b2
https://github.com/MacHu-GWU/sqlalchemy_mate-project/blob/946754744c8870f083fd7b4339fca15d1d6128b2/sqlalchemy_mate/orm/extended_declarative_base.py#L200-L223
train
Print itself only display attributes defined in
MacHu-GWU/sqlalchemy_mate-project
sqlalchemy_mate/orm/extended_declarative_base.py
ExtendedBase.absorb
def absorb(self, other, ignore_none=True): """ For attributes of others that value is not None, assign it to self. :type data: ExtendedBase :type ignore_none: bool **中文文档** 将另一个文档中的数据更新到本条文档。当且仅当数据值不为None时。 """ if not isinstance(other, self.__class__): ...
python
def absorb(self, other, ignore_none=True): """ For attributes of others that value is not None, assign it to self. :type data: ExtendedBase :type ignore_none: bool **中文文档** 将另一个文档中的数据更新到本条文档。当且仅当数据值不为None时。 """ if not isinstance(other, self.__class__): ...
[ "def", "absorb", "(", "self", ",", "other", ",", "ignore_none", "=", "True", ")", ":", "if", "not", "isinstance", "(", "other", ",", "self", ".", "__class__", ")", ":", "raise", "TypeError", "(", "\"`other` has to be a instance of %s!\"", "%", "self", ".", ...
For attributes of others that value is not None, assign it to self. :type data: ExtendedBase :type ignore_none: bool **中文文档** 将另一个文档中的数据更新到本条文档。当且仅当数据值不为None时。
[ "For", "attributes", "of", "others", "that", "value", "is", "not", "None", "assign", "it", "to", "self", "." ]
946754744c8870f083fd7b4339fca15d1d6128b2
https://github.com/MacHu-GWU/sqlalchemy_mate-project/blob/946754744c8870f083fd7b4339fca15d1d6128b2/sqlalchemy_mate/orm/extended_declarative_base.py#L225-L248
train
This method absorbs the current object with the contents of the other object.
MacHu-GWU/sqlalchemy_mate-project
sqlalchemy_mate/orm/extended_declarative_base.py
ExtendedBase.revise
def revise(self, data, ignore_none=True): """ Revise attributes value with dictionary data. :type data: dict :type ignore_none: bool **中文文档** 将一个字典中的数据更新到本条文档。当且仅当数据值不为None时。 """ if not isinstance(data, dict): raise TypeError("`data` has to ...
python
def revise(self, data, ignore_none=True): """ Revise attributes value with dictionary data. :type data: dict :type ignore_none: bool **中文文档** 将一个字典中的数据更新到本条文档。当且仅当数据值不为None时。 """ if not isinstance(data, dict): raise TypeError("`data` has to ...
[ "def", "revise", "(", "self", ",", "data", ",", "ignore_none", "=", "True", ")", ":", "if", "not", "isinstance", "(", "data", ",", "dict", ")", ":", "raise", "TypeError", "(", "\"`data` has to be a dict!\"", ")", "if", "ignore_none", ":", "for", "key", "...
Revise attributes value with dictionary data. :type data: dict :type ignore_none: bool **中文文档** 将一个字典中的数据更新到本条文档。当且仅当数据值不为None时。
[ "Revise", "attributes", "value", "with", "dictionary", "data", "." ]
946754744c8870f083fd7b4339fca15d1d6128b2
https://github.com/MacHu-GWU/sqlalchemy_mate-project/blob/946754744c8870f083fd7b4339fca15d1d6128b2/sqlalchemy_mate/orm/extended_declarative_base.py#L250-L272
train
Revise attributes value with dictionary data.
MacHu-GWU/sqlalchemy_mate-project
sqlalchemy_mate/orm/extended_declarative_base.py
ExtendedBase.random
def random(cls, engine_or_session, limit=5): """ Return random ORM instance. :type engine_or_session: Union[Engine, Session] :type limit: int :rtype: List[ExtendedBase] """ ses, auto_close = ensure_session(engine_or_session) result = ses.query(cls).order...
python
def random(cls, engine_or_session, limit=5): """ Return random ORM instance. :type engine_or_session: Union[Engine, Session] :type limit: int :rtype: List[ExtendedBase] """ ses, auto_close = ensure_session(engine_or_session) result = ses.query(cls).order...
[ "def", "random", "(", "cls", ",", "engine_or_session", ",", "limit", "=", "5", ")", ":", "ses", ",", "auto_close", "=", "ensure_session", "(", "engine_or_session", ")", "result", "=", "ses", ".", "query", "(", "cls", ")", ".", "order_by", "(", "func", ...
Return random ORM instance. :type engine_or_session: Union[Engine, Session] :type limit: int :rtype: List[ExtendedBase]
[ "Return", "random", "ORM", "instance", "." ]
946754744c8870f083fd7b4339fca15d1d6128b2
https://github.com/MacHu-GWU/sqlalchemy_mate-project/blob/946754744c8870f083fd7b4339fca15d1d6128b2/sqlalchemy_mate/orm/extended_declarative_base.py#L413-L426
train
Return random ORM instance.
RedKrieg/pysparklines
sparkline/sparkline.py
guess_series
def guess_series(input_string): u"""Tries to convert <input_string> into a list of floats. Example: >>> guess_series("0.5 1.2 3.5 7.3 8 12.5, 13.2," ... "15.0, 14.2, 11.8, 6.1, 1.9") [0.5, 1.2, 3.5, 7.3, 8.0, 12.5, 13.2, 15.0, 14.2, 11.8, 6.1, 1.9] """ float_finder = re.compile("([-+]?[0-9]...
python
def guess_series(input_string): u"""Tries to convert <input_string> into a list of floats. Example: >>> guess_series("0.5 1.2 3.5 7.3 8 12.5, 13.2," ... "15.0, 14.2, 11.8, 6.1, 1.9") [0.5, 1.2, 3.5, 7.3, 8.0, 12.5, 13.2, 15.0, 14.2, 11.8, 6.1, 1.9] """ float_finder = re.compile("([-+]?[0-9]...
[ "def", "guess_series", "(", "input_string", ")", ":", "float_finder", "=", "re", ".", "compile", "(", "\"([-+]?[0-9]*\\.?[0-9]+(?:[eE][-+]?[0-9]+)?)\"", ")", "return", "(", "[", "i", "for", "i", "in", "[", "_convert_to_float", "(", "j", ")", "for", "j", "in", ...
u"""Tries to convert <input_string> into a list of floats. Example: >>> guess_series("0.5 1.2 3.5 7.3 8 12.5, 13.2," ... "15.0, 14.2, 11.8, 6.1, 1.9") [0.5, 1.2, 3.5, 7.3, 8.0, 12.5, 13.2, 15.0, 14.2, 11.8, 6.1, 1.9]
[ "u", "Tries", "to", "convert", "<input_string", ">", "into", "a", "list", "of", "floats", "." ]
7efdc98f841a0003e138a93c4e27cd71a64e7062
https://github.com/RedKrieg/pysparklines/blob/7efdc98f841a0003e138a93c4e27cd71a64e7062/sparkline/sparkline.py#L41-L55
train
u Try to convert input_string into a list of floats.
RedKrieg/pysparklines
sparkline/sparkline.py
main
def main(): u"""Reads from command line args or stdin and prints a sparkline from the data. Requires at least 2 data points as input. """ import argparse from pkg_resources import require parser = argparse.ArgumentParser(description=main.__doc__) parser.add_argument( "data", ...
python
def main(): u"""Reads from command line args or stdin and prints a sparkline from the data. Requires at least 2 data points as input. """ import argparse from pkg_resources import require parser = argparse.ArgumentParser(description=main.__doc__) parser.add_argument( "data", ...
[ "def", "main", "(", ")", ":", "import", "argparse", "from", "pkg_resources", "import", "require", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "main", ".", "__doc__", ")", "parser", ".", "add_argument", "(", "\"data\"", ",", "na...
u"""Reads from command line args or stdin and prints a sparkline from the data. Requires at least 2 data points as input.
[ "u", "Reads", "from", "command", "line", "args", "or", "stdin", "and", "prints", "a", "sparkline", "from", "the", "data", ".", "Requires", "at", "least", "2", "data", "points", "as", "input", "." ]
7efdc98f841a0003e138a93c4e27cd71a64e7062
https://github.com/RedKrieg/pysparklines/blob/7efdc98f841a0003e138a93c4e27cd71a64e7062/sparkline/sparkline.py#L57-L97
train
u Main function for the Sparkline command line interface.
uogbuji/versa
tools/py/reader/rdfalite.py
toversa
def toversa(htmlsource, model, source_uri): ''' >>> import urllib >>> from versa.reader import rdfalite >>> from versa.driver import memory >>> m = memory.connection() >>> burl = 'http://link.delawarelibrary.org/' >>> with urllib.request.urlopen(burl) as resourcefp: rdfalite.toversa(resource...
python
def toversa(htmlsource, model, source_uri): ''' >>> import urllib >>> from versa.reader import rdfalite >>> from versa.driver import memory >>> m = memory.connection() >>> burl = 'http://link.delawarelibrary.org/' >>> with urllib.request.urlopen(burl) as resourcefp: rdfalite.toversa(resource...
[ "def", "toversa", "(", "htmlsource", ",", "model", ",", "source_uri", ")", ":", "sink", "=", "versalinks", "(", "model", ")", "next", "(", "sink", ")", "#Prime the coroutine", "return", "parse", "(", "htmlsource", ",", "sink", ",", "source_uri", ")" ]
>>> import urllib >>> from versa.reader import rdfalite >>> from versa.driver import memory >>> m = memory.connection() >>> burl = 'http://link.delawarelibrary.org/' >>> with urllib.request.urlopen(burl) as resourcefp: rdfalite.toversa(resourcefp.read(), m, burl)
[ ">>>", "import", "urllib", ">>>", "from", "versa", ".", "reader", "import", "rdfalite", ">>>", "from", "versa", ".", "driver", "import", "memory", ">>>", "m", "=", "memory", ".", "connection", "()", ">>>", "burl", "=", "http", ":", "//", "link", ".", "...
f092ffc7ed363a5b170890955168500f32de0dd5
https://github.com/uogbuji/versa/blob/f092ffc7ed363a5b170890955168500f32de0dd5/tools/py/reader/rdfalite.py#L39-L51
train
Parse a HTML source with the given model and return a tuple of the resulting HTML.
clement-alexandre/TotemBionet
totembionet/src/discrete_model/multiplex.py
Multiplex.is_active
def is_active(self, state: 'State') -> bool: """ Return True if the multiplex is active in the given state, false otherwise. """ # Remove the genes which does not contribute to the multiplex sub_state = state.sub_state_by_gene_name(*self.expression.variables) # If this state is not in th...
python
def is_active(self, state: 'State') -> bool: """ Return True if the multiplex is active in the given state, false otherwise. """ # Remove the genes which does not contribute to the multiplex sub_state = state.sub_state_by_gene_name(*self.expression.variables) # If this state is not in th...
[ "def", "is_active", "(", "self", ",", "state", ":", "'State'", ")", "->", "bool", ":", "# Remove the genes which does not contribute to the multiplex", "sub_state", "=", "state", ".", "sub_state_by_gene_name", "(", "*", "self", ".", "expression", ".", "variables", "...
Return True if the multiplex is active in the given state, false otherwise.
[ "Return", "True", "if", "the", "multiplex", "is", "active", "in", "the", "given", "state", "false", "otherwise", "." ]
f37a2f9358c1ce49f21c4a868b904da5dcd4614f
https://github.com/clement-alexandre/TotemBionet/blob/f37a2f9358c1ce49f21c4a868b904da5dcd4614f/totembionet/src/discrete_model/multiplex.py#L21-L30
train
Return True if the multiplex is active in the given state False otherwise.
aacanakin/glim
glim/core.py
Registry.get
def get(self, key): """ Function deeply gets the key with "." notation Args ---- key (string): A key with the "." notation. Returns ------- reg (unknown type): Returns a dict or a primitive type. """ try: layer...
python
def get(self, key): """ Function deeply gets the key with "." notation Args ---- key (string): A key with the "." notation. Returns ------- reg (unknown type): Returns a dict or a primitive type. """ try: layer...
[ "def", "get", "(", "self", ",", "key", ")", ":", "try", ":", "layers", "=", "key", ".", "split", "(", "'.'", ")", "value", "=", "self", ".", "registrar", "for", "key", "in", "layers", ":", "value", "=", "value", "[", "key", "]", "return", "value"...
Function deeply gets the key with "." notation Args ---- key (string): A key with the "." notation. Returns ------- reg (unknown type): Returns a dict or a primitive type.
[ "Function", "deeply", "gets", "the", "key", "with", ".", "notation" ]
71a20ac149a1292c0d6c1dc7414985ea51854f7a
https://github.com/aacanakin/glim/blob/71a20ac149a1292c0d6c1dc7414985ea51854f7a/glim/core.py#L34-L54
train
Function deeply gets the key with. notation Returns None if no such key exists
aacanakin/glim
glim/core.py
Registry.set
def set(self, key, value): """ Function deeply sets the key with "." notation Args ---- key (string): A key with the "." notation. value (unknown type): A dict or a primitive type. """ target = self.registrar for element in key.split('.')[:-1]...
python
def set(self, key, value): """ Function deeply sets the key with "." notation Args ---- key (string): A key with the "." notation. value (unknown type): A dict or a primitive type. """ target = self.registrar for element in key.split('.')[:-1]...
[ "def", "set", "(", "self", ",", "key", ",", "value", ")", ":", "target", "=", "self", ".", "registrar", "for", "element", "in", "key", ".", "split", "(", "'.'", ")", "[", ":", "-", "1", "]", ":", "target", "=", "target", ".", "setdefault", "(", ...
Function deeply sets the key with "." notation Args ---- key (string): A key with the "." notation. value (unknown type): A dict or a primitive type.
[ "Function", "deeply", "sets", "the", "key", "with", ".", "notation" ]
71a20ac149a1292c0d6c1dc7414985ea51854f7a
https://github.com/aacanakin/glim/blob/71a20ac149a1292c0d6c1dc7414985ea51854f7a/glim/core.py#L56-L68
train
Function deeply sets the key with. notation
aacanakin/glim
glim/core.py
Facade.boot
def boot(cls, *args, **kwargs): """ Function creates the instance of accessor with dynamic positional & keyword arguments. Args ---- args (positional arguments): the positional arguments that are passed to the class of accessor. kwargs (keyword ar...
python
def boot(cls, *args, **kwargs): """ Function creates the instance of accessor with dynamic positional & keyword arguments. Args ---- args (positional arguments): the positional arguments that are passed to the class of accessor. kwargs (keyword ar...
[ "def", "boot", "(", "cls", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "cls", ".", "accessor", "is", "not", "None", ":", "if", "cls", ".", "instance", "is", "None", ":", "cls", ".", "instance", "=", "cls", ".", "accessor", "(", "...
Function creates the instance of accessor with dynamic positional & keyword arguments. Args ---- args (positional arguments): the positional arguments that are passed to the class of accessor. kwargs (keyword arguments): the keyword arguments that are...
[ "Function", "creates", "the", "instance", "of", "accessor", "with", "dynamic", "positional", "&", "keyword", "arguments", "." ]
71a20ac149a1292c0d6c1dc7414985ea51854f7a
https://github.com/aacanakin/glim/blob/71a20ac149a1292c0d6c1dc7414985ea51854f7a/glim/core.py#L150-L164
train
Function creates the instance of the class with the given arguments.
aacanakin/glim
glim/core.py
Facade.register
def register(cls, config={}): """ This function is basically a shortcut of boot for accessors that have only the config dict argument. Args ---- config (dict): the configuration dictionary """ if cls.accessor is not None: if cls.instance is ...
python
def register(cls, config={}): """ This function is basically a shortcut of boot for accessors that have only the config dict argument. Args ---- config (dict): the configuration dictionary """ if cls.accessor is not None: if cls.instance is ...
[ "def", "register", "(", "cls", ",", "config", "=", "{", "}", ")", ":", "if", "cls", ".", "accessor", "is", "not", "None", ":", "if", "cls", ".", "instance", "is", "None", ":", "cls", ".", "instance", "=", "cls", ".", "accessor", "(", "config", ")...
This function is basically a shortcut of boot for accessors that have only the config dict argument. Args ---- config (dict): the configuration dictionary
[ "This", "function", "is", "basically", "a", "shortcut", "of", "boot", "for", "accessors", "that", "have", "only", "the", "config", "dict", "argument", "." ]
71a20ac149a1292c0d6c1dc7414985ea51854f7a
https://github.com/aacanakin/glim/blob/71a20ac149a1292c0d6c1dc7414985ea51854f7a/glim/core.py#L167-L178
train
Register a new instance of the class with the given configuration dictionary.
TUNE-Archive/freight_forwarder
freight_forwarder/freight_forwarder.py
FreightForwarder.commercial_invoice
def commercial_invoice(self, action, data_center, environment, transport_service, tagging_scheme=None): """ :param action: :param data_center: :param environment: :param transport_service: :param tagging_scheme: :return: """ if action not in ACTION...
python
def commercial_invoice(self, action, data_center, environment, transport_service, tagging_scheme=None): """ :param action: :param data_center: :param environment: :param transport_service: :param tagging_scheme: :return: """ if action not in ACTION...
[ "def", "commercial_invoice", "(", "self", ",", "action", ",", "data_center", ",", "environment", ",", "transport_service", ",", "tagging_scheme", "=", "None", ")", ":", "if", "action", "not", "in", "ACTIONS_SCHEME", ":", "raise", "LookupError", "(", "logger", ...
:param action: :param data_center: :param environment: :param transport_service: :param tagging_scheme: :return:
[ ":", "param", "action", ":", ":", "param", "data_center", ":", ":", "param", "environment", ":", ":", "param", "transport_service", ":", ":", "param", "tagging_scheme", ":", ":", "return", ":" ]
6ea4a49f474ec04abb8bb81b175c774a16b5312f
https://github.com/TUNE-Archive/freight_forwarder/blob/6ea4a49f474ec04abb8bb81b175c774a16b5312f/freight_forwarder/freight_forwarder.py#L49-L102
train
Returns a CommercialInvoice object for the given action data center environment and transport service.
TUNE-Archive/freight_forwarder
freight_forwarder/freight_forwarder.py
FreightForwarder.deploy_containers
def deploy_containers(self, commercial_invoice, tag=None, env=None): """ Deploy containers to specific container ship. 'restart_policy' = {"maximum_retry_count": 5, "name": "always"} """ commercial_invoice = self.__validate_commercial_invoice(commercial_invoice, 'deploy') ...
python
def deploy_containers(self, commercial_invoice, tag=None, env=None): """ Deploy containers to specific container ship. 'restart_policy' = {"maximum_retry_count": 5, "name": "always"} """ commercial_invoice = self.__validate_commercial_invoice(commercial_invoice, 'deploy') ...
[ "def", "deploy_containers", "(", "self", ",", "commercial_invoice", ",", "tag", "=", "None", ",", "env", "=", "None", ")", ":", "commercial_invoice", "=", "self", ".", "__validate_commercial_invoice", "(", "commercial_invoice", ",", "'deploy'", ")", "fleet", "="...
Deploy containers to specific container ship. 'restart_policy' = {"maximum_retry_count": 5, "name": "always"}
[ "Deploy", "containers", "to", "specific", "container", "ship", ".", "restart_policy", "=", "{", "maximum_retry_count", ":", "5", "name", ":", "always", "}" ]
6ea4a49f474ec04abb8bb81b175c774a16b5312f
https://github.com/TUNE-Archive/freight_forwarder/blob/6ea4a49f474ec04abb8bb81b175c774a16b5312f/freight_forwarder/freight_forwarder.py#L118-L167
train
Deploy containers to specific container ship.
TUNE-Archive/freight_forwarder
freight_forwarder/freight_forwarder.py
FreightForwarder.quality_control
def quality_control(self, commercial_invoice, attach=False, clean=None, test=None, configs=None, use_cache=False, env=None): """ :param attach: :param clean: :param test: :param configs: :return: """ commercial_invoice = self.__validate_commercial_invoice(...
python
def quality_control(self, commercial_invoice, attach=False, clean=None, test=None, configs=None, use_cache=False, env=None): """ :param attach: :param clean: :param test: :param configs: :return: """ commercial_invoice = self.__validate_commercial_invoice(...
[ "def", "quality_control", "(", "self", ",", "commercial_invoice", ",", "attach", "=", "False", ",", "clean", "=", "None", ",", "test", "=", "None", ",", "configs", "=", "None", ",", "use_cache", "=", "False", ",", "env", "=", "None", ")", ":", "commerc...
:param attach: :param clean: :param test: :param configs: :return:
[ ":", "param", "attach", ":", ":", "param", "clean", ":", ":", "param", "test", ":", ":", "param", "configs", ":", ":", "return", ":" ]
6ea4a49f474ec04abb8bb81b175c774a16b5312f
https://github.com/TUNE-Archive/freight_forwarder/blob/6ea4a49f474ec04abb8bb81b175c774a16b5312f/freight_forwarder/freight_forwarder.py#L169-L233
train
This method is used to run the quality control process.
Kortemme-Lab/klab
klab/bio/complexes.py
ProteinProteinComplex.add_pdb_set
def add_pdb_set(self, pdb_names, lchains, rchains, is_complex, notes = None): '''lchains and rchains should be lists of pairs (p, c, n) where p is a PDB object (bio/pdb.py:PDB), c is a chain identifier, and n is the NMR model number (or zero if this is not applicable). (character). This al...
python
def add_pdb_set(self, pdb_names, lchains, rchains, is_complex, notes = None): '''lchains and rchains should be lists of pairs (p, c, n) where p is a PDB object (bio/pdb.py:PDB), c is a chain identifier, and n is the NMR model number (or zero if this is not applicable). (character). This al...
[ "def", "add_pdb_set", "(", "self", ",", "pdb_names", ",", "lchains", ",", "rchains", ",", "is_complex", ",", "notes", "=", "None", ")", ":", "# If PDB objects differ and is_complex is set, raise an exception", "# This is not foolproof - we use the PDB object reference which cou...
lchains and rchains should be lists of pairs (p, c, n) where p is a PDB object (bio/pdb.py:PDB), c is a chain identifier, and n is the NMR model number (or zero if this is not applicable). (character). This allows us to represent combinations of unbound chains. is_complex should be set ...
[ "lchains", "and", "rchains", "should", "be", "lists", "of", "pairs", "(", "p", "c", "n", ")", "where", "p", "is", "a", "PDB", "object", "(", "bio", "/", "pdb", ".", "py", ":", "PDB", ")", "c", "is", "a", "chain", "identifier", "and", "n", "is", ...
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/complexes.py#L85-L139
train
Add a PDB set to the metadata.
Kortemme-Lab/klab
klab/bio/complexes.py
ProteinProteinComplex.get_complex
def get_complex(self): '''Returns the record for the complex definition to be used for database storage.''' d = dict( LName = self.lname, LShortName = self.lshortname, LHTMLName = self.lhtmlname, RName = self.rname, RShortName = self.rshortname...
python
def get_complex(self): '''Returns the record for the complex definition to be used for database storage.''' d = dict( LName = self.lname, LShortName = self.lshortname, LHTMLName = self.lhtmlname, RName = self.rname, RShortName = self.rshortname...
[ "def", "get_complex", "(", "self", ")", ":", "d", "=", "dict", "(", "LName", "=", "self", ".", "lname", ",", "LShortName", "=", "self", ".", "lshortname", ",", "LHTMLName", "=", "self", ".", "lhtmlname", ",", "RName", "=", "self", ".", "rname", ",", ...
Returns the record for the complex definition to be used for database storage.
[ "Returns", "the", "record", "for", "the", "complex", "definition", "to", "be", "used", "for", "database", "storage", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/complexes.py#L143-L162
train
Returns the record for the complex definition to be used for database storage.
Kortemme-Lab/klab
klab/bio/complexes.py
ProteinProteinComplex.get_pdb_sets
def get_pdb_sets(self): '''Return a record to be used for database storage. This only makes sense if self.id is set. See usage example above.''' assert(self.id != None) data = [] for pdb_set in self.pdb_sets: pdb_set_record = dict( PPComplexID = ...
python
def get_pdb_sets(self): '''Return a record to be used for database storage. This only makes sense if self.id is set. See usage example above.''' assert(self.id != None) data = [] for pdb_set in self.pdb_sets: pdb_set_record = dict( PPComplexID = ...
[ "def", "get_pdb_sets", "(", "self", ")", ":", "assert", "(", "self", ".", "id", "!=", "None", ")", "data", "=", "[", "]", "for", "pdb_set", "in", "self", ".", "pdb_sets", ":", "pdb_set_record", "=", "dict", "(", "PPComplexID", "=", "self", ".", "id",...
Return a record to be used for database storage. This only makes sense if self.id is set. See usage example above.
[ "Return", "a", "record", "to", "be", "used", "for", "database", "storage", ".", "This", "only", "makes", "sense", "if", "self", ".", "id", "is", "set", ".", "See", "usage", "example", "above", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/complexes.py#L166-L196
train
Return a list of dictionaries containing the information for each PDB set in the database. This only makes sense if self. id is set. See usage example above.
Kortemme-Lab/klab
klab/parsers/xml.py
parse_singular_float
def parse_singular_float(t, tag_name): '''Parses the sole floating point value with name tag_name in tag t. Heavy-handed with the asserts.''' pos = t.getElementsByTagName(tag_name) assert(len(pos) == 1) pos = pos[0] assert(len(pos.childNodes) == 1) return float(pos.childNodes[0].data)
python
def parse_singular_float(t, tag_name): '''Parses the sole floating point value with name tag_name in tag t. Heavy-handed with the asserts.''' pos = t.getElementsByTagName(tag_name) assert(len(pos) == 1) pos = pos[0] assert(len(pos.childNodes) == 1) return float(pos.childNodes[0].data)
[ "def", "parse_singular_float", "(", "t", ",", "tag_name", ")", ":", "pos", "=", "t", ".", "getElementsByTagName", "(", "tag_name", ")", "assert", "(", "len", "(", "pos", ")", "==", "1", ")", "pos", "=", "pos", "[", "0", "]", "assert", "(", "len", "...
Parses the sole floating point value with name tag_name in tag t. Heavy-handed with the asserts.
[ "Parses", "the", "sole", "floating", "point", "value", "with", "name", "tag_name", "in", "tag", "t", ".", "Heavy", "-", "handed", "with", "the", "asserts", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/parsers/xml.py#L14-L20
train
Parses the sole floating point value with name tag_name in tag t. Heavy - handed with the asserts.
Kortemme-Lab/klab
klab/parsers/xml.py
parse_singular_int
def parse_singular_int(t, tag_name): '''Parses the sole integer value with name tag_name in tag t. Heavy-handed with the asserts.''' pos = t.getElementsByTagName(tag_name) assert(len(pos) == 1) pos = pos[0] assert(len(pos.childNodes) == 1) v = pos.childNodes[0].data assert(v.isdigit()) # no ...
python
def parse_singular_int(t, tag_name): '''Parses the sole integer value with name tag_name in tag t. Heavy-handed with the asserts.''' pos = t.getElementsByTagName(tag_name) assert(len(pos) == 1) pos = pos[0] assert(len(pos.childNodes) == 1) v = pos.childNodes[0].data assert(v.isdigit()) # no ...
[ "def", "parse_singular_int", "(", "t", ",", "tag_name", ")", ":", "pos", "=", "t", ".", "getElementsByTagName", "(", "tag_name", ")", "assert", "(", "len", "(", "pos", ")", "==", "1", ")", "pos", "=", "pos", "[", "0", "]", "assert", "(", "len", "("...
Parses the sole integer value with name tag_name in tag t. Heavy-handed with the asserts.
[ "Parses", "the", "sole", "integer", "value", "with", "name", "tag_name", "in", "tag", "t", ".", "Heavy", "-", "handed", "with", "the", "asserts", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/parsers/xml.py#L22-L30
train
Parses the sole integer value with name tag_name in tag t. Heavy - handed with the asserts.
Kortemme-Lab/klab
klab/parsers/xml.py
parse_singular_alphabetic_character
def parse_singular_alphabetic_character(t, tag_name): '''Parses the sole alphabetic character value with name tag_name in tag t. Heavy-handed with the asserts.''' pos = t.getElementsByTagName(tag_name) assert(len(pos) == 1) pos = pos[0] assert(len(pos.childNodes) == 1) v = pos.childNodes[0].data...
python
def parse_singular_alphabetic_character(t, tag_name): '''Parses the sole alphabetic character value with name tag_name in tag t. Heavy-handed with the asserts.''' pos = t.getElementsByTagName(tag_name) assert(len(pos) == 1) pos = pos[0] assert(len(pos.childNodes) == 1) v = pos.childNodes[0].data...
[ "def", "parse_singular_alphabetic_character", "(", "t", ",", "tag_name", ")", ":", "pos", "=", "t", ".", "getElementsByTagName", "(", "tag_name", ")", "assert", "(", "len", "(", "pos", ")", "==", "1", ")", "pos", "=", "pos", "[", "0", "]", "assert", "(...
Parses the sole alphabetic character value with name tag_name in tag t. Heavy-handed with the asserts.
[ "Parses", "the", "sole", "alphabetic", "character", "value", "with", "name", "tag_name", "in", "tag", "t", ".", "Heavy", "-", "handed", "with", "the", "asserts", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/parsers/xml.py#L32-L40
train
Parses the sole alphabetic character value with name tag_name in tag t. Heavy - handed with the asserts.
Kortemme-Lab/klab
klab/parsers/xml.py
parse_singular_string
def parse_singular_string(t, tag_name): '''Parses the sole string value with name tag_name in tag t. Heavy-handed with the asserts.''' pos = t.getElementsByTagName(tag_name) assert(len(pos) == 1) pos = pos[0] assert(len(pos.childNodes) == 1) return pos.childNodes[0].data
python
def parse_singular_string(t, tag_name): '''Parses the sole string value with name tag_name in tag t. Heavy-handed with the asserts.''' pos = t.getElementsByTagName(tag_name) assert(len(pos) == 1) pos = pos[0] assert(len(pos.childNodes) == 1) return pos.childNodes[0].data
[ "def", "parse_singular_string", "(", "t", ",", "tag_name", ")", ":", "pos", "=", "t", ".", "getElementsByTagName", "(", "tag_name", ")", "assert", "(", "len", "(", "pos", ")", "==", "1", ")", "pos", "=", "pos", "[", "0", "]", "assert", "(", "len", ...
Parses the sole string value with name tag_name in tag t. Heavy-handed with the asserts.
[ "Parses", "the", "sole", "string", "value", "with", "name", "tag_name", "in", "tag", "t", ".", "Heavy", "-", "handed", "with", "the", "asserts", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/parsers/xml.py#L42-L48
train
Parses the sole string value with name tag_name in tag t. Heavy - handed with the asserts.
CodersOfTheNight/oshino
oshino/util.py
timer
def timer(): """ Timer used for calculate time elapsed """ if sys.platform == "win32": default_timer = time.clock else: default_timer = time.time return default_timer()
python
def timer(): """ Timer used for calculate time elapsed """ if sys.platform == "win32": default_timer = time.clock else: default_timer = time.time return default_timer()
[ "def", "timer", "(", ")", ":", "if", "sys", ".", "platform", "==", "\"win32\"", ":", "default_timer", "=", "time", ".", "clock", "else", ":", "default_timer", "=", "time", ".", "time", "return", "default_timer", "(", ")" ]
Timer used for calculate time elapsed
[ "Timer", "used", "for", "calculate", "time", "elapsed" ]
00f7e151e3ce1f3a7f43b353b695c4dba83c7f28
https://github.com/CodersOfTheNight/oshino/blob/00f7e151e3ce1f3a7f43b353b695c4dba83c7f28/oshino/util.py#L20-L29
train
Timer used for calculate time elapsed
adaptive-learning/proso-apps
proso/rand.py
roulette
def roulette(weights, n): """ Choose randomly the given number of items. The probability the item is chosen is proportionate to its weight. .. testsetup:: import random from proso.rand import roulette random.seed(1) .. testcode:: print(roulette({'cat': 2, 'dog': ...
python
def roulette(weights, n): """ Choose randomly the given number of items. The probability the item is chosen is proportionate to its weight. .. testsetup:: import random from proso.rand import roulette random.seed(1) .. testcode:: print(roulette({'cat': 2, 'dog': ...
[ "def", "roulette", "(", "weights", ",", "n", ")", ":", "if", "n", ">", "len", "(", "weights", ")", ":", "raise", "Exception", "(", "\"Can't choose {} samples from {} items\"", ".", "format", "(", "n", ",", "len", "(", "weights", ")", ")", ")", "if", "a...
Choose randomly the given number of items. The probability the item is chosen is proportionate to its weight. .. testsetup:: import random from proso.rand import roulette random.seed(1) .. testcode:: print(roulette({'cat': 2, 'dog': 1000}, 1)) .. testoutput:: ...
[ "Choose", "randomly", "the", "given", "number", "of", "items", ".", "The", "probability", "the", "item", "is", "chosen", "is", "proportionate", "to", "its", "weight", "." ]
8278c72e498d6ef8d392cc47b48473f4ec037142
https://github.com/adaptive-learning/proso-apps/blob/8278c72e498d6ef8d392cc47b48473f4ec037142/proso/rand.py#L9-L54
train
Choose randomly the given number of items.
TUNE-Archive/freight_forwarder
freight_forwarder/cli/marshaling_yard.py
MarshalingYardCommand._build_arguments
def _build_arguments(self): """ build arguments for command. """ self._parser.add_argument( '-a', '--alias', required=False, default='default', type=str, help='registry alias created in freight-forwarder.yml. Example: tune_dev' ...
python
def _build_arguments(self): """ build arguments for command. """ self._parser.add_argument( '-a', '--alias', required=False, default='default', type=str, help='registry alias created in freight-forwarder.yml. Example: tune_dev' ...
[ "def", "_build_arguments", "(", "self", ")", ":", "self", ".", "_parser", ".", "add_argument", "(", "'-a'", ",", "'--alias'", ",", "required", "=", "False", ",", "default", "=", "'default'", ",", "type", "=", "str", ",", "help", "=", "'registry alias creat...
build arguments for command.
[ "build", "arguments", "for", "command", "." ]
6ea4a49f474ec04abb8bb81b175c774a16b5312f
https://github.com/TUNE-Archive/freight_forwarder/blob/6ea4a49f474ec04abb8bb81b175c774a16b5312f/freight_forwarder/cli/marshaling_yard.py#L46-L56
train
Build command line arguments for command.
TUNE-Archive/freight_forwarder
freight_forwarder/cli/marshaling_yard.py
MarshalingYardTags._build_arguments
def _build_arguments(self): """ build arguments for command. """ self._parser.add_argument( 'image_name', metavar='IMAGE_NAME', type=six.text_type, help='Name of the image example: \"namespace/repository\"' )
python
def _build_arguments(self): """ build arguments for command. """ self._parser.add_argument( 'image_name', metavar='IMAGE_NAME', type=six.text_type, help='Name of the image example: \"namespace/repository\"' )
[ "def", "_build_arguments", "(", "self", ")", ":", "self", ".", "_parser", ".", "add_argument", "(", "'image_name'", ",", "metavar", "=", "'IMAGE_NAME'", ",", "type", "=", "six", ".", "text_type", ",", "help", "=", "'Name of the image example: \\\"namespace/reposit...
build arguments for command.
[ "build", "arguments", "for", "command", "." ]
6ea4a49f474ec04abb8bb81b175c774a16b5312f
https://github.com/TUNE-Archive/freight_forwarder/blob/6ea4a49f474ec04abb8bb81b175c774a16b5312f/freight_forwarder/cli/marshaling_yard.py#L70-L79
train
Build the command line arguments for the command.
ethan92429/onshapepy
onshapepy/uri.py
Uri.as_dict
def as_dict(self): """ Return the URI object as a dictionary""" d = {k:v for (k,v) in self.__dict__.items()} return d
python
def as_dict(self): """ Return the URI object as a dictionary""" d = {k:v for (k,v) in self.__dict__.items()} return d
[ "def", "as_dict", "(", "self", ")", ":", "d", "=", "{", "k", ":", "v", "for", "(", "k", ",", "v", ")", "in", "self", ".", "__dict__", ".", "items", "(", ")", "}", "return", "d" ]
Return the URI object as a dictionary
[ "Return", "the", "URI", "object", "as", "a", "dictionary" ]
61dc7ccbdc6095fa6cc3b4a414e2f72d03d1c9df
https://github.com/ethan92429/onshapepy/blob/61dc7ccbdc6095fa6cc3b4a414e2f72d03d1c9df/onshapepy/uri.py#L53-L56
train
Return the URI object as a dictionary
andialbrecht/sentry-comments
sentry_comments/plugin.py
CommentsPlugin.get_title
def get_title(self, group=None): """Adds number of comments to title.""" title = super(CommentsPlugin, self).get_title() if group is not None: count = GroupComments.objects.filter(group=group).count() else: count = None if count: title = u'%s (...
python
def get_title(self, group=None): """Adds number of comments to title.""" title = super(CommentsPlugin, self).get_title() if group is not None: count = GroupComments.objects.filter(group=group).count() else: count = None if count: title = u'%s (...
[ "def", "get_title", "(", "self", ",", "group", "=", "None", ")", ":", "title", "=", "super", "(", "CommentsPlugin", ",", "self", ")", ".", "get_title", "(", ")", "if", "group", "is", "not", "None", ":", "count", "=", "GroupComments", ".", "objects", ...
Adds number of comments to title.
[ "Adds", "number", "of", "comments", "to", "title", "." ]
b9319320dc3b25b6d813377e69b2d379bcbf6197
https://github.com/andialbrecht/sentry-comments/blob/b9319320dc3b25b6d813377e69b2d379bcbf6197/sentry_comments/plugin.py#L38-L47
train
Adds number of comments to title.