repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 3
values | summary stringlengths 4 350 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
contains-io/typet | typet/validation.py | _BoundedMeta._instantiate | def _instantiate(class_, type_, __value, *args, **kwargs):
"""Instantiate the object if possible.
Args:
class_: The class to instantiate.
type_: The the class is uninstantiable, attempt to cast to a base
type.
__value: The value to return if the class... | python | def _instantiate(class_, type_, __value, *args, **kwargs):
"""Instantiate the object if possible.
Args:
class_: The class to instantiate.
type_: The the class is uninstantiable, attempt to cast to a base
type.
__value: The value to return if the class... | [
"def",
"_instantiate",
"(",
"class_",
",",
"type_",
",",
"__value",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"return",
"class_",
"(",
"__value",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"except",
"TypeError",
":",
"tr... | Instantiate the object if possible.
Args:
class_: The class to instantiate.
type_: The the class is uninstantiable, attempt to cast to a base
type.
__value: The value to return if the class and type are
uninstantiable.
*args: The p... | [
"Instantiate",
"the",
"object",
"if",
"possible",
"."
] | ad5087c567af84db299eca186776e1cee228e442 | https://github.com/contains-io/typet/blob/ad5087c567af84db299eca186776e1cee228e442/typet/validation.py#L183-L205 | train | Instantiate the object if possible. |
contains-io/typet | typet/validation.py | _BoundedMeta._get_class_repr | def _get_class_repr(cls, type_, bound, keyfunc, keyfunc_name):
# type: (Any, slice, Callable, str) -> str
"""Return a class representation using the slice parameters.
Args:
type_: The type the class was sliced with.
bound: The boundaries specified for the values of type_... | python | def _get_class_repr(cls, type_, bound, keyfunc, keyfunc_name):
# type: (Any, slice, Callable, str) -> str
"""Return a class representation using the slice parameters.
Args:
type_: The type the class was sliced with.
bound: The boundaries specified for the values of type_... | [
"def",
"_get_class_repr",
"(",
"cls",
",",
"type_",
",",
"bound",
",",
"keyfunc",
",",
"keyfunc_name",
")",
":",
"# type: (Any, slice, Callable, str) -> str",
"if",
"keyfunc",
"is",
"not",
"cls",
".",
"_default",
":",
"return",
"\"{}.{}[{}, {}, {}]\"",
".",
"forma... | Return a class representation using the slice parameters.
Args:
type_: The type the class was sliced with.
bound: The boundaries specified for the values of type_.
keyfunc: The comparison function used to check the value
boundaries.
keyfunc_name: ... | [
"Return",
"a",
"class",
"representation",
"using",
"the",
"slice",
"parameters",
"."
] | ad5087c567af84db299eca186776e1cee228e442 | https://github.com/contains-io/typet/blob/ad5087c567af84db299eca186776e1cee228e442/typet/validation.py#L207-L234 | train | Return a string representation of the class using the slice parameters. |
contains-io/typet | typet/validation.py | _BoundedMeta._get_args | def _get_args(cls, args):
# type: (tuple) -> Tuple[Any, slice, Callable]
"""Return the parameters necessary to check type boundaries.
Args:
args: A tuple with two or three elements: a type, a slice
representing the minimum and maximum lengths allowed for values
... | python | def _get_args(cls, args):
# type: (tuple) -> Tuple[Any, slice, Callable]
"""Return the parameters necessary to check type boundaries.
Args:
args: A tuple with two or three elements: a type, a slice
representing the minimum and maximum lengths allowed for values
... | [
"def",
"_get_args",
"(",
"cls",
",",
"args",
")",
":",
"# type: (tuple) -> Tuple[Any, slice, Callable]",
"if",
"not",
"isinstance",
"(",
"args",
",",
"tuple",
")",
":",
"raise",
"TypeError",
"(",
"\"{}[...] takes two or three arguments.\"",
".",
"format",
"(",
"cls"... | Return the parameters necessary to check type boundaries.
Args:
args: A tuple with two or three elements: a type, a slice
representing the minimum and maximum lengths allowed for values
of that type and, optionally, a function to use on values
before ... | [
"Return",
"the",
"parameters",
"necessary",
"to",
"check",
"type",
"boundaries",
"."
] | ad5087c567af84db299eca186776e1cee228e442 | https://github.com/contains-io/typet/blob/ad5087c567af84db299eca186776e1cee228e442/typet/validation.py#L236-L266 | train | Returns the parameters needed to check type boundaries. |
contains-io/typet | typet/validation.py | _BoundedMeta._get_fullname | def _get_fullname(obj):
# type: (Any) -> str
"""Get the full name of an object including the module.
Args:
obj: An object.
Returns:
The full class name of the object.
"""
if not hasattr(obj, "__name__"):
obj = obj.__class__
if... | python | def _get_fullname(obj):
# type: (Any) -> str
"""Get the full name of an object including the module.
Args:
obj: An object.
Returns:
The full class name of the object.
"""
if not hasattr(obj, "__name__"):
obj = obj.__class__
if... | [
"def",
"_get_fullname",
"(",
"obj",
")",
":",
"# type: (Any) -> str",
"if",
"not",
"hasattr",
"(",
"obj",
",",
"\"__name__\"",
")",
":",
"obj",
"=",
"obj",
".",
"__class__",
"if",
"obj",
".",
"__module__",
"in",
"(",
"\"builtins\"",
",",
"\"__builtin__\"",
... | Get the full name of an object including the module.
Args:
obj: An object.
Returns:
The full class name of the object. | [
"Get",
"the",
"full",
"name",
"of",
"an",
"object",
"including",
"the",
"module",
"."
] | ad5087c567af84db299eca186776e1cee228e442 | https://github.com/contains-io/typet/blob/ad5087c567af84db299eca186776e1cee228e442/typet/validation.py#L297-L311 | train | Get the full name of an object including the module. |
contains-io/typet | typet/validation.py | _LengthBoundedMeta._get_args | def _get_args(cls, args):
# type: (tuple) -> Tuple[type, slice, Callable]
"""Return the parameters necessary to check type boundaries.
Args:
args: A tuple with two parameters: a type, and a slice representing
the minimum and maximum lengths allowed for values of that... | python | def _get_args(cls, args):
# type: (tuple) -> Tuple[type, slice, Callable]
"""Return the parameters necessary to check type boundaries.
Args:
args: A tuple with two parameters: a type, and a slice representing
the minimum and maximum lengths allowed for values of that... | [
"def",
"_get_args",
"(",
"cls",
",",
"args",
")",
":",
"# type: (tuple) -> Tuple[type, slice, Callable]",
"if",
"not",
"isinstance",
"(",
"args",
",",
"tuple",
")",
"or",
"not",
"len",
"(",
"args",
")",
"==",
"2",
":",
"raise",
"TypeError",
"(",
"\"{}[...] t... | Return the parameters necessary to check type boundaries.
Args:
args: A tuple with two parameters: a type, and a slice representing
the minimum and maximum lengths allowed for values of that
type.
Returns:
A tuple with three parameters: a type, a... | [
"Return",
"the",
"parameters",
"necessary",
"to",
"check",
"type",
"boundaries",
"."
] | ad5087c567af84db299eca186776e1cee228e442 | https://github.com/contains-io/typet/blob/ad5087c567af84db299eca186776e1cee228e442/typet/validation.py#L343-L360 | train | Return the parameters needed to check type boundaries. |
contains-io/typet | typet/validation.py | _ValidationBoundedMeta._get_args | def _get_args(cls, args):
# type: (tuple) -> Tuple[type, slice, Callable]
"""Return the parameters necessary to check type boundaries.
Args:
args: A tuple with one or two parameters: A type to cast the
value passed, and a predicate function to use for bounds
... | python | def _get_args(cls, args):
# type: (tuple) -> Tuple[type, slice, Callable]
"""Return the parameters necessary to check type boundaries.
Args:
args: A tuple with one or two parameters: A type to cast the
value passed, and a predicate function to use for bounds
... | [
"def",
"_get_args",
"(",
"cls",
",",
"args",
")",
":",
"# type: (tuple) -> Tuple[type, slice, Callable]",
"if",
"isinstance",
"(",
"args",
",",
"tuple",
")",
":",
"if",
"not",
"len",
"(",
"args",
")",
"==",
"2",
":",
"raise",
"TypeError",
"(",
"\"{}[...] tak... | Return the parameters necessary to check type boundaries.
Args:
args: A tuple with one or two parameters: A type to cast the
value passed, and a predicate function to use for bounds
checking.
Returns:
A tuple with three parameters: a type, a slic... | [
"Return",
"the",
"parameters",
"necessary",
"to",
"check",
"type",
"boundaries",
"."
] | ad5087c567af84db299eca186776e1cee228e442 | https://github.com/contains-io/typet/blob/ad5087c567af84db299eca186776e1cee228e442/typet/validation.py#L386-L407 | train | Return the parameters needed to check type boundaries. |
contains-io/typet | typet/validation.py | _ValidationBoundedMeta._get_class_repr | def _get_class_repr(cls, type_, bound, keyfunc, keyfunc_name):
# type: (Any, slice, Callable, str) -> str
"""Return a class representation using the slice parameters.
Args:
type_: The type the class was sliced with.
bound: The boundaries specified for the values of type_... | python | def _get_class_repr(cls, type_, bound, keyfunc, keyfunc_name):
# type: (Any, slice, Callable, str) -> str
"""Return a class representation using the slice parameters.
Args:
type_: The type the class was sliced with.
bound: The boundaries specified for the values of type_... | [
"def",
"_get_class_repr",
"(",
"cls",
",",
"type_",
",",
"bound",
",",
"keyfunc",
",",
"keyfunc_name",
")",
":",
"# type: (Any, slice, Callable, str) -> str",
"if",
"type_",
"is",
"not",
"Any",
":",
"return",
"\"{}.{}[{}, {}]\"",
".",
"format",
"(",
"cls",
".",
... | Return a class representation using the slice parameters.
Args:
type_: The type the class was sliced with.
bound: The boundaries specified for the values of type_.
keyfunc: The comparison function used to check the value
boundaries.
keyfunc_name: ... | [
"Return",
"a",
"class",
"representation",
"using",
"the",
"slice",
"parameters",
"."
] | ad5087c567af84db299eca186776e1cee228e442 | https://github.com/contains-io/typet/blob/ad5087c567af84db299eca186776e1cee228e442/typet/validation.py#L409-L430 | train | Return a string representation of the class. |
contains-io/typet | typet/validation.py | _StringMeta._get_args | def _get_args(cls, args):
# type: (tuple) -> Tuple[type, slice, Callable]
"""Return the parameters necessary to check type boundaries.
Args:
args: A slice representing the minimum and maximum lengths allowed
for values of that string.
Returns:
A ... | python | def _get_args(cls, args):
# type: (tuple) -> Tuple[type, slice, Callable]
"""Return the parameters necessary to check type boundaries.
Args:
args: A slice representing the minimum and maximum lengths allowed
for values of that string.
Returns:
A ... | [
"def",
"_get_args",
"(",
"cls",
",",
"args",
")",
":",
"# type: (tuple) -> Tuple[type, slice, Callable]",
"if",
"isinstance",
"(",
"args",
",",
"tuple",
")",
":",
"raise",
"TypeError",
"(",
"\"{}[...] takes exactly one argument.\"",
".",
"format",
"(",
"cls",
".",
... | Return the parameters necessary to check type boundaries.
Args:
args: A slice representing the minimum and maximum lengths allowed
for values of that string.
Returns:
A tuple with three parameters: a type, a slice, and the len
function. | [
"Return",
"the",
"parameters",
"necessary",
"to",
"check",
"type",
"boundaries",
"."
] | ad5087c567af84db299eca186776e1cee228e442 | https://github.com/contains-io/typet/blob/ad5087c567af84db299eca186776e1cee228e442/typet/validation.py#L462-L478 | train | Return the parameters necessary to check type boundaries. |
contains-io/typet | typet/validation.py | _StringMeta._get_class_repr | def _get_class_repr(cls, type_, bound, keyfunc, keyfunc_name):
# type: (Any, slice, Callable, str) -> str
"""Return a class representation using the slice parameters.
Args:
type_: The type the class was sliced with. This will always be
_STR_TYPE.
bound: T... | python | def _get_class_repr(cls, type_, bound, keyfunc, keyfunc_name):
# type: (Any, slice, Callable, str) -> str
"""Return a class representation using the slice parameters.
Args:
type_: The type the class was sliced with. This will always be
_STR_TYPE.
bound: T... | [
"def",
"_get_class_repr",
"(",
"cls",
",",
"type_",
",",
"bound",
",",
"keyfunc",
",",
"keyfunc_name",
")",
":",
"# type: (Any, slice, Callable, str) -> str",
"return",
"\"{}.{}[{}]\"",
".",
"format",
"(",
"cls",
".",
"__module__",
",",
"cls",
".",
"__name__",
"... | Return a class representation using the slice parameters.
Args:
type_: The type the class was sliced with. This will always be
_STR_TYPE.
bound: The boundaries specified for the values of type_.
keyfunc: The comparison function used to check the value
... | [
"Return",
"a",
"class",
"representation",
"using",
"the",
"slice",
"parameters",
"."
] | ad5087c567af84db299eca186776e1cee228e442 | https://github.com/contains-io/typet/blob/ad5087c567af84db299eca186776e1cee228e442/typet/validation.py#L480-L497 | train | Return a string representation of the class. |
sublee/etc | etc/client.py | Client.get | def get(self, key, recursive=False, sorted=False, quorum=False,
timeout=None):
"""Gets a value of key."""
return self.adapter.get(key, recursive=recursive, sorted=sorted,
quorum=quorum, timeout=timeout) | python | def get(self, key, recursive=False, sorted=False, quorum=False,
timeout=None):
"""Gets a value of key."""
return self.adapter.get(key, recursive=recursive, sorted=sorted,
quorum=quorum, timeout=timeout) | [
"def",
"get",
"(",
"self",
",",
"key",
",",
"recursive",
"=",
"False",
",",
"sorted",
"=",
"False",
",",
"quorum",
"=",
"False",
",",
"timeout",
"=",
"None",
")",
":",
"return",
"self",
".",
"adapter",
".",
"get",
"(",
"key",
",",
"recursive",
"=",... | Gets a value of key. | [
"Gets",
"a",
"value",
"of",
"key",
"."
] | f2be64604da5af0d7739cfacf36f55712f0fc5cb | https://github.com/sublee/etc/blob/f2be64604da5af0d7739cfacf36f55712f0fc5cb/etc/client.py#L29-L33 | train | Gets a value of a key. |
sublee/etc | etc/client.py | Client.wait | def wait(self, key, index=0, recursive=False, sorted=False, quorum=False,
timeout=None):
"""Waits until a node changes."""
return self.adapter.get(key, recursive=recursive, sorted=sorted,
quorum=quorum, wait=True, wait_index=index,
... | python | def wait(self, key, index=0, recursive=False, sorted=False, quorum=False,
timeout=None):
"""Waits until a node changes."""
return self.adapter.get(key, recursive=recursive, sorted=sorted,
quorum=quorum, wait=True, wait_index=index,
... | [
"def",
"wait",
"(",
"self",
",",
"key",
",",
"index",
"=",
"0",
",",
"recursive",
"=",
"False",
",",
"sorted",
"=",
"False",
",",
"quorum",
"=",
"False",
",",
"timeout",
"=",
"None",
")",
":",
"return",
"self",
".",
"adapter",
".",
"get",
"(",
"k... | Waits until a node changes. | [
"Waits",
"until",
"a",
"node",
"changes",
"."
] | f2be64604da5af0d7739cfacf36f55712f0fc5cb | https://github.com/sublee/etc/blob/f2be64604da5af0d7739cfacf36f55712f0fc5cb/etc/client.py#L35-L40 | train | Waits until a node changes. |
sublee/etc | etc/client.py | Client.refresh | def refresh(self, key, ttl, prev_value=None, prev_index=None,
timeout=None):
"""Sets only a TTL of a key. The waiters doesn't receive notification
by this operation.
"""
return self.adapter.set(key, ttl=ttl, refresh=True,
prev_value=prev_v... | python | def refresh(self, key, ttl, prev_value=None, prev_index=None,
timeout=None):
"""Sets only a TTL of a key. The waiters doesn't receive notification
by this operation.
"""
return self.adapter.set(key, ttl=ttl, refresh=True,
prev_value=prev_v... | [
"def",
"refresh",
"(",
"self",
",",
"key",
",",
"ttl",
",",
"prev_value",
"=",
"None",
",",
"prev_index",
"=",
"None",
",",
"timeout",
"=",
"None",
")",
":",
"return",
"self",
".",
"adapter",
".",
"set",
"(",
"key",
",",
"ttl",
"=",
"ttl",
",",
"... | Sets only a TTL of a key. The waiters doesn't receive notification
by this operation. | [
"Sets",
"only",
"a",
"TTL",
"of",
"a",
"key",
".",
"The",
"waiters",
"doesn",
"t",
"receive",
"notification",
"by",
"this",
"operation",
"."
] | f2be64604da5af0d7739cfacf36f55712f0fc5cb | https://github.com/sublee/etc/blob/f2be64604da5af0d7739cfacf36f55712f0fc5cb/etc/client.py#L49-L56 | train | Refreshes the TTL of a key. |
sublee/etc | etc/client.py | Client.create | def create(self, key, value=None, dir=False, ttl=None, timeout=None):
"""Creates a new key."""
return self.adapter.set(key, value, dir=dir, ttl=ttl,
prev_exist=False, timeout=timeout) | python | def create(self, key, value=None, dir=False, ttl=None, timeout=None):
"""Creates a new key."""
return self.adapter.set(key, value, dir=dir, ttl=ttl,
prev_exist=False, timeout=timeout) | [
"def",
"create",
"(",
"self",
",",
"key",
",",
"value",
"=",
"None",
",",
"dir",
"=",
"False",
",",
"ttl",
"=",
"None",
",",
"timeout",
"=",
"None",
")",
":",
"return",
"self",
".",
"adapter",
".",
"set",
"(",
"key",
",",
"value",
",",
"dir",
"... | Creates a new key. | [
"Creates",
"a",
"new",
"key",
"."
] | f2be64604da5af0d7739cfacf36f55712f0fc5cb | https://github.com/sublee/etc/blob/f2be64604da5af0d7739cfacf36f55712f0fc5cb/etc/client.py#L58-L61 | train | Creates a new key. |
sublee/etc | etc/client.py | Client.update | def update(self, key, value=None, dir=False, ttl=None, refresh=False,
prev_value=None, prev_index=None, timeout=None):
"""Updates an existing key."""
return self.adapter.set(key, value, dir=dir, ttl=ttl, refresh=refresh,
prev_value=prev_value, prev_index=pr... | python | def update(self, key, value=None, dir=False, ttl=None, refresh=False,
prev_value=None, prev_index=None, timeout=None):
"""Updates an existing key."""
return self.adapter.set(key, value, dir=dir, ttl=ttl, refresh=refresh,
prev_value=prev_value, prev_index=pr... | [
"def",
"update",
"(",
"self",
",",
"key",
",",
"value",
"=",
"None",
",",
"dir",
"=",
"False",
",",
"ttl",
"=",
"None",
",",
"refresh",
"=",
"False",
",",
"prev_value",
"=",
"None",
",",
"prev_index",
"=",
"None",
",",
"timeout",
"=",
"None",
")",
... | Updates an existing key. | [
"Updates",
"an",
"existing",
"key",
"."
] | f2be64604da5af0d7739cfacf36f55712f0fc5cb | https://github.com/sublee/etc/blob/f2be64604da5af0d7739cfacf36f55712f0fc5cb/etc/client.py#L63-L68 | train | Updates an existing key. |
sublee/etc | etc/client.py | Client.append | def append(self, key, value=None, dir=False, ttl=None, timeout=None):
"""Creates a new automatically increasing key in the given directory
key.
"""
return self.adapter.append(key, value, dir=dir, ttl=ttl,
timeout=timeout) | python | def append(self, key, value=None, dir=False, ttl=None, timeout=None):
"""Creates a new automatically increasing key in the given directory
key.
"""
return self.adapter.append(key, value, dir=dir, ttl=ttl,
timeout=timeout) | [
"def",
"append",
"(",
"self",
",",
"key",
",",
"value",
"=",
"None",
",",
"dir",
"=",
"False",
",",
"ttl",
"=",
"None",
",",
"timeout",
"=",
"None",
")",
":",
"return",
"self",
".",
"adapter",
".",
"append",
"(",
"key",
",",
"value",
",",
"dir",
... | Creates a new automatically increasing key in the given directory
key. | [
"Creates",
"a",
"new",
"automatically",
"increasing",
"key",
"in",
"the",
"given",
"directory",
"key",
"."
] | f2be64604da5af0d7739cfacf36f55712f0fc5cb | https://github.com/sublee/etc/blob/f2be64604da5af0d7739cfacf36f55712f0fc5cb/etc/client.py#L70-L75 | train | Creates a new automatically increasing key in the given directory
key. |
sublee/etc | etc/client.py | Client.delete | def delete(self, key, dir=False, recursive=False,
prev_value=None, prev_index=None, timeout=None):
"""Deletes a key."""
return self.adapter.delete(key, dir=dir, recursive=recursive,
prev_value=prev_value,
prev_index=pre... | python | def delete(self, key, dir=False, recursive=False,
prev_value=None, prev_index=None, timeout=None):
"""Deletes a key."""
return self.adapter.delete(key, dir=dir, recursive=recursive,
prev_value=prev_value,
prev_index=pre... | [
"def",
"delete",
"(",
"self",
",",
"key",
",",
"dir",
"=",
"False",
",",
"recursive",
"=",
"False",
",",
"prev_value",
"=",
"None",
",",
"prev_index",
"=",
"None",
",",
"timeout",
"=",
"None",
")",
":",
"return",
"self",
".",
"adapter",
".",
"delete"... | Deletes a key. | [
"Deletes",
"a",
"key",
"."
] | f2be64604da5af0d7739cfacf36f55712f0fc5cb | https://github.com/sublee/etc/blob/f2be64604da5af0d7739cfacf36f55712f0fc5cb/etc/client.py#L77-L82 | train | Deletes a key. |
a1ezzz/wasp-general | wasp_general/network/messenger/layers.py | WMessengerOnionModeLayerProto.process | def process(self, envelope, session, mode=None, **kwargs):
""" :meth:`.WMessengerOnionLayerProto.process` implementation
"""
if mode is None:
raise RuntimeError('"mode" argument must be specified for this object')
if isinstance(mode, self.__mode_cls) is False:
raise TypeError('Invalid "mode" argument')
... | python | def process(self, envelope, session, mode=None, **kwargs):
""" :meth:`.WMessengerOnionLayerProto.process` implementation
"""
if mode is None:
raise RuntimeError('"mode" argument must be specified for this object')
if isinstance(mode, self.__mode_cls) is False:
raise TypeError('Invalid "mode" argument')
... | [
"def",
"process",
"(",
"self",
",",
"envelope",
",",
"session",
",",
"mode",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"mode",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"'\"mode\" argument must be specified for this object'",
")",
"if",
"i... | :meth:`.WMessengerOnionLayerProto.process` implementation | [
":",
"meth",
":",
".",
"WMessengerOnionLayerProto",
".",
"process",
"implementation"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/messenger/layers.py#L77-L86 | train | implementation of WMessengerOnionLayerProto. process |
a1ezzz/wasp-general | wasp_general/network/messenger/layers.py | WMessengerOnionCoderLayerProto._process | def _process(self, envelope, session, mode, **kwargs):
""" :meth:`.WMessengerOnionLayerProto.process` implementation
"""
if mode == WMessengerOnionCoderLayerProto.Mode.encode:
return self.encode(envelope, session, **kwargs)
else: # mode == WMessengerOnionCoderLayerProto.Mode.decode
return self.decode(env... | python | def _process(self, envelope, session, mode, **kwargs):
""" :meth:`.WMessengerOnionLayerProto.process` implementation
"""
if mode == WMessengerOnionCoderLayerProto.Mode.encode:
return self.encode(envelope, session, **kwargs)
else: # mode == WMessengerOnionCoderLayerProto.Mode.decode
return self.decode(env... | [
"def",
"_process",
"(",
"self",
",",
"envelope",
",",
"session",
",",
"mode",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"mode",
"==",
"WMessengerOnionCoderLayerProto",
".",
"Mode",
".",
"encode",
":",
"return",
"self",
".",
"encode",
"(",
"envelope",
",",... | :meth:`.WMessengerOnionLayerProto.process` implementation | [
":",
"meth",
":",
".",
"WMessengerOnionLayerProto",
".",
"process",
"implementation"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/messenger/layers.py#L127-L133 | train | Implementation of the process method. |
a1ezzz/wasp-general | wasp_general/network/messenger/layers.py | WMessengerOnionPackerLayerProto._process | def _process(self, envelope, session, mode, **kwargs):
""" :meth:`.WMessengerOnionLayerProto.process` implementation
"""
if mode == WMessengerOnionPackerLayerProto.Mode.pack:
return self.pack(envelope, session, **kwargs)
else: # mode == WMessengerOnionPackerLayerProto.Mode.unpack
return self.unpack(envel... | python | def _process(self, envelope, session, mode, **kwargs):
""" :meth:`.WMessengerOnionLayerProto.process` implementation
"""
if mode == WMessengerOnionPackerLayerProto.Mode.pack:
return self.pack(envelope, session, **kwargs)
else: # mode == WMessengerOnionPackerLayerProto.Mode.unpack
return self.unpack(envel... | [
"def",
"_process",
"(",
"self",
",",
"envelope",
",",
"session",
",",
"mode",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"mode",
"==",
"WMessengerOnionPackerLayerProto",
".",
"Mode",
".",
"pack",
":",
"return",
"self",
".",
"pack",
"(",
"envelope",
",",
... | :meth:`.WMessengerOnionLayerProto.process` implementation | [
":",
"meth",
":",
".",
"WMessengerOnionLayerProto",
".",
"process",
"implementation"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/messenger/layers.py#L181-L187 | train | Implementation of the process method. |
jahuth/litus | spikes.py | create_timing_signals | def create_timing_signals(timings,ranges=[3,8]):
"""
Creates a linear list/np.array of timestamps and a list of integers, specifying the sequence
and number of levels.
The levels are first rotated on the first dimension, then the second and so on. If the
last dimension is -1, the ... | python | def create_timing_signals(timings,ranges=[3,8]):
"""
Creates a linear list/np.array of timestamps and a list of integers, specifying the sequence
and number of levels.
The levels are first rotated on the first dimension, then the second and so on. If the
last dimension is -1, the ... | [
"def",
"create_timing_signals",
"(",
"timings",
",",
"ranges",
"=",
"[",
"3",
",",
"8",
"]",
")",
":",
"if",
"ranges",
"[",
"-",
"1",
"]",
"==",
"-",
"1",
":",
"ranges",
"[",
"-",
"1",
"]",
"=",
"np",
".",
"floor",
"(",
"len",
"(",
"timings",
... | Creates a linear list/np.array of timestamps and a list of integers, specifying the sequence
and number of levels.
The levels are first rotated on the first dimension, then the second and so on. If the
last dimension is -1, the number of levels is computed from the timestamps.
return... | [
"Creates",
"a",
"linear",
"list",
"/",
"np",
".",
"array",
"of",
"timestamps",
"and",
"a",
"list",
"of",
"integers",
"specifying",
"the",
"sequence",
"and",
"number",
"of",
"levels",
"."
] | 712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e | https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/spikes.py#L46-L70 | train | Creates a linear list of timestamps and a list of integers specifying the sequence
and the number of levels. |
jahuth/litus | spikes.py | SpikeContainerCollection.find | def find(self,cell_designation,cell_filter=lambda x,c: 'c' in x and x['c'] == c):
"""
finds spike containers in a multi spike containers collection
"""
res = [i for i,sc in enumerate(self.spike_containers) if cell_filter(sc.meta,cell_designation)]
if len(res) > 0:
... | python | def find(self,cell_designation,cell_filter=lambda x,c: 'c' in x and x['c'] == c):
"""
finds spike containers in a multi spike containers collection
"""
res = [i for i,sc in enumerate(self.spike_containers) if cell_filter(sc.meta,cell_designation)]
if len(res) > 0:
... | [
"def",
"find",
"(",
"self",
",",
"cell_designation",
",",
"cell_filter",
"=",
"lambda",
"x",
",",
"c",
":",
"'c'",
"in",
"x",
"and",
"x",
"[",
"'c'",
"]",
"==",
"c",
")",
":",
"res",
"=",
"[",
"i",
"for",
"i",
",",
"sc",
"in",
"enumerate",
"(",... | finds spike containers in a multi spike containers collection | [
"finds",
"spike",
"containers",
"in",
"a",
"multi",
"spike",
"containers",
"collection"
] | 712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e | https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/spikes.py#L145-L151 | train | finds a spike container in a multi spike containers collection |
jahuth/litus | spikes.py | SpikeContainerCollection.label_by_time | def label_by_time(self,time_signals,label_names=[],copy=False, **kwargs):
"""
creates a labeled spike data structure
time_label_array is list of lists (or matrix), containing a timestamp in the
first column (or first element of each element) and indizes that are to ... | python | def label_by_time(self,time_signals,label_names=[],copy=False, **kwargs):
"""
creates a labeled spike data structure
time_label_array is list of lists (or matrix), containing a timestamp in the
first column (or first element of each element) and indizes that are to ... | [
"def",
"label_by_time",
"(",
"self",
",",
"time_signals",
",",
"label_names",
"=",
"[",
"]",
",",
"copy",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"new_containers",
"=",
"[",
"]",
"for",
"sc",
"in",
"self",
".",
"spike_containers",
":",
"new_sc... | creates a labeled spike data structure
time_label_array is list of lists (or matrix), containing a timestamp in the
first column (or first element of each element) and indizes that are to be
applied to the data in the remaining columns / elements.
This fun... | [
"creates",
"a",
"labeled",
"spike",
"data",
"structure"
] | 712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e | https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/spikes.py#L169-L195 | train | Returns a new SpikeContainerCollection with the same attributes as self but with the given time signals. |
jahuth/litus | spikes.py | LabelDimension.len | def len(self,resolution=1.0,units=None,conversion_function=convert_time, end_at_end=True):
"""
Calculates the length of the Label Dimension from its minimum, maximum and wether it is discrete.
`resolution`:
`units`: output units
`conversion_function`:
... | python | def len(self,resolution=1.0,units=None,conversion_function=convert_time, end_at_end=True):
"""
Calculates the length of the Label Dimension from its minimum, maximum and wether it is discrete.
`resolution`:
`units`: output units
`conversion_function`:
... | [
"def",
"len",
"(",
"self",
",",
"resolution",
"=",
"1.0",
",",
"units",
"=",
"None",
",",
"conversion_function",
"=",
"convert_time",
",",
"end_at_end",
"=",
"True",
")",
":",
"if",
"units",
"is",
"not",
"None",
":",
"resolution",
"=",
"conversion_function... | Calculates the length of the Label Dimension from its minimum, maximum and wether it is discrete.
`resolution`:
`units`: output units
`conversion_function`:
`end_at_end`: additional switch for continuous behaviour | [
"Calculates",
"the",
"length",
"of",
"the",
"Label",
"Dimension",
"from",
"its",
"minimum",
"maximum",
"and",
"wether",
"it",
"is",
"discrete",
"."
] | 712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e | https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/spikes.py#L282-L301 | train | Calculates the length of the Label Dimension from its minimum maximum and wether it is discrete. |
jahuth/litus | spikes.py | LabelDimension.space | def space(self,bins=None,units=None,conversion_function=convert_time,resolution=None,end_at_end=True,scale=None):
"""
Computes adequat binning for the dimension (on the values).
bins: number of bins or None
units: str or None
conversion_function: func... | python | def space(self,bins=None,units=None,conversion_function=convert_time,resolution=None,end_at_end=True,scale=None):
"""
Computes adequat binning for the dimension (on the values).
bins: number of bins or None
units: str or None
conversion_function: func... | [
"def",
"space",
"(",
"self",
",",
"bins",
"=",
"None",
",",
"units",
"=",
"None",
",",
"conversion_function",
"=",
"convert_time",
",",
"resolution",
"=",
"None",
",",
"end_at_end",
"=",
"True",
",",
"scale",
"=",
"None",
")",
":",
"if",
"scale",
"in",... | Computes adequat binning for the dimension (on the values).
bins: number of bins or None
units: str or None
conversion_function: function to convert units to other units
resolution: step size or None
end_at_end: Boolean
... | [
"Computes",
"adequat",
"binning",
"for",
"the",
"dimension",
"(",
"on",
"the",
"values",
")",
"."
] | 712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e | https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/spikes.py#L302-L319 | train | Returns a spikes for the dimension. |
jahuth/litus | spikes.py | LabelDimension.bins | def bins(self,bins=None,units=None,conversion_function=convert_time,resolution=None,scale=None):
"""
Computes adequat binning for the dimension (between the values).
bins: number of bins or None
units: str or None
conversion_function: function to conv... | python | def bins(self,bins=None,units=None,conversion_function=convert_time,resolution=None,scale=None):
"""
Computes adequat binning for the dimension (between the values).
bins: number of bins or None
units: str or None
conversion_function: function to conv... | [
"def",
"bins",
"(",
"self",
",",
"bins",
"=",
"None",
",",
"units",
"=",
"None",
",",
"conversion_function",
"=",
"convert_time",
",",
"resolution",
"=",
"None",
",",
"scale",
"=",
"None",
")",
":",
"if",
"scale",
"in",
"[",
"'log'",
"]",
"or",
"(",
... | Computes adequat binning for the dimension (between the values).
bins: number of bins or None
units: str or None
conversion_function: function to convert units to other units
resolution: step size or None
scale: 'lin','log' or None
... | [
"Computes",
"adequat",
"binning",
"for",
"the",
"dimension",
"(",
"between",
"the",
"values",
")",
"."
] | 712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e | https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/spikes.py#L320-L335 | train | Computes adequat binning for the label. |
jahuth/litus | spikes.py | LabelDimension.linspace_bins | def linspace_bins(self,bins=None,units=None,conversion_function=convert_time,resolution=None,end_at_end=True,extra_bins=0):
"""Generates bin edges for a linspace tiling: there is one edge more than bins and each bin is in the middle between two edges"""
bins = self.linspace(bins=bins,units=units,convers... | python | def linspace_bins(self,bins=None,units=None,conversion_function=convert_time,resolution=None,end_at_end=True,extra_bins=0):
"""Generates bin edges for a linspace tiling: there is one edge more than bins and each bin is in the middle between two edges"""
bins = self.linspace(bins=bins,units=units,convers... | [
"def",
"linspace_bins",
"(",
"self",
",",
"bins",
"=",
"None",
",",
"units",
"=",
"None",
",",
"conversion_function",
"=",
"convert_time",
",",
"resolution",
"=",
"None",
",",
"end_at_end",
"=",
"True",
",",
"extra_bins",
"=",
"0",
")",
":",
"bins",
"=",... | Generates bin edges for a linspace tiling: there is one edge more than bins and each bin is in the middle between two edges | [
"Generates",
"bin",
"edges",
"for",
"a",
"linspace",
"tiling",
":",
"there",
"is",
"one",
"edge",
"more",
"than",
"bins",
"and",
"each",
"bin",
"is",
"in",
"the",
"middle",
"between",
"two",
"edges"
] | 712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e | https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/spikes.py#L355-L360 | train | Generates bin edges for a linspace tiling |
jahuth/litus | spikes.py | LabelDimension.logspace | def logspace(self,bins=None,units=None,conversion_function=convert_time,resolution=None,end_at_end=True):
""" bins overwrites resolution """
if type(bins) in [list, np.ndarray]:
return bins
min = conversion_function(self.min,from_units=self.units,to_units=units)
max = convers... | python | def logspace(self,bins=None,units=None,conversion_function=convert_time,resolution=None,end_at_end=True):
""" bins overwrites resolution """
if type(bins) in [list, np.ndarray]:
return bins
min = conversion_function(self.min,from_units=self.units,to_units=units)
max = convers... | [
"def",
"logspace",
"(",
"self",
",",
"bins",
"=",
"None",
",",
"units",
"=",
"None",
",",
"conversion_function",
"=",
"convert_time",
",",
"resolution",
"=",
"None",
",",
"end_at_end",
"=",
"True",
")",
":",
"if",
"type",
"(",
"bins",
")",
"in",
"[",
... | bins overwrites resolution | [
"bins",
"overwrites",
"resolution"
] | 712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e | https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/spikes.py#L363-L381 | train | Return a numpy array of log10 values in the specified bins. |
jahuth/litus | spikes.py | LabelDimension.logspace_bins | def logspace_bins(self,bins=None,units=None,conversion_function=convert_time,resolution=None):
"""Generates bin edges for a logspace tiling: there is one edge more than bins and each bin is between two edges"""
bins = self.logspace(bins=bins,units=units,conversion_function=conversion_function,resolution... | python | def logspace_bins(self,bins=None,units=None,conversion_function=convert_time,resolution=None):
"""Generates bin edges for a logspace tiling: there is one edge more than bins and each bin is between two edges"""
bins = self.logspace(bins=bins,units=units,conversion_function=conversion_function,resolution... | [
"def",
"logspace_bins",
"(",
"self",
",",
"bins",
"=",
"None",
",",
"units",
"=",
"None",
",",
"conversion_function",
"=",
"convert_time",
",",
"resolution",
"=",
"None",
")",
":",
"bins",
"=",
"self",
".",
"logspace",
"(",
"bins",
"=",
"bins",
",",
"u... | Generates bin edges for a logspace tiling: there is one edge more than bins and each bin is between two edges | [
"Generates",
"bin",
"edges",
"for",
"a",
"logspace",
"tiling",
":",
"there",
"is",
"one",
"edge",
"more",
"than",
"bins",
"and",
"each",
"bin",
"is",
"between",
"two",
"edges"
] | 712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e | https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/spikes.py#L382-L387 | train | Generates bin edges for a logspace tiling |
jahuth/litus | spikes.py | LabelDimension.constraint_range_dict | def constraint_range_dict(self,*args,**kwargs):
"""
Creates a list of dictionaries which each give a constraint for a certain
section of the dimension.
bins arguments overwrites resolution
"""
bins = self.bins(*args,**kwargs)
return [{self.name+'__gt... | python | def constraint_range_dict(self,*args,**kwargs):
"""
Creates a list of dictionaries which each give a constraint for a certain
section of the dimension.
bins arguments overwrites resolution
"""
bins = self.bins(*args,**kwargs)
return [{self.name+'__gt... | [
"def",
"constraint_range_dict",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"bins",
"=",
"self",
".",
"bins",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"return",
"[",
"{",
"self",
".",
"name",
"+",
"'__gte'",
":",
"a",... | Creates a list of dictionaries which each give a constraint for a certain
section of the dimension.
bins arguments overwrites resolution | [
"Creates",
"a",
"list",
"of",
"dictionaries",
"which",
"each",
"give",
"a",
"constraint",
"for",
"a",
"certain",
"section",
"of",
"the",
"dimension",
"."
] | 712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e | https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/spikes.py#L392-L403 | train | Returns a list of dictionaries which each give a constraint for a certain
section of the dimension. |
jahuth/litus | spikes.py | LabeledMatrix.find_labels | def find_labels(self,key,find_in_name=True,find_in_units=False):
"""
Takes a string or a function to find a set of label indizes
that match.
If the string starts with a '~', the label only has to contain the string.
"""
if type(key) is str:
found_... | python | def find_labels(self,key,find_in_name=True,find_in_units=False):
"""
Takes a string or a function to find a set of label indizes
that match.
If the string starts with a '~', the label only has to contain the string.
"""
if type(key) is str:
found_... | [
"def",
"find_labels",
"(",
"self",
",",
"key",
",",
"find_in_name",
"=",
"True",
",",
"find_in_units",
"=",
"False",
")",
":",
"if",
"type",
"(",
"key",
")",
"is",
"str",
":",
"found_keys",
"=",
"[",
"]",
"if",
"key",
".",
"startswith",
"(",
"'~'",
... | Takes a string or a function to find a set of label indizes
that match.
If the string starts with a '~', the label only has to contain the string. | [
"Takes",
"a",
"string",
"or",
"a",
"function",
"to",
"find",
"a",
"set",
"of",
"label",
"indizes",
"that",
"match",
".",
"If",
"the",
"string",
"starts",
"with",
"a",
"~",
"the",
"label",
"only",
"has",
"to",
"contain",
"the",
"string",
"."
] | 712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e | https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/spikes.py#L462-L491 | train | Given a string or a function to find a set of label indizes
that match. |
jahuth/litus | spikes.py | LabeledMatrix.table | def table(self,x,*args,**kwargs):
"""
returns the values of column x
in an n-dimensional array, each
dimension being the values from
a dimension in *args
at the moment very slow due to generate :/
"""
reduce_func = kwargs.get('reduce',... | python | def table(self,x,*args,**kwargs):
"""
returns the values of column x
in an n-dimensional array, each
dimension being the values from
a dimension in *args
at the moment very slow due to generate :/
"""
reduce_func = kwargs.get('reduce',... | [
"def",
"table",
"(",
"self",
",",
"x",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"reduce_func",
"=",
"kwargs",
".",
"get",
"(",
"'reduce'",
",",
"lambda",
"x",
":",
"x",
")",
"data",
"=",
"[",
"]",
"for",
"i",
",",
"d",
"in",
"enum... | returns the values of column x
in an n-dimensional array, each
dimension being the values from
a dimension in *args
at the moment very slow due to generate :/ | [
"returns",
"the",
"values",
"of",
"column",
"x",
"in",
"an",
"n",
"-",
"dimensional",
"array",
"each",
"dimension",
"being",
"the",
"values",
"from",
"a",
"dimension",
"in",
"*",
"args"
] | 712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e | https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/spikes.py#L565-L584 | train | returns the values of column x
in an n - dimensional array each dimension being the values from the generated column x
|
jahuth/litus | spikes.py | LabeledMatrix.convert | def convert(self,label,units=None,conversion_function=convert_time):
""" converts a dimension in place """
label_no = self.get_label_no(label)
new_label, new_column = self.get_converted(label_no,units,conversion_function)
labels = [LabelDimension(l) for l in self.labels]
labels[l... | python | def convert(self,label,units=None,conversion_function=convert_time):
""" converts a dimension in place """
label_no = self.get_label_no(label)
new_label, new_column = self.get_converted(label_no,units,conversion_function)
labels = [LabelDimension(l) for l in self.labels]
labels[l... | [
"def",
"convert",
"(",
"self",
",",
"label",
",",
"units",
"=",
"None",
",",
"conversion_function",
"=",
"convert_time",
")",
":",
"label_no",
"=",
"self",
".",
"get_label_no",
"(",
"label",
")",
"new_label",
",",
"new_column",
"=",
"self",
".",
"get_conve... | converts a dimension in place | [
"converts",
"a",
"dimension",
"in",
"place"
] | 712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e | https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/spikes.py#L597-L605 | train | converts a dimension in place |
jahuth/litus | spikes.py | LabeledMatrix._get_constrained_labels | def _get_constrained_labels(self,remove_dimensions=False,**kwargs):
"""
returns labels which have updated minima and maxima,
depending on the kwargs supplied to this
"""
new_labels = []
for label_no,label in enumerate(self.labels):
new_label = LabelDim... | python | def _get_constrained_labels(self,remove_dimensions=False,**kwargs):
"""
returns labels which have updated minima and maxima,
depending on the kwargs supplied to this
"""
new_labels = []
for label_no,label in enumerate(self.labels):
new_label = LabelDim... | [
"def",
"_get_constrained_labels",
"(",
"self",
",",
"remove_dimensions",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"new_labels",
"=",
"[",
"]",
"for",
"label_no",
",",
"label",
"in",
"enumerate",
"(",
"self",
".",
"labels",
")",
":",
"new_label",
... | returns labels which have updated minima and maxima,
depending on the kwargs supplied to this | [
"returns",
"labels",
"which",
"have",
"updated",
"minima",
"and",
"maxima",
"depending",
"on",
"the",
"kwargs",
"supplied",
"to",
"this"
] | 712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e | https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/spikes.py#L606-L645 | train | Returns a list of labels which have updated minima and maxima depending on the kwargs supplied to this object. |
jahuth/litus | spikes.py | LabeledMatrix.generate | def generate(self,*args,**kwargs):
"""
Creates an iterator over one of the index dimensions of the object.
Example::
for l in s.generate('layer',remove_dimensions=False,resolution=2):
# taking two layers at a time
print l
remove_dimensio... | python | def generate(self,*args,**kwargs):
"""
Creates an iterator over one of the index dimensions of the object.
Example::
for l in s.generate('layer',remove_dimensions=False,resolution=2):
# taking two layers at a time
print l
remove_dimensio... | [
"def",
"generate",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"constraints",
"=",
"[",
"]",
"remove_dimensions",
"=",
"kwargs",
".",
"pop",
"(",
"'remove_dimensions'",
",",
"False",
")",
"resolution",
"=",
"kwargs",
".",
"get",
"... | Creates an iterator over one of the index dimensions of the object.
Example::
for l in s.generate('layer',remove_dimensions=False,resolution=2):
# taking two layers at a time
print l
remove_dimensions: False
Whether the labels that are u... | [
"Creates",
"an",
"iterator",
"over",
"one",
"of",
"the",
"index",
"dimensions",
"of",
"the",
"object",
"."
] | 712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e | https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/spikes.py#L738-L781 | train | Generates an iterator over the object s index dimensions. |
jahuth/litus | spikes.py | SpikeContainer.copy | def copy(self,**kwargs):
"""
Copies the spikes and optionally converts the spike times.
(when the keyword units is not None)
"""
new_spike_times = LabeledMatrix(self.spike_times.matrix,self.spike_times.labels) # copies the data
return SpikeContainer(new_spike_time... | python | def copy(self,**kwargs):
"""
Copies the spikes and optionally converts the spike times.
(when the keyword units is not None)
"""
new_spike_times = LabeledMatrix(self.spike_times.matrix,self.spike_times.labels) # copies the data
return SpikeContainer(new_spike_time... | [
"def",
"copy",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"new_spike_times",
"=",
"LabeledMatrix",
"(",
"self",
".",
"spike_times",
".",
"matrix",
",",
"self",
".",
"spike_times",
".",
"labels",
")",
"# copies the data",
"return",
"SpikeContainer",
"(",... | Copies the spikes and optionally converts the spike times.
(when the keyword units is not None) | [
"Copies",
"the",
"spikes",
"and",
"optionally",
"converts",
"the",
"spike",
"times",
".",
"(",
"when",
"the",
"keyword",
"units",
"is",
"not",
"None",
")"
] | 712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e | https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/spikes.py#L864-L870 | train | Returns a copy of the current object. |
jahuth/litus | spikes.py | SpikeContainer.store_meta | def store_meta(self,meta):
"Inplace method that adds meta information to the meta dictionary"
if self.meta is None:
self.meta = {}
self.meta.update(meta)
return self | python | def store_meta(self,meta):
"Inplace method that adds meta information to the meta dictionary"
if self.meta is None:
self.meta = {}
self.meta.update(meta)
return self | [
"def",
"store_meta",
"(",
"self",
",",
"meta",
")",
":",
"if",
"self",
".",
"meta",
"is",
"None",
":",
"self",
".",
"meta",
"=",
"{",
"}",
"self",
".",
"meta",
".",
"update",
"(",
"meta",
")",
"return",
"self"
] | Inplace method that adds meta information to the meta dictionary | [
"Inplace",
"method",
"that",
"adds",
"meta",
"information",
"to",
"the",
"meta",
"dictionary"
] | 712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e | https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/spikes.py#L879-L884 | train | Inplace method that adds meta information to the meta dictionary |
jahuth/litus | spikes.py | SpikeContainer.label_by_time | def label_by_time(self,time_signals,label_names=[],time_units='ms',time_dimension=0,copy=True,backup_original_spike_times_to=None,**kwargs):
"""
creates a labeled spike data structure
`time_signals` is list of lists (or matrix), containing a timestamp in the
first c... | python | def label_by_time(self,time_signals,label_names=[],time_units='ms',time_dimension=0,copy=True,backup_original_spike_times_to=None,**kwargs):
"""
creates a labeled spike data structure
`time_signals` is list of lists (or matrix), containing a timestamp in the
first c... | [
"def",
"label_by_time",
"(",
"self",
",",
"time_signals",
",",
"label_names",
"=",
"[",
"]",
",",
"time_units",
"=",
"'ms'",
",",
"time_dimension",
"=",
"0",
",",
"copy",
"=",
"True",
",",
"backup_original_spike_times_to",
"=",
"None",
",",
"*",
"*",
"kwar... | creates a labeled spike data structure
`time_signals` is list of lists (or matrix), containing a timestamp in the
first column (or first element of each element) and indizes that are to be
applied to the data in the remaining columns / elements.
This funct... | [
"creates",
"a",
"labeled",
"spike",
"data",
"structure"
] | 712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e | https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/spikes.py#L902-L970 | train | Returns a new SpikeContainer with the labelled spikes in the given time_signals. |
jahuth/litus | spikes.py | SpikeContainer._absolute_spike_times_from_labels | def _absolute_spike_times_from_labels(self,time_dimension=0,*args,**kwargs):
"""
internal function that gives absolute_spike_times_from_labels, as well as
the factor (maximum range)
"""
x = self[time_dimension].copy()
#x = self.spike_times.get_converted(time_dime... | python | def _absolute_spike_times_from_labels(self,time_dimension=0,*args,**kwargs):
"""
internal function that gives absolute_spike_times_from_labels, as well as
the factor (maximum range)
"""
x = self[time_dimension].copy()
#x = self.spike_times.get_converted(time_dime... | [
"def",
"_absolute_spike_times_from_labels",
"(",
"self",
",",
"time_dimension",
"=",
"0",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"x",
"=",
"self",
"[",
"time_dimension",
"]",
".",
"copy",
"(",
")",
"#x = self.spike_times.get_converted(time_dimensio... | internal function that gives absolute_spike_times_from_labels, as well as
the factor (maximum range) | [
"internal",
"function",
"that",
"gives",
"absolute_spike_times_from_labels",
"as",
"well",
"as",
"the",
"factor",
"(",
"maximum",
"range",
")"
] | 712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e | https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/spikes.py#L971-L990 | train | internal function that gives absolute_spike_times_from_labels as well as
the factor |
jahuth/litus | spikes.py | SpikeContainer.absolute_spike_times_from_labels | def absolute_spike_times_from_labels(self,time_dimension=0,*args,**kwargs):
"""
Creates a list of spike times where each value of the supplied dimensions
is added as a trial-time offset. This can be used as the inverse of
`label_by_time` or `label_peri_signals` (while the la... | python | def absolute_spike_times_from_labels(self,time_dimension=0,*args,**kwargs):
"""
Creates a list of spike times where each value of the supplied dimensions
is added as a trial-time offset. This can be used as the inverse of
`label_by_time` or `label_peri_signals` (while the la... | [
"def",
"absolute_spike_times_from_labels",
"(",
"self",
",",
"time_dimension",
"=",
"0",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_absolute_spike_times_from_labels",
"(",
"time_dimension",
",",
"*",
"args",
",",
"*",
"*",
... | Creates a list of spike times where each value of the supplied dimensions
is added as a trial-time offset. This can be used as the inverse of
`label_by_time` or `label_peri_signals` (while the later can lead to spike duplicates).
Eg. for three stimuli, in 5 trials each, for one sec... | [
"Creates",
"a",
"list",
"of",
"spike",
"times",
"where",
"each",
"value",
"of",
"the",
"supplied",
"dimensions",
"is",
"added",
"as",
"a",
"trial",
"-",
"time",
"offset",
".",
"This",
"can",
"be",
"used",
"as",
"the",
"inverse",
"of",
"label_by_time",
"o... | 712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e | https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/spikes.py#L991-L1011 | train | Returns a list of spike times for the given time dimension and arguments. |
jahuth/litus | spikes.py | SpikeContainer.label_peri_signals | def label_peri_signals(self,time_signals,label_names=[],units=None,data_units=None,copy=True, pre_signal = 100.0, post_signal = 1000.0, **kwargs):
"""
creates a labeled spike data structure
time_label_array is list of lists (or matrix), containing a timestamp in the
first c... | python | def label_peri_signals(self,time_signals,label_names=[],units=None,data_units=None,copy=True, pre_signal = 100.0, post_signal = 1000.0, **kwargs):
"""
creates a labeled spike data structure
time_label_array is list of lists (or matrix), containing a timestamp in the
first c... | [
"def",
"label_peri_signals",
"(",
"self",
",",
"time_signals",
",",
"label_names",
"=",
"[",
"]",
",",
"units",
"=",
"None",
",",
"data_units",
"=",
"None",
",",
"copy",
"=",
"True",
",",
"pre_signal",
"=",
"100.0",
",",
"post_signal",
"=",
"1000.0",
","... | creates a labeled spike data structure
time_label_array is list of lists (or matrix), containing a timestamp in the
first column (or first element of each element) and indizes that are to be
applied to the data in the remaining columns / elements.
This function will ... | [
"creates",
"a",
"labeled",
"spike",
"data",
"structure"
] | 712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e | https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/spikes.py#L1025-L1069 | train | Creates a labeled spike container for each time signal. |
jahuth/litus | spikes.py | SpikeContainer.ISIs | def ISIs(self,time_dimension=0,units=None,min_t=None,max_t=None):
"""
returns the Inter Spike Intervals
`time_dimension`: which dimension contains the spike times (by default the first)
`units`,`min_t`,`max_t`: define the units of the output and the range of spikes ... | python | def ISIs(self,time_dimension=0,units=None,min_t=None,max_t=None):
"""
returns the Inter Spike Intervals
`time_dimension`: which dimension contains the spike times (by default the first)
`units`,`min_t`,`max_t`: define the units of the output and the range of spikes ... | [
"def",
"ISIs",
"(",
"self",
",",
"time_dimension",
"=",
"0",
",",
"units",
"=",
"None",
",",
"min_t",
"=",
"None",
",",
"max_t",
"=",
"None",
")",
":",
"units",
"=",
"self",
".",
"_default_units",
"(",
"units",
")",
"converted_dimension",
",",
"st",
... | returns the Inter Spike Intervals
`time_dimension`: which dimension contains the spike times (by default the first)
`units`,`min_t`,`max_t`: define the units of the output and the range of spikes that should be considered | [
"returns",
"the",
"Inter",
"Spike",
"Intervals"
] | 712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e | https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/spikes.py#L1076-L1090 | train | returns the inter - spike times in the specified units |
jahuth/litus | spikes.py | SpikeContainer.spatial_firing_rate | def spatial_firing_rate(self,label_x='x',label_y='y',bins=None,resolution=1.0,geometry=None,weight_function=None,normalize_time=True,normalize_n=False,start_units_with_0=True):
"""
`bins` can be either a number of bins (has to be int) or a list of edges.
`bins` can be a tuple (fo... | python | def spatial_firing_rate(self,label_x='x',label_y='y',bins=None,resolution=1.0,geometry=None,weight_function=None,normalize_time=True,normalize_n=False,start_units_with_0=True):
"""
`bins` can be either a number of bins (has to be int) or a list of edges.
`bins` can be a tuple (fo... | [
"def",
"spatial_firing_rate",
"(",
"self",
",",
"label_x",
"=",
"'x'",
",",
"label_y",
"=",
"'y'",
",",
"bins",
"=",
"None",
",",
"resolution",
"=",
"1.0",
",",
"geometry",
"=",
"None",
",",
"weight_function",
"=",
"None",
",",
"normalize_time",
"=",
"Tr... | `bins` can be either a number of bins (has to be int) or a list of edges.
`bins` can be a tuple (for x and y respectively).
imshow(s.spatial_firing_rate(weight_function=lambda x: (x[:,1]>0.5)*(x[:,1]<0.6))) | [
"bins",
"can",
"be",
"either",
"a",
"number",
"of",
"bins",
"(",
"has",
"to",
"be",
"int",
")",
"or",
"a",
"list",
"of",
"edges",
".",
"bins",
"can",
"be",
"a",
"tuple",
"(",
"for",
"x",
"and",
"y",
"respectively",
")",
"."
] | 712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e | https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/spikes.py#L1135-L1176 | train | Returns the spatial firing rate of a neuron. |
jahuth/litus | spikes.py | SpikeContainer.plot_spatial_firing_rate | def plot_spatial_firing_rate(self,label_x='x',label_y='y',bins=None,resolution=1.0,geometry=None,weight_function=None,normalize_time=True,normalize_n=False,start_units_with_0=True,**kwargs):
"""
Plots a two dimensional representation of the firing rates.
Each spike is binned according to... | python | def plot_spatial_firing_rate(self,label_x='x',label_y='y',bins=None,resolution=1.0,geometry=None,weight_function=None,normalize_time=True,normalize_n=False,start_units_with_0=True,**kwargs):
"""
Plots a two dimensional representation of the firing rates.
Each spike is binned according to... | [
"def",
"plot_spatial_firing_rate",
"(",
"self",
",",
"label_x",
"=",
"'x'",
",",
"label_y",
"=",
"'y'",
",",
"bins",
"=",
"None",
",",
"resolution",
"=",
"1.0",
",",
"geometry",
"=",
"None",
",",
"weight_function",
"=",
"None",
",",
"normalize_time",
"=",
... | Plots a two dimensional representation of the firing rates.
Each spike is binned according to two labels (`label_x`='x' and `label_y`='y'),
which give a 2d histogram with `bins` many bins in each direction.
By default, the number of bins orients itself on the dimensions of the
... | [
"Plots",
"a",
"two",
"dimensional",
"representation",
"of",
"the",
"firing",
"rates",
".",
"Each",
"spike",
"is",
"binned",
"according",
"to",
"two",
"labels",
"(",
"label_x",
"=",
"x",
"and",
"label_y",
"=",
"y",
")",
"which",
"give",
"a",
"2d",
"histog... | 712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e | https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/spikes.py#L1177-L1200 | train | Plots a 2D histogram of the firing rates of the spike. |
jahuth/litus | spikes.py | SpikeContainer.temporal_firing_rate | def temporal_firing_rate(self,time_dimension=0,resolution=1.0,units=None,
min_t=None,max_t=None,weight_function=None,normalize_time=False,
normalize_n=False,start_units_with_0=True,cell_dimension='N'):
"""
Outputs a time histogram of spikes.
... | python | def temporal_firing_rate(self,time_dimension=0,resolution=1.0,units=None,
min_t=None,max_t=None,weight_function=None,normalize_time=False,
normalize_n=False,start_units_with_0=True,cell_dimension='N'):
"""
Outputs a time histogram of spikes.
... | [
"def",
"temporal_firing_rate",
"(",
"self",
",",
"time_dimension",
"=",
"0",
",",
"resolution",
"=",
"1.0",
",",
"units",
"=",
"None",
",",
"min_t",
"=",
"None",
",",
"max_t",
"=",
"None",
",",
"weight_function",
"=",
"None",
",",
"normalize_time",
"=",
... | Outputs a time histogram of spikes.
`bins`: number of bins (default is 1ms bins from 0 to t_max)
`weight_function`: if set, computes a weighted histogram, dependent on the (index, time) tuples of each spike
weight_function = lambda x: weight_map.flatten()[array(x[:,0],dtype... | [
"Outputs",
"a",
"time",
"histogram",
"of",
"spikes",
"."
] | 712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e | https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/spikes.py#L1201-L1232 | train | Outputs a time histogram of spikes. |
jahuth/litus | spikes.py | SpikeContainer.plot_temporal_firing_rate | def plot_temporal_firing_rate(self,time_dimension=0,resolution=1.0,units=None,min_t=None,max_t=None,weight_function=None,normalize_time=False,normalize_n=False,start_units_with_0=True,cell_dimension='N',**kwargs):
"""
Plots a firing rate plot.
Accepts the same keyword arguments as :func... | python | def plot_temporal_firing_rate(self,time_dimension=0,resolution=1.0,units=None,min_t=None,max_t=None,weight_function=None,normalize_time=False,normalize_n=False,start_units_with_0=True,cell_dimension='N',**kwargs):
"""
Plots a firing rate plot.
Accepts the same keyword arguments as :func... | [
"def",
"plot_temporal_firing_rate",
"(",
"self",
",",
"time_dimension",
"=",
"0",
",",
"resolution",
"=",
"1.0",
",",
"units",
"=",
"None",
",",
"min_t",
"=",
"None",
",",
"max_t",
"=",
"None",
",",
"weight_function",
"=",
"None",
",",
"normalize_time",
"=... | Plots a firing rate plot.
Accepts the same keyword arguments as :func:`matplotlib.pylab.plot()` for lines (:class:`~matplotlib.lines.Line2D`), eg `color`, `linewidth` (or `lw`), `linestyle` (or `ls`).
See help for :func:`matplotlib.pylab.plot()`. | [
"Plots",
"a",
"firing",
"rate",
"plot",
"."
] | 712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e | https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/spikes.py#L1235-L1245 | train | Plots a temporal firing rate plot. |
jahuth/litus | spikes.py | SpikeContainer.plot_raster | def plot_raster(self,cell_dimension='N',time_dimension=0,
resolution=1.0,units=None,min_t=None,max_t=None,
weight_function=None,normalize_time=True,normalize_n=True,
start_units_with_0=True,**kwargs):
"""Plots a raster plot with `cell_di... | python | def plot_raster(self,cell_dimension='N',time_dimension=0,
resolution=1.0,units=None,min_t=None,max_t=None,
weight_function=None,normalize_time=True,normalize_n=True,
start_units_with_0=True,**kwargs):
"""Plots a raster plot with `cell_di... | [
"def",
"plot_raster",
"(",
"self",
",",
"cell_dimension",
"=",
"'N'",
",",
"time_dimension",
"=",
"0",
",",
"resolution",
"=",
"1.0",
",",
"units",
"=",
"None",
",",
"min_t",
"=",
"None",
",",
"max_t",
"=",
"None",
",",
"weight_function",
"=",
"None",
... | Plots a raster plot with `cell_dimension` as y and `time_dimension` as x (default: 'N' and 0).
Accepts the same keyword arguments as matplotlib.pylab.plot() for points, eg. `marker`,
`markerfacecolor`, `markersize` (or `ms`), `markeredgecolor`.
See help for :func:`matplotlib.pylab.p... | [
"Plots",
"a",
"raster",
"plot",
"with",
"cell_dimension",
"as",
"y",
"and",
"time_dimension",
"as",
"x",
"(",
"default",
":",
"N",
"and",
"0",
")",
"."
] | 712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e | https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/spikes.py#L1246-L1274 | train | Plots a raster plot with the specified time dimension and units. |
jahuth/litus | spikes.py | SpikeContainer.generate | def generate(self,*args,**kwargs):
"""
Creates an iterator over one of the index dimensions of the object.
Example for a discrete variable::
for l in s.generate('layer',remove_dimensions=False,resolution=2):
# taking two layers at a time
print l
... | python | def generate(self,*args,**kwargs):
"""
Creates an iterator over one of the index dimensions of the object.
Example for a discrete variable::
for l in s.generate('layer',remove_dimensions=False,resolution=2):
# taking two layers at a time
print l
... | [
"def",
"generate",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"st",
"in",
"self",
".",
"spike_times",
".",
"generate",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"yield",
"SpikeContainer",
"(",
"st",
",",
"... | Creates an iterator over one of the index dimensions of the object.
Example for a discrete variable::
for l in s.generate('layer',remove_dimensions=False,resolution=2):
# taking two layers at a time
print l
Example for two continuous variables::
... | [
"Creates",
"an",
"iterator",
"over",
"one",
"of",
"the",
"index",
"dimensions",
"of",
"the",
"object",
"."
] | 712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e | https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/spikes.py#L1310-L1350 | train | Generates a new object of the correct type. |
jahuth/litus | spikes.py | SpikeContainer.len | def len(self,*args,**kwargs):
"""
Returns the number of spikes or the length of a Dimension in the respective unit::
spikes.len() # returns the number of entries ie. the number of spikes
spikes.len('t') # returns eg. ms
spikes.len('N') # returns t... | python | def len(self,*args,**kwargs):
"""
Returns the number of spikes or the length of a Dimension in the respective unit::
spikes.len() # returns the number of entries ie. the number of spikes
spikes.len('t') # returns eg. ms
spikes.len('N') # returns t... | [
"def",
"len",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"len",
"(",
"args",
")",
"==",
"0",
"or",
"args",
"==",
"None",
":",
"return",
"self",
".",
"spike_times",
".",
"matrix",
".",
"shape",
"[",
"0",
"]",
"if",
... | Returns the number of spikes or the length of a Dimension in the respective unit::
spikes.len() # returns the number of entries ie. the number of spikes
spikes.len('t') # returns eg. ms
spikes.len('N') # returns the number of neurons ()
If multiple argum... | [
"Returns",
"the",
"number",
"of",
"spikes",
"or",
"the",
"length",
"of",
"a",
"Dimension",
"in",
"the",
"respective",
"unit",
"::"
] | 712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e | https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/spikes.py#L1351-L1380 | train | Returns the number of spikes or neurons in the respective unit. |
jahuth/litus | spikes.py | SpikeContainer.get_units | def get_units(self,*args,**kwargs):
"""
Returns the units of a Dimension
"""
if len(args) == 1:
return self.spike_times.get_label(args[0]).units
return [self.spike_times.get_label(a).units for a in args] | python | def get_units(self,*args,**kwargs):
"""
Returns the units of a Dimension
"""
if len(args) == 1:
return self.spike_times.get_label(args[0]).units
return [self.spike_times.get_label(a).units for a in args] | [
"def",
"get_units",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"len",
"(",
"args",
")",
"==",
"1",
":",
"return",
"self",
".",
"spike_times",
".",
"get_label",
"(",
"args",
"[",
"0",
"]",
")",
".",
"units",
"return",
... | Returns the units of a Dimension | [
"Returns",
"the",
"units",
"of",
"a",
"Dimension"
] | 712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e | https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/spikes.py#L1381-L1387 | train | Returns the units of a Dimension
|
jahuth/litus | spikes.py | SpikeContainer.get_min | def get_min(self,*args,**kwargs):
"""
Returns the minimum of a Dimension
TODO: conversion is not implemented yet but should be
"""
if len(args) == 1:
return self.spike_times.get_label(args[0]).min
return [self.spike_times.get_label(a).max for a in arg... | python | def get_min(self,*args,**kwargs):
"""
Returns the minimum of a Dimension
TODO: conversion is not implemented yet but should be
"""
if len(args) == 1:
return self.spike_times.get_label(args[0]).min
return [self.spike_times.get_label(a).max for a in arg... | [
"def",
"get_min",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"len",
"(",
"args",
")",
"==",
"1",
":",
"return",
"self",
".",
"spike_times",
".",
"get_label",
"(",
"args",
"[",
"0",
"]",
")",
".",
"min",
"return",
"[... | Returns the minimum of a Dimension
TODO: conversion is not implemented yet but should be | [
"Returns",
"the",
"minimum",
"of",
"a",
"Dimension"
] | 712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e | https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/spikes.py#L1388-L1396 | train | Returns the minimum of a Dimension
|
jahuth/litus | spikes.py | SpikeContainer.get_max | def get_max(self,*args,**kwargs):
"""
Returns the maximum of a Dimension
TODO: conversion is not implemented yet but should be
"""
if len(args) == 1:
return self.spike_times.get_label(args[0]).max
return [self.spike_times.get_label(a).max for a in arg... | python | def get_max(self,*args,**kwargs):
"""
Returns the maximum of a Dimension
TODO: conversion is not implemented yet but should be
"""
if len(args) == 1:
return self.spike_times.get_label(args[0]).max
return [self.spike_times.get_label(a).max for a in arg... | [
"def",
"get_max",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"len",
"(",
"args",
")",
"==",
"1",
":",
"return",
"self",
".",
"spike_times",
".",
"get_label",
"(",
"args",
"[",
"0",
"]",
")",
".",
"max",
"return",
"[... | Returns the maximum of a Dimension
TODO: conversion is not implemented yet but should be | [
"Returns",
"the",
"maximum",
"of",
"a",
"Dimension"
] | 712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e | https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/spikes.py#L1397-L1405 | train | Returns the maximum of a Dimension
|
jahuth/litus | spikes.py | SpikeContainer.linspace | def linspace(self,dim,*args,**kwargs):
"""
Creates a range of values for a specific dimension that go from its minimum to its
maximum either in certain steps (resolution != None) or a fixed number of bins
(bins != None). The output can be converted into a different unit (eg... | python | def linspace(self,dim,*args,**kwargs):
"""
Creates a range of values for a specific dimension that go from its minimum to its
maximum either in certain steps (resolution != None) or a fixed number of bins
(bins != None). The output can be converted into a different unit (eg... | [
"def",
"linspace",
"(",
"self",
",",
"dim",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"spike_times",
".",
"get_label",
"(",
"dim",
")",
".",
"linspace",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | Creates a range of values for a specific dimension that go from its minimum to its
maximum either in certain steps (resolution != None) or a fixed number of bins
(bins != None). The output can be converted into a different unit (eg. into 'seconds').
bins=None
units=Non... | [
"Creates",
"a",
"range",
"of",
"values",
"for",
"a",
"specific",
"dimension",
"that",
"go",
"from",
"its",
"minimum",
"to",
"its",
"maximum",
"either",
"in",
"certain",
"steps",
"(",
"resolution",
"!",
"=",
"None",
")",
"or",
"a",
"fixed",
"number",
"of"... | 712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e | https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/spikes.py#L1406-L1427 | train | Creates a range of values for a specific dimension that go from its minimum to its maximum either in certain steps or in fixed number of bins. |
jahuth/litus | spikes.py | SpikeContainer.linspace_bins | def linspace_bins(self,dim,*args,**kwargs):
"""
Like linspace, but shifts the space to create edges for histograms.
"""
return self.spike_times.get_label(dim).linspace_bins(*args,**kwargs) | python | def linspace_bins(self,dim,*args,**kwargs):
"""
Like linspace, but shifts the space to create edges for histograms.
"""
return self.spike_times.get_label(dim).linspace_bins(*args,**kwargs) | [
"def",
"linspace_bins",
"(",
"self",
",",
"dim",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"spike_times",
".",
"get_label",
"(",
"dim",
")",
".",
"linspace_bins",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | Like linspace, but shifts the space to create edges for histograms. | [
"Like",
"linspace",
"but",
"shifts",
"the",
"space",
"to",
"create",
"edges",
"for",
"histograms",
"."
] | 712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e | https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/spikes.py#L1432-L1436 | train | Like linspace but shifts the space to create edges for histograms. |
jahuth/litus | spikes.py | SpikeContainer.create_SpikeGeneratorGroup | def create_SpikeGeneratorGroup(self,time_label=0,index_label=1,reorder_indices=False,index_offset=True):
"""
Creates a brian 2 create_SpikeGeneratorGroup object that contains the spikes in this container.
time_label: Name or number of the label that contains the spike times (def... | python | def create_SpikeGeneratorGroup(self,time_label=0,index_label=1,reorder_indices=False,index_offset=True):
"""
Creates a brian 2 create_SpikeGeneratorGroup object that contains the spikes in this container.
time_label: Name or number of the label that contains the spike times (def... | [
"def",
"create_SpikeGeneratorGroup",
"(",
"self",
",",
"time_label",
"=",
"0",
",",
"index_label",
"=",
"1",
",",
"reorder_indices",
"=",
"False",
",",
"index_offset",
"=",
"True",
")",
":",
"import",
"brian2",
"spike_times",
"=",
"self",
".",
"spike_times",
... | Creates a brian 2 create_SpikeGeneratorGroup object that contains the spikes in this container.
time_label: Name or number of the label that contains the spike times (default: 0 / first column)
index_label: Name or number of the label that contains the cell indices (default: 1 / ... | [
"Creates",
"a",
"brian",
"2",
"create_SpikeGeneratorGroup",
"object",
"that",
"contains",
"the",
"spikes",
"in",
"this",
"container",
"."
] | 712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e | https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/spikes.py#L1495-L1524 | train | Creates a brian 2 create_SpikeGeneratorGroup object that contains the spikes in this container. |
jahuth/litus | spikes.py | SpikeContainer.to_neo | def to_neo(self,index_label='N',time_label=0,name='segment of exported spikes',index=0):
"""
Returns a `neo` Segment containing the spike trains.
Example usage::
import quantities as pq
seg = sp.to_neo()
fig = pyplot.figure()
... | python | def to_neo(self,index_label='N',time_label=0,name='segment of exported spikes',index=0):
"""
Returns a `neo` Segment containing the spike trains.
Example usage::
import quantities as pq
seg = sp.to_neo()
fig = pyplot.figure()
... | [
"def",
"to_neo",
"(",
"self",
",",
"index_label",
"=",
"'N'",
",",
"time_label",
"=",
"0",
",",
"name",
"=",
"'segment of exported spikes'",
",",
"index",
"=",
"0",
")",
":",
"import",
"neo",
"from",
"quantities",
"import",
"s",
"seq",
"=",
"neo",
".",
... | Returns a `neo` Segment containing the spike trains.
Example usage::
import quantities as pq
seg = sp.to_neo()
fig = pyplot.figure()
trains = [st.rescale('s').magnitude for st in seg.spiketrains]
colors = pyplot.cm.jet(np.li... | [
"Returns",
"a",
"neo",
"Segment",
"containing",
"the",
"spike",
"trains",
"."
] | 712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e | https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/spikes.py#L1525-L1556 | train | Returns a neo. Segment containing the spike trains. |
olitheolix/qtmacs | qtmacs/applets/scieditor.py | SciEditor.qteModificationChanged | def qteModificationChanged(self, mod):
"""
Update the modification status in the mode bar.
This slot is Connected to the ``modificationChanged`` signal
from the ``QtmacsScintilla`` widget.
"""
if mod:
s = '*'
else:
s = '-'
self._qt... | python | def qteModificationChanged(self, mod):
"""
Update the modification status in the mode bar.
This slot is Connected to the ``modificationChanged`` signal
from the ``QtmacsScintilla`` widget.
"""
if mod:
s = '*'
else:
s = '-'
self._qt... | [
"def",
"qteModificationChanged",
"(",
"self",
",",
"mod",
")",
":",
"if",
"mod",
":",
"s",
"=",
"'*'",
"else",
":",
"s",
"=",
"'-'",
"self",
".",
"_qteModeBar",
".",
"qteChangeModeValue",
"(",
"'MODIFIED'",
",",
"s",
")"
] | Update the modification status in the mode bar.
This slot is Connected to the ``modificationChanged`` signal
from the ``QtmacsScintilla`` widget. | [
"Update",
"the",
"modification",
"status",
"in",
"the",
"mode",
"bar",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/applets/scieditor.py#L214-L225 | train | Update the modification status in the mode bar. |
olitheolix/qtmacs | qtmacs/applets/scieditor.py | SciEditor.loadFile | def loadFile(self, fileName):
"""
Display the file ``fileName``.
"""
self.fileName = fileName
# Assign QFile object with the current name.
self.file = QtCore.QFile(fileName)
if self.file.exists():
# Load the file into the widget and reset the undo sta... | python | def loadFile(self, fileName):
"""
Display the file ``fileName``.
"""
self.fileName = fileName
# Assign QFile object with the current name.
self.file = QtCore.QFile(fileName)
if self.file.exists():
# Load the file into the widget and reset the undo sta... | [
"def",
"loadFile",
"(",
"self",
",",
"fileName",
")",
":",
"self",
".",
"fileName",
"=",
"fileName",
"# Assign QFile object with the current name.",
"self",
".",
"file",
"=",
"QtCore",
".",
"QFile",
"(",
"fileName",
")",
"if",
"self",
".",
"file",
".",
"exis... | Display the file ``fileName``. | [
"Display",
"the",
"file",
"fileName",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/applets/scieditor.py#L239-L256 | train | Load the file into the applet and set the text to the current state of the current object. |
noobermin/pys | pys/__init__.py | conv | def conv(arg,default=None,func=None):
'''
essentially, the generalization of
arg if arg else default
or
func(arg) if arg else default
'''
if func:
return func(arg) if arg else default;
else:
return arg if arg else default; | python | def conv(arg,default=None,func=None):
'''
essentially, the generalization of
arg if arg else default
or
func(arg) if arg else default
'''
if func:
return func(arg) if arg else default;
else:
return arg if arg else default; | [
"def",
"conv",
"(",
"arg",
",",
"default",
"=",
"None",
",",
"func",
"=",
"None",
")",
":",
"if",
"func",
":",
"return",
"func",
"(",
"arg",
")",
"if",
"arg",
"else",
"default",
"else",
":",
"return",
"arg",
"if",
"arg",
"else",
"default"
] | essentially, the generalization of
arg if arg else default
or
func(arg) if arg else default | [
"essentially",
"the",
"generalization",
"of",
"arg",
"if",
"arg",
"else",
"default"
] | e01b74210c65eb96d019bb42e0a3c9e6676da943 | https://github.com/noobermin/pys/blob/e01b74210c65eb96d019bb42e0a3c9e6676da943/pys/__init__.py#L10-L23 | train | conv is the generalization of
arg if arg else default ; |
noobermin/pys | pys/__init__.py | dump_pickle | def dump_pickle(name, obj):
'''quick pickle dump similar to np.save'''
with open(name,"wb") as f:
pickle.dump(obj,f,2);
pass; | python | def dump_pickle(name, obj):
'''quick pickle dump similar to np.save'''
with open(name,"wb") as f:
pickle.dump(obj,f,2);
pass; | [
"def",
"dump_pickle",
"(",
"name",
",",
"obj",
")",
":",
"with",
"open",
"(",
"name",
",",
"\"wb\"",
")",
"as",
"f",
":",
"pickle",
".",
"dump",
"(",
"obj",
",",
"f",
",",
"2",
")",
"pass"
] | quick pickle dump similar to np.save | [
"quick",
"pickle",
"dump",
"similar",
"to",
"np",
".",
"save"
] | e01b74210c65eb96d019bb42e0a3c9e6676da943 | https://github.com/noobermin/pys/blob/e01b74210c65eb96d019bb42e0a3c9e6676da943/pys/__init__.py#L36-L40 | train | quick pickle dump similar to np. save |
noobermin/pys | pys/__init__.py | chunks | def chunks(l,n):
'''chunk l in n sized bits'''
#http://stackoverflow.com/a/3226719
#...not that this is hard to understand.
return [l[x:x+n] for x in range(0, len(l), n)]; | python | def chunks(l,n):
'''chunk l in n sized bits'''
#http://stackoverflow.com/a/3226719
#...not that this is hard to understand.
return [l[x:x+n] for x in range(0, len(l), n)]; | [
"def",
"chunks",
"(",
"l",
",",
"n",
")",
":",
"#http://stackoverflow.com/a/3226719",
"#...not that this is hard to understand.",
"return",
"[",
"l",
"[",
"x",
":",
"x",
"+",
"n",
"]",
"for",
"x",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"l",
")",
",",
... | chunk l in n sized bits | [
"chunk",
"l",
"in",
"n",
"sized",
"bits"
] | e01b74210c65eb96d019bb42e0a3c9e6676da943 | https://github.com/noobermin/pys/blob/e01b74210c65eb96d019bb42e0a3c9e6676da943/pys/__init__.py#L48-L52 | train | chunk l in n sized bits |
noobermin/pys | pys/__init__.py | check_vprint | def check_vprint(s, vprinter):
'''checked verbose printing'''
if vprinter is True:
print(s);
elif callable(vprinter):
vprinter(s); | python | def check_vprint(s, vprinter):
'''checked verbose printing'''
if vprinter is True:
print(s);
elif callable(vprinter):
vprinter(s); | [
"def",
"check_vprint",
"(",
"s",
",",
"vprinter",
")",
":",
"if",
"vprinter",
"is",
"True",
":",
"print",
"(",
"s",
")",
"elif",
"callable",
"(",
"vprinter",
")",
":",
"vprinter",
"(",
"s",
")"
] | checked verbose printing | [
"checked",
"verbose",
"printing"
] | e01b74210c65eb96d019bb42e0a3c9e6676da943 | https://github.com/noobermin/pys/blob/e01b74210c65eb96d019bb42e0a3c9e6676da943/pys/__init__.py#L54-L59 | train | checked verbose printing |
noobermin/pys | pys/__init__.py | filelines | def filelines(fname,strip=False):
'''read lines from a file into lines...optional strip'''
with open(fname,'r') as f:
lines = f.readlines();
if strip:
lines[:] = [line.strip() for line in lines]
return lines; | python | def filelines(fname,strip=False):
'''read lines from a file into lines...optional strip'''
with open(fname,'r') as f:
lines = f.readlines();
if strip:
lines[:] = [line.strip() for line in lines]
return lines; | [
"def",
"filelines",
"(",
"fname",
",",
"strip",
"=",
"False",
")",
":",
"with",
"open",
"(",
"fname",
",",
"'r'",
")",
"as",
"f",
":",
"lines",
"=",
"f",
".",
"readlines",
"(",
")",
"if",
"strip",
":",
"lines",
"[",
":",
"]",
"=",
"[",
"line",
... | read lines from a file into lines...optional strip | [
"read",
"lines",
"from",
"a",
"file",
"into",
"lines",
"...",
"optional",
"strip"
] | e01b74210c65eb96d019bb42e0a3c9e6676da943 | https://github.com/noobermin/pys/blob/e01b74210c65eb96d019bb42e0a3c9e6676da943/pys/__init__.py#L69-L75 | train | read lines from a file into lines... optional strip |
noobermin/pys | pys/__init__.py | parse_utuple | def parse_utuple(s,urx,length=2):
'''parse a string into a list of a uniform type'''
if type(urx) != str:
urx=urx.pattern;
if length is not None and length < 1:
raise ValueError("invalid length: {}".format(length));
if length == 1:
rx = r"^ *\( *{urx} *,? *\) *$".format(urx=urx);... | python | def parse_utuple(s,urx,length=2):
'''parse a string into a list of a uniform type'''
if type(urx) != str:
urx=urx.pattern;
if length is not None and length < 1:
raise ValueError("invalid length: {}".format(length));
if length == 1:
rx = r"^ *\( *{urx} *,? *\) *$".format(urx=urx);... | [
"def",
"parse_utuple",
"(",
"s",
",",
"urx",
",",
"length",
"=",
"2",
")",
":",
"if",
"type",
"(",
"urx",
")",
"!=",
"str",
":",
"urx",
"=",
"urx",
".",
"pattern",
"if",
"length",
"is",
"not",
"None",
"and",
"length",
"<",
"1",
":",
"raise",
"V... | parse a string into a list of a uniform type | [
"parse",
"a",
"string",
"into",
"a",
"list",
"of",
"a",
"uniform",
"type"
] | e01b74210c65eb96d019bb42e0a3c9e6676da943 | https://github.com/noobermin/pys/blob/e01b74210c65eb96d019bb42e0a3c9e6676da943/pys/__init__.py#L90-L104 | train | parse a string into a list of a uniform type |
noobermin/pys | pys/__init__.py | parse_numtuple | def parse_numtuple(s,intype,length=2,scale=1):
'''parse a string into a list of numbers of a type'''
if intype == int:
numrx = intrx_s;
elif intype == float:
numrx = fltrx_s;
else:
raise NotImplementedError("Not implemented for type: {}".format(
intype));
if parse... | python | def parse_numtuple(s,intype,length=2,scale=1):
'''parse a string into a list of numbers of a type'''
if intype == int:
numrx = intrx_s;
elif intype == float:
numrx = fltrx_s;
else:
raise NotImplementedError("Not implemented for type: {}".format(
intype));
if parse... | [
"def",
"parse_numtuple",
"(",
"s",
",",
"intype",
",",
"length",
"=",
"2",
",",
"scale",
"=",
"1",
")",
":",
"if",
"intype",
"==",
"int",
":",
"numrx",
"=",
"intrx_s",
"elif",
"intype",
"==",
"float",
":",
"numrx",
"=",
"fltrx_s",
"else",
":",
"rai... | parse a string into a list of numbers of a type | [
"parse",
"a",
"string",
"into",
"a",
"list",
"of",
"numbers",
"of",
"a",
"type"
] | e01b74210c65eb96d019bb42e0a3c9e6676da943 | https://github.com/noobermin/pys/blob/e01b74210c65eb96d019bb42e0a3c9e6676da943/pys/__init__.py#L110-L121 | train | parse a string into a list of numbers of a type |
noobermin/pys | pys/__init__.py | parse_ctuple | def parse_ctuple(s,length=2):
'''parse a string of acceptable colors into matplotlib, that is, either
strings, or three tuples of rgb. Don't quote strings.
'''
if parse_utuple(s, colrx_s, length=length) is None:
raise ValueError("{} is not a valid color tuple.".format(s));
#quote strings
... | python | def parse_ctuple(s,length=2):
'''parse a string of acceptable colors into matplotlib, that is, either
strings, or three tuples of rgb. Don't quote strings.
'''
if parse_utuple(s, colrx_s, length=length) is None:
raise ValueError("{} is not a valid color tuple.".format(s));
#quote strings
... | [
"def",
"parse_ctuple",
"(",
"s",
",",
"length",
"=",
"2",
")",
":",
"if",
"parse_utuple",
"(",
"s",
",",
"colrx_s",
",",
"length",
"=",
"length",
")",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"{} is not a valid color tuple.\"",
".",
"format",
"(",
... | parse a string of acceptable colors into matplotlib, that is, either
strings, or three tuples of rgb. Don't quote strings. | [
"parse",
"a",
"string",
"of",
"acceptable",
"colors",
"into",
"matplotlib",
"that",
"is",
"either",
"strings",
"or",
"three",
"tuples",
"of",
"rgb",
".",
"Don",
"t",
"quote",
"strings",
"."
] | e01b74210c65eb96d019bb42e0a3c9e6676da943 | https://github.com/noobermin/pys/blob/e01b74210c65eb96d019bb42e0a3c9e6676da943/pys/__init__.py#L130-L138 | train | parse a string of acceptable colors into matplotlib that is either
strings or three tuples of rgb. Don t quote strings. |
noobermin/pys | pys/__init__.py | parse_stuple | def parse_stuple(s,length=2):
'''parse a string of strings. Don't quote strings'''
if parse_utuple(s, isrx_s, length=length) is None:
raise ValueError("{} is not a valid string tuple.".format(s));
s = quote_subs(s);
return evalt(s); | python | def parse_stuple(s,length=2):
'''parse a string of strings. Don't quote strings'''
if parse_utuple(s, isrx_s, length=length) is None:
raise ValueError("{} is not a valid string tuple.".format(s));
s = quote_subs(s);
return evalt(s); | [
"def",
"parse_stuple",
"(",
"s",
",",
"length",
"=",
"2",
")",
":",
"if",
"parse_utuple",
"(",
"s",
",",
"isrx_s",
",",
"length",
"=",
"length",
")",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"{} is not a valid string tuple.\"",
".",
"format",
"(",
... | parse a string of strings. Don't quote strings | [
"parse",
"a",
"string",
"of",
"strings",
".",
"Don",
"t",
"quote",
"strings"
] | e01b74210c65eb96d019bb42e0a3c9e6676da943 | https://github.com/noobermin/pys/blob/e01b74210c65eb96d019bb42e0a3c9e6676da943/pys/__init__.py#L140-L145 | train | parse a string of strings. Don t quote strings |
noobermin/pys | pys/__init__.py | parse_colors | def parse_colors(s, length=1):
'''helper for parsing a string that can be either a matplotlib
color or be a tuple of colors. Returns a tuple of them either
way.
'''
if length and length > 1:
return parse_ctuple(s,length=length);
if re.match('^ *{} *$'.format(isrx_s), s):
#i... | python | def parse_colors(s, length=1):
'''helper for parsing a string that can be either a matplotlib
color or be a tuple of colors. Returns a tuple of them either
way.
'''
if length and length > 1:
return parse_ctuple(s,length=length);
if re.match('^ *{} *$'.format(isrx_s), s):
#i... | [
"def",
"parse_colors",
"(",
"s",
",",
"length",
"=",
"1",
")",
":",
"if",
"length",
"and",
"length",
">",
"1",
":",
"return",
"parse_ctuple",
"(",
"s",
",",
"length",
"=",
"length",
")",
"if",
"re",
".",
"match",
"(",
"'^ *{} *$'",
".",
"format",
"... | helper for parsing a string that can be either a matplotlib
color or be a tuple of colors. Returns a tuple of them either
way. | [
"helper",
"for",
"parsing",
"a",
"string",
"that",
"can",
"be",
"either",
"a",
"matplotlib",
"color",
"or",
"be",
"a",
"tuple",
"of",
"colors",
".",
"Returns",
"a",
"tuple",
"of",
"them",
"either",
"way",
"."
] | e01b74210c65eb96d019bb42e0a3c9e6676da943 | https://github.com/noobermin/pys/blob/e01b74210c65eb96d019bb42e0a3c9e6676da943/pys/__init__.py#L155-L168 | train | helper for parsing a string that can be either a matplotlib
color or a tuple of colors. Returns a tuple of them either
way. |
noobermin/pys | pys/__init__.py | parse_qs | def parse_qs(s, rx, parsef=None, length=2, quote=False):
'''helper for parsing a string that can both rx or parsef
which is obstensibly the parsef for rx.
Use parse colors for color tuples. This won't work with
those.
'''
if type(rx) != str:
rx = rx.pattern;
if re.match(" *... | python | def parse_qs(s, rx, parsef=None, length=2, quote=False):
'''helper for parsing a string that can both rx or parsef
which is obstensibly the parsef for rx.
Use parse colors for color tuples. This won't work with
those.
'''
if type(rx) != str:
rx = rx.pattern;
if re.match(" *... | [
"def",
"parse_qs",
"(",
"s",
",",
"rx",
",",
"parsef",
"=",
"None",
",",
"length",
"=",
"2",
",",
"quote",
"=",
"False",
")",
":",
"if",
"type",
"(",
"rx",
")",
"!=",
"str",
":",
"rx",
"=",
"rx",
".",
"pattern",
"if",
"re",
".",
"match",
"(",... | helper for parsing a string that can both rx or parsef
which is obstensibly the parsef for rx.
Use parse colors for color tuples. This won't work with
those. | [
"helper",
"for",
"parsing",
"a",
"string",
"that",
"can",
"both",
"rx",
"or",
"parsef",
"which",
"is",
"obstensibly",
"the",
"parsef",
"for",
"rx",
"."
] | e01b74210c65eb96d019bb42e0a3c9e6676da943 | https://github.com/noobermin/pys/blob/e01b74210c65eb96d019bb42e0a3c9e6676da943/pys/__init__.py#L170-L196 | train | helper for parsing a string that can both rx or parsef
Use parse colors for color tuples. This will not work with any color tuples. |
noobermin/pys | pys/__init__.py | destr | def destr(d,*l):
'''destructure a dict (like take, but return a list)'''
if type(l[0]) is not str:
l=l[0];
return [d[i] for i in l]; | python | def destr(d,*l):
'''destructure a dict (like take, but return a list)'''
if type(l[0]) is not str:
l=l[0];
return [d[i] for i in l]; | [
"def",
"destr",
"(",
"d",
",",
"*",
"l",
")",
":",
"if",
"type",
"(",
"l",
"[",
"0",
"]",
")",
"is",
"not",
"str",
":",
"l",
"=",
"l",
"[",
"0",
"]",
"return",
"[",
"d",
"[",
"i",
"]",
"for",
"i",
"in",
"l",
"]"
] | destructure a dict (like take, but return a list) | [
"destructure",
"a",
"dict",
"(",
"like",
"take",
"but",
"return",
"a",
"list",
")"
] | e01b74210c65eb96d019bb42e0a3c9e6676da943 | https://github.com/noobermin/pys/blob/e01b74210c65eb96d019bb42e0a3c9e6676da943/pys/__init__.py#L239-L243 | train | destructure a dict ( like take but return a list |
noobermin/pys | pys/__init__.py | takef | def takef(d,l,val=None):
'''take(f) a list of keys and fill in others with val'''
return {i:(d[i] if i in d else val)
for i in l}; | python | def takef(d,l,val=None):
'''take(f) a list of keys and fill in others with val'''
return {i:(d[i] if i in d else val)
for i in l}; | [
"def",
"takef",
"(",
"d",
",",
"l",
",",
"val",
"=",
"None",
")",
":",
"return",
"{",
"i",
":",
"(",
"d",
"[",
"i",
"]",
"if",
"i",
"in",
"d",
"else",
"val",
")",
"for",
"i",
"in",
"l",
"}"
] | take(f) a list of keys and fill in others with val | [
"take",
"(",
"f",
")",
"a",
"list",
"of",
"keys",
"and",
"fill",
"in",
"others",
"with",
"val"
] | e01b74210c65eb96d019bb42e0a3c9e6676da943 | https://github.com/noobermin/pys/blob/e01b74210c65eb96d019bb42e0a3c9e6676da943/pys/__init__.py#L245-L248 | train | take a list of keys and fill in others with val |
noobermin/pys | pys/__init__.py | mk_getkw | def mk_getkw(kw, defaults,prefer_passed=False):
'''
a helper for generating a function for reading keywords in
interface functions with a dictionary with defaults
expects the defaults dictionary to have keywords you request.
example:
defaults = dict(a='a',b=3);
def bigfunc(**kw):
g... | python | def mk_getkw(kw, defaults,prefer_passed=False):
'''
a helper for generating a function for reading keywords in
interface functions with a dictionary with defaults
expects the defaults dictionary to have keywords you request.
example:
defaults = dict(a='a',b=3);
def bigfunc(**kw):
g... | [
"def",
"mk_getkw",
"(",
"kw",
",",
"defaults",
",",
"prefer_passed",
"=",
"False",
")",
":",
"def",
"getkw",
"(",
"*",
"ls",
")",
":",
"r",
"=",
"[",
"kw",
"[",
"l",
"]",
"if",
"test",
"(",
"kw",
",",
"l",
")",
"else",
"defaults",
"[",
"l",
"... | a helper for generating a function for reading keywords in
interface functions with a dictionary with defaults
expects the defaults dictionary to have keywords you request.
example:
defaults = dict(a='a',b=3);
def bigfunc(**kw):
getkw=mk_getkw(kw,defaults);
# I want the callers' `... | [
"a",
"helper",
"for",
"generating",
"a",
"function",
"for",
"reading",
"keywords",
"in",
"interface",
"functions",
"with",
"a",
"dictionary",
"with",
"defaults"
] | e01b74210c65eb96d019bb42e0a3c9e6676da943 | https://github.com/noobermin/pys/blob/e01b74210c65eb96d019bb42e0a3c9e6676da943/pys/__init__.py#L250-L281 | train | creates a helper for generating a function for reading keywords in
interface functions with a dictionary with defaults dictionary with keywords you request. |
consbio/restle | restle/resources.py | Resource._load_resource | def _load_resource(self):
"""Load resource data from server"""
url = self._url
if self._params:
url += '?{0}'.format(six.moves.urllib_parse.urlencode(self._params))
r = getattr(self._session, self._meta.get_method.lower())(url)
if r.status_code == 404:
... | python | def _load_resource(self):
"""Load resource data from server"""
url = self._url
if self._params:
url += '?{0}'.format(six.moves.urllib_parse.urlencode(self._params))
r = getattr(self._session, self._meta.get_method.lower())(url)
if r.status_code == 404:
... | [
"def",
"_load_resource",
"(",
"self",
")",
":",
"url",
"=",
"self",
".",
"_url",
"if",
"self",
".",
"_params",
":",
"url",
"+=",
"'?{0}'",
".",
"format",
"(",
"six",
".",
"moves",
".",
"urllib_parse",
".",
"urlencode",
"(",
"self",
".",
"_params",
")... | Load resource data from server | [
"Load",
"resource",
"data",
"from",
"server"
] | 60d100da034c612d4910f4f79eaa57a76eb3dcc6 | https://github.com/consbio/restle/blob/60d100da034c612d4910f4f79eaa57a76eb3dcc6/restle/resources.py#L69-L84 | train | Load resource data from server |
consbio/restle | restle/resources.py | Resource.populate_field_values | def populate_field_values(self, data):
"""Load resource data and populate field values"""
if not self._meta.case_sensitive_fields:
data = {k.lower(): v for k, v in six.iteritems(data)}
if self._meta.match_fuzzy_keys:
# String any non-alphanumeric chars from each key
... | python | def populate_field_values(self, data):
"""Load resource data and populate field values"""
if not self._meta.case_sensitive_fields:
data = {k.lower(): v for k, v in six.iteritems(data)}
if self._meta.match_fuzzy_keys:
# String any non-alphanumeric chars from each key
... | [
"def",
"populate_field_values",
"(",
"self",
",",
"data",
")",
":",
"if",
"not",
"self",
".",
"_meta",
".",
"case_sensitive_fields",
":",
"data",
"=",
"{",
"k",
".",
"lower",
"(",
")",
":",
"v",
"for",
"k",
",",
"v",
"in",
"six",
".",
"iteritems",
... | Load resource data and populate field values | [
"Load",
"resource",
"data",
"and",
"populate",
"field",
"values"
] | 60d100da034c612d4910f4f79eaa57a76eb3dcc6 | https://github.com/consbio/restle/blob/60d100da034c612d4910f4f79eaa57a76eb3dcc6/restle/resources.py#L86-L116 | train | Load resource data and populate field values |
a1ezzz/wasp-general | wasp_general/task/thread.py | WThreadTask.close_thread | def close_thread(self):
""" Clear all object descriptors for stopped task. Task must be joined prior to calling this method.
:return: None
"""
if self.__thread is not None and self.__thread.is_alive() is True:
raise WThreadJoiningTimeoutError('Thread is still alive. Thread name: %s' % self.__thread.name)
... | python | def close_thread(self):
""" Clear all object descriptors for stopped task. Task must be joined prior to calling this method.
:return: None
"""
if self.__thread is not None and self.__thread.is_alive() is True:
raise WThreadJoiningTimeoutError('Thread is still alive. Thread name: %s' % self.__thread.name)
... | [
"def",
"close_thread",
"(",
"self",
")",
":",
"if",
"self",
".",
"__thread",
"is",
"not",
"None",
"and",
"self",
".",
"__thread",
".",
"is_alive",
"(",
")",
"is",
"True",
":",
"raise",
"WThreadJoiningTimeoutError",
"(",
"'Thread is still alive. Thread name: %s'"... | Clear all object descriptors for stopped task. Task must be joined prior to calling this method.
:return: None | [
"Clear",
"all",
"object",
"descriptors",
"for",
"stopped",
"task",
".",
"Task",
"must",
"be",
"joined",
"prior",
"to",
"calling",
"this",
"method",
"."
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/thread.py#L166-L174 | train | Closes all object descriptors for stopped task. |
a1ezzz/wasp-general | wasp_general/task/thread.py | WThreadTask.start | def start(self):
""" :meth:`WStoppableTask.start` implementation that creates new thread
"""
start_event = self.start_event()
stop_event = self.stop_event()
ready_event = self.ready_event()
def thread_target():
try:
start_event.set()
self.thread_started()
if ready_event is not None:
re... | python | def start(self):
""" :meth:`WStoppableTask.start` implementation that creates new thread
"""
start_event = self.start_event()
stop_event = self.stop_event()
ready_event = self.ready_event()
def thread_target():
try:
start_event.set()
self.thread_started()
if ready_event is not None:
re... | [
"def",
"start",
"(",
"self",
")",
":",
"start_event",
"=",
"self",
".",
"start_event",
"(",
")",
"stop_event",
"=",
"self",
".",
"stop_event",
"(",
")",
"ready_event",
"=",
"self",
".",
"ready_event",
"(",
")",
"def",
"thread_target",
"(",
")",
":",
"t... | :meth:`WStoppableTask.start` implementation that creates new thread | [
":",
"meth",
":",
"WStoppableTask",
".",
"start",
"implementation",
"that",
"creates",
"new",
"thread"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/thread.py#L176-L204 | train | method that creates new thread
|
a1ezzz/wasp-general | wasp_general/task/thread.py | WThreadTask.stop | def stop(self):
""" :meth:`WStoppableTask.stop` implementation that sets stop even (if available), calls
:meth:`WStoppableTask.threaded_stopped` and cleans up thread (if configured)
"""
thread = self.thread()
if thread is not None:
if self.stop_event() is not None:
self.stop_event().set()
self.thre... | python | def stop(self):
""" :meth:`WStoppableTask.stop` implementation that sets stop even (if available), calls
:meth:`WStoppableTask.threaded_stopped` and cleans up thread (if configured)
"""
thread = self.thread()
if thread is not None:
if self.stop_event() is not None:
self.stop_event().set()
self.thre... | [
"def",
"stop",
"(",
"self",
")",
":",
"thread",
"=",
"self",
".",
"thread",
"(",
")",
"if",
"thread",
"is",
"not",
"None",
":",
"if",
"self",
".",
"stop_event",
"(",
")",
"is",
"not",
"None",
":",
"self",
".",
"stop_event",
"(",
")",
".",
"set",
... | :meth:`WStoppableTask.stop` implementation that sets stop even (if available), calls
:meth:`WStoppableTask.threaded_stopped` and cleans up thread (if configured) | [
":",
"meth",
":",
"WStoppableTask",
".",
"stop",
"implementation",
"that",
"sets",
"stop",
"even",
"(",
"if",
"available",
")",
"calls",
":",
"meth",
":",
"WStoppableTask",
".",
"threaded_stopped",
"and",
"cleans",
"up",
"thread",
"(",
"if",
"configured",
")... | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/thread.py#L206-L219 | train | stop method for this object |
a1ezzz/wasp-general | wasp_general/task/thread.py | WThreadTask.thread_exception | def thread_exception(self, raised_exception):
""" Callback for handling exception, that are raised inside :meth:`.WThreadTask.thread_started`
:param raised_exception: raised exception
:return: None
"""
print('Thread execution was stopped by the exception. Exception: %s' % str(raised_exception))
print('Trac... | python | def thread_exception(self, raised_exception):
""" Callback for handling exception, that are raised inside :meth:`.WThreadTask.thread_started`
:param raised_exception: raised exception
:return: None
"""
print('Thread execution was stopped by the exception. Exception: %s' % str(raised_exception))
print('Trac... | [
"def",
"thread_exception",
"(",
"self",
",",
"raised_exception",
")",
":",
"print",
"(",
"'Thread execution was stopped by the exception. Exception: %s'",
"%",
"str",
"(",
"raised_exception",
")",
")",
"print",
"(",
"'Traceback:'",
")",
"print",
"(",
"traceback",
".",... | Callback for handling exception, that are raised inside :meth:`.WThreadTask.thread_started`
:param raised_exception: raised exception
:return: None | [
"Callback",
"for",
"handling",
"exception",
"that",
"are",
"raised",
"inside",
":",
"meth",
":",
".",
"WThreadTask",
".",
"thread_started"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/thread.py#L237-L245 | train | Callback for handling exception that are raised inside thread_started |
a1ezzz/wasp-general | wasp_general/task/thread.py | WThreadTask.check_events | def check_events(self):
""" Check "stopping"-events ('ready_event', 'stop_event', 'exception_event') if one of them is set.
Usually True value means that thread is meant to be stopped, means that it is finished its job or
some error has happened or this thread was asked to stop
:return: bool
"""
return (
... | python | def check_events(self):
""" Check "stopping"-events ('ready_event', 'stop_event', 'exception_event') if one of them is set.
Usually True value means that thread is meant to be stopped, means that it is finished its job or
some error has happened or this thread was asked to stop
:return: bool
"""
return (
... | [
"def",
"check_events",
"(",
"self",
")",
":",
"return",
"(",
"self",
".",
"ready_event",
"(",
")",
".",
"is_set",
"(",
")",
"is",
"True",
"or",
"self",
".",
"stop_event",
"(",
")",
".",
"is_set",
"(",
")",
"is",
"True",
"or",
"self",
".",
"exceptio... | Check "stopping"-events ('ready_event', 'stop_event', 'exception_event') if one of them is set.
Usually True value means that thread is meant to be stopped, means that it is finished its job or
some error has happened or this thread was asked to stop
:return: bool | [
"Check",
"stopping",
"-",
"events",
"(",
"ready_event",
"stop_event",
"exception_event",
")",
"if",
"one",
"of",
"them",
"is",
"set",
".",
"Usually",
"True",
"value",
"means",
"that",
"thread",
"is",
"meant",
"to",
"be",
"stopped",
"means",
"that",
"it",
"... | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/thread.py#L247-L258 | train | Check if any of the events in the queue are set. |
a1ezzz/wasp-general | wasp_general/task/thread.py | WThreadCustomTask.thread_stopped | def thread_stopped(self):
""" If original task is :class:`.WStoppableTask` object, then stop it
:return: None
"""
task = self.task()
if isinstance(task, WStoppableTask) is True:
task.stop() | python | def thread_stopped(self):
""" If original task is :class:`.WStoppableTask` object, then stop it
:return: None
"""
task = self.task()
if isinstance(task, WStoppableTask) is True:
task.stop() | [
"def",
"thread_stopped",
"(",
"self",
")",
":",
"task",
"=",
"self",
".",
"task",
"(",
")",
"if",
"isinstance",
"(",
"task",
",",
"WStoppableTask",
")",
"is",
"True",
":",
"task",
".",
"stop",
"(",
")"
] | If original task is :class:`.WStoppableTask` object, then stop it
:return: None | [
"If",
"original",
"task",
"is",
":",
"class",
":",
".",
"WStoppableTask",
"object",
"then",
"stop",
"it"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/thread.py#L300-L307 | train | Stop thread if task is stoppable |
a1ezzz/wasp-general | wasp_general/task/thread.py | WPollingThreadTask.thread_started | def thread_started(self):
""" Start polling for a stop event or ready event and do small work via
:meth:`.WPollingThreadTask._polling_iteration` method call
:return: None
"""
while self.check_events() is False:
self._polling_iteration()
self.stop_event().wait(self.polling_timeout()) | python | def thread_started(self):
""" Start polling for a stop event or ready event and do small work via
:meth:`.WPollingThreadTask._polling_iteration` method call
:return: None
"""
while self.check_events() is False:
self._polling_iteration()
self.stop_event().wait(self.polling_timeout()) | [
"def",
"thread_started",
"(",
"self",
")",
":",
"while",
"self",
".",
"check_events",
"(",
")",
"is",
"False",
":",
"self",
".",
"_polling_iteration",
"(",
")",
"self",
".",
"stop_event",
"(",
")",
".",
"wait",
"(",
"self",
".",
"polling_timeout",
"(",
... | Start polling for a stop event or ready event and do small work via
:meth:`.WPollingThreadTask._polling_iteration` method call
:return: None | [
"Start",
"polling",
"for",
"a",
"stop",
"event",
"or",
"ready",
"event",
"and",
"do",
"small",
"work",
"via",
":",
"meth",
":",
".",
"WPollingThreadTask",
".",
"_polling_iteration",
"method",
"call"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/thread.py#L354-L362 | train | Start polling for a stop event or ready event via
. _polling_iteration method |
a1ezzz/wasp-general | wasp_general/task/thread.py | WThreadedTaskChain._polling_iteration | def _polling_iteration(self):
""" :meth:`.WPollingThreadTask._polling_iteration` implementation
"""
if len(self.__task_chain) > 0:
if self.__current_task is None:
self.__current_task = 0
task = self.__task_chain[self.__current_task]
if task.thread() is None:
task.start()
elif task.ready_event... | python | def _polling_iteration(self):
""" :meth:`.WPollingThreadTask._polling_iteration` implementation
"""
if len(self.__task_chain) > 0:
if self.__current_task is None:
self.__current_task = 0
task = self.__task_chain[self.__current_task]
if task.thread() is None:
task.start()
elif task.ready_event... | [
"def",
"_polling_iteration",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"__task_chain",
")",
">",
"0",
":",
"if",
"self",
".",
"__current_task",
"is",
"None",
":",
"self",
".",
"__current_task",
"=",
"0",
"task",
"=",
"self",
".",
"__task_ch... | :meth:`.WPollingThreadTask._polling_iteration` implementation | [
":",
"meth",
":",
".",
"WPollingThreadTask",
".",
"_polling_iteration",
"implementation"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/thread.py#L400-L419 | train | method for polling iteration |
a1ezzz/wasp-general | wasp_general/task/thread.py | WThreadedTaskChain.thread_stopped | def thread_stopped(self):
""" :meth:`.WThreadTask._polling_iteration` implementation
"""
if self.__current_task is not None:
task = self.__task_chain[self.__current_task]
task.stop()
self.__current_task = None | python | def thread_stopped(self):
""" :meth:`.WThreadTask._polling_iteration` implementation
"""
if self.__current_task is not None:
task = self.__task_chain[self.__current_task]
task.stop()
self.__current_task = None | [
"def",
"thread_stopped",
"(",
"self",
")",
":",
"if",
"self",
".",
"__current_task",
"is",
"not",
"None",
":",
"task",
"=",
"self",
".",
"__task_chain",
"[",
"self",
".",
"__current_task",
"]",
"task",
".",
"stop",
"(",
")",
"self",
".",
"__current_task"... | :meth:`.WThreadTask._polling_iteration` implementation | [
":",
"meth",
":",
".",
"WThreadTask",
".",
"_polling_iteration",
"implementation"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/thread.py#L421-L427 | train | Stop the current thread if it is running. |
pmacosta/pexdoc | docs/support/trace_my_module_1.py | trace_module | def trace_module(no_print=True):
"""Trace my_module exceptions."""
pwd = os.path.dirname(__file__)
script_name = os.path.join(pwd, "test_my_module.py")
with pexdoc.ExDocCxt() as exdoc_obj:
if pytest.main(["-s", "-vv", "-x", "{0}".format(script_name)]):
raise RuntimeError("Tracing did... | python | def trace_module(no_print=True):
"""Trace my_module exceptions."""
pwd = os.path.dirname(__file__)
script_name = os.path.join(pwd, "test_my_module.py")
with pexdoc.ExDocCxt() as exdoc_obj:
if pytest.main(["-s", "-vv", "-x", "{0}".format(script_name)]):
raise RuntimeError("Tracing did... | [
"def",
"trace_module",
"(",
"no_print",
"=",
"True",
")",
":",
"pwd",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
"script_name",
"=",
"os",
".",
"path",
".",
"join",
"(",
"pwd",
",",
"\"test_my_module.py\"",
")",
"with",
"pexdoc",
"."... | Trace my_module exceptions. | [
"Trace",
"my_module",
"exceptions",
"."
] | 201ac243e5781347feb75896a4231429fe6da4b1 | https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/docs/support/trace_my_module_1.py#L14-L29 | train | Trace my_module exceptions. |
a1ezzz/wasp-general | wasp_general/network/web/headers.py | WHTTPHeaders.header_name_check | def header_name_check(header_name):
""" Check header name for validity. Return True if name is valid
:param header_name: name to check
:return: bool
"""
header_match = WHTTPHeaders.header_name_re.match(header_name.encode('us-ascii'))
return len(header_name) > 0 and header_match is not None | python | def header_name_check(header_name):
""" Check header name for validity. Return True if name is valid
:param header_name: name to check
:return: bool
"""
header_match = WHTTPHeaders.header_name_re.match(header_name.encode('us-ascii'))
return len(header_name) > 0 and header_match is not None | [
"def",
"header_name_check",
"(",
"header_name",
")",
":",
"header_match",
"=",
"WHTTPHeaders",
".",
"header_name_re",
".",
"match",
"(",
"header_name",
".",
"encode",
"(",
"'us-ascii'",
")",
")",
"return",
"len",
"(",
"header_name",
")",
">",
"0",
"and",
"he... | Check header name for validity. Return True if name is valid
:param header_name: name to check
:return: bool | [
"Check",
"header",
"name",
"for",
"validity",
".",
"Return",
"True",
"if",
"name",
"is",
"valid"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/web/headers.py#L53-L60 | train | Check header name for validity. Return True if name is valid otherwise False |
a1ezzz/wasp-general | wasp_general/network/web/headers.py | WHTTPHeaders.remove_headers | def remove_headers(self, header_name):
""" Remove header by its name
:param header_name: name of header to remove
:return: None
"""
if self.__ro_flag:
raise RuntimeError('ro')
header_name = self.normalize_name(header_name)
if header_name in self.__headers.keys():
self.__headers.pop(header_name) | python | def remove_headers(self, header_name):
""" Remove header by its name
:param header_name: name of header to remove
:return: None
"""
if self.__ro_flag:
raise RuntimeError('ro')
header_name = self.normalize_name(header_name)
if header_name in self.__headers.keys():
self.__headers.pop(header_name) | [
"def",
"remove_headers",
"(",
"self",
",",
"header_name",
")",
":",
"if",
"self",
".",
"__ro_flag",
":",
"raise",
"RuntimeError",
"(",
"'ro'",
")",
"header_name",
"=",
"self",
".",
"normalize_name",
"(",
"header_name",
")",
"if",
"header_name",
"in",
"self",... | Remove header by its name
:param header_name: name of header to remove
:return: None | [
"Remove",
"header",
"by",
"its",
"name"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/web/headers.py#L83-L93 | train | Removes a header by its name |
a1ezzz/wasp-general | wasp_general/network/web/headers.py | WHTTPHeaders.add_headers | def add_headers(self, header_name, value, *values):
""" Add new header
:param header_name: name of the header to add
:param value: header value
:param values: additional header values (in a result request/response must be concatenated by the coma \
or by the separate header string)
:return: None
"""
if... | python | def add_headers(self, header_name, value, *values):
""" Add new header
:param header_name: name of the header to add
:param value: header value
:param values: additional header values (in a result request/response must be concatenated by the coma \
or by the separate header string)
:return: None
"""
if... | [
"def",
"add_headers",
"(",
"self",
",",
"header_name",
",",
"value",
",",
"*",
"values",
")",
":",
"if",
"self",
".",
"__ro_flag",
":",
"raise",
"RuntimeError",
"(",
"'ro'",
")",
"header_name",
"=",
"self",
".",
"normalize_name",
"(",
"header_name",
")",
... | Add new header
:param header_name: name of the header to add
:param value: header value
:param values: additional header values (in a result request/response must be concatenated by the coma \
or by the separate header string)
:return: None | [
"Add",
"new",
"header"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/web/headers.py#L98-L116 | train | Add new header to the response |
a1ezzz/wasp-general | wasp_general/network/web/headers.py | WHTTPHeaders.replace_headers | def replace_headers(self, header_name, value, *values):
""" Replace header value with specified value and/or values
:param header_name: target header
:param value: new header value
:param values: additional header values (in a result request/response must be concatenated by the coma \
or by the separate head... | python | def replace_headers(self, header_name, value, *values):
""" Replace header value with specified value and/or values
:param header_name: target header
:param value: new header value
:param values: additional header values (in a result request/response must be concatenated by the coma \
or by the separate head... | [
"def",
"replace_headers",
"(",
"self",
",",
"header_name",
",",
"value",
",",
"*",
"values",
")",
":",
"if",
"self",
".",
"__ro_flag",
":",
"raise",
"RuntimeError",
"(",
"'ro'",
")",
"header_name",
"=",
"self",
".",
"normalize_name",
"(",
"header_name",
")... | Replace header value with specified value and/or values
:param header_name: target header
:param value: new header value
:param values: additional header values (in a result request/response must be concatenated by the coma \
or by the separate header string)
:return: None | [
"Replace",
"header",
"value",
"with",
"specified",
"value",
"and",
"/",
"or",
"values"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/web/headers.py#L120-L133 | train | Replace header value with specified value and or values and return None |
a1ezzz/wasp-general | wasp_general/network/web/headers.py | WHTTPHeaders.get_headers | def get_headers(self, header_name):
""" Return header value by its name
:param header_name: header name
:return: tuple of str
"""
header_name = self.normalize_name(header_name)
if header_name in self.__headers.keys():
return tuple(self.__headers[header_name]) | python | def get_headers(self, header_name):
""" Return header value by its name
:param header_name: header name
:return: tuple of str
"""
header_name = self.normalize_name(header_name)
if header_name in self.__headers.keys():
return tuple(self.__headers[header_name]) | [
"def",
"get_headers",
"(",
"self",
",",
"header_name",
")",
":",
"header_name",
"=",
"self",
".",
"normalize_name",
"(",
"header_name",
")",
"if",
"header_name",
"in",
"self",
".",
"__headers",
".",
"keys",
"(",
")",
":",
"return",
"tuple",
"(",
"self",
... | Return header value by its name
:param header_name: header name
:return: tuple of str | [
"Return",
"header",
"value",
"by",
"its",
"name"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/web/headers.py#L137-L145 | train | Return header value by its name
header |
a1ezzz/wasp-general | wasp_general/network/web/headers.py | WHTTPHeaders.normalize_name | def normalize_name(self, header_name):
""" Return header name as it is recommended (required) by corresponding http protocol. For
protocol switching use :meth:`.WHTTPHeaders.switch_name_style` method.
All current available protocols (0.9-2) compare header names in a case-insensitive fashion. However,
previous ... | python | def normalize_name(self, header_name):
""" Return header name as it is recommended (required) by corresponding http protocol. For
protocol switching use :meth:`.WHTTPHeaders.switch_name_style` method.
All current available protocols (0.9-2) compare header names in a case-insensitive fashion. However,
previous ... | [
"def",
"normalize_name",
"(",
"self",
",",
"header_name",
")",
":",
"if",
"self",
".",
"__normalization_mode",
"in",
"[",
"'0.9'",
",",
"'1.0'",
",",
"'1.1'",
"]",
":",
"return",
"'-'",
".",
"join",
"(",
"[",
"x",
".",
"capitalize",
"(",
")",
"for",
... | Return header name as it is recommended (required) by corresponding http protocol. For
protocol switching use :meth:`.WHTTPHeaders.switch_name_style` method.
All current available protocols (0.9-2) compare header names in a case-insensitive fashion. However,
previous protocol versions (0.9-1.1) recommends to use... | [
"Return",
"header",
"name",
"as",
"it",
"is",
"recommended",
"(",
"required",
")",
"by",
"corresponding",
"http",
"protocol",
".",
"For",
"protocol",
"switching",
"use",
":",
"meth",
":",
".",
"WHTTPHeaders",
".",
"switch_name_style",
"method",
"."
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/web/headers.py#L159-L174 | train | Return header name as it is recommended by corresponding http protocol. For
HTTP version 0. 9 - 2 and 0. 1 - 1. 1 are supported. |
a1ezzz/wasp-general | wasp_general/network/web/headers.py | WHTTPHeaders.switch_name_style | def switch_name_style(self, http_protocol_version):
""" Return object copy with header names saved as it is described in the given protocol version
see :meth:`.WHTTPHeaders.normalize_name`
:param http_protocol_version: target HTTP protocol version
:return: WHTTPHeaders
"""
new_headers = WHTTPHeaders()
n... | python | def switch_name_style(self, http_protocol_version):
""" Return object copy with header names saved as it is described in the given protocol version
see :meth:`.WHTTPHeaders.normalize_name`
:param http_protocol_version: target HTTP protocol version
:return: WHTTPHeaders
"""
new_headers = WHTTPHeaders()
n... | [
"def",
"switch_name_style",
"(",
"self",
",",
"http_protocol_version",
")",
":",
"new_headers",
"=",
"WHTTPHeaders",
"(",
")",
"new_headers",
".",
"__normalization_mode",
"=",
"http_protocol_version",
"names",
"=",
"self",
".",
"headers",
"(",
")",
"for",
"name",
... | Return object copy with header names saved as it is described in the given protocol version
see :meth:`.WHTTPHeaders.normalize_name`
:param http_protocol_version: target HTTP protocol version
:return: WHTTPHeaders | [
"Return",
"object",
"copy",
"with",
"header",
"names",
"saved",
"as",
"it",
"is",
"described",
"in",
"the",
"given",
"protocol",
"version"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/web/headers.py#L178-L193 | train | Return object copy with header names saved as it is described in the given HTTP protocol version. |
a1ezzz/wasp-general | wasp_general/network/web/headers.py | WHTTPHeaders.ro | def ro(self):
""" Return read-only copy of this object
:return: WHTTPHeaders
"""
ro_headers = WHTTPHeaders()
names = self.headers()
for name in names:
ro_headers.add_headers(name, *self.get_headers(name))
ro_headers.__cookies = self.__set_cookies.ro()
ro_headers.__ro_flag = True
return ro_headers | python | def ro(self):
""" Return read-only copy of this object
:return: WHTTPHeaders
"""
ro_headers = WHTTPHeaders()
names = self.headers()
for name in names:
ro_headers.add_headers(name, *self.get_headers(name))
ro_headers.__cookies = self.__set_cookies.ro()
ro_headers.__ro_flag = True
return ro_headers | [
"def",
"ro",
"(",
"self",
")",
":",
"ro_headers",
"=",
"WHTTPHeaders",
"(",
")",
"names",
"=",
"self",
".",
"headers",
"(",
")",
"for",
"name",
"in",
"names",
":",
"ro_headers",
".",
"add_headers",
"(",
"name",
",",
"*",
"self",
".",
"get_headers",
"... | Return read-only copy of this object
:return: WHTTPHeaders | [
"Return",
"read",
"-",
"only",
"copy",
"of",
"this",
"object"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/web/headers.py#L195-L206 | train | Return read - only copy of this object |
a1ezzz/wasp-general | wasp_general/network/web/headers.py | WHTTPHeaders.content_type | def content_type(self, value=None):
""" Set (replace) and or get "Content-Type" header value
:param value: value to set (if specified)
:return: None if header doesn't exist, otherwise - str
"""
content_type = self.normalize_name('Content-Type')
if value is not None:
self.replace_headers(content_type, va... | python | def content_type(self, value=None):
""" Set (replace) and or get "Content-Type" header value
:param value: value to set (if specified)
:return: None if header doesn't exist, otherwise - str
"""
content_type = self.normalize_name('Content-Type')
if value is not None:
self.replace_headers(content_type, va... | [
"def",
"content_type",
"(",
"self",
",",
"value",
"=",
"None",
")",
":",
"content_type",
"=",
"self",
".",
"normalize_name",
"(",
"'Content-Type'",
")",
"if",
"value",
"is",
"not",
"None",
":",
"self",
".",
"replace_headers",
"(",
"content_type",
",",
"val... | Set (replace) and or get "Content-Type" header value
:param value: value to set (if specified)
:return: None if header doesn't exist, otherwise - str | [
"Set",
"(",
"replace",
")",
"and",
"or",
"get",
"Content",
"-",
"Type",
"header",
"value"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/web/headers.py#L209-L219 | train | Set or get Content - Type header value |
a1ezzz/wasp-general | wasp_general/network/web/headers.py | WHTTPHeaders.client_cookie_jar | def client_cookie_jar(self):
""" Return internal cookie jar that must be used as HTTP-request cookies
see :class:`.WHTTPCookieJar`
:return: WHTTPCookieJar
"""
cookie_jar = WHTTPCookieJar()
cookie_header = self.get_headers('Cookie')
for cookie_string in (cookie_header if cookie_header is not None else tu... | python | def client_cookie_jar(self):
""" Return internal cookie jar that must be used as HTTP-request cookies
see :class:`.WHTTPCookieJar`
:return: WHTTPCookieJar
"""
cookie_jar = WHTTPCookieJar()
cookie_header = self.get_headers('Cookie')
for cookie_string in (cookie_header if cookie_header is not None else tu... | [
"def",
"client_cookie_jar",
"(",
"self",
")",
":",
"cookie_jar",
"=",
"WHTTPCookieJar",
"(",
")",
"cookie_header",
"=",
"self",
".",
"get_headers",
"(",
"'Cookie'",
")",
"for",
"cookie_string",
"in",
"(",
"cookie_header",
"if",
"cookie_header",
"is",
"not",
"N... | Return internal cookie jar that must be used as HTTP-request cookies
see :class:`.WHTTPCookieJar`
:return: WHTTPCookieJar | [
"Return",
"internal",
"cookie",
"jar",
"that",
"must",
"be",
"used",
"as",
"HTTP",
"-",
"request",
"cookies"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/web/headers.py#L230-L243 | train | Return internal cookie jar that must be used as HTTP - request cookies
see : class :. WHTTPCookieJar |
a1ezzz/wasp-general | wasp_general/network/web/headers.py | WHTTPHeaders.import_headers | def import_headers(cls, http_code):
""" Create WHTTPHeaders by the given code. If code has 'Set-Cookie' headers, that headers are
parsed, data are stored in internal cookie jar. At the end of parsing 'Set-Cookie' headers are
removed from the result
:param http_code: HTTP code to parse
:return: WHTTPHeaders
... | python | def import_headers(cls, http_code):
""" Create WHTTPHeaders by the given code. If code has 'Set-Cookie' headers, that headers are
parsed, data are stored in internal cookie jar. At the end of parsing 'Set-Cookie' headers are
removed from the result
:param http_code: HTTP code to parse
:return: WHTTPHeaders
... | [
"def",
"import_headers",
"(",
"cls",
",",
"http_code",
")",
":",
"headers",
"=",
"WHTTPHeaders",
"(",
")",
"message",
"=",
"email",
".",
"message_from_file",
"(",
"StringIO",
"(",
"http_code",
")",
")",
"for",
"header_name",
",",
"header_value",
"in",
"messa... | Create WHTTPHeaders by the given code. If code has 'Set-Cookie' headers, that headers are
parsed, data are stored in internal cookie jar. At the end of parsing 'Set-Cookie' headers are
removed from the result
:param http_code: HTTP code to parse
:return: WHTTPHeaders | [
"Create",
"WHTTPHeaders",
"by",
"the",
"given",
"code",
".",
"If",
"code",
"has",
"Set",
"-",
"Cookie",
"headers",
"that",
"headers",
"are",
"parsed",
"data",
"are",
"stored",
"in",
"internal",
"cookie",
"jar",
".",
"At",
"the",
"end",
"of",
"parsing",
"... | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/web/headers.py#L247-L267 | train | Create WHTTPHeaders by the given HTTP code. |
pmacosta/pexdoc | docs/support/trace_my_module_2.py | trace_module | def trace_module(no_print=True):
"""Trace my_module_original exceptions."""
with pexdoc.ExDocCxt() as exdoc_obj:
try:
docs.support.my_module.func("John")
obj = docs.support.my_module.MyClass()
obj.value = 5
obj.value
except:
raise Runti... | python | def trace_module(no_print=True):
"""Trace my_module_original exceptions."""
with pexdoc.ExDocCxt() as exdoc_obj:
try:
docs.support.my_module.func("John")
obj = docs.support.my_module.MyClass()
obj.value = 5
obj.value
except:
raise Runti... | [
"def",
"trace_module",
"(",
"no_print",
"=",
"True",
")",
":",
"with",
"pexdoc",
".",
"ExDocCxt",
"(",
")",
"as",
"exdoc_obj",
":",
"try",
":",
"docs",
".",
"support",
".",
"my_module",
".",
"func",
"(",
"\"John\"",
")",
"obj",
"=",
"docs",
".",
"sup... | Trace my_module_original exceptions. | [
"Trace",
"my_module_original",
"exceptions",
"."
] | 201ac243e5781347feb75896a4231429fe6da4b1 | https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/docs/support/trace_my_module_2.py#L14-L32 | train | Trace my_module_original exceptions. |
a1ezzz/wasp-general | wasp_general/network/web/request.py | WWebRequest.parse_request_line | def parse_request_line(cls, session, request_line):
""" Parse given request line like 'GET /foo' or 'POST /zzz HTTP/1.0'
:param session: origin session
:param request_line: line to parse
:return: WWebRequest
"""
r = cls.request_line_re.search(request_line)
if r is not None:
method, path, protocol_sent... | python | def parse_request_line(cls, session, request_line):
""" Parse given request line like 'GET /foo' or 'POST /zzz HTTP/1.0'
:param session: origin session
:param request_line: line to parse
:return: WWebRequest
"""
r = cls.request_line_re.search(request_line)
if r is not None:
method, path, protocol_sent... | [
"def",
"parse_request_line",
"(",
"cls",
",",
"session",
",",
"request_line",
")",
":",
"r",
"=",
"cls",
".",
"request_line_re",
".",
"search",
"(",
"request_line",
")",
"if",
"r",
"is",
"not",
"None",
":",
"method",
",",
"path",
",",
"protocol_sentence",
... | Parse given request line like 'GET /foo' or 'POST /zzz HTTP/1.0'
:param session: origin session
:param request_line: line to parse
:return: WWebRequest | [
"Parse",
"given",
"request",
"line",
"like",
"GET",
"/",
"foo",
"or",
"POST",
"/",
"zzz",
"HTTP",
"/",
"1",
".",
"0"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/web/request.py#L130-L141 | train | Parse given request line like GET POST or HTTP 1. 0 |
a1ezzz/wasp-general | wasp_general/network/web/request.py | WWebRequest.parse_headers | def parse_headers(self, http_code):
""" Parse http-code (like 'Header-X: foo\r\nHeader-Y: bar\r\n') and retrieve (save) HTTP-headers
:param http_code: code to parse
:return: None
"""
if self.__ro_flag:
raise RuntimeError('Read-only object changing attempt')
self.__headers = WHTTPHeaders.import_headers(h... | python | def parse_headers(self, http_code):
""" Parse http-code (like 'Header-X: foo\r\nHeader-Y: bar\r\n') and retrieve (save) HTTP-headers
:param http_code: code to parse
:return: None
"""
if self.__ro_flag:
raise RuntimeError('Read-only object changing attempt')
self.__headers = WHTTPHeaders.import_headers(h... | [
"def",
"parse_headers",
"(",
"self",
",",
"http_code",
")",
":",
"if",
"self",
".",
"__ro_flag",
":",
"raise",
"RuntimeError",
"(",
"'Read-only object changing attempt'",
")",
"self",
".",
"__headers",
"=",
"WHTTPHeaders",
".",
"import_headers",
"(",
"http_code",
... | Parse http-code (like 'Header-X: foo\r\nHeader-Y: bar\r\n') and retrieve (save) HTTP-headers
:param http_code: code to parse
:return: None | [
"Parse",
"http",
"-",
"code",
"(",
"like",
"Header",
"-",
"X",
":",
"foo",
"\\",
"r",
"\\",
"nHeader",
"-",
"Y",
":",
"bar",
"\\",
"r",
"\\",
"n",
")",
"and",
"retrieve",
"(",
"save",
")",
"HTTP",
"-",
"headers"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/web/request.py#L144-L152 | train | Parse HTTP - code and retrieve it |
a1ezzz/wasp-general | wasp_general/network/web/request.py | WWebRequest.ro | def ro(self):
""" Create read-only copy
:return: WWebRequest
"""
request = WWebRequest(
self.session(), self.method(), self.path(),
headers=self.headers().ro(), request_data=self.request_data()
)
request.__ro_flag = True
return request | python | def ro(self):
""" Create read-only copy
:return: WWebRequest
"""
request = WWebRequest(
self.session(), self.method(), self.path(),
headers=self.headers().ro(), request_data=self.request_data()
)
request.__ro_flag = True
return request | [
"def",
"ro",
"(",
"self",
")",
":",
"request",
"=",
"WWebRequest",
"(",
"self",
".",
"session",
"(",
")",
",",
"self",
".",
"method",
"(",
")",
",",
"self",
".",
"path",
"(",
")",
",",
"headers",
"=",
"self",
".",
"headers",
"(",
")",
".",
"ro"... | Create read-only copy
:return: WWebRequest | [
"Create",
"read",
"-",
"only",
"copy"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/web/request.py#L154-L164 | train | Create read - only copy of this object |
tBaxter/tango-contact-manager | build/lib/contact_manager/views.py | simple_contact | def simple_contact(request, username=""):
"""
Defines simple contact form that can be used to
contact a site member passed by username in the URL
or to all superusers or to a list defined in settings.DEFAULT_CONTACTS.
"""
site = Site.objects.get_current()
form = ContactForm(request.PO... | python | def simple_contact(request, username=""):
"""
Defines simple contact form that can be used to
contact a site member passed by username in the URL
or to all superusers or to a list defined in settings.DEFAULT_CONTACTS.
"""
site = Site.objects.get_current()
form = ContactForm(request.PO... | [
"def",
"simple_contact",
"(",
"request",
",",
"username",
"=",
"\"\"",
")",
":",
"site",
"=",
"Site",
".",
"objects",
".",
"get_current",
"(",
")",
"form",
"=",
"ContactForm",
"(",
"request",
".",
"POST",
"or",
"None",
")",
"UserModel",
"=",
"get_user_mo... | Defines simple contact form that can be used to
contact a site member passed by username in the URL
or to all superusers or to a list defined in settings.DEFAULT_CONTACTS. | [
"Defines",
"simple",
"contact",
"form",
"that",
"can",
"be",
"used",
"to",
"contact",
"a",
"site",
"member",
"passed",
"by",
"username",
"in",
"the",
"URL",
"or",
"to",
"all",
"superusers",
"or",
"to",
"a",
"list",
"defined",
"in",
"settings",
".",
"DEFA... | 7bd5be326a8db8f438cdefff0fbd14849d0474a5 | https://github.com/tBaxter/tango-contact-manager/blob/7bd5be326a8db8f438cdefff0fbd14849d0474a5/build/lib/contact_manager/views.py#L61-L135 | train | Returns a new contact form that can be used to contact a single site member. |
tBaxter/tango-contact-manager | build/lib/contact_manager/views.py | build_contact | def build_contact(request, slug=""):
"""
Builds appropriate contact form based on options
set in the contact_form controller.
"""
controller = get_object_or_404(ContactFormController, slug=slug)
site = Site.objects.get_current()
UserModel = get_user_model()
user = request.user
... | python | def build_contact(request, slug=""):
"""
Builds appropriate contact form based on options
set in the contact_form controller.
"""
controller = get_object_or_404(ContactFormController, slug=slug)
site = Site.objects.get_current()
UserModel = get_user_model()
user = request.user
... | [
"def",
"build_contact",
"(",
"request",
",",
"slug",
"=",
"\"\"",
")",
":",
"controller",
"=",
"get_object_or_404",
"(",
"ContactFormController",
",",
"slug",
"=",
"slug",
")",
"site",
"=",
"Site",
".",
"objects",
".",
"get_current",
"(",
")",
"UserModel",
... | Builds appropriate contact form based on options
set in the contact_form controller. | [
"Builds",
"appropriate",
"contact",
"form",
"based",
"on",
"options",
"set",
"in",
"the",
"contact_form",
"controller",
"."
] | 7bd5be326a8db8f438cdefff0fbd14849d0474a5 | https://github.com/tBaxter/tango-contact-manager/blob/7bd5be326a8db8f438cdefff0fbd14849d0474a5/build/lib/contact_manager/views.py#L138-L219 | train | Builds appropriate contact form based on options |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.