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/compiler.py
Compiler.compile_action_preconditions_checking
def compile_action_preconditions_checking(self, state: Sequence[tf.Tensor], action: Sequence[tf.Tensor]) -> tf.Tensor: '''Combines the action preconditions into an applicability checking op. Args: state (Sequence[tf.Tensor]): The current state fluents. ac...
python
def compile_action_preconditions_checking(self, state: Sequence[tf.Tensor], action: Sequence[tf.Tensor]) -> tf.Tensor: '''Combines the action preconditions into an applicability checking op. Args: state (Sequence[tf.Tensor]): The current state fluents. ac...
[ "def", "compile_action_preconditions_checking", "(", "self", ",", "state", ":", "Sequence", "[", "tf", ".", "Tensor", "]", ",", "action", ":", "Sequence", "[", "tf", ".", "Tensor", "]", ")", "->", "tf", ".", "Tensor", ":", "with", "self", ".", "graph", ...
Combines the action preconditions into an applicability checking op. Args: state (Sequence[tf.Tensor]): The current state fluents. action (Sequence[tf.Tensor]): The action fluents. Returns: A boolean tensor for checking if `action` is application in `state`.
[ "Combines", "the", "action", "preconditions", "into", "an", "applicability", "checking", "op", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/compiler.py#L321-L338
thiagopbueno/rddl2tf
rddl2tf/compiler.py
Compiler.compile_action_bound_constraints
def compile_action_bound_constraints(self, state: Sequence[tf.Tensor]) -> Dict[str, Bounds]: '''Compiles all actions bounds for the given `state`. Args: state (Sequence[tf.Tensor]): The current state fluents. Returns: A mapping from action names to a pair of...
python
def compile_action_bound_constraints(self, state: Sequence[tf.Tensor]) -> Dict[str, Bounds]: '''Compiles all actions bounds for the given `state`. Args: state (Sequence[tf.Tensor]): The current state fluents. Returns: A mapping from action names to a pair of...
[ "def", "compile_action_bound_constraints", "(", "self", ",", "state", ":", "Sequence", "[", "tf", ".", "Tensor", "]", ")", "->", "Dict", "[", "str", ",", "Bounds", "]", ":", "scope", "=", "self", ".", "action_precondition_scope", "(", "state", ")", "lower_...
Compiles all actions bounds for the given `state`. Args: state (Sequence[tf.Tensor]): The current state fluents. Returns: A mapping from action names to a pair of :obj:`rddl2tf.fluent.TensorFluent` representing its lower and upper bounds.
[ "Compiles", "all", "actions", "bounds", "for", "the", "given", "state", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/compiler.py#L340-L377
thiagopbueno/rddl2tf
rddl2tf/compiler.py
Compiler.non_fluents_scope
def non_fluents_scope(self) -> Dict[str, TensorFluent]: '''Returns a partial scope with non-fluents. Returns: A mapping from non-fluent names to :obj:`rddl2tf.fluent.TensorFluent`. ''' if self.__dict__.get('non_fluents') is None: self._initialize_non_fluents() ...
python
def non_fluents_scope(self) -> Dict[str, TensorFluent]: '''Returns a partial scope with non-fluents. Returns: A mapping from non-fluent names to :obj:`rddl2tf.fluent.TensorFluent`. ''' if self.__dict__.get('non_fluents') is None: self._initialize_non_fluents() ...
[ "def", "non_fluents_scope", "(", "self", ")", "->", "Dict", "[", "str", ",", "TensorFluent", "]", ":", "if", "self", ".", "__dict__", ".", "get", "(", "'non_fluents'", ")", "is", "None", ":", "self", ".", "_initialize_non_fluents", "(", ")", "return", "d...
Returns a partial scope with non-fluents. Returns: A mapping from non-fluent names to :obj:`rddl2tf.fluent.TensorFluent`.
[ "Returns", "a", "partial", "scope", "with", "non", "-", "fluents", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/compiler.py#L379-L387
thiagopbueno/rddl2tf
rddl2tf/compiler.py
Compiler.state_scope
def state_scope(self, state_fluents: Sequence[tf.Tensor]) -> Dict[str, TensorFluent]: '''Returns a partial scope with current state-fluents. Args: state_fluents (Sequence[tf.Tensor]): The current state fluents. Returns: A mapping from state fluent names to :obj:`rddl2tf...
python
def state_scope(self, state_fluents: Sequence[tf.Tensor]) -> Dict[str, TensorFluent]: '''Returns a partial scope with current state-fluents. Args: state_fluents (Sequence[tf.Tensor]): The current state fluents. Returns: A mapping from state fluent names to :obj:`rddl2tf...
[ "def", "state_scope", "(", "self", ",", "state_fluents", ":", "Sequence", "[", "tf", ".", "Tensor", "]", ")", "->", "Dict", "[", "str", ",", "TensorFluent", "]", ":", "return", "dict", "(", "zip", "(", "self", ".", "rddl", ".", "domain", ".", "state_...
Returns a partial scope with current state-fluents. Args: state_fluents (Sequence[tf.Tensor]): The current state fluents. Returns: A mapping from state fluent names to :obj:`rddl2tf.fluent.TensorFluent`.
[ "Returns", "a", "partial", "scope", "with", "current", "state", "-", "fluents", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/compiler.py#L389-L398
thiagopbueno/rddl2tf
rddl2tf/compiler.py
Compiler.action_scope
def action_scope(self, action_fluents: Sequence[tf.Tensor]) -> Dict[str, TensorFluent]: '''Returns a partial scope with current action-fluents. Args: action_fluents (Sequence[tf.Tensor]): The action fluents. Returns: A mapping from action fluent names to :obj:`rddl2tf.f...
python
def action_scope(self, action_fluents: Sequence[tf.Tensor]) -> Dict[str, TensorFluent]: '''Returns a partial scope with current action-fluents. Args: action_fluents (Sequence[tf.Tensor]): The action fluents. Returns: A mapping from action fluent names to :obj:`rddl2tf.f...
[ "def", "action_scope", "(", "self", ",", "action_fluents", ":", "Sequence", "[", "tf", ".", "Tensor", "]", ")", "->", "Dict", "[", "str", ",", "TensorFluent", "]", ":", "return", "dict", "(", "zip", "(", "self", ".", "rddl", ".", "domain", ".", "acti...
Returns a partial scope with current action-fluents. Args: action_fluents (Sequence[tf.Tensor]): The action fluents. Returns: A mapping from action fluent names to :obj:`rddl2tf.fluent.TensorFluent`.
[ "Returns", "a", "partial", "scope", "with", "current", "action", "-", "fluents", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/compiler.py#L400-L409
thiagopbueno/rddl2tf
rddl2tf/compiler.py
Compiler.next_state_scope
def next_state_scope(self, next_state_fluents: Sequence[tf.Tensor]) -> Dict[str, TensorFluent]: '''Returns a partial scope with current next state-fluents. Args: next_state_fluents (Sequence[tf.Tensor]): The next state fluents. Returns: A mapping from next state fluent ...
python
def next_state_scope(self, next_state_fluents: Sequence[tf.Tensor]) -> Dict[str, TensorFluent]: '''Returns a partial scope with current next state-fluents. Args: next_state_fluents (Sequence[tf.Tensor]): The next state fluents. Returns: A mapping from next state fluent ...
[ "def", "next_state_scope", "(", "self", ",", "next_state_fluents", ":", "Sequence", "[", "tf", ".", "Tensor", "]", ")", "->", "Dict", "[", "str", ",", "TensorFluent", "]", ":", "return", "dict", "(", "zip", "(", "self", ".", "rddl", ".", "domain", ".",...
Returns a partial scope with current next state-fluents. Args: next_state_fluents (Sequence[tf.Tensor]): The next state fluents. Returns: A mapping from next state fluent names to :obj:`rddl2tf.fluent.TensorFluent`.
[ "Returns", "a", "partial", "scope", "with", "current", "next", "state", "-", "fluents", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/compiler.py#L411-L420
thiagopbueno/rddl2tf
rddl2tf/compiler.py
Compiler.transition_scope
def transition_scope(self, state: Sequence[tf.Tensor], action: Sequence[tf.Tensor]) -> Dict[str, TensorFluent]: '''Returns the complete transition fluent scope for the current `state` and `action` fluents. Args: state (Sequence[tf.Tensor]): The current state fluents....
python
def transition_scope(self, state: Sequence[tf.Tensor], action: Sequence[tf.Tensor]) -> Dict[str, TensorFluent]: '''Returns the complete transition fluent scope for the current `state` and `action` fluents. Args: state (Sequence[tf.Tensor]): The current state fluents....
[ "def", "transition_scope", "(", "self", ",", "state", ":", "Sequence", "[", "tf", ".", "Tensor", "]", ",", "action", ":", "Sequence", "[", "tf", ".", "Tensor", "]", ")", "->", "Dict", "[", "str", ",", "TensorFluent", "]", ":", "scope", "=", "{", "}...
Returns the complete transition fluent scope for the current `state` and `action` fluents. Args: state (Sequence[tf.Tensor]): The current state fluents. action (Sequence[tf.Tensor]): The action fluents. Returns: A mapping from fluent names to :obj:`rddl2tf.f...
[ "Returns", "the", "complete", "transition", "fluent", "scope", "for", "the", "current", "state", "and", "action", "fluents", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/compiler.py#L422-L439
thiagopbueno/rddl2tf
rddl2tf/compiler.py
Compiler.reward_scope
def reward_scope(self, state: Sequence[tf.Tensor], action: Sequence[tf.Tensor], next_state: Sequence[tf.Tensor]) -> Dict[str, TensorFluent]: '''Returns the complete reward fluent scope for the current `state`, `action` fluents, and `next_sta...
python
def reward_scope(self, state: Sequence[tf.Tensor], action: Sequence[tf.Tensor], next_state: Sequence[tf.Tensor]) -> Dict[str, TensorFluent]: '''Returns the complete reward fluent scope for the current `state`, `action` fluents, and `next_sta...
[ "def", "reward_scope", "(", "self", ",", "state", ":", "Sequence", "[", "tf", ".", "Tensor", "]", ",", "action", ":", "Sequence", "[", "tf", ".", "Tensor", "]", ",", "next_state", ":", "Sequence", "[", "tf", ".", "Tensor", "]", ")", "->", "Dict", "...
Returns the complete reward fluent scope for the current `state`, `action` fluents, and `next_state` fluents. Args: state (Sequence[tf.Tensor]): The current state fluents. action (Sequence[tf.Tensor]): The action fluents. next_state (Sequence[tf.Tensor]): The next st...
[ "Returns", "the", "complete", "reward", "fluent", "scope", "for", "the", "current", "state", "action", "fluents", "and", "next_state", "fluents", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/compiler.py#L441-L461
thiagopbueno/rddl2tf
rddl2tf/compiler.py
Compiler.state_invariant_scope
def state_invariant_scope(self, state: Sequence[tf.Tensor]): '''Returns the state invariant fluent scope for the current `state`. Args: state (Sequence[tf.Tensor]): The current state fluents. Returns: A mapping from fluent names to :obj:`rddl2tf.fluent.TensorFluent`. ...
python
def state_invariant_scope(self, state: Sequence[tf.Tensor]): '''Returns the state invariant fluent scope for the current `state`. Args: state (Sequence[tf.Tensor]): The current state fluents. Returns: A mapping from fluent names to :obj:`rddl2tf.fluent.TensorFluent`. ...
[ "def", "state_invariant_scope", "(", "self", ",", "state", ":", "Sequence", "[", "tf", ".", "Tensor", "]", ")", ":", "scope", "=", "{", "}", "scope", ".", "update", "(", "self", ".", "non_fluents_scope", "(", ")", ")", "scope", ".", "update", "(", "s...
Returns the state invariant fluent scope for the current `state`. Args: state (Sequence[tf.Tensor]): The current state fluents. Returns: A mapping from fluent names to :obj:`rddl2tf.fluent.TensorFluent`.
[ "Returns", "the", "state", "invariant", "fluent", "scope", "for", "the", "current", "state", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/compiler.py#L463-L475
thiagopbueno/rddl2tf
rddl2tf/compiler.py
Compiler._initialize_pvariables
def _initialize_pvariables(self, pvariables: Dict[str, PVariable], ordering: List[str], initializer: Optional[InitializerList] = None) -> List[Tuple[str, TensorFluent]]: '''Instantiates `pvariables` given an initialization list and returns a list of TensorFluents in t...
python
def _initialize_pvariables(self, pvariables: Dict[str, PVariable], ordering: List[str], initializer: Optional[InitializerList] = None) -> List[Tuple[str, TensorFluent]]: '''Instantiates `pvariables` given an initialization list and returns a list of TensorFluents in t...
[ "def", "_initialize_pvariables", "(", "self", ",", "pvariables", ":", "Dict", "[", "str", ",", "PVariable", "]", ",", "ordering", ":", "List", "[", "str", "]", ",", "initializer", ":", "Optional", "[", "InitializerList", "]", "=", "None", ")", "->", "Lis...
Instantiates `pvariables` given an initialization list and returns a list of TensorFluents in the given `ordering`. Returns: List[Tuple[str, TensorFluent]]: A list of pairs of fluent name and fluent tensor.
[ "Instantiates", "pvariables", "given", "an", "initialization", "list", "and", "returns", "a", "list", "of", "TensorFluents", "in", "the", "given", "ordering", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/compiler.py#L497-L541
thiagopbueno/rddl2tf
rddl2tf/compiler.py
Compiler._initialize_non_fluents
def _initialize_non_fluents(self): '''Returns the non-fluents instantiated.''' non_fluents = self.rddl.domain.non_fluents initializer = self.rddl.non_fluents.init_non_fluent self.non_fluents = self._initialize_pvariables( non_fluents, self.rddl.domain.non_fluent_o...
python
def _initialize_non_fluents(self): '''Returns the non-fluents instantiated.''' non_fluents = self.rddl.domain.non_fluents initializer = self.rddl.non_fluents.init_non_fluent self.non_fluents = self._initialize_pvariables( non_fluents, self.rddl.domain.non_fluent_o...
[ "def", "_initialize_non_fluents", "(", "self", ")", ":", "non_fluents", "=", "self", ".", "rddl", ".", "domain", ".", "non_fluents", "initializer", "=", "self", ".", "rddl", ".", "non_fluents", ".", "init_non_fluent", "self", ".", "non_fluents", "=", "self", ...
Returns the non-fluents instantiated.
[ "Returns", "the", "non", "-", "fluents", "instantiated", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/compiler.py#L543-L551
thiagopbueno/rddl2tf
rddl2tf/compiler.py
Compiler._initialize_initial_state_fluents
def _initialize_initial_state_fluents(self): '''Returns the initial state-fluents instantiated.''' state_fluents = self.rddl.domain.state_fluents initializer = self.rddl.instance.init_state self.initial_state_fluents = self._initialize_pvariables( state_fluents, s...
python
def _initialize_initial_state_fluents(self): '''Returns the initial state-fluents instantiated.''' state_fluents = self.rddl.domain.state_fluents initializer = self.rddl.instance.init_state self.initial_state_fluents = self._initialize_pvariables( state_fluents, s...
[ "def", "_initialize_initial_state_fluents", "(", "self", ")", ":", "state_fluents", "=", "self", ".", "rddl", ".", "domain", ".", "state_fluents", "initializer", "=", "self", ".", "rddl", ".", "instance", ".", "init_state", "self", ".", "initial_state_fluents", ...
Returns the initial state-fluents instantiated.
[ "Returns", "the", "initial", "state", "-", "fluents", "instantiated", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/compiler.py#L553-L561
thiagopbueno/rddl2tf
rddl2tf/compiler.py
Compiler._initialize_default_action_fluents
def _initialize_default_action_fluents(self): '''Returns the default action-fluents instantiated.''' action_fluents = self.rddl.domain.action_fluents self.default_action_fluents = self._initialize_pvariables( action_fluents, self.rddl.domain.action_fluent_ordering) ...
python
def _initialize_default_action_fluents(self): '''Returns the default action-fluents instantiated.''' action_fluents = self.rddl.domain.action_fluents self.default_action_fluents = self._initialize_pvariables( action_fluents, self.rddl.domain.action_fluent_ordering) ...
[ "def", "_initialize_default_action_fluents", "(", "self", ")", ":", "action_fluents", "=", "self", ".", "rddl", ".", "domain", ".", "action_fluents", "self", ".", "default_action_fluents", "=", "self", ".", "_initialize_pvariables", "(", "action_fluents", ",", "self...
Returns the default action-fluents instantiated.
[ "Returns", "the", "default", "action", "-", "fluents", "instantiated", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/compiler.py#L563-L569
thiagopbueno/rddl2tf
rddl2tf/compiler.py
Compiler._compile_batch_fluents
def _compile_batch_fluents(self, fluents: List[Tuple[str, TensorFluent]], batch_size: int) -> Sequence[tf.Tensor]: '''Compiles `fluents` into tensors with given `batch_size`. Returns: Sequence[tf.Tensor]: A tuple of tensors with first dimension correspond...
python
def _compile_batch_fluents(self, fluents: List[Tuple[str, TensorFluent]], batch_size: int) -> Sequence[tf.Tensor]: '''Compiles `fluents` into tensors with given `batch_size`. Returns: Sequence[tf.Tensor]: A tuple of tensors with first dimension correspond...
[ "def", "_compile_batch_fluents", "(", "self", ",", "fluents", ":", "List", "[", "Tuple", "[", "str", ",", "TensorFluent", "]", "]", ",", "batch_size", ":", "int", ")", "->", "Sequence", "[", "tf", ".", "Tensor", "]", ":", "batch_fluents", "=", "[", "]"...
Compiles `fluents` into tensors with given `batch_size`. Returns: Sequence[tf.Tensor]: A tuple of tensors with first dimension corresponding to the batch size.
[ "Compiles", "fluents", "into", "tensors", "with", "given", "batch_size", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/compiler.py#L571-L587
thiagopbueno/rddl2tf
rddl2tf/compiler.py
Compiler._compile_expression
def _compile_expression(self, expr: Expression, scope: Dict[str, TensorFluent], batch_size: Optional[int] = None, noise: Optional[List[tf.Tensor]] = None) -> TensorFluent: '''Compile the expression `e...
python
def _compile_expression(self, expr: Expression, scope: Dict[str, TensorFluent], batch_size: Optional[int] = None, noise: Optional[List[tf.Tensor]] = None) -> TensorFluent: '''Compile the expression `e...
[ "def", "_compile_expression", "(", "self", ",", "expr", ":", "Expression", ",", "scope", ":", "Dict", "[", "str", ",", "TensorFluent", "]", ",", "batch_size", ":", "Optional", "[", "int", "]", "=", "None", ",", "noise", ":", "Optional", "[", "List", "[...
Compile the expression `expr` into a TensorFluent in the given `scope` with optional batch size. Args: expr (:obj:`rddl2tf.expr.Expression`): A RDDL expression. scope (Dict[str, :obj:`rddl2tf.fluent.TensorFluent`]): A fluent scope. batch_size (Optional[size]): The ba...
[ "Compile", "the", "expression", "expr", "into", "a", "TensorFluent", "in", "the", "given", "scope", "with", "optional", "batch", "size", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/compiler.py#L589-L623
thiagopbueno/rddl2tf
rddl2tf/compiler.py
Compiler._compile_constant_expression
def _compile_constant_expression(self, expr: Expression, scope: Dict[str, TensorFluent], batch_size: Optional[int] = None, noise: Optional[List[tf.Tensor]] = None) -> Tenso...
python
def _compile_constant_expression(self, expr: Expression, scope: Dict[str, TensorFluent], batch_size: Optional[int] = None, noise: Optional[List[tf.Tensor]] = None) -> Tenso...
[ "def", "_compile_constant_expression", "(", "self", ",", "expr", ":", "Expression", ",", "scope", ":", "Dict", "[", "str", ",", "TensorFluent", "]", ",", "batch_size", ":", "Optional", "[", "int", "]", "=", "None", ",", "noise", ":", "Optional", "[", "Li...
Compile a constant expression `expr` into a TensorFluent in the given `scope` with optional batch size. Args: expr (:obj:`rddl2tf.expr.Expression`): A RDDL constant expression. scope (Dict[str, :obj:`rddl2tf.fluent.TensorFluent`]): A fluent scope. batch_size (Optiona...
[ "Compile", "a", "constant", "expression", "expr", "into", "a", "TensorFluent", "in", "the", "given", "scope", "with", "optional", "batch", "size", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/compiler.py#L625-L645
thiagopbueno/rddl2tf
rddl2tf/compiler.py
Compiler._compile_pvariable_expression
def _compile_pvariable_expression(self, expr: Expression, scope: Dict[str, TensorFluent], batch_size: Optional[int] = None, noise: Optional[List[tf.Tensor]] = None) -> ...
python
def _compile_pvariable_expression(self, expr: Expression, scope: Dict[str, TensorFluent], batch_size: Optional[int] = None, noise: Optional[List[tf.Tensor]] = None) -> ...
[ "def", "_compile_pvariable_expression", "(", "self", ",", "expr", ":", "Expression", ",", "scope", ":", "Dict", "[", "str", ",", "TensorFluent", "]", ",", "batch_size", ":", "Optional", "[", "int", "]", "=", "None", ",", "noise", ":", "Optional", "[", "L...
Compile a pvariable expression `expr` into a TensorFluent in the given `scope` with optional batch size. Args: expr (:obj:`rddl2tf.expr.Expression`): A RDDL pvariable expression. scope (Dict[str, :obj:`rddl2tf.fluent.TensorFluent`]): A fluent scope. batch_size (Optio...
[ "Compile", "a", "pvariable", "expression", "expr", "into", "a", "TensorFluent", "in", "the", "given", "scope", "with", "optional", "batch", "size", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/compiler.py#L647-L676
thiagopbueno/rddl2tf
rddl2tf/compiler.py
Compiler._compile_random_variable_expression
def _compile_random_variable_expression(self, expr: Expression, scope: Dict[str, TensorFluent], batch_size: Optional[int] = None, noise: Optiona...
python
def _compile_random_variable_expression(self, expr: Expression, scope: Dict[str, TensorFluent], batch_size: Optional[int] = None, noise: Optiona...
[ "def", "_compile_random_variable_expression", "(", "self", ",", "expr", ":", "Expression", ",", "scope", ":", "Dict", "[", "str", ",", "TensorFluent", "]", ",", "batch_size", ":", "Optional", "[", "int", "]", "=", "None", ",", "noise", ":", "Optional", "["...
Compile a random variable expression `expr` into a TensorFluent in the given `scope` with optional batch size. If `reparam` tensor is given, then it conditionally stops gradient backpropagation at the batch level where `reparam` is False. Args: expr (:obj:`rddl2tf.expr.Expr...
[ "Compile", "a", "random", "variable", "expression", "expr", "into", "a", "TensorFluent", "in", "the", "given", "scope", "with", "optional", "batch", "size", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/compiler.py#L678-L734
thiagopbueno/rddl2tf
rddl2tf/compiler.py
Compiler._compile_arithmetic_expression
def _compile_arithmetic_expression(self, expr: Expression, scope: Dict[str, TensorFluent], batch_size: Optional[int] = None, noise: Optional[List[tf.Tensor]] = None...
python
def _compile_arithmetic_expression(self, expr: Expression, scope: Dict[str, TensorFluent], batch_size: Optional[int] = None, noise: Optional[List[tf.Tensor]] = None...
[ "def", "_compile_arithmetic_expression", "(", "self", ",", "expr", ":", "Expression", ",", "scope", ":", "Dict", "[", "str", ",", "TensorFluent", "]", ",", "batch_size", ":", "Optional", "[", "int", "]", "=", "None", ",", "noise", ":", "Optional", "[", "...
Compile an arithmetic expression `expr` into a TensorFluent in the given `scope` with optional batch size. Args: expr (:obj:`rddl2tf.expr.Expression`): A RDDL arithmetic expression. scope (Dict[str, :obj:`rddl2tf.fluent.TensorFluent`]): A fluent scope. batch_size (Op...
[ "Compile", "an", "arithmetic", "expression", "expr", "into", "a", "TensorFluent", "in", "the", "given", "scope", "with", "optional", "batch", "size", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/compiler.py#L736-L784
thiagopbueno/rddl2tf
rddl2tf/compiler.py
Compiler._compile_function_expression
def _compile_function_expression(self, expr: Expression, scope: Dict[str, TensorFluent], batch_size: Optional[int] = None, noise: Optional[List[tf.Tensor]] = None) -> Tenso...
python
def _compile_function_expression(self, expr: Expression, scope: Dict[str, TensorFluent], batch_size: Optional[int] = None, noise: Optional[List[tf.Tensor]] = None) -> Tenso...
[ "def", "_compile_function_expression", "(", "self", ",", "expr", ":", "Expression", ",", "scope", ":", "Dict", "[", "str", ",", "TensorFluent", "]", ",", "batch_size", ":", "Optional", "[", "int", "]", "=", "None", ",", "noise", ":", "Optional", "[", "Li...
Compile a function expression `expr` into a TensorFluent in the given `scope` with optional batch size. Args: expr (:obj:`rddl2tf.expr.Expression`): A RDDL function expression. scope (Dict[str, :obj:`rddl2tf.fluent.TensorFluent`]): A fluent scope. batch_size (Optiona...
[ "Compile", "a", "function", "expression", "expr", "into", "a", "TensorFluent", "in", "the", "given", "scope", "with", "optional", "batch", "size", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/compiler.py#L874-L936
thiagopbueno/rddl2tf
rddl2tf/compiler.py
Compiler._compile_control_flow_expression
def _compile_control_flow_expression(self, expr: Expression, scope: Dict[str, TensorFluent], batch_size: Optional[int] = None, noise: Optional[List[tf.Tenso...
python
def _compile_control_flow_expression(self, expr: Expression, scope: Dict[str, TensorFluent], batch_size: Optional[int] = None, noise: Optional[List[tf.Tenso...
[ "def", "_compile_control_flow_expression", "(", "self", ",", "expr", ":", "Expression", ",", "scope", ":", "Dict", "[", "str", ",", "TensorFluent", "]", ",", "batch_size", ":", "Optional", "[", "int", "]", "=", "None", ",", "noise", ":", "Optional", "[", ...
Compile a control flow expression `expr` into a TensorFluent in the given `scope` with optional batch size. Args: expr (:obj:`rddl2tf.expr.Expression`): A RDDL control flow expression. scope (Dict[str, :obj:`rddl2tf.fluent.TensorFluent`]): A fluent scope. batch_size ...
[ "Compile", "a", "control", "flow", "expression", "expr", "into", "a", "TensorFluent", "in", "the", "given", "scope", "with", "optional", "batch", "size", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/compiler.py#L938-L963
thiagopbueno/rddl2tf
rddl2tf/compiler.py
Compiler._compile_aggregation_expression
def _compile_aggregation_expression(self, expr: Expression, scope: Dict[str, TensorFluent], batch_size: Optional[int] = None, noise: Optional[List[tf.Tensor]] =...
python
def _compile_aggregation_expression(self, expr: Expression, scope: Dict[str, TensorFluent], batch_size: Optional[int] = None, noise: Optional[List[tf.Tensor]] =...
[ "def", "_compile_aggregation_expression", "(", "self", ",", "expr", ":", "Expression", ",", "scope", ":", "Dict", "[", "str", ",", "TensorFluent", "]", ",", "batch_size", ":", "Optional", "[", "int", "]", "=", "None", ",", "noise", ":", "Optional", "[", ...
Compile an aggregation expression `expr` into a TensorFluent in the given `scope` with optional batch size. Args: expr (:obj:`rddl2tf.expr.Expression`): A RDDL aggregation expression. scope (Dict[str, :obj:`rddl2tf.fluent.TensorFluent`]): A fluent scope. batch_size (...
[ "Compile", "an", "aggregation", "expression", "expr", "into", "a", "TensorFluent", "in", "the", "given", "scope", "with", "optional", "batch", "size", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/compiler.py#L965-L1006
yymao/easyquery
easyquery.py
Query.mask
def mask(self, table): """ Use the current Query object to count the number of entries in `table` that satisfy `queries`. Parameters ---------- table : NumPy structured array, astropy Table, etc. Returns ------- mask : numpy bool array ""...
python
def mask(self, table): """ Use the current Query object to count the number of entries in `table` that satisfy `queries`. Parameters ---------- table : NumPy structured array, astropy Table, etc. Returns ------- mask : numpy bool array ""...
[ "def", "mask", "(", "self", ",", "table", ")", ":", "if", "self", ".", "_operator", "is", "None", ":", "if", "self", ".", "_operands", "is", "None", ":", "return", "np", ".", "ones", "(", "self", ".", "_get_table_len", "(", "table", ")", ",", "dtyp...
Use the current Query object to count the number of entries in `table` that satisfy `queries`. Parameters ---------- table : NumPy structured array, astropy Table, etc. Returns ------- mask : numpy bool array
[ "Use", "the", "current", "Query", "object", "to", "count", "the", "number", "of", "entries", "in", "table", "that", "satisfy", "queries", "." ]
train
https://github.com/yymao/easyquery/blob/cd94c100e26f59042cd9ffb26d0a7b61cdcd457d/easyquery.py#L201-L234
yymao/easyquery
easyquery.py
Query.filter
def filter(self, table, column_slice=None): """ Use the current Query object to create a mask (a boolean array) for `table`. Parameters ---------- table : NumPy structured array, astropy Table, etc. column_slice : Column to return. Default is None (return all col...
python
def filter(self, table, column_slice=None): """ Use the current Query object to create a mask (a boolean array) for `table`. Parameters ---------- table : NumPy structured array, astropy Table, etc. column_slice : Column to return. Default is None (return all col...
[ "def", "filter", "(", "self", ",", "table", ",", "column_slice", "=", "None", ")", ":", "if", "self", ".", "_operator", "is", "None", "and", "self", ".", "_operands", "is", "None", ":", "return", "table", "if", "column_slice", "is", "None", "else", "se...
Use the current Query object to create a mask (a boolean array) for `table`. Parameters ---------- table : NumPy structured array, astropy Table, etc. column_slice : Column to return. Default is None (return all columns). Returns ------- table : filtered...
[ "Use", "the", "current", "Query", "object", "to", "create", "a", "mask", "(", "a", "boolean", "array", ")", "for", "table", "." ]
train
https://github.com/yymao/easyquery/blob/cd94c100e26f59042cd9ffb26d0a7b61cdcd457d/easyquery.py#L237-L262
yymao/easyquery
easyquery.py
Query.count
def count(self, table): """ Use the current Query object to count the number of entries in `table` that satisfy `queries`. Parameters ---------- table : NumPy structured array, astropy Table, etc. Returns ------- count : int """ i...
python
def count(self, table): """ Use the current Query object to count the number of entries in `table` that satisfy `queries`. Parameters ---------- table : NumPy structured array, astropy Table, etc. Returns ------- count : int """ i...
[ "def", "count", "(", "self", ",", "table", ")", ":", "if", "self", ".", "_operator", "is", "None", "and", "self", ".", "_operands", "is", "None", ":", "return", "self", ".", "_get_table_len", "(", "table", ")", "return", "np", ".", "count_nonzero", "("...
Use the current Query object to count the number of entries in `table` that satisfy `queries`. Parameters ---------- table : NumPy structured array, astropy Table, etc. Returns ------- count : int
[ "Use", "the", "current", "Query", "object", "to", "count", "the", "number", "of", "entries", "in", "table", "that", "satisfy", "queries", "." ]
train
https://github.com/yymao/easyquery/blob/cd94c100e26f59042cd9ffb26d0a7b61cdcd457d/easyquery.py#L266-L282
yymao/easyquery
easyquery.py
Query.variable_names
def variable_names(self): """ Get all variable names required for this query """ if self._variable_names is None: if self._operator is None: if self._operands is None: self._variable_names = tuple() else: ...
python
def variable_names(self): """ Get all variable names required for this query """ if self._variable_names is None: if self._operator is None: if self._operands is None: self._variable_names = tuple() else: ...
[ "def", "variable_names", "(", "self", ")", ":", "if", "self", ".", "_variable_names", "is", "None", ":", "if", "self", ".", "_operator", "is", "None", ":", "if", "self", ".", "_operands", "is", "None", ":", "self", ".", "_variable_names", "=", "tuple", ...
Get all variable names required for this query
[ "Get", "all", "variable", "names", "required", "for", "this", "query" ]
train
https://github.com/yymao/easyquery/blob/cd94c100e26f59042cd9ffb26d0a7b61cdcd457d/easyquery.py#L313-L334
non-Jedi/gyr
gyr/matrix_objects.py
Event.user
def user(self): """Creates a User object when requested.""" try: return self._user except AttributeError: self._user = MatrixUser(self.mxid, self.Api(identity=self.mxid)) return self._user
python
def user(self): """Creates a User object when requested.""" try: return self._user except AttributeError: self._user = MatrixUser(self.mxid, self.Api(identity=self.mxid)) return self._user
[ "def", "user", "(", "self", ")", ":", "try", ":", "return", "self", ".", "_user", "except", "AttributeError", ":", "self", ".", "_user", "=", "MatrixUser", "(", "self", ".", "mxid", ",", "self", ".", "Api", "(", "identity", "=", "self", ".", "mxid", ...
Creates a User object when requested.
[ "Creates", "a", "User", "object", "when", "requested", "." ]
train
https://github.com/non-Jedi/gyr/blob/9f7bfe033b9d3bbfd3a9e8aea02e35526b53125e/gyr/matrix_objects.py#L49-L55
non-Jedi/gyr
gyr/matrix_objects.py
Event.room
def room(self): """Creates a Room object when requested.""" try: return self._room except AttributeError: room_id = self.json["room_id"] self._room = MatrixRoom(room_id, self.Api) return self._room
python
def room(self): """Creates a Room object when requested.""" try: return self._room except AttributeError: room_id = self.json["room_id"] self._room = MatrixRoom(room_id, self.Api) return self._room
[ "def", "room", "(", "self", ")", ":", "try", ":", "return", "self", ".", "_room", "except", "AttributeError", ":", "room_id", "=", "self", ".", "json", "[", "\"room_id\"", "]", "self", ".", "_room", "=", "MatrixRoom", "(", "room_id", ",", "self", ".", ...
Creates a Room object when requested.
[ "Creates", "a", "Room", "object", "when", "requested", "." ]
train
https://github.com/non-Jedi/gyr/blob/9f7bfe033b9d3bbfd3a9e8aea02e35526b53125e/gyr/matrix_objects.py#L58-L65
non-Jedi/gyr
gyr/matrix_objects.py
MatrixUser.join
def join(self, room_str): """Joins room id or alias even if it must first be created.""" response = self.user_api.join_room(room_str) return self._mkroom(response["room_id"])
python
def join(self, room_str): """Joins room id or alias even if it must first be created.""" response = self.user_api.join_room(room_str) return self._mkroom(response["room_id"])
[ "def", "join", "(", "self", ",", "room_str", ")", ":", "response", "=", "self", ".", "user_api", ".", "join_room", "(", "room_str", ")", "return", "self", ".", "_mkroom", "(", "response", "[", "\"room_id\"", "]", ")" ]
Joins room id or alias even if it must first be created.
[ "Joins", "room", "id", "or", "alias", "even", "if", "it", "must", "first", "be", "created", "." ]
train
https://github.com/non-Jedi/gyr/blob/9f7bfe033b9d3bbfd3a9e8aea02e35526b53125e/gyr/matrix_objects.py#L234-L237
non-Jedi/gyr
gyr/matrix_objects.py
MatrixUser.refresh_rooms
def refresh_rooms(self): """Calls GET /joined_rooms to refresh rooms list.""" for room_id in self.user_api.get_joined_rooms()["joined_rooms"]: self._rooms[room_id] = MatrixRoom(room_id, self.user_api)
python
def refresh_rooms(self): """Calls GET /joined_rooms to refresh rooms list.""" for room_id in self.user_api.get_joined_rooms()["joined_rooms"]: self._rooms[room_id] = MatrixRoom(room_id, self.user_api)
[ "def", "refresh_rooms", "(", "self", ")", ":", "for", "room_id", "in", "self", ".", "user_api", ".", "get_joined_rooms", "(", ")", "[", "\"joined_rooms\"", "]", ":", "self", ".", "_rooms", "[", "room_id", "]", "=", "MatrixRoom", "(", "room_id", ",", "sel...
Calls GET /joined_rooms to refresh rooms list.
[ "Calls", "GET", "/", "joined_rooms", "to", "refresh", "rooms", "list", "." ]
train
https://github.com/non-Jedi/gyr/blob/9f7bfe033b9d3bbfd3a9e8aea02e35526b53125e/gyr/matrix_objects.py#L274-L277
alfredodeza/notario
notario/decorators.py
not_empty
def not_empty(_object): """ Validates the given input (has to be a valid data structure) is empty. Input *has* to be one of: `list`, `dict`, or `string`. It is specially useful when most of the validators being created are dealing with data structures that should not be empty. """ if is_cal...
python
def not_empty(_object): """ Validates the given input (has to be a valid data structure) is empty. Input *has* to be one of: `list`, `dict`, or `string`. It is specially useful when most of the validators being created are dealing with data structures that should not be empty. """ if is_cal...
[ "def", "not_empty", "(", "_object", ")", ":", "if", "is_callable", "(", "_object", ")", ":", "_validator", "=", "_object", "@", "wraps", "(", "_validator", ")", "@", "instance_of", "(", ")", "def", "decorated", "(", "value", ")", ":", "ensure", "(", "v...
Validates the given input (has to be a valid data structure) is empty. Input *has* to be one of: `list`, `dict`, or `string`. It is specially useful when most of the validators being created are dealing with data structures that should not be empty.
[ "Validates", "the", "given", "input", "(", "has", "to", "be", "a", "valid", "data", "structure", ")", "is", "empty", ".", "Input", "*", "has", "*", "to", "be", "one", "of", ":", "list", "dict", "or", "string", "." ]
train
https://github.com/alfredodeza/notario/blob/d5dc2edfcb75d9291ced3f2551f368c35dd31475/notario/decorators.py#L72-L92
alfredodeza/notario
notario/decorators.py
optional
def optional(_object): """ This decorator has a double functionality, it can wrap validators and make them optional or it can wrap keys and make that entry optional. **Optional Validator:** Allows to have validators work only when there is a value that contains some data, otherwise it will just...
python
def optional(_object): """ This decorator has a double functionality, it can wrap validators and make them optional or it can wrap keys and make that entry optional. **Optional Validator:** Allows to have validators work only when there is a value that contains some data, otherwise it will just...
[ "def", "optional", "(", "_object", ")", ":", "if", "is_callable", "(", "_object", ")", ":", "validator", "=", "_object", "@", "wraps", "(", "validator", ")", "def", "decorated", "(", "value", ")", ":", "if", "value", ":", "return", "validator", "(", "v...
This decorator has a double functionality, it can wrap validators and make them optional or it can wrap keys and make that entry optional. **Optional Validator:** Allows to have validators work only when there is a value that contains some data, otherwise it will just not pass the information to the ac...
[ "This", "decorator", "has", "a", "double", "functionality", "it", "can", "wrap", "validators", "and", "make", "them", "optional", "or", "it", "can", "wrap", "keys", "and", "make", "that", "entry", "optional", "." ]
train
https://github.com/alfredodeza/notario/blob/d5dc2edfcb75d9291ced3f2551f368c35dd31475/notario/decorators.py#L95-L156
RowleyGroup/pyqueue
pyqueue/job.py
Job.set_walltime
def set_walltime(self, walltime): """ Setting a walltime for the job >>> job.set_walltime(datetime.timedelta(hours=2, minutes=30)) :param walltime: Walltime of the job (an instance of timedelta) :returns: self :rtype: self """ if not isinstance(walltime,...
python
def set_walltime(self, walltime): """ Setting a walltime for the job >>> job.set_walltime(datetime.timedelta(hours=2, minutes=30)) :param walltime: Walltime of the job (an instance of timedelta) :returns: self :rtype: self """ if not isinstance(walltime,...
[ "def", "set_walltime", "(", "self", ",", "walltime", ")", ":", "if", "not", "isinstance", "(", "walltime", ",", "timedelta", ")", ":", "raise", "TypeError", "(", "'walltime must be an instance of datetime.timedelta. %s given'", "%", "type", "(", "walltime", ")", "...
Setting a walltime for the job >>> job.set_walltime(datetime.timedelta(hours=2, minutes=30)) :param walltime: Walltime of the job (an instance of timedelta) :returns: self :rtype: self
[ "Setting", "a", "walltime", "for", "the", "job" ]
train
https://github.com/RowleyGroup/pyqueue/blob/24de6e1b06b9626ed94d0d5a859bc71bd3afbb4f/pyqueue/job.py#L155-L172
ocaballeror/LyricFetch
lyricfetch/scraping.py
get_url
def get_url(url, parser='html'): """ Requests the specified url and returns a BeautifulSoup object with its contents. """ url = request.quote(url, safe=':/?=&') logger.debug('URL: %s', url) req = request.Request(url, headers={'User-Agent': 'foobar'}) try: response = request.urlop...
python
def get_url(url, parser='html'): """ Requests the specified url and returns a BeautifulSoup object with its contents. """ url = request.quote(url, safe=':/?=&') logger.debug('URL: %s', url) req = request.Request(url, headers={'User-Agent': 'foobar'}) try: response = request.urlop...
[ "def", "get_url", "(", "url", ",", "parser", "=", "'html'", ")", ":", "url", "=", "request", ".", "quote", "(", "url", ",", "safe", "=", "':/?=&'", ")", "logger", ".", "debug", "(", "'URL: %s'", ",", "url", ")", "req", "=", "request", ".", "Request...
Requests the specified url and returns a BeautifulSoup object with its contents.
[ "Requests", "the", "specified", "url", "and", "returns", "a", "BeautifulSoup", "object", "with", "its", "contents", "." ]
train
https://github.com/ocaballeror/LyricFetch/blob/86e62fb39c4c413ad7e1acf5bf0d28c9ed7c8fcb/lyricfetch/scraping.py#L17-L43
ocaballeror/LyricFetch
lyricfetch/scraping.py
get_lastfm
def get_lastfm(method, lastfm_key='', **kwargs): """ Request the specified method from the lastfm api. """ if not lastfm_key: if 'lastfm_key' not in CONFIG or not CONFIG['lastfm_key']: logger.warning('No lastfm key configured') return '' else: lastfm_k...
python
def get_lastfm(method, lastfm_key='', **kwargs): """ Request the specified method from the lastfm api. """ if not lastfm_key: if 'lastfm_key' not in CONFIG or not CONFIG['lastfm_key']: logger.warning('No lastfm key configured') return '' else: lastfm_k...
[ "def", "get_lastfm", "(", "method", ",", "lastfm_key", "=", "''", ",", "*", "*", "kwargs", ")", ":", "if", "not", "lastfm_key", ":", "if", "'lastfm_key'", "not", "in", "CONFIG", "or", "not", "CONFIG", "[", "'lastfm_key'", "]", ":", "logger", ".", "warn...
Request the specified method from the lastfm api.
[ "Request", "the", "specified", "method", "from", "the", "lastfm", "api", "." ]
train
https://github.com/ocaballeror/LyricFetch/blob/86e62fb39c4c413ad7e1acf5bf0d28c9ed7c8fcb/lyricfetch/scraping.py#L46-L68
ocaballeror/LyricFetch
lyricfetch/scraping.py
normalize
def normalize(string, chars_to_remove=None, replacement=''): """ Remove accented characters and such. The argument chars_to_remove is a dictionary that maps a string of chars to a single character. Every occurrence of every character in the first string will be replaced by that second character pas...
python
def normalize(string, chars_to_remove=None, replacement=''): """ Remove accented characters and such. The argument chars_to_remove is a dictionary that maps a string of chars to a single character. Every occurrence of every character in the first string will be replaced by that second character pas...
[ "def", "normalize", "(", "string", ",", "chars_to_remove", "=", "None", ",", "replacement", "=", "''", ")", ":", "ret", "=", "string", ".", "translate", "(", "str", ".", "maketrans", "(", "{", "'á':", " ", "a',", "", "'ä':", " ", "a',", "", "'æ':", ...
Remove accented characters and such. The argument chars_to_remove is a dictionary that maps a string of chars to a single character. Every occurrence of every character in the first string will be replaced by that second character passed as value. If only one mapping is desired, chars_to_remove may be ...
[ "Remove", "accented", "characters", "and", "such", "." ]
train
https://github.com/ocaballeror/LyricFetch/blob/86e62fb39c4c413ad7e1acf5bf0d28c9ed7c8fcb/lyricfetch/scraping.py#L71-L103
ocaballeror/LyricFetch
lyricfetch/scraping.py
metrolyrics
def metrolyrics(song): """ Returns the lyrics found in metrolyrics for the specified mp3 file or an empty string if not found. """ translate = {URLESCAPE: '', ' ': '-'} title = song.title.lower() title = normalize(title, translate) title = re.sub(r'\-{2,}', '-', title) artist = song....
python
def metrolyrics(song): """ Returns the lyrics found in metrolyrics for the specified mp3 file or an empty string if not found. """ translate = {URLESCAPE: '', ' ': '-'} title = song.title.lower() title = normalize(title, translate) title = re.sub(r'\-{2,}', '-', title) artist = song....
[ "def", "metrolyrics", "(", "song", ")", ":", "translate", "=", "{", "URLESCAPE", ":", "''", ",", "' '", ":", "'-'", "}", "title", "=", "song", ".", "title", ".", "lower", "(", ")", "title", "=", "normalize", "(", "title", ",", "translate", ")", "ti...
Returns the lyrics found in metrolyrics for the specified mp3 file or an empty string if not found.
[ "Returns", "the", "lyrics", "found", "in", "metrolyrics", "for", "the", "specified", "mp3", "file", "or", "an", "empty", "string", "if", "not", "found", "." ]
train
https://github.com/ocaballeror/LyricFetch/blob/86e62fb39c4c413ad7e1acf5bf0d28c9ed7c8fcb/lyricfetch/scraping.py#L106-L131
ocaballeror/LyricFetch
lyricfetch/scraping.py
darklyrics
def darklyrics(song): """ Returns the lyrics found in darklyrics for the specified mp3 file or an empty string if not found. """ # Darklyrics relies on the album name if not hasattr(song, 'album') or not song.album: song.fetch_album_name() if not hasattr(song, 'album') or not so...
python
def darklyrics(song): """ Returns the lyrics found in darklyrics for the specified mp3 file or an empty string if not found. """ # Darklyrics relies on the album name if not hasattr(song, 'album') or not song.album: song.fetch_album_name() if not hasattr(song, 'album') or not so...
[ "def", "darklyrics", "(", "song", ")", ":", "# Darklyrics relies on the album name", "if", "not", "hasattr", "(", "song", ",", "'album'", ")", "or", "not", "song", ".", "album", ":", "song", ".", "fetch_album_name", "(", ")", "if", "not", "hasattr", "(", "...
Returns the lyrics found in darklyrics for the specified mp3 file or an empty string if not found.
[ "Returns", "the", "lyrics", "found", "in", "darklyrics", "for", "the", "specified", "mp3", "file", "or", "an", "empty", "string", "if", "not", "found", "." ]
train
https://github.com/ocaballeror/LyricFetch/blob/86e62fb39c4c413ad7e1acf5bf0d28c9ed7c8fcb/lyricfetch/scraping.py#L134-L167
ocaballeror/LyricFetch
lyricfetch/scraping.py
azlyrics
def azlyrics(song): """ Returns the lyrics found in azlyrics for the specified mp3 file or an empty string if not found. """ artist = song.artist.lower() if artist[0:2] == 'a ': artist = artist[2:] artist = normalize(artist, URLESCAPES, '') title = song.title.lower() title = ...
python
def azlyrics(song): """ Returns the lyrics found in azlyrics for the specified mp3 file or an empty string if not found. """ artist = song.artist.lower() if artist[0:2] == 'a ': artist = artist[2:] artist = normalize(artist, URLESCAPES, '') title = song.title.lower() title = ...
[ "def", "azlyrics", "(", "song", ")", ":", "artist", "=", "song", ".", "artist", ".", "lower", "(", ")", "if", "artist", "[", "0", ":", "2", "]", "==", "'a '", ":", "artist", "=", "artist", "[", "2", ":", "]", "artist", "=", "normalize", "(", "a...
Returns the lyrics found in azlyrics for the specified mp3 file or an empty string if not found.
[ "Returns", "the", "lyrics", "found", "in", "azlyrics", "for", "the", "specified", "mp3", "file", "or", "an", "empty", "string", "if", "not", "found", "." ]
train
https://github.com/ocaballeror/LyricFetch/blob/86e62fb39c4c413ad7e1acf5bf0d28c9ed7c8fcb/lyricfetch/scraping.py#L170-L185
ocaballeror/LyricFetch
lyricfetch/scraping.py
genius
def genius(song): """ Returns the lyrics found in genius.com for the specified mp3 file or an empty string if not found. """ translate = { '@': 'at', '&': 'and', URLESCAPE: '', ' ': '-' } artist = song.artist.capitalize() artist = normalize(artist, transla...
python
def genius(song): """ Returns the lyrics found in genius.com for the specified mp3 file or an empty string if not found. """ translate = { '@': 'at', '&': 'and', URLESCAPE: '', ' ': '-' } artist = song.artist.capitalize() artist = normalize(artist, transla...
[ "def", "genius", "(", "song", ")", ":", "translate", "=", "{", "'@'", ":", "'at'", ",", "'&'", ":", "'and'", ",", "URLESCAPE", ":", "''", ",", "' '", ":", "'-'", "}", "artist", "=", "song", ".", "artist", ".", "capitalize", "(", ")", "artist", "=...
Returns the lyrics found in genius.com for the specified mp3 file or an empty string if not found.
[ "Returns", "the", "lyrics", "found", "in", "genius", ".", "com", "for", "the", "specified", "mp3", "file", "or", "an", "empty", "string", "if", "not", "found", "." ]
train
https://github.com/ocaballeror/LyricFetch/blob/86e62fb39c4c413ad7e1acf5bf0d28c9ed7c8fcb/lyricfetch/scraping.py#L188-L212
ocaballeror/LyricFetch
lyricfetch/scraping.py
metalarchives
def metalarchives(song): """ Returns the lyrics found in MetalArchives for the specified mp3 file or an empty string if not found. """ artist = normalize(song.artist) title = normalize(song.title) url = 'https://www.metal-archives.com/search/ajax-advanced/searching/songs' url += f'/?son...
python
def metalarchives(song): """ Returns the lyrics found in MetalArchives for the specified mp3 file or an empty string if not found. """ artist = normalize(song.artist) title = normalize(song.title) url = 'https://www.metal-archives.com/search/ajax-advanced/searching/songs' url += f'/?son...
[ "def", "metalarchives", "(", "song", ")", ":", "artist", "=", "normalize", "(", "song", ".", "artist", ")", "title", "=", "normalize", "(", "song", ".", "title", ")", "url", "=", "'https://www.metal-archives.com/search/ajax-advanced/searching/songs'", "url", "+=",...
Returns the lyrics found in MetalArchives for the specified mp3 file or an empty string if not found.
[ "Returns", "the", "lyrics", "found", "in", "MetalArchives", "for", "the", "specified", "mp3", "file", "or", "an", "empty", "string", "if", "not", "found", "." ]
train
https://github.com/ocaballeror/LyricFetch/blob/86e62fb39c4c413ad7e1acf5bf0d28c9ed7c8fcb/lyricfetch/scraping.py#L215-L244
ocaballeror/LyricFetch
lyricfetch/scraping.py
lyricswikia
def lyricswikia(song): """ Returns the lyrics found in lyrics.wikia.com for the specified mp3 file or an empty string if not found. """ artist = song.artist.title() artist = normalize(artist, ' ', '_') title = song.title title = normalize(title, ' ', '_') url = 'https://lyrics.wikia...
python
def lyricswikia(song): """ Returns the lyrics found in lyrics.wikia.com for the specified mp3 file or an empty string if not found. """ artist = song.artist.title() artist = normalize(artist, ' ', '_') title = song.title title = normalize(title, ' ', '_') url = 'https://lyrics.wikia...
[ "def", "lyricswikia", "(", "song", ")", ":", "artist", "=", "song", ".", "artist", ".", "title", "(", ")", "artist", "=", "normalize", "(", "artist", ",", "' '", ",", "'_'", ")", "title", "=", "song", ".", "title", "title", "=", "normalize", "(", "...
Returns the lyrics found in lyrics.wikia.com for the specified mp3 file or an empty string if not found.
[ "Returns", "the", "lyrics", "found", "in", "lyrics", ".", "wikia", ".", "com", "for", "the", "specified", "mp3", "file", "or", "an", "empty", "string", "if", "not", "found", "." ]
train
https://github.com/ocaballeror/LyricFetch/blob/86e62fb39c4c413ad7e1acf5bf0d28c9ed7c8fcb/lyricfetch/scraping.py#L247-L280
ocaballeror/LyricFetch
lyricfetch/scraping.py
musixmatch
def musixmatch(song): """ Returns the lyrics found in musixmatch for the specified mp3 file or an empty string if not found. """ escape = re.sub("'-¡¿", '', URLESCAPE) translate = { escape: '', ' ': '-' } artist = song.artist.title() artist = re.sub(r"( '|' )", '', ar...
python
def musixmatch(song): """ Returns the lyrics found in musixmatch for the specified mp3 file or an empty string if not found. """ escape = re.sub("'-¡¿", '', URLESCAPE) translate = { escape: '', ' ': '-' } artist = song.artist.title() artist = re.sub(r"( '|' )", '', ar...
[ "def", "musixmatch", "(", "song", ")", ":", "escape", "=", "re", ".", "sub", "(", "\"'-¡¿\", ", "'", ", ", "U", "LESCAPE)", "", "translate", "=", "{", "escape", ":", "''", ",", "' '", ":", "'-'", "}", "artist", "=", "song", ".", "artist", ".", "t...
Returns the lyrics found in musixmatch for the specified mp3 file or an empty string if not found.
[ "Returns", "the", "lyrics", "found", "in", "musixmatch", "for", "the", "specified", "mp3", "file", "or", "an", "empty", "string", "if", "not", "found", "." ]
train
https://github.com/ocaballeror/LyricFetch/blob/86e62fb39c4c413ad7e1acf5bf0d28c9ed7c8fcb/lyricfetch/scraping.py#L283-L314
ocaballeror/LyricFetch
lyricfetch/scraping.py
songlyrics
def songlyrics(song): """ Returns the lyrics found in songlyrics.com for the specified mp3 file or an empty string if not found. """ translate = { URLESCAPE: '', ' ': '-' } artist = song.artist.lower() artist = normalize(artist, translate) title = song.title.lower() ...
python
def songlyrics(song): """ Returns the lyrics found in songlyrics.com for the specified mp3 file or an empty string if not found. """ translate = { URLESCAPE: '', ' ': '-' } artist = song.artist.lower() artist = normalize(artist, translate) title = song.title.lower() ...
[ "def", "songlyrics", "(", "song", ")", ":", "translate", "=", "{", "URLESCAPE", ":", "''", ",", "' '", ":", "'-'", "}", "artist", "=", "song", ".", "artist", ".", "lower", "(", ")", "artist", "=", "normalize", "(", "artist", ",", "translate", ")", ...
Returns the lyrics found in songlyrics.com for the specified mp3 file or an empty string if not found.
[ "Returns", "the", "lyrics", "found", "in", "songlyrics", ".", "com", "for", "the", "specified", "mp3", "file", "or", "an", "empty", "string", "if", "not", "found", "." ]
train
https://github.com/ocaballeror/LyricFetch/blob/86e62fb39c4c413ad7e1acf5bf0d28c9ed7c8fcb/lyricfetch/scraping.py#L319-L346
ocaballeror/LyricFetch
lyricfetch/scraping.py
lyricscom
def lyricscom(song): """ Returns the lyrics found in lyrics.com for the specified mp3 file or an empty string if not found. """ artist = song.artist.lower() artist = normalize(artist, ' ', '+') title = song.title url = 'https://www.lyrics.com/artist/{}'.format(artist) soup = get_url...
python
def lyricscom(song): """ Returns the lyrics found in lyrics.com for the specified mp3 file or an empty string if not found. """ artist = song.artist.lower() artist = normalize(artist, ' ', '+') title = song.title url = 'https://www.lyrics.com/artist/{}'.format(artist) soup = get_url...
[ "def", "lyricscom", "(", "song", ")", ":", "artist", "=", "song", ".", "artist", ".", "lower", "(", ")", "artist", "=", "normalize", "(", "artist", ",", "' '", ",", "'+'", ")", "title", "=", "song", ".", "title", "url", "=", "'https://www.lyrics.com/ar...
Returns the lyrics found in lyrics.com for the specified mp3 file or an empty string if not found.
[ "Returns", "the", "lyrics", "found", "in", "lyrics", ".", "com", "for", "the", "specified", "mp3", "file", "or", "an", "empty", "string", "if", "not", "found", "." ]
train
https://github.com/ocaballeror/LyricFetch/blob/86e62fb39c4c413ad7e1acf5bf0d28c9ed7c8fcb/lyricfetch/scraping.py#L349-L374
ocaballeror/LyricFetch
lyricfetch/scraping.py
vagalume
def vagalume(song): """ Returns the lyrics found in vagalume.com.br for the specified mp3 file or an empty string if not found. """ translate = { '@': 'a', URLESCAPE: '', ' ': '-' } artist = song.artist.lower() artist = normalize(artist, translate) artist = re...
python
def vagalume(song): """ Returns the lyrics found in vagalume.com.br for the specified mp3 file or an empty string if not found. """ translate = { '@': 'a', URLESCAPE: '', ' ': '-' } artist = song.artist.lower() artist = normalize(artist, translate) artist = re...
[ "def", "vagalume", "(", "song", ")", ":", "translate", "=", "{", "'@'", ":", "'a'", ",", "URLESCAPE", ":", "''", ",", "' '", ":", "'-'", "}", "artist", "=", "song", ".", "artist", ".", "lower", "(", ")", "artist", "=", "normalize", "(", "artist", ...
Returns the lyrics found in vagalume.com.br for the specified mp3 file or an empty string if not found.
[ "Returns", "the", "lyrics", "found", "in", "vagalume", ".", "com", ".", "br", "for", "the", "specified", "mp3", "file", "or", "an", "empty", "string", "if", "not", "found", "." ]
train
https://github.com/ocaballeror/LyricFetch/blob/86e62fb39c4c413ad7e1acf5bf0d28c9ed7c8fcb/lyricfetch/scraping.py#L377-L404
ocaballeror/LyricFetch
lyricfetch/scraping.py
lyricsmode
def lyricsmode(song): """ Returns the lyrics found in lyricsmode.com for the specified mp3 file or an empty string if not found. """ translate = { URLESCAPE: '', ' ': '_' } artist = song.artist.lower() artist = normalize(artist, translate) title = song.title.lower() ...
python
def lyricsmode(song): """ Returns the lyrics found in lyricsmode.com for the specified mp3 file or an empty string if not found. """ translate = { URLESCAPE: '', ' ': '_' } artist = song.artist.lower() artist = normalize(artist, translate) title = song.title.lower() ...
[ "def", "lyricsmode", "(", "song", ")", ":", "translate", "=", "{", "URLESCAPE", ":", "''", ",", "' '", ":", "'_'", "}", "artist", "=", "song", ".", "artist", ".", "lower", "(", ")", "artist", "=", "normalize", "(", "artist", ",", "translate", ")", ...
Returns the lyrics found in lyricsmode.com for the specified mp3 file or an empty string if not found.
[ "Returns", "the", "lyrics", "found", "in", "lyricsmode", ".", "com", "for", "the", "specified", "mp3", "file", "or", "an", "empty", "string", "if", "not", "found", "." ]
train
https://github.com/ocaballeror/LyricFetch/blob/86e62fb39c4c413ad7e1acf5bf0d28c9ed7c8fcb/lyricfetch/scraping.py#L407-L437
ocaballeror/LyricFetch
lyricfetch/scraping.py
letras
def letras(song): """ Returns the lyrics found in letras.com for the specified mp3 file or an empty string if not found. """ translate = { '&': 'a', URLESCAPE: '', ' ': '-' } artist = song.artist.lower() artist = normalize(artist, translate) title = song.title...
python
def letras(song): """ Returns the lyrics found in letras.com for the specified mp3 file or an empty string if not found. """ translate = { '&': 'a', URLESCAPE: '', ' ': '-' } artist = song.artist.lower() artist = normalize(artist, translate) title = song.title...
[ "def", "letras", "(", "song", ")", ":", "translate", "=", "{", "'&'", ":", "'a'", ",", "URLESCAPE", ":", "''", ",", "' '", ":", "'-'", "}", "artist", "=", "song", ".", "artist", ".", "lower", "(", ")", "artist", "=", "normalize", "(", "artist", "...
Returns the lyrics found in letras.com for the specified mp3 file or an empty string if not found.
[ "Returns", "the", "lyrics", "found", "in", "letras", ".", "com", "for", "the", "specified", "mp3", "file", "or", "an", "empty", "string", "if", "not", "found", "." ]
train
https://github.com/ocaballeror/LyricFetch/blob/86e62fb39c4c413ad7e1acf5bf0d28c9ed7c8fcb/lyricfetch/scraping.py#L440-L482
ocaballeror/LyricFetch
lyricfetch/scraping.py
id_source
def id_source(source, full=False): """ Returns the name of a website-scrapping function. """ if source not in source_ids: return '' if full: return source_ids[source][1] else: return source_ids[source][0]
python
def id_source(source, full=False): """ Returns the name of a website-scrapping function. """ if source not in source_ids: return '' if full: return source_ids[source][1] else: return source_ids[source][0]
[ "def", "id_source", "(", "source", ",", "full", "=", "False", ")", ":", "if", "source", "not", "in", "source_ids", ":", "return", "''", "if", "full", ":", "return", "source_ids", "[", "source", "]", "[", "1", "]", "else", ":", "return", "source_ids", ...
Returns the name of a website-scrapping function.
[ "Returns", "the", "name", "of", "a", "website", "-", "scrapping", "function", "." ]
train
https://github.com/ocaballeror/LyricFetch/blob/86e62fb39c4c413ad7e1acf5bf0d28c9ed7c8fcb/lyricfetch/scraping.py#L501-L511
tipsi/tipsi_tools
tipsi_tools/mon_server/gitlab_runners.py
update_gitlab_loop
async def update_gitlab_loop(update_metrics, params): """ app = Sanic() mserver = MetricsServer(app) mserver.add_task(update_gitlab_loop, params={'url': GITLAB_URL, 'token': token}) """ gitlab_api = gitlab.Gitlab(url=params['url'], private_token=params['token'], api_version=4) while True: ...
python
async def update_gitlab_loop(update_metrics, params): """ app = Sanic() mserver = MetricsServer(app) mserver.add_task(update_gitlab_loop, params={'url': GITLAB_URL, 'token': token}) """ gitlab_api = gitlab.Gitlab(url=params['url'], private_token=params['token'], api_version=4) while True: ...
[ "async", "def", "update_gitlab_loop", "(", "update_metrics", ",", "params", ")", ":", "gitlab_api", "=", "gitlab", ".", "Gitlab", "(", "url", "=", "params", "[", "'url'", "]", ",", "private_token", "=", "params", "[", "'token'", "]", ",", "api_version", "=...
app = Sanic() mserver = MetricsServer(app) mserver.add_task(update_gitlab_loop, params={'url': GITLAB_URL, 'token': token})
[ "app", "=", "Sanic", "()", "mserver", "=", "MetricsServer", "(", "app", ")", "mserver", ".", "add_task", "(", "update_gitlab_loop", "params", "=", "{", "url", ":", "GITLAB_URL", "token", ":", "token", "}", ")" ]
train
https://github.com/tipsi/tipsi_tools/blob/1aba960c9890ceef2fb5e215b98b1646056ee58e/tipsi_tools/mon_server/gitlab_runners.py#L28-L42
nion-software/nionswift-instrumentation-kit
nion/instrumentation/stem_controller.py
STEMController.set_probe_position
def set_probe_position(self, new_probe_position): """ Set the probe position, in normalized coordinates with origin at top left. """ if new_probe_position is not None: # convert the probe position to a FloatPoint and limit it to the 0.0 to 1.0 range in both axes. new_probe_positi...
python
def set_probe_position(self, new_probe_position): """ Set the probe position, in normalized coordinates with origin at top left. """ if new_probe_position is not None: # convert the probe position to a FloatPoint and limit it to the 0.0 to 1.0 range in both axes. new_probe_positi...
[ "def", "set_probe_position", "(", "self", ",", "new_probe_position", ")", ":", "if", "new_probe_position", "is", "not", "None", ":", "# convert the probe position to a FloatPoint and limit it to the 0.0 to 1.0 range in both axes.", "new_probe_position", "=", "Geometry", ".", "F...
Set the probe position, in normalized coordinates with origin at top left.
[ "Set", "the", "probe", "position", "in", "normalized", "coordinates", "with", "origin", "at", "top", "left", "." ]
train
https://github.com/nion-software/nionswift-instrumentation-kit/blob/b20c4fff17e840e8cb3d544705faf5bd05f1cbf7/nion/instrumentation/stem_controller.py#L157-L170
nion-software/nionswift-instrumentation-kit
nion/instrumentation/stem_controller.py
STEMController.apply_metadata_groups
def apply_metadata_groups(self, properties: typing.Dict, metatdata_groups: typing.Tuple[typing.List[str], str]) -> None: """Apply metadata groups to properties. Metadata groups is a tuple with two elements. The first is a list of strings representing a dict-path in which to add the controls. Th...
python
def apply_metadata_groups(self, properties: typing.Dict, metatdata_groups: typing.Tuple[typing.List[str], str]) -> None: """Apply metadata groups to properties. Metadata groups is a tuple with two elements. The first is a list of strings representing a dict-path in which to add the controls. Th...
[ "def", "apply_metadata_groups", "(", "self", ",", "properties", ":", "typing", ".", "Dict", ",", "metatdata_groups", ":", "typing", ".", "Tuple", "[", "typing", ".", "List", "[", "str", "]", ",", "str", "]", ")", "->", "None", ":", "pass" ]
Apply metadata groups to properties. Metadata groups is a tuple with two elements. The first is a list of strings representing a dict-path in which to add the controls. The second is a control group from which to read a list of controls to be added as name value pairs to the dict-path.
[ "Apply", "metadata", "groups", "to", "properties", "." ]
train
https://github.com/nion-software/nionswift-instrumentation-kit/blob/b20c4fff17e840e8cb3d544705faf5bd05f1cbf7/nion/instrumentation/stem_controller.py#L222-L229
numan/py-analytics
analytics/__init__.py
create_analytic_backend
def create_analytic_backend(settings): """ Creates a new Analytics backend from the settings :param settings: Dictionary of settings for the analytics backend :returns: A backend object implementing the analytics api >>> >>> analytics = create_analytic({ >>> 'backend': 'analytics.backe...
python
def create_analytic_backend(settings): """ Creates a new Analytics backend from the settings :param settings: Dictionary of settings for the analytics backend :returns: A backend object implementing the analytics api >>> >>> analytics = create_analytic({ >>> 'backend': 'analytics.backe...
[ "def", "create_analytic_backend", "(", "settings", ")", ":", "backend", "=", "settings", ".", "get", "(", "'backend'", ")", "if", "isinstance", "(", "backend", ",", "basestring", ")", ":", "backend", "=", "import_string", "(", "backend", ")", "elif", "backen...
Creates a new Analytics backend from the settings :param settings: Dictionary of settings for the analytics backend :returns: A backend object implementing the analytics api >>> >>> analytics = create_analytic({ >>> 'backend': 'analytics.backends.redis.Redis', >>> 'settings': { >>>...
[ "Creates", "a", "new", "Analytics", "backend", "from", "the", "settings" ]
train
https://github.com/numan/py-analytics/blob/abbc814925c6cc200b3329c7de9f1868e1cb8c01/analytics/__init__.py#L27-L55
nion-software/nionswift-instrumentation-kit
nionswift_plugin/nion_instrumentation_ui/ScanControlPanel.py
ScanControlStateController.initialize_state
def initialize_state(self): """ Call this to initialize the state of the UI after everything has been connected. """ if self.__scan_hardware_source: self.__profile_changed_event_listener = self.__scan_hardware_source.profile_changed_event.listen(self.__update_profile_index) self....
python
def initialize_state(self): """ Call this to initialize the state of the UI after everything has been connected. """ if self.__scan_hardware_source: self.__profile_changed_event_listener = self.__scan_hardware_source.profile_changed_event.listen(self.__update_profile_index) self....
[ "def", "initialize_state", "(", "self", ")", ":", "if", "self", ".", "__scan_hardware_source", ":", "self", ".", "__profile_changed_event_listener", "=", "self", ".", "__scan_hardware_source", ".", "profile_changed_event", ".", "listen", "(", "self", ".", "__update_...
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/ScanControlPanel.py#L262-L307
nion-software/nionswift-instrumentation-kit
nionswift_plugin/nion_instrumentation_ui/ScanControlPanel.py
ScanControlStateController.handle_play_pause_clicked
def handle_play_pause_clicked(self): """ Call this when the user clicks the play/pause button. """ if self.__scan_hardware_source: if self.is_playing: self.__scan_hardware_source.stop_playing() else: self.__scan_hardware_source.start_playing()
python
def handle_play_pause_clicked(self): """ Call this when the user clicks the play/pause button. """ if self.__scan_hardware_source: if self.is_playing: self.__scan_hardware_source.stop_playing() else: self.__scan_hardware_source.start_playing()
[ "def", "handle_play_pause_clicked", "(", "self", ")", ":", "if", "self", ".", "__scan_hardware_source", ":", "if", "self", ".", "is_playing", ":", "self", ".", "__scan_hardware_source", ".", "stop_playing", "(", ")", "else", ":", "self", ".", "__scan_hardware_so...
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/ScanControlPanel.py#L315-L321
nion-software/nionswift-instrumentation-kit
nionswift_plugin/nion_instrumentation_ui/ScanControlPanel.py
ScanControlStateController.handle_record_clicked
def handle_record_clicked(self, callback_fn): """ Call this when the user clicks the record button. """ assert callable(callback_fn) if self.__scan_hardware_source: def finish_record(data_and_metadata_list): record_index = self.__scan_hardware_source.record_index ...
python
def handle_record_clicked(self, callback_fn): """ Call this when the user clicks the record button. """ assert callable(callback_fn) if self.__scan_hardware_source: def finish_record(data_and_metadata_list): record_index = self.__scan_hardware_source.record_index ...
[ "def", "handle_record_clicked", "(", "self", ",", "callback_fn", ")", ":", "assert", "callable", "(", "callback_fn", ")", "if", "self", ".", "__scan_hardware_source", ":", "def", "finish_record", "(", "data_and_metadata_list", ")", ":", "record_index", "=", "self"...
Call this when the user clicks the record button.
[ "Call", "this", "when", "the", "user", "clicks", "the", "record", "button", "." ]
train
https://github.com/nion-software/nionswift-instrumentation-kit/blob/b20c4fff17e840e8cb3d544705faf5bd05f1cbf7/nionswift_plugin/nion_instrumentation_ui/ScanControlPanel.py#L330-L351
nion-software/nionswift-instrumentation-kit
nionswift_plugin/nion_instrumentation_ui/ScanControlPanel.py
IconCanvasItem.size_to_content
def size_to_content(self, horizontal_padding=None, vertical_padding=None): """ Size the canvas item to the text content. """ if horizontal_padding is None: horizontal_padding = 0 if vertical_padding is None: vertical_padding = 0 self.sizing.set_fixed_size(Geome...
python
def size_to_content(self, horizontal_padding=None, vertical_padding=None): """ Size the canvas item to the text content. """ if horizontal_padding is None: horizontal_padding = 0 if vertical_padding is None: vertical_padding = 0 self.sizing.set_fixed_size(Geome...
[ "def", "size_to_content", "(", "self", ",", "horizontal_padding", "=", "None", ",", "vertical_padding", "=", "None", ")", ":", "if", "horizontal_padding", "is", "None", ":", "horizontal_padding", "=", "0", "if", "vertical_padding", "is", "None", ":", "vertical_p...
Size the canvas item to the text content.
[ "Size", "the", "canvas", "item", "to", "the", "text", "content", "." ]
train
https://github.com/nion-software/nionswift-instrumentation-kit/blob/b20c4fff17e840e8cb3d544705faf5bd05f1cbf7/nionswift_plugin/nion_instrumentation_ui/ScanControlPanel.py#L581-L590
Parsely/redis-fluster
fluster/utils.py
round_controlled
def round_controlled(cycled_iterable, rounds=1): """Return after <rounds> passes through a cycled iterable.""" round_start = None rounds_completed = 0 for item in cycled_iterable: if round_start is None: round_start = item elif item == round_start: rounds_complet...
python
def round_controlled(cycled_iterable, rounds=1): """Return after <rounds> passes through a cycled iterable.""" round_start = None rounds_completed = 0 for item in cycled_iterable: if round_start is None: round_start = item elif item == round_start: rounds_complet...
[ "def", "round_controlled", "(", "cycled_iterable", ",", "rounds", "=", "1", ")", ":", "round_start", "=", "None", "rounds_completed", "=", "0", "for", "item", "in", "cycled_iterable", ":", "if", "round_start", "is", "None", ":", "round_start", "=", "item", "...
Return after <rounds> passes through a cycled iterable.
[ "Return", "after", "<rounds", ">", "passes", "through", "a", "cycled", "iterable", "." ]
train
https://github.com/Parsely/redis-fluster/blob/9fb3ccdc3e0b24906520cac1e933a775e8dfbd99/fluster/utils.py#L1-L15
ocaballeror/LyricFetch
lyricfetch/stats.py
Record.success_rate
def success_rate(self): """ Returns a float with the rate of success from all the logged results. """ if self.successes + self.fails == 0: success_rate = 0 else: total_attempts = self.successes + self.fails success_rate = (self.successes * 100 ...
python
def success_rate(self): """ Returns a float with the rate of success from all the logged results. """ if self.successes + self.fails == 0: success_rate = 0 else: total_attempts = self.successes + self.fails success_rate = (self.successes * 100 ...
[ "def", "success_rate", "(", "self", ")", ":", "if", "self", ".", "successes", "+", "self", ".", "fails", "==", "0", ":", "success_rate", "=", "0", "else", ":", "total_attempts", "=", "self", ".", "successes", "+", "self", ".", "fails", "success_rate", ...
Returns a float with the rate of success from all the logged results.
[ "Returns", "a", "float", "with", "the", "rate", "of", "success", "from", "all", "the", "logged", "results", "." ]
train
https://github.com/ocaballeror/LyricFetch/blob/86e62fb39c4c413ad7e1acf5bf0d28c9ed7c8fcb/lyricfetch/stats.py#L46-L56
ocaballeror/LyricFetch
lyricfetch/stats.py
Stats.add_result
def add_result(self, source, found, runtime): """ Adds a new record to the statistics 'database'. This function is intended to be called after a website has been scraped. The arguments indicate the function that was called, the time taken to scrap the website and a boolean indica...
python
def add_result(self, source, found, runtime): """ Adds a new record to the statistics 'database'. This function is intended to be called after a website has been scraped. The arguments indicate the function that was called, the time taken to scrap the website and a boolean indica...
[ "def", "add_result", "(", "self", ",", "source", ",", "found", ",", "runtime", ")", ":", "self", ".", "source_stats", "[", "source", ".", "__name__", "]", ".", "add_runtime", "(", "runtime", ")", "if", "found", ":", "self", ".", "source_stats", "[", "s...
Adds a new record to the statistics 'database'. This function is intended to be called after a website has been scraped. The arguments indicate the function that was called, the time taken to scrap the website and a boolean indicating if the lyrics were found or not.
[ "Adds", "a", "new", "record", "to", "the", "statistics", "database", ".", "This", "function", "is", "intended", "to", "be", "called", "after", "a", "website", "has", "been", "scraped", ".", "The", "arguments", "indicate", "the", "function", "that", "was", ...
train
https://github.com/ocaballeror/LyricFetch/blob/86e62fb39c4c413ad7e1acf5bf0d28c9ed7c8fcb/lyricfetch/stats.py#L67-L78
ocaballeror/LyricFetch
lyricfetch/stats.py
Stats.avg_time
def avg_time(self, source=None): """ Returns the average time taken to scrape lyrics. If a string or a function is passed as source, return the average time taken to scrape lyrics from that source, otherwise return the total average. """ if source is None: run...
python
def avg_time(self, source=None): """ Returns the average time taken to scrape lyrics. If a string or a function is passed as source, return the average time taken to scrape lyrics from that source, otherwise return the total average. """ if source is None: run...
[ "def", "avg_time", "(", "self", ",", "source", "=", "None", ")", ":", "if", "source", "is", "None", ":", "runtimes", "=", "[", "]", "for", "rec", "in", "self", ".", "source_stats", ".", "values", "(", ")", ":", "runtimes", ".", "extend", "(", "[", ...
Returns the average time taken to scrape lyrics. If a string or a function is passed as source, return the average time taken to scrape lyrics from that source, otherwise return the total average.
[ "Returns", "the", "average", "time", "taken", "to", "scrape", "lyrics", ".", "If", "a", "string", "or", "a", "function", "is", "passed", "as", "source", "return", "the", "average", "time", "taken", "to", "scrape", "lyrics", "from", "that", "source", "other...
train
https://github.com/ocaballeror/LyricFetch/blob/86e62fb39c4c413ad7e1acf5bf0d28c9ed7c8fcb/lyricfetch/stats.py#L80-L95
ocaballeror/LyricFetch
lyricfetch/stats.py
Stats.calculate
def calculate(self): """ Calculate the overall counts of best, worst, fastest, slowest, total found, total not found and total runtime Results are returned in a dictionary with the above parameters as keys. """ best, worst, fastest, slowest = (), (), (), () found...
python
def calculate(self): """ Calculate the overall counts of best, worst, fastest, slowest, total found, total not found and total runtime Results are returned in a dictionary with the above parameters as keys. """ best, worst, fastest, slowest = (), (), (), () found...
[ "def", "calculate", "(", "self", ")", ":", "best", ",", "worst", ",", "fastest", ",", "slowest", "=", "(", ")", ",", "(", ")", ",", "(", ")", ",", "(", ")", "found", "=", "notfound", "=", "total_time", "=", "0", "for", "source", ",", "rec", "in...
Calculate the overall counts of best, worst, fastest, slowest, total found, total not found and total runtime Results are returned in a dictionary with the above parameters as keys.
[ "Calculate", "the", "overall", "counts", "of", "best", "worst", "fastest", "slowest", "total", "found", "total", "not", "found", "and", "total", "runtime" ]
train
https://github.com/ocaballeror/LyricFetch/blob/86e62fb39c4c413ad7e1acf5bf0d28c9ed7c8fcb/lyricfetch/stats.py#L97-L130
ocaballeror/LyricFetch
lyricfetch/stats.py
Stats.print_stats
def print_stats(self): """ Print a series of relevant stats about a full execution. This function is meant to be called at the end of the program. """ stats = self.calculate() total_time = '%d:%02d:%02d' % (stats['total_time'] / 3600, ...
python
def print_stats(self): """ Print a series of relevant stats about a full execution. This function is meant to be called at the end of the program. """ stats = self.calculate() total_time = '%d:%02d:%02d' % (stats['total_time'] / 3600, ...
[ "def", "print_stats", "(", "self", ")", ":", "stats", "=", "self", ".", "calculate", "(", ")", "total_time", "=", "'%d:%02d:%02d'", "%", "(", "stats", "[", "'total_time'", "]", "/", "3600", ",", "(", "stats", "[", "'total_time'", "]", "/", "3600", ")",...
Print a series of relevant stats about a full execution. This function is meant to be called at the end of the program.
[ "Print", "a", "series", "of", "relevant", "stats", "about", "a", "full", "execution", ".", "This", "function", "is", "meant", "to", "be", "called", "at", "the", "end", "of", "the", "program", "." ]
train
https://github.com/ocaballeror/LyricFetch/blob/86e62fb39c4c413ad7e1acf5bf0d28c9ed7c8fcb/lyricfetch/stats.py#L132-L175
thiagopbueno/rddl2tf
rddl2tf/fluentscope.py
TensorFluentScope.broadcast
def broadcast(cls, s1: ParamsList, s2: ParamsList) -> BroadcastTuple: '''It broadcasts the smaller scope over the larger scope. It handles scope intersection as well as differences in scopes in order to output a resulting scope so that input scopes are contained within it (i.e., input s...
python
def broadcast(cls, s1: ParamsList, s2: ParamsList) -> BroadcastTuple: '''It broadcasts the smaller scope over the larger scope. It handles scope intersection as well as differences in scopes in order to output a resulting scope so that input scopes are contained within it (i.e., input s...
[ "def", "broadcast", "(", "cls", ",", "s1", ":", "ParamsList", ",", "s2", ":", "ParamsList", ")", "->", "BroadcastTuple", ":", "if", "len", "(", "s1", ")", "==", "0", ":", "return", "s2", ",", "[", "]", ",", "[", "]", "if", "len", "(", "s2", ")"...
It broadcasts the smaller scope over the larger scope. It handles scope intersection as well as differences in scopes in order to output a resulting scope so that input scopes are contained within it (i.e., input scopes are subscopes of the output scope). Also, if necessary, it outputs ...
[ "It", "broadcasts", "the", "smaller", "scope", "over", "the", "larger", "scope", "." ]
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/fluentscope.py#L68-L137
inodb/sufam
sufam/__main__.py
get_baseparser_extended_df
def get_baseparser_extended_df(sample, bp_lines, ref, alt): """Turn baseParser results into a dataframe""" columns = "chrom\tpos\tref\tcov\tA\tC\tG\tT\t*\t-\t+".split() if bp_lines is None: return None # change baseparser output to get most common maf per indel bpdf = pd.DataFrame([[sample]...
python
def get_baseparser_extended_df(sample, bp_lines, ref, alt): """Turn baseParser results into a dataframe""" columns = "chrom\tpos\tref\tcov\tA\tC\tG\tT\t*\t-\t+".split() if bp_lines is None: return None # change baseparser output to get most common maf per indel bpdf = pd.DataFrame([[sample]...
[ "def", "get_baseparser_extended_df", "(", "sample", ",", "bp_lines", ",", "ref", ",", "alt", ")", ":", "columns", "=", "\"chrom\\tpos\\tref\\tcov\\tA\\tC\\tG\\tT\\t*\\t-\\t+\"", ".", "split", "(", ")", "if", "bp_lines", "is", "None", ":", "return", "None", "# chan...
Turn baseParser results into a dataframe
[ "Turn", "baseParser", "results", "into", "a", "dataframe" ]
train
https://github.com/inodb/sufam/blob/d4e41c5478ca9ba58be44d95106885c096c90a74/sufam/__main__.py#L92-L119
inodb/sufam
sufam/__main__.py
filter_out_mutations_in_normal
def filter_out_mutations_in_normal(tumordf, normaldf, most_common_maf_min=0.2, most_common_count_maf_threshold=20, most_common_count_min=1): """Remove mutations that are in normal""" df = tumordf.merge(normaldf, on=["chrom", "pos"], suffixes=...
python
def filter_out_mutations_in_normal(tumordf, normaldf, most_common_maf_min=0.2, most_common_count_maf_threshold=20, most_common_count_min=1): """Remove mutations that are in normal""" df = tumordf.merge(normaldf, on=["chrom", "pos"], suffixes=...
[ "def", "filter_out_mutations_in_normal", "(", "tumordf", ",", "normaldf", ",", "most_common_maf_min", "=", "0.2", ",", "most_common_count_maf_threshold", "=", "20", ",", "most_common_count_min", "=", "1", ")", ":", "df", "=", "tumordf", ".", "merge", "(", "normald...
Remove mutations that are in normal
[ "Remove", "mutations", "that", "are", "in", "normal" ]
train
https://github.com/inodb/sufam/blob/d4e41c5478ca9ba58be44d95106885c096c90a74/sufam/__main__.py#L122-L144
inodb/sufam
sufam/__main__.py
select_only_revertant_mutations
def select_only_revertant_mutations(bpdf, snv=None, ins=None, dlt=None): """ Selects only mutations that revert the given mutations in a single event. """ if sum([bool(snv), bool(ins), bool(dlt)]) != 1: raise(Exception("Should be either snv, ins or del".format(snv))) if snv: if snv ...
python
def select_only_revertant_mutations(bpdf, snv=None, ins=None, dlt=None): """ Selects only mutations that revert the given mutations in a single event. """ if sum([bool(snv), bool(ins), bool(dlt)]) != 1: raise(Exception("Should be either snv, ins or del".format(snv))) if snv: if snv ...
[ "def", "select_only_revertant_mutations", "(", "bpdf", ",", "snv", "=", "None", ",", "ins", "=", "None", ",", "dlt", "=", "None", ")", ":", "if", "sum", "(", "[", "bool", "(", "snv", ")", ",", "bool", "(", "ins", ")", ",", "bool", "(", "dlt", ")"...
Selects only mutations that revert the given mutations in a single event.
[ "Selects", "only", "mutations", "that", "revert", "the", "given", "mutations", "in", "a", "single", "event", "." ]
train
https://github.com/inodb/sufam/blob/d4e41c5478ca9ba58be44d95106885c096c90a74/sufam/__main__.py#L147-L172
inodb/sufam
sufam/__main__.py
validate_mutations
def validate_mutations(vcffile, bams, reffa, chr_reffa, samples, output_format, outfile, mpileup_parameters=mpileup_parser.MPILEUP_DEFAULT_PARAMS): """Check if mutations in vcf are in bam""" output_header = "sample chrom pos ref cov A C G T * - + " \ "val_ref val_alt val_al_type v...
python
def validate_mutations(vcffile, bams, reffa, chr_reffa, samples, output_format, outfile, mpileup_parameters=mpileup_parser.MPILEUP_DEFAULT_PARAMS): """Check if mutations in vcf are in bam""" output_header = "sample chrom pos ref cov A C G T * - + " \ "val_ref val_alt val_al_type v...
[ "def", "validate_mutations", "(", "vcffile", ",", "bams", ",", "reffa", ",", "chr_reffa", ",", "samples", ",", "output_format", ",", "outfile", ",", "mpileup_parameters", "=", "mpileup_parser", ".", "MPILEUP_DEFAULT_PARAMS", ")", ":", "output_header", "=", "\"samp...
Check if mutations in vcf are in bam
[ "Check", "if", "mutations", "in", "vcf", "are", "in", "bam" ]
train
https://github.com/inodb/sufam/blob/d4e41c5478ca9ba58be44d95106885c096c90a74/sufam/__main__.py#L208-L289
Parsely/redis-fluster
fluster/cluster.py
FlusterCluster._prep_clients
def _prep_clients(self, clients): """Prep a client by tagging it with and id and wrapping methods. Methods are wrapper to catch ConnectionError so that we can remove it from the pool until the instance comes back up. :returns: patched clients """ for pool_id, client in ...
python
def _prep_clients(self, clients): """Prep a client by tagging it with and id and wrapping methods. Methods are wrapper to catch ConnectionError so that we can remove it from the pool until the instance comes back up. :returns: patched clients """ for pool_id, client in ...
[ "def", "_prep_clients", "(", "self", ",", "clients", ")", ":", "for", "pool_id", ",", "client", "in", "enumerate", "(", "clients", ")", ":", "# Tag it with an id we'll use to identify it in the pool", "if", "hasattr", "(", "client", ",", "\"pool_id\"", ")", ":", ...
Prep a client by tagging it with and id and wrapping methods. Methods are wrapper to catch ConnectionError so that we can remove it from the pool until the instance comes back up. :returns: patched clients
[ "Prep", "a", "client", "by", "tagging", "it", "with", "and", "id", "and", "wrapping", "methods", "." ]
train
https://github.com/Parsely/redis-fluster/blob/9fb3ccdc3e0b24906520cac1e933a775e8dfbd99/fluster/cluster.py#L79-L94
Parsely/redis-fluster
fluster/cluster.py
FlusterCluster._wrap_functions
def _wrap_functions(self, client): """Wrap public functions to catch ConnectionError. When an error happens, it puts the client in the penalty box so that it won't be retried again for a little while. """ def wrap(fn): def wrapper(*args, **kwargs): "...
python
def _wrap_functions(self, client): """Wrap public functions to catch ConnectionError. When an error happens, it puts the client in the penalty box so that it won't be retried again for a little while. """ def wrap(fn): def wrapper(*args, **kwargs): "...
[ "def", "_wrap_functions", "(", "self", ",", "client", ")", ":", "def", "wrap", "(", "fn", ")", ":", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "\"\"\"Simple wrapper for to catch dead clients.\"\"\"", "try", ":", "return", "fn", ...
Wrap public functions to catch ConnectionError. When an error happens, it puts the client in the penalty box so that it won't be retried again for a little while.
[ "Wrap", "public", "functions", "to", "catch", "ConnectionError", "." ]
train
https://github.com/Parsely/redis-fluster/blob/9fb3ccdc3e0b24906520cac1e933a775e8dfbd99/fluster/cluster.py#L96-L124
Parsely/redis-fluster
fluster/cluster.py
FlusterCluster._prune_penalty_box
def _prune_penalty_box(self): """Restores clients that have reconnected. This function should be called first for every public method. """ added = False for client in self.penalty_box.get(): log.info("Client %r is back up.", client) self.active_clients.ap...
python
def _prune_penalty_box(self): """Restores clients that have reconnected. This function should be called first for every public method. """ added = False for client in self.penalty_box.get(): log.info("Client %r is back up.", client) self.active_clients.ap...
[ "def", "_prune_penalty_box", "(", "self", ")", ":", "added", "=", "False", "for", "client", "in", "self", ".", "penalty_box", ".", "get", "(", ")", ":", "log", ".", "info", "(", "\"Client %r is back up.\"", ",", "client", ")", "self", ".", "active_clients"...
Restores clients that have reconnected. This function should be called first for every public method.
[ "Restores", "clients", "that", "have", "reconnected", "." ]
train
https://github.com/Parsely/redis-fluster/blob/9fb3ccdc3e0b24906520cac1e933a775e8dfbd99/fluster/cluster.py#L126-L137
Parsely/redis-fluster
fluster/cluster.py
FlusterCluster.get_client
def get_client(self, shard_key): """Get the client for a given shard, based on what's available. If the proper client isn't available, the next available client is returned. If no clients are available, an exception is raised. """ self._prune_penalty_box() if len(self.a...
python
def get_client(self, shard_key): """Get the client for a given shard, based on what's available. If the proper client isn't available, the next available client is returned. If no clients are available, an exception is raised. """ self._prune_penalty_box() if len(self.a...
[ "def", "get_client", "(", "self", ",", "shard_key", ")", ":", "self", ".", "_prune_penalty_box", "(", ")", "if", "len", "(", "self", ".", "active_clients", ")", "==", "0", ":", "raise", "ClusterEmptyError", "(", "\"All clients are down.\"", ")", "# So that has...
Get the client for a given shard, based on what's available. If the proper client isn't available, the next available client is returned. If no clients are available, an exception is raised.
[ "Get", "the", "client", "for", "a", "given", "shard", "based", "on", "what", "s", "available", "." ]
train
https://github.com/Parsely/redis-fluster/blob/9fb3ccdc3e0b24906520cac1e933a775e8dfbd99/fluster/cluster.py#L139-L164
Parsely/redis-fluster
fluster/cluster.py
FlusterCluster._penalize_client
def _penalize_client(self, client): """Place client in the penalty box. :param client: Client object """ if client in self.active_clients: # hasn't been removed yet log.warning("%r marked down.", client) self.active_clients.remove(client) self.penalt...
python
def _penalize_client(self, client): """Place client in the penalty box. :param client: Client object """ if client in self.active_clients: # hasn't been removed yet log.warning("%r marked down.", client) self.active_clients.remove(client) self.penalt...
[ "def", "_penalize_client", "(", "self", ",", "client", ")", ":", "if", "client", "in", "self", ".", "active_clients", ":", "# hasn't been removed yet", "log", ".", "warning", "(", "\"%r marked down.\"", ",", "client", ")", "self", ".", "active_clients", ".", "...
Place client in the penalty box. :param client: Client object
[ "Place", "client", "in", "the", "penalty", "box", "." ]
train
https://github.com/Parsely/redis-fluster/blob/9fb3ccdc3e0b24906520cac1e933a775e8dfbd99/fluster/cluster.py#L166-L176
Parsely/redis-fluster
fluster/cluster.py
FlusterCluster.zrevrange_with_int_score
def zrevrange_with_int_score(self, key, max_score, min_score): """Get the zrevrangebyscore across the cluster. Highest score for duplicate element is returned. A faster method should be written if scores are not needed. """ self._prune_penalty_box() if len(self.active_cl...
python
def zrevrange_with_int_score(self, key, max_score, min_score): """Get the zrevrangebyscore across the cluster. Highest score for duplicate element is returned. A faster method should be written if scores are not needed. """ self._prune_penalty_box() if len(self.active_cl...
[ "def", "zrevrange_with_int_score", "(", "self", ",", "key", ",", "max_score", ",", "min_score", ")", ":", "self", ".", "_prune_penalty_box", "(", ")", "if", "len", "(", "self", ".", "active_clients", ")", "==", "0", ":", "raise", "ClusterEmptyError", "(", ...
Get the zrevrangebyscore across the cluster. Highest score for duplicate element is returned. A faster method should be written if scores are not needed.
[ "Get", "the", "zrevrangebyscore", "across", "the", "cluster", ".", "Highest", "score", "for", "duplicate", "element", "is", "returned", ".", "A", "faster", "method", "should", "be", "written", "if", "scores", "are", "not", "needed", "." ]
train
https://github.com/Parsely/redis-fluster/blob/9fb3ccdc3e0b24906520cac1e933a775e8dfbd99/fluster/cluster.py#L178-L197
alfredodeza/notario
notario/regex.py
chain
def chain(*regexes, **kwargs): """ A helper function to interact with the regular expression engine that compiles and applies partial matches to a string. It expects key value tuples as arguments (any number of them) where the first pair is the regex to compile and the latter is the message to disp...
python
def chain(*regexes, **kwargs): """ A helper function to interact with the regular expression engine that compiles and applies partial matches to a string. It expects key value tuples as arguments (any number of them) where the first pair is the regex to compile and the latter is the message to disp...
[ "def", "chain", "(", "*", "regexes", ",", "*", "*", "kwargs", ")", ":", "prepend_negation", "=", "kwargs", ".", "get", "(", "'prepend_negation'", ",", "True", ")", "return", "Linker", "(", "regexes", ",", "prepend_negation", "=", "prepend_negation", ")" ]
A helper function to interact with the regular expression engine that compiles and applies partial matches to a string. It expects key value tuples as arguments (any number of them) where the first pair is the regex to compile and the latter is the message to display when the regular expression does no...
[ "A", "helper", "function", "to", "interact", "with", "the", "regular", "expression", "engine", "that", "compiles", "and", "applies", "partial", "matches", "to", "a", "string", "." ]
train
https://github.com/alfredodeza/notario/blob/d5dc2edfcb75d9291ced3f2551f368c35dd31475/notario/regex.py#L57-L94
solvebio/solvebio-dash-components
examples/s3_uploader.py
generate_s3_url
def generate_s3_url(files): """Takes files from React side, creates SolveBio Object containing signed S3 URL.""" if files: vault = g.client.Vault.get_personal_vault() files = json.loads(files) objects = [] for i in xrange(len(files)): obj = g.client.Object.create(...
python
def generate_s3_url(files): """Takes files from React side, creates SolveBio Object containing signed S3 URL.""" if files: vault = g.client.Vault.get_personal_vault() files = json.loads(files) objects = [] for i in xrange(len(files)): obj = g.client.Object.create(...
[ "def", "generate_s3_url", "(", "files", ")", ":", "if", "files", ":", "vault", "=", "g", ".", "client", ".", "Vault", ".", "get_personal_vault", "(", ")", "files", "=", "json", ".", "loads", "(", "files", ")", "objects", "=", "[", "]", "for", "i", ...
Takes files from React side, creates SolveBio Object containing signed S3 URL.
[ "Takes", "files", "from", "React", "side", "creates", "SolveBio", "Object", "containing", "signed", "S3", "URL", "." ]
train
https://github.com/solvebio/solvebio-dash-components/blob/07f786379f9bb1bb003cc5727baf85f5ce54ae23/examples/s3_uploader.py#L36-L56
solvebio/solvebio-dash-components
examples/s3_uploader.py
handle_uploaded_files
def handle_uploaded_files(uploaded_files): """Handles downstream processes using metadata about the uploaded files from React side.""" if uploaded_files: uploaded_files = json.loads(uploaded_files)[0] _id = uploaded_files.get('id') # Strip extension from filename _filename = ...
python
def handle_uploaded_files(uploaded_files): """Handles downstream processes using metadata about the uploaded files from React side.""" if uploaded_files: uploaded_files = json.loads(uploaded_files)[0] _id = uploaded_files.get('id') # Strip extension from filename _filename = ...
[ "def", "handle_uploaded_files", "(", "uploaded_files", ")", ":", "if", "uploaded_files", ":", "uploaded_files", "=", "json", ".", "loads", "(", "uploaded_files", ")", "[", "0", "]", "_id", "=", "uploaded_files", ".", "get", "(", "'id'", ")", "# Strip extension...
Handles downstream processes using metadata about the uploaded files from React side.
[ "Handles", "downstream", "processes", "using", "metadata", "about", "the", "uploaded", "files", "from", "React", "side", "." ]
train
https://github.com/solvebio/solvebio-dash-components/blob/07f786379f9bb1bb003cc5727baf85f5ce54ae23/examples/s3_uploader.py#L62-L92
nion-software/nionswift-instrumentation-kit
nionswift_plugin/nion_instrumentation_ui/CameraControlPanel.py
create_camera_panel
def create_camera_panel(document_controller, panel_id, properties): """Create a custom camera panel. The camera panel type is specified in the 'camera_panel_type' key in the properties dict. The camera panel type must match a the 'camera_panel_type' of a camera panel factory in the Registry. The matc...
python
def create_camera_panel(document_controller, panel_id, properties): """Create a custom camera panel. The camera panel type is specified in the 'camera_panel_type' key in the properties dict. The camera panel type must match a the 'camera_panel_type' of a camera panel factory in the Registry. The matc...
[ "def", "create_camera_panel", "(", "document_controller", ",", "panel_id", ",", "properties", ")", ":", "camera_panel_type", "=", "properties", ".", "get", "(", "\"camera_panel_type\"", ")", "for", "component", "in", "Registry", ".", "get_components_by_type", "(", "...
Create a custom camera panel. The camera panel type is specified in the 'camera_panel_type' key in the properties dict. The camera panel type must match a the 'camera_panel_type' of a camera panel factory in the Registry. The matching camera panel factory must return a ui_handler for the panel which is u...
[ "Create", "a", "custom", "camera", "panel", "." ]
train
https://github.com/nion-software/nionswift-instrumentation-kit/blob/b20c4fff17e840e8cb3d544705faf5bd05f1cbf7/nionswift_plugin/nion_instrumentation_ui/CameraControlPanel.py#L849-L869
nion-software/nionswift-instrumentation-kit
nionswift_plugin/nion_instrumentation_ui/CameraControlPanel.py
CameraControlStateController.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.__profile_changed_event_listener = self.__hardware_source.profile_changed_event.listen(self.__update_profile_index) self.__frame_pa...
python
def initialize_state(self): """ Call this to initialize the state of the UI after everything has been connected. """ if self.__hardware_source: self.__profile_changed_event_listener = self.__hardware_source.profile_changed_event.listen(self.__update_profile_index) self.__frame_pa...
[ "def", "initialize_state", "(", "self", ")", ":", "if", "self", ".", "__hardware_source", ":", "self", ".", "__profile_changed_event_listener", "=", "self", ".", "__hardware_source", ".", "profile_changed_event", ".", "listen", "(", "self", ".", "__update_profile_in...
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/CameraControlPanel.py#L221-L242
nion-software/nionswift-instrumentation-kit
nionswift_plugin/nion_instrumentation_ui/CameraControlPanel.py
CameraControlStateController.handle_play_pause_clicked
def handle_play_pause_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_pause_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_pause_clicked", "(", "self", ")", ":", "if", "self", ".", "__hardware_source", ":", "if", "self", ".", "is_playing", ":", "self", ".", "__hardware_source", ".", "stop_playing", "(", ")", "else", ":", "self", ".", "__hardware_source", ".", ...
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/CameraControlPanel.py#L249-L255
jneight/django-earthdistance
django_earthdistance/models.py
LlToEarth.resolve_expression
def resolve_expression(self, query=None, allow_joins=True, reuse=None, summarize=False, for_save=False): """Setup any data here, this method will be called before final SQL is generated""" c = self.copy() c.is_summary = summarize c.for_save = for_save final_points = [] fo...
python
def resolve_expression(self, query=None, allow_joins=True, reuse=None, summarize=False, for_save=False): """Setup any data here, this method will be called before final SQL is generated""" c = self.copy() c.is_summary = summarize c.for_save = for_save final_points = [] fo...
[ "def", "resolve_expression", "(", "self", ",", "query", "=", "None", ",", "allow_joins", "=", "True", ",", "reuse", "=", "None", ",", "summarize", "=", "False", ",", "for_save", "=", "False", ")", ":", "c", "=", "self", ".", "copy", "(", ")", "c", ...
Setup any data here, this method will be called before final SQL is generated
[ "Setup", "any", "data", "here", "this", "method", "will", "be", "called", "before", "final", "SQL", "is", "generated" ]
train
https://github.com/jneight/django-earthdistance/blob/d9e620778a8bb49ae8e73ea161fee3e832f1af77/django_earthdistance/models.py#L20-L37
jneight/django-earthdistance
django_earthdistance/models.py
EarthDistance.resolve_expression
def resolve_expression(self, query=None, allow_joins=True, reuse=None, summarize=False, for_save=False): """Prepare SQL from inner funcions (ll_to_earth or any other)""" c = self.copy() c.is_summary = summarize c.for_save = for_save for pos, expression in enumerate(self.expressio...
python
def resolve_expression(self, query=None, allow_joins=True, reuse=None, summarize=False, for_save=False): """Prepare SQL from inner funcions (ll_to_earth or any other)""" c = self.copy() c.is_summary = summarize c.for_save = for_save for pos, expression in enumerate(self.expressio...
[ "def", "resolve_expression", "(", "self", ",", "query", "=", "None", ",", "allow_joins", "=", "True", ",", "reuse", "=", "None", ",", "summarize", "=", "False", ",", "for_save", "=", "False", ")", ":", "c", "=", "self", ".", "copy", "(", ")", "c", ...
Prepare SQL from inner funcions (ll_to_earth or any other)
[ "Prepare", "SQL", "from", "inner", "funcions", "(", "ll_to_earth", "or", "any", "other", ")" ]
train
https://github.com/jneight/django-earthdistance/blob/d9e620778a8bb49ae8e73ea161fee3e832f1af77/django_earthdistance/models.py#L57-L64
jneight/django-earthdistance
django_earthdistance/models.py
EarthDistanceQuerySet.in_distance
def in_distance(self, distance, fields, points, annotate='_ed_distance'): """Filter rows inside a circunference of radius distance `distance` :param distance: max distance to allow :param fields: `tuple` with the fields to filter (latitude, longitude) :param points: center o...
python
def in_distance(self, distance, fields, points, annotate='_ed_distance'): """Filter rows inside a circunference of radius distance `distance` :param distance: max distance to allow :param fields: `tuple` with the fields to filter (latitude, longitude) :param points: center o...
[ "def", "in_distance", "(", "self", ",", "distance", ",", "fields", ",", "points", ",", "annotate", "=", "'_ed_distance'", ")", ":", "clone", "=", "self", ".", "_clone", "(", ")", "return", "clone", ".", "annotate", "(", "*", "*", "{", "annotate", ":", ...
Filter rows inside a circunference of radius distance `distance` :param distance: max distance to allow :param fields: `tuple` with the fields to filter (latitude, longitude) :param points: center of the circunference (latitude, longitude) :param annotate: name where the...
[ "Filter", "rows", "inside", "a", "circunference", "of", "radius", "distance", "distance" ]
train
https://github.com/jneight/django-earthdistance/blob/d9e620778a8bb49ae8e73ea161fee3e832f1af77/django_earthdistance/models.py#L76-L89
HolmesNL/confidence
confidence/models.py
Configuration.get
def get(self, path, default=_NoDefault, as_type=None, resolve_references=True): """ Gets a value for the specified path. :param path: the configuration key to fetch a value for, steps separated by the separator supplied to the constructor (default ``.``) :param d...
python
def get(self, path, default=_NoDefault, as_type=None, resolve_references=True): """ Gets a value for the specified path. :param path: the configuration key to fetch a value for, steps separated by the separator supplied to the constructor (default ``.``) :param d...
[ "def", "get", "(", "self", ",", "path", ",", "default", "=", "_NoDefault", ",", "as_type", "=", "None", ",", "resolve_references", "=", "True", ")", ":", "value", "=", "self", ".", "_source", "steps_taken", "=", "[", "]", "try", ":", "# walk through the ...
Gets a value for the specified path. :param path: the configuration key to fetch a value for, steps separated by the separator supplied to the constructor (default ``.``) :param default: a value to return if no value is found for the supplied path (``None`` is allowe...
[ "Gets", "a", "value", "for", "the", "specified", "path", "." ]
train
https://github.com/HolmesNL/confidence/blob/e14d2d8769a01fa55676716f7a2f22714c2616d3/confidence/models.py#L113-L161
craigahobbs/chisel
src/chisel/action.py
action
def action(action_callback=None, **kwargs): """ Chisel action decorator """ if action_callback is None: return lambda fn: action(fn, **kwargs) else: return Action(action_callback, **kwargs).decorate_module(action_callback)
python
def action(action_callback=None, **kwargs): """ Chisel action decorator """ if action_callback is None: return lambda fn: action(fn, **kwargs) else: return Action(action_callback, **kwargs).decorate_module(action_callback)
[ "def", "action", "(", "action_callback", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "action_callback", "is", "None", ":", "return", "lambda", "fn", ":", "action", "(", "fn", ",", "*", "*", "kwargs", ")", "else", ":", "return", "Action", "(...
Chisel action decorator
[ "Chisel", "action", "decorator" ]
train
https://github.com/craigahobbs/chisel/blob/d306a9eae2ff757647c6ca1c933bc944efa5c326/src/chisel/action.py#L15-L23
nion-software/nionswift-instrumentation-kit
nion/instrumentation/scan_base.py
ScanHardwareSource.record_async
def record_async(self, callback_fn): """ Call this when the user clicks the record button. """ assert callable(callback_fn) def record_thread(): current_frame_time = self.get_current_frame_time() def handle_finished(xdatas): callback_fn(xdatas) ...
python
def record_async(self, callback_fn): """ Call this when the user clicks the record button. """ assert callable(callback_fn) def record_thread(): current_frame_time = self.get_current_frame_time() def handle_finished(xdatas): callback_fn(xdatas) ...
[ "def", "record_async", "(", "self", ",", "callback_fn", ")", ":", "assert", "callable", "(", "callback_fn", ")", "def", "record_thread", "(", ")", ":", "current_frame_time", "=", "self", ".", "get_current_frame_time", "(", ")", "def", "handle_finished", "(", "...
Call this when the user clicks the record button.
[ "Call", "this", "when", "the", "user", "clicks", "the", "record", "button", "." ]
train
https://github.com/nion-software/nionswift-instrumentation-kit/blob/b20c4fff17e840e8cb3d544705faf5bd05f1cbf7/nion/instrumentation/scan_base.py#L801-L814
nion-software/nionswift-instrumentation-kit
nion/instrumentation/scan_base.py
ScanHardwareSource.get_buffer_data
def get_buffer_data(self, start: int, count: int) -> typing.Optional[typing.List[typing.List[typing.Dict]]]: """Get recently acquired (buffered) data. The start parameter can be negative to index backwards from the end. If start refers to a buffer item that doesn't exist or if count requests t...
python
def get_buffer_data(self, start: int, count: int) -> typing.Optional[typing.List[typing.List[typing.Dict]]]: """Get recently acquired (buffered) data. The start parameter can be negative to index backwards from the end. If start refers to a buffer item that doesn't exist or if count requests t...
[ "def", "get_buffer_data", "(", "self", ",", "start", ":", "int", ",", "count", ":", "int", ")", "->", "typing", ".", "Optional", "[", "typing", ".", "List", "[", "typing", ".", "List", "[", "typing", ".", "Dict", "]", "]", "]", ":", "if", "hasattr"...
Get recently acquired (buffered) data. The start parameter can be negative to index backwards from the end. If start refers to a buffer item that doesn't exist or if count requests too many buffer items given the start value, the returned list may have fewer elements than count. Retur...
[ "Get", "recently", "acquired", "(", "buffered", ")", "data", "." ]
train
https://github.com/nion-software/nionswift-instrumentation-kit/blob/b20c4fff17e840e8cb3d544705faf5bd05f1cbf7/nion/instrumentation/scan_base.py#L910-L946
tipsi/tipsi_tools
tipsi_tools/tipsi_logging.py
get_plain_logname
def get_plain_logname(base_name, root_dir, enable_json): """ we nest all plain logs to prevent double log shipping """ if enable_json: nested_dir = os.path.join(root_dir, 'plain') if os.path.exists(root_dir) and not os.path.exists(nested_dir): os.mkdir(nested_dir) roo...
python
def get_plain_logname(base_name, root_dir, enable_json): """ we nest all plain logs to prevent double log shipping """ if enable_json: nested_dir = os.path.join(root_dir, 'plain') if os.path.exists(root_dir) and not os.path.exists(nested_dir): os.mkdir(nested_dir) roo...
[ "def", "get_plain_logname", "(", "base_name", ",", "root_dir", ",", "enable_json", ")", ":", "if", "enable_json", ":", "nested_dir", "=", "os", ".", "path", ".", "join", "(", "root_dir", ",", "'plain'", ")", "if", "os", ".", "path", ".", "exists", "(", ...
we nest all plain logs to prevent double log shipping
[ "we", "nest", "all", "plain", "logs", "to", "prevent", "double", "log", "shipping" ]
train
https://github.com/tipsi/tipsi_tools/blob/1aba960c9890ceef2fb5e215b98b1646056ee58e/tipsi_tools/tipsi_logging.py#L50-L59
tipsi/tipsi_tools
tipsi_tools/tipsi_logging.py
setup_logger
def setup_logger( base_name, root_dir=None, enable_json=True, json_formatter='tipsi_tools.tipsi_logging.JSFormatter', loggers={}, ): """ json_formatter: 'fan.contrib.django.span_formatter.SpanFormatter' - add INSTALLATION_ID, SPAN and etc """ if not root_dir: root_dir = o...
python
def setup_logger( base_name, root_dir=None, enable_json=True, json_formatter='tipsi_tools.tipsi_logging.JSFormatter', loggers={}, ): """ json_formatter: 'fan.contrib.django.span_formatter.SpanFormatter' - add INSTALLATION_ID, SPAN and etc """ if not root_dir: root_dir = o...
[ "def", "setup_logger", "(", "base_name", ",", "root_dir", "=", "None", ",", "enable_json", "=", "True", ",", "json_formatter", "=", "'tipsi_tools.tipsi_logging.JSFormatter'", ",", "loggers", "=", "{", "}", ",", ")", ":", "if", "not", "root_dir", ":", "root_dir...
json_formatter: 'fan.contrib.django.span_formatter.SpanFormatter' - add INSTALLATION_ID, SPAN and etc
[ "json_formatter", ":", "fan", ".", "contrib", ".", "django", ".", "span_formatter", ".", "SpanFormatter", "-", "add", "INSTALLATION_ID", "SPAN", "and", "etc" ]
train
https://github.com/tipsi/tipsi_tools/blob/1aba960c9890ceef2fb5e215b98b1646056ee58e/tipsi_tools/tipsi_logging.py#L62-L106
tipsi/tipsi_tools
tipsi_tools/unix.py
run
def run(command): ''' Run command in shell, accepts command construction from list Return (return_code, stdout, stderr) stdout and stderr - as list of strings ''' if isinstance(command, list): command = ' '.join(command) out = subprocess.run(command, shell=True, stdout=subprocess.PIP...
python
def run(command): ''' Run command in shell, accepts command construction from list Return (return_code, stdout, stderr) stdout and stderr - as list of strings ''' if isinstance(command, list): command = ' '.join(command) out = subprocess.run(command, shell=True, stdout=subprocess.PIP...
[ "def", "run", "(", "command", ")", ":", "if", "isinstance", "(", "command", ",", "list", ")", ":", "command", "=", "' '", ".", "join", "(", "command", ")", "out", "=", "subprocess", ".", "run", "(", "command", ",", "shell", "=", "True", ",", "stdou...
Run command in shell, accepts command construction from list Return (return_code, stdout, stderr) stdout and stderr - as list of strings
[ "Run", "command", "in", "shell", "accepts", "command", "construction", "from", "list", "Return", "(", "return_code", "stdout", "stderr", ")", "stdout", "and", "stderr", "-", "as", "list", "of", "strings" ]
train
https://github.com/tipsi/tipsi_tools/blob/1aba960c9890ceef2fb5e215b98b1646056ee58e/tipsi_tools/unix.py#L22-L31
tipsi/tipsi_tools
tipsi_tools/unix.py
succ
def succ(cmd, check_stderr=True, stdout=None, stderr=None): ''' Alias to run with check return code and stderr ''' code, out, err = run(cmd) # Because we're raising error, sometimes we want to process stdout/stderr after catching error # so we're copying these outputs if required if stdout ...
python
def succ(cmd, check_stderr=True, stdout=None, stderr=None): ''' Alias to run with check return code and stderr ''' code, out, err = run(cmd) # Because we're raising error, sometimes we want to process stdout/stderr after catching error # so we're copying these outputs if required if stdout ...
[ "def", "succ", "(", "cmd", ",", "check_stderr", "=", "True", ",", "stdout", "=", "None", ",", "stderr", "=", "None", ")", ":", "code", ",", "out", ",", "err", "=", "run", "(", "cmd", ")", "# Because we're raising error, sometimes we want to process stdout/stde...
Alias to run with check return code and stderr
[ "Alias", "to", "run", "with", "check", "return", "code", "and", "stderr" ]
train
https://github.com/tipsi/tipsi_tools/blob/1aba960c9890ceef2fb5e215b98b1646056ee58e/tipsi_tools/unix.py#L34-L53
tipsi/tipsi_tools
tipsi_tools/unix.py
wait_socket
def wait_socket(host, port, timeout=120): ''' Wait for socket opened on remote side. Return False after timeout ''' return wait_result(lambda: check_socket(host, port), True, timeout)
python
def wait_socket(host, port, timeout=120): ''' Wait for socket opened on remote side. Return False after timeout ''' return wait_result(lambda: check_socket(host, port), True, timeout)
[ "def", "wait_socket", "(", "host", ",", "port", ",", "timeout", "=", "120", ")", ":", "return", "wait_result", "(", "lambda", ":", "check_socket", "(", "host", ",", "port", ")", ",", "True", ",", "timeout", ")" ]
Wait for socket opened on remote side. Return False after timeout
[ "Wait", "for", "socket", "opened", "on", "remote", "side", ".", "Return", "False", "after", "timeout" ]
train
https://github.com/tipsi/tipsi_tools/blob/1aba960c9890ceef2fb5e215b98b1646056ee58e/tipsi_tools/unix.py#L132-L136
tipsi/tipsi_tools
tipsi_tools/unix.py
interpolate_sysenv
def interpolate_sysenv(line, defaults={}): ''' Format line system environment variables + defaults ''' map = ChainMap(os.environ, defaults) return line.format(**map)
python
def interpolate_sysenv(line, defaults={}): ''' Format line system environment variables + defaults ''' map = ChainMap(os.environ, defaults) return line.format(**map)
[ "def", "interpolate_sysenv", "(", "line", ",", "defaults", "=", "{", "}", ")", ":", "map", "=", "ChainMap", "(", "os", ".", "environ", ",", "defaults", ")", "return", "line", ".", "format", "(", "*", "*", "map", ")" ]
Format line system environment variables + defaults
[ "Format", "line", "system", "environment", "variables", "+", "defaults" ]
train
https://github.com/tipsi/tipsi_tools/blob/1aba960c9890ceef2fb5e215b98b1646056ee58e/tipsi_tools/unix.py#L143-L148
tipsi/tipsi_tools
tipsi_tools/unix.py
source
def source(fname): ''' Acts similar to bash 'source' or '.' commands. ''' rex = re.compile('(?:export |declare -x )?(.*?)="(.*?)"') out = call_out('source {} && export'.format(fname)) out = [x for x in out if 'export' in x or 'declare' in x] out = {k: v for k, v in [rex.match(x).groups() for...
python
def source(fname): ''' Acts similar to bash 'source' or '.' commands. ''' rex = re.compile('(?:export |declare -x )?(.*?)="(.*?)"') out = call_out('source {} && export'.format(fname)) out = [x for x in out if 'export' in x or 'declare' in x] out = {k: v for k, v in [rex.match(x).groups() for...
[ "def", "source", "(", "fname", ")", ":", "rex", "=", "re", ".", "compile", "(", "'(?:export |declare -x )?(.*?)=\"(.*?)\"'", ")", "out", "=", "call_out", "(", "'source {} && export'", ".", "format", "(", "fname", ")", ")", "out", "=", "[", "x", "for", "x",...
Acts similar to bash 'source' or '.' commands.
[ "Acts", "similar", "to", "bash", "source", "or", ".", "commands", "." ]
train
https://github.com/tipsi/tipsi_tools/blob/1aba960c9890ceef2fb5e215b98b1646056ee58e/tipsi_tools/unix.py#L151-L160
tipsi/tipsi_tools
tipsi_tools/unix.py
cd
def cd(dir_name): """ do something in other directory and return back after block ended """ old_path = os.path.abspath('.') os.chdir(dir_name) try: yield os.chdir(old_path) except Exception: os.chdir(old_path) raise
python
def cd(dir_name): """ do something in other directory and return back after block ended """ old_path = os.path.abspath('.') os.chdir(dir_name) try: yield os.chdir(old_path) except Exception: os.chdir(old_path) raise
[ "def", "cd", "(", "dir_name", ")", ":", "old_path", "=", "os", ".", "path", ".", "abspath", "(", "'.'", ")", "os", ".", "chdir", "(", "dir_name", ")", "try", ":", "yield", "os", ".", "chdir", "(", "old_path", ")", "except", "Exception", ":", "os", ...
do something in other directory and return back after block ended
[ "do", "something", "in", "other", "directory", "and", "return", "back", "after", "block", "ended" ]
train
https://github.com/tipsi/tipsi_tools/blob/1aba960c9890ceef2fb5e215b98b1646056ee58e/tipsi_tools/unix.py#L164-L175
non-Jedi/gyr
gyr/resources.py
Resource._is_new
def _is_new(self, identifier): """Returns True if identifier hasn't been seen before.""" if identifier in self.tracker: return False else: self.tracker.append(identifier) self.tracker.pop(0) return True
python
def _is_new(self, identifier): """Returns True if identifier hasn't been seen before.""" if identifier in self.tracker: return False else: self.tracker.append(identifier) self.tracker.pop(0) return True
[ "def", "_is_new", "(", "self", ",", "identifier", ")", ":", "if", "identifier", "in", "self", ".", "tracker", ":", "return", "False", "else", ":", "self", ".", "tracker", ".", "append", "(", "identifier", ")", "self", ".", "tracker", ".", "pop", "(", ...
Returns True if identifier hasn't been seen before.
[ "Returns", "True", "if", "identifier", "hasn", "t", "been", "seen", "before", "." ]
train
https://github.com/non-Jedi/gyr/blob/9f7bfe033b9d3bbfd3a9e8aea02e35526b53125e/gyr/resources.py#L35-L42
non-Jedi/gyr
gyr/resources.py
Room.on_get
def on_get(self, request, response, room_alias=None): """Called when a GET request is sent to /rooms/{room_alias}""" response.body = "{}" if self.handler(room_alias): response.status = falcon.HTTP_200 self.api.create_room(alias=room_alias) else: respon...
python
def on_get(self, request, response, room_alias=None): """Called when a GET request is sent to /rooms/{room_alias}""" response.body = "{}" if self.handler(room_alias): response.status = falcon.HTTP_200 self.api.create_room(alias=room_alias) else: respon...
[ "def", "on_get", "(", "self", ",", "request", ",", "response", ",", "room_alias", "=", "None", ")", ":", "response", ".", "body", "=", "\"{}\"", "if", "self", ".", "handler", "(", "room_alias", ")", ":", "response", ".", "status", "=", "falcon", ".", ...
Called when a GET request is sent to /rooms/{room_alias}
[ "Called", "when", "a", "GET", "request", "is", "sent", "to", "/", "rooms", "/", "{", "room_alias", "}" ]
train
https://github.com/non-Jedi/gyr/blob/9f7bfe033b9d3bbfd3a9e8aea02e35526b53125e/gyr/resources.py#L48-L55
non-Jedi/gyr
gyr/resources.py
Transaction.on_put
def on_put(self, request, response, txn_id=None): """Responds to PUT request containing events.""" response.body = "{}" # Check whether repeat txn_id if not self._is_new(txn_id): response.status = falcon.HTTP_200 return request.context["body"] = request....
python
def on_put(self, request, response, txn_id=None): """Responds to PUT request containing events.""" response.body = "{}" # Check whether repeat txn_id if not self._is_new(txn_id): response.status = falcon.HTTP_200 return request.context["body"] = request....
[ "def", "on_put", "(", "self", ",", "request", ",", "response", ",", "txn_id", "=", "None", ")", ":", "response", ".", "body", "=", "\"{}\"", "# Check whether repeat txn_id", "if", "not", "self", ".", "_is_new", "(", "txn_id", ")", ":", "response", ".", "...
Responds to PUT request containing events.
[ "Responds", "to", "PUT", "request", "containing", "events", "." ]
train
https://github.com/non-Jedi/gyr/blob/9f7bfe033b9d3bbfd3a9e8aea02e35526b53125e/gyr/resources.py#L61-L81
non-Jedi/gyr
gyr/resources.py
User.on_get
def on_get(self, request, response, user_id=None): """Responds to GET request for users.""" response.body = "{}" if self.handler(user_id): response.status = falcon.HTTP_200 self.api.register(utils.mxid2localpart(user_id)) else: response.status = falcon...
python
def on_get(self, request, response, user_id=None): """Responds to GET request for users.""" response.body = "{}" if self.handler(user_id): response.status = falcon.HTTP_200 self.api.register(utils.mxid2localpart(user_id)) else: response.status = falcon...
[ "def", "on_get", "(", "self", ",", "request", ",", "response", ",", "user_id", "=", "None", ")", ":", "response", ".", "body", "=", "\"{}\"", "if", "self", ".", "handler", "(", "user_id", ")", ":", "response", ".", "status", "=", "falcon", ".", "HTTP...
Responds to GET request for users.
[ "Responds", "to", "GET", "request", "for", "users", "." ]
train
https://github.com/non-Jedi/gyr/blob/9f7bfe033b9d3bbfd3a9e8aea02e35526b53125e/gyr/resources.py#L87-L94
nion-software/nionswift-instrumentation-kit
nion/instrumentation/camera_base.py
CameraSettings.set_frame_parameters
def set_frame_parameters(self, profile_index: int, frame_parameters) -> None: """Set the frame parameters with the settings index and fire the frame parameters changed event. If the settings index matches the current settings index, call set current frame parameters. If the settings index matc...
python
def set_frame_parameters(self, profile_index: int, frame_parameters) -> None: """Set the frame parameters with the settings index and fire the frame parameters changed event. If the settings index matches the current settings index, call set current frame parameters. If the settings index matc...
[ "def", "set_frame_parameters", "(", "self", ",", "profile_index", ":", "int", ",", "frame_parameters", ")", "->", "None", ":", "self", ".", "frame_parameters_changed_event", ".", "fire", "(", "profile_index", ",", "frame_parameters", ")" ]
Set the frame parameters with the settings index and fire the frame parameters changed event. If the settings index matches the current settings index, call set current frame parameters. If the settings index matches the record settings index, call set record frame parameters.
[ "Set", "the", "frame", "parameters", "with", "the", "settings", "index", "and", "fire", "the", "frame", "parameters", "changed", "event", "." ]
train
https://github.com/nion-software/nionswift-instrumentation-kit/blob/b20c4fff17e840e8cb3d544705faf5bd05f1cbf7/nion/instrumentation/camera_base.py#L504-L511