repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
thiagopbueno/rddl2tf
rddl2tf/fluent.py
TensorFluent.min
def min(cls, x: 'TensorFluent', y: 'TensorFluent') -> 'TensorFluent': '''Returns a TensorFluent for the minimum function. Args: x: The first operand. y: The second operand. Returns: A TensorFluent wrapping the minimum function. ''' return cls...
python
def min(cls, x: 'TensorFluent', y: 'TensorFluent') -> 'TensorFluent': '''Returns a TensorFluent for the minimum function. Args: x: The first operand. y: The second operand. Returns: A TensorFluent wrapping the minimum function. ''' return cls...
[ "def", "min", "(", "cls", ",", "x", ":", "'TensorFluent'", ",", "y", ":", "'TensorFluent'", ")", "->", "'TensorFluent'", ":", "return", "cls", ".", "_binary_op", "(", "x", ",", "y", ",", "tf", ".", "minimum", ",", "tf", ".", "float32", ")" ]
Returns a TensorFluent for the minimum function. Args: x: The first operand. y: The second operand. Returns: A TensorFluent wrapping the minimum function.
[ "Returns", "a", "TensorFluent", "for", "the", "minimum", "function", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/fluent.py#L468-L478
thiagopbueno/rddl2tf
rddl2tf/fluent.py
TensorFluent.if_then_else
def if_then_else(cls, condition: 'TensorFluent', true_case: 'TensorFluent', false_case: 'TensorFluent') -> 'TensorFluent': '''Returns a TensorFluent for the control op if-then-else. Args: condition: Boolean fluent for the if condition. true_ca...
python
def if_then_else(cls, condition: 'TensorFluent', true_case: 'TensorFluent', false_case: 'TensorFluent') -> 'TensorFluent': '''Returns a TensorFluent for the control op if-then-else. Args: condition: Boolean fluent for the if condition. true_ca...
[ "def", "if_then_else", "(", "cls", ",", "condition", ":", "'TensorFluent'", ",", "true_case", ":", "'TensorFluent'", ",", "false_case", ":", "'TensorFluent'", ")", "->", "'TensorFluent'", ":", "true", "=", "TensorFluent", ".", "constant", "(", "True", ",", "tf...
Returns a TensorFluent for the control op if-then-else. Args: condition: Boolean fluent for the if condition. true_case: Fluent returned in the true clause. false_case: Fluent returned in the false clause. Returns: A TensorFluent wrapping the if-then-els...
[ "Returns", "a", "TensorFluent", "for", "the", "control", "op", "if", "-", "then", "-", "else", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/fluent.py#L481-L503
thiagopbueno/rddl2tf
rddl2tf/fluent.py
TensorFluent._binary_op
def _binary_op(cls, x: 'TensorFluent', y: 'TensorFluent', op: Callable[[tf.Tensor, tf.Tensor], tf.Tensor], dtype: tf.DType) -> 'TensorFluent': '''Returns a TensorFluent for the binary `op` applied to fluents `x` and `y`. Args: x: The first ope...
python
def _binary_op(cls, x: 'TensorFluent', y: 'TensorFluent', op: Callable[[tf.Tensor, tf.Tensor], tf.Tensor], dtype: tf.DType) -> 'TensorFluent': '''Returns a TensorFluent for the binary `op` applied to fluents `x` and `y`. Args: x: The first ope...
[ "def", "_binary_op", "(", "cls", ",", "x", ":", "'TensorFluent'", ",", "y", ":", "'TensorFluent'", ",", "op", ":", "Callable", "[", "[", "tf", ".", "Tensor", ",", "tf", ".", "Tensor", "]", ",", "tf", ".", "Tensor", "]", ",", "dtype", ":", "tf", "...
Returns a TensorFluent for the binary `op` applied to fluents `x` and `y`. Args: x: The first operand. y: The second operand. op: The binary operator. dtype: The output's data type. Returns: A TensorFluent wrapping the binary operator's outpu...
[ "Returns", "a", "TensorFluent", "for", "the", "binary", "op", "applied", "to", "fluents", "x", "and", "y", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/fluent.py#L506-L550
thiagopbueno/rddl2tf
rddl2tf/fluent.py
TensorFluent._unary_op
def _unary_op(cls, x: 'TensorFluent', op: Callable[[tf.Tensor], tf.Tensor], dtype: tf.DType) -> 'TensorFluent': '''Returns a TensorFluent for the unary `op` applied to fluent `x`. Args: x: The input fluent. op: The unary operation. ...
python
def _unary_op(cls, x: 'TensorFluent', op: Callable[[tf.Tensor], tf.Tensor], dtype: tf.DType) -> 'TensorFluent': '''Returns a TensorFluent for the unary `op` applied to fluent `x`. Args: x: The input fluent. op: The unary operation. ...
[ "def", "_unary_op", "(", "cls", ",", "x", ":", "'TensorFluent'", ",", "op", ":", "Callable", "[", "[", "tf", ".", "Tensor", "]", ",", "tf", ".", "Tensor", "]", ",", "dtype", ":", "tf", ".", "DType", ")", "->", "'TensorFluent'", ":", "x", "=", "x"...
Returns a TensorFluent for the unary `op` applied to fluent `x`. Args: x: The input fluent. op: The unary operation. dtype: The output's data type. Returns: A TensorFluent wrapping the unary operator's output.
[ "Returns", "a", "TensorFluent", "for", "the", "unary", "op", "applied", "to", "fluent", "x", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/fluent.py#L553-L571
thiagopbueno/rddl2tf
rddl2tf/fluent.py
TensorFluent._aggregation_op
def _aggregation_op(cls, op: Callable[[tf.Tensor, Optional[Sequence[int]]], tf.Tensor], x: 'TensorFluent', vars_list: List[str]) -> 'TensorFluent': '''Returns a TensorFluent for the aggregation `op` applied to fluent `x`. Args: op: The aggregation operati...
python
def _aggregation_op(cls, op: Callable[[tf.Tensor, Optional[Sequence[int]]], tf.Tensor], x: 'TensorFluent', vars_list: List[str]) -> 'TensorFluent': '''Returns a TensorFluent for the aggregation `op` applied to fluent `x`. Args: op: The aggregation operati...
[ "def", "_aggregation_op", "(", "cls", ",", "op", ":", "Callable", "[", "[", "tf", ".", "Tensor", ",", "Optional", "[", "Sequence", "[", "int", "]", "]", "]", ",", "tf", ".", "Tensor", "]", ",", "x", ":", "'TensorFluent'", ",", "vars_list", ":", "Li...
Returns a TensorFluent for the aggregation `op` applied to fluent `x`. Args: op: The aggregation operation. x: The input fluent. vars_list: The list of variables to be aggregated over. Returns: A TensorFluent wrapping the aggregation operator's output.
[ "Returns", "a", "TensorFluent", "for", "the", "aggregation", "op", "applied", "to", "fluent", "x", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/fluent.py#L574-L598
thiagopbueno/rddl2tf
rddl2tf/fluent.py
TensorFluent._varslist2axis
def _varslist2axis(cls, fluent: 'TensorFluent', vars_list: List[str]) -> List[int]: '''Maps the `vars_list` into a list of axis indices corresponding to the `fluent` scope. Args: x: The fluent. vars_list: The list of variables to be aggregated over. Returns: ...
python
def _varslist2axis(cls, fluent: 'TensorFluent', vars_list: List[str]) -> List[int]: '''Maps the `vars_list` into a list of axis indices corresponding to the `fluent` scope. Args: x: The fluent. vars_list: The list of variables to be aggregated over. Returns: ...
[ "def", "_varslist2axis", "(", "cls", ",", "fluent", ":", "'TensorFluent'", ",", "vars_list", ":", "List", "[", "str", "]", ")", "->", "List", "[", "int", "]", ":", "axis", "=", "[", "]", "for", "var", "in", "vars_list", ":", "if", "var", "in", "flu...
Maps the `vars_list` into a list of axis indices corresponding to the `fluent` scope. Args: x: The fluent. vars_list: The list of variables to be aggregated over. Returns: List[int]: a list of axis.
[ "Maps", "the", "vars_list", "into", "a", "list", "of", "axis", "indices", "corresponding", "to", "the", "fluent", "scope", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/fluent.py#L601-L619
thiagopbueno/rddl2tf
rddl2tf/fluent.py
TensorFluent.cast
def cast(self, dtype: tf.DType) -> 'TensorFluent': '''Returns a TensorFluent for the cast operation with given `dtype`. Args: dtype: The output's data type. Returns: A TensorFluent wrapping the cast operation. ''' if self.dtype == dtype: retu...
python
def cast(self, dtype: tf.DType) -> 'TensorFluent': '''Returns a TensorFluent for the cast operation with given `dtype`. Args: dtype: The output's data type. Returns: A TensorFluent wrapping the cast operation. ''' if self.dtype == dtype: retu...
[ "def", "cast", "(", "self", ",", "dtype", ":", "tf", ".", "DType", ")", "->", "'TensorFluent'", ":", "if", "self", ".", "dtype", "==", "dtype", ":", "return", "self", "t", "=", "tf", ".", "cast", "(", "self", ".", "tensor", ",", "dtype", ")", "sc...
Returns a TensorFluent for the cast operation with given `dtype`. Args: dtype: The output's data type. Returns: A TensorFluent wrapping the cast operation.
[ "Returns", "a", "TensorFluent", "for", "the", "cast", "operation", "with", "given", "dtype", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/fluent.py#L622-L636
thiagopbueno/rddl2tf
rddl2tf/fluent.py
TensorFluent.reshape
def reshape(self, shape: tf.TensorShape) -> 'TensorFluent': '''Returns a TensorFluent for the reshape operation with given `shape`. Args: shape: The output's shape. Returns: A TensorFluent wrapping the reshape operation. ''' t = tf.reshape(self.tensor, s...
python
def reshape(self, shape: tf.TensorShape) -> 'TensorFluent': '''Returns a TensorFluent for the reshape operation with given `shape`. Args: shape: The output's shape. Returns: A TensorFluent wrapping the reshape operation. ''' t = tf.reshape(self.tensor, s...
[ "def", "reshape", "(", "self", ",", "shape", ":", "tf", ".", "TensorShape", ")", "->", "'TensorFluent'", ":", "t", "=", "tf", ".", "reshape", "(", "self", ".", "tensor", ",", "shape", ")", "scope", "=", "self", ".", "scope", ".", "as_list", "(", ")...
Returns a TensorFluent for the reshape operation with given `shape`. Args: shape: The output's shape. Returns: A TensorFluent wrapping the reshape operation.
[ "Returns", "a", "TensorFluent", "for", "the", "reshape", "operation", "with", "given", "shape", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/fluent.py#L638-L650
thiagopbueno/rddl2tf
rddl2tf/fluent.py
TensorFluent.transpose
def transpose(self, permutation: Optional[List[int]] = None) -> 'TensorFluent': '''Returns a TensorFluent for the transpose operation with given `permutation`. Args: permutation: The output's shape permutation. Returns: A TensorFluent wrapping the transpose operation. ...
python
def transpose(self, permutation: Optional[List[int]] = None) -> 'TensorFluent': '''Returns a TensorFluent for the transpose operation with given `permutation`. Args: permutation: The output's shape permutation. Returns: A TensorFluent wrapping the transpose operation. ...
[ "def", "transpose", "(", "self", ",", "permutation", ":", "Optional", "[", "List", "[", "int", "]", "]", "=", "None", ")", "->", "'TensorFluent'", ":", "if", "permutation", "==", "[", "]", ":", "return", "self", "t", "=", "tf", ".", "transpose", "(",...
Returns a TensorFluent for the transpose operation with given `permutation`. Args: permutation: The output's shape permutation. Returns: A TensorFluent wrapping the transpose operation.
[ "Returns", "a", "TensorFluent", "for", "the", "transpose", "operation", "with", "given", "permutation", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/fluent.py#L652-L666
thiagopbueno/rddl2tf
rddl2tf/fluent.py
TensorFluent.sum
def sum(self, vars_list: List[str]) -> 'TensorFluent': '''Returns the TensorFluent for the sum aggregation function. Args: vars_list: The list of variables to be aggregated over. Returns: A TensorFluent wrapping the sum aggregation function. ''' operand ...
python
def sum(self, vars_list: List[str]) -> 'TensorFluent': '''Returns the TensorFluent for the sum aggregation function. Args: vars_list: The list of variables to be aggregated over. Returns: A TensorFluent wrapping the sum aggregation function. ''' operand ...
[ "def", "sum", "(", "self", ",", "vars_list", ":", "List", "[", "str", "]", ")", "->", "'TensorFluent'", ":", "operand", "=", "self", "if", "operand", ".", "dtype", "==", "tf", ".", "bool", ":", "operand", "=", "operand", ".", "cast", "(", "tf", "."...
Returns the TensorFluent for the sum aggregation function. Args: vars_list: The list of variables to be aggregated over. Returns: A TensorFluent wrapping the sum aggregation function.
[ "Returns", "the", "TensorFluent", "for", "the", "sum", "aggregation", "function", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/fluent.py#L668-L680
thiagopbueno/rddl2tf
rddl2tf/fluent.py
TensorFluent.avg
def avg(self, vars_list: List[str]) -> 'TensorFluent': '''Returns the TensorFluent for the avg aggregation function. Args: vars_list: The list of variables to be aggregated over. Returns: A TensorFluent wrapping the avg aggregation function. ''' operand ...
python
def avg(self, vars_list: List[str]) -> 'TensorFluent': '''Returns the TensorFluent for the avg aggregation function. Args: vars_list: The list of variables to be aggregated over. Returns: A TensorFluent wrapping the avg aggregation function. ''' operand ...
[ "def", "avg", "(", "self", ",", "vars_list", ":", "List", "[", "str", "]", ")", "->", "'TensorFluent'", ":", "operand", "=", "self", "if", "operand", ".", "dtype", "==", "tf", ".", "bool", ":", "operand", "=", "operand", ".", "cast", "(", "tf", "."...
Returns the TensorFluent for the avg aggregation function. Args: vars_list: The list of variables to be aggregated over. Returns: A TensorFluent wrapping the avg aggregation function.
[ "Returns", "the", "TensorFluent", "for", "the", "avg", "aggregation", "function", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/fluent.py#L682-L694
thiagopbueno/rddl2tf
rddl2tf/fluent.py
TensorFluent.prod
def prod(self, vars_list: List[str]) -> 'TensorFluent': '''Returns the TensorFluent for the prod aggregation function. Args: vars_list: The list of variables to be aggregated over. Returns: A TensorFluent wrapping the prod aggregation function. ''' opera...
python
def prod(self, vars_list: List[str]) -> 'TensorFluent': '''Returns the TensorFluent for the prod aggregation function. Args: vars_list: The list of variables to be aggregated over. Returns: A TensorFluent wrapping the prod aggregation function. ''' opera...
[ "def", "prod", "(", "self", ",", "vars_list", ":", "List", "[", "str", "]", ")", "->", "'TensorFluent'", ":", "operand", "=", "self", "if", "operand", ".", "dtype", "==", "tf", ".", "bool", ":", "operand", "=", "operand", ".", "cast", "(", "tf", "....
Returns the TensorFluent for the prod aggregation function. Args: vars_list: The list of variables to be aggregated over. Returns: A TensorFluent wrapping the prod aggregation function.
[ "Returns", "the", "TensorFluent", "for", "the", "prod", "aggregation", "function", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/fluent.py#L696-L708
thiagopbueno/rddl2tf
rddl2tf/fluent.py
TensorFluent.maximum
def maximum(self, vars_list: List[str]) -> 'TensorFluent': '''Returns the TensorFluent for the maximum aggregation function. Args: vars_list: The list of variables to be aggregated over. Returns: A TensorFluent wrapping the maximum aggregation function. ''' ...
python
def maximum(self, vars_list: List[str]) -> 'TensorFluent': '''Returns the TensorFluent for the maximum aggregation function. Args: vars_list: The list of variables to be aggregated over. Returns: A TensorFluent wrapping the maximum aggregation function. ''' ...
[ "def", "maximum", "(", "self", ",", "vars_list", ":", "List", "[", "str", "]", ")", "->", "'TensorFluent'", ":", "return", "self", ".", "_aggregation_op", "(", "tf", ".", "reduce_max", ",", "self", ",", "vars_list", ")" ]
Returns the TensorFluent for the maximum aggregation function. Args: vars_list: The list of variables to be aggregated over. Returns: A TensorFluent wrapping the maximum aggregation function.
[ "Returns", "the", "TensorFluent", "for", "the", "maximum", "aggregation", "function", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/fluent.py#L710-L719
thiagopbueno/rddl2tf
rddl2tf/fluent.py
TensorFluent.minimum
def minimum(self, vars_list: List[str]) -> 'TensorFluent': '''Returns the TensorFluent for the minimum aggregation function. Args: vars_list: The list of variables to be aggregated over. Returns: A TensorFluent wrapping the minimum aggregation function. ''' ...
python
def minimum(self, vars_list: List[str]) -> 'TensorFluent': '''Returns the TensorFluent for the minimum aggregation function. Args: vars_list: The list of variables to be aggregated over. Returns: A TensorFluent wrapping the minimum aggregation function. ''' ...
[ "def", "minimum", "(", "self", ",", "vars_list", ":", "List", "[", "str", "]", ")", "->", "'TensorFluent'", ":", "return", "self", ".", "_aggregation_op", "(", "tf", ".", "reduce_min", ",", "self", ",", "vars_list", ")" ]
Returns the TensorFluent for the minimum aggregation function. Args: vars_list: The list of variables to be aggregated over. Returns: A TensorFluent wrapping the minimum aggregation function.
[ "Returns", "the", "TensorFluent", "for", "the", "minimum", "aggregation", "function", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/fluent.py#L721-L730
thiagopbueno/rddl2tf
rddl2tf/fluent.py
TensorFluent.forall
def forall(self, vars_list: List[str]) -> 'TensorFluent': '''Returns the TensorFluent for the forall aggregation function. Args: vars_list: The list of variables to be aggregated over. Returns: A TensorFluent wrapping the forall aggregation function. ''' ...
python
def forall(self, vars_list: List[str]) -> 'TensorFluent': '''Returns the TensorFluent for the forall aggregation function. Args: vars_list: The list of variables to be aggregated over. Returns: A TensorFluent wrapping the forall aggregation function. ''' ...
[ "def", "forall", "(", "self", ",", "vars_list", ":", "List", "[", "str", "]", ")", "->", "'TensorFluent'", ":", "return", "self", ".", "_aggregation_op", "(", "tf", ".", "reduce_all", ",", "self", ",", "vars_list", ")" ]
Returns the TensorFluent for the forall aggregation function. Args: vars_list: The list of variables to be aggregated over. Returns: A TensorFluent wrapping the forall aggregation function.
[ "Returns", "the", "TensorFluent", "for", "the", "forall", "aggregation", "function", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/fluent.py#L732-L741
thiagopbueno/rddl2tf
rddl2tf/fluent.py
TensorFluent.exists
def exists(self, vars_list: List[str]) -> 'TensorFluent': '''Returns the TensorFluent for the exists aggregation function. Args: vars_list: The list of variables to be aggregated over. Returns: A TensorFluent wrapping the exists aggregation function. ''' ...
python
def exists(self, vars_list: List[str]) -> 'TensorFluent': '''Returns the TensorFluent for the exists aggregation function. Args: vars_list: The list of variables to be aggregated over. Returns: A TensorFluent wrapping the exists aggregation function. ''' ...
[ "def", "exists", "(", "self", ",", "vars_list", ":", "List", "[", "str", "]", ")", "->", "'TensorFluent'", ":", "return", "self", ".", "_aggregation_op", "(", "tf", ".", "reduce_any", ",", "self", ",", "vars_list", ")" ]
Returns the TensorFluent for the exists aggregation function. Args: vars_list: The list of variables to be aggregated over. Returns: A TensorFluent wrapping the exists aggregation function.
[ "Returns", "the", "TensorFluent", "for", "the", "exists", "aggregation", "function", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/fluent.py#L743-L752
ocaballeror/LyricFetch
lyricfetch/run.py
exclude_sources
def exclude_sources(exclude, section=False): """ Returns a narrower list of sources. If the exclude parameter is a list, every one of its items will be removed from the returned list. If it's just a function (or a function's name) and 'section' is set to False (default), a copy of the sources l...
python
def exclude_sources(exclude, section=False): """ Returns a narrower list of sources. If the exclude parameter is a list, every one of its items will be removed from the returned list. If it's just a function (or a function's name) and 'section' is set to False (default), a copy of the sources l...
[ "def", "exclude_sources", "(", "exclude", ",", "section", "=", "False", ")", ":", "newlist", "=", "sources", ".", "copy", "(", ")", "if", "not", "isinstance", "(", "exclude", ",", "list", ")", ":", "exclude", "=", "[", "exclude", "]", "for", "source", ...
Returns a narrower list of sources. If the exclude parameter is a list, every one of its items will be removed from the returned list. If it's just a function (or a function's name) and 'section' is set to False (default), a copy of the sources list without this element will be returned. If it'...
[ "Returns", "a", "narrower", "list", "of", "sources", "." ]
train
https://github.com/ocaballeror/LyricFetch/blob/86e62fb39c4c413ad7e1acf5bf0d28c9ed7c8fcb/lyricfetch/run.py#L65-L90
ocaballeror/LyricFetch
lyricfetch/run.py
get_lyrics
def get_lyrics(song, l_sources=None): """ Searches for lyrics of a single song and returns a Result object with the various stats collected in the process. The optional parameter 'sources' specifies an alternative list of sources. If not present, the main list will be used. """ if l_sources...
python
def get_lyrics(song, l_sources=None): """ Searches for lyrics of a single song and returns a Result object with the various stats collected in the process. The optional parameter 'sources' specifies an alternative list of sources. If not present, the main list will be used. """ if l_sources...
[ "def", "get_lyrics", "(", "song", ",", "l_sources", "=", "None", ")", ":", "if", "l_sources", "is", "None", ":", "l_sources", "=", "sources", "if", "song", ".", "lyrics", "and", "not", "CONFIG", "[", "'overwrite'", "]", ":", "logger", ".", "debug", "("...
Searches for lyrics of a single song and returns a Result object with the various stats collected in the process. The optional parameter 'sources' specifies an alternative list of sources. If not present, the main list will be used.
[ "Searches", "for", "lyrics", "of", "a", "single", "song", "and", "returns", "a", "Result", "object", "with", "the", "various", "stats", "collected", "in", "the", "process", "." ]
train
https://github.com/ocaballeror/LyricFetch/blob/86e62fb39c4c413ad7e1acf5bf0d28c9ed7c8fcb/lyricfetch/run.py#L93-L129
ocaballeror/LyricFetch
lyricfetch/run.py
get_lyrics_threaded
def get_lyrics_threaded(song, l_sources=None): """ Launches a pool of threads to search for the lyrics of a single song. The optional parameter 'sources' specifies an alternative list of sources. If not present, the main list will be used. """ if l_sources is None: l_sources = sources ...
python
def get_lyrics_threaded(song, l_sources=None): """ Launches a pool of threads to search for the lyrics of a single song. The optional parameter 'sources' specifies an alternative list of sources. If not present, the main list will be used. """ if l_sources is None: l_sources = sources ...
[ "def", "get_lyrics_threaded", "(", "song", ",", "l_sources", "=", "None", ")", ":", "if", "l_sources", "is", "None", ":", "l_sources", "=", "sources", "if", "song", ".", "lyrics", "and", "not", "CONFIG", "[", "'overwrite'", "]", ":", "logger", ".", "debu...
Launches a pool of threads to search for the lyrics of a single song. The optional parameter 'sources' specifies an alternative list of sources. If not present, the main list will be used.
[ "Launches", "a", "pool", "of", "threads", "to", "search", "for", "the", "lyrics", "of", "a", "single", "song", "." ]
train
https://github.com/ocaballeror/LyricFetch/blob/86e62fb39c4c413ad7e1acf5bf0d28c9ed7c8fcb/lyricfetch/run.py#L132-L164
ocaballeror/LyricFetch
lyricfetch/run.py
process_result
def process_result(result): """ Process a result object by: 1. Saving the lyrics to the corresponding file(if applicable). 2. Printing the lyrics or the corresponding error/success message. 3. Returning a boolean indicating if the lyrics were found or not. """ found = result.sour...
python
def process_result(result): """ Process a result object by: 1. Saving the lyrics to the corresponding file(if applicable). 2. Printing the lyrics or the corresponding error/success message. 3. Returning a boolean indicating if the lyrics were found or not. """ found = result.sour...
[ "def", "process_result", "(", "result", ")", ":", "found", "=", "result", ".", "source", "is", "not", "None", "if", "found", ":", "if", "hasattr", "(", "result", ".", "song", ",", "'filename'", ")", ":", "audiofile", "=", "eyed3", ".", "load", "(", "...
Process a result object by: 1. Saving the lyrics to the corresponding file(if applicable). 2. Printing the lyrics or the corresponding error/success message. 3. Returning a boolean indicating if the lyrics were found or not.
[ "Process", "a", "result", "object", "by", ":", "1", ".", "Saving", "the", "lyrics", "to", "the", "corresponding", "file", "(", "if", "applicable", ")", ".", "2", ".", "Printing", "the", "lyrics", "or", "the", "corresponding", "error", "/", "success", "me...
train
https://github.com/ocaballeror/LyricFetch/blob/86e62fb39c4c413ad7e1acf5bf0d28c9ed7c8fcb/lyricfetch/run.py#L167-L190
ocaballeror/LyricFetch
lyricfetch/run.py
run
def run(songs): """ Calls get_lyrics_threaded for a song or list of songs. """ if not hasattr(songs, '__iter__'): result = get_lyrics_threaded(songs) process_result(result) else: start = time.time() stats = run_mp(songs) end = time.time() if CONFIG['pr...
python
def run(songs): """ Calls get_lyrics_threaded for a song or list of songs. """ if not hasattr(songs, '__iter__'): result = get_lyrics_threaded(songs) process_result(result) else: start = time.time() stats = run_mp(songs) end = time.time() if CONFIG['pr...
[ "def", "run", "(", "songs", ")", ":", "if", "not", "hasattr", "(", "songs", ",", "'__iter__'", ")", ":", "result", "=", "get_lyrics_threaded", "(", "songs", ")", "process_result", "(", "result", ")", "else", ":", "start", "=", "time", ".", "time", "(",...
Calls get_lyrics_threaded for a song or list of songs.
[ "Calls", "get_lyrics_threaded", "for", "a", "song", "or", "list", "of", "songs", "." ]
train
https://github.com/ocaballeror/LyricFetch/blob/86e62fb39c4c413ad7e1acf5bf0d28c9ed7c8fcb/lyricfetch/run.py#L193-L210
ocaballeror/LyricFetch
lyricfetch/run.py
run_mp
def run_mp(songs): """ Concurrently calls get_lyrics to fetch the lyrics of a large list of songs. """ stats = Stats() if CONFIG['debug']: good = open('found', 'w') bad = open('notfound', 'w') logger.debug('Launching a pool of %d processes\n', CONFIG['jobcount']) chunksize =...
python
def run_mp(songs): """ Concurrently calls get_lyrics to fetch the lyrics of a large list of songs. """ stats = Stats() if CONFIG['debug']: good = open('found', 'w') bad = open('notfound', 'w') logger.debug('Launching a pool of %d processes\n', CONFIG['jobcount']) chunksize =...
[ "def", "run_mp", "(", "songs", ")", ":", "stats", "=", "Stats", "(", ")", "if", "CONFIG", "[", "'debug'", "]", ":", "good", "=", "open", "(", "'found'", ",", "'w'", ")", "bad", "=", "open", "(", "'notfound'", ",", "'w'", ")", "logger", ".", "debu...
Concurrently calls get_lyrics to fetch the lyrics of a large list of songs.
[ "Concurrently", "calls", "get_lyrics", "to", "fetch", "the", "lyrics", "of", "a", "large", "list", "of", "songs", "." ]
train
https://github.com/ocaballeror/LyricFetch/blob/86e62fb39c4c413ad7e1acf5bf0d28c9ed7c8fcb/lyricfetch/run.py#L213-L247
malramsay64/experi
src/experi/scheduler.py
parse_setup
def parse_setup(options: Union[List, str]) -> str: """Convert potentially a list of commands into a single string. This creates a single string with newlines between each element of the list so that they will all run after each other in a bash script. """ if isinstance(options, str): retur...
python
def parse_setup(options: Union[List, str]) -> str: """Convert potentially a list of commands into a single string. This creates a single string with newlines between each element of the list so that they will all run after each other in a bash script. """ if isinstance(options, str): retur...
[ "def", "parse_setup", "(", "options", ":", "Union", "[", "List", ",", "str", "]", ")", "->", "str", ":", "if", "isinstance", "(", "options", ",", "str", ")", ":", "return", "options", "return", "\"\\n\"", ".", "join", "(", "options", ")" ]
Convert potentially a list of commands into a single string. This creates a single string with newlines between each element of the list so that they will all run after each other in a bash script.
[ "Convert", "potentially", "a", "list", "of", "commands", "into", "a", "single", "string", "." ]
train
https://github.com/malramsay64/experi/blob/7159644df0420e4a395c87c0c08e11567f401443/src/experi/scheduler.py#L267-L276
malramsay64/experi
src/experi/scheduler.py
create_scheduler_file
def create_scheduler_file(scheduler: str, job: Job) -> str: """Substitute values into a template scheduler file.""" logger.debug("Create Scheduler File Function") if job.scheduler_options is None: scheduler_options: Dict[str, Any] = {} else: scheduler_options = deepcopy(job.scheduler_op...
python
def create_scheduler_file(scheduler: str, job: Job) -> str: """Substitute values into a template scheduler file.""" logger.debug("Create Scheduler File Function") if job.scheduler_options is None: scheduler_options: Dict[str, Any] = {} else: scheduler_options = deepcopy(job.scheduler_op...
[ "def", "create_scheduler_file", "(", "scheduler", ":", "str", ",", "job", ":", "Job", ")", "->", "str", ":", "logger", ".", "debug", "(", "\"Create Scheduler File Function\"", ")", "if", "job", ".", "scheduler_options", "is", "None", ":", "scheduler_options", ...
Substitute values into a template scheduler file.
[ "Substitute", "values", "into", "a", "template", "scheduler", "file", "." ]
train
https://github.com/malramsay64/experi/blob/7159644df0420e4a395c87c0c08e11567f401443/src/experi/scheduler.py#L304-L333
nion-software/nionswift-instrumentation-kit
nionswift_plugin/nion_instrumentation_ui/VideoControlPanel.py
VideoSourceStateController.initialize_state
def initialize_state(self): """ Call this to initialize the state of the UI after everything has been connected. """ if self.__hardware_source: self.__data_item_states_changed_event_listener = self.__hardware_source.data_item_states_changed_event.listen(self.__data_item_states_changed) ...
python
def initialize_state(self): """ Call this to initialize the state of the UI after everything has been connected. """ if self.__hardware_source: self.__data_item_states_changed_event_listener = self.__hardware_source.data_item_states_changed_event.listen(self.__data_item_states_changed) ...
[ "def", "initialize_state", "(", "self", ")", ":", "if", "self", ".", "__hardware_source", ":", "self", ".", "__data_item_states_changed_event_listener", "=", "self", ".", "__hardware_source", ".", "data_item_states_changed_event", ".", "listen", "(", "self", ".", "_...
Call this to initialize the state of the UI after everything has been connected.
[ "Call", "this", "to", "initialize", "the", "state", "of", "the", "UI", "after", "everything", "has", "been", "connected", "." ]
train
https://github.com/nion-software/nionswift-instrumentation-kit/blob/b20c4fff17e840e8cb3d544705faf5bd05f1cbf7/nionswift_plugin/nion_instrumentation_ui/VideoControlPanel.py#L121-L130
nion-software/nionswift-instrumentation-kit
nionswift_plugin/nion_instrumentation_ui/VideoControlPanel.py
VideoSourceStateController.handle_play_clicked
def handle_play_clicked(self): """ Call this when the user clicks the play/pause button. """ if self.__hardware_source: if self.is_playing: self.__hardware_source.stop_playing() else: self.__hardware_source.start_playing()
python
def handle_play_clicked(self): """ Call this when the user clicks the play/pause button. """ if self.__hardware_source: if self.is_playing: self.__hardware_source.stop_playing() else: self.__hardware_source.start_playing()
[ "def", "handle_play_clicked", "(", "self", ")", ":", "if", "self", ".", "__hardware_source", ":", "if", "self", ".", "is_playing", ":", "self", ".", "__hardware_source", ".", "stop_playing", "(", ")", "else", ":", "self", ".", "__hardware_source", ".", "star...
Call this when the user clicks the play/pause button.
[ "Call", "this", "when", "the", "user", "clicks", "the", "play", "/", "pause", "button", "." ]
train
https://github.com/nion-software/nionswift-instrumentation-kit/blob/b20c4fff17e840e8cb3d544705faf5bd05f1cbf7/nionswift_plugin/nion_instrumentation_ui/VideoControlPanel.py#L132-L138
thiagopbueno/rddl2tf
rddl2tf/utils.py
range_type_to_dtype
def range_type_to_dtype(range_type: str) -> Optional[tf.DType]: '''Maps RDDL range types to TensorFlow dtypes.''' range2dtype = { 'real': tf.float32, 'int': tf.int32, 'bool': tf.bool } return range2dtype[range_type]
python
def range_type_to_dtype(range_type: str) -> Optional[tf.DType]: '''Maps RDDL range types to TensorFlow dtypes.''' range2dtype = { 'real': tf.float32, 'int': tf.int32, 'bool': tf.bool } return range2dtype[range_type]
[ "def", "range_type_to_dtype", "(", "range_type", ":", "str", ")", "->", "Optional", "[", "tf", ".", "DType", "]", ":", "range2dtype", "=", "{", "'real'", ":", "tf", ".", "float32", ",", "'int'", ":", "tf", ".", "int32", ",", "'bool'", ":", "tf", ".",...
Maps RDDL range types to TensorFlow dtypes.
[ "Maps", "RDDL", "range", "types", "to", "TensorFlow", "dtypes", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/utils.py#L22-L29
thiagopbueno/rddl2tf
rddl2tf/utils.py
python_type_to_dtype
def python_type_to_dtype(python_type: type) -> Optional[tf.DType]: '''Maps python types to TensorFlow dtypes.''' dtype = None if python_type == float: dtype = tf.float32 elif python_type == int: dtype = tf.int32 elif python_type == bool: dtype = tf.bool return dtype
python
def python_type_to_dtype(python_type: type) -> Optional[tf.DType]: '''Maps python types to TensorFlow dtypes.''' dtype = None if python_type == float: dtype = tf.float32 elif python_type == int: dtype = tf.int32 elif python_type == bool: dtype = tf.bool return dtype
[ "def", "python_type_to_dtype", "(", "python_type", ":", "type", ")", "->", "Optional", "[", "tf", ".", "DType", "]", ":", "dtype", "=", "None", "if", "python_type", "==", "float", ":", "dtype", "=", "tf", ".", "float32", "elif", "python_type", "==", "int...
Maps python types to TensorFlow dtypes.
[ "Maps", "python", "types", "to", "TensorFlow", "dtypes", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/utils.py#L32-L41
RowleyGroup/pyqueue
pyqueue/systems/slurm.py
SlurmPrinter.get_dependency_type
def get_dependency_type(_type): """ Get the dependency type string for SlurmPrinter :rtype: str """ if _type == DependencyTypes.AFTER: return 'after' elif _type == DependencyTypes.AFTER_ANY: return 'afterany' elif _type == DependencyTypes....
python
def get_dependency_type(_type): """ Get the dependency type string for SlurmPrinter :rtype: str """ if _type == DependencyTypes.AFTER: return 'after' elif _type == DependencyTypes.AFTER_ANY: return 'afterany' elif _type == DependencyTypes....
[ "def", "get_dependency_type", "(", "_type", ")", ":", "if", "_type", "==", "DependencyTypes", ".", "AFTER", ":", "return", "'after'", "elif", "_type", "==", "DependencyTypes", ".", "AFTER_ANY", ":", "return", "'afterany'", "elif", "_type", "==", "DependencyTypes...
Get the dependency type string for SlurmPrinter :rtype: str
[ "Get", "the", "dependency", "type", "string", "for", "SlurmPrinter" ]
train
https://github.com/RowleyGroup/pyqueue/blob/24de6e1b06b9626ed94d0d5a859bc71bd3afbb4f/pyqueue/systems/slurm.py#L21-L38
RowleyGroup/pyqueue
pyqueue/systems/slurm.py
SlurmPrinter.get_header
def get_header(): """ Makes the header section for the scripts :rtype: str """ username, userid, uname = get_user_information() header = '''\ # This Slurm batch script was generated # By user: %s (%s) # On host: %s # At date: %s # Using: Pyqueue v%s ''' % (username, us...
python
def get_header(): """ Makes the header section for the scripts :rtype: str """ username, userid, uname = get_user_information() header = '''\ # This Slurm batch script was generated # By user: %s (%s) # On host: %s # At date: %s # Using: Pyqueue v%s ''' % (username, us...
[ "def", "get_header", "(", ")", ":", "username", ",", "userid", ",", "uname", "=", "get_user_information", "(", ")", "header", "=", "'''\\\n# This Slurm batch script was generated\n# By user: %s (%s)\n# On host: %s\n# At date: %s\n# Using: Pyqueue v%s\n\n'''", "%", "(", "usernam...
Makes the header section for the scripts :rtype: str
[ "Makes", "the", "header", "section", "for", "the", "scripts" ]
train
https://github.com/RowleyGroup/pyqueue/blob/24de6e1b06b9626ed94d0d5a859bc71bd3afbb4f/pyqueue/systems/slurm.py#L41-L58
RowleyGroup/pyqueue
pyqueue/systems/slurm.py
SlurmPrinter.generate
def generate(self, job): """ Generates a job submission script from a job object :param job: An instance of JobInterface :type job: pyqueue.job.JobInterface """ options = job.get_options().copy() job_name = options.pop('name', None) job_account = options...
python
def generate(self, job): """ Generates a job submission script from a job object :param job: An instance of JobInterface :type job: pyqueue.job.JobInterface """ options = job.get_options().copy() job_name = options.pop('name', None) job_account = options...
[ "def", "generate", "(", "self", ",", "job", ")", ":", "options", "=", "job", ".", "get_options", "(", ")", ".", "copy", "(", ")", "job_name", "=", "options", ".", "pop", "(", "'name'", ",", "None", ")", "job_account", "=", "options", ".", "pop", "(...
Generates a job submission script from a job object :param job: An instance of JobInterface :type job: pyqueue.job.JobInterface
[ "Generates", "a", "job", "submission", "script", "from", "a", "job", "object" ]
train
https://github.com/RowleyGroup/pyqueue/blob/24de6e1b06b9626ed94d0d5a859bc71bd3afbb4f/pyqueue/systems/slurm.py#L60-L137
RowleyGroup/pyqueue
pyqueue/systems/slurm.py
SlurmLocalSubmitter.submit
def submit(self, job): """ Submits a given job :param job: The job to submit :type job: pyqueue.job.JobInterface """ from subprocess import Popen, PIPE script = self._printer.generate(job) process = Popen('sbatch', stdout=PIPE, stdin=PIPE, stderr=PIPE) ...
python
def submit(self, job): """ Submits a given job :param job: The job to submit :type job: pyqueue.job.JobInterface """ from subprocess import Popen, PIPE script = self._printer.generate(job) process = Popen('sbatch', stdout=PIPE, stdin=PIPE, stderr=PIPE) ...
[ "def", "submit", "(", "self", ",", "job", ")", ":", "from", "subprocess", "import", "Popen", ",", "PIPE", "script", "=", "self", ".", "_printer", ".", "generate", "(", "job", ")", "process", "=", "Popen", "(", "'sbatch'", ",", "stdout", "=", "PIPE", ...
Submits a given job :param job: The job to submit :type job: pyqueue.job.JobInterface
[ "Submits", "a", "given", "job" ]
train
https://github.com/RowleyGroup/pyqueue/blob/24de6e1b06b9626ed94d0d5a859bc71bd3afbb4f/pyqueue/systems/slurm.py#L149-L160
RowleyGroup/pyqueue
pyqueue/systems/slurm.py
SlurmRemoteSubmitter.submit
def submit(self, job): """ Submits a given job :param job: The job to submit :type job: pyqueue.job.JobInterface """ script = self._printer.generate(job) stdin, stdout, stderr = self._ssh.exec_command('sbatch') stdin.write(script) stdin.flush() ...
python
def submit(self, job): """ Submits a given job :param job: The job to submit :type job: pyqueue.job.JobInterface """ script = self._printer.generate(job) stdin, stdout, stderr = self._ssh.exec_command('sbatch') stdin.write(script) stdin.flush() ...
[ "def", "submit", "(", "self", ",", "job", ")", ":", "script", "=", "self", ".", "_printer", ".", "generate", "(", "job", ")", "stdin", ",", "stdout", ",", "stderr", "=", "self", ".", "_ssh", ".", "exec_command", "(", "'sbatch'", ")", "stdin", ".", ...
Submits a given job :param job: The job to submit :type job: pyqueue.job.JobInterface
[ "Submits", "a", "given", "job" ]
train
https://github.com/RowleyGroup/pyqueue/blob/24de6e1b06b9626ed94d0d5a859bc71bd3afbb4f/pyqueue/systems/slurm.py#L172-L184
ocaballeror/LyricFetch
lyricfetch/song.py
get_info_mpris2
def get_info_mpris2(name): """ Get the current playing song from an mpris2 compliant player. """ # qdbus org.mpris.MediaPlayer2.<name> /org/mpris/MediaPlayer2\ # org.freedesktop.DBus.Properties.Get org.mpris.MediaPlayer2.Player Metadat bus_name = 'org.mpris.MediaPlayer2.' + name path = '/org...
python
def get_info_mpris2(name): """ Get the current playing song from an mpris2 compliant player. """ # qdbus org.mpris.MediaPlayer2.<name> /org/mpris/MediaPlayer2\ # org.freedesktop.DBus.Properties.Get org.mpris.MediaPlayer2.Player Metadat bus_name = 'org.mpris.MediaPlayer2.' + name path = '/org...
[ "def", "get_info_mpris2", "(", "name", ")", ":", "# qdbus org.mpris.MediaPlayer2.<name> /org/mpris/MediaPlayer2\\", "# org.freedesktop.DBus.Properties.Get org.mpris.MediaPlayer2.Player Metadat", "bus_name", "=", "'org.mpris.MediaPlayer2.'", "+", "name", "path", "=", "'/org/mpris/MediaP...
Get the current playing song from an mpris2 compliant player.
[ "Get", "the", "current", "playing", "song", "from", "an", "mpris2", "compliant", "player", "." ]
train
https://github.com/ocaballeror/LyricFetch/blob/86e62fb39c4c413ad7e1acf5bf0d28c9ed7c8fcb/lyricfetch/song.py#L147-L178
ocaballeror/LyricFetch
lyricfetch/song.py
get_current_clementine
def get_current_clementine(): """ Get the current song from clementine. """ # mpris_version 2 try: return get_info_mpris2('clementine') except DBusErrorResponse: bus_name = 'org.mpris.clementine' path = '/Player' interface = 'org.freedesktop.MediaPlayer' r...
python
def get_current_clementine(): """ Get the current song from clementine. """ # mpris_version 2 try: return get_info_mpris2('clementine') except DBusErrorResponse: bus_name = 'org.mpris.clementine' path = '/Player' interface = 'org.freedesktop.MediaPlayer' r...
[ "def", "get_current_clementine", "(", ")", ":", "# mpris_version 2", "try", ":", "return", "get_info_mpris2", "(", "'clementine'", ")", "except", "DBusErrorResponse", ":", "bus_name", "=", "'org.mpris.clementine'", "path", "=", "'/Player'", "interface", "=", "'org.fre...
Get the current song from clementine.
[ "Get", "the", "current", "song", "from", "clementine", "." ]
train
https://github.com/ocaballeror/LyricFetch/blob/86e62fb39c4c413ad7e1acf5bf0d28c9ed7c8fcb/lyricfetch/song.py#L198-L209
ocaballeror/LyricFetch
lyricfetch/song.py
get_current_cmus
def get_current_cmus(): """ Get the current song from cmus. """ result = subprocess.run('cmus-remote -Q'.split(' '), check=True, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL) info = {} for line in result.stdout.decode().split('\n'): line = line.split(' ')...
python
def get_current_cmus(): """ Get the current song from cmus. """ result = subprocess.run('cmus-remote -Q'.split(' '), check=True, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL) info = {} for line in result.stdout.decode().split('\n'): line = line.split(' ')...
[ "def", "get_current_cmus", "(", ")", ":", "result", "=", "subprocess", ".", "run", "(", "'cmus-remote -Q'", ".", "split", "(", "' '", ")", ",", "check", "=", "True", ",", "stdout", "=", "subprocess", ".", "PIPE", ",", "stderr", "=", "subprocess", ".", ...
Get the current song from cmus.
[ "Get", "the", "current", "song", "from", "cmus", "." ]
train
https://github.com/ocaballeror/LyricFetch/blob/86e62fb39c4c413ad7e1acf5bf0d28c9ed7c8fcb/lyricfetch/song.py#L212-L232
ocaballeror/LyricFetch
lyricfetch/song.py
Song.from_filename
def from_filename(cls, filename): """ Class constructor using the path to the corresponding mp3 file. The metadata will be read from this file to create the song object, so it must at least contain valid ID3 tags for artist and title. """ if not filename: logg...
python
def from_filename(cls, filename): """ Class constructor using the path to the corresponding mp3 file. The metadata will be read from this file to create the song object, so it must at least contain valid ID3 tags for artist and title. """ if not filename: logg...
[ "def", "from_filename", "(", "cls", ",", "filename", ")", ":", "if", "not", "filename", ":", "logger", ".", "error", "(", "'No filename specified'", ")", "return", "None", "if", "not", "os", ".", "path", ".", "exists", "(", "filename", ")", ":", "logger"...
Class constructor using the path to the corresponding mp3 file. The metadata will be read from this file to create the song object, so it must at least contain valid ID3 tags for artist and title.
[ "Class", "constructor", "using", "the", "path", "to", "the", "corresponding", "mp3", "file", ".", "The", "metadata", "will", "be", "read", "from", "this", "file", "to", "create", "the", "song", "object", "so", "it", "must", "at", "least", "contain", "valid...
train
https://github.com/ocaballeror/LyricFetch/blob/86e62fb39c4c413ad7e1acf5bf0d28c9ed7c8fcb/lyricfetch/song.py#L65-L103
ocaballeror/LyricFetch
lyricfetch/song.py
Song.from_string
def from_string(cls, name, separator='-', reverse=False): """ Class constructor using a string with the artist and title. This should be used when parsing user input, since all the information must be specified in a single string formatted as: '{artist} - {title}'. """ re...
python
def from_string(cls, name, separator='-', reverse=False): """ Class constructor using a string with the artist and title. This should be used when parsing user input, since all the information must be specified in a single string formatted as: '{artist} - {title}'. """ re...
[ "def", "from_string", "(", "cls", ",", "name", ",", "separator", "=", "'-'", ",", "reverse", "=", "False", ")", ":", "recv", "=", "[", "t", ".", "strip", "(", ")", "for", "t", "in", "name", ".", "split", "(", "separator", ")", "]", "if", "len", ...
Class constructor using a string with the artist and title. This should be used when parsing user input, since all the information must be specified in a single string formatted as: '{artist} - {title}'.
[ "Class", "constructor", "using", "a", "string", "with", "the", "artist", "and", "title", ".", "This", "should", "be", "used", "when", "parsing", "user", "input", "since", "all", "the", "information", "must", "be", "specified", "in", "a", "single", "string", ...
train
https://github.com/ocaballeror/LyricFetch/blob/86e62fb39c4c413ad7e1acf5bf0d28c9ed7c8fcb/lyricfetch/song.py#L106-L129
ocaballeror/LyricFetch
lyricfetch/song.py
Song.fetch_album_name
def fetch_album_name(self): """ Get the name of the album from lastfm. """ response = get_lastfm('track.getInfo', artist=self.artist, track=self.title) if response: try: self.album = response['track']['album']['title'] ...
python
def fetch_album_name(self): """ Get the name of the album from lastfm. """ response = get_lastfm('track.getInfo', artist=self.artist, track=self.title) if response: try: self.album = response['track']['album']['title'] ...
[ "def", "fetch_album_name", "(", "self", ")", ":", "response", "=", "get_lastfm", "(", "'track.getInfo'", ",", "artist", "=", "self", ".", "artist", ",", "track", "=", "self", ".", "title", ")", "if", "response", ":", "try", ":", "self", ".", "album", "...
Get the name of the album from lastfm.
[ "Get", "the", "name", "of", "the", "album", "from", "lastfm", "." ]
train
https://github.com/ocaballeror/LyricFetch/blob/86e62fb39c4c413ad7e1acf5bf0d28c9ed7c8fcb/lyricfetch/song.py#L131-L144
numan/py-analytics
analytics/backends/redis.py
Redis._get_closest_week
def _get_closest_week(self, metric_date): """ Gets the closest monday to the date provided. """ #find the offset to the closest monday days_after_monday = metric_date.isoweekday() - 1 return metric_date - datetime.timedelta(days=days_after_monday)
python
def _get_closest_week(self, metric_date): """ Gets the closest monday to the date provided. """ #find the offset to the closest monday days_after_monday = metric_date.isoweekday() - 1 return metric_date - datetime.timedelta(days=days_after_monday)
[ "def", "_get_closest_week", "(", "self", ",", "metric_date", ")", ":", "#find the offset to the closest monday", "days_after_monday", "=", "metric_date", ".", "isoweekday", "(", ")", "-", "1", "return", "metric_date", "-", "datetime", ".", "timedelta", "(", "days", ...
Gets the closest monday to the date provided.
[ "Gets", "the", "closest", "monday", "to", "the", "date", "provided", "." ]
train
https://github.com/numan/py-analytics/blob/abbc814925c6cc200b3329c7de9f1868e1cb8c01/analytics/backends/redis.py#L58-L65
numan/py-analytics
analytics/backends/redis.py
Redis._get_daily_date_range
def _get_daily_date_range(self, metric_date, delta): """ Get the range of months that we need to use as keys to scan redis. """ dates = [metric_date] start_date = metric_date end_date = metric_date + delta while start_date.month < end_date.month or start_date.yea...
python
def _get_daily_date_range(self, metric_date, delta): """ Get the range of months that we need to use as keys to scan redis. """ dates = [metric_date] start_date = metric_date end_date = metric_date + delta while start_date.month < end_date.month or start_date.yea...
[ "def", "_get_daily_date_range", "(", "self", ",", "metric_date", ",", "delta", ")", ":", "dates", "=", "[", "metric_date", "]", "start_date", "=", "metric_date", "end_date", "=", "metric_date", "+", "delta", "while", "start_date", ".", "month", "<", "end_date"...
Get the range of months that we need to use as keys to scan redis.
[ "Get", "the", "range", "of", "months", "that", "we", "need", "to", "use", "as", "keys", "to", "scan", "redis", "." ]
train
https://github.com/numan/py-analytics/blob/abbc814925c6cc200b3329c7de9f1868e1cb8c01/analytics/backends/redis.py#L97-L112
numan/py-analytics
analytics/backends/redis.py
Redis._get_weekly_date_range
def _get_weekly_date_range(self, metric_date, delta): """ Gets the range of years that we need to use as keys to get metrics from redis. """ dates = [metric_date] end_date = metric_date + delta #Figure out how many years our metric range spans spanning_years = end...
python
def _get_weekly_date_range(self, metric_date, delta): """ Gets the range of years that we need to use as keys to get metrics from redis. """ dates = [metric_date] end_date = metric_date + delta #Figure out how many years our metric range spans spanning_years = end...
[ "def", "_get_weekly_date_range", "(", "self", ",", "metric_date", ",", "delta", ")", ":", "dates", "=", "[", "metric_date", "]", "end_date", "=", "metric_date", "+", "delta", "#Figure out how many years our metric range spans", "spanning_years", "=", "end_date", ".", ...
Gets the range of years that we need to use as keys to get metrics from redis.
[ "Gets", "the", "range", "of", "years", "that", "we", "need", "to", "use", "as", "keys", "to", "get", "metrics", "from", "redis", "." ]
train
https://github.com/numan/py-analytics/blob/abbc814925c6cc200b3329c7de9f1868e1cb8c01/analytics/backends/redis.py#L114-L127
numan/py-analytics
analytics/backends/redis.py
Redis.clear_all
def clear_all(self): """ Deletes all ``sandsnake`` related data from redis. .. warning:: Very expensive and destructive operation. Use with causion """ keys = self._analytics_backend.keys() for key in itertools.chain(*keys): with self._analytics...
python
def clear_all(self): """ Deletes all ``sandsnake`` related data from redis. .. warning:: Very expensive and destructive operation. Use with causion """ keys = self._analytics_backend.keys() for key in itertools.chain(*keys): with self._analytics...
[ "def", "clear_all", "(", "self", ")", ":", "keys", "=", "self", ".", "_analytics_backend", ".", "keys", "(", ")", "for", "key", "in", "itertools", ".", "chain", "(", "*", "keys", ")", ":", "with", "self", ".", "_analytics_backend", ".", "map", "(", "...
Deletes all ``sandsnake`` related data from redis. .. warning:: Very expensive and destructive operation. Use with causion
[ "Deletes", "all", "sandsnake", "related", "data", "from", "redis", "." ]
train
https://github.com/numan/py-analytics/blob/abbc814925c6cc200b3329c7de9f1868e1cb8c01/analytics/backends/redis.py#L151-L164
numan/py-analytics
analytics/backends/redis.py
Redis.track_count
def track_count(self, unique_identifier, metric, inc_amt=1, **kwargs): """ Tracks a metric just by count. If you track a metric this way, you won't be able to query the metric by day, week or month. :param unique_identifier: Unique string indetifying the object this metric is for ...
python
def track_count(self, unique_identifier, metric, inc_amt=1, **kwargs): """ Tracks a metric just by count. If you track a metric this way, you won't be able to query the metric by day, week or month. :param unique_identifier: Unique string indetifying the object this metric is for ...
[ "def", "track_count", "(", "self", ",", "unique_identifier", ",", "metric", ",", "inc_amt", "=", "1", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_analytics_backend", ".", "incr", "(", "self", ".", "_prefix", "+", "\":\"", "+", "\"analy:%s...
Tracks a metric just by count. If you track a metric this way, you won't be able to query the metric by day, week or month. :param unique_identifier: Unique string indetifying the object this metric is for :param metric: A unique name for the metric you want to track :param inc_amt: The...
[ "Tracks", "a", "metric", "just", "by", "count", ".", "If", "you", "track", "a", "metric", "this", "way", "you", "won", "t", "be", "able", "to", "query", "the", "metric", "by", "day", "week", "or", "month", "." ]
train
https://github.com/numan/py-analytics/blob/abbc814925c6cc200b3329c7de9f1868e1cb8c01/analytics/backends/redis.py#L166-L176
numan/py-analytics
analytics/backends/redis.py
Redis.track_metric
def track_metric(self, unique_identifier, metric, date=None, inc_amt=1, **kwargs): """ Tracks a metric for a specific ``unique_identifier`` for a certain date. The redis backend supports lists for both ``unique_identifier`` and ``metric`` allowing for tracking of multiple metrics for multiple ...
python
def track_metric(self, unique_identifier, metric, date=None, inc_amt=1, **kwargs): """ Tracks a metric for a specific ``unique_identifier`` for a certain date. The redis backend supports lists for both ``unique_identifier`` and ``metric`` allowing for tracking of multiple metrics for multiple ...
[ "def", "track_metric", "(", "self", ",", "unique_identifier", ",", "metric", ",", "date", "=", "None", ",", "inc_amt", "=", "1", ",", "*", "*", "kwargs", ")", ":", "metric", "=", "[", "metric", "]", "if", "isinstance", "(", "metric", ",", "basestring",...
Tracks a metric for a specific ``unique_identifier`` for a certain date. The redis backend supports lists for both ``unique_identifier`` and ``metric`` allowing for tracking of multiple metrics for multiple unique_identifiers efficiently. Not all backends may support this. :param unique_identif...
[ "Tracks", "a", "metric", "for", "a", "specific", "unique_identifier", "for", "a", "certain", "date", ".", "The", "redis", "backend", "supports", "lists", "for", "both", "unique_identifier", "and", "metric", "allowing", "for", "tracking", "of", "multiple", "metri...
train
https://github.com/numan/py-analytics/blob/abbc814925c6cc200b3329c7de9f1868e1cb8c01/analytics/backends/redis.py#L178-L216
numan/py-analytics
analytics/backends/redis.py
Redis.get_metric_by_day
def get_metric_by_day(self, unique_identifier, metric, from_date, limit=30, **kwargs): """ Returns the ``metric`` for ``unique_identifier`` segmented by day starting from``from_date`` :param unique_identifier: Unique string indetifying the object this metric is for :param metric...
python
def get_metric_by_day(self, unique_identifier, metric, from_date, limit=30, **kwargs): """ Returns the ``metric`` for ``unique_identifier`` segmented by day starting from``from_date`` :param unique_identifier: Unique string indetifying the object this metric is for :param metric...
[ "def", "get_metric_by_day", "(", "self", ",", "unique_identifier", ",", "metric", ",", "from_date", ",", "limit", "=", "30", ",", "*", "*", "kwargs", ")", ":", "conn", "=", "kwargs", ".", "get", "(", "\"connection\"", ",", "None", ")", "date_generator", ...
Returns the ``metric`` for ``unique_identifier`` segmented by day starting from``from_date`` :param unique_identifier: Unique string indetifying the object this metric is for :param metric: A unique name for the metric you want to track :param from_date: A python date object :pa...
[ "Returns", "the", "metric", "for", "unique_identifier", "segmented", "by", "day", "starting", "from", "from_date" ]
train
https://github.com/numan/py-analytics/blob/abbc814925c6cc200b3329c7de9f1868e1cb8c01/analytics/backends/redis.py#L218-L246
numan/py-analytics
analytics/backends/redis.py
Redis.get_metric_by_week
def get_metric_by_week(self, unique_identifier, metric, from_date, limit=10, **kwargs): """ Returns the ``metric`` for ``unique_identifier`` segmented by week starting from``from_date`` :param unique_identifier: Unique string indetifying the object this metric is for :param metr...
python
def get_metric_by_week(self, unique_identifier, metric, from_date, limit=10, **kwargs): """ Returns the ``metric`` for ``unique_identifier`` segmented by week starting from``from_date`` :param unique_identifier: Unique string indetifying the object this metric is for :param metr...
[ "def", "get_metric_by_week", "(", "self", ",", "unique_identifier", ",", "metric", ",", "from_date", ",", "limit", "=", "10", ",", "*", "*", "kwargs", ")", ":", "conn", "=", "kwargs", ".", "get", "(", "\"connection\"", ",", "None", ")", "closest_monday_fro...
Returns the ``metric`` for ``unique_identifier`` segmented by week starting from``from_date`` :param unique_identifier: Unique string indetifying the object this metric is for :param metric: A unique name for the metric you want to track :param from_date: A python date object :p...
[ "Returns", "the", "metric", "for", "unique_identifier", "segmented", "by", "week", "starting", "from", "from_date" ]
train
https://github.com/numan/py-analytics/blob/abbc814925c6cc200b3329c7de9f1868e1cb8c01/analytics/backends/redis.py#L248-L278
numan/py-analytics
analytics/backends/redis.py
Redis.get_metric_by_month
def get_metric_by_month(self, unique_identifier, metric, from_date, limit=10, **kwargs): """ Returns the ``metric`` for ``unique_identifier`` segmented by month starting from``from_date``. It will retrieve metrics data starting from the 1st of the month specified in ``from_date`` ...
python
def get_metric_by_month(self, unique_identifier, metric, from_date, limit=10, **kwargs): """ Returns the ``metric`` for ``unique_identifier`` segmented by month starting from``from_date``. It will retrieve metrics data starting from the 1st of the month specified in ``from_date`` ...
[ "def", "get_metric_by_month", "(", "self", ",", "unique_identifier", ",", "metric", ",", "from_date", ",", "limit", "=", "10", ",", "*", "*", "kwargs", ")", ":", "conn", "=", "kwargs", ".", "get", "(", "\"connection\"", ",", "None", ")", "first_of_month", ...
Returns the ``metric`` for ``unique_identifier`` segmented by month starting from``from_date``. It will retrieve metrics data starting from the 1st of the month specified in ``from_date`` :param unique_identifier: Unique string indetifying the object this metric is for :param metric: A ...
[ "Returns", "the", "metric", "for", "unique_identifier", "segmented", "by", "month", "starting", "from", "from_date", ".", "It", "will", "retrieve", "metrics", "data", "starting", "from", "the", "1st", "of", "the", "month", "specified", "in", "from_date" ]
train
https://github.com/numan/py-analytics/blob/abbc814925c6cc200b3329c7de9f1868e1cb8c01/analytics/backends/redis.py#L280-L313
numan/py-analytics
analytics/backends/redis.py
Redis.get_metrics
def get_metrics(self, metric_identifiers, from_date, limit=10, group_by="week", **kwargs): """ Retrieves a multiple metrics as efficiently as possible. :param metric_identifiers: a list of tuples of the form `(unique_identifier, metric_name`) identifying which metrics to retrieve. For e...
python
def get_metrics(self, metric_identifiers, from_date, limit=10, group_by="week", **kwargs): """ Retrieves a multiple metrics as efficiently as possible. :param metric_identifiers: a list of tuples of the form `(unique_identifier, metric_name`) identifying which metrics to retrieve. For e...
[ "def", "get_metrics", "(", "self", ",", "metric_identifiers", ",", "from_date", ",", "limit", "=", "10", ",", "group_by", "=", "\"week\"", ",", "*", "*", "kwargs", ")", ":", "results", "=", "[", "]", "#validation of types:", "allowed_types", "=", "{", "\"d...
Retrieves a multiple metrics as efficiently as possible. :param metric_identifiers: a list of tuples of the form `(unique_identifier, metric_name`) identifying which metrics to retrieve. For example [('user:1', 'people_invited',), ('user:2', 'people_invited',), ('user:1', 'comments_posted',), ('user:2'...
[ "Retrieves", "a", "multiple", "metrics", "as", "efficiently", "as", "possible", "." ]
train
https://github.com/numan/py-analytics/blob/abbc814925c6cc200b3329c7de9f1868e1cb8c01/analytics/backends/redis.py#L315-L344
numan/py-analytics
analytics/backends/redis.py
Redis.get_count
def get_count(self, unique_identifier, metric, start_date=None, end_date=None, **kwargs): """ Gets the count for the ``metric`` for ``unique_identifier``. You can specify a ``start_date`` and an ``end_date``, to only get metrics within that time range. :param unique_identifier: Unique s...
python
def get_count(self, unique_identifier, metric, start_date=None, end_date=None, **kwargs): """ Gets the count for the ``metric`` for ``unique_identifier``. You can specify a ``start_date`` and an ``end_date``, to only get metrics within that time range. :param unique_identifier: Unique s...
[ "def", "get_count", "(", "self", ",", "unique_identifier", ",", "metric", ",", "start_date", "=", "None", ",", "end_date", "=", "None", ",", "*", "*", "kwargs", ")", ":", "result", "=", "None", "if", "start_date", "and", "end_date", ":", "start_date", ",...
Gets the count for the ``metric`` for ``unique_identifier``. You can specify a ``start_date`` and an ``end_date``, to only get metrics within that time range. :param unique_identifier: Unique string indetifying the object this metric is for :param metric: A unique name for the metric you want t...
[ "Gets", "the", "count", "for", "the", "metric", "for", "unique_identifier", ".", "You", "can", "specify", "a", "start_date", "and", "an", "end_date", "to", "only", "get", "metrics", "within", "that", "time", "range", "." ]
train
https://github.com/numan/py-analytics/blob/abbc814925c6cc200b3329c7de9f1868e1cb8c01/analytics/backends/redis.py#L346-L389
numan/py-analytics
analytics/backends/redis.py
Redis.get_counts
def get_counts(self, metric_identifiers, **kwargs): """ Retrieves a multiple metrics as efficiently as possible. :param metric_identifiers: a list of tuples of the form `(unique_identifier, metric_name`) identifying which metrics to retrieve. For example [('user:1', 'people_invited',), ...
python
def get_counts(self, metric_identifiers, **kwargs): """ Retrieves a multiple metrics as efficiently as possible. :param metric_identifiers: a list of tuples of the form `(unique_identifier, metric_name`) identifying which metrics to retrieve. For example [('user:1', 'people_invited',), ...
[ "def", "get_counts", "(", "self", ",", "metric_identifiers", ",", "*", "*", "kwargs", ")", ":", "parsed_results", "=", "[", "]", "results", "=", "[", "self", ".", "get_count", "(", "unique_identifier", ",", "metric", ",", "*", "*", "kwargs", ")", "for", ...
Retrieves a multiple metrics as efficiently as possible. :param metric_identifiers: a list of tuples of the form `(unique_identifier, metric_name`) identifying which metrics to retrieve. For example [('user:1', 'people_invited',), ('user:2', 'people_invited',), ('user:1', 'comments_posted',), ('user:2'...
[ "Retrieves", "a", "multiple", "metrics", "as", "efficiently", "as", "possible", "." ]
train
https://github.com/numan/py-analytics/blob/abbc814925c6cc200b3329c7de9f1868e1cb8c01/analytics/backends/redis.py#L391-L411
numan/py-analytics
analytics/backends/redis.py
Redis.set_metric_by_day
def set_metric_by_day(self, unique_identifier, metric, date, count, sync_agg=True, update_counter=True): """ Sets the count for the ``metric`` for ``unique_identifier``. You must specify a ``date`` for the ``count`` to be set on. Useful for resetting a metric count to 0 or decrementing a metric....
python
def set_metric_by_day(self, unique_identifier, metric, date, count, sync_agg=True, update_counter=True): """ Sets the count for the ``metric`` for ``unique_identifier``. You must specify a ``date`` for the ``count`` to be set on. Useful for resetting a metric count to 0 or decrementing a metric....
[ "def", "set_metric_by_day", "(", "self", ",", "unique_identifier", ",", "metric", ",", "date", ",", "count", ",", "sync_agg", "=", "True", ",", "update_counter", "=", "True", ")", ":", "metric", "=", "[", "metric", "]", "if", "isinstance", "(", "metric", ...
Sets the count for the ``metric`` for ``unique_identifier``. You must specify a ``date`` for the ``count`` to be set on. Useful for resetting a metric count to 0 or decrementing a metric. The redis backend supports lists for both ``unique_identifier`` and ``metric`` allowing for the setting of ...
[ "Sets", "the", "count", "for", "the", "metric", "for", "unique_identifier", ".", "You", "must", "specify", "a", "date", "for", "the", "count", "to", "be", "set", "on", ".", "Useful", "for", "resetting", "a", "metric", "count", "to", "0", "or", "decrement...
train
https://github.com/numan/py-analytics/blob/abbc814925c6cc200b3329c7de9f1868e1cb8c01/analytics/backends/redis.py#L413-L448
numan/py-analytics
analytics/backends/redis.py
Redis.sync_agg_metric
def sync_agg_metric(self, unique_identifier, metric, start_date, end_date): """ Uses the count for each day in the date range to recalculate the counters for the associated weeks and months for the ``metric`` for ``unique_identifier``. Useful for updating the counters for week and month after us...
python
def sync_agg_metric(self, unique_identifier, metric, start_date, end_date): """ Uses the count for each day in the date range to recalculate the counters for the associated weeks and months for the ``metric`` for ``unique_identifier``. Useful for updating the counters for week and month after us...
[ "def", "sync_agg_metric", "(", "self", ",", "unique_identifier", ",", "metric", ",", "start_date", ",", "end_date", ")", ":", "self", ".", "sync_week_metric", "(", "unique_identifier", ",", "metric", ",", "start_date", ",", "end_date", ")", "self", ".", "sync_...
Uses the count for each day in the date range to recalculate the counters for the associated weeks and months for the ``metric`` for ``unique_identifier``. Useful for updating the counters for week and month after using set_metric_by_day. The redis backend supports lists for both ``unique_identifier`` ...
[ "Uses", "the", "count", "for", "each", "day", "in", "the", "date", "range", "to", "recalculate", "the", "counters", "for", "the", "associated", "weeks", "and", "months", "for", "the", "metric", "for", "unique_identifier", ".", "Useful", "for", "updating", "t...
train
https://github.com/numan/py-analytics/blob/abbc814925c6cc200b3329c7de9f1868e1cb8c01/analytics/backends/redis.py#L450-L464
numan/py-analytics
analytics/backends/redis.py
Redis.sync_week_metric
def sync_week_metric(self, unique_identifier, metric, start_date, end_date): """ Uses the count for each day in the date range to recalculate the counters for the weeks for the ``metric`` for ``unique_identifier``. Useful for updating the counters for week and month after using set_metri...
python
def sync_week_metric(self, unique_identifier, metric, start_date, end_date): """ Uses the count for each day in the date range to recalculate the counters for the weeks for the ``metric`` for ``unique_identifier``. Useful for updating the counters for week and month after using set_metri...
[ "def", "sync_week_metric", "(", "self", ",", "unique_identifier", ",", "metric", ",", "start_date", ",", "end_date", ")", ":", "metric", "=", "[", "metric", "]", "if", "isinstance", "(", "metric", ",", "basestring", ")", "else", "metric", "unique_identifier", ...
Uses the count for each day in the date range to recalculate the counters for the weeks for the ``metric`` for ``unique_identifier``. Useful for updating the counters for week and month after using set_metric_by_day. The redis backend supports lists for both ``unique_identifier`` and ``metric``...
[ "Uses", "the", "count", "for", "each", "day", "in", "the", "date", "range", "to", "recalculate", "the", "counters", "for", "the", "weeks", "for", "the", "metric", "for", "unique_identifier", ".", "Useful", "for", "updating", "the", "counters", "for", "week",...
train
https://github.com/numan/py-analytics/blob/abbc814925c6cc200b3329c7de9f1868e1cb8c01/analytics/backends/redis.py#L466-L498
numan/py-analytics
analytics/backends/redis.py
Redis.sync_month_metric
def sync_month_metric(self, unique_identifier, metric, start_date, end_date): """ Uses the count for each day in the date range to recalculate the counters for the months for the ``metric`` for ``unique_identifier``. Useful for updating the counters for week and month after using set_metric_by_d...
python
def sync_month_metric(self, unique_identifier, metric, start_date, end_date): """ Uses the count for each day in the date range to recalculate the counters for the months for the ``metric`` for ``unique_identifier``. Useful for updating the counters for week and month after using set_metric_by_d...
[ "def", "sync_month_metric", "(", "self", ",", "unique_identifier", ",", "metric", ",", "start_date", ",", "end_date", ")", ":", "metric", "=", "[", "metric", "]", "if", "isinstance", "(", "metric", ",", "basestring", ")", "else", "metric", "unique_identifier",...
Uses the count for each day in the date range to recalculate the counters for the months for the ``metric`` for ``unique_identifier``. Useful for updating the counters for week and month after using set_metric_by_day. The redis backend supports lists for both ``unique_identifier`` and ``metric`` allowi...
[ "Uses", "the", "count", "for", "each", "day", "in", "the", "date", "range", "to", "recalculate", "the", "counters", "for", "the", "months", "for", "the", "metric", "for", "unique_identifier", ".", "Useful", "for", "updating", "the", "counters", "for", "week"...
train
https://github.com/numan/py-analytics/blob/abbc814925c6cc200b3329c7de9f1868e1cb8c01/analytics/backends/redis.py#L500-L532
non-Jedi/gyr
gyr/utils.py
is_full_mxid
def is_full_mxid(user_string): """Returns True if a string is a valid mxid.""" if not user_string[0] == "@": return False parts = user_string[1:].split(":") localpart_chars = ascii_lowercase + digits + "._-=" if not (len(parts) == 2 and all([i in localpart_chars for i in parts[0]])): ...
python
def is_full_mxid(user_string): """Returns True if a string is a valid mxid.""" if not user_string[0] == "@": return False parts = user_string[1:].split(":") localpart_chars = ascii_lowercase + digits + "._-=" if not (len(parts) == 2 and all([i in localpart_chars for i in parts[0]])): ...
[ "def", "is_full_mxid", "(", "user_string", ")", ":", "if", "not", "user_string", "[", "0", "]", "==", "\"@\"", ":", "return", "False", "parts", "=", "user_string", "[", "1", ":", "]", ".", "split", "(", "\":\"", ")", "localpart_chars", "=", "ascii_lowerc...
Returns True if a string is a valid mxid.
[ "Returns", "True", "if", "a", "string", "is", "a", "valid", "mxid", "." ]
train
https://github.com/non-Jedi/gyr/blob/9f7bfe033b9d3bbfd3a9e8aea02e35526b53125e/gyr/utils.py#L30-L38
non-Jedi/gyr
gyr/utils.py
intent
def intent(method): """Helps object methods handle MatrixRequestError. Args: method(function): Object method to be wrapped Method's object must have _handle_request_exception method that deals with specific status codes and errcodes. """ def wrapper(self, *args, **kwargs): try...
python
def intent(method): """Helps object methods handle MatrixRequestError. Args: method(function): Object method to be wrapped Method's object must have _handle_request_exception method that deals with specific status codes and errcodes. """ def wrapper(self, *args, **kwargs): try...
[ "def", "intent", "(", "method", ")", ":", "def", "wrapper", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "return", "method", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", "except", "exceptions", "."...
Helps object methods handle MatrixRequestError. Args: method(function): Object method to be wrapped Method's object must have _handle_request_exception method that deals with specific status codes and errcodes.
[ "Helps", "object", "methods", "handle", "MatrixRequestError", "." ]
train
https://github.com/non-Jedi/gyr/blob/9f7bfe033b9d3bbfd3a9e8aea02e35526b53125e/gyr/utils.py#L46-L68
malramsay64/experi
src/experi/commands.py
Command.get_variables
def get_variables(self) -> Set[str]: """Find all the variables specified in a format string. This returns a list of all the different variables specified in a format string, that is the variables inside the braces. """ variables = set() for cmd in self._cmd: ...
python
def get_variables(self) -> Set[str]: """Find all the variables specified in a format string. This returns a list of all the different variables specified in a format string, that is the variables inside the braces. """ variables = set() for cmd in self._cmd: ...
[ "def", "get_variables", "(", "self", ")", "->", "Set", "[", "str", "]", ":", "variables", "=", "set", "(", ")", "for", "cmd", "in", "self", ".", "_cmd", ":", "for", "var", "in", "self", ".", "__formatter", ".", "parse", "(", "cmd", ")", ":", "log...
Find all the variables specified in a format string. This returns a list of all the different variables specified in a format string, that is the variables inside the braces.
[ "Find", "all", "the", "variables", "specified", "in", "a", "format", "string", "." ]
train
https://github.com/malramsay64/experi/blob/7159644df0420e4a395c87c0c08e11567f401443/src/experi/commands.py#L53-L67
malramsay64/experi
src/experi/commands.py
Job.as_bash_array
def as_bash_array(self) -> str: """Return a representation as a bash array. This creates a string formatted as a bash array containing all the commands in the job. """ return_string = "( \\\n" for command in self: return_string += '"' + str(command) + '" \\\n' ...
python
def as_bash_array(self) -> str: """Return a representation as a bash array. This creates a string formatted as a bash array containing all the commands in the job. """ return_string = "( \\\n" for command in self: return_string += '"' + str(command) + '" \\\n' ...
[ "def", "as_bash_array", "(", "self", ")", "->", "str", ":", "return_string", "=", "\"( \\\\\\n\"", "for", "command", "in", "self", ":", "return_string", "+=", "'\"'", "+", "str", "(", "command", ")", "+", "'\" \\\\\\n'", "return_string", "+=", "\")\"", "retu...
Return a representation as a bash array. This creates a string formatted as a bash array containing all the commands in the job.
[ "Return", "a", "representation", "as", "a", "bash", "array", "." ]
train
https://github.com/malramsay64/experi/blob/7159644df0420e4a395c87c0c08e11567f401443/src/experi/commands.py#L140-L150
tipsi/tipsi_tools
tipsi_tools/doc_utils/tipsi_sphinx/dyn_serializer.py
parse_doc
def parse_doc(doc): """ Parse docstrings to dict, it should look like: key: value """ if not doc: return {} out = {} for s in doc.split('\n'): s = s.strip().split(':', maxsplit=1) if len(s) == 2: out[s[0]] = s[1] return out
python
def parse_doc(doc): """ Parse docstrings to dict, it should look like: key: value """ if not doc: return {} out = {} for s in doc.split('\n'): s = s.strip().split(':', maxsplit=1) if len(s) == 2: out[s[0]] = s[1] return out
[ "def", "parse_doc", "(", "doc", ")", ":", "if", "not", "doc", ":", "return", "{", "}", "out", "=", "{", "}", "for", "s", "in", "doc", ".", "split", "(", "'\\n'", ")", ":", "s", "=", "s", ".", "strip", "(", ")", ".", "split", "(", "':'", ","...
Parse docstrings to dict, it should look like: key: value
[ "Parse", "docstrings", "to", "dict", "it", "should", "look", "like", ":", "key", ":", "value" ]
train
https://github.com/tipsi/tipsi_tools/blob/1aba960c9890ceef2fb5e215b98b1646056ee58e/tipsi_tools/doc_utils/tipsi_sphinx/dyn_serializer.py#L20-L32
malramsay64/experi
src/experi/run.py
combine_dictionaries
def combine_dictionaries(dicts: List[Dict[str, Any]]) -> Dict[str, Any]: """Merge a list of dictionaries into a single dictionary. Where there are collisions the first value in the list will be set as this function is using ChainMap to combine the dicts. """ return dict(ChainMap(*dicts))
python
def combine_dictionaries(dicts: List[Dict[str, Any]]) -> Dict[str, Any]: """Merge a list of dictionaries into a single dictionary. Where there are collisions the first value in the list will be set as this function is using ChainMap to combine the dicts. """ return dict(ChainMap(*dicts))
[ "def", "combine_dictionaries", "(", "dicts", ":", "List", "[", "Dict", "[", "str", ",", "Any", "]", "]", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "return", "dict", "(", "ChainMap", "(", "*", "dicts", ")", ")" ]
Merge a list of dictionaries into a single dictionary. Where there are collisions the first value in the list will be set as this function is using ChainMap to combine the dicts.
[ "Merge", "a", "list", "of", "dictionaries", "into", "a", "single", "dictionary", "." ]
train
https://github.com/malramsay64/experi/blob/7159644df0420e4a395c87c0c08e11567f401443/src/experi/run.py#L39-L46
malramsay64/experi
src/experi/run.py
iterator_zip
def iterator_zip(variables: VarType, parent: str = None) -> Iterable[VarMatrix]: """Apply the zip operator to a set of variables. This uses the python zip iterator to combine multiple lists of variables such that the nth variable in each list is aligned. Args: variables: The variables object ...
python
def iterator_zip(variables: VarType, parent: str = None) -> Iterable[VarMatrix]: """Apply the zip operator to a set of variables. This uses the python zip iterator to combine multiple lists of variables such that the nth variable in each list is aligned. Args: variables: The variables object ...
[ "def", "iterator_zip", "(", "variables", ":", "VarType", ",", "parent", ":", "str", "=", "None", ")", "->", "Iterable", "[", "VarMatrix", "]", ":", "logger", ".", "debug", "(", "\"Yielding from zip iterator\"", ")", "if", "isinstance", "(", "variables", ",",...
Apply the zip operator to a set of variables. This uses the python zip iterator to combine multiple lists of variables such that the nth variable in each list is aligned. Args: variables: The variables object parent: Unused
[ "Apply", "the", "zip", "operator", "to", "a", "set", "of", "variables", "." ]
train
https://github.com/malramsay64/experi/blob/7159644df0420e4a395c87c0c08e11567f401443/src/experi/run.py#L49-L66
malramsay64/experi
src/experi/run.py
iterator_product
def iterator_product(variables: VarType, parent: str = None) -> Iterable[VarMatrix]: """Apply the product operator to a set of variables. This uses the python itertools.product iterator to combine multiple variables such that all possible combinations are generated. This is the default iterator however...
python
def iterator_product(variables: VarType, parent: str = None) -> Iterable[VarMatrix]: """Apply the product operator to a set of variables. This uses the python itertools.product iterator to combine multiple variables such that all possible combinations are generated. This is the default iterator however...
[ "def", "iterator_product", "(", "variables", ":", "VarType", ",", "parent", ":", "str", "=", "None", ")", "->", "Iterable", "[", "VarMatrix", "]", ":", "logger", ".", "debug", "(", "\"Yielding from product iterator\"", ")", "if", "isinstance", "(", "variables"...
Apply the product operator to a set of variables. This uses the python itertools.product iterator to combine multiple variables such that all possible combinations are generated. This is the default iterator however this is a method of manually specifying the option. Args: variables: The varia...
[ "Apply", "the", "product", "operator", "to", "a", "set", "of", "variables", "." ]
train
https://github.com/malramsay64/experi/blob/7159644df0420e4a395c87c0c08e11567f401443/src/experi/run.py#L69-L87
malramsay64/experi
src/experi/run.py
iterator_chain
def iterator_chain(variables: VarType, parent: str = None) -> Iterable[VarMatrix]: """This successively appends each element of an array to a single list of values. This takes a list of values and puts all the values generated for each element in the list into a single list of values. It uses the :func:`it...
python
def iterator_chain(variables: VarType, parent: str = None) -> Iterable[VarMatrix]: """This successively appends each element of an array to a single list of values. This takes a list of values and puts all the values generated for each element in the list into a single list of values. It uses the :func:`it...
[ "def", "iterator_chain", "(", "variables", ":", "VarType", ",", "parent", ":", "str", "=", "None", ")", "->", "Iterable", "[", "VarMatrix", "]", ":", "logger", ".", "debug", "(", "\"Yielding from append iterator\"", ")", "if", "not", "isinstance", "(", "vari...
This successively appends each element of an array to a single list of values. This takes a list of values and puts all the values generated for each element in the list into a single list of values. It uses the :func:`itertools.chain` function to achieve this. This function is particularly useful for spec...
[ "This", "successively", "appends", "each", "element", "of", "an", "array", "to", "a", "single", "list", "of", "values", "." ]
train
https://github.com/malramsay64/experi/blob/7159644df0420e4a395c87c0c08e11567f401443/src/experi/run.py#L90-L114
malramsay64/experi
src/experi/run.py
iterator_arange
def iterator_arange(variables: VarType, parent: str) -> Iterable[VarMatrix]: """Create a list of values using the :func:`numpy.arange` function. Args: variables: The input variables for the creation of the range parent: The variable for which the values are being generated. Returns: A list...
python
def iterator_arange(variables: VarType, parent: str) -> Iterable[VarMatrix]: """Create a list of values using the :func:`numpy.arange` function. Args: variables: The input variables for the creation of the range parent: The variable for which the values are being generated. Returns: A list...
[ "def", "iterator_arange", "(", "variables", ":", "VarType", ",", "parent", ":", "str", ")", "->", "Iterable", "[", "VarMatrix", "]", ":", "assert", "parent", "is", "not", "None", "if", "isinstance", "(", "variables", ",", "(", "int", ",", "float", ")", ...
Create a list of values using the :func:`numpy.arange` function. Args: variables: The input variables for the creation of the range parent: The variable for which the values are being generated. Returns: A list of dictionaries mapping the parent to each value.
[ "Create", "a", "list", "of", "values", "using", "the", ":", "func", ":", "numpy", ".", "arange", "function", "." ]
train
https://github.com/malramsay64/experi/blob/7159644df0420e4a395c87c0c08e11567f401443/src/experi/run.py#L123-L146
malramsay64/experi
src/experi/run.py
iterator_cycle
def iterator_cycle(variables: VarType, parent: str) -> Iterable[VarMatrix]: """Cycle through a list of values a specified number of times Args: variables: The input variables for the creation of the range parent: The variable for which the values are being generated. Returns: A list of dic...
python
def iterator_cycle(variables: VarType, parent: str) -> Iterable[VarMatrix]: """Cycle through a list of values a specified number of times Args: variables: The input variables for the creation of the range parent: The variable for which the values are being generated. Returns: A list of dic...
[ "def", "iterator_cycle", "(", "variables", ":", "VarType", ",", "parent", ":", "str", ")", "->", "Iterable", "[", "VarMatrix", "]", ":", "if", "isinstance", "(", "variables", ",", "dict", ")", ":", "if", "variables", ".", "get", "(", "\"times\"", ")", ...
Cycle through a list of values a specified number of times Args: variables: The input variables for the creation of the range parent: The variable for which the values are being generated. Returns: A list of dictionaries mapping the parent to each value.
[ "Cycle", "through", "a", "list", "of", "values", "a", "specified", "number", "of", "times" ]
train
https://github.com/malramsay64/experi/blob/7159644df0420e4a395c87c0c08e11567f401443/src/experi/run.py#L149-L171
malramsay64/experi
src/experi/run.py
variable_matrix
def variable_matrix( variables: VarType, parent: str = None, iterator: str = "product" ) -> Iterable[Dict[str, YamlValue]]: """Process the variables into a list of the appropriate combinations. This function performs recursive processing of the input variables, creating an iterator which has all the co...
python
def variable_matrix( variables: VarType, parent: str = None, iterator: str = "product" ) -> Iterable[Dict[str, YamlValue]]: """Process the variables into a list of the appropriate combinations. This function performs recursive processing of the input variables, creating an iterator which has all the co...
[ "def", "variable_matrix", "(", "variables", ":", "VarType", ",", "parent", ":", "str", "=", "None", ",", "iterator", ":", "str", "=", "\"product\"", ")", "->", "Iterable", "[", "Dict", "[", "str", ",", "YamlValue", "]", "]", ":", "_iters", ":", "Dict",...
Process the variables into a list of the appropriate combinations. This function performs recursive processing of the input variables, creating an iterator which has all the combinations of variables specified in the input.
[ "Process", "the", "variables", "into", "a", "list", "of", "the", "appropriate", "combinations", "." ]
train
https://github.com/malramsay64/experi/blob/7159644df0420e4a395c87c0c08e11567f401443/src/experi/run.py#L174-L226
malramsay64/experi
src/experi/run.py
uniqueify
def uniqueify(my_list: Any) -> List[Any]: """Remove duplicate entries in a list retaining order.""" if sys.version_info >= (3, 6): # An implementation specific detail of py3.6 is the retention of order # within a dictionary. In py3.7 this becomes the documented behaviour. return list(dic...
python
def uniqueify(my_list: Any) -> List[Any]: """Remove duplicate entries in a list retaining order.""" if sys.version_info >= (3, 6): # An implementation specific detail of py3.6 is the retention of order # within a dictionary. In py3.7 this becomes the documented behaviour. return list(dic...
[ "def", "uniqueify", "(", "my_list", ":", "Any", ")", "->", "List", "[", "Any", "]", ":", "if", "sys", ".", "version_info", ">=", "(", "3", ",", "6", ")", ":", "# An implementation specific detail of py3.6 is the retention of order", "# within a dictionary. In py3.7 ...
Remove duplicate entries in a list retaining order.
[ "Remove", "duplicate", "entries", "in", "a", "list", "retaining", "order", "." ]
train
https://github.com/malramsay64/experi/blob/7159644df0420e4a395c87c0c08e11567f401443/src/experi/run.py#L229-L238
malramsay64/experi
src/experi/run.py
process_command
def process_command(command: CommandInput, matrix: VarMatrix) -> List[Command]: """Generate all combinations of commands given a variable matrix. Processes the commands to be sequences of strings. """ assert command is not None if isinstance(command, str): command_list = [Command(command, ...
python
def process_command(command: CommandInput, matrix: VarMatrix) -> List[Command]: """Generate all combinations of commands given a variable matrix. Processes the commands to be sequences of strings. """ assert command is not None if isinstance(command, str): command_list = [Command(command, ...
[ "def", "process_command", "(", "command", ":", "CommandInput", ",", "matrix", ":", "VarMatrix", ")", "->", "List", "[", "Command", "]", ":", "assert", "command", "is", "not", "None", "if", "isinstance", "(", "command", ",", "str", ")", ":", "command_list",...
Generate all combinations of commands given a variable matrix. Processes the commands to be sequences of strings.
[ "Generate", "all", "combinations", "of", "commands", "given", "a", "variable", "matrix", "." ]
train
https://github.com/malramsay64/experi/blob/7159644df0420e4a395c87c0c08e11567f401443/src/experi/run.py#L263-L286
malramsay64/experi
src/experi/run.py
read_file
def read_file(filename: PathLike = "experiment.yml") -> Dict[str, Any]: """Read and parse yaml file.""" logger.debug("Input file: %s", filename) with open(filename, "r") as stream: structure = yaml.safe_load(stream) return structure
python
def read_file(filename: PathLike = "experiment.yml") -> Dict[str, Any]: """Read and parse yaml file.""" logger.debug("Input file: %s", filename) with open(filename, "r") as stream: structure = yaml.safe_load(stream) return structure
[ "def", "read_file", "(", "filename", ":", "PathLike", "=", "\"experiment.yml\"", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "logger", ".", "debug", "(", "\"Input file: %s\"", ",", "filename", ")", "with", "open", "(", "filename", ",", "\"r\"", ...
Read and parse yaml file.
[ "Read", "and", "parse", "yaml", "file", "." ]
train
https://github.com/malramsay64/experi/blob/7159644df0420e4a395c87c0c08e11567f401443/src/experi/run.py#L289-L295
malramsay64/experi
src/experi/run.py
run_bash_jobs
def run_bash_jobs( jobs: Iterator[Job], directory: PathLike = Path.cwd(), dry_run: bool = False ) -> None: """Submit commands to the bash shell. This function runs the commands iteratively but handles errors in the same way as with the pbs_commands function. A command will run for all combinations ...
python
def run_bash_jobs( jobs: Iterator[Job], directory: PathLike = Path.cwd(), dry_run: bool = False ) -> None: """Submit commands to the bash shell. This function runs the commands iteratively but handles errors in the same way as with the pbs_commands function. A command will run for all combinations ...
[ "def", "run_bash_jobs", "(", "jobs", ":", "Iterator", "[", "Job", "]", ",", "directory", ":", "PathLike", "=", "Path", ".", "cwd", "(", ")", ",", "dry_run", ":", "bool", "=", "False", ")", "->", "None", ":", "logger", ".", "debug", "(", "\"Running co...
Submit commands to the bash shell. This function runs the commands iteratively but handles errors in the same way as with the pbs_commands function. A command will run for all combinations of variables in the variable matrix, however if any one of those commands fails then the next command will not run...
[ "Submit", "commands", "to", "the", "bash", "shell", "." ]
train
https://github.com/malramsay64/experi/blob/7159644df0420e4a395c87c0c08e11567f401443/src/experi/run.py#L361-L395
malramsay64/experi
src/experi/run.py
run_scheduler_jobs
def run_scheduler_jobs( scheduler: str, jobs: Iterator[Job], directory: PathLike = Path.cwd(), basename: str = "experi", dry_run: bool = False, ) -> None: """Submit a series of commands to a batch scheduler. This takes a list of strings which are the contents of the pbs files, writes the ...
python
def run_scheduler_jobs( scheduler: str, jobs: Iterator[Job], directory: PathLike = Path.cwd(), basename: str = "experi", dry_run: bool = False, ) -> None: """Submit a series of commands to a batch scheduler. This takes a list of strings which are the contents of the pbs files, writes the ...
[ "def", "run_scheduler_jobs", "(", "scheduler", ":", "str", ",", "jobs", ":", "Iterator", "[", "Job", "]", ",", "directory", ":", "PathLike", "=", "Path", ".", "cwd", "(", ")", ",", "basename", ":", "str", "=", "\"experi\"", ",", "dry_run", ":", "bool",...
Submit a series of commands to a batch scheduler. This takes a list of strings which are the contents of the pbs files, writes the files to disk and submits the job to the scheduler. Files which match the pattern of the resulting files <basename>_<index>.pbs are deleted before writing the new files. T...
[ "Submit", "a", "series", "of", "commands", "to", "a", "batch", "scheduler", "." ]
train
https://github.com/malramsay64/experi/blob/7159644df0420e4a395c87c0c08e11567f401443/src/experi/run.py#L398-L483
malramsay64/experi
src/experi/run.py
determine_scheduler
def determine_scheduler( scheduler: Optional[str], experiment_definition: Dict[str, YamlValue] ) -> str: """Determine the scheduler to use to run the jobs.""" # Scheduler value from command line has first priority if scheduler is not None: if scheduler in ["shell", "pbs", "slurm"]: ...
python
def determine_scheduler( scheduler: Optional[str], experiment_definition: Dict[str, YamlValue] ) -> str: """Determine the scheduler to use to run the jobs.""" # Scheduler value from command line has first priority if scheduler is not None: if scheduler in ["shell", "pbs", "slurm"]: ...
[ "def", "determine_scheduler", "(", "scheduler", ":", "Optional", "[", "str", "]", ",", "experiment_definition", ":", "Dict", "[", "str", ",", "YamlValue", "]", ")", "->", "str", ":", "# Scheduler value from command line has first priority", "if", "scheduler", "is", ...
Determine the scheduler to use to run the jobs.
[ "Determine", "the", "scheduler", "to", "use", "to", "run", "the", "jobs", "." ]
train
https://github.com/malramsay64/experi/blob/7159644df0420e4a395c87c0c08e11567f401443/src/experi/run.py#L486-L514
alfredodeza/notario
notario/validators/iterables.py
BasicIterableValidator.safe_type
def safe_type(self, data, tree): """ Make sure that the incoming data complies with the class type we are expecting it to be. In this case, classes that inherit from this base class expect data to be of type ``list``. """ if not isinstance(data, list): name = ...
python
def safe_type(self, data, tree): """ Make sure that the incoming data complies with the class type we are expecting it to be. In this case, classes that inherit from this base class expect data to be of type ``list``. """ if not isinstance(data, list): name = ...
[ "def", "safe_type", "(", "self", ",", "data", ",", "tree", ")", ":", "if", "not", "isinstance", "(", "data", ",", "list", ")", ":", "name", "=", "self", ".", "__class__", ".", "__name__", "msg", "=", "\"did not pass validation against callable: %s\"", "%", ...
Make sure that the incoming data complies with the class type we are expecting it to be. In this case, classes that inherit from this base class expect data to be of type ``list``.
[ "Make", "sure", "that", "the", "incoming", "data", "complies", "with", "the", "class", "type", "we", "are", "expecting", "it", "to", "be", ".", "In", "this", "case", "classes", "that", "inherit", "from", "this", "base", "class", "expect", "data", "to", "...
train
https://github.com/alfredodeza/notario/blob/d5dc2edfcb75d9291ced3f2551f368c35dd31475/notario/validators/iterables.py#L22-L32
aptivate/ckanext-datasetversions
ckanext/datasetversions/helpers.py
get_context
def get_context(context): """An internal context generator. Accepts a CKAN context. CKAN's internals put various things into the context which makes reusing it for multiple API calls inadvisable. This function adds more fine grain control on the context from our plugin logic side. """ new_c...
python
def get_context(context): """An internal context generator. Accepts a CKAN context. CKAN's internals put various things into the context which makes reusing it for multiple API calls inadvisable. This function adds more fine grain control on the context from our plugin logic side. """ new_c...
[ "def", "get_context", "(", "context", ")", ":", "new_context", "=", "{", "'model'", ":", "context", "[", "'model'", "]", ",", "'session'", ":", "context", "[", "'session'", "]", ",", "'user'", ":", "context", ".", "get", "(", "'user'", ")", ",", "'igno...
An internal context generator. Accepts a CKAN context. CKAN's internals put various things into the context which makes reusing it for multiple API calls inadvisable. This function adds more fine grain control on the context from our plugin logic side.
[ "An", "internal", "context", "generator", ".", "Accepts", "a", "CKAN", "context", "." ]
train
https://github.com/aptivate/ckanext-datasetversions/blob/6a82fa5b20e28c705a2c187f4835b31ae928d88a/ckanext/datasetversions/helpers.py#L16-L35
tipsi/tipsi_tools
tipsi_tools/django/__init__.py
request_uniq
def request_uniq(func): """ return unique dict for each uwsgi request. note: won't work on non-uwsgi cases """ def _wrapped(*args, **kwargs): data = _get_request_unique_cache() return func(data, *args, **kwargs) return _wrapped
python
def request_uniq(func): """ return unique dict for each uwsgi request. note: won't work on non-uwsgi cases """ def _wrapped(*args, **kwargs): data = _get_request_unique_cache() return func(data, *args, **kwargs) return _wrapped
[ "def", "request_uniq", "(", "func", ")", ":", "def", "_wrapped", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "data", "=", "_get_request_unique_cache", "(", ")", "return", "func", "(", "data", ",", "*", "args", ",", "*", "*", "kwargs", ")", ...
return unique dict for each uwsgi request. note: won't work on non-uwsgi cases
[ "return", "unique", "dict", "for", "each", "uwsgi", "request", ".", "note", ":", "won", "t", "work", "on", "non", "-", "uwsgi", "cases" ]
train
https://github.com/tipsi/tipsi_tools/blob/1aba960c9890ceef2fb5e215b98b1646056ee58e/tipsi_tools/django/__init__.py#L21-L31
alfredodeza/notario
notario/utils.py
safe_repr
def safe_repr(obj): """ Try to get ``__name__`` first, ``__class__.__name__`` second and finally, if we can't get anything acceptable, fallback to user a ``repr()`` call. """ name = getattr(obj, '__name__', getattr(obj.__class__, '__name__')) if name == 'ndict': name = 'dict' ret...
python
def safe_repr(obj): """ Try to get ``__name__`` first, ``__class__.__name__`` second and finally, if we can't get anything acceptable, fallback to user a ``repr()`` call. """ name = getattr(obj, '__name__', getattr(obj.__class__, '__name__')) if name == 'ndict': name = 'dict' ret...
[ "def", "safe_repr", "(", "obj", ")", ":", "name", "=", "getattr", "(", "obj", ",", "'__name__'", ",", "getattr", "(", "obj", ".", "__class__", ",", "'__name__'", ")", ")", "if", "name", "==", "'ndict'", ":", "name", "=", "'dict'", "return", "name", "...
Try to get ``__name__`` first, ``__class__.__name__`` second and finally, if we can't get anything acceptable, fallback to user a ``repr()`` call.
[ "Try", "to", "get", "__name__", "first", "__class__", ".", "__name__", "second", "and", "finally", "if", "we", "can", "t", "get", "anything", "acceptable", "fallback", "to", "user", "a", "repr", "()", "call", "." ]
train
https://github.com/alfredodeza/notario/blob/d5dc2edfcb75d9291ced3f2551f368c35dd31475/notario/utils.py#L10-L19
alfredodeza/notario
notario/utils.py
re_sort
def re_sort(data): """ A data with keys that are not enumerated sequentially will be re sorted and sequentially ordered. For example:: >>> data = {16: ('1', 'b'), 3: ('1', 'a')} >>> re_sort(data) >>> {0: ('1', 'a'), 1: ('1', 'b')} """ keys = sorted(data.keys()) new_...
python
def re_sort(data): """ A data with keys that are not enumerated sequentially will be re sorted and sequentially ordered. For example:: >>> data = {16: ('1', 'b'), 3: ('1', 'a')} >>> re_sort(data) >>> {0: ('1', 'a'), 1: ('1', 'b')} """ keys = sorted(data.keys()) new_...
[ "def", "re_sort", "(", "data", ")", ":", "keys", "=", "sorted", "(", "data", ".", "keys", "(", ")", ")", "new_data", "=", "{", "}", "for", "number", ",", "key", "in", "enumerate", "(", "keys", ")", ":", "new_data", "[", "number", "]", "=", "data"...
A data with keys that are not enumerated sequentially will be re sorted and sequentially ordered. For example:: >>> data = {16: ('1', 'b'), 3: ('1', 'a')} >>> re_sort(data) >>> {0: ('1', 'a'), 1: ('1', 'b')}
[ "A", "data", "with", "keys", "that", "are", "not", "enumerated", "sequentially", "will", "be", "re", "sorted", "and", "sequentially", "ordered", "." ]
train
https://github.com/alfredodeza/notario/blob/d5dc2edfcb75d9291ced3f2551f368c35dd31475/notario/utils.py#L39-L54
alfredodeza/notario
notario/utils.py
sift
def sift(data, required_items=None): """ Receive a ``data`` object that will be in the form of a normalized structure (e.g. ``{0: {'a': 0}}``) and filter out keys that match the ``required_items``. """ required_items = required_items or [] new_data = {} for k, v in data.items(): ...
python
def sift(data, required_items=None): """ Receive a ``data`` object that will be in the form of a normalized structure (e.g. ``{0: {'a': 0}}``) and filter out keys that match the ``required_items``. """ required_items = required_items or [] new_data = {} for k, v in data.items(): ...
[ "def", "sift", "(", "data", ",", "required_items", "=", "None", ")", ":", "required_items", "=", "required_items", "or", "[", "]", "new_data", "=", "{", "}", "for", "k", ",", "v", "in", "data", ".", "items", "(", ")", ":", "if", "v", "[", "0", "]...
Receive a ``data`` object that will be in the form of a normalized structure (e.g. ``{0: {'a': 0}}``) and filter out keys that match the ``required_items``.
[ "Receive", "a", "data", "object", "that", "will", "be", "in", "the", "form", "of", "a", "normalized", "structure", "(", "e", ".", "g", ".", "{", "0", ":", "{", "a", ":", "0", "}}", ")", "and", "filter", "out", "keys", "that", "match", "the", "req...
train
https://github.com/alfredodeza/notario/blob/d5dc2edfcb75d9291ced3f2551f368c35dd31475/notario/utils.py#L57-L75
alfredodeza/notario
notario/utils.py
data_item
def data_item(data): """ When trying to return a meaningful error about an unexpected data item we cannot just `repr(data)` as that could show a gigantic data struture. This utility should try to get the key of the first item or the single item in the data structure. """ if isinstance(data,...
python
def data_item(data): """ When trying to return a meaningful error about an unexpected data item we cannot just `repr(data)` as that could show a gigantic data struture. This utility should try to get the key of the first item or the single item in the data structure. """ if isinstance(data,...
[ "def", "data_item", "(", "data", ")", ":", "if", "isinstance", "(", "data", ",", "ndict", ")", ":", "# OK, we have something that looks like {0: ('a', 'b')}", "# or something that is a regular dictionary", "# so try to return 'a' regardless of the length", "for", "item", "in", ...
When trying to return a meaningful error about an unexpected data item we cannot just `repr(data)` as that could show a gigantic data struture. This utility should try to get the key of the first item or the single item in the data structure.
[ "When", "trying", "to", "return", "a", "meaningful", "error", "about", "an", "unexpected", "data", "item", "we", "cannot", "just", "repr", "(", "data", ")", "as", "that", "could", "show", "a", "gigantic", "data", "struture", "." ]
train
https://github.com/alfredodeza/notario/blob/d5dc2edfcb75d9291ced3f2551f368c35dd31475/notario/utils.py#L95-L114
alfredodeza/notario
notario/utils.py
ensure
def ensure(assertion, message=None): """ Checks an assertion argument for truth-ness. Will return ``True`` or explicitly raise ``AssertionError``. This is to deal with environments using ``python -O` or ``PYTHONOPTIMIZE=``. :param assertion: some value to evaluate for truth-ness :param message:...
python
def ensure(assertion, message=None): """ Checks an assertion argument for truth-ness. Will return ``True`` or explicitly raise ``AssertionError``. This is to deal with environments using ``python -O` or ``PYTHONOPTIMIZE=``. :param assertion: some value to evaluate for truth-ness :param message:...
[ "def", "ensure", "(", "assertion", ",", "message", "=", "None", ")", ":", "message", "=", "message", "or", "assertion", "if", "not", "assertion", ":", "raise", "AssertionError", "(", "message", ")", "return", "True" ]
Checks an assertion argument for truth-ness. Will return ``True`` or explicitly raise ``AssertionError``. This is to deal with environments using ``python -O` or ``PYTHONOPTIMIZE=``. :param assertion: some value to evaluate for truth-ness :param message: optional message used for raising AssertionError
[ "Checks", "an", "assertion", "argument", "for", "truth", "-", "ness", ".", "Will", "return", "True", "or", "explicitly", "raise", "AssertionError", ".", "This", "is", "to", "deal", "with", "environments", "using", "python", "-", "O", "or", "PYTHONOPTIMIZE", ...
train
https://github.com/alfredodeza/notario/blob/d5dc2edfcb75d9291ced3f2551f368c35dd31475/notario/utils.py#L144-L158
thiagopbueno/rddl2tf
rddl2tf/fluentshape.py
TensorFluentShape.fluent_shape
def fluent_shape(self) -> Sequence[int]: '''Returns a copy of the fluent shape, ignoring batch size if in batch mode.''' return tuple(self._shape.as_list()[1:] if self._batch else self._shape.as_list()[:])
python
def fluent_shape(self) -> Sequence[int]: '''Returns a copy of the fluent shape, ignoring batch size if in batch mode.''' return tuple(self._shape.as_list()[1:] if self._batch else self._shape.as_list()[:])
[ "def", "fluent_shape", "(", "self", ")", "->", "Sequence", "[", "int", "]", ":", "return", "tuple", "(", "self", ".", "_shape", ".", "as_list", "(", ")", "[", "1", ":", "]", "if", "self", ".", "_batch", "else", "self", ".", "_shape", ".", "as_list"...
Returns a copy of the fluent shape, ignoring batch size if in batch mode.
[ "Returns", "a", "copy", "of", "the", "fluent", "shape", "ignoring", "batch", "size", "if", "in", "batch", "mode", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/fluentshape.py#L80-L82
thiagopbueno/rddl2tf
rddl2tf/fluentshape.py
TensorFluentShape.broadcast
def broadcast(cls, shape1: 'TensorFluentShape', shape2: 'TensorFluentShape') -> Tuple[Reshaping, Reshaping]: '''It broadcasts the fluent shapes if any input is in batch mode. It handles input shapes in different modes, expanding its dimensions if necessary. It outputs a ...
python
def broadcast(cls, shape1: 'TensorFluentShape', shape2: 'TensorFluentShape') -> Tuple[Reshaping, Reshaping]: '''It broadcasts the fluent shapes if any input is in batch mode. It handles input shapes in different modes, expanding its dimensions if necessary. It outputs a ...
[ "def", "broadcast", "(", "cls", ",", "shape1", ":", "'TensorFluentShape'", ",", "shape2", ":", "'TensorFluentShape'", ")", "->", "Tuple", "[", "Reshaping", ",", "Reshaping", "]", ":", "reshape_1", ",", "reshape_2", "=", "None", ",", "None", "if", "not", "(...
It broadcasts the fluent shapes if any input is in batch mode. It handles input shapes in different modes, expanding its dimensions if necessary. It outputs a tuple with new shapes. If no input shape is in batch mode, return (None, None). If an input shape does not need to be changed, r...
[ "It", "broadcasts", "the", "fluent", "shapes", "if", "any", "input", "is", "in", "batch", "mode", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/fluentshape.py#L90-L125
inodb/sufam
sufam/mpileup_parser.py
run
def run(bam, chrom, pos1, pos2, reffa, chr_reffa, parameters): """Run mpileup on given chrom and pos""" # check for chr ref is_chr_query = chrom.startswith('chr') if is_chr_query and chr_reffa is None: chr_reffa = reffa # check bam ref type bam_header = subprocess.check_output("samtool...
python
def run(bam, chrom, pos1, pos2, reffa, chr_reffa, parameters): """Run mpileup on given chrom and pos""" # check for chr ref is_chr_query = chrom.startswith('chr') if is_chr_query and chr_reffa is None: chr_reffa = reffa # check bam ref type bam_header = subprocess.check_output("samtool...
[ "def", "run", "(", "bam", ",", "chrom", ",", "pos1", ",", "pos2", ",", "reffa", ",", "chr_reffa", ",", "parameters", ")", ":", "# check for chr ref", "is_chr_query", "=", "chrom", ".", "startswith", "(", "'chr'", ")", "if", "is_chr_query", "and", "chr_reff...
Run mpileup on given chrom and pos
[ "Run", "mpileup", "on", "given", "chrom", "and", "pos" ]
train
https://github.com/inodb/sufam/blob/d4e41c5478ca9ba58be44d95106885c096c90a74/sufam/mpileup_parser.py#L97-L136
tipsi/tipsi_tools
tipsi_tools/python.py
execfile
def execfile(fname, _globals, _locals): """ Usage: execfile('path/to/file.py', globals(), locals()) """ if os.path.exists(fname): with open(fname) as f: code = compile(f.read(), os.path.basename(fname), 'exec') exec(code, _globals, _locals) return True els...
python
def execfile(fname, _globals, _locals): """ Usage: execfile('path/to/file.py', globals(), locals()) """ if os.path.exists(fname): with open(fname) as f: code = compile(f.read(), os.path.basename(fname), 'exec') exec(code, _globals, _locals) return True els...
[ "def", "execfile", "(", "fname", ",", "_globals", ",", "_locals", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "fname", ")", ":", "with", "open", "(", "fname", ")", "as", "f", ":", "code", "=", "compile", "(", "f", ".", "read", "(", "...
Usage: execfile('path/to/file.py', globals(), locals())
[ "Usage", ":", "execfile", "(", "path", "/", "to", "/", "file", ".", "py", "globals", "()", "locals", "()", ")" ]
train
https://github.com/tipsi/tipsi_tools/blob/1aba960c9890ceef2fb5e215b98b1646056ee58e/tipsi_tools/python.py#L6-L16
tipsi/tipsi_tools
tipsi_tools/python.py
auto_directory
def auto_directory(rel_name): """ if you're using py.path you make do that as: py.path.local(full_path).ensure_dir() """ dir_name = rel_path(rel_name, check=False) if not os.path.exists(dir_name): os.makedirs(dir_name, exist_ok=True) return dir_name
python
def auto_directory(rel_name): """ if you're using py.path you make do that as: py.path.local(full_path).ensure_dir() """ dir_name = rel_path(rel_name, check=False) if not os.path.exists(dir_name): os.makedirs(dir_name, exist_ok=True) return dir_name
[ "def", "auto_directory", "(", "rel_name", ")", ":", "dir_name", "=", "rel_path", "(", "rel_name", ",", "check", "=", "False", ")", "if", "not", "os", ".", "path", ".", "exists", "(", "dir_name", ")", ":", "os", ".", "makedirs", "(", "dir_name", ",", ...
if you're using py.path you make do that as: py.path.local(full_path).ensure_dir()
[ "if", "you", "re", "using", "py", ".", "path", "you", "make", "do", "that", "as", ":", "py", ".", "path", ".", "local", "(", "full_path", ")", ".", "ensure_dir", "()" ]
train
https://github.com/tipsi/tipsi_tools/blob/1aba960c9890ceef2fb5e215b98b1646056ee58e/tipsi_tools/python.py#L27-L35
craigahobbs/chisel
src/chisel/util.py
parse_iso8601_date
def parse_iso8601_date(string): """ Parse an ISO 8601 date string """ # Match ISO 8601? match = _RE_ISO8601_DATE.search(string) if not match: raise ValueError('Expected ISO 8601 date') # Extract ISO 8601 components year = int(match.group('year')) month = int(match.group('mo...
python
def parse_iso8601_date(string): """ Parse an ISO 8601 date string """ # Match ISO 8601? match = _RE_ISO8601_DATE.search(string) if not match: raise ValueError('Expected ISO 8601 date') # Extract ISO 8601 components year = int(match.group('year')) month = int(match.group('mo...
[ "def", "parse_iso8601_date", "(", "string", ")", ":", "# Match ISO 8601?", "match", "=", "_RE_ISO8601_DATE", ".", "search", "(", "string", ")", "if", "not", "match", ":", "raise", "ValueError", "(", "'Expected ISO 8601 date'", ")", "# Extract ISO 8601 components", "...
Parse an ISO 8601 date string
[ "Parse", "an", "ISO", "8601", "date", "string" ]
train
https://github.com/craigahobbs/chisel/blob/d306a9eae2ff757647c6ca1c933bc944efa5c326/src/chisel/util.py#L106-L121
craigahobbs/chisel
src/chisel/util.py
parse_iso8601_datetime
def parse_iso8601_datetime(string): """ Parse an ISO 8601 date/time string """ # Match ISO 8601? match = _RE_ISO8601_DATETIME.search(string) if not match: raise ValueError('Expected ISO 8601 date/time') # Extract ISO 8601 components year = int(match.group('year')) month = i...
python
def parse_iso8601_datetime(string): """ Parse an ISO 8601 date/time string """ # Match ISO 8601? match = _RE_ISO8601_DATETIME.search(string) if not match: raise ValueError('Expected ISO 8601 date/time') # Extract ISO 8601 components year = int(match.group('year')) month = i...
[ "def", "parse_iso8601_datetime", "(", "string", ")", ":", "# Match ISO 8601?", "match", "=", "_RE_ISO8601_DATETIME", ".", "search", "(", "string", ")", "if", "not", "match", ":", "raise", "ValueError", "(", "'Expected ISO 8601 date/time'", ")", "# Extract ISO 8601 com...
Parse an ISO 8601 date/time string
[ "Parse", "an", "ISO", "8601", "date", "/", "time", "string" ]
train
https://github.com/craigahobbs/chisel/blob/d306a9eae2ff757647c6ca1c933bc944efa5c326/src/chisel/util.py#L124-L146
craigahobbs/chisel
src/chisel/util.py
import_submodules
def import_submodules(package, parent_package=None, exclude_submodules=None): """ Generator which imports all submodules of a module, recursively, including subpackages :param package: package name (e.g 'chisel.util'); may be relative if parent_package is provided :type package: str :param parent_p...
python
def import_submodules(package, parent_package=None, exclude_submodules=None): """ Generator which imports all submodules of a module, recursively, including subpackages :param package: package name (e.g 'chisel.util'); may be relative if parent_package is provided :type package: str :param parent_p...
[ "def", "import_submodules", "(", "package", ",", "parent_package", "=", "None", ",", "exclude_submodules", "=", "None", ")", ":", "exclude_submodules_dot", "=", "[", "x", "+", "'.'", "for", "x", "in", "exclude_submodules", "]", "if", "exclude_submodules", "else"...
Generator which imports all submodules of a module, recursively, including subpackages :param package: package name (e.g 'chisel.util'); may be relative if parent_package is provided :type package: str :param parent_package: parent package name (e.g 'chisel') :type package: str :rtype: iterator of ...
[ "Generator", "which", "imports", "all", "submodules", "of", "a", "module", "recursively", "including", "subpackages" ]
train
https://github.com/craigahobbs/chisel/blob/d306a9eae2ff757647c6ca1c933bc944efa5c326/src/chisel/util.py#L149-L165
thiagopbueno/rddl2tf
rddl2tf/compiler.py
Compiler.compile_initial_state
def compile_initial_state(self, batch_size: Optional[int] = None) -> Sequence[tf.Tensor]: '''Returns a tuple of tensors representing the initial state fluents. Args: batch_size (Optional[int]): The batch size. Returns: Sequence[tf.Tensor]: A tuple of tensors. ''...
python
def compile_initial_state(self, batch_size: Optional[int] = None) -> Sequence[tf.Tensor]: '''Returns a tuple of tensors representing the initial state fluents. Args: batch_size (Optional[int]): The batch size. Returns: Sequence[tf.Tensor]: A tuple of tensors. ''...
[ "def", "compile_initial_state", "(", "self", ",", "batch_size", ":", "Optional", "[", "int", "]", "=", "None", ")", "->", "Sequence", "[", "tf", ".", "Tensor", "]", ":", "with", "self", ".", "graph", ".", "as_default", "(", ")", ":", "with", "tf", "....
Returns a tuple of tensors representing the initial state fluents. Args: batch_size (Optional[int]): The batch size. Returns: Sequence[tf.Tensor]: A tuple of tensors.
[ "Returns", "a", "tuple", "of", "tensors", "representing", "the", "initial", "state", "fluents", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/compiler.py#L90-L104
thiagopbueno/rddl2tf
rddl2tf/compiler.py
Compiler.compile_default_action
def compile_default_action(self, batch_size: Optional[int] = None) -> Sequence[tf.Tensor]: '''Returns a tuple of tensors representing the default action fluents. Args: batch_size (int): The batch size. Returns: Sequence[tf.Tensor]: A tuple of tensors. ''' ...
python
def compile_default_action(self, batch_size: Optional[int] = None) -> Sequence[tf.Tensor]: '''Returns a tuple of tensors representing the default action fluents. Args: batch_size (int): The batch size. Returns: Sequence[tf.Tensor]: A tuple of tensors. ''' ...
[ "def", "compile_default_action", "(", "self", ",", "batch_size", ":", "Optional", "[", "int", "]", "=", "None", ")", "->", "Sequence", "[", "tf", ".", "Tensor", "]", ":", "with", "self", ".", "graph", ".", "as_default", "(", ")", ":", "with", "tf", "...
Returns a tuple of tensors representing the default action fluents. Args: batch_size (int): The batch size. Returns: Sequence[tf.Tensor]: A tuple of tensors.
[ "Returns", "a", "tuple", "of", "tensors", "representing", "the", "default", "action", "fluents", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/compiler.py#L106-L120
thiagopbueno/rddl2tf
rddl2tf/compiler.py
Compiler.cpfs
def cpfs(self, state: Sequence[tf.Tensor], action: Sequence[tf.Tensor], noise: Optional[Noise] = None) -> Tuple[List[TensorFluent], List[TensorFluent]]: '''Compiles the intermediate and next state fluent CPFs given the current `state` and `action`. Args: ...
python
def cpfs(self, state: Sequence[tf.Tensor], action: Sequence[tf.Tensor], noise: Optional[Noise] = None) -> Tuple[List[TensorFluent], List[TensorFluent]]: '''Compiles the intermediate and next state fluent CPFs given the current `state` and `action`. Args: ...
[ "def", "cpfs", "(", "self", ",", "state", ":", "Sequence", "[", "tf", ".", "Tensor", "]", ",", "action", ":", "Sequence", "[", "tf", ".", "Tensor", "]", ",", "noise", ":", "Optional", "[", "Noise", "]", "=", "None", ")", "->", "Tuple", "[", "List...
Compiles the intermediate and next state fluent CPFs given the current `state` and `action`. Args: state (Sequence[tf.Tensor]): A tuple of state tensors. action (Sequence[tf.Tensor]): A tuple of action tensors. Returns: Tuple[List[TensorFluent], List[TensorF...
[ "Compiles", "the", "intermediate", "and", "next", "state", "fluent", "CPFs", "given", "the", "current", "state", "and", "action", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/compiler.py#L122-L142
thiagopbueno/rddl2tf
rddl2tf/compiler.py
Compiler.reward
def reward(self, state: Sequence[tf.Tensor], action: Sequence[tf.Tensor], next_state: Sequence[tf.Tensor]) -> tf.Tensor: '''Compiles the reward function given the current `state`, `action` and `next_state`. Args: state (Sequence[tf.Tensor...
python
def reward(self, state: Sequence[tf.Tensor], action: Sequence[tf.Tensor], next_state: Sequence[tf.Tensor]) -> tf.Tensor: '''Compiles the reward function given the current `state`, `action` and `next_state`. Args: state (Sequence[tf.Tensor...
[ "def", "reward", "(", "self", ",", "state", ":", "Sequence", "[", "tf", ".", "Tensor", "]", ",", "action", ":", "Sequence", "[", "tf", ".", "Tensor", "]", ",", "next_state", ":", "Sequence", "[", "tf", ".", "Tensor", "]", ")", "->", "tf", ".", "T...
Compiles the reward function given the current `state`, `action` and `next_state`. Args: state (Sequence[tf.Tensor]): A tuple of current state tensors. action (Sequence[tf.Tensor]): A tuple of action tensors. next_state (Sequence[tf.Tensor]): A tuple of next state te...
[ "Compiles", "the", "reward", "function", "given", "the", "current", "state", "action", "and", "next_state", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/compiler.py#L144-L163
thiagopbueno/rddl2tf
rddl2tf/compiler.py
Compiler.compile_cpfs
def compile_cpfs(self, scope: Dict[str, TensorFluent], batch_size: Optional[int] = None, noise: Optional[Noise] = None) -> Tuple[List[CPFPair], List[CPFPair]]: '''Compiles the intermediate and next state fluent CPFs given the current `state` and `ac...
python
def compile_cpfs(self, scope: Dict[str, TensorFluent], batch_size: Optional[int] = None, noise: Optional[Noise] = None) -> Tuple[List[CPFPair], List[CPFPair]]: '''Compiles the intermediate and next state fluent CPFs given the current `state` and `ac...
[ "def", "compile_cpfs", "(", "self", ",", "scope", ":", "Dict", "[", "str", ",", "TensorFluent", "]", ",", "batch_size", ":", "Optional", "[", "int", "]", "=", "None", ",", "noise", ":", "Optional", "[", "Noise", "]", "=", "None", ")", "->", "Tuple", ...
Compiles the intermediate and next state fluent CPFs given the current `state` and `action` scope. Args: scope (Dict[str, :obj:`rddl2tf.fluent.TensorFluent`]): The fluent scope for CPF evaluation. batch_size (Optional[int]): The batch size. Returns: Tuple[List[CPFPa...
[ "Compiles", "the", "intermediate", "and", "next", "state", "fluent", "CPFs", "given", "the", "current", "state", "and", "action", "scope", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/compiler.py#L165-L182
thiagopbueno/rddl2tf
rddl2tf/compiler.py
Compiler.compile_intermediate_cpfs
def compile_intermediate_cpfs(self, scope: Dict[str, TensorFluent], batch_size: Optional[int] = None, noise: Optional[Noise] = None) -> List[CPFPair]: '''Compiles the intermediate fluent CPFs given the current ...
python
def compile_intermediate_cpfs(self, scope: Dict[str, TensorFluent], batch_size: Optional[int] = None, noise: Optional[Noise] = None) -> List[CPFPair]: '''Compiles the intermediate fluent CPFs given the current ...
[ "def", "compile_intermediate_cpfs", "(", "self", ",", "scope", ":", "Dict", "[", "str", ",", "TensorFluent", "]", ",", "batch_size", ":", "Optional", "[", "int", "]", "=", "None", ",", "noise", ":", "Optional", "[", "Noise", "]", "=", "None", ")", "->"...
Compiles the intermediate fluent CPFs given the current `state` and `action` scope. Args: scope (Dict[str, :obj:`rddl2tf.fluent.TensorFluent`]): The fluent scope for CPF evaluation. batch_size (Optional[int]): The batch size. Returns: A list of intermediate fluent C...
[ "Compiles", "the", "intermediate", "fluent", "CPFs", "given", "the", "current", "state", "and", "action", "scope", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/compiler.py#L184-L212
thiagopbueno/rddl2tf
rddl2tf/compiler.py
Compiler.compile_state_cpfs
def compile_state_cpfs(self, scope: Dict[str, TensorFluent], batch_size: Optional[int] = None, noise: Optional[Noise] = None) -> List[CPFPair]: '''Compiles the next state fluent CPFs given the current `state` and `action` scope. ...
python
def compile_state_cpfs(self, scope: Dict[str, TensorFluent], batch_size: Optional[int] = None, noise: Optional[Noise] = None) -> List[CPFPair]: '''Compiles the next state fluent CPFs given the current `state` and `action` scope. ...
[ "def", "compile_state_cpfs", "(", "self", ",", "scope", ":", "Dict", "[", "str", ",", "TensorFluent", "]", ",", "batch_size", ":", "Optional", "[", "int", "]", "=", "None", ",", "noise", ":", "Optional", "[", "Noise", "]", "=", "None", ")", "->", "Li...
Compiles the next state fluent CPFs given the current `state` and `action` scope. Args: scope (Dict[str, :obj:`rddl2tf.fluent.TensorFluent`]): The fluent scope for CPF evaluation. batch_size (Optional[int]): The batch size. Returns: A list of state fluent CPFs compi...
[ "Compiles", "the", "next", "state", "fluent", "CPFs", "given", "the", "current", "state", "and", "action", "scope", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/compiler.py#L214-L244
thiagopbueno/rddl2tf
rddl2tf/compiler.py
Compiler.compile_reward
def compile_reward(self, scope: Dict[str, TensorFluent]) -> TensorFluent: '''Compiles the reward function given the fluent `scope`. Args: scope (Dict[str, :obj:`rddl2tf.fluent.TensorFluent`]): The fluent scope for reward evaluation. Returns: A :obj:`rddl2tf.fluent.Tenso...
python
def compile_reward(self, scope: Dict[str, TensorFluent]) -> TensorFluent: '''Compiles the reward function given the fluent `scope`. Args: scope (Dict[str, :obj:`rddl2tf.fluent.TensorFluent`]): The fluent scope for reward evaluation. Returns: A :obj:`rddl2tf.fluent.Tenso...
[ "def", "compile_reward", "(", "self", ",", "scope", ":", "Dict", "[", "str", ",", "TensorFluent", "]", ")", "->", "TensorFluent", ":", "reward_expr", "=", "self", ".", "rddl", ".", "domain", ".", "reward", "with", "self", ".", "graph", ".", "as_default",...
Compiles the reward function given the fluent `scope`. Args: scope (Dict[str, :obj:`rddl2tf.fluent.TensorFluent`]): The fluent scope for reward evaluation. Returns: A :obj:`rddl2tf.fluent.TensorFluent` representing the reward function.
[ "Compiles", "the", "reward", "function", "given", "the", "fluent", "scope", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/compiler.py#L246-L258
thiagopbueno/rddl2tf
rddl2tf/compiler.py
Compiler.compile_state_action_constraints
def compile_state_action_constraints(self, state: Sequence[tf.Tensor], action: Sequence[tf.Tensor]) -> List[TensorFluent]: '''Compiles the state-action constraints given current `state` and `action` fluents. Args: state (Sequence[tf.Tensor]): The current state fluent...
python
def compile_state_action_constraints(self, state: Sequence[tf.Tensor], action: Sequence[tf.Tensor]) -> List[TensorFluent]: '''Compiles the state-action constraints given current `state` and `action` fluents. Args: state (Sequence[tf.Tensor]): The current state fluent...
[ "def", "compile_state_action_constraints", "(", "self", ",", "state", ":", "Sequence", "[", "tf", ".", "Tensor", "]", ",", "action", ":", "Sequence", "[", "tf", ".", "Tensor", "]", ")", "->", "List", "[", "TensorFluent", "]", ":", "scope", "=", "self", ...
Compiles the state-action constraints given current `state` and `action` fluents. Args: state (Sequence[tf.Tensor]): The current state fluents. action (Sequence[tf.Tensor]): The action fluents. Returns: A list of :obj:`rddl2tf.fluent.TensorFluent`.
[ "Compiles", "the", "state", "-", "action", "constraints", "given", "current", "state", "and", "action", "fluents", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/compiler.py#L260-L279
thiagopbueno/rddl2tf
rddl2tf/compiler.py
Compiler.compile_action_preconditions
def compile_action_preconditions(self, state: Sequence[tf.Tensor], action: Sequence[tf.Tensor]) -> List[TensorFluent]: '''Compiles the action preconditions given current `state` and `action` fluents. Args: state (Sequence[tf.Tensor]): The current state fluents. ...
python
def compile_action_preconditions(self, state: Sequence[tf.Tensor], action: Sequence[tf.Tensor]) -> List[TensorFluent]: '''Compiles the action preconditions given current `state` and `action` fluents. Args: state (Sequence[tf.Tensor]): The current state fluents. ...
[ "def", "compile_action_preconditions", "(", "self", ",", "state", ":", "Sequence", "[", "tf", ".", "Tensor", "]", ",", "action", ":", "Sequence", "[", "tf", ".", "Tensor", "]", ")", "->", "List", "[", "TensorFluent", "]", ":", "scope", "=", "self", "."...
Compiles the action preconditions given current `state` and `action` fluents. Args: state (Sequence[tf.Tensor]): The current state fluents. action (Sequence[tf.Tensor]): The action fluents. Returns: A list of :obj:`rddl2tf.fluent.TensorFluent`.
[ "Compiles", "the", "action", "preconditions", "given", "current", "state", "and", "action", "fluents", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/compiler.py#L281-L300
thiagopbueno/rddl2tf
rddl2tf/compiler.py
Compiler.compile_state_invariants
def compile_state_invariants(self, state: Sequence[tf.Tensor]) -> List[TensorFluent]: '''Compiles the state invarints given current `state` fluents. Args: state (Sequence[tf.Tensor]): The current state fluents. Returns: A list of :obj:`rddl2tf.fluent.TensorF...
python
def compile_state_invariants(self, state: Sequence[tf.Tensor]) -> List[TensorFluent]: '''Compiles the state invarints given current `state` fluents. Args: state (Sequence[tf.Tensor]): The current state fluents. Returns: A list of :obj:`rddl2tf.fluent.TensorF...
[ "def", "compile_state_invariants", "(", "self", ",", "state", ":", "Sequence", "[", "tf", ".", "Tensor", "]", ")", "->", "List", "[", "TensorFluent", "]", ":", "scope", "=", "self", ".", "state_invariant_scope", "(", "state", ")", "invariants", "=", "[", ...
Compiles the state invarints given current `state` fluents. Args: state (Sequence[tf.Tensor]): The current state fluents. Returns: A list of :obj:`rddl2tf.fluent.TensorFluent`.
[ "Compiles", "the", "state", "invarints", "given", "current", "state", "fluents", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/compiler.py#L302-L319