id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
17,200
pysathq/pysat
pysat/solvers.py
Solver.add_clause
def add_clause(self, clause, no_return=True): """ This method is used to add a single clause to the solver. An optional argument ``no_return`` controls whether or not to check the formula's satisfiability after adding the new clause. :param clause: an iterable ov...
python
def add_clause(self, clause, no_return=True): """ This method is used to add a single clause to the solver. An optional argument ``no_return`` controls whether or not to check the formula's satisfiability after adding the new clause. :param clause: an iterable ov...
[ "def", "add_clause", "(", "self", ",", "clause", ",", "no_return", "=", "True", ")", ":", "if", "self", ".", "solver", ":", "res", "=", "self", ".", "solver", ".", "add_clause", "(", "clause", ",", "no_return", ")", "if", "not", "no_return", ":", "re...
This method is used to add a single clause to the solver. An optional argument ``no_return`` controls whether or not to check the formula's satisfiability after adding the new clause. :param clause: an iterable over literals. :param no_return: check solver's internal for...
[ "This", "method", "is", "used", "to", "add", "a", "single", "clause", "to", "the", "solver", ".", "An", "optional", "argument", "no_return", "controls", "whether", "or", "not", "to", "check", "the", "formula", "s", "satisfiability", "after", "adding", "the",...
522742e8f2d4c6ac50ecd9087f7a346206774c67
https://github.com/pysathq/pysat/blob/522742e8f2d4c6ac50ecd9087f7a346206774c67/pysat/solvers.py#L825-L856
17,201
pysathq/pysat
pysat/solvers.py
Solver.append_formula
def append_formula(self, formula, no_return=True): """ This method can be used to add a given list of clauses into the solver. :param formula: a list of clauses. :param no_return: check solver's internal formula and return the result, if set to ``...
python
def append_formula(self, formula, no_return=True): """ This method can be used to add a given list of clauses into the solver. :param formula: a list of clauses. :param no_return: check solver's internal formula and return the result, if set to ``...
[ "def", "append_formula", "(", "self", ",", "formula", ",", "no_return", "=", "True", ")", ":", "if", "self", ".", "solver", ":", "res", "=", "self", ".", "solver", ".", "append_formula", "(", "formula", ",", "no_return", ")", "if", "not", "no_return", ...
This method can be used to add a given list of clauses into the solver. :param formula: a list of clauses. :param no_return: check solver's internal formula and return the result, if set to ``False``. :type formula: iterable(iterable(int)) :t...
[ "This", "method", "can", "be", "used", "to", "add", "a", "given", "list", "of", "clauses", "into", "the", "solver", "." ]
522742e8f2d4c6ac50ecd9087f7a346206774c67
https://github.com/pysathq/pysat/blob/522742e8f2d4c6ac50ecd9087f7a346206774c67/pysat/solvers.py#L896-L924
17,202
pysathq/pysat
pysat/solvers.py
Glucose4.enum_models
def enum_models(self, assumptions=[]): """ Iterate over models of the internal formula. """ if self.glucose: done = False while not done: if self.use_timer: start_time = time.clock() self.status = pysolvers...
python
def enum_models(self, assumptions=[]): """ Iterate over models of the internal formula. """ if self.glucose: done = False while not done: if self.use_timer: start_time = time.clock() self.status = pysolvers...
[ "def", "enum_models", "(", "self", ",", "assumptions", "=", "[", "]", ")", ":", "if", "self", ".", "glucose", ":", "done", "=", "False", "while", "not", "done", ":", "if", "self", ".", "use_timer", ":", "start_time", "=", "time", ".", "clock", "(", ...
Iterate over models of the internal formula.
[ "Iterate", "over", "models", "of", "the", "internal", "formula", "." ]
522742e8f2d4c6ac50ecd9087f7a346206774c67
https://github.com/pysathq/pysat/blob/522742e8f2d4c6ac50ecd9087f7a346206774c67/pysat/solvers.py#L1453-L1476
17,203
pysathq/pysat
pysat/solvers.py
MapleChrono.propagate
def propagate(self, assumptions=[], phase_saving=0): """ Propagate a given set of assumption literals. """ if self.maplesat: if self.use_timer: start_time = time.clock() # saving default SIGINT handler def_sigint_handler = signal...
python
def propagate(self, assumptions=[], phase_saving=0): """ Propagate a given set of assumption literals. """ if self.maplesat: if self.use_timer: start_time = time.clock() # saving default SIGINT handler def_sigint_handler = signal...
[ "def", "propagate", "(", "self", ",", "assumptions", "=", "[", "]", ",", "phase_saving", "=", "0", ")", ":", "if", "self", ".", "maplesat", ":", "if", "self", ".", "use_timer", ":", "start_time", "=", "time", ".", "clock", "(", ")", "# saving default S...
Propagate a given set of assumption literals.
[ "Propagate", "a", "given", "set", "of", "assumption", "literals", "." ]
522742e8f2d4c6ac50ecd9087f7a346206774c67
https://github.com/pysathq/pysat/blob/522742e8f2d4c6ac50ecd9087f7a346206774c67/pysat/solvers.py#L1892-L1913
17,204
pysathq/pysat
pysat/solvers.py
MapleChrono.get_proof
def get_proof(self): """ Get a proof produced while deciding the formula. """ if self.maplesat and self.prfile: self.prfile.seek(0) return [line.rstrip() for line in self.prfile.readlines()]
python
def get_proof(self): """ Get a proof produced while deciding the formula. """ if self.maplesat and self.prfile: self.prfile.seek(0) return [line.rstrip() for line in self.prfile.readlines()]
[ "def", "get_proof", "(", "self", ")", ":", "if", "self", ".", "maplesat", "and", "self", ".", "prfile", ":", "self", ".", "prfile", ".", "seek", "(", "0", ")", "return", "[", "line", ".", "rstrip", "(", ")", "for", "line", "in", "self", ".", "prf...
Get a proof produced while deciding the formula.
[ "Get", "a", "proof", "produced", "while", "deciding", "the", "formula", "." ]
522742e8f2d4c6ac50ecd9087f7a346206774c67
https://github.com/pysathq/pysat/blob/522742e8f2d4c6ac50ecd9087f7a346206774c67/pysat/solvers.py#L1949-L1956
17,205
pysathq/pysat
pysat/solvers.py
Minicard.add_atmost
def add_atmost(self, lits, k, no_return=True): """ Add a new atmost constraint to solver's internal formula. """ if self.minicard: res = pysolvers.minicard_add_am(self.minicard, lits, k) if res == False: self.status = False if no...
python
def add_atmost(self, lits, k, no_return=True): """ Add a new atmost constraint to solver's internal formula. """ if self.minicard: res = pysolvers.minicard_add_am(self.minicard, lits, k) if res == False: self.status = False if no...
[ "def", "add_atmost", "(", "self", ",", "lits", ",", "k", ",", "no_return", "=", "True", ")", ":", "if", "self", ".", "minicard", ":", "res", "=", "pysolvers", ".", "minicard_add_am", "(", "self", ".", "minicard", ",", "lits", ",", "k", ")", "if", "...
Add a new atmost constraint to solver's internal formula.
[ "Add", "a", "new", "atmost", "constraint", "to", "solver", "s", "internal", "formula", "." ]
522742e8f2d4c6ac50ecd9087f7a346206774c67
https://github.com/pysathq/pysat/blob/522742e8f2d4c6ac50ecd9087f7a346206774c67/pysat/solvers.py#L2885-L2897
17,206
pysathq/pysat
pysat/formula.py
IDPool.id
def id(self, obj): """ The method is to be used to assign an integer variable ID for a given new object. If the object already has an ID, no new ID is created and the old one is returned instead. An object can be anything. In some cases it is convenient to use ...
python
def id(self, obj): """ The method is to be used to assign an integer variable ID for a given new object. If the object already has an ID, no new ID is created and the old one is returned instead. An object can be anything. In some cases it is convenient to use ...
[ "def", "id", "(", "self", ",", "obj", ")", ":", "vid", "=", "self", ".", "obj2id", "[", "obj", "]", "if", "vid", "not", "in", "self", ".", "id2obj", ":", "self", ".", "id2obj", "[", "vid", "]", "=", "obj", "return", "vid" ]
The method is to be used to assign an integer variable ID for a given new object. If the object already has an ID, no new ID is created and the old one is returned instead. An object can be anything. In some cases it is convenient to use string variable names. ...
[ "The", "method", "is", "to", "be", "used", "to", "assign", "an", "integer", "variable", "ID", "for", "a", "given", "new", "object", ".", "If", "the", "object", "already", "has", "an", "ID", "no", "new", "ID", "is", "created", "and", "the", "old", "on...
522742e8f2d4c6ac50ecd9087f7a346206774c67
https://github.com/pysathq/pysat/blob/522742e8f2d4c6ac50ecd9087f7a346206774c67/pysat/formula.py#L264-L311
17,207
pysathq/pysat
pysat/formula.py
IDPool._next
def _next(self): """ Get next variable ID. Skip occupied intervals if any. """ self.top += 1 while self._occupied and self.top >= self._occupied[0][0]: if self.top <= self._occupied[0][1]: self.top = self._occupied[0][1] + 1 self._oc...
python
def _next(self): """ Get next variable ID. Skip occupied intervals if any. """ self.top += 1 while self._occupied and self.top >= self._occupied[0][0]: if self.top <= self._occupied[0][1]: self.top = self._occupied[0][1] + 1 self._oc...
[ "def", "_next", "(", "self", ")", ":", "self", ".", "top", "+=", "1", "while", "self", ".", "_occupied", "and", "self", ".", "top", ">=", "self", ".", "_occupied", "[", "0", "]", "[", "0", "]", ":", "if", "self", ".", "top", "<=", "self", ".", ...
Get next variable ID. Skip occupied intervals if any.
[ "Get", "next", "variable", "ID", ".", "Skip", "occupied", "intervals", "if", "any", "." ]
522742e8f2d4c6ac50ecd9087f7a346206774c67
https://github.com/pysathq/pysat/blob/522742e8f2d4c6ac50ecd9087f7a346206774c67/pysat/formula.py#L351-L364
17,208
pysathq/pysat
pysat/formula.py
CNF.from_file
def from_file(self, fname, comment_lead=['c'], compressed_with='use_ext'): """ Read a CNF formula from a file in the DIMACS format. A file name is expected as an argument. A default argument is ``comment_lead`` for parsing comment lines. A given file can be compressed by eith...
python
def from_file(self, fname, comment_lead=['c'], compressed_with='use_ext'): """ Read a CNF formula from a file in the DIMACS format. A file name is expected as an argument. A default argument is ``comment_lead`` for parsing comment lines. A given file can be compressed by eith...
[ "def", "from_file", "(", "self", ",", "fname", ",", "comment_lead", "=", "[", "'c'", "]", ",", "compressed_with", "=", "'use_ext'", ")", ":", "with", "FileObject", "(", "fname", ",", "mode", "=", "'r'", ",", "compression", "=", "compressed_with", ")", "a...
Read a CNF formula from a file in the DIMACS format. A file name is expected as an argument. A default argument is ``comment_lead`` for parsing comment lines. A given file can be compressed by either gzip, bzip2, or lzma. :param fname: name of a file to parse. ...
[ "Read", "a", "CNF", "formula", "from", "a", "file", "in", "the", "DIMACS", "format", ".", "A", "file", "name", "is", "expected", "as", "an", "argument", ".", "A", "default", "argument", "is", "comment_lead", "for", "parsing", "comment", "lines", ".", "A"...
522742e8f2d4c6ac50ecd9087f7a346206774c67
https://github.com/pysathq/pysat/blob/522742e8f2d4c6ac50ecd9087f7a346206774c67/pysat/formula.py#L409-L443
17,209
pysathq/pysat
pysat/formula.py
CNF.from_fp
def from_fp(self, file_pointer, comment_lead=['c']): """ Read a CNF formula from a file pointer. A file pointer should be specified as an argument. The only default argument is ``comment_lead``, which can be used for parsing specific comment lines. :p...
python
def from_fp(self, file_pointer, comment_lead=['c']): """ Read a CNF formula from a file pointer. A file pointer should be specified as an argument. The only default argument is ``comment_lead``, which can be used for parsing specific comment lines. :p...
[ "def", "from_fp", "(", "self", ",", "file_pointer", ",", "comment_lead", "=", "[", "'c'", "]", ")", ":", "self", ".", "nv", "=", "0", "self", ".", "clauses", "=", "[", "]", "self", ".", "comments", "=", "[", "]", "comment_lead", "=", "tuple", "(", ...
Read a CNF formula from a file pointer. A file pointer should be specified as an argument. The only default argument is ``comment_lead``, which can be used for parsing specific comment lines. :param file_pointer: a file pointer to read the formula from. :para...
[ "Read", "a", "CNF", "formula", "from", "a", "file", "pointer", ".", "A", "file", "pointer", "should", "be", "specified", "as", "an", "argument", ".", "The", "only", "default", "argument", "is", "comment_lead", "which", "can", "be", "used", "for", "parsing"...
522742e8f2d4c6ac50ecd9087f7a346206774c67
https://github.com/pysathq/pysat/blob/522742e8f2d4c6ac50ecd9087f7a346206774c67/pysat/formula.py#L445-L484
17,210
pysathq/pysat
pysat/formula.py
CNF.from_clauses
def from_clauses(self, clauses): """ This methods copies a list of clauses into a CNF object. :param clauses: a list of clauses. :type clauses: list(list(int)) Example: .. code-block:: python >>> from pysat.formula import CNF ...
python
def from_clauses(self, clauses): """ This methods copies a list of clauses into a CNF object. :param clauses: a list of clauses. :type clauses: list(list(int)) Example: .. code-block:: python >>> from pysat.formula import CNF ...
[ "def", "from_clauses", "(", "self", ",", "clauses", ")", ":", "self", ".", "clauses", "=", "copy", ".", "deepcopy", "(", "clauses", ")", "for", "cl", "in", "self", ".", "clauses", ":", "self", ".", "nv", "=", "max", "(", "[", "abs", "(", "l", ")"...
This methods copies a list of clauses into a CNF object. :param clauses: a list of clauses. :type clauses: list(list(int)) Example: .. code-block:: python >>> from pysat.formula import CNF >>> cnf = CNF(from_clauses=[[-1, 2], [1, -2], [...
[ "This", "methods", "copies", "a", "list", "of", "clauses", "into", "a", "CNF", "object", "." ]
522742e8f2d4c6ac50ecd9087f7a346206774c67
https://github.com/pysathq/pysat/blob/522742e8f2d4c6ac50ecd9087f7a346206774c67/pysat/formula.py#L518-L540
17,211
pysathq/pysat
pysat/formula.py
CNF.to_fp
def to_fp(self, file_pointer, comments=None): """ The method can be used to save a CNF formula into a file pointer. The file pointer is expected as an argument. Additionally, supplementary comment lines can be specified in the ``comments`` parameter. ...
python
def to_fp(self, file_pointer, comments=None): """ The method can be used to save a CNF formula into a file pointer. The file pointer is expected as an argument. Additionally, supplementary comment lines can be specified in the ``comments`` parameter. ...
[ "def", "to_fp", "(", "self", ",", "file_pointer", ",", "comments", "=", "None", ")", ":", "# saving formula's internal comments", "for", "c", "in", "self", ".", "comments", ":", "print", "(", "c", ",", "file", "=", "file_pointer", ")", "# saving externally spe...
The method can be used to save a CNF formula into a file pointer. The file pointer is expected as an argument. Additionally, supplementary comment lines can be specified in the ``comments`` parameter. :param fname: a file name where to store the formula. :par...
[ "The", "method", "can", "be", "used", "to", "save", "a", "CNF", "formula", "into", "a", "file", "pointer", ".", "The", "file", "pointer", "is", "expected", "as", "an", "argument", ".", "Additionally", "supplementary", "comment", "lines", "can", "be", "spec...
522742e8f2d4c6ac50ecd9087f7a346206774c67
https://github.com/pysathq/pysat/blob/522742e8f2d4c6ac50ecd9087f7a346206774c67/pysat/formula.py#L606-L643
17,212
pysathq/pysat
pysat/formula.py
CNF.append
def append(self, clause): """ Add one more clause to CNF formula. This method additionally updates the number of variables, i.e. variable ``self.nv``, used in the formula. :param clause: a new clause to add. :type clause: list(int) .. cod...
python
def append(self, clause): """ Add one more clause to CNF formula. This method additionally updates the number of variables, i.e. variable ``self.nv``, used in the formula. :param clause: a new clause to add. :type clause: list(int) .. cod...
[ "def", "append", "(", "self", ",", "clause", ")", ":", "self", ".", "nv", "=", "max", "(", "[", "abs", "(", "l", ")", "for", "l", "in", "clause", "]", "+", "[", "self", ".", "nv", "]", ")", "self", ".", "clauses", ".", "append", "(", "clause"...
Add one more clause to CNF formula. This method additionally updates the number of variables, i.e. variable ``self.nv``, used in the formula. :param clause: a new clause to add. :type clause: list(int) .. code-block:: python >>> from pysat.f...
[ "Add", "one", "more", "clause", "to", "CNF", "formula", ".", "This", "method", "additionally", "updates", "the", "number", "of", "variables", "i", ".", "e", ".", "variable", "self", ".", "nv", "used", "in", "the", "formula", "." ]
522742e8f2d4c6ac50ecd9087f7a346206774c67
https://github.com/pysathq/pysat/blob/522742e8f2d4c6ac50ecd9087f7a346206774c67/pysat/formula.py#L645-L664
17,213
pysathq/pysat
pysat/formula.py
WCNF.from_fp
def from_fp(self, file_pointer, comment_lead=['c']): """ Read a WCNF formula from a file pointer. A file pointer should be specified as an argument. The only default argument is ``comment_lead``, which can be used for parsing specific comment lines. :...
python
def from_fp(self, file_pointer, comment_lead=['c']): """ Read a WCNF formula from a file pointer. A file pointer should be specified as an argument. The only default argument is ``comment_lead``, which can be used for parsing specific comment lines. :...
[ "def", "from_fp", "(", "self", ",", "file_pointer", ",", "comment_lead", "=", "[", "'c'", "]", ")", ":", "self", ".", "nv", "=", "0", "self", ".", "hard", "=", "[", "]", "self", ".", "soft", "=", "[", "]", "self", ".", "wght", "=", "[", "]", ...
Read a WCNF formula from a file pointer. A file pointer should be specified as an argument. The only default argument is ``comment_lead``, which can be used for parsing specific comment lines. :param file_pointer: a file pointer to read the formula from. :par...
[ "Read", "a", "WCNF", "formula", "from", "a", "file", "pointer", ".", "A", "file", "pointer", "should", "be", "specified", "as", "an", "argument", ".", "The", "only", "default", "argument", "is", "comment_lead", "which", "can", "be", "used", "for", "parsing...
522742e8f2d4c6ac50ecd9087f7a346206774c67
https://github.com/pysathq/pysat/blob/522742e8f2d4c6ac50ecd9087f7a346206774c67/pysat/formula.py#L863-L912
17,214
pysathq/pysat
pysat/formula.py
WCNF.to_fp
def to_fp(self, file_pointer, comments=None): """ The method can be used to save a WCNF formula into a file pointer. The file pointer is expected as an argument. Additionally, supplementary comment lines can be specified in the ``comments`` parameter. ...
python
def to_fp(self, file_pointer, comments=None): """ The method can be used to save a WCNF formula into a file pointer. The file pointer is expected as an argument. Additionally, supplementary comment lines can be specified in the ``comments`` parameter. ...
[ "def", "to_fp", "(", "self", ",", "file_pointer", ",", "comments", "=", "None", ")", ":", "# saving formula's internal comments", "for", "c", "in", "self", ".", "comments", ":", "print", "(", "c", ",", "file", "=", "file_pointer", ")", "# saving externally spe...
The method can be used to save a WCNF formula into a file pointer. The file pointer is expected as an argument. Additionally, supplementary comment lines can be specified in the ``comments`` parameter. :param fname: a file name where to store the formula. :pa...
[ "The", "method", "can", "be", "used", "to", "save", "a", "WCNF", "formula", "into", "a", "file", "pointer", ".", "The", "file", "pointer", "is", "expected", "as", "an", "argument", ".", "Additionally", "supplementary", "comment", "lines", "can", "be", "spe...
522742e8f2d4c6ac50ecd9087f7a346206774c67
https://github.com/pysathq/pysat/blob/522742e8f2d4c6ac50ecd9087f7a346206774c67/pysat/formula.py#L1024-L1066
17,215
pysathq/pysat
pysat/formula.py
WCNF.append
def append(self, clause, weight=None): """ Add one more clause to WCNF formula. This method additionally updates the number of variables, i.e. variable ``self.nv``, used in the formula. The clause can be hard or soft depending on the ``weight`` argume...
python
def append(self, clause, weight=None): """ Add one more clause to WCNF formula. This method additionally updates the number of variables, i.e. variable ``self.nv``, used in the formula. The clause can be hard or soft depending on the ``weight`` argume...
[ "def", "append", "(", "self", ",", "clause", ",", "weight", "=", "None", ")", ":", "self", ".", "nv", "=", "max", "(", "[", "abs", "(", "l", ")", "for", "l", "in", "clause", "]", "+", "[", "self", ".", "nv", "]", ")", "if", "weight", ":", "...
Add one more clause to WCNF formula. This method additionally updates the number of variables, i.e. variable ``self.nv``, used in the formula. The clause can be hard or soft depending on the ``weight`` argument. If no weight is set, the clause is considered to be hard. ...
[ "Add", "one", "more", "clause", "to", "WCNF", "formula", ".", "This", "method", "additionally", "updates", "the", "number", "of", "variables", "i", ".", "e", ".", "variable", "self", ".", "nv", "used", "in", "the", "formula", "." ]
522742e8f2d4c6ac50ecd9087f7a346206774c67
https://github.com/pysathq/pysat/blob/522742e8f2d4c6ac50ecd9087f7a346206774c67/pysat/formula.py#L1068-L1104
17,216
pysathq/pysat
pysat/formula.py
CNFPlus.from_fp
def from_fp(self, file_pointer, comment_lead=['c']): """ Read a CNF+ formula from a file pointer. A file pointer should be specified as an argument. The only default argument is ``comment_lead``, which can be used for parsing specific comment lines. :...
python
def from_fp(self, file_pointer, comment_lead=['c']): """ Read a CNF+ formula from a file pointer. A file pointer should be specified as an argument. The only default argument is ``comment_lead``, which can be used for parsing specific comment lines. :...
[ "def", "from_fp", "(", "self", ",", "file_pointer", ",", "comment_lead", "=", "[", "'c'", "]", ")", ":", "self", ".", "nv", "=", "0", "self", ".", "clauses", "=", "[", "]", "self", ".", "atmosts", "=", "[", "]", "self", ".", "comments", "=", "[",...
Read a CNF+ formula from a file pointer. A file pointer should be specified as an argument. The only default argument is ``comment_lead``, which can be used for parsing specific comment lines. :param file_pointer: a file pointer to read the formula from. :par...
[ "Read", "a", "CNF", "+", "formula", "from", "a", "file", "pointer", ".", "A", "file", "pointer", "should", "be", "specified", "as", "an", "argument", ".", "The", "only", "default", "argument", "is", "comment_lead", "which", "can", "be", "used", "for", "p...
522742e8f2d4c6ac50ecd9087f7a346206774c67
https://github.com/pysathq/pysat/blob/522742e8f2d4c6ac50ecd9087f7a346206774c67/pysat/formula.py#L1239-L1291
17,217
pysathq/pysat
pysat/formula.py
CNFPlus.to_fp
def to_fp(self, file_pointer, comments=None): """ The method can be used to save a CNF+ formula into a file pointer. The file pointer is expected as an argument. Additionally, supplementary comment lines can be specified in the ``comments`` parameter. ...
python
def to_fp(self, file_pointer, comments=None): """ The method can be used to save a CNF+ formula into a file pointer. The file pointer is expected as an argument. Additionally, supplementary comment lines can be specified in the ``comments`` parameter. ...
[ "def", "to_fp", "(", "self", ",", "file_pointer", ",", "comments", "=", "None", ")", ":", "# saving formula's internal comments", "for", "c", "in", "self", ".", "comments", ":", "print", "(", "c", ",", "file", "=", "file_pointer", ")", "# saving externally spe...
The method can be used to save a CNF+ formula into a file pointer. The file pointer is expected as an argument. Additionally, supplementary comment lines can be specified in the ``comments`` parameter. :param fname: a file name where to store the formula. :pa...
[ "The", "method", "can", "be", "used", "to", "save", "a", "CNF", "+", "formula", "into", "a", "file", "pointer", ".", "The", "file", "pointer", "is", "expected", "as", "an", "argument", ".", "Additionally", "supplementary", "comment", "lines", "can", "be", ...
522742e8f2d4c6ac50ecd9087f7a346206774c67
https://github.com/pysathq/pysat/blob/522742e8f2d4c6ac50ecd9087f7a346206774c67/pysat/formula.py#L1293-L1335
17,218
pysathq/pysat
pysat/formula.py
CNFPlus.append
def append(self, clause, is_atmost=False): """ Add a single clause or a single AtMostK constraint to CNF+ formula. This method additionally updates the number of variables, i.e. variable ``self.nv``, used in the formula. If the clause is an AtMostK constraint, th...
python
def append(self, clause, is_atmost=False): """ Add a single clause or a single AtMostK constraint to CNF+ formula. This method additionally updates the number of variables, i.e. variable ``self.nv``, used in the formula. If the clause is an AtMostK constraint, th...
[ "def", "append", "(", "self", ",", "clause", ",", "is_atmost", "=", "False", ")", ":", "if", "not", "is_atmost", ":", "self", ".", "nv", "=", "max", "(", "[", "abs", "(", "l", ")", "for", "l", "in", "clause", "]", "+", "[", "self", ".", "nv", ...
Add a single clause or a single AtMostK constraint to CNF+ formula. This method additionally updates the number of variables, i.e. variable ``self.nv``, used in the formula. If the clause is an AtMostK constraint, this should be set with the use of the additional default...
[ "Add", "a", "single", "clause", "or", "a", "single", "AtMostK", "constraint", "to", "CNF", "+", "formula", ".", "This", "method", "additionally", "updates", "the", "number", "of", "variables", "i", ".", "e", ".", "variable", "self", ".", "nv", "used", "i...
522742e8f2d4c6ac50ecd9087f7a346206774c67
https://github.com/pysathq/pysat/blob/522742e8f2d4c6ac50ecd9087f7a346206774c67/pysat/formula.py#L1337-L1370
17,219
pysathq/pysat
pysat/formula.py
WCNFPlus.from_fp
def from_fp(self, file_pointer, comment_lead=['c']): """ Read a WCNF+ formula from a file pointer. A file pointer should be specified as an argument. The only default argument is ``comment_lead``, which can be used for parsing specific comment lines. ...
python
def from_fp(self, file_pointer, comment_lead=['c']): """ Read a WCNF+ formula from a file pointer. A file pointer should be specified as an argument. The only default argument is ``comment_lead``, which can be used for parsing specific comment lines. ...
[ "def", "from_fp", "(", "self", ",", "file_pointer", ",", "comment_lead", "=", "[", "'c'", "]", ")", ":", "self", ".", "nv", "=", "0", "self", ".", "hard", "=", "[", "]", "self", ".", "atms", "=", "[", "]", "self", ".", "soft", "=", "[", "]", ...
Read a WCNF+ formula from a file pointer. A file pointer should be specified as an argument. The only default argument is ``comment_lead``, which can be used for parsing specific comment lines. :param file_pointer: a file pointer to read the formula from. :pa...
[ "Read", "a", "WCNF", "+", "formula", "from", "a", "file", "pointer", ".", "A", "file", "pointer", "should", "be", "specified", "as", "an", "argument", ".", "The", "only", "default", "argument", "is", "comment_lead", "which", "can", "be", "used", "for", "...
522742e8f2d4c6ac50ecd9087f7a346206774c67
https://github.com/pysathq/pysat/blob/522742e8f2d4c6ac50ecd9087f7a346206774c67/pysat/formula.py#L1438-L1500
17,220
pysathq/pysat
pysat/formula.py
WCNFPlus.append
def append(self, clause, weight=None, is_atmost=False): """ Add a single clause or a single AtMostK constraint to WCNF+ formula. This method additionally updates the number of variables, i.e. variable ``self.nv``, used in the formula. If the clause is an AtMostK...
python
def append(self, clause, weight=None, is_atmost=False): """ Add a single clause or a single AtMostK constraint to WCNF+ formula. This method additionally updates the number of variables, i.e. variable ``self.nv``, used in the formula. If the clause is an AtMostK...
[ "def", "append", "(", "self", ",", "clause", ",", "weight", "=", "None", ",", "is_atmost", "=", "False", ")", ":", "if", "not", "is_atmost", ":", "self", ".", "nv", "=", "max", "(", "[", "abs", "(", "l", ")", "for", "l", "in", "clause", "]", "+...
Add a single clause or a single AtMostK constraint to WCNF+ formula. This method additionally updates the number of variables, i.e. variable ``self.nv``, used in the formula. If the clause is an AtMostK constraint, this should be set with the use of the additional defau...
[ "Add", "a", "single", "clause", "or", "a", "single", "AtMostK", "constraint", "to", "WCNF", "+", "formula", ".", "This", "method", "additionally", "updates", "the", "number", "of", "variables", "i", ".", "e", ".", "variable", "self", ".", "nv", "used", "...
522742e8f2d4c6ac50ecd9087f7a346206774c67
https://github.com/pysathq/pysat/blob/522742e8f2d4c6ac50ecd9087f7a346206774c67/pysat/formula.py#L1552-L1602
17,221
pysathq/pysat
examples/fm.py
FM.delete
def delete(self): """ Explicit destructor of the internal SAT oracle. """ if self.oracle: self.time += self.oracle.time_accum() # keep SAT solving time self.oracle.delete() self.oracle = None
python
def delete(self): """ Explicit destructor of the internal SAT oracle. """ if self.oracle: self.time += self.oracle.time_accum() # keep SAT solving time self.oracle.delete() self.oracle = None
[ "def", "delete", "(", "self", ")", ":", "if", "self", ".", "oracle", ":", "self", ".", "time", "+=", "self", ".", "oracle", ".", "time_accum", "(", ")", "# keep SAT solving time", "self", ".", "oracle", ".", "delete", "(", ")", "self", ".", "oracle", ...
Explicit destructor of the internal SAT oracle.
[ "Explicit", "destructor", "of", "the", "internal", "SAT", "oracle", "." ]
522742e8f2d4c6ac50ecd9087f7a346206774c67
https://github.com/pysathq/pysat/blob/522742e8f2d4c6ac50ecd9087f7a346206774c67/examples/fm.py#L216-L225
17,222
pysathq/pysat
examples/fm.py
FM.split_core
def split_core(self, minw): """ Split clauses in the core whenever necessary. Given a list of soft clauses in an unsatisfiable core, the method is used for splitting clauses whose weights are greater than the minimum weight of the core, i.e. the ``minw`` value co...
python
def split_core(self, minw): """ Split clauses in the core whenever necessary. Given a list of soft clauses in an unsatisfiable core, the method is used for splitting clauses whose weights are greater than the minimum weight of the core, i.e. the ``minw`` value co...
[ "def", "split_core", "(", "self", ",", "minw", ")", ":", "for", "clid", "in", "self", ".", "core", ":", "sel", "=", "self", ".", "sels", "[", "clid", "]", "if", "self", ".", "wght", "[", "clid", "]", ">", "minw", ":", "self", ".", "topv", "+=",...
Split clauses in the core whenever necessary. Given a list of soft clauses in an unsatisfiable core, the method is used for splitting clauses whose weights are greater than the minimum weight of the core, i.e. the ``minw`` value computed in :func:`treat_core`. Each claus...
[ "Split", "clauses", "in", "the", "core", "whenever", "necessary", "." ]
522742e8f2d4c6ac50ecd9087f7a346206774c67
https://github.com/pysathq/pysat/blob/522742e8f2d4c6ac50ecd9087f7a346206774c67/examples/fm.py#L325-L363
17,223
pysathq/pysat
examples/fm.py
FM.relax_core
def relax_core(self): """ Relax and bound the core. After unsatisfiable core splitting, this method is called. If the core contains only one clause, i.e. this clause cannot be satisfied together with the hard clauses of the formula, the formula gets a...
python
def relax_core(self): """ Relax and bound the core. After unsatisfiable core splitting, this method is called. If the core contains only one clause, i.e. this clause cannot be satisfied together with the hard clauses of the formula, the formula gets a...
[ "def", "relax_core", "(", "self", ")", ":", "if", "len", "(", "self", ".", "core", ")", ">", "1", ":", "# relaxing", "rels", "=", "[", "]", "for", "clid", "in", "self", ".", "core", ":", "self", ".", "topv", "+=", "1", "rels", ".", "append", "(...
Relax and bound the core. After unsatisfiable core splitting, this method is called. If the core contains only one clause, i.e. this clause cannot be satisfied together with the hard clauses of the formula, the formula gets augmented with the negation of the clause (see ...
[ "Relax", "and", "bound", "the", "core", "." ]
522742e8f2d4c6ac50ecd9087f7a346206774c67
https://github.com/pysathq/pysat/blob/522742e8f2d4c6ac50ecd9087f7a346206774c67/examples/fm.py#L365-L408
17,224
pysathq/pysat
examples/lsu.py
parse_options
def parse_options(): """ Parses command-line options. """ try: opts, args = getopt.getopt(sys.argv[1:], 'hms:v', ['help', 'model', 'solver=', 'verbose']) except getopt.GetoptError as err: sys.stderr.write(str(err).capitalize()) print_usage() sys.exit(1) solv...
python
def parse_options(): """ Parses command-line options. """ try: opts, args = getopt.getopt(sys.argv[1:], 'hms:v', ['help', 'model', 'solver=', 'verbose']) except getopt.GetoptError as err: sys.stderr.write(str(err).capitalize()) print_usage() sys.exit(1) solv...
[ "def", "parse_options", "(", ")", ":", "try", ":", "opts", ",", "args", "=", "getopt", ".", "getopt", "(", "sys", ".", "argv", "[", "1", ":", "]", ",", "'hms:v'", ",", "[", "'help'", ",", "'model'", ",", "'solver='", ",", "'verbose'", "]", ")", "...
Parses command-line options.
[ "Parses", "command", "-", "line", "options", "." ]
522742e8f2d4c6ac50ecd9087f7a346206774c67
https://github.com/pysathq/pysat/blob/522742e8f2d4c6ac50ecd9087f7a346206774c67/examples/lsu.py#L308-L337
17,225
pysathq/pysat
examples/lsu.py
parse_formula
def parse_formula(fml_file): """ Parse and return MaxSAT formula. """ if re.search('\.wcnf(\.(gz|bz2|lzma|xz))?$', fml_file): fml = WCNF(from_file=fml_file) else: # expecting '*.cnf' fml = CNF(from_file=fml_file).weighted() return fml
python
def parse_formula(fml_file): """ Parse and return MaxSAT formula. """ if re.search('\.wcnf(\.(gz|bz2|lzma|xz))?$', fml_file): fml = WCNF(from_file=fml_file) else: # expecting '*.cnf' fml = CNF(from_file=fml_file).weighted() return fml
[ "def", "parse_formula", "(", "fml_file", ")", ":", "if", "re", ".", "search", "(", "'\\.wcnf(\\.(gz|bz2|lzma|xz))?$'", ",", "fml_file", ")", ":", "fml", "=", "WCNF", "(", "from_file", "=", "fml_file", ")", "else", ":", "# expecting '*.cnf'", "fml", "=", "CNF...
Parse and return MaxSAT formula.
[ "Parse", "and", "return", "MaxSAT", "formula", "." ]
522742e8f2d4c6ac50ecd9087f7a346206774c67
https://github.com/pysathq/pysat/blob/522742e8f2d4c6ac50ecd9087f7a346206774c67/examples/lsu.py#L358-L368
17,226
pysathq/pysat
examples/lsu.py
LSU._init
def _init(self, formula): """ SAT oracle initialization. The method creates a new SAT oracle and feeds it with the formula's hard clauses. Afterwards, all soft clauses of the formula are augmented with selector literals and also added to the solver. The list of al...
python
def _init(self, formula): """ SAT oracle initialization. The method creates a new SAT oracle and feeds it with the formula's hard clauses. Afterwards, all soft clauses of the formula are augmented with selector literals and also added to the solver. The list of al...
[ "def", "_init", "(", "self", ",", "formula", ")", ":", "self", ".", "oracle", "=", "Solver", "(", "name", "=", "self", ".", "solver", ",", "bootstrap_with", "=", "formula", ".", "hard", ",", "incr", "=", "True", ",", "use_timer", "=", "True", ")", ...
SAT oracle initialization. The method creates a new SAT oracle and feeds it with the formula's hard clauses. Afterwards, all soft clauses of the formula are augmented with selector literals and also added to the solver. The list of all introduced selectors is stored in va...
[ "SAT", "oracle", "initialization", ".", "The", "method", "creates", "a", "new", "SAT", "oracle", "and", "feeds", "it", "with", "the", "formula", "s", "hard", "clauses", ".", "Afterwards", "all", "soft", "clauses", "of", "the", "formula", "are", "augmented", ...
522742e8f2d4c6ac50ecd9087f7a346206774c67
https://github.com/pysathq/pysat/blob/522742e8f2d4c6ac50ecd9087f7a346206774c67/examples/lsu.py#L139-L164
17,227
pysathq/pysat
examples/lsu.py
LSU._get_model_cost
def _get_model_cost(self, formula, model): """ Given a WCNF formula and a model, the method computes the MaxSAT cost of the model, i.e. the sum of weights of soft clauses that are unsatisfied by the model. :param formula: an input MaxSAT formula :para...
python
def _get_model_cost(self, formula, model): """ Given a WCNF formula and a model, the method computes the MaxSAT cost of the model, i.e. the sum of weights of soft clauses that are unsatisfied by the model. :param formula: an input MaxSAT formula :para...
[ "def", "_get_model_cost", "(", "self", ",", "formula", ",", "model", ")", ":", "model_set", "=", "set", "(", "model", ")", "cost", "=", "0", "for", "i", ",", "cl", "in", "enumerate", "(", "formula", ".", "soft", ")", ":", "cost", "+=", "formula", "...
Given a WCNF formula and a model, the method computes the MaxSAT cost of the model, i.e. the sum of weights of soft clauses that are unsatisfied by the model. :param formula: an input MaxSAT formula :param model: a satisfying assignment :type formula: :class...
[ "Given", "a", "WCNF", "formula", "and", "a", "model", "the", "method", "computes", "the", "MaxSAT", "cost", "of", "the", "model", "i", ".", "e", ".", "the", "sum", "of", "weights", "of", "soft", "clauses", "that", "are", "unsatisfied", "by", "the", "mo...
522742e8f2d4c6ac50ecd9087f7a346206774c67
https://github.com/pysathq/pysat/blob/522742e8f2d4c6ac50ecd9087f7a346206774c67/examples/lsu.py#L249-L270
17,228
pysathq/pysat
examples/rc2.py
parse_options
def parse_options(): """ Parses command-line option """ try: opts, args = getopt.getopt(sys.argv[1:], 'ac:e:hilms:t:vx', ['adapt', 'comp=', 'enum=', 'exhaust', 'help', 'incr', 'blo', 'minimize', 'solver=', 'trim=', 'verbose']) except getopt.GetoptErro...
python
def parse_options(): """ Parses command-line option """ try: opts, args = getopt.getopt(sys.argv[1:], 'ac:e:hilms:t:vx', ['adapt', 'comp=', 'enum=', 'exhaust', 'help', 'incr', 'blo', 'minimize', 'solver=', 'trim=', 'verbose']) except getopt.GetoptErro...
[ "def", "parse_options", "(", ")", ":", "try", ":", "opts", ",", "args", "=", "getopt", ".", "getopt", "(", "sys", ".", "argv", "[", "1", ":", "]", ",", "'ac:e:hilms:t:vx'", ",", "[", "'adapt'", ",", "'comp='", ",", "'enum='", ",", "'exhaust'", ",", ...
Parses command-line option
[ "Parses", "command", "-", "line", "option" ]
522742e8f2d4c6ac50ecd9087f7a346206774c67
https://github.com/pysathq/pysat/blob/522742e8f2d4c6ac50ecd9087f7a346206774c67/examples/rc2.py#L1463-L1520
17,229
pysathq/pysat
examples/rc2.py
RC2.delete
def delete(self): """ Explicit destructor of the internal SAT oracle and all the totalizer objects creating during the solving process. """ if self.oracle: self.oracle.delete() self.oracle = None if self.solver != 'mc': # for minicar...
python
def delete(self): """ Explicit destructor of the internal SAT oracle and all the totalizer objects creating during the solving process. """ if self.oracle: self.oracle.delete() self.oracle = None if self.solver != 'mc': # for minicar...
[ "def", "delete", "(", "self", ")", ":", "if", "self", ".", "oracle", ":", "self", ".", "oracle", ".", "delete", "(", ")", "self", ".", "oracle", "=", "None", "if", "self", ".", "solver", "!=", "'mc'", ":", "# for minicard, there is nothing to free", "for...
Explicit destructor of the internal SAT oracle and all the totalizer objects creating during the solving process.
[ "Explicit", "destructor", "of", "the", "internal", "SAT", "oracle", "and", "all", "the", "totalizer", "objects", "creating", "during", "the", "solving", "process", "." ]
522742e8f2d4c6ac50ecd9087f7a346206774c67
https://github.com/pysathq/pysat/blob/522742e8f2d4c6ac50ecd9087f7a346206774c67/examples/rc2.py#L382-L394
17,230
pysathq/pysat
examples/rc2.py
RC2.trim_core
def trim_core(self): """ This method trims a previously extracted unsatisfiable core at most a given number of times. If a fixed point is reached before that, the method returns. """ for i in range(self.trim): # call solver with core assumption on...
python
def trim_core(self): """ This method trims a previously extracted unsatisfiable core at most a given number of times. If a fixed point is reached before that, the method returns. """ for i in range(self.trim): # call solver with core assumption on...
[ "def", "trim_core", "(", "self", ")", ":", "for", "i", "in", "range", "(", "self", ".", "trim", ")", ":", "# call solver with core assumption only", "# it must return 'unsatisfiable'", "self", ".", "oracle", ".", "solve", "(", "assumptions", "=", "self", ".", ...
This method trims a previously extracted unsatisfiable core at most a given number of times. If a fixed point is reached before that, the method returns.
[ "This", "method", "trims", "a", "previously", "extracted", "unsatisfiable", "core", "at", "most", "a", "given", "number", "of", "times", ".", "If", "a", "fixed", "point", "is", "reached", "before", "that", "the", "method", "returns", "." ]
522742e8f2d4c6ac50ecd9087f7a346206774c67
https://github.com/pysathq/pysat/blob/522742e8f2d4c6ac50ecd9087f7a346206774c67/examples/rc2.py#L757-L777
17,231
pysathq/pysat
examples/rc2.py
RC2.minimize_core
def minimize_core(self): """ Reduce a previously extracted core and compute an over-approximation of an MUS. This is done using the simple deletion-based MUS extraction algorithm. The idea is to try to deactivate soft clauses of the unsatisfiable core...
python
def minimize_core(self): """ Reduce a previously extracted core and compute an over-approximation of an MUS. This is done using the simple deletion-based MUS extraction algorithm. The idea is to try to deactivate soft clauses of the unsatisfiable core...
[ "def", "minimize_core", "(", "self", ")", ":", "if", "self", ".", "minz", "and", "len", "(", "self", ".", "core", ")", ">", "1", ":", "self", ".", "core", "=", "sorted", "(", "self", ".", "core", ",", "key", "=", "lambda", "l", ":", "self", "."...
Reduce a previously extracted core and compute an over-approximation of an MUS. This is done using the simple deletion-based MUS extraction algorithm. The idea is to try to deactivate soft clauses of the unsatisfiable core one by one while checking if the rem...
[ "Reduce", "a", "previously", "extracted", "core", "and", "compute", "an", "over", "-", "approximation", "of", "an", "MUS", ".", "This", "is", "done", "using", "the", "simple", "deletion", "-", "based", "MUS", "extraction", "algorithm", "." ]
522742e8f2d4c6ac50ecd9087f7a346206774c67
https://github.com/pysathq/pysat/blob/522742e8f2d4c6ac50ecd9087f7a346206774c67/examples/rc2.py#L779-L808
17,232
pysathq/pysat
examples/rc2.py
RC2.update_sum
def update_sum(self, assump): """ The method is used to increase the bound for a given totalizer sum. The totalizer object is identified by the input parameter ``assump``, which is an assumption literal associated with the totalizer object. The method...
python
def update_sum(self, assump): """ The method is used to increase the bound for a given totalizer sum. The totalizer object is identified by the input parameter ``assump``, which is an assumption literal associated with the totalizer object. The method...
[ "def", "update_sum", "(", "self", ",", "assump", ")", ":", "# getting a totalizer object corresponding to assumption", "t", "=", "self", ".", "tobj", "[", "assump", "]", "# increment the current bound", "b", "=", "self", ".", "bnds", "[", "assump", "]", "+", "1"...
The method is used to increase the bound for a given totalizer sum. The totalizer object is identified by the input parameter ``assump``, which is an assumption literal associated with the totalizer object. The method increases the bound for the totalizer sum, ...
[ "The", "method", "is", "used", "to", "increase", "the", "bound", "for", "a", "given", "totalizer", "sum", ".", "The", "totalizer", "object", "is", "identified", "by", "the", "input", "parameter", "assump", "which", "is", "an", "assumption", "literal", "assoc...
522742e8f2d4c6ac50ecd9087f7a346206774c67
https://github.com/pysathq/pysat/blob/522742e8f2d4c6ac50ecd9087f7a346206774c67/examples/rc2.py#L990-L1045
17,233
pysathq/pysat
examples/rc2.py
RC2.set_bound
def set_bound(self, tobj, rhs): """ Given a totalizer sum and its right-hand side to be enforced, the method creates a new sum assumption literal, which will be used in the following SAT oracle calls. :param tobj: totalizer sum :param rhs: right-hand ...
python
def set_bound(self, tobj, rhs): """ Given a totalizer sum and its right-hand side to be enforced, the method creates a new sum assumption literal, which will be used in the following SAT oracle calls. :param tobj: totalizer sum :param rhs: right-hand ...
[ "def", "set_bound", "(", "self", ",", "tobj", ",", "rhs", ")", ":", "# saving the sum and its weight in a mapping", "self", ".", "tobj", "[", "-", "tobj", ".", "rhs", "[", "rhs", "]", "]", "=", "tobj", "self", ".", "bnds", "[", "-", "tobj", ".", "rhs",...
Given a totalizer sum and its right-hand side to be enforced, the method creates a new sum assumption literal, which will be used in the following SAT oracle calls. :param tobj: totalizer sum :param rhs: right-hand side :type tobj: :class:`.ITotalizer` ...
[ "Given", "a", "totalizer", "sum", "and", "its", "right", "-", "hand", "side", "to", "be", "enforced", "the", "method", "creates", "a", "new", "sum", "assumption", "literal", "which", "will", "be", "used", "in", "the", "following", "SAT", "oracle", "calls",...
522742e8f2d4c6ac50ecd9087f7a346206774c67
https://github.com/pysathq/pysat/blob/522742e8f2d4c6ac50ecd9087f7a346206774c67/examples/rc2.py#L1047-L1066
17,234
pysathq/pysat
examples/rc2.py
RC2.filter_assumps
def filter_assumps(self): """ Filter out unnecessary selectors and sums from the list of assumption literals. The corresponding values are also removed from the dictionaries of bounds and weights. Note that assumptions marked as garbage are collected in ...
python
def filter_assumps(self): """ Filter out unnecessary selectors and sums from the list of assumption literals. The corresponding values are also removed from the dictionaries of bounds and weights. Note that assumptions marked as garbage are collected in ...
[ "def", "filter_assumps", "(", "self", ")", ":", "self", ".", "sels", "=", "list", "(", "filter", "(", "lambda", "x", ":", "x", "not", "in", "self", ".", "garbage", ",", "self", ".", "sels", ")", ")", "self", ".", "sums", "=", "list", "(", "filter...
Filter out unnecessary selectors and sums from the list of assumption literals. The corresponding values are also removed from the dictionaries of bounds and weights. Note that assumptions marked as garbage are collected in the core processing methods, i.e. in :func:`pro...
[ "Filter", "out", "unnecessary", "selectors", "and", "sums", "from", "the", "list", "of", "assumption", "literals", ".", "The", "corresponding", "values", "are", "also", "removed", "from", "the", "dictionaries", "of", "bounds", "and", "weights", "." ]
522742e8f2d4c6ac50ecd9087f7a346206774c67
https://github.com/pysathq/pysat/blob/522742e8f2d4c6ac50ecd9087f7a346206774c67/examples/rc2.py#L1068-L1085
17,235
Kensuke-Mitsuzawa/JapaneseTokenizers
JapaneseTokenizer/mecab_wrapper/mecab_wrapper.py
MecabWrapper.__get_path_to_mecab_config
def __get_path_to_mecab_config(self): """You get path into mecab-config """ if six.PY2: path_mecab_config_dir = subprocess.check_output(['which', 'mecab-config']) path_mecab_config_dir = path_mecab_config_dir.strip().replace('/mecab-config', '') else: ...
python
def __get_path_to_mecab_config(self): """You get path into mecab-config """ if six.PY2: path_mecab_config_dir = subprocess.check_output(['which', 'mecab-config']) path_mecab_config_dir = path_mecab_config_dir.strip().replace('/mecab-config', '') else: ...
[ "def", "__get_path_to_mecab_config", "(", "self", ")", ":", "if", "six", ".", "PY2", ":", "path_mecab_config_dir", "=", "subprocess", ".", "check_output", "(", "[", "'which'", ",", "'mecab-config'", "]", ")", "path_mecab_config_dir", "=", "path_mecab_config_dir", ...
You get path into mecab-config
[ "You", "get", "path", "into", "mecab", "-", "config" ]
3bdfb6be73de0f78e5c08f3a51376ad3efa00b6c
https://github.com/Kensuke-Mitsuzawa/JapaneseTokenizers/blob/3bdfb6be73de0f78e5c08f3a51376ad3efa00b6c/JapaneseTokenizer/mecab_wrapper/mecab_wrapper.py#L79-L90
17,236
Kensuke-Mitsuzawa/JapaneseTokenizers
JapaneseTokenizer/mecab_wrapper/mecab_wrapper.py
MecabWrapper.__result_parser
def __result_parser(self, analyzed_line, is_feature, is_surface): # type: (text_type,bool,bool)->TokenizedResult """Extract surface word and feature from analyzed line. Extracted elements are returned with TokenizedResult class """ assert isinstance(analyzed_line, str) as...
python
def __result_parser(self, analyzed_line, is_feature, is_surface): # type: (text_type,bool,bool)->TokenizedResult """Extract surface word and feature from analyzed line. Extracted elements are returned with TokenizedResult class """ assert isinstance(analyzed_line, str) as...
[ "def", "__result_parser", "(", "self", ",", "analyzed_line", ",", "is_feature", ",", "is_surface", ")", ":", "# type: (text_type,bool,bool)->TokenizedResult", "assert", "isinstance", "(", "analyzed_line", ",", "str", ")", "assert", "isinstance", "(", "is_feature", ","...
Extract surface word and feature from analyzed line. Extracted elements are returned with TokenizedResult class
[ "Extract", "surface", "word", "and", "feature", "from", "analyzed", "line", ".", "Extracted", "elements", "are", "returned", "with", "TokenizedResult", "class" ]
3bdfb6be73de0f78e5c08f3a51376ad3efa00b6c
https://github.com/Kensuke-Mitsuzawa/JapaneseTokenizers/blob/3bdfb6be73de0f78e5c08f3a51376ad3efa00b6c/JapaneseTokenizer/mecab_wrapper/mecab_wrapper.py#L239-L259
17,237
Kensuke-Mitsuzawa/JapaneseTokenizers
JapaneseTokenizer/datamodels.py
__is_valid_pos
def __is_valid_pos(pos_tuple, valid_pos): # type: (Tuple[text_type,...],List[Tuple[text_type,...]])->bool """This function checks token's pos is with in POS set that user specified. If token meets all conditions, Return True; else return False """ def is_valid_pos(valid_pos_tuple): # type: (...
python
def __is_valid_pos(pos_tuple, valid_pos): # type: (Tuple[text_type,...],List[Tuple[text_type,...]])->bool """This function checks token's pos is with in POS set that user specified. If token meets all conditions, Return True; else return False """ def is_valid_pos(valid_pos_tuple): # type: (...
[ "def", "__is_valid_pos", "(", "pos_tuple", ",", "valid_pos", ")", ":", "# type: (Tuple[text_type,...],List[Tuple[text_type,...]])->bool", "def", "is_valid_pos", "(", "valid_pos_tuple", ")", ":", "# type: (Tuple[text_type,...])->bool", "length_valid_pos_tuple", "=", "len", "(", ...
This function checks token's pos is with in POS set that user specified. If token meets all conditions, Return True; else return False
[ "This", "function", "checks", "token", "s", "pos", "is", "with", "in", "POS", "set", "that", "user", "specified", ".", "If", "token", "meets", "all", "conditions", "Return", "True", ";", "else", "return", "False" ]
3bdfb6be73de0f78e5c08f3a51376ad3efa00b6c
https://github.com/Kensuke-Mitsuzawa/JapaneseTokenizers/blob/3bdfb6be73de0f78e5c08f3a51376ad3efa00b6c/JapaneseTokenizer/datamodels.py#L25-L43
17,238
Kensuke-Mitsuzawa/JapaneseTokenizers
JapaneseTokenizer/datamodels.py
filter_words
def filter_words(tokenized_obj, valid_pos, stopwords, check_field_name='stem'): # type: (TokenizedSenetence, List[Tuple[text_type,...]], List[text_type],text_type) -> FilteredObject """This function filter token that user don't want to take. Condition is stopword and pos. * Input - valid_pos ...
python
def filter_words(tokenized_obj, valid_pos, stopwords, check_field_name='stem'): # type: (TokenizedSenetence, List[Tuple[text_type,...]], List[text_type],text_type) -> FilteredObject """This function filter token that user don't want to take. Condition is stopword and pos. * Input - valid_pos ...
[ "def", "filter_words", "(", "tokenized_obj", ",", "valid_pos", ",", "stopwords", ",", "check_field_name", "=", "'stem'", ")", ":", "# type: (TokenizedSenetence, List[Tuple[text_type,...]], List[text_type],text_type) -> FilteredObject", "assert", "isinstance", "(", "tokenized_obj"...
This function filter token that user don't want to take. Condition is stopword and pos. * Input - valid_pos - List of Tuple which has POS element to keep. - Keep in your mind, each tokenizer has different POS structure. >>> [('名詞', '固有名詞'), ('動詞', )] - stopwords - List ...
[ "This", "function", "filter", "token", "that", "user", "don", "t", "want", "to", "take", ".", "Condition", "is", "stopword", "and", "pos", "." ]
3bdfb6be73de0f78e5c08f3a51376ad3efa00b6c
https://github.com/Kensuke-Mitsuzawa/JapaneseTokenizers/blob/3bdfb6be73de0f78e5c08f3a51376ad3efa00b6c/JapaneseTokenizer/datamodels.py#L46-L91
17,239
Kensuke-Mitsuzawa/JapaneseTokenizers
JapaneseTokenizer/datamodels.py
TokenizedSenetence.__extend_token_object
def __extend_token_object(self, token_object, is_denormalize=True, func_denormalizer=denormalize_text): # type: (TokenizedResult,bool,Callable[[str],str])->Tuple """This method creates dict object from token object. """ assert i...
python
def __extend_token_object(self, token_object, is_denormalize=True, func_denormalizer=denormalize_text): # type: (TokenizedResult,bool,Callable[[str],str])->Tuple """This method creates dict object from token object. """ assert i...
[ "def", "__extend_token_object", "(", "self", ",", "token_object", ",", "is_denormalize", "=", "True", ",", "func_denormalizer", "=", "denormalize_text", ")", ":", "# type: (TokenizedResult,bool,Callable[[str],str])->Tuple", "assert", "isinstance", "(", "token_object", ",", ...
This method creates dict object from token object.
[ "This", "method", "creates", "dict", "object", "from", "token", "object", "." ]
3bdfb6be73de0f78e5c08f3a51376ad3efa00b6c
https://github.com/Kensuke-Mitsuzawa/JapaneseTokenizers/blob/3bdfb6be73de0f78e5c08f3a51376ad3efa00b6c/JapaneseTokenizer/datamodels.py#L143-L174
17,240
mosquito/cysystemd
cysystemd/daemon.py
notify
def notify(notification, value=None, unset_environment=False): """ Send notification to systemd daemon :type notification: Notification :type value: int :type unset_environment: bool :param value: str or int value for non constant notifications :returns None """ if not isinstance(noti...
python
def notify(notification, value=None, unset_environment=False): """ Send notification to systemd daemon :type notification: Notification :type value: int :type unset_environment: bool :param value: str or int value for non constant notifications :returns None """ if not isinstance(noti...
[ "def", "notify", "(", "notification", ",", "value", "=", "None", ",", "unset_environment", "=", "False", ")", ":", "if", "not", "isinstance", "(", "notification", ",", "Notification", ")", ":", "raise", "TypeError", "(", "\"state must be an instance of Notificatio...
Send notification to systemd daemon :type notification: Notification :type value: int :type unset_environment: bool :param value: str or int value for non constant notifications :returns None
[ "Send", "notification", "to", "systemd", "daemon" ]
e0acede93387d51e4d6b20fdc278b2675052958d
https://github.com/mosquito/cysystemd/blob/e0acede93387d51e4d6b20fdc278b2675052958d/cysystemd/daemon.py#L28-L59
17,241
Pylons/hupper
src/hupper/worker.py
expand_source_paths
def expand_source_paths(paths): """ Convert pyc files into their source equivalents.""" for src_path in paths: # only track the source path if we can find it to avoid double-reloads # when the source and the compiled path change because on some # platforms they are not changed at the sam...
python
def expand_source_paths(paths): """ Convert pyc files into their source equivalents.""" for src_path in paths: # only track the source path if we can find it to avoid double-reloads # when the source and the compiled path change because on some # platforms they are not changed at the sam...
[ "def", "expand_source_paths", "(", "paths", ")", ":", "for", "src_path", "in", "paths", ":", "# only track the source path if we can find it to avoid double-reloads", "# when the source and the compiled path change because on some", "# platforms they are not changed at the same time", "i...
Convert pyc files into their source equivalents.
[ "Convert", "pyc", "files", "into", "their", "source", "equivalents", "." ]
197173c09e775b66c148468b6299c571e736c381
https://github.com/Pylons/hupper/blob/197173c09e775b66c148468b6299c571e736c381/src/hupper/worker.py#L84-L94
17,242
Pylons/hupper
src/hupper/worker.py
iter_module_paths
def iter_module_paths(modules=None): """ Yield paths of all imported modules.""" modules = modules or list(sys.modules.values()) for module in modules: try: filename = module.__file__ except (AttributeError, ImportError): # pragma: no cover continue if filena...
python
def iter_module_paths(modules=None): """ Yield paths of all imported modules.""" modules = modules or list(sys.modules.values()) for module in modules: try: filename = module.__file__ except (AttributeError, ImportError): # pragma: no cover continue if filena...
[ "def", "iter_module_paths", "(", "modules", "=", "None", ")", ":", "modules", "=", "modules", "or", "list", "(", "sys", ".", "modules", ".", "values", "(", ")", ")", "for", "module", "in", "modules", ":", "try", ":", "filename", "=", "module", ".", "...
Yield paths of all imported modules.
[ "Yield", "paths", "of", "all", "imported", "modules", "." ]
197173c09e775b66c148468b6299c571e736c381
https://github.com/Pylons/hupper/blob/197173c09e775b66c148468b6299c571e736c381/src/hupper/worker.py#L97-L108
17,243
Pylons/hupper
src/hupper/worker.py
WatchSysModules.update_paths
def update_paths(self): """ Check sys.modules for paths to add to our path set.""" new_paths = [] with self.lock: for path in expand_source_paths(iter_module_paths()): if path not in self.paths: self.paths.add(path) new_paths.ap...
python
def update_paths(self): """ Check sys.modules for paths to add to our path set.""" new_paths = [] with self.lock: for path in expand_source_paths(iter_module_paths()): if path not in self.paths: self.paths.add(path) new_paths.ap...
[ "def", "update_paths", "(", "self", ")", ":", "new_paths", "=", "[", "]", "with", "self", ".", "lock", ":", "for", "path", "in", "expand_source_paths", "(", "iter_module_paths", "(", ")", ")", ":", "if", "path", "not", "in", "self", ".", "paths", ":", ...
Check sys.modules for paths to add to our path set.
[ "Check", "sys", ".", "modules", "for", "paths", "to", "add", "to", "our", "path", "set", "." ]
197173c09e775b66c148468b6299c571e736c381
https://github.com/Pylons/hupper/blob/197173c09e775b66c148468b6299c571e736c381/src/hupper/worker.py#L39-L48
17,244
Pylons/hupper
src/hupper/worker.py
WatchSysModules.search_traceback
def search_traceback(self, tb): """ Inspect a traceback for new paths to add to our path set.""" new_paths = [] with self.lock: for filename, line, funcname, txt in traceback.extract_tb(tb): path = os.path.abspath(filename) if path not in self.paths: ...
python
def search_traceback(self, tb): """ Inspect a traceback for new paths to add to our path set.""" new_paths = [] with self.lock: for filename, line, funcname, txt in traceback.extract_tb(tb): path = os.path.abspath(filename) if path not in self.paths: ...
[ "def", "search_traceback", "(", "self", ",", "tb", ")", ":", "new_paths", "=", "[", "]", "with", "self", ".", "lock", ":", "for", "filename", ",", "line", ",", "funcname", ",", "txt", "in", "traceback", ".", "extract_tb", "(", "tb", ")", ":", "path",...
Inspect a traceback for new paths to add to our path set.
[ "Inspect", "a", "traceback", "for", "new", "paths", "to", "add", "to", "our", "path", "set", "." ]
197173c09e775b66c148468b6299c571e736c381
https://github.com/Pylons/hupper/blob/197173c09e775b66c148468b6299c571e736c381/src/hupper/worker.py#L50-L60
17,245
Pylons/hupper
src/hupper/ipc.py
args_from_interpreter_flags
def args_from_interpreter_flags(): """ Return a list of command-line arguments reproducing the current settings in sys.flags and sys.warnoptions. """ flag_opt_map = { 'debug': 'd', 'dont_write_bytecode': 'B', 'no_user_site': 's', 'no_site': 'S', 'ignore_envir...
python
def args_from_interpreter_flags(): """ Return a list of command-line arguments reproducing the current settings in sys.flags and sys.warnoptions. """ flag_opt_map = { 'debug': 'd', 'dont_write_bytecode': 'B', 'no_user_site': 's', 'no_site': 'S', 'ignore_envir...
[ "def", "args_from_interpreter_flags", "(", ")", ":", "flag_opt_map", "=", "{", "'debug'", ":", "'d'", ",", "'dont_write_bytecode'", ":", "'B'", ",", "'no_user_site'", ":", "'s'", ",", "'no_site'", ":", "'S'", ",", "'ignore_environment'", ":", "'E'", ",", "'ver...
Return a list of command-line arguments reproducing the current settings in sys.flags and sys.warnoptions.
[ "Return", "a", "list", "of", "command", "-", "line", "arguments", "reproducing", "the", "current", "settings", "in", "sys", ".", "flags", "and", "sys", ".", "warnoptions", "." ]
197173c09e775b66c148468b6299c571e736c381
https://github.com/Pylons/hupper/blob/197173c09e775b66c148468b6299c571e736c381/src/hupper/ipc.py#L221-L245
17,246
Pylons/hupper
src/hupper/ipc.py
spawn
def spawn(spec, kwargs, pass_fds=()): """ Invoke a python function in a subprocess. """ r, w = os.pipe() for fd in [r] + list(pass_fds): set_inheritable(fd, True) preparation_data = get_preparation_data() r_handle = get_handle(r) args, env = get_command_line(pipe_handle=r_hand...
python
def spawn(spec, kwargs, pass_fds=()): """ Invoke a python function in a subprocess. """ r, w = os.pipe() for fd in [r] + list(pass_fds): set_inheritable(fd, True) preparation_data = get_preparation_data() r_handle = get_handle(r) args, env = get_command_line(pipe_handle=r_hand...
[ "def", "spawn", "(", "spec", ",", "kwargs", ",", "pass_fds", "=", "(", ")", ")", ":", "r", ",", "w", "=", "os", ".", "pipe", "(", ")", "for", "fd", "in", "[", "r", "]", "+", "list", "(", "pass_fds", ")", ":", "set_inheritable", "(", "fd", ","...
Invoke a python function in a subprocess.
[ "Invoke", "a", "python", "function", "in", "a", "subprocess", "." ]
197173c09e775b66c148468b6299c571e736c381
https://github.com/Pylons/hupper/blob/197173c09e775b66c148468b6299c571e736c381/src/hupper/ipc.py#L287-L306
17,247
Pylons/hupper
src/hupper/utils.py
get_watchman_sockpath
def get_watchman_sockpath(binpath='watchman'): """ Find the watchman socket or raise.""" path = os.getenv('WATCHMAN_SOCK') if path: return path cmd = [binpath, '--output-encoding=json', 'get-sockname'] result = subprocess.check_output(cmd) result = json.loads(result) return result['...
python
def get_watchman_sockpath(binpath='watchman'): """ Find the watchman socket or raise.""" path = os.getenv('WATCHMAN_SOCK') if path: return path cmd = [binpath, '--output-encoding=json', 'get-sockname'] result = subprocess.check_output(cmd) result = json.loads(result) return result['...
[ "def", "get_watchman_sockpath", "(", "binpath", "=", "'watchman'", ")", ":", "path", "=", "os", ".", "getenv", "(", "'WATCHMAN_SOCK'", ")", "if", "path", ":", "return", "path", "cmd", "=", "[", "binpath", ",", "'--output-encoding=json'", ",", "'get-sockname'",...
Find the watchman socket or raise.
[ "Find", "the", "watchman", "socket", "or", "raise", "." ]
197173c09e775b66c148468b6299c571e736c381
https://github.com/Pylons/hupper/blob/197173c09e775b66c148468b6299c571e736c381/src/hupper/utils.py#L49-L58
17,248
Pylons/hupper
src/hupper/reloader.py
start_reloader
def start_reloader( worker_path, reload_interval=1, shutdown_interval=default, verbose=1, logger=None, monitor_factory=None, worker_args=None, worker_kwargs=None, ignore_files=None, ): """ Start a monitor and then fork a worker process which starts by executing the import...
python
def start_reloader( worker_path, reload_interval=1, shutdown_interval=default, verbose=1, logger=None, monitor_factory=None, worker_args=None, worker_kwargs=None, ignore_files=None, ): """ Start a monitor and then fork a worker process which starts by executing the import...
[ "def", "start_reloader", "(", "worker_path", ",", "reload_interval", "=", "1", ",", "shutdown_interval", "=", "default", ",", "verbose", "=", "1", ",", "logger", "=", "None", ",", "monitor_factory", "=", "None", ",", "worker_args", "=", "None", ",", "worker_...
Start a monitor and then fork a worker process which starts by executing the importable function at ``worker_path``. If this function is called from a worker process that is already being monitored then it will return a reference to the current :class:`hupper.interfaces.IReloaderProxy` which can be use...
[ "Start", "a", "monitor", "and", "then", "fork", "a", "worker", "process", "which", "starts", "by", "executing", "the", "importable", "function", "at", "worker_path", "." ]
197173c09e775b66c148468b6299c571e736c381
https://github.com/Pylons/hupper/blob/197173c09e775b66c148468b6299c571e736c381/src/hupper/reloader.py#L289-L364
17,249
Pylons/hupper
src/hupper/reloader.py
Reloader.run
def run(self): """ Execute the reloader forever, blocking the current thread. This will invoke ``sys.exit(1)`` if interrupted. """ self._capture_signals() self._start_monitor() try: while True: if not self._run_worker(): ...
python
def run(self): """ Execute the reloader forever, blocking the current thread. This will invoke ``sys.exit(1)`` if interrupted. """ self._capture_signals() self._start_monitor() try: while True: if not self._run_worker(): ...
[ "def", "run", "(", "self", ")", ":", "self", ".", "_capture_signals", "(", ")", "self", ".", "_start_monitor", "(", ")", "try", ":", "while", "True", ":", "if", "not", "self", ".", "_run_worker", "(", ")", ":", "self", ".", "_wait_for_changes", "(", ...
Execute the reloader forever, blocking the current thread. This will invoke ``sys.exit(1)`` if interrupted.
[ "Execute", "the", "reloader", "forever", "blocking", "the", "current", "thread", "." ]
197173c09e775b66c148468b6299c571e736c381
https://github.com/Pylons/hupper/blob/197173c09e775b66c148468b6299c571e736c381/src/hupper/reloader.py#L102-L121
17,250
Pylons/hupper
src/hupper/reloader.py
Reloader.run_once
def run_once(self): """ Execute the worker once. This method will return after a file change is detected. """ self._capture_signals() self._start_monitor() try: self._run_worker() except KeyboardInterrupt: return finally: ...
python
def run_once(self): """ Execute the worker once. This method will return after a file change is detected. """ self._capture_signals() self._start_monitor() try: self._run_worker() except KeyboardInterrupt: return finally: ...
[ "def", "run_once", "(", "self", ")", ":", "self", ".", "_capture_signals", "(", ")", "self", ".", "_start_monitor", "(", ")", "try", ":", "self", ".", "_run_worker", "(", ")", "except", "KeyboardInterrupt", ":", "return", "finally", ":", "self", ".", "_s...
Execute the worker once. This method will return after a file change is detected.
[ "Execute", "the", "worker", "once", "." ]
197173c09e775b66c148468b6299c571e736c381
https://github.com/Pylons/hupper/blob/197173c09e775b66c148468b6299c571e736c381/src/hupper/reloader.py#L123-L138
17,251
BYU-PCCL/holodeck
holodeck/holodeckclient.py
HolodeckClient.malloc
def malloc(self, key, shape, dtype): """Allocates a block of shared memory, and returns a numpy array whose data corresponds with that block. Args: key (str): The key to identify the block. shape (list of int): The shape of the numpy array to allocate. dtype (type): ...
python
def malloc(self, key, shape, dtype): """Allocates a block of shared memory, and returns a numpy array whose data corresponds with that block. Args: key (str): The key to identify the block. shape (list of int): The shape of the numpy array to allocate. dtype (type): ...
[ "def", "malloc", "(", "self", ",", "key", ",", "shape", ",", "dtype", ")", ":", "if", "key", "not", "in", "self", ".", "_memory", "or", "self", ".", "_memory", "[", "key", "]", ".", "shape", "!=", "shape", "or", "self", ".", "_memory", "[", "key"...
Allocates a block of shared memory, and returns a numpy array whose data corresponds with that block. Args: key (str): The key to identify the block. shape (list of int): The shape of the numpy array to allocate. dtype (type): The numpy data type (e.g. np.float32). ...
[ "Allocates", "a", "block", "of", "shared", "memory", "and", "returns", "a", "numpy", "array", "whose", "data", "corresponds", "with", "that", "block", "." ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/holodeckclient.py#L88-L102
17,252
BYU-PCCL/holodeck
holodeck/packagemanager.py
package_info
def package_info(pkg_name): """Prints the information of a package. Args: pkg_name (str): The name of the desired package to get information """ indent = " " for config, _ in _iter_packages(): if pkg_name == config["name"]: print("Package:", pkg_name) print(...
python
def package_info(pkg_name): """Prints the information of a package. Args: pkg_name (str): The name of the desired package to get information """ indent = " " for config, _ in _iter_packages(): if pkg_name == config["name"]: print("Package:", pkg_name) print(...
[ "def", "package_info", "(", "pkg_name", ")", ":", "indent", "=", "\" \"", "for", "config", ",", "_", "in", "_iter_packages", "(", ")", ":", "if", "pkg_name", "==", "config", "[", "\"name\"", "]", ":", "print", "(", "\"Package:\"", ",", "pkg_name", ")", ...
Prints the information of a package. Args: pkg_name (str): The name of the desired package to get information
[ "Prints", "the", "information", "of", "a", "package", "." ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/packagemanager.py#L38-L53
17,253
BYU-PCCL/holodeck
holodeck/packagemanager.py
world_info
def world_info(world_name, world_config=None, initial_indent="", next_indent=" "): """Gets and prints the information of a world. Args: world_name (str): the name of the world to retrieve information for world_config (dict optional): A dictionary containing the world's configuration. Will find...
python
def world_info(world_name, world_config=None, initial_indent="", next_indent=" "): """Gets and prints the information of a world. Args: world_name (str): the name of the world to retrieve information for world_config (dict optional): A dictionary containing the world's configuration. Will find...
[ "def", "world_info", "(", "world_name", ",", "world_config", "=", "None", ",", "initial_indent", "=", "\"\"", ",", "next_indent", "=", "\" \"", ")", ":", "if", "world_config", "is", "None", ":", "for", "config", ",", "_", "in", "_iter_packages", "(", ")",...
Gets and prints the information of a world. Args: world_name (str): the name of the world to retrieve information for world_config (dict optional): A dictionary containing the world's configuration. Will find the config if None. Defaults to None. initial_indent (str optional): This indent w...
[ "Gets", "and", "prints", "the", "information", "of", "a", "world", "." ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/packagemanager.py#L56-L86
17,254
BYU-PCCL/holodeck
holodeck/packagemanager.py
install
def install(package_name): """Installs a holodeck package. Args: package_name (str): The name of the package to install """ holodeck_path = util.get_holodeck_path() binary_website = "https://s3.amazonaws.com/holodeckworlds/" if package_name not in packages: raise HolodeckExcept...
python
def install(package_name): """Installs a holodeck package. Args: package_name (str): The name of the package to install """ holodeck_path = util.get_holodeck_path() binary_website = "https://s3.amazonaws.com/holodeckworlds/" if package_name not in packages: raise HolodeckExcept...
[ "def", "install", "(", "package_name", ")", ":", "holodeck_path", "=", "util", ".", "get_holodeck_path", "(", ")", "binary_website", "=", "\"https://s3.amazonaws.com/holodeckworlds/\"", "if", "package_name", "not", "in", "packages", ":", "raise", "HolodeckException", ...
Installs a holodeck package. Args: package_name (str): The name of the package to install
[ "Installs", "a", "holodeck", "package", "." ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/packagemanager.py#L89-L107
17,255
BYU-PCCL/holodeck
holodeck/packagemanager.py
remove
def remove(package_name): """Removes a holodeck package. Args: package_name (str): the name of the package to remove """ if package_name not in packages: raise HolodeckException("Unknown package name " + package_name) for config, path in _iter_packages(): if config["name"] =...
python
def remove(package_name): """Removes a holodeck package. Args: package_name (str): the name of the package to remove """ if package_name not in packages: raise HolodeckException("Unknown package name " + package_name) for config, path in _iter_packages(): if config["name"] =...
[ "def", "remove", "(", "package_name", ")", ":", "if", "package_name", "not", "in", "packages", ":", "raise", "HolodeckException", "(", "\"Unknown package name \"", "+", "package_name", ")", "for", "config", ",", "path", "in", "_iter_packages", "(", ")", ":", "...
Removes a holodeck package. Args: package_name (str): the name of the package to remove
[ "Removes", "a", "holodeck", "package", "." ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/packagemanager.py#L110-L120
17,256
BYU-PCCL/holodeck
holodeck/holodeck.py
make
def make(world_name, gl_version=GL_VERSION.OPENGL4, window_res=None, cam_res=None, verbose=False): """Creates a holodeck environment using the supplied world name. Args: world_name (str): The name of the world to load as an environment. Must match the name of a world in an installed package...
python
def make(world_name, gl_version=GL_VERSION.OPENGL4, window_res=None, cam_res=None, verbose=False): """Creates a holodeck environment using the supplied world name. Args: world_name (str): The name of the world to load as an environment. Must match the name of a world in an installed package...
[ "def", "make", "(", "world_name", ",", "gl_version", "=", "GL_VERSION", ".", "OPENGL4", ",", "window_res", "=", "None", ",", "cam_res", "=", "None", ",", "verbose", "=", "False", ")", ":", "holodeck_worlds", "=", "_get_worlds_map", "(", ")", "if", "world_n...
Creates a holodeck environment using the supplied world name. Args: world_name (str): The name of the world to load as an environment. Must match the name of a world in an installed package. gl_version (int, optional): The OpenGL version to use (Linux only). Defaults to GL_VERSION.OPENG...
[ "Creates", "a", "holodeck", "environment", "using", "the", "supplied", "world", "name", "." ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/holodeck.py#L22-L54
17,257
BYU-PCCL/holodeck
holodeck/shmem.py
Shmem.unlink
def unlink(self): """unlinks the shared memory""" if os.name == "posix": self.__linux_unlink__() elif os.name == "nt": self.__windows_unlink__() else: raise HolodeckException("Currently unsupported os: " + os.name)
python
def unlink(self): """unlinks the shared memory""" if os.name == "posix": self.__linux_unlink__() elif os.name == "nt": self.__windows_unlink__() else: raise HolodeckException("Currently unsupported os: " + os.name)
[ "def", "unlink", "(", "self", ")", ":", "if", "os", ".", "name", "==", "\"posix\"", ":", "self", ".", "__linux_unlink__", "(", ")", "elif", "os", ".", "name", "==", "\"nt\"", ":", "self", ".", "__windows_unlink__", "(", ")", "else", ":", "raise", "Ho...
unlinks the shared memory
[ "unlinks", "the", "shared", "memory" ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/shmem.py#L51-L58
17,258
BYU-PCCL/holodeck
holodeck/command.py
Command.add_number_parameters
def add_number_parameters(self, number): """Add given number parameters to the internal list. Args: number (list of int or list of float): A number or list of numbers to add to the parameters. """ if isinstance(number, list): for x in number: self...
python
def add_number_parameters(self, number): """Add given number parameters to the internal list. Args: number (list of int or list of float): A number or list of numbers to add to the parameters. """ if isinstance(number, list): for x in number: self...
[ "def", "add_number_parameters", "(", "self", ",", "number", ")", ":", "if", "isinstance", "(", "number", ",", "list", ")", ":", "for", "x", "in", "number", ":", "self", ".", "add_number_parameters", "(", "x", ")", "return", "self", ".", "_parameters", "....
Add given number parameters to the internal list. Args: number (list of int or list of float): A number or list of numbers to add to the parameters.
[ "Add", "given", "number", "parameters", "to", "the", "internal", "list", "." ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/command.py#L49-L59
17,259
BYU-PCCL/holodeck
holodeck/command.py
Command.add_string_parameters
def add_string_parameters(self, string): """Add given string parameters to the internal list. Args: string (list of str or str): A string or list of strings to add to the parameters. """ if isinstance(string, list): for x in string: self.add_strin...
python
def add_string_parameters(self, string): """Add given string parameters to the internal list. Args: string (list of str or str): A string or list of strings to add to the parameters. """ if isinstance(string, list): for x in string: self.add_strin...
[ "def", "add_string_parameters", "(", "self", ",", "string", ")", ":", "if", "isinstance", "(", "string", ",", "list", ")", ":", "for", "x", "in", "string", ":", "self", ".", "add_string_parameters", "(", "x", ")", "return", "self", ".", "_parameters", "....
Add given string parameters to the internal list. Args: string (list of str or str): A string or list of strings to add to the parameters.
[ "Add", "given", "string", "parameters", "to", "the", "internal", "list", "." ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/command.py#L61-L71
17,260
BYU-PCCL/holodeck
holodeck/command.py
SetWeatherCommand.set_type
def set_type(self, weather_type): """Set the weather type. Args: weather_type (str): The weather type. """ weather_type.lower() exists = self.has_type(weather_type) if exists: self.add_string_parameters(weather_type)
python
def set_type(self, weather_type): """Set the weather type. Args: weather_type (str): The weather type. """ weather_type.lower() exists = self.has_type(weather_type) if exists: self.add_string_parameters(weather_type)
[ "def", "set_type", "(", "self", ",", "weather_type", ")", ":", "weather_type", ".", "lower", "(", ")", "exists", "=", "self", ".", "has_type", "(", "weather_type", ")", "if", "exists", ":", "self", ".", "add_string_parameters", "(", "weather_type", ")" ]
Set the weather type. Args: weather_type (str): The weather type.
[ "Set", "the", "weather", "type", "." ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/command.py#L227-L236
17,261
BYU-PCCL/holodeck
example.py
uav_example
def uav_example(): """A basic example of how to use the UAV agent.""" env = holodeck.make("UrbanCity") # This changes the control scheme for the uav env.set_control_scheme("uav0", ControlSchemes.UAV_ROLL_PITCH_YAW_RATE_ALT) for i in range(10): env.reset() # This command tells the ...
python
def uav_example(): """A basic example of how to use the UAV agent.""" env = holodeck.make("UrbanCity") # This changes the control scheme for the uav env.set_control_scheme("uav0", ControlSchemes.UAV_ROLL_PITCH_YAW_RATE_ALT) for i in range(10): env.reset() # This command tells the ...
[ "def", "uav_example", "(", ")", ":", "env", "=", "holodeck", ".", "make", "(", "\"UrbanCity\"", ")", "# This changes the control scheme for the uav", "env", ".", "set_control_scheme", "(", "\"uav0\"", ",", "ControlSchemes", ".", "UAV_ROLL_PITCH_YAW_RATE_ALT", ")", "fo...
A basic example of how to use the UAV agent.
[ "A", "basic", "example", "of", "how", "to", "use", "the", "UAV", "agent", "." ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/example.py#L10-L27
17,262
BYU-PCCL/holodeck
example.py
sphere_example
def sphere_example(): """A basic example of how to use the sphere agent.""" env = holodeck.make("MazeWorld") # This command is to constantly rotate to the right command = 2 for i in range(10): env.reset() for _ in range(1000): state, reward, terminal, _ = env.step(comman...
python
def sphere_example(): """A basic example of how to use the sphere agent.""" env = holodeck.make("MazeWorld") # This command is to constantly rotate to the right command = 2 for i in range(10): env.reset() for _ in range(1000): state, reward, terminal, _ = env.step(comman...
[ "def", "sphere_example", "(", ")", ":", "env", "=", "holodeck", ".", "make", "(", "\"MazeWorld\"", ")", "# This command is to constantly rotate to the right", "command", "=", "2", "for", "i", "in", "range", "(", "10", ")", ":", "env", ".", "reset", "(", ")",...
A basic example of how to use the sphere agent.
[ "A", "basic", "example", "of", "how", "to", "use", "the", "sphere", "agent", "." ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/example.py#L36-L49
17,263
BYU-PCCL/holodeck
example.py
android_example
def android_example(): """A basic example of how to use the android agent.""" env = holodeck.make("AndroidPlayground") # The Android's command is a 94 length vector representing torques to be applied at each of his joints command = np.ones(94) * 10 for i in range(10): env.reset() fo...
python
def android_example(): """A basic example of how to use the android agent.""" env = holodeck.make("AndroidPlayground") # The Android's command is a 94 length vector representing torques to be applied at each of his joints command = np.ones(94) * 10 for i in range(10): env.reset() fo...
[ "def", "android_example", "(", ")", ":", "env", "=", "holodeck", ".", "make", "(", "\"AndroidPlayground\"", ")", "# The Android's command is a 94 length vector representing torques to be applied at each of his joints", "command", "=", "np", ".", "ones", "(", "94", ")", "*...
A basic example of how to use the android agent.
[ "A", "basic", "example", "of", "how", "to", "use", "the", "android", "agent", "." ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/example.py#L53-L69
17,264
BYU-PCCL/holodeck
example.py
multi_agent_example
def multi_agent_example(): """A basic example of using multiple agents""" env = holodeck.make("UrbanCity") cmd0 = np.array([0, 0, -2, 10]) cmd1 = np.array([0, 0, 5, 10]) for i in range(10): env.reset() # This will queue up a new agent to spawn into the environment, given that the co...
python
def multi_agent_example(): """A basic example of using multiple agents""" env = holodeck.make("UrbanCity") cmd0 = np.array([0, 0, -2, 10]) cmd1 = np.array([0, 0, 5, 10]) for i in range(10): env.reset() # This will queue up a new agent to spawn into the environment, given that the co...
[ "def", "multi_agent_example", "(", ")", ":", "env", "=", "holodeck", ".", "make", "(", "\"UrbanCity\"", ")", "cmd0", "=", "np", ".", "array", "(", "[", "0", ",", "0", ",", "-", "2", ",", "10", "]", ")", "cmd1", "=", "np", ".", "array", "(", "["...
A basic example of using multiple agents
[ "A", "basic", "example", "of", "using", "multiple", "agents" ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/example.py#L73-L96
17,265
BYU-PCCL/holodeck
example.py
world_command_examples
def world_command_examples(): """A few examples to showcase commands for manipulating the worlds.""" env = holodeck.make("MazeWorld") # This is the unaltered MazeWorld for _ in range(300): _ = env.tick() env.reset() # The set_day_time_command sets the hour between 0 and 23 (military ti...
python
def world_command_examples(): """A few examples to showcase commands for manipulating the worlds.""" env = holodeck.make("MazeWorld") # This is the unaltered MazeWorld for _ in range(300): _ = env.tick() env.reset() # The set_day_time_command sets the hour between 0 and 23 (military ti...
[ "def", "world_command_examples", "(", ")", ":", "env", "=", "holodeck", ".", "make", "(", "\"MazeWorld\"", ")", "# This is the unaltered MazeWorld", "for", "_", "in", "range", "(", "300", ")", ":", "_", "=", "env", ".", "tick", "(", ")", "env", ".", "res...
A few examples to showcase commands for manipulating the worlds.
[ "A", "few", "examples", "to", "showcase", "commands", "for", "manipulating", "the", "worlds", "." ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/example.py#L99-L143
17,266
BYU-PCCL/holodeck
example.py
editor_example
def editor_example(): """This editor example shows how to interact with holodeck worlds while they are being built in the Unreal Engine. Most people that use holodeck will not need this. """ sensors = [Sensors.PIXEL_CAMERA, Sensors.LOCATION_SENSOR, Sensors.VELOCITY_SENSOR] agent = AgentDefinition("u...
python
def editor_example(): """This editor example shows how to interact with holodeck worlds while they are being built in the Unreal Engine. Most people that use holodeck will not need this. """ sensors = [Sensors.PIXEL_CAMERA, Sensors.LOCATION_SENSOR, Sensors.VELOCITY_SENSOR] agent = AgentDefinition("u...
[ "def", "editor_example", "(", ")", ":", "sensors", "=", "[", "Sensors", ".", "PIXEL_CAMERA", ",", "Sensors", ".", "LOCATION_SENSOR", ",", "Sensors", ".", "VELOCITY_SENSOR", "]", "agent", "=", "AgentDefinition", "(", "\"uav0\"", ",", "agents", ".", "UavAgent", ...
This editor example shows how to interact with holodeck worlds while they are being built in the Unreal Engine. Most people that use holodeck will not need this.
[ "This", "editor", "example", "shows", "how", "to", "interact", "with", "holodeck", "worlds", "while", "they", "are", "being", "built", "in", "the", "Unreal", "Engine", ".", "Most", "people", "that", "use", "holodeck", "will", "not", "need", "this", "." ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/example.py#L146-L159
17,267
BYU-PCCL/holodeck
example.py
editor_multi_agent_example
def editor_multi_agent_example(): """This editor example shows how to interact with holodeck worlds that have multiple agents. This is specifically for when working with UE4 directly and not a prebuilt binary. """ agent_definitions = [ AgentDefinition("uav0", agents.UavAgent, [Sensors.PIXEL_CAME...
python
def editor_multi_agent_example(): """This editor example shows how to interact with holodeck worlds that have multiple agents. This is specifically for when working with UE4 directly and not a prebuilt binary. """ agent_definitions = [ AgentDefinition("uav0", agents.UavAgent, [Sensors.PIXEL_CAME...
[ "def", "editor_multi_agent_example", "(", ")", ":", "agent_definitions", "=", "[", "AgentDefinition", "(", "\"uav0\"", ",", "agents", ".", "UavAgent", ",", "[", "Sensors", ".", "PIXEL_CAMERA", ",", "Sensors", ".", "LOCATION_SENSOR", "]", ")", ",", "AgentDefiniti...
This editor example shows how to interact with holodeck worlds that have multiple agents. This is specifically for when working with UE4 directly and not a prebuilt binary.
[ "This", "editor", "example", "shows", "how", "to", "interact", "with", "holodeck", "worlds", "that", "have", "multiple", "agents", ".", "This", "is", "specifically", "for", "when", "working", "with", "UE4", "directly", "and", "not", "a", "prebuilt", "binary", ...
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/example.py#L162-L183
17,268
BYU-PCCL/holodeck
holodeck/util.py
get_holodeck_path
def get_holodeck_path(): """Gets the path of the holodeck environment Returns: (str): path to the current holodeck environment """ if "HOLODECKPATH" in os.environ and os.environ["HOLODECKPATH"] != "": return os.environ["HOLODECKPATH"] if os.name == "posix": return os.path.ex...
python
def get_holodeck_path(): """Gets the path of the holodeck environment Returns: (str): path to the current holodeck environment """ if "HOLODECKPATH" in os.environ and os.environ["HOLODECKPATH"] != "": return os.environ["HOLODECKPATH"] if os.name == "posix": return os.path.ex...
[ "def", "get_holodeck_path", "(", ")", ":", "if", "\"HOLODECKPATH\"", "in", "os", ".", "environ", "and", "os", ".", "environ", "[", "\"HOLODECKPATH\"", "]", "!=", "\"\"", ":", "return", "os", ".", "environ", "[", "\"HOLODECKPATH\"", "]", "if", "os", ".", ...
Gets the path of the holodeck environment Returns: (str): path to the current holodeck environment
[ "Gets", "the", "path", "of", "the", "holodeck", "environment" ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/util.py#L11-L24
17,269
BYU-PCCL/holodeck
holodeck/util.py
convert_unicode
def convert_unicode(value): """Resolves python 2 issue with json loading in unicode instead of string Args: value (str): Unicode value to be converted Returns: (str): converted string """ if isinstance(value, dict): return {convert_unicode(key): convert_unicode(value) ...
python
def convert_unicode(value): """Resolves python 2 issue with json loading in unicode instead of string Args: value (str): Unicode value to be converted Returns: (str): converted string """ if isinstance(value, dict): return {convert_unicode(key): convert_unicode(value) ...
[ "def", "convert_unicode", "(", "value", ")", ":", "if", "isinstance", "(", "value", ",", "dict", ")", ":", "return", "{", "convert_unicode", "(", "key", ")", ":", "convert_unicode", "(", "value", ")", "for", "key", ",", "value", "in", "value", ".", "it...
Resolves python 2 issue with json loading in unicode instead of string Args: value (str): Unicode value to be converted Returns: (str): converted string
[ "Resolves", "python", "2", "issue", "with", "json", "loading", "in", "unicode", "instead", "of", "string" ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/util.py#L27-L45
17,270
BYU-PCCL/holodeck
holodeck/environments.py
HolodeckEnvironment.info
def info(self): """Returns a string with specific information about the environment. This information includes which agents are in the environment and which sensors they have. Returns: str: The information in a string format. """ result = list() result.append...
python
def info(self): """Returns a string with specific information about the environment. This information includes which agents are in the environment and which sensors they have. Returns: str: The information in a string format. """ result = list() result.append...
[ "def", "info", "(", "self", ")", ":", "result", "=", "list", "(", ")", "result", ".", "append", "(", "\"Agents:\\n\"", ")", "for", "agent", "in", "self", ".", "_all_agents", ":", "result", ".", "append", "(", "\"\\tName: \"", ")", "result", ".", "appen...
Returns a string with specific information about the environment. This information includes which agents are in the environment and which sensors they have. Returns: str: The information in a string format.
[ "Returns", "a", "string", "with", "specific", "information", "about", "the", "environment", ".", "This", "information", "includes", "which", "agents", "are", "in", "the", "environment", "and", "which", "sensors", "they", "have", "." ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/environments.py#L142-L162
17,271
BYU-PCCL/holodeck
holodeck/environments.py
HolodeckEnvironment.reset
def reset(self): """Resets the environment, and returns the state. If it is a single agent environment, it returns that state for that agent. Otherwise, it returns a dict from agent name to state. Returns: tuple or dict: For single agent environment, returns the same as `ste...
python
def reset(self): """Resets the environment, and returns the state. If it is a single agent environment, it returns that state for that agent. Otherwise, it returns a dict from agent name to state. Returns: tuple or dict: For single agent environment, returns the same as `ste...
[ "def", "reset", "(", "self", ")", ":", "self", ".", "_reset_ptr", "[", "0", "]", "=", "True", "self", ".", "_commands", ".", "clear", "(", ")", "for", "_", "in", "range", "(", "self", ".", "_pre_start_steps", "+", "1", ")", ":", "self", ".", "tic...
Resets the environment, and returns the state. If it is a single agent environment, it returns that state for that agent. Otherwise, it returns a dict from agent name to state. Returns: tuple or dict: For single agent environment, returns the same as `step`. For mult...
[ "Resets", "the", "environment", "and", "returns", "the", "state", ".", "If", "it", "is", "a", "single", "agent", "environment", "it", "returns", "that", "state", "for", "that", "agent", ".", "Otherwise", "it", "returns", "a", "dict", "from", "agent", "name...
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/environments.py#L164-L179
17,272
BYU-PCCL/holodeck
holodeck/environments.py
HolodeckEnvironment.step
def step(self, action): """Supplies an action to the main agent and tells the environment to tick once. Primary mode of interaction for single agent environments. Args: action (np.ndarray): An action for the main agent to carry out on the next tick. Returns: tup...
python
def step(self, action): """Supplies an action to the main agent and tells the environment to tick once. Primary mode of interaction for single agent environments. Args: action (np.ndarray): An action for the main agent to carry out on the next tick. Returns: tup...
[ "def", "step", "(", "self", ",", "action", ")", ":", "self", ".", "_agent", ".", "act", "(", "action", ")", "self", ".", "_handle_command_buffer", "(", ")", "self", ".", "_client", ".", "release", "(", ")", "self", ".", "_client", ".", "acquire", "("...
Supplies an action to the main agent and tells the environment to tick once. Primary mode of interaction for single agent environments. Args: action (np.ndarray): An action for the main agent to carry out on the next tick. Returns: tuple: The (state, reward, terminal, i...
[ "Supplies", "an", "action", "to", "the", "main", "agent", "and", "tells", "the", "environment", "to", "tick", "once", ".", "Primary", "mode", "of", "interaction", "for", "single", "agent", "environments", "." ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/environments.py#L181-L202
17,273
BYU-PCCL/holodeck
holodeck/environments.py
HolodeckEnvironment.teleport
def teleport(self, agent_name, location=None, rotation=None): """Teleports the target agent to any given location, and applies a specific rotation. Args: agent_name (str): The name of the agent to teleport. location (np.ndarray or list): XYZ coordinates (in meters) for the agent...
python
def teleport(self, agent_name, location=None, rotation=None): """Teleports the target agent to any given location, and applies a specific rotation. Args: agent_name (str): The name of the agent to teleport. location (np.ndarray or list): XYZ coordinates (in meters) for the agent...
[ "def", "teleport", "(", "self", ",", "agent_name", ",", "location", "=", "None", ",", "rotation", "=", "None", ")", ":", "self", ".", "agents", "[", "agent_name", "]", ".", "teleport", "(", "location", "*", "100", ",", "rotation", ")", "# * 100 to conver...
Teleports the target agent to any given location, and applies a specific rotation. Args: agent_name (str): The name of the agent to teleport. location (np.ndarray or list): XYZ coordinates (in meters) for the agent to be teleported to. If no location is given, it isn't t...
[ "Teleports", "the", "target", "agent", "to", "any", "given", "location", "and", "applies", "a", "specific", "rotation", "." ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/environments.py#L204-L215
17,274
BYU-PCCL/holodeck
holodeck/environments.py
HolodeckEnvironment.tick
def tick(self): """Ticks the environment once. Normally used for multi-agent environments. Returns: dict: A dictionary from agent name to its full state. The full state is another dictionary from :obj:`holodeck.sensors.Sensors` enum to np.ndarray, containing the sensors informat...
python
def tick(self): """Ticks the environment once. Normally used for multi-agent environments. Returns: dict: A dictionary from agent name to its full state. The full state is another dictionary from :obj:`holodeck.sensors.Sensors` enum to np.ndarray, containing the sensors informat...
[ "def", "tick", "(", "self", ")", ":", "self", ".", "_handle_command_buffer", "(", ")", "self", ".", "_client", ".", "release", "(", ")", "self", ".", "_client", ".", "acquire", "(", ")", "return", "self", ".", "_get_full_state", "(", ")" ]
Ticks the environment once. Normally used for multi-agent environments. Returns: dict: A dictionary from agent name to its full state. The full state is another dictionary from :obj:`holodeck.sensors.Sensors` enum to np.ndarray, containing the sensors information for each se...
[ "Ticks", "the", "environment", "once", ".", "Normally", "used", "for", "multi", "-", "agent", "environments", "." ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/environments.py#L229-L240
17,275
BYU-PCCL/holodeck
holodeck/environments.py
HolodeckEnvironment.add_state_sensors
def add_state_sensors(self, agent_name, sensors): """Adds a sensor to a particular agent. This only works if the world you are running also includes that particular sensor on the agent. Args: agent_name (str): The name of the agent to add the sensor to. sensors (:obj:`Ho...
python
def add_state_sensors(self, agent_name, sensors): """Adds a sensor to a particular agent. This only works if the world you are running also includes that particular sensor on the agent. Args: agent_name (str): The name of the agent to add the sensor to. sensors (:obj:`Ho...
[ "def", "add_state_sensors", "(", "self", ",", "agent_name", ",", "sensors", ")", ":", "if", "isinstance", "(", "sensors", ",", "list", ")", ":", "for", "sensor", "in", "sensors", ":", "self", ".", "add_state_sensors", "(", "agent_name", ",", "sensor", ")",...
Adds a sensor to a particular agent. This only works if the world you are running also includes that particular sensor on the agent. Args: agent_name (str): The name of the agent to add the sensor to. sensors (:obj:`HolodeckSensor` or list of :obj:`HolodeckSensor`): Sensors to a...
[ "Adds", "a", "sensor", "to", "a", "particular", "agent", ".", "This", "only", "works", "if", "the", "world", "you", "are", "running", "also", "includes", "that", "particular", "sensor", "on", "the", "agent", "." ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/environments.py#L242-L260
17,276
BYU-PCCL/holodeck
holodeck/environments.py
HolodeckEnvironment.spawn_agent
def spawn_agent(self, agent_definition, location): """Queues a spawn agent command. It will be applied when `tick` or `step` is called next. The agent won't be able to be used until the next frame. Args: agent_definition (:obj:`AgentDefinition`): The definition of the agent to spawn...
python
def spawn_agent(self, agent_definition, location): """Queues a spawn agent command. It will be applied when `tick` or `step` is called next. The agent won't be able to be used until the next frame. Args: agent_definition (:obj:`AgentDefinition`): The definition of the agent to spawn...
[ "def", "spawn_agent", "(", "self", ",", "agent_definition", ",", "location", ")", ":", "self", ".", "_should_write_to_command_buffer", "=", "True", "self", ".", "_add_agents", "(", "agent_definition", ")", "command_to_send", "=", "SpawnAgentCommand", "(", "location"...
Queues a spawn agent command. It will be applied when `tick` or `step` is called next. The agent won't be able to be used until the next frame. Args: agent_definition (:obj:`AgentDefinition`): The definition of the agent to spawn. location (np.ndarray or list): The position to s...
[ "Queues", "a", "spawn", "agent", "command", ".", "It", "will", "be", "applied", "when", "tick", "or", "step", "is", "called", "next", ".", "The", "agent", "won", "t", "be", "able", "to", "be", "used", "until", "the", "next", "frame", "." ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/environments.py#L262-L273
17,277
BYU-PCCL/holodeck
holodeck/environments.py
HolodeckEnvironment.set_fog_density
def set_fog_density(self, density): """Queue up a change fog density command. It will be applied when `tick` or `step` is called next. By the next tick, the exponential height fog in the world will have the new density. If there is no fog in the world, it will be automatically created with the g...
python
def set_fog_density(self, density): """Queue up a change fog density command. It will be applied when `tick` or `step` is called next. By the next tick, the exponential height fog in the world will have the new density. If there is no fog in the world, it will be automatically created with the g...
[ "def", "set_fog_density", "(", "self", ",", "density", ")", ":", "if", "density", "<", "0", "or", "density", ">", "1", ":", "raise", "HolodeckException", "(", "\"Fog density should be between 0 and 1\"", ")", "self", ".", "_should_write_to_command_buffer", "=", "T...
Queue up a change fog density command. It will be applied when `tick` or `step` is called next. By the next tick, the exponential height fog in the world will have the new density. If there is no fog in the world, it will be automatically created with the given density. Args: densit...
[ "Queue", "up", "a", "change", "fog", "density", "command", ".", "It", "will", "be", "applied", "when", "tick", "or", "step", "is", "called", "next", ".", "By", "the", "next", "tick", "the", "exponential", "height", "fog", "in", "the", "world", "will", ...
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/environments.py#L275-L289
17,278
BYU-PCCL/holodeck
holodeck/environments.py
HolodeckEnvironment.set_day_time
def set_day_time(self, hour): """Queue up a change day time command. It will be applied when `tick` or `step` is called next. By the next tick, the lighting and the skysphere will be updated with the new hour. If there is no skysphere or directional light in the world, the command will not funct...
python
def set_day_time(self, hour): """Queue up a change day time command. It will be applied when `tick` or `step` is called next. By the next tick, the lighting and the skysphere will be updated with the new hour. If there is no skysphere or directional light in the world, the command will not funct...
[ "def", "set_day_time", "(", "self", ",", "hour", ")", ":", "self", ".", "_should_write_to_command_buffer", "=", "True", "command_to_send", "=", "DayTimeCommand", "(", "hour", "%", "24", ")", "self", ".", "_commands", ".", "add_command", "(", "command_to_send", ...
Queue up a change day time command. It will be applied when `tick` or `step` is called next. By the next tick, the lighting and the skysphere will be updated with the new hour. If there is no skysphere or directional light in the world, the command will not function properly but will not cause a crash. ...
[ "Queue", "up", "a", "change", "day", "time", "command", ".", "It", "will", "be", "applied", "when", "tick", "or", "step", "is", "called", "next", ".", "By", "the", "next", "tick", "the", "lighting", "and", "the", "skysphere", "will", "be", "updated", "...
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/environments.py#L291-L301
17,279
BYU-PCCL/holodeck
holodeck/environments.py
HolodeckEnvironment.start_day_cycle
def start_day_cycle(self, day_length): """Queue up a day cycle command to start the day cycle. It will be applied when `tick` or `step` is called next. The sky sphere will now update each tick with an updated sun angle as it moves about the sky. The length of a day will be roughly equivalent to ...
python
def start_day_cycle(self, day_length): """Queue up a day cycle command to start the day cycle. It will be applied when `tick` or `step` is called next. The sky sphere will now update each tick with an updated sun angle as it moves about the sky. The length of a day will be roughly equivalent to ...
[ "def", "start_day_cycle", "(", "self", ",", "day_length", ")", ":", "if", "day_length", "<=", "0", ":", "raise", "HolodeckException", "(", "\"The given day length should be between above 0!\"", ")", "self", ".", "_should_write_to_command_buffer", "=", "True", "command_t...
Queue up a day cycle command to start the day cycle. It will be applied when `tick` or `step` is called next. The sky sphere will now update each tick with an updated sun angle as it moves about the sky. The length of a day will be roughly equivalent to the number of minutes given. Args: ...
[ "Queue", "up", "a", "day", "cycle", "command", "to", "start", "the", "day", "cycle", ".", "It", "will", "be", "applied", "when", "tick", "or", "step", "is", "called", "next", ".", "The", "sky", "sphere", "will", "now", "update", "each", "tick", "with",...
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/environments.py#L303-L317
17,280
BYU-PCCL/holodeck
holodeck/environments.py
HolodeckEnvironment.stop_day_cycle
def stop_day_cycle(self): """Queue up a day cycle command to stop the day cycle. It will be applied when `tick` or `step` is called next. By the next tick, day cycle will stop where it is. """ self._should_write_to_command_buffer = True command_to_send = DayCycleCommand(False) ...
python
def stop_day_cycle(self): """Queue up a day cycle command to stop the day cycle. It will be applied when `tick` or `step` is called next. By the next tick, day cycle will stop where it is. """ self._should_write_to_command_buffer = True command_to_send = DayCycleCommand(False) ...
[ "def", "stop_day_cycle", "(", "self", ")", ":", "self", ".", "_should_write_to_command_buffer", "=", "True", "command_to_send", "=", "DayCycleCommand", "(", "False", ")", "self", ".", "_commands", ".", "add_command", "(", "command_to_send", ")" ]
Queue up a day cycle command to stop the day cycle. It will be applied when `tick` or `step` is called next. By the next tick, day cycle will stop where it is.
[ "Queue", "up", "a", "day", "cycle", "command", "to", "stop", "the", "day", "cycle", ".", "It", "will", "be", "applied", "when", "tick", "or", "step", "is", "called", "next", ".", "By", "the", "next", "tick", "day", "cycle", "will", "stop", "where", "...
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/environments.py#L319-L325
17,281
BYU-PCCL/holodeck
holodeck/environments.py
HolodeckEnvironment.teleport_camera
def teleport_camera(self, location, rotation): """Queue up a teleport camera command to stop the day cycle. By the next tick, the camera's location and rotation will be updated """ self._should_write_to_command_buffer = True command_to_send = TeleportCameraCommand(location, rotat...
python
def teleport_camera(self, location, rotation): """Queue up a teleport camera command to stop the day cycle. By the next tick, the camera's location and rotation will be updated """ self._should_write_to_command_buffer = True command_to_send = TeleportCameraCommand(location, rotat...
[ "def", "teleport_camera", "(", "self", ",", "location", ",", "rotation", ")", ":", "self", ".", "_should_write_to_command_buffer", "=", "True", "command_to_send", "=", "TeleportCameraCommand", "(", "location", ",", "rotation", ")", "self", ".", "_commands", ".", ...
Queue up a teleport camera command to stop the day cycle. By the next tick, the camera's location and rotation will be updated
[ "Queue", "up", "a", "teleport", "camera", "command", "to", "stop", "the", "day", "cycle", ".", "By", "the", "next", "tick", "the", "camera", "s", "location", "and", "rotation", "will", "be", "updated" ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/environments.py#L327-L333
17,282
BYU-PCCL/holodeck
holodeck/environments.py
HolodeckEnvironment.set_control_scheme
def set_control_scheme(self, agent_name, control_scheme): """Set the control scheme for a specific agent. Args: agent_name (str): The name of the agent to set the control scheme for. control_scheme (int): A control scheme value (see :obj:`holodeck.agents.ControlSchemes`) ...
python
def set_control_scheme(self, agent_name, control_scheme): """Set the control scheme for a specific agent. Args: agent_name (str): The name of the agent to set the control scheme for. control_scheme (int): A control scheme value (see :obj:`holodeck.agents.ControlSchemes`) ...
[ "def", "set_control_scheme", "(", "self", ",", "agent_name", ",", "control_scheme", ")", ":", "if", "agent_name", "not", "in", "self", ".", "agents", ":", "print", "(", "\"No such agent %s\"", "%", "agent_name", ")", "else", ":", "self", ".", "agents", "[", ...
Set the control scheme for a specific agent. Args: agent_name (str): The name of the agent to set the control scheme for. control_scheme (int): A control scheme value (see :obj:`holodeck.agents.ControlSchemes`)
[ "Set", "the", "control", "scheme", "for", "a", "specific", "agent", "." ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/environments.py#L357-L367
17,283
BYU-PCCL/holodeck
holodeck/environments.py
HolodeckEnvironment._handle_command_buffer
def _handle_command_buffer(self): """Checks if we should write to the command buffer, writes all of the queued commands to the buffer, and then clears the contents of the self._commands list""" if self._should_write_to_command_buffer: self._write_to_command_buffer(self._commands.to_j...
python
def _handle_command_buffer(self): """Checks if we should write to the command buffer, writes all of the queued commands to the buffer, and then clears the contents of the self._commands list""" if self._should_write_to_command_buffer: self._write_to_command_buffer(self._commands.to_j...
[ "def", "_handle_command_buffer", "(", "self", ")", ":", "if", "self", ".", "_should_write_to_command_buffer", ":", "self", ".", "_write_to_command_buffer", "(", "self", ".", "_commands", ".", "to_json", "(", ")", ")", "self", ".", "_should_write_to_command_buffer", ...
Checks if we should write to the command buffer, writes all of the queued commands to the buffer, and then clears the contents of the self._commands list
[ "Checks", "if", "we", "should", "write", "to", "the", "command", "buffer", "writes", "all", "of", "the", "queued", "commands", "to", "the", "buffer", "and", "then", "clears", "the", "contents", "of", "the", "self", ".", "_commands", "list" ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/environments.py#L423-L429
17,284
BYU-PCCL/holodeck
holodeck/environments.py
HolodeckEnvironment._write_to_command_buffer
def _write_to_command_buffer(self, to_write): """Write input to the command buffer. Reformat input string to the correct format. Args: to_write (str): The string to write to the command buffer. """ # TODO(mitch): Handle the edge case of writing too much data to the buffer. ...
python
def _write_to_command_buffer(self, to_write): """Write input to the command buffer. Reformat input string to the correct format. Args: to_write (str): The string to write to the command buffer. """ # TODO(mitch): Handle the edge case of writing too much data to the buffer. ...
[ "def", "_write_to_command_buffer", "(", "self", ",", "to_write", ")", ":", "# TODO(mitch): Handle the edge case of writing too much data to the buffer.", "np", ".", "copyto", "(", "self", ".", "_command_bool_ptr", ",", "True", ")", "to_write", "+=", "'0'", "# The gason JS...
Write input to the command buffer. Reformat input string to the correct format. Args: to_write (str): The string to write to the command buffer.
[ "Write", "input", "to", "the", "command", "buffer", ".", "Reformat", "input", "string", "to", "the", "correct", "format", "." ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/environments.py#L453-L464
17,285
BYU-PCCL/holodeck
holodeck/agents.py
HolodeckAgent.teleport
def teleport(self, location=None, rotation=None): """Teleports the agent to a specific location, with a specific rotation. Args: location (np.ndarray, optional): An array with three elements specifying the target world coordinate in meters. If None, keeps the current location. D...
python
def teleport(self, location=None, rotation=None): """Teleports the agent to a specific location, with a specific rotation. Args: location (np.ndarray, optional): An array with three elements specifying the target world coordinate in meters. If None, keeps the current location. D...
[ "def", "teleport", "(", "self", ",", "location", "=", "None", ",", "rotation", "=", "None", ")", ":", "val", "=", "0", "if", "location", "is", "not", "None", ":", "val", "+=", "1", "np", ".", "copyto", "(", "self", ".", "_teleport_buffer", ",", "lo...
Teleports the agent to a specific location, with a specific rotation. Args: location (np.ndarray, optional): An array with three elements specifying the target world coordinate in meters. If None, keeps the current location. Defaults to None. rotation (np.ndarray, optional):...
[ "Teleports", "the", "agent", "to", "a", "specific", "location", "with", "a", "specific", "rotation", "." ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/agents.py#L79-L98
17,286
browniebroke/deezer-python
deezer/client.py
Client.url
def url(self, request=""): """Build the url with the appended request if provided.""" if request.startswith("/"): request = request[1:] return "{}://{}/{}".format(self.scheme, self.host, request)
python
def url(self, request=""): """Build the url with the appended request if provided.""" if request.startswith("/"): request = request[1:] return "{}://{}/{}".format(self.scheme, self.host, request)
[ "def", "url", "(", "self", ",", "request", "=", "\"\"", ")", ":", "if", "request", ".", "startswith", "(", "\"/\"", ")", ":", "request", "=", "request", "[", "1", ":", "]", "return", "\"{}://{}/{}\"", ".", "format", "(", "self", ".", "scheme", ",", ...
Build the url with the appended request if provided.
[ "Build", "the", "url", "with", "the", "appended", "request", "if", "provided", "." ]
fb869c3617045b22e7124e4b783ec1a68d283ac3
https://github.com/browniebroke/deezer-python/blob/fb869c3617045b22e7124e4b783ec1a68d283ac3/deezer/client.py#L95-L99
17,287
browniebroke/deezer-python
deezer/client.py
Client.object_url
def object_url(self, object_t, object_id=None, relation=None, **kwargs): """ Helper method to build the url to query to access the object passed as parameter :raises TypeError: if the object type is invalid """ if object_t not in self.objects_types: raise Typ...
python
def object_url(self, object_t, object_id=None, relation=None, **kwargs): """ Helper method to build the url to query to access the object passed as parameter :raises TypeError: if the object type is invalid """ if object_t not in self.objects_types: raise Typ...
[ "def", "object_url", "(", "self", ",", "object_t", ",", "object_id", "=", "None", ",", "relation", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "object_t", "not", "in", "self", ".", "objects_types", ":", "raise", "TypeError", "(", "\"{} is not a...
Helper method to build the url to query to access the object passed as parameter :raises TypeError: if the object type is invalid
[ "Helper", "method", "to", "build", "the", "url", "to", "query", "to", "access", "the", "object", "passed", "as", "parameter" ]
fb869c3617045b22e7124e4b783ec1a68d283ac3
https://github.com/browniebroke/deezer-python/blob/fb869c3617045b22e7124e4b783ec1a68d283ac3/deezer/client.py#L101-L126
17,288
browniebroke/deezer-python
deezer/client.py
Client.get_album
def get_album(self, object_id, relation=None, **kwargs): """ Get the album with the provided id :returns: an :class:`~deezer.resources.Album` object """ return self.get_object("album", object_id, relation=relation, **kwargs)
python
def get_album(self, object_id, relation=None, **kwargs): """ Get the album with the provided id :returns: an :class:`~deezer.resources.Album` object """ return self.get_object("album", object_id, relation=relation, **kwargs)
[ "def", "get_album", "(", "self", ",", "object_id", ",", "relation", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "get_object", "(", "\"album\"", ",", "object_id", ",", "relation", "=", "relation", ",", "*", "*", "kwargs", ")" ...
Get the album with the provided id :returns: an :class:`~deezer.resources.Album` object
[ "Get", "the", "album", "with", "the", "provided", "id" ]
fb869c3617045b22e7124e4b783ec1a68d283ac3
https://github.com/browniebroke/deezer-python/blob/fb869c3617045b22e7124e4b783ec1a68d283ac3/deezer/client.py#L150-L156
17,289
browniebroke/deezer-python
deezer/client.py
Client.get_artist
def get_artist(self, object_id, relation=None, **kwargs): """ Get the artist with the provided id :returns: an :class:`~deezer.resources.Artist` object """ return self.get_object("artist", object_id, relation=relation, **kwargs)
python
def get_artist(self, object_id, relation=None, **kwargs): """ Get the artist with the provided id :returns: an :class:`~deezer.resources.Artist` object """ return self.get_object("artist", object_id, relation=relation, **kwargs)
[ "def", "get_artist", "(", "self", ",", "object_id", ",", "relation", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "get_object", "(", "\"artist\"", ",", "object_id", ",", "relation", "=", "relation", ",", "*", "*", "kwargs", ")...
Get the artist with the provided id :returns: an :class:`~deezer.resources.Artist` object
[ "Get", "the", "artist", "with", "the", "provided", "id" ]
fb869c3617045b22e7124e4b783ec1a68d283ac3
https://github.com/browniebroke/deezer-python/blob/fb869c3617045b22e7124e4b783ec1a68d283ac3/deezer/client.py#L158-L164
17,290
browniebroke/deezer-python
deezer/client.py
Client.search
def search(self, query, relation=None, index=0, limit=25, **kwargs): """ Search track, album, artist or user :returns: a list of :class:`~deezer.resources.Resource` objects. """ return self.get_object( "search", relation=relation, q=query, index=index, limit=limit, *...
python
def search(self, query, relation=None, index=0, limit=25, **kwargs): """ Search track, album, artist or user :returns: a list of :class:`~deezer.resources.Resource` objects. """ return self.get_object( "search", relation=relation, q=query, index=index, limit=limit, *...
[ "def", "search", "(", "self", ",", "query", ",", "relation", "=", "None", ",", "index", "=", "0", ",", "limit", "=", "25", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "get_object", "(", "\"search\"", ",", "relation", "=", "relation", ...
Search track, album, artist or user :returns: a list of :class:`~deezer.resources.Resource` objects.
[ "Search", "track", "album", "artist", "or", "user" ]
fb869c3617045b22e7124e4b783ec1a68d283ac3
https://github.com/browniebroke/deezer-python/blob/fb869c3617045b22e7124e4b783ec1a68d283ac3/deezer/client.py#L236-L244
17,291
browniebroke/deezer-python
deezer/client.py
Client.advanced_search
def advanced_search(self, terms, relation=None, index=0, limit=25, **kwargs): """ Advanced search of track, album or artist. See `Search section of Deezer API <https://developers.deezer.com/api/search>`_ for search terms. :returns: a list of :class:`~deezer.resources.Resource` ...
python
def advanced_search(self, terms, relation=None, index=0, limit=25, **kwargs): """ Advanced search of track, album or artist. See `Search section of Deezer API <https://developers.deezer.com/api/search>`_ for search terms. :returns: a list of :class:`~deezer.resources.Resource` ...
[ "def", "advanced_search", "(", "self", ",", "terms", ",", "relation", "=", "None", ",", "index", "=", "0", ",", "limit", "=", "25", ",", "*", "*", "kwargs", ")", ":", "assert", "isinstance", "(", "terms", ",", "dict", ")", ",", "\"terms must be a dict\...
Advanced search of track, album or artist. See `Search section of Deezer API <https://developers.deezer.com/api/search>`_ for search terms. :returns: a list of :class:`~deezer.resources.Resource` objects. >>> client.advanced_search({"artist": "Daft Punk", "album": "Homework"}) ...
[ "Advanced", "search", "of", "track", "album", "or", "artist", "." ]
fb869c3617045b22e7124e4b783ec1a68d283ac3
https://github.com/browniebroke/deezer-python/blob/fb869c3617045b22e7124e4b783ec1a68d283ac3/deezer/client.py#L246-L264
17,292
browniebroke/deezer-python
deezer/resources.py
Resource.asdict
def asdict(self): """ Convert resource to dictionary """ result = {} for key in self._fields: value = getattr(self, key) if isinstance(value, list): value = [i.asdict() if isinstance(i, Resource) else i for i in value] if isinst...
python
def asdict(self): """ Convert resource to dictionary """ result = {} for key in self._fields: value = getattr(self, key) if isinstance(value, list): value = [i.asdict() if isinstance(i, Resource) else i for i in value] if isinst...
[ "def", "asdict", "(", "self", ")", ":", "result", "=", "{", "}", "for", "key", "in", "self", ".", "_fields", ":", "value", "=", "getattr", "(", "self", ",", "key", ")", "if", "isinstance", "(", "value", ",", "list", ")", ":", "value", "=", "[", ...
Convert resource to dictionary
[ "Convert", "resource", "to", "dictionary" ]
fb869c3617045b22e7124e4b783ec1a68d283ac3
https://github.com/browniebroke/deezer-python/blob/fb869c3617045b22e7124e4b783ec1a68d283ac3/deezer/resources.py#L28-L40
17,293
browniebroke/deezer-python
deezer/resources.py
Resource.get_relation
def get_relation(self, relation, **kwargs): """ Generic method to load the relation from any resource. Query the client with the object's known parameters and try to retrieve the provided relation type. This is not meant to be used directly by a client, it's more a helpe...
python
def get_relation(self, relation, **kwargs): """ Generic method to load the relation from any resource. Query the client with the object's known parameters and try to retrieve the provided relation type. This is not meant to be used directly by a client, it's more a helpe...
[ "def", "get_relation", "(", "self", ",", "relation", ",", "*", "*", "kwargs", ")", ":", "# pylint: disable=E1101", "return", "self", ".", "client", ".", "get_object", "(", "self", ".", "type", ",", "self", ".", "id", ",", "relation", ",", "self", ",", ...
Generic method to load the relation from any resource. Query the client with the object's known parameters and try to retrieve the provided relation type. This is not meant to be used directly by a client, it's more a helper method for the child objects.
[ "Generic", "method", "to", "load", "the", "relation", "from", "any", "resource", "." ]
fb869c3617045b22e7124e4b783ec1a68d283ac3
https://github.com/browniebroke/deezer-python/blob/fb869c3617045b22e7124e4b783ec1a68d283ac3/deezer/resources.py#L42-L52
17,294
browniebroke/deezer-python
deezer/resources.py
Resource.iter_relation
def iter_relation(self, relation, **kwargs): """ Generic method to iterate relation from any resource. Query the client with the object's known parameters and try to retrieve the provided relation type. This is not meant to be used directly by a client, it's more a helpe...
python
def iter_relation(self, relation, **kwargs): """ Generic method to iterate relation from any resource. Query the client with the object's known parameters and try to retrieve the provided relation type. This is not meant to be used directly by a client, it's more a helpe...
[ "def", "iter_relation", "(", "self", ",", "relation", ",", "*", "*", "kwargs", ")", ":", "# pylint: disable=E1101", "index", "=", "0", "while", "1", ":", "items", "=", "self", ".", "get_relation", "(", "relation", ",", "index", "=", "index", ",", "*", ...
Generic method to iterate relation from any resource. Query the client with the object's known parameters and try to retrieve the provided relation type. This is not meant to be used directly by a client, it's more a helper method for the child objects.
[ "Generic", "method", "to", "iterate", "relation", "from", "any", "resource", "." ]
fb869c3617045b22e7124e4b783ec1a68d283ac3
https://github.com/browniebroke/deezer-python/blob/fb869c3617045b22e7124e4b783ec1a68d283ac3/deezer/resources.py#L54-L72
17,295
lambdamusic/Ontospy
ontospy/ontodocs/viz/viz_sigmajs.py
run
def run(graph, save_on_github=False, main_entity=None): """ 2016-11-30 """ try: ontology = graph.all_ontologies[0] uri = ontology.uri except: ontology = None uri = ";".join([s for s in graph.sources]) # ontotemplate = open("template.html", "r") ontotemplate ...
python
def run(graph, save_on_github=False, main_entity=None): """ 2016-11-30 """ try: ontology = graph.all_ontologies[0] uri = ontology.uri except: ontology = None uri = ";".join([s for s in graph.sources]) # ontotemplate = open("template.html", "r") ontotemplate ...
[ "def", "run", "(", "graph", ",", "save_on_github", "=", "False", ",", "main_entity", "=", "None", ")", ":", "try", ":", "ontology", "=", "graph", ".", "all_ontologies", "[", "0", "]", "uri", "=", "ontology", ".", "uri", "except", ":", "ontology", "=", ...
2016-11-30
[ "2016", "-", "11", "-", "30" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/ontodocs/viz/viz_sigmajs.py#L149-L204
17,296
lambdamusic/Ontospy
ontospy/core/rdf_loader.py
RDFLoader._debugGraph
def _debugGraph(self): """internal util to print out contents of graph""" print("Len of graph: ", len(self.rdflib_graph)) for x, y, z in self.rdflib_graph: print(x, y, z)
python
def _debugGraph(self): """internal util to print out contents of graph""" print("Len of graph: ", len(self.rdflib_graph)) for x, y, z in self.rdflib_graph: print(x, y, z)
[ "def", "_debugGraph", "(", "self", ")", ":", "print", "(", "\"Len of graph: \"", ",", "len", "(", "self", ".", "rdflib_graph", ")", ")", "for", "x", ",", "y", ",", "z", "in", "self", ".", "rdflib_graph", ":", "print", "(", "x", ",", "y", ",", "z", ...
internal util to print out contents of graph
[ "internal", "util", "to", "print", "out", "contents", "of", "graph" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/core/rdf_loader.py#L61-L65
17,297
lambdamusic/Ontospy
ontospy/core/rdf_loader.py
RDFLoader.load_uri
def load_uri(self, uri): """ Load a single resource into the graph for this object. Approach: try loading into a temporary graph first, if that succeeds merge it into the main graph. This allows to deal with the JSONLD loading issues which can solved only by using a ConjunctiveGraph (https://...
python
def load_uri(self, uri): """ Load a single resource into the graph for this object. Approach: try loading into a temporary graph first, if that succeeds merge it into the main graph. This allows to deal with the JSONLD loading issues which can solved only by using a ConjunctiveGraph (https://...
[ "def", "load_uri", "(", "self", ",", "uri", ")", ":", "# if self.verbose: printDebug(\"----------\")", "if", "self", ".", "verbose", ":", "printDebug", "(", "\"Reading: <%s>\"", "%", "uri", ",", "fg", "=", "\"green\"", ")", "success", "=", "False", "sorted_fmt_o...
Load a single resource into the graph for this object. Approach: try loading into a temporary graph first, if that succeeds merge it into the main graph. This allows to deal with the JSONLD loading issues which can solved only by using a ConjunctiveGraph (https://github.com/RDFLib/rdflib/issues/436). Also it...
[ "Load", "a", "single", "resource", "into", "the", "graph", "for", "this", "object", "." ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/core/rdf_loader.py#L114-L158
17,298
lambdamusic/Ontospy
ontospy/core/rdf_loader.py
RDFLoader.print_summary
def print_summary(self): """ print out stats about loading operation """ if self.sources_valid: printDebug( "----------\nLoaded %d triples.\n----------" % len( self.rdflib_graph), fg='white') printDebug( ...
python
def print_summary(self): """ print out stats about loading operation """ if self.sources_valid: printDebug( "----------\nLoaded %d triples.\n----------" % len( self.rdflib_graph), fg='white') printDebug( ...
[ "def", "print_summary", "(", "self", ")", ":", "if", "self", ".", "sources_valid", ":", "printDebug", "(", "\"----------\\nLoaded %d triples.\\n----------\"", "%", "len", "(", "self", ".", "rdflib_graph", ")", ",", "fg", "=", "'white'", ")", "printDebug", "(", ...
print out stats about loading operation
[ "print", "out", "stats", "about", "loading", "operation" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/core/rdf_loader.py#L225-L251
17,299
lambdamusic/Ontospy
ontospy/core/rdf_loader.py
RDFLoader.loading_failed
def loading_failed(self, rdf_format_opts, uri=""): """default message if we need to abort loading""" if uri: uri = " <%s>" % str(uri) printDebug( "----------\nFatal error parsing graph%s\n(using RDF serializations: %s)" % (uri, str(rdf_format_opts)), "red") ...
python
def loading_failed(self, rdf_format_opts, uri=""): """default message if we need to abort loading""" if uri: uri = " <%s>" % str(uri) printDebug( "----------\nFatal error parsing graph%s\n(using RDF serializations: %s)" % (uri, str(rdf_format_opts)), "red") ...
[ "def", "loading_failed", "(", "self", ",", "rdf_format_opts", ",", "uri", "=", "\"\"", ")", ":", "if", "uri", ":", "uri", "=", "\" <%s>\"", "%", "str", "(", "uri", ")", "printDebug", "(", "\"----------\\nFatal error parsing graph%s\\n(using RDF serializations: %s)\"...
default message if we need to abort loading
[ "default", "message", "if", "we", "need", "to", "abort", "loading" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/core/rdf_loader.py#L253-L264