repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
mdavidsaver/p4p | src/p4p/server/cothread.py | _sync | def _sync(timeout=None):
"""I will wait until all pending handlers cothreads have completed
"""
evt = WeakEvent(auto_reset=False)
# first ensure that any pending callbacks from worker threads have been delivered
# these are calls of _fromMain()
Callback(evt.Signal)
evt.Wait(timeout=timeout)... | python | def _sync(timeout=None):
"""I will wait until all pending handlers cothreads have completed
"""
evt = WeakEvent(auto_reset=False)
# first ensure that any pending callbacks from worker threads have been delivered
# these are calls of _fromMain()
Callback(evt.Signal)
evt.Wait(timeout=timeout)... | [
"def",
"_sync",
"(",
"timeout",
"=",
"None",
")",
":",
"evt",
"=",
"WeakEvent",
"(",
"auto_reset",
"=",
"False",
")",
"# first ensure that any pending callbacks from worker threads have been delivered",
"# these are calls of _fromMain()",
"Callback",
"(",
"evt",
".",
"Sig... | I will wait until all pending handlers cothreads have completed | [
"I",
"will",
"wait",
"until",
"all",
"pending",
"handlers",
"cothreads",
"have",
"completed"
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/server/cothread.py#L33-L60 |
mdavidsaver/p4p | src/p4p/server/cothread.py | SharedPV.close | def close(self, destroy=False, sync=False, timeout=None):
"""Close PV, disconnecting any clients.
:param bool destroy: Indicate "permanent" closure. Current clients will not see subsequent open().
:param bool sync: When block until any pending onLastDisconnect() is delivered (timeout applies).... | python | def close(self, destroy=False, sync=False, timeout=None):
"""Close PV, disconnecting any clients.
:param bool destroy: Indicate "permanent" closure. Current clients will not see subsequent open().
:param bool sync: When block until any pending onLastDisconnect() is delivered (timeout applies).... | [
"def",
"close",
"(",
"self",
",",
"destroy",
"=",
"False",
",",
"sync",
"=",
"False",
",",
"timeout",
"=",
"None",
")",
":",
"_SharedPV",
".",
"close",
"(",
"self",
",",
"destroy",
")",
"if",
"sync",
":",
"# TODO: still not syncing PVA workers...",
"_sync"... | Close PV, disconnecting any clients.
:param bool destroy: Indicate "permanent" closure. Current clients will not see subsequent open().
:param bool sync: When block until any pending onLastDisconnect() is delivered (timeout applies).
:param float timeout: Applies only when sync=True. None for... | [
"Close",
"PV",
"disconnecting",
"any",
"clients",
"."
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/server/cothread.py#L101-L117 |
mdavidsaver/p4p | src/p4p/util.py | WorkQueue.handle | def handle(self):
"""Process queued work until interrupt() is called
"""
while True:
# TODO: Queue.get() (and anything using thread.allocate_lock
# ignores signals :( so timeout periodically to allow delivery
try:
callable = None # ensur... | python | def handle(self):
"""Process queued work until interrupt() is called
"""
while True:
# TODO: Queue.get() (and anything using thread.allocate_lock
# ignores signals :( so timeout periodically to allow delivery
try:
callable = None # ensur... | [
"def",
"handle",
"(",
"self",
")",
":",
"while",
"True",
":",
"# TODO: Queue.get() (and anything using thread.allocate_lock",
"# ignores signals :( so timeout periodically to allow delivery",
"try",
":",
"callable",
"=",
"None",
"# ensure no lingering references to past work w... | Process queued work until interrupt() is called | [
"Process",
"queued",
"work",
"until",
"interrupt",
"()",
"is",
"called"
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/util.py#L42-L60 |
mdavidsaver/p4p | src/p4p/__init__.py | set_debug | def set_debug(lvl):
"""Set PVA global debug print level. This prints directly to stdout,
bypassing eg. sys.stdout.
:param lvl: logging.* level or logLevel*
"""
lvl = _lvlmap.get(lvl, lvl)
assert lvl in _lvls, lvl
_ClientProvider.set_debug(lvl) | python | def set_debug(lvl):
"""Set PVA global debug print level. This prints directly to stdout,
bypassing eg. sys.stdout.
:param lvl: logging.* level or logLevel*
"""
lvl = _lvlmap.get(lvl, lvl)
assert lvl in _lvls, lvl
_ClientProvider.set_debug(lvl) | [
"def",
"set_debug",
"(",
"lvl",
")",
":",
"lvl",
"=",
"_lvlmap",
".",
"get",
"(",
"lvl",
",",
"lvl",
")",
"assert",
"lvl",
"in",
"_lvls",
",",
"lvl",
"_ClientProvider",
".",
"set_debug",
"(",
"lvl",
")"
] | Set PVA global debug print level. This prints directly to stdout,
bypassing eg. sys.stdout.
:param lvl: logging.* level or logLevel* | [
"Set",
"PVA",
"global",
"debug",
"print",
"level",
".",
"This",
"prints",
"directly",
"to",
"stdout",
"bypassing",
"eg",
".",
"sys",
".",
"stdout",
"."
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/__init__.py#L44-L52 |
mdavidsaver/p4p | src/p4p/__init__.py | cleanup | def cleanup():
"""P4P sequenced shutdown. Intended to be atexit. Idenpotent.
"""
_log.debug("P4P atexit begins")
# clean provider registry
from .server import clearProviders, _cleanup_servers
clearProviders()
# close client contexts
from .client.raw import _cleanup_contexts
_clean... | python | def cleanup():
"""P4P sequenced shutdown. Intended to be atexit. Idenpotent.
"""
_log.debug("P4P atexit begins")
# clean provider registry
from .server import clearProviders, _cleanup_servers
clearProviders()
# close client contexts
from .client.raw import _cleanup_contexts
_clean... | [
"def",
"cleanup",
"(",
")",
":",
"_log",
".",
"debug",
"(",
"\"P4P atexit begins\"",
")",
"# clean provider registry",
"from",
".",
"server",
"import",
"clearProviders",
",",
"_cleanup_servers",
"clearProviders",
"(",
")",
"# close client contexts",
"from",
".",
"cl... | P4P sequenced shutdown. Intended to be atexit. Idenpotent. | [
"P4P",
"sequenced",
"shutdown",
".",
"Intended",
"to",
"be",
"atexit",
".",
"Idenpotent",
"."
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/__init__.py#L56-L74 |
mdavidsaver/p4p | src/p4p/server/__init__.py | Server.forever | def forever(klass, *args, **kws):
"""Create a server and block the calling thread until KeyboardInterrupt.
Shorthand for: ::
with Server(*args, **kws):
try;
time.sleep(99999999)
except KeyboardInterrupt:
pass
""... | python | def forever(klass, *args, **kws):
"""Create a server and block the calling thread until KeyboardInterrupt.
Shorthand for: ::
with Server(*args, **kws):
try;
time.sleep(99999999)
except KeyboardInterrupt:
pass
""... | [
"def",
"forever",
"(",
"klass",
",",
"*",
"args",
",",
"*",
"*",
"kws",
")",
":",
"with",
"klass",
"(",
"*",
"args",
",",
"*",
"*",
"kws",
")",
":",
"_log",
".",
"info",
"(",
"\"Running server\"",
")",
"try",
":",
"while",
"True",
":",
"time",
... | Create a server and block the calling thread until KeyboardInterrupt.
Shorthand for: ::
with Server(*args, **kws):
try;
time.sleep(99999999)
except KeyboardInterrupt:
pass | [
"Create",
"a",
"server",
"and",
"block",
"the",
"calling",
"thread",
"until",
"KeyboardInterrupt",
".",
"Shorthand",
"for",
":",
"::"
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/server/__init__.py#L134-L152 |
mdavidsaver/p4p | src/p4p/nt/scalar.py | NTScalar.buildType | def buildType(valtype, extra=[], display=False, control=False, valueAlarm=False):
"""Build a Type
:param str valtype: A type code to be used with the 'value' field. See :ref:`valuecodes`
:param list extra: A list of tuples describing additional non-standard fields
:param bool display: ... | python | def buildType(valtype, extra=[], display=False, control=False, valueAlarm=False):
"""Build a Type
:param str valtype: A type code to be used with the 'value' field. See :ref:`valuecodes`
:param list extra: A list of tuples describing additional non-standard fields
:param bool display: ... | [
"def",
"buildType",
"(",
"valtype",
",",
"extra",
"=",
"[",
"]",
",",
"display",
"=",
"False",
",",
"control",
"=",
"False",
",",
"valueAlarm",
"=",
"False",
")",
":",
"isarray",
"=",
"valtype",
"[",
":",
"1",
"]",
"==",
"'a'",
"F",
"=",
"[",
"("... | Build a Type
:param str valtype: A type code to be used with the 'value' field. See :ref:`valuecodes`
:param list extra: A list of tuples describing additional non-standard fields
:param bool display: Include optional fields for display meta-data
:param bool control: Include optional f... | [
"Build",
"a",
"Type"
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/nt/scalar.py#L159-L178 |
mdavidsaver/p4p | src/p4p/nt/scalar.py | NTScalar.wrap | def wrap(self, value, timestamp=None):
"""Pack python value into Value
Accepts dict to explicitly initialize fields be name.
Any other type is assigned to the 'value' field.
"""
if isinstance(value, Value):
return value
elif isinstance(value, ntwrappercommon)... | python | def wrap(self, value, timestamp=None):
"""Pack python value into Value
Accepts dict to explicitly initialize fields be name.
Any other type is assigned to the 'value' field.
"""
if isinstance(value, Value):
return value
elif isinstance(value, ntwrappercommon)... | [
"def",
"wrap",
"(",
"self",
",",
"value",
",",
"timestamp",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"Value",
")",
":",
"return",
"value",
"elif",
"isinstance",
"(",
"value",
",",
"ntwrappercommon",
")",
":",
"return",
"value",
"."... | Pack python value into Value
Accepts dict to explicitly initialize fields be name.
Any other type is assigned to the 'value' field. | [
"Pack",
"python",
"value",
"into",
"Value"
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/nt/scalar.py#L183-L203 |
mdavidsaver/p4p | src/p4p/nt/scalar.py | NTScalar.unwrap | def unwrap(klass, value):
"""Unpack a Value into an augmented python type (selected from the 'value' field)
"""
assert isinstance(value, Value), value
V = value.value
try:
T = klass.typeMap[type(V)]
except KeyError:
raise ValueError("Can't unwrap v... | python | def unwrap(klass, value):
"""Unpack a Value into an augmented python type (selected from the 'value' field)
"""
assert isinstance(value, Value), value
V = value.value
try:
T = klass.typeMap[type(V)]
except KeyError:
raise ValueError("Can't unwrap v... | [
"def",
"unwrap",
"(",
"klass",
",",
"value",
")",
":",
"assert",
"isinstance",
"(",
"value",
",",
"Value",
")",
",",
"value",
"V",
"=",
"value",
".",
"value",
"try",
":",
"T",
"=",
"klass",
".",
"typeMap",
"[",
"type",
"(",
"V",
")",
"]",
"except... | Unpack a Value into an augmented python type (selected from the 'value' field) | [
"Unpack",
"a",
"Value",
"into",
"an",
"augmented",
"python",
"type",
"(",
"selected",
"from",
"the",
"value",
"field",
")"
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/nt/scalar.py#L214-L226 |
mdavidsaver/p4p | src/p4p/wrapper.py | Value.changed | def changed(self, *fields):
"""Test if one or more fields have changed.
A field is considered to have changed if it has been marked as changed,
or if any of its parent, or child, fields have been marked as changed.
"""
S = super(Value, self).changed
for fld in fields or ... | python | def changed(self, *fields):
"""Test if one or more fields have changed.
A field is considered to have changed if it has been marked as changed,
or if any of its parent, or child, fields have been marked as changed.
"""
S = super(Value, self).changed
for fld in fields or ... | [
"def",
"changed",
"(",
"self",
",",
"*",
"fields",
")",
":",
"S",
"=",
"super",
"(",
"Value",
",",
"self",
")",
".",
"changed",
"for",
"fld",
"in",
"fields",
"or",
"(",
"None",
",",
")",
":",
"# no args tests for any change",
"if",
"S",
"(",
"fld",
... | Test if one or more fields have changed.
A field is considered to have changed if it has been marked as changed,
or if any of its parent, or child, fields have been marked as changed. | [
"Test",
"if",
"one",
"or",
"more",
"fields",
"have",
"changed",
"."
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/wrapper.py#L147-L157 |
mdavidsaver/p4p | src/p4p/wrapper.py | Value.changedSet | def changedSet(self, expand=False, parents=False):
"""
:param bool expand: Whether to expand when entire sub-structures are marked as changed.
If True, then sub-structures are expanded and only leaf fields will be included.
If False, then a direct ... | python | def changedSet(self, expand=False, parents=False):
"""
:param bool expand: Whether to expand when entire sub-structures are marked as changed.
If True, then sub-structures are expanded and only leaf fields will be included.
If False, then a direct ... | [
"def",
"changedSet",
"(",
"self",
",",
"expand",
"=",
"False",
",",
"parents",
"=",
"False",
")",
":",
"return",
"ValueBase",
".",
"changedSet",
"(",
"self",
",",
"expand",
",",
"parents",
")"
] | :param bool expand: Whether to expand when entire sub-structures are marked as changed.
If True, then sub-structures are expanded and only leaf fields will be included.
If False, then a direct translation is made, which may include both leaf and sub-structure fiel... | [
":",
"param",
"bool",
"expand",
":",
"Whether",
"to",
"expand",
"when",
"entire",
"sub",
"-",
"structures",
"are",
"marked",
"as",
"changed",
".",
"If",
"True",
"then",
"sub",
"-",
"structures",
"are",
"expanded",
"and",
"only",
"leaf",
"fields",
"will",
... | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/wrapper.py#L159-L198 |
mdavidsaver/p4p | src/p4p/nt/ndarray.py | NTNDArray.wrap | def wrap(self, value):
"""Wrap numpy.ndarray as Value
"""
attrib = getattr(value, 'attrib', {})
S, NS = divmod(time.time(), 1.0)
value = numpy.asarray(value) # loses any special/augmented attributes
dims = list(value.shape)
dims.reverse() # inner-most sent as lef... | python | def wrap(self, value):
"""Wrap numpy.ndarray as Value
"""
attrib = getattr(value, 'attrib', {})
S, NS = divmod(time.time(), 1.0)
value = numpy.asarray(value) # loses any special/augmented attributes
dims = list(value.shape)
dims.reverse() # inner-most sent as lef... | [
"def",
"wrap",
"(",
"self",
",",
"value",
")",
":",
"attrib",
"=",
"getattr",
"(",
"value",
",",
"'attrib'",
",",
"{",
"}",
")",
"S",
",",
"NS",
"=",
"divmod",
"(",
"time",
".",
"time",
"(",
")",
",",
"1.0",
")",
"value",
"=",
"numpy",
".",
"... | Wrap numpy.ndarray as Value | [
"Wrap",
"numpy",
".",
"ndarray",
"as",
"Value"
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/nt/ndarray.py#L133-L171 |
mdavidsaver/p4p | src/p4p/nt/ndarray.py | NTNDArray.unwrap | def unwrap(klass, value):
"""Unwrap Value as NTNDArray
"""
V = value.value
if V is None:
# Union empty. treat as zero-length char array
V = numpy.zeros((0,), dtype=numpy.uint8)
return V.view(klass.ntndarray)._store(value) | python | def unwrap(klass, value):
"""Unwrap Value as NTNDArray
"""
V = value.value
if V is None:
# Union empty. treat as zero-length char array
V = numpy.zeros((0,), dtype=numpy.uint8)
return V.view(klass.ntndarray)._store(value) | [
"def",
"unwrap",
"(",
"klass",
",",
"value",
")",
":",
"V",
"=",
"value",
".",
"value",
"if",
"V",
"is",
"None",
":",
"# Union empty. treat as zero-length char array",
"V",
"=",
"numpy",
".",
"zeros",
"(",
"(",
"0",
",",
")",
",",
"dtype",
"=",
"numpy... | Unwrap Value as NTNDArray | [
"Unwrap",
"Value",
"as",
"NTNDArray"
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/nt/ndarray.py#L174-L181 |
mdavidsaver/p4p | src/p4p/client/raw.py | unwrapHandler | def unwrapHandler(handler, nt):
"""Wrap get/rpc handler to unwrap Value
"""
def dounwrap(code, msg, val):
_log.debug("Handler (%s, %s, %s) -> %s", code, msg, LazyRepr(val), handler)
try:
if code == 0:
handler(RemoteError(msg))
elif code == 1:
... | python | def unwrapHandler(handler, nt):
"""Wrap get/rpc handler to unwrap Value
"""
def dounwrap(code, msg, val):
_log.debug("Handler (%s, %s, %s) -> %s", code, msg, LazyRepr(val), handler)
try:
if code == 0:
handler(RemoteError(msg))
elif code == 1:
... | [
"def",
"unwrapHandler",
"(",
"handler",
",",
"nt",
")",
":",
"def",
"dounwrap",
"(",
"code",
",",
"msg",
",",
"val",
")",
":",
"_log",
".",
"debug",
"(",
"\"Handler (%s, %s, %s) -> %s\"",
",",
"code",
",",
"msg",
",",
"LazyRepr",
"(",
"val",
")",
",",
... | Wrap get/rpc handler to unwrap Value | [
"Wrap",
"get",
"/",
"rpc",
"handler",
"to",
"unwrap",
"Value"
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/client/raw.py#L61-L77 |
mdavidsaver/p4p | src/p4p/client/raw.py | defaultBuilder | def defaultBuilder(value, nt):
"""Reasonably sensible default handling of put builder
"""
if callable(value):
def logbuilder(V):
try:
value(V)
except:
_log.exception("Error in Builder")
raise # will be logged again
retu... | python | def defaultBuilder(value, nt):
"""Reasonably sensible default handling of put builder
"""
if callable(value):
def logbuilder(V):
try:
value(V)
except:
_log.exception("Error in Builder")
raise # will be logged again
retu... | [
"def",
"defaultBuilder",
"(",
"value",
",",
"nt",
")",
":",
"if",
"callable",
"(",
"value",
")",
":",
"def",
"logbuilder",
"(",
"V",
")",
":",
"try",
":",
"value",
"(",
"V",
")",
"except",
":",
"_log",
".",
"exception",
"(",
"\"Error in Builder\"",
"... | Reasonably sensible default handling of put builder | [
"Reasonably",
"sensible",
"default",
"handling",
"of",
"put",
"builder"
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/client/raw.py#L97-L121 |
mdavidsaver/p4p | src/p4p/client/raw.py | Context.disconnect | def disconnect(self, name=None):
"""Clear internal Channel cache, allowing currently unused channels to be implictly closed.
:param str name: None, to clear the entire cache, or a name string to clear only a certain entry.
"""
if name is None:
self._channels = {}
els... | python | def disconnect(self, name=None):
"""Clear internal Channel cache, allowing currently unused channels to be implictly closed.
:param str name: None, to clear the entire cache, or a name string to clear only a certain entry.
"""
if name is None:
self._channels = {}
els... | [
"def",
"disconnect",
"(",
"self",
",",
"name",
"=",
"None",
")",
":",
"if",
"name",
"is",
"None",
":",
"self",
".",
"_channels",
"=",
"{",
"}",
"else",
":",
"self",
".",
"_channels",
".",
"pop",
"(",
"name",
")",
"if",
"self",
".",
"_ctxt",
"is",... | Clear internal Channel cache, allowing currently unused channels to be implictly closed.
:param str name: None, to clear the entire cache, or a name string to clear only a certain entry. | [
"Clear",
"internal",
"Channel",
"cache",
"allowing",
"currently",
"unused",
"channels",
"to",
"be",
"implictly",
"closed",
"."
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/client/raw.py#L225-L235 |
mdavidsaver/p4p | src/p4p/client/raw.py | Context._request | def _request(self, process=None, wait=None):
"""helper for building pvRequests
:param str process: Control remote processing. May be 'true', 'false', 'passive', or None.
:param bool wait: Wait for all server processing to complete.
"""
opts = []
if process is not None:
... | python | def _request(self, process=None, wait=None):
"""helper for building pvRequests
:param str process: Control remote processing. May be 'true', 'false', 'passive', or None.
:param bool wait: Wait for all server processing to complete.
"""
opts = []
if process is not None:
... | [
"def",
"_request",
"(",
"self",
",",
"process",
"=",
"None",
",",
"wait",
"=",
"None",
")",
":",
"opts",
"=",
"[",
"]",
"if",
"process",
"is",
"not",
"None",
":",
"opts",
".",
"append",
"(",
"'process=%s'",
"%",
"process",
")",
"if",
"wait",
"is",
... | helper for building pvRequests
:param str process: Control remote processing. May be 'true', 'false', 'passive', or None.
:param bool wait: Wait for all server processing to complete. | [
"helper",
"for",
"building",
"pvRequests"
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/client/raw.py#L237-L251 |
mdavidsaver/p4p | src/p4p/client/raw.py | Context.get | def get(self, name, handler, request=None):
"""Begin Fetch of current value of a PV
:param name: A single name string or list of name strings
:param request: A :py:class:`p4p.Value` or string to qualify this request, or None to use a default.
:param callable handler: Completion notifica... | python | def get(self, name, handler, request=None):
"""Begin Fetch of current value of a PV
:param name: A single name string or list of name strings
:param request: A :py:class:`p4p.Value` or string to qualify this request, or None to use a default.
:param callable handler: Completion notifica... | [
"def",
"get",
"(",
"self",
",",
"name",
",",
"handler",
",",
"request",
"=",
"None",
")",
":",
"chan",
"=",
"self",
".",
"_channel",
"(",
"name",
")",
"return",
"_p4p",
".",
"ClientOperation",
"(",
"chan",
",",
"handler",
"=",
"unwrapHandler",
"(",
"... | Begin Fetch of current value of a PV
:param name: A single name string or list of name strings
:param request: A :py:class:`p4p.Value` or string to qualify this request, or None to use a default.
:param callable handler: Completion notification. Called with a Value, RemoteError, or Cancelled
... | [
"Begin",
"Fetch",
"of",
"current",
"value",
"of",
"a",
"PV"
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/client/raw.py#L253-L264 |
mdavidsaver/p4p | src/p4p/client/raw.py | Context.put | def put(self, name, handler, builder=None, request=None, get=True):
"""Write a new value to a PV.
:param name: A single name string or list of name strings
:param callable handler: Completion notification. Called with None (success), RemoteError, or Cancelled
:param callable builder: C... | python | def put(self, name, handler, builder=None, request=None, get=True):
"""Write a new value to a PV.
:param name: A single name string or list of name strings
:param callable handler: Completion notification. Called with None (success), RemoteError, or Cancelled
:param callable builder: C... | [
"def",
"put",
"(",
"self",
",",
"name",
",",
"handler",
",",
"builder",
"=",
"None",
",",
"request",
"=",
"None",
",",
"get",
"=",
"True",
")",
":",
"chan",
"=",
"self",
".",
"_channel",
"(",
"name",
")",
"return",
"_p4p",
".",
"ClientOperation",
"... | Write a new value to a PV.
:param name: A single name string or list of name strings
:param callable handler: Completion notification. Called with None (success), RemoteError, or Cancelled
:param callable builder: Called when the PV Put type is known. A builder is responsible
... | [
"Write",
"a",
"new",
"value",
"to",
"a",
"PV",
"."
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/client/raw.py#L266-L282 |
mdavidsaver/p4p | src/p4p/client/raw.py | Context.rpc | def rpc(self, name, handler, value, request=None):
"""Perform RPC operation on PV
:param name: A single name string or list of name strings
:param callable handler: Completion notification. Called with a Value, RemoteError, or Cancelled
:param request: A :py:class:`p4p.Value` or string... | python | def rpc(self, name, handler, value, request=None):
"""Perform RPC operation on PV
:param name: A single name string or list of name strings
:param callable handler: Completion notification. Called with a Value, RemoteError, or Cancelled
:param request: A :py:class:`p4p.Value` or string... | [
"def",
"rpc",
"(",
"self",
",",
"name",
",",
"handler",
",",
"value",
",",
"request",
"=",
"None",
")",
":",
"chan",
"=",
"self",
".",
"_channel",
"(",
"name",
")",
"if",
"value",
"is",
"None",
":",
"value",
"=",
"Value",
"(",
"Type",
"(",
"[",
... | Perform RPC operation on PV
:param name: A single name string or list of name strings
:param callable handler: Completion notification. Called with a Value, RemoteError, or Cancelled
:param request: A :py:class:`p4p.Value` or string to qualify this request, or None to use a default.
:... | [
"Perform",
"RPC",
"operation",
"on",
"PV"
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/client/raw.py#L284-L297 |
mdavidsaver/p4p | src/p4p/client/raw.py | Context.monitor | def monitor(self, name, handler, request=None, **kws):
"""Begin subscription to named PV
:param str name: PV name string
:param callable handler: Completion notification. Called with None (FIFO not empty), RemoteError, Cancelled, or Disconnected
:param request: A :py:class:`p4p.Value` ... | python | def monitor(self, name, handler, request=None, **kws):
"""Begin subscription to named PV
:param str name: PV name string
:param callable handler: Completion notification. Called with None (FIFO not empty), RemoteError, Cancelled, or Disconnected
:param request: A :py:class:`p4p.Value` ... | [
"def",
"monitor",
"(",
"self",
",",
"name",
",",
"handler",
",",
"request",
"=",
"None",
",",
"*",
"*",
"kws",
")",
":",
"chan",
"=",
"self",
".",
"_channel",
"(",
"name",
")",
"return",
"Subscription",
"(",
"context",
"=",
"self",
",",
"nt",
"=",
... | Begin subscription to named PV
:param str name: PV name string
:param callable handler: Completion notification. Called with None (FIFO not empty), RemoteError, Cancelled, or Disconnected
:param request: A :py:class:`p4p.Value` or string to qualify this request, or None to use a default.
... | [
"Begin",
"subscription",
"to",
"named",
"PV"
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/client/raw.py#L299-L313 |
mdavidsaver/p4p | src/p4p/server/asyncio.py | SharedPV.close | def close(self, destroy=False, sync=False):
"""Close PV, disconnecting any clients.
:param bool destroy: Indicate "permanent" closure. Current clients will not see subsequent open().
:param bool sync: When block until any pending onLastDisconnect() is delivered (timeout applies).
:para... | python | def close(self, destroy=False, sync=False):
"""Close PV, disconnecting any clients.
:param bool destroy: Indicate "permanent" closure. Current clients will not see subsequent open().
:param bool sync: When block until any pending onLastDisconnect() is delivered (timeout applies).
:para... | [
"def",
"close",
"(",
"self",
",",
"destroy",
"=",
"False",
",",
"sync",
"=",
"False",
")",
":",
"_SharedPV",
".",
"close",
"(",
"self",
",",
"destroy",
")",
"if",
"sync",
":",
"return",
"self",
".",
"_wait_closed",
"(",
")"
] | Close PV, disconnecting any clients.
:param bool destroy: Indicate "permanent" closure. Current clients will not see subsequent open().
:param bool sync: When block until any pending onLastDisconnect() is delivered (timeout applies).
:param float timeout: Applies only when sync=True. None for... | [
"Close",
"PV",
"disconnecting",
"any",
"clients",
"."
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/server/asyncio.py#L109-L123 |
mdavidsaver/p4p | src/p4p/client/asyncio.py | timesout | def timesout(deftimeout=5.0):
"""Decorate a coroutine to implement an overall timeout.
The decorated coroutine will have an additional keyword
argument 'timeout=' which gives a timeout in seconds,
or None to disable timeout.
:param float deftimeout: The default timeout= for the decorated coroutine... | python | def timesout(deftimeout=5.0):
"""Decorate a coroutine to implement an overall timeout.
The decorated coroutine will have an additional keyword
argument 'timeout=' which gives a timeout in seconds,
or None to disable timeout.
:param float deftimeout: The default timeout= for the decorated coroutine... | [
"def",
"timesout",
"(",
"deftimeout",
"=",
"5.0",
")",
":",
"def",
"decorate",
"(",
"fn",
")",
":",
"assert",
"asyncio",
".",
"iscoroutinefunction",
"(",
"fn",
")",
",",
"\"Place @timesout before @coroutine\"",
"@",
"wraps",
"(",
"fn",
")",
"@",
"asyncio",
... | Decorate a coroutine to implement an overall timeout.
The decorated coroutine will have an additional keyword
argument 'timeout=' which gives a timeout in seconds,
or None to disable timeout.
:param float deftimeout: The default timeout= for the decorated coroutine.
It is suggested perform one ov... | [
"Decorate",
"a",
"coroutine",
"to",
"implement",
"an",
"overall",
"timeout",
"."
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/client/asyncio.py#L27-L65 |
mdavidsaver/p4p | src/p4p/client/asyncio.py | Context.get | def get(self, name, request=None):
"""Fetch current value of some number of PVs.
:param name: A single name string or list of name strings
:param request: A :py:class:`p4p.Value` or string to qualify this request, or None to use a default.
:returns: A p4p.Value, or list of same. Subje... | python | def get(self, name, request=None):
"""Fetch current value of some number of PVs.
:param name: A single name string or list of name strings
:param request: A :py:class:`p4p.Value` or string to qualify this request, or None to use a default.
:returns: A p4p.Value, or list of same. Subje... | [
"def",
"get",
"(",
"self",
",",
"name",
",",
"request",
"=",
"None",
")",
":",
"singlepv",
"=",
"isinstance",
"(",
"name",
",",
"(",
"bytes",
",",
"str",
")",
")",
"if",
"singlepv",
":",
"return",
"(",
"yield",
"from",
"self",
".",
"_get_one",
"(",... | Fetch current value of some number of PVs.
:param name: A single name string or list of name strings
:param request: A :py:class:`p4p.Value` or string to qualify this request, or None to use a default.
:returns: A p4p.Value, or list of same. Subject to :py:ref:`unwrap`.
When invoked ... | [
"Fetch",
"current",
"value",
"of",
"some",
"number",
"of",
"PVs",
"."
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/client/asyncio.py#L117-L145 |
mdavidsaver/p4p | src/p4p/client/asyncio.py | Context.put | def put(self, name, values, request=None, process=None, wait=None, get=True):
"""Write a new value of some number of PVs.
:param name: A single name string or list of name strings
:param values: A single value, a list of values, a dict, a `Value`. May be modified by the constructor nt= argumen... | python | def put(self, name, values, request=None, process=None, wait=None, get=True):
"""Write a new value of some number of PVs.
:param name: A single name string or list of name strings
:param values: A single value, a list of values, a dict, a `Value`. May be modified by the constructor nt= argumen... | [
"def",
"put",
"(",
"self",
",",
"name",
",",
"values",
",",
"request",
"=",
"None",
",",
"process",
"=",
"None",
",",
"wait",
"=",
"None",
",",
"get",
"=",
"True",
")",
":",
"if",
"request",
"and",
"(",
"process",
"or",
"wait",
"is",
"not",
"None... | Write a new value of some number of PVs.
:param name: A single name string or list of name strings
:param values: A single value, a list of values, a dict, a `Value`. May be modified by the constructor nt= argument.
:param request: A :py:class:`p4p.Value` or string to qualify this request, or ... | [
"Write",
"a",
"new",
"value",
"of",
"some",
"number",
"of",
"PVs",
"."
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/client/asyncio.py#L169-L213 |
mdavidsaver/p4p | src/p4p/client/asyncio.py | Context.monitor | def monitor(self, name, cb, request=None, notify_disconnect=False):
"""Create a subscription.
:param str name: PV name string
:param callable cb: Processing callback
:param request: A :py:class:`p4p.Value` or string to qualify this request, or None to use a default.
:param bool ... | python | def monitor(self, name, cb, request=None, notify_disconnect=False):
"""Create a subscription.
:param str name: PV name string
:param callable cb: Processing callback
:param request: A :py:class:`p4p.Value` or string to qualify this request, or None to use a default.
:param bool ... | [
"def",
"monitor",
"(",
"self",
",",
"name",
",",
"cb",
",",
"request",
"=",
"None",
",",
"notify_disconnect",
"=",
"False",
")",
":",
"assert",
"asyncio",
".",
"iscoroutinefunction",
"(",
"cb",
")",
",",
"\"monitor callback must be coroutine\"",
"R",
"=",
"S... | Create a subscription.
:param str name: PV name string
:param callable cb: Processing callback
:param request: A :py:class:`p4p.Value` or string to qualify this request, or None to use a default.
:param bool notify_disconnect: In additional to Values, the callback may also be call with ... | [
"Create",
"a",
"subscription",
"."
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/client/asyncio.py#L277-L297 |
mdavidsaver/p4p | src/p4p/client/asyncio.py | Subscription.close | def close(self):
"""Begin closing subscription.
"""
if self._S is not None:
# after .close() self._event should never be called
self._S.close()
self._S = None
self._Q.put_nowait(None) | python | def close(self):
"""Begin closing subscription.
"""
if self._S is not None:
# after .close() self._event should never be called
self._S.close()
self._S = None
self._Q.put_nowait(None) | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"_S",
"is",
"not",
"None",
":",
"# after .close() self._event should never be called",
"self",
".",
"_S",
".",
"close",
"(",
")",
"self",
".",
"_S",
"=",
"None",
"self",
".",
"_Q",
".",
"put_nowai... | Begin closing subscription. | [
"Begin",
"closing",
"subscription",
"."
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/client/asyncio.py#L322-L329 |
mdavidsaver/p4p | src/p4p/client/thread.py | Subscription.close | def close(self):
"""Close subscription.
"""
if self._S is not None:
# after .close() self._event should never be called
self._S.close()
# wait for Cancelled to be delivered
self._evt.wait()
self._S = None | python | def close(self):
"""Close subscription.
"""
if self._S is not None:
# after .close() self._event should never be called
self._S.close()
# wait for Cancelled to be delivered
self._evt.wait()
self._S = None | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"_S",
"is",
"not",
"None",
":",
"# after .close() self._event should never be called",
"self",
".",
"_S",
".",
"close",
"(",
")",
"# wait for Cancelled to be delivered",
"self",
".",
"_evt",
".",
"wait",
... | Close subscription. | [
"Close",
"subscription",
"."
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/client/thread.py#L65-L73 |
mdavidsaver/p4p | src/p4p/client/thread.py | Context.close | def close(self):
"""Force close all Channels and cancel all Operations
"""
if self._Q is not None:
for T in self._T:
self._Q.interrupt()
for n, T in enumerate(self._T):
_log.debug('Join Context worker %d', n)
T.join()
... | python | def close(self):
"""Force close all Channels and cancel all Operations
"""
if self._Q is not None:
for T in self._T:
self._Q.interrupt()
for n, T in enumerate(self._T):
_log.debug('Join Context worker %d', n)
T.join()
... | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"_Q",
"is",
"not",
"None",
":",
"for",
"T",
"in",
"self",
".",
"_T",
":",
"self",
".",
"_Q",
".",
"interrupt",
"(",
")",
"for",
"n",
",",
"T",
"in",
"enumerate",
"(",
"self",
".",
"_T"... | Force close all Channels and cancel all Operations | [
"Force",
"close",
"all",
"Channels",
"and",
"cancel",
"all",
"Operations"
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/client/thread.py#L207-L218 |
mdavidsaver/p4p | src/p4p/client/thread.py | Context.get | def get(self, name, request=None, timeout=5.0, throw=True):
"""Fetch current value of some number of PVs.
:param name: A single name string or list of name strings
:param request: A :py:class:`p4p.Value` or string to qualify this request, or None to use a default.
:param float timeout: ... | python | def get(self, name, request=None, timeout=5.0, throw=True):
"""Fetch current value of some number of PVs.
:param name: A single name string or list of name strings
:param request: A :py:class:`p4p.Value` or string to qualify this request, or None to use a default.
:param float timeout: ... | [
"def",
"get",
"(",
"self",
",",
"name",
",",
"request",
"=",
"None",
",",
"timeout",
"=",
"5.0",
",",
"throw",
"=",
"True",
")",
":",
"singlepv",
"=",
"isinstance",
"(",
"name",
",",
"(",
"bytes",
",",
"unicode",
")",
")",
"if",
"singlepv",
":",
... | Fetch current value of some number of PVs.
:param name: A single name string or list of name strings
:param request: A :py:class:`p4p.Value` or string to qualify this request, or None to use a default.
:param float timeout: Operation timeout in seconds
:param bool throw: When true, oper... | [
"Fetch",
"current",
"value",
"of",
"some",
"number",
"of",
"PVs",
"."
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/client/thread.py#L220-L287 |
mdavidsaver/p4p | src/p4p/client/thread.py | Context.put | def put(self, name, values, request=None, timeout=5.0, throw=True,
process=None, wait=None, get=True):
"""Write a new value of some number of PVs.
:param name: A single name string or list of name strings
:param values: A single value, a list of values, a dict, a `Value`. May be mo... | python | def put(self, name, values, request=None, timeout=5.0, throw=True,
process=None, wait=None, get=True):
"""Write a new value of some number of PVs.
:param name: A single name string or list of name strings
:param values: A single value, a list of values, a dict, a `Value`. May be mo... | [
"def",
"put",
"(",
"self",
",",
"name",
",",
"values",
",",
"request",
"=",
"None",
",",
"timeout",
"=",
"5.0",
",",
"throw",
"=",
"True",
",",
"process",
"=",
"None",
",",
"wait",
"=",
"None",
",",
"get",
"=",
"True",
")",
":",
"if",
"request",
... | Write a new value of some number of PVs.
:param name: A single name string or list of name strings
:param values: A single value, a list of values, a dict, a `Value`. May be modified by the constructor nt= argument.
:param request: A :py:class:`p4p.Value` or string to qualify this request, or ... | [
"Write",
"a",
"new",
"value",
"of",
"some",
"number",
"of",
"PVs",
"."
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/client/thread.py#L289-L380 |
mdavidsaver/p4p | src/p4p/client/thread.py | Context.rpc | def rpc(self, name, value, request=None, timeout=5.0, throw=True):
"""Perform a Remote Procedure Call (RPC) operation
:param str name: PV name string
:param Value value: Arguments. Must be Value instance
:param request: A :py:class:`p4p.Value` or string to qualify this request, or None... | python | def rpc(self, name, value, request=None, timeout=5.0, throw=True):
"""Perform a Remote Procedure Call (RPC) operation
:param str name: PV name string
:param Value value: Arguments. Must be Value instance
:param request: A :py:class:`p4p.Value` or string to qualify this request, or None... | [
"def",
"rpc",
"(",
"self",
",",
"name",
",",
"value",
",",
"request",
"=",
"None",
",",
"timeout",
"=",
"5.0",
",",
"throw",
"=",
"True",
")",
":",
"done",
"=",
"Queue",
"(",
")",
"op",
"=",
"super",
"(",
"Context",
",",
"self",
")",
".",
"rpc"... | Perform a Remote Procedure Call (RPC) operation
:param str name: PV name string
:param Value value: Arguments. Must be Value instance
:param request: A :py:class:`p4p.Value` or string to qualify this request, or None to use a default.
:param float timeout: Operation timeout in seconds
... | [
"Perform",
"a",
"Remote",
"Procedure",
"Call",
"(",
"RPC",
")",
"operation"
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/client/thread.py#L382-L419 |
mdavidsaver/p4p | src/p4p/client/thread.py | Context.monitor | def monitor(self, name, cb, request=None, notify_disconnect=False, queue=None):
"""Create a subscription.
:param str name: PV name string
:param callable cb: Processing callback
:param request: A :py:class:`p4p.Value` or string to qualify this request, or None to use a default.
... | python | def monitor(self, name, cb, request=None, notify_disconnect=False, queue=None):
"""Create a subscription.
:param str name: PV name string
:param callable cb: Processing callback
:param request: A :py:class:`p4p.Value` or string to qualify this request, or None to use a default.
... | [
"def",
"monitor",
"(",
"self",
",",
"name",
",",
"cb",
",",
"request",
"=",
"None",
",",
"notify_disconnect",
"=",
"False",
",",
"queue",
"=",
"None",
")",
":",
"R",
"=",
"Subscription",
"(",
"self",
",",
"name",
",",
"cb",
",",
"notify_disconnect",
... | Create a subscription.
:param str name: PV name string
:param callable cb: Processing callback
:param request: A :py:class:`p4p.Value` or string to qualify this request, or None to use a default.
:param bool notify_disconnect: In additional to Values, the callback may also be call with ... | [
"Create",
"a",
"subscription",
"."
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/client/thread.py#L421-L440 |
mdavidsaver/p4p | src/p4p/server/raw.py | SharedPV.open | def open(self, value, nt=None, wrap=None, unwrap=None):
"""Mark the PV as opened an provide its initial value.
This initial value is later updated with post().
:param value: A Value, or appropriate object (see nt= and wrap= of the constructor).
Any clients which have begun connecting ... | python | def open(self, value, nt=None, wrap=None, unwrap=None):
"""Mark the PV as opened an provide its initial value.
This initial value is later updated with post().
:param value: A Value, or appropriate object (see nt= and wrap= of the constructor).
Any clients which have begun connecting ... | [
"def",
"open",
"(",
"self",
",",
"value",
",",
"nt",
"=",
"None",
",",
"wrap",
"=",
"None",
",",
"unwrap",
"=",
"None",
")",
":",
"self",
".",
"_wrap",
"=",
"wrap",
"or",
"(",
"nt",
"and",
"nt",
".",
"wrap",
")",
"or",
"self",
".",
"_wrap",
"... | Mark the PV as opened an provide its initial value.
This initial value is later updated with post().
:param value: A Value, or appropriate object (see nt= and wrap= of the constructor).
Any clients which have begun connecting which began connecting while
this PV was in the close'd sta... | [
"Mark",
"the",
"PV",
"as",
"opened",
"an",
"provide",
"its",
"initial",
"value",
".",
"This",
"initial",
"value",
"is",
"later",
"updated",
"with",
"post",
"()",
"."
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/server/raw.py#L136-L151 |
mdavidsaver/p4p | src/p4p/rpc.py | rpc | def rpc(rtype=None):
"""Decorator marks a method for export.
:param type: Specifies which :py:class:`Type` this method will return.
The return type (rtype) must be one of:
- An instance of :py:class:`p4p.Type`
- None, in which case the method must return a :py:class:`p4p.Value`
- One of the N... | python | def rpc(rtype=None):
"""Decorator marks a method for export.
:param type: Specifies which :py:class:`Type` this method will return.
The return type (rtype) must be one of:
- An instance of :py:class:`p4p.Type`
- None, in which case the method must return a :py:class:`p4p.Value`
- One of the N... | [
"def",
"rpc",
"(",
"rtype",
"=",
"None",
")",
":",
"wrap",
"=",
"None",
"if",
"rtype",
"is",
"None",
"or",
"isinstance",
"(",
"rtype",
",",
"Type",
")",
":",
"pass",
"elif",
"isinstance",
"(",
"type",
",",
"(",
"list",
",",
"tuple",
")",
")",
":"... | Decorator marks a method for export.
:param type: Specifies which :py:class:`Type` this method will return.
The return type (rtype) must be one of:
- An instance of :py:class:`p4p.Type`
- None, in which case the method must return a :py:class:`p4p.Value`
- One of the NT helper classes (eg :py:cla... | [
"Decorator",
"marks",
"a",
"method",
"for",
"export",
"."
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/rpc.py#L26-L68 |
mdavidsaver/p4p | src/p4p/rpc.py | rpccall | def rpccall(pvname, request=None, rtype=None):
"""Decorator marks a client proxy method.
:param str pvname: The PV name, which will be formated using the 'format' argument of the proxy class constructor.
:param request: A pvRequest string or :py:class:`p4p.Value` passed to eg. :py:meth:`p4p.client.thread.C... | python | def rpccall(pvname, request=None, rtype=None):
"""Decorator marks a client proxy method.
:param str pvname: The PV name, which will be formated using the 'format' argument of the proxy class constructor.
:param request: A pvRequest string or :py:class:`p4p.Value` passed to eg. :py:meth:`p4p.client.thread.C... | [
"def",
"rpccall",
"(",
"pvname",
",",
"request",
"=",
"None",
",",
"rtype",
"=",
"None",
")",
":",
"def",
"wrapper",
"(",
"fn",
")",
":",
"fn",
".",
"_call_PV",
"=",
"pvname",
"fn",
".",
"_call_Request",
"=",
"request",
"fn",
".",
"_reply_Type",
"=",... | Decorator marks a client proxy method.
:param str pvname: The PV name, which will be formated using the 'format' argument of the proxy class constructor.
:param request: A pvRequest string or :py:class:`p4p.Value` passed to eg. :py:meth:`p4p.client.thread.Context.rpc`.
The method to be decorated must have... | [
"Decorator",
"marks",
"a",
"client",
"proxy",
"method",
"."
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/rpc.py#L71-L86 |
mdavidsaver/p4p | src/p4p/rpc.py | quickRPCServer | def quickRPCServer(provider, prefix, target,
maxsize=20,
workers=1,
useenv=True, conf=None, isolate=False):
"""Run an RPC server in the current thread
Calls are handled sequentially, and always in the current thread, if workers=1 (the default).
If wo... | python | def quickRPCServer(provider, prefix, target,
maxsize=20,
workers=1,
useenv=True, conf=None, isolate=False):
"""Run an RPC server in the current thread
Calls are handled sequentially, and always in the current thread, if workers=1 (the default).
If wo... | [
"def",
"quickRPCServer",
"(",
"provider",
",",
"prefix",
",",
"target",
",",
"maxsize",
"=",
"20",
",",
"workers",
"=",
"1",
",",
"useenv",
"=",
"True",
",",
"conf",
"=",
"None",
",",
"isolate",
"=",
"False",
")",
":",
"from",
"p4p",
".",
"server",
... | Run an RPC server in the current thread
Calls are handled sequentially, and always in the current thread, if workers=1 (the default).
If workers>1 then calls are handled concurrently by a pool of worker threads.
Requires NTURI style argument encoding.
:param str provider: A provider name. Must be uni... | [
"Run",
"an",
"RPC",
"server",
"in",
"the",
"current",
"thread"
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/rpc.py#L209-L236 |
mdavidsaver/p4p | src/p4p/rpc.py | rpcproxy | def rpcproxy(spec):
"""Decorator to enable this class to proxy RPC client calls
The decorated class constructor takes two additional arguments,
`context=` is required to be a :class:`~p4p.client.thread.Context`.
`format`= can be a string, tuple, or dictionary and is applied
to PV name strings given... | python | def rpcproxy(spec):
"""Decorator to enable this class to proxy RPC client calls
The decorated class constructor takes two additional arguments,
`context=` is required to be a :class:`~p4p.client.thread.Context`.
`format`= can be a string, tuple, or dictionary and is applied
to PV name strings given... | [
"def",
"rpcproxy",
"(",
"spec",
")",
":",
"# inject our ctor first so we don't have to worry about super() non-sense.",
"def",
"_proxyinit",
"(",
"self",
",",
"context",
"=",
"None",
",",
"format",
"=",
"{",
"}",
",",
"*",
"*",
"kws",
")",
":",
"assert",
"contex... | Decorator to enable this class to proxy RPC client calls
The decorated class constructor takes two additional arguments,
`context=` is required to be a :class:`~p4p.client.thread.Context`.
`format`= can be a string, tuple, or dictionary and is applied
to PV name strings given to :py:func:`rpcall`.
... | [
"Decorator",
"to",
"enable",
"this",
"class",
"to",
"proxy",
"RPC",
"client",
"calls"
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/rpc.py#L283-L315 |
mdavidsaver/p4p | src/p4p/nt/__init__.py | ClientUnwrapper.unwrap | def unwrap(self, val):
"""Unpack a Value as some other python type
"""
if val.getID()!=self.id:
self._update(val)
return self._unwrap(val) | python | def unwrap(self, val):
"""Unpack a Value as some other python type
"""
if val.getID()!=self.id:
self._update(val)
return self._unwrap(val) | [
"def",
"unwrap",
"(",
"self",
",",
"val",
")",
":",
"if",
"val",
".",
"getID",
"(",
")",
"!=",
"self",
".",
"id",
":",
"self",
".",
"_update",
"(",
"val",
")",
"return",
"self",
".",
"_unwrap",
"(",
"val",
")"
] | Unpack a Value as some other python type | [
"Unpack",
"a",
"Value",
"as",
"some",
"other",
"python",
"type"
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/nt/__init__.py#L79-L84 |
mdavidsaver/p4p | src/p4p/nt/__init__.py | NTMultiChannel.buildType | def buildType(valtype, extra=[]):
"""Build a Type
:param str valtype: A type code to be used with the 'value' field. Must be an array
:param list extra: A list of tuples describing additional non-standard fields
:returns: A :py:class:`Type`
"""
assert valtype[:1] == 'a'... | python | def buildType(valtype, extra=[]):
"""Build a Type
:param str valtype: A type code to be used with the 'value' field. Must be an array
:param list extra: A list of tuples describing additional non-standard fields
:returns: A :py:class:`Type`
"""
assert valtype[:1] == 'a'... | [
"def",
"buildType",
"(",
"valtype",
",",
"extra",
"=",
"[",
"]",
")",
":",
"assert",
"valtype",
"[",
":",
"1",
"]",
"==",
"'a'",
",",
"'valtype must be an array'",
"return",
"Type",
"(",
"id",
"=",
"\"epics:nt/NTMultiChannel:1.0\"",
",",
"spec",
"=",
"[",
... | Build a Type
:param str valtype: A type code to be used with the 'value' field. Must be an array
:param list extra: A list of tuples describing additional non-standard fields
:returns: A :py:class:`Type` | [
"Build",
"a",
"Type"
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/nt/__init__.py#L118-L140 |
mdavidsaver/p4p | src/p4p/nt/__init__.py | NTTable.buildType | def buildType(columns=[], extra=[]):
"""Build a table
:param list columns: List of column names and types. eg [('colA', 'd')]
:param list extra: A list of tuples describing additional non-standard fields
:returns: A :py:class:`Type`
"""
return Type(id="epics:nt/NTTable:1... | python | def buildType(columns=[], extra=[]):
"""Build a table
:param list columns: List of column names and types. eg [('colA', 'd')]
:param list extra: A list of tuples describing additional non-standard fields
:returns: A :py:class:`Type`
"""
return Type(id="epics:nt/NTTable:1... | [
"def",
"buildType",
"(",
"columns",
"=",
"[",
"]",
",",
"extra",
"=",
"[",
"]",
")",
":",
"return",
"Type",
"(",
"id",
"=",
"\"epics:nt/NTTable:1.0\"",
",",
"spec",
"=",
"[",
"(",
"'labels'",
",",
"'as'",
")",
",",
"(",
"'value'",
",",
"(",
"'S'",
... | Build a table
:param list columns: List of column names and types. eg [('colA', 'd')]
:param list extra: A list of tuples describing additional non-standard fields
:returns: A :py:class:`Type` | [
"Build",
"a",
"table"
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/nt/__init__.py#L155-L169 |
mdavidsaver/p4p | src/p4p/nt/__init__.py | NTTable.wrap | def wrap(self, values):
"""Pack an iterable of dict into a Value
>>> T=NTTable([('A', 'ai'), ('B', 'as')])
>>> V = T.wrap([
{'A':42, 'B':'one'},
{'A':43, 'B':'two'},
])
"""
if isinstance(values, Value):
return values
cols = dic... | python | def wrap(self, values):
"""Pack an iterable of dict into a Value
>>> T=NTTable([('A', 'ai'), ('B', 'as')])
>>> V = T.wrap([
{'A':42, 'B':'one'},
{'A':43, 'B':'two'},
])
"""
if isinstance(values, Value):
return values
cols = dic... | [
"def",
"wrap",
"(",
"self",
",",
"values",
")",
":",
"if",
"isinstance",
"(",
"values",
",",
"Value",
")",
":",
"return",
"values",
"cols",
"=",
"dict",
"(",
"[",
"(",
"L",
",",
"[",
"]",
")",
"for",
"L",
"in",
"self",
".",
"labels",
"]",
")",
... | Pack an iterable of dict into a Value
>>> T=NTTable([('A', 'ai'), ('B', 'as')])
>>> V = T.wrap([
{'A':42, 'B':'one'},
{'A':43, 'B':'two'},
]) | [
"Pack",
"an",
"iterable",
"of",
"dict",
"into",
"a",
"Value"
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/nt/__init__.py#L181-L217 |
mdavidsaver/p4p | src/p4p/nt/__init__.py | NTTable.unwrap | def unwrap(value):
"""Iterate an NTTable
:returns: An iterator yielding an OrderedDict for each column
"""
ret = []
# build lists of column names, and value
lbl, cols = [], []
for cname, cval in value.value.items():
lbl.append(cname)
cols... | python | def unwrap(value):
"""Iterate an NTTable
:returns: An iterator yielding an OrderedDict for each column
"""
ret = []
# build lists of column names, and value
lbl, cols = [], []
for cname, cval in value.value.items():
lbl.append(cname)
cols... | [
"def",
"unwrap",
"(",
"value",
")",
":",
"ret",
"=",
"[",
"]",
"# build lists of column names, and value",
"lbl",
",",
"cols",
"=",
"[",
"]",
",",
"[",
"]",
"for",
"cname",
",",
"cval",
"in",
"value",
".",
"value",
".",
"items",
"(",
")",
":",
"lbl",... | Iterate an NTTable
:returns: An iterator yielding an OrderedDict for each column | [
"Iterate",
"an",
"NTTable"
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/nt/__init__.py#L220-L238 |
mdavidsaver/p4p | src/p4p/nt/__init__.py | NTURI.buildType | def buildType(args):
"""Build NTURI
:param list args: A list of tuples of query argument name and PVD type code.
>>> I = NTURI([
('arg_a', 'I'),
('arg_two', 's'),
])
"""
try:
return Type(id="epics:nt/NTURI:1.0", spec=[
... | python | def buildType(args):
"""Build NTURI
:param list args: A list of tuples of query argument name and PVD type code.
>>> I = NTURI([
('arg_a', 'I'),
('arg_two', 's'),
])
"""
try:
return Type(id="epics:nt/NTURI:1.0", spec=[
... | [
"def",
"buildType",
"(",
"args",
")",
":",
"try",
":",
"return",
"Type",
"(",
"id",
"=",
"\"epics:nt/NTURI:1.0\"",
",",
"spec",
"=",
"[",
"(",
"'scheme'",
",",
"'s'",
")",
",",
"(",
"'authority'",
",",
"'s'",
")",
",",
"(",
"'path'",
",",
"'s'",
")... | Build NTURI
:param list args: A list of tuples of query argument name and PVD type code.
>>> I = NTURI([
('arg_a', 'I'),
('arg_two', 's'),
]) | [
"Build",
"NTURI"
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/nt/__init__.py#L243-L261 |
mdavidsaver/p4p | src/p4p/nt/__init__.py | NTURI.wrap | def wrap(self, path, args=(), kws={}, scheme='', authority=''):
"""Wrap argument values (tuple/list with optional dict) into Value
:param str path: The PV name to which this call is made
:param tuple args: Ordered arguments
:param dict kws: Keyword arguments
:rtype: Value
... | python | def wrap(self, path, args=(), kws={}, scheme='', authority=''):
"""Wrap argument values (tuple/list with optional dict) into Value
:param str path: The PV name to which this call is made
:param tuple args: Ordered arguments
:param dict kws: Keyword arguments
:rtype: Value
... | [
"def",
"wrap",
"(",
"self",
",",
"path",
",",
"args",
"=",
"(",
")",
",",
"kws",
"=",
"{",
"}",
",",
"scheme",
"=",
"''",
",",
"authority",
"=",
"''",
")",
":",
"# build dict of argument name+value",
"AV",
"=",
"{",
"}",
"AV",
".",
"update",
"(",
... | Wrap argument values (tuple/list with optional dict) into Value
:param str path: The PV name to which this call is made
:param tuple args: Ordered arguments
:param dict kws: Keyword arguments
:rtype: Value | [
"Wrap",
"argument",
"values",
"(",
"tuple",
"/",
"list",
"with",
"optional",
"dict",
")",
"into",
"Value"
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/nt/__init__.py#L267-L292 |
mdavidsaver/p4p | src/p4p/nt/enum.py | NTEnum.wrap | def wrap(self, value, timestamp=None):
"""Pack python value into Value
"""
V = self.type()
S, NS = divmod(float(timestamp or time.time()), 1.0)
V.timeStamp = {
'secondsPastEpoch': S,
'nanoseconds': NS * 1e9,
}
if isinstance(value, dict):
... | python | def wrap(self, value, timestamp=None):
"""Pack python value into Value
"""
V = self.type()
S, NS = divmod(float(timestamp or time.time()), 1.0)
V.timeStamp = {
'secondsPastEpoch': S,
'nanoseconds': NS * 1e9,
}
if isinstance(value, dict):
... | [
"def",
"wrap",
"(",
"self",
",",
"value",
",",
"timestamp",
"=",
"None",
")",
":",
"V",
"=",
"self",
".",
"type",
"(",
")",
"S",
",",
"NS",
"=",
"divmod",
"(",
"float",
"(",
"timestamp",
"or",
"time",
".",
"time",
"(",
")",
")",
",",
"1.0",
"... | Pack python value into Value | [
"Pack",
"python",
"value",
"into",
"Value"
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/nt/enum.py#L62-L78 |
mdavidsaver/p4p | src/p4p/nt/enum.py | NTEnum.unwrap | def unwrap(self, value):
"""Unpack a Value into an augmented python type (selected from the 'value' field)
"""
if value.changed('value.choices'):
self._choices = value['value.choices']
idx = value['value.index']
ret = ntenum(idx)._store(value)
try:
... | python | def unwrap(self, value):
"""Unpack a Value into an augmented python type (selected from the 'value' field)
"""
if value.changed('value.choices'):
self._choices = value['value.choices']
idx = value['value.index']
ret = ntenum(idx)._store(value)
try:
... | [
"def",
"unwrap",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
".",
"changed",
"(",
"'value.choices'",
")",
":",
"self",
".",
"_choices",
"=",
"value",
"[",
"'value.choices'",
"]",
"idx",
"=",
"value",
"[",
"'value.index'",
"]",
"ret",
"=",
"nten... | Unpack a Value into an augmented python type (selected from the 'value' field) | [
"Unpack",
"a",
"Value",
"into",
"an",
"augmented",
"python",
"type",
"(",
"selected",
"from",
"the",
"value",
"field",
")"
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/nt/enum.py#L80-L92 |
mdavidsaver/p4p | src/p4p/nt/enum.py | NTEnum.assign | def assign(self, V, py):
"""Store python value in Value
"""
if isinstance(py, (bytes, unicode)):
for i,C in enumerate(V['value.choices'] or self._choices):
if py==C:
V['value.index'] = i
return
# attempt to parse as int... | python | def assign(self, V, py):
"""Store python value in Value
"""
if isinstance(py, (bytes, unicode)):
for i,C in enumerate(V['value.choices'] or self._choices):
if py==C:
V['value.index'] = i
return
# attempt to parse as int... | [
"def",
"assign",
"(",
"self",
",",
"V",
",",
"py",
")",
":",
"if",
"isinstance",
"(",
"py",
",",
"(",
"bytes",
",",
"unicode",
")",
")",
":",
"for",
"i",
",",
"C",
"in",
"enumerate",
"(",
"V",
"[",
"'value.choices'",
"]",
"or",
"self",
".",
"_c... | Store python value in Value | [
"Store",
"python",
"value",
"in",
"Value"
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/nt/enum.py#L94-L104 |
mdavidsaver/p4p | src/p4p/server/thread.py | SharedPV.close | def close(self, destroy=False, sync=False, timeout=None):
"""Close PV, disconnecting any clients.
:param bool destroy: Indicate "permanent" closure. Current clients will not see subsequent open().
:param bool sync: When block until any pending onLastDisconnect() is delivered (timeout applies).... | python | def close(self, destroy=False, sync=False, timeout=None):
"""Close PV, disconnecting any clients.
:param bool destroy: Indicate "permanent" closure. Current clients will not see subsequent open().
:param bool sync: When block until any pending onLastDisconnect() is delivered (timeout applies).... | [
"def",
"close",
"(",
"self",
",",
"destroy",
"=",
"False",
",",
"sync",
"=",
"False",
",",
"timeout",
"=",
"None",
")",
":",
"_SharedPV",
".",
"close",
"(",
"self",
",",
"destroy",
")",
"if",
"sync",
":",
"# TODO: still not syncing PVA workers...",
"self",... | Close PV, disconnecting any clients.
:param bool destroy: Indicate "permanent" closure. Current clients will not see subsequent open().
:param bool sync: When block until any pending onLastDisconnect() is delivered (timeout applies).
:param float timeout: Applies only when sync=True. None for... | [
"Close",
"PV",
"disconnecting",
"any",
"clients",
"."
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/server/thread.py#L91-L107 |
mdavidsaver/p4p | src/p4p/disect.py | gcstats | def gcstats():
"""Count the number of instances of each type/class
:returns: A dict() mapping type (as a string) to an integer number of references
"""
all = gc.get_objects()
_stats = {}
for obj in all:
K = type(obj)
if K is StatsDelta:
continue # avoid counting ou... | python | def gcstats():
"""Count the number of instances of each type/class
:returns: A dict() mapping type (as a string) to an integer number of references
"""
all = gc.get_objects()
_stats = {}
for obj in all:
K = type(obj)
if K is StatsDelta:
continue # avoid counting ou... | [
"def",
"gcstats",
"(",
")",
":",
"all",
"=",
"gc",
".",
"get_objects",
"(",
")",
"_stats",
"=",
"{",
"}",
"for",
"obj",
"in",
"all",
":",
"K",
"=",
"type",
"(",
"obj",
")",
"if",
"K",
"is",
"StatsDelta",
":",
"continue",
"# avoid counting ourselves",... | Count the number of instances of each type/class
:returns: A dict() mapping type (as a string) to an integer number of references | [
"Count",
"the",
"number",
"of",
"instances",
"of",
"each",
"type",
"/",
"class"
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/disect.py#L80-L109 |
mdavidsaver/p4p | src/p4p/disect.py | periodic | def periodic(period=60.0, file=sys.stderr):
"""Start a daemon thread which will periodically print GC stats
:param period: Update period in seconds
:param file: A writable file-like object
"""
import threading
import time
S = _StatsThread(period=period, file=file)
T = threading.Thread(t... | python | def periodic(period=60.0, file=sys.stderr):
"""Start a daemon thread which will periodically print GC stats
:param period: Update period in seconds
:param file: A writable file-like object
"""
import threading
import time
S = _StatsThread(period=period, file=file)
T = threading.Thread(t... | [
"def",
"periodic",
"(",
"period",
"=",
"60.0",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
":",
"import",
"threading",
"import",
"time",
"S",
"=",
"_StatsThread",
"(",
"period",
"=",
"period",
",",
"file",
"=",
"file",
")",
"T",
"=",
"threading",
".... | Start a daemon thread which will periodically print GC stats
:param period: Update period in seconds
:param file: A writable file-like object | [
"Start",
"a",
"daemon",
"thread",
"which",
"will",
"periodically",
"print",
"GC",
"stats"
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/disect.py#L142-L153 |
mdavidsaver/p4p | src/p4p/disect.py | StatsDelta.collect | def collect(self, file=sys.stderr):
"""Collect stats and print results to file
:param file: A writable file-like object
"""
cur = gcstats()
Ncur = len(cur)
if self.stats is not None and file is not None:
prev = self.stats
Nprev = self.ntypes # ma... | python | def collect(self, file=sys.stderr):
"""Collect stats and print results to file
:param file: A writable file-like object
"""
cur = gcstats()
Ncur = len(cur)
if self.stats is not None and file is not None:
prev = self.stats
Nprev = self.ntypes # ma... | [
"def",
"collect",
"(",
"self",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
":",
"cur",
"=",
"gcstats",
"(",
")",
"Ncur",
"=",
"len",
"(",
"cur",
")",
"if",
"self",
".",
"stats",
"is",
"not",
"None",
"and",
"file",
"is",
"not",
"None",
":",
"pr... | Collect stats and print results to file
:param file: A writable file-like object | [
"Collect",
"stats",
"and",
"print",
"results",
"to",
"file"
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/disect.py#L34-L76 |
mdavidsaver/p4p | src/p4p/client/cothread.py | Context.get | def get(self, name, request=None, timeout=5.0, throw=True):
"""Fetch current value of some number of PVs.
:param name: A single name string or list of name strings
:param request: A :py:class:`p4p.Value` or string to qualify this request, or None to use a default.
:param float timeout: ... | python | def get(self, name, request=None, timeout=5.0, throw=True):
"""Fetch current value of some number of PVs.
:param name: A single name string or list of name strings
:param request: A :py:class:`p4p.Value` or string to qualify this request, or None to use a default.
:param float timeout: ... | [
"def",
"get",
"(",
"self",
",",
"name",
",",
"request",
"=",
"None",
",",
"timeout",
"=",
"5.0",
",",
"throw",
"=",
"True",
")",
":",
"singlepv",
"=",
"isinstance",
"(",
"name",
",",
"(",
"bytes",
",",
"unicode",
")",
")",
"if",
"singlepv",
":",
... | Fetch current value of some number of PVs.
:param name: A single name string or list of name strings
:param request: A :py:class:`p4p.Value` or string to qualify this request, or None to use a default.
:param float timeout: Operation timeout in seconds
:param bool throw: When true, oper... | [
"Fetch",
"current",
"value",
"of",
"some",
"number",
"of",
"PVs",
"."
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/client/cothread.py#L34-L65 |
mdavidsaver/p4p | src/p4p/client/cothread.py | Context.put | def put(self, name, values, request=None, process=None, wait=None, timeout=5.0, get=True, throw=True):
"""Write a new value of some number of PVs.
:param name: A single name string or list of name strings
:param values: A single value, a list of values, a dict, a `Value`. May be modified by th... | python | def put(self, name, values, request=None, process=None, wait=None, timeout=5.0, get=True, throw=True):
"""Write a new value of some number of PVs.
:param name: A single name string or list of name strings
:param values: A single value, a list of values, a dict, a `Value`. May be modified by th... | [
"def",
"put",
"(",
"self",
",",
"name",
",",
"values",
",",
"request",
"=",
"None",
",",
"process",
"=",
"None",
",",
"wait",
"=",
"None",
",",
"timeout",
"=",
"5.0",
",",
"get",
"=",
"True",
",",
"throw",
"=",
"True",
")",
":",
"if",
"request",
... | Write a new value of some number of PVs.
:param name: A single name string or list of name strings
:param values: A single value, a list of values, a dict, a `Value`. May be modified by the constructor nt= argument.
:param request: A :py:class:`p4p.Value` or string to qualify this request, or ... | [
"Write",
"a",
"new",
"value",
"of",
"some",
"number",
"of",
"PVs",
"."
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/client/cothread.py#L94-L146 |
mdavidsaver/p4p | src/p4p/client/cothread.py | Context.monitor | def monitor(self, name, cb, request=None, notify_disconnect=False):
"""Create a subscription.
:param str name: PV name string
:param callable cb: Processing callback
:param request: A :py:class:`p4p.Value` or string to qualify this request, or None to use a default.
:param bool ... | python | def monitor(self, name, cb, request=None, notify_disconnect=False):
"""Create a subscription.
:param str name: PV name string
:param callable cb: Processing callback
:param request: A :py:class:`p4p.Value` or string to qualify this request, or None to use a default.
:param bool ... | [
"def",
"monitor",
"(",
"self",
",",
"name",
",",
"cb",
",",
"request",
"=",
"None",
",",
"notify_disconnect",
"=",
"False",
")",
":",
"R",
"=",
"Subscription",
"(",
"name",
",",
"cb",
",",
"notify_disconnect",
"=",
"notify_disconnect",
")",
"cb",
"=",
... | Create a subscription.
:param str name: PV name string
:param callable cb: Processing callback
:param request: A :py:class:`p4p.Value` or string to qualify this request, or None to use a default.
:param bool notify_disconnect: In additional to Values, the callback may also be call with ... | [
"Create",
"a",
"subscription",
"."
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/client/cothread.py#L224-L243 |
mdavidsaver/p4p | src/p4p/client/cothread.py | Subscription.close | def close(self):
"""Close subscription.
"""
if self._S is not None:
# after .close() self._event should never be called
self._S.close()
self._S = None
self._Q.Signal(None)
self._T.Wait() | python | def close(self):
"""Close subscription.
"""
if self._S is not None:
# after .close() self._event should never be called
self._S.close()
self._S = None
self._Q.Signal(None)
self._T.Wait() | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"_S",
"is",
"not",
"None",
":",
"# after .close() self._event should never be called",
"self",
".",
"_S",
".",
"close",
"(",
")",
"self",
".",
"_S",
"=",
"None",
"self",
".",
"_Q",
".",
"Signal",
... | Close subscription. | [
"Close",
"subscription",
"."
] | train | https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/client/cothread.py#L265-L273 |
eyeseast/propublica-congress | congress/members.py | MembersClient.filter | def filter(self, chamber, congress=CURRENT_CONGRESS, **kwargs):
"""
Takes a chamber and Congress,
OR state and district, returning a list of members
"""
check_chamber(chamber)
kwargs.update(chamber=chamber, congress=congress)
if 'state' in kwargs and 'district' ... | python | def filter(self, chamber, congress=CURRENT_CONGRESS, **kwargs):
"""
Takes a chamber and Congress,
OR state and district, returning a list of members
"""
check_chamber(chamber)
kwargs.update(chamber=chamber, congress=congress)
if 'state' in kwargs and 'district' ... | [
"def",
"filter",
"(",
"self",
",",
"chamber",
",",
"congress",
"=",
"CURRENT_CONGRESS",
",",
"*",
"*",
"kwargs",
")",
":",
"check_chamber",
"(",
"chamber",
")",
"kwargs",
".",
"update",
"(",
"chamber",
"=",
"chamber",
",",
"congress",
"=",
"congress",
")... | Takes a chamber and Congress,
OR state and district, returning a list of members | [
"Takes",
"a",
"chamber",
"and",
"Congress",
"OR",
"state",
"and",
"district",
"returning",
"a",
"list",
"of",
"members"
] | train | https://github.com/eyeseast/propublica-congress/blob/03e519341063c5703080b4723112f1831816c77e/congress/members.py#L12-L33 |
eyeseast/propublica-congress | congress/members.py | MembersClient.bills | def bills(self, member_id, type='introduced'):
"Same as BillsClient.by_member"
path = "members/{0}/bills/{1}.json".format(member_id, type)
return self.fetch(path) | python | def bills(self, member_id, type='introduced'):
"Same as BillsClient.by_member"
path = "members/{0}/bills/{1}.json".format(member_id, type)
return self.fetch(path) | [
"def",
"bills",
"(",
"self",
",",
"member_id",
",",
"type",
"=",
"'introduced'",
")",
":",
"path",
"=",
"\"members/{0}/bills/{1}.json\"",
".",
"format",
"(",
"member_id",
",",
"type",
")",
"return",
"self",
".",
"fetch",
"(",
"path",
")"
] | Same as BillsClient.by_member | [
"Same",
"as",
"BillsClient",
".",
"by_member"
] | train | https://github.com/eyeseast/propublica-congress/blob/03e519341063c5703080b4723112f1831816c77e/congress/members.py#L35-L38 |
eyeseast/propublica-congress | congress/members.py | MembersClient.compare | def compare(self, first, second, chamber, type='votes', congress=CURRENT_CONGRESS):
"""
See how often two members voted together in a given Congress.
Takes two member IDs, a chamber and a Congress number.
"""
check_chamber(chamber)
path = "members/{first}/{type}/{second}/... | python | def compare(self, first, second, chamber, type='votes', congress=CURRENT_CONGRESS):
"""
See how often two members voted together in a given Congress.
Takes two member IDs, a chamber and a Congress number.
"""
check_chamber(chamber)
path = "members/{first}/{type}/{second}/... | [
"def",
"compare",
"(",
"self",
",",
"first",
",",
"second",
",",
"chamber",
",",
"type",
"=",
"'votes'",
",",
"congress",
"=",
"CURRENT_CONGRESS",
")",
":",
"check_chamber",
"(",
"chamber",
")",
"path",
"=",
"\"members/{first}/{type}/{second}/{congress}/{chamber}.... | See how often two members voted together in a given Congress.
Takes two member IDs, a chamber and a Congress number. | [
"See",
"how",
"often",
"two",
"members",
"voted",
"together",
"in",
"a",
"given",
"Congress",
".",
"Takes",
"two",
"member",
"IDs",
"a",
"chamber",
"and",
"a",
"Congress",
"number",
"."
] | train | https://github.com/eyeseast/propublica-congress/blob/03e519341063c5703080b4723112f1831816c77e/congress/members.py#L51-L60 |
eyeseast/propublica-congress | congress/bills.py | BillsClient.by_member | def by_member(self, member_id, type='introduced'):
"""
Takes a bioguide ID and a type:
(introduced|updated|cosponsored|withdrawn)
Returns recent bills
"""
path = "members/{member_id}/bills/{type}.json".format(
member_id=member_id, type=type)
return sel... | python | def by_member(self, member_id, type='introduced'):
"""
Takes a bioguide ID and a type:
(introduced|updated|cosponsored|withdrawn)
Returns recent bills
"""
path = "members/{member_id}/bills/{type}.json".format(
member_id=member_id, type=type)
return sel... | [
"def",
"by_member",
"(",
"self",
",",
"member_id",
",",
"type",
"=",
"'introduced'",
")",
":",
"path",
"=",
"\"members/{member_id}/bills/{type}.json\"",
".",
"format",
"(",
"member_id",
"=",
"member_id",
",",
"type",
"=",
"type",
")",
"return",
"self",
".",
... | Takes a bioguide ID and a type:
(introduced|updated|cosponsored|withdrawn)
Returns recent bills | [
"Takes",
"a",
"bioguide",
"ID",
"and",
"a",
"type",
":",
"(",
"introduced|updated|cosponsored|withdrawn",
")",
"Returns",
"recent",
"bills"
] | train | https://github.com/eyeseast/propublica-congress/blob/03e519341063c5703080b4723112f1831816c77e/congress/bills.py#L7-L15 |
eyeseast/propublica-congress | congress/bills.py | BillsClient.upcoming | def upcoming(self, chamber, congress=CURRENT_CONGRESS):
"Shortcut for upcoming bills"
path = "bills/upcoming/{chamber}.json".format(chamber=chamber)
return self.fetch(path) | python | def upcoming(self, chamber, congress=CURRENT_CONGRESS):
"Shortcut for upcoming bills"
path = "bills/upcoming/{chamber}.json".format(chamber=chamber)
return self.fetch(path) | [
"def",
"upcoming",
"(",
"self",
",",
"chamber",
",",
"congress",
"=",
"CURRENT_CONGRESS",
")",
":",
"path",
"=",
"\"bills/upcoming/{chamber}.json\"",
".",
"format",
"(",
"chamber",
"=",
"chamber",
")",
"return",
"self",
".",
"fetch",
"(",
"path",
")"
] | Shortcut for upcoming bills | [
"Shortcut",
"for",
"upcoming",
"bills"
] | train | https://github.com/eyeseast/propublica-congress/blob/03e519341063c5703080b4723112f1831816c77e/congress/bills.py#L66-L69 |
eyeseast/propublica-congress | congress/votes.py | VotesClient.by_month | def by_month(self, chamber, year=None, month=None):
"""
Return votes for a single month, defaulting to the current month.
"""
check_chamber(chamber)
now = datetime.datetime.now()
year = year or now.year
month = month or now.month
path = "{chamber}/votes/... | python | def by_month(self, chamber, year=None, month=None):
"""
Return votes for a single month, defaulting to the current month.
"""
check_chamber(chamber)
now = datetime.datetime.now()
year = year or now.year
month = month or now.month
path = "{chamber}/votes/... | [
"def",
"by_month",
"(",
"self",
",",
"chamber",
",",
"year",
"=",
"None",
",",
"month",
"=",
"None",
")",
":",
"check_chamber",
"(",
"chamber",
")",
"now",
"=",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
"year",
"=",
"year",
"or",
"now",
".... | Return votes for a single month, defaulting to the current month. | [
"Return",
"votes",
"for",
"a",
"single",
"month",
"defaulting",
"to",
"the",
"current",
"month",
"."
] | train | https://github.com/eyeseast/propublica-congress/blob/03e519341063c5703080b4723112f1831816c77e/congress/votes.py#L10-L22 |
eyeseast/propublica-congress | congress/votes.py | VotesClient.by_range | def by_range(self, chamber, start, end):
"""
Return votes cast in a chamber between two dates,
up to one month apart.
"""
check_chamber(chamber)
start, end = parse_date(start), parse_date(end)
if start > end:
start, end = end, start
path = "{... | python | def by_range(self, chamber, start, end):
"""
Return votes cast in a chamber between two dates,
up to one month apart.
"""
check_chamber(chamber)
start, end = parse_date(start), parse_date(end)
if start > end:
start, end = end, start
path = "{... | [
"def",
"by_range",
"(",
"self",
",",
"chamber",
",",
"start",
",",
"end",
")",
":",
"check_chamber",
"(",
"chamber",
")",
"start",
",",
"end",
"=",
"parse_date",
"(",
"start",
")",
",",
"parse_date",
"(",
"end",
")",
"if",
"start",
">",
"end",
":",
... | Return votes cast in a chamber between two dates,
up to one month apart. | [
"Return",
"votes",
"cast",
"in",
"a",
"chamber",
"between",
"two",
"dates",
"up",
"to",
"one",
"month",
"apart",
"."
] | train | https://github.com/eyeseast/propublica-congress/blob/03e519341063c5703080b4723112f1831816c77e/congress/votes.py#L24-L37 |
eyeseast/propublica-congress | congress/votes.py | VotesClient.by_date | def by_date(self, chamber, date):
"Return votes cast in a chamber on a single day"
date = parse_date(date)
return self.by_range(chamber, date, date) | python | def by_date(self, chamber, date):
"Return votes cast in a chamber on a single day"
date = parse_date(date)
return self.by_range(chamber, date, date) | [
"def",
"by_date",
"(",
"self",
",",
"chamber",
",",
"date",
")",
":",
"date",
"=",
"parse_date",
"(",
"date",
")",
"return",
"self",
".",
"by_range",
"(",
"chamber",
",",
"date",
",",
"date",
")"
] | Return votes cast in a chamber on a single day | [
"Return",
"votes",
"cast",
"in",
"a",
"chamber",
"on",
"a",
"single",
"day"
] | train | https://github.com/eyeseast/propublica-congress/blob/03e519341063c5703080b4723112f1831816c77e/congress/votes.py#L39-L42 |
eyeseast/propublica-congress | congress/votes.py | VotesClient.today | def today(self, chamber):
"Return today's votes in a given chamber"
now = datetime.date.today()
return self.by_range(chamber, now, now) | python | def today(self, chamber):
"Return today's votes in a given chamber"
now = datetime.date.today()
return self.by_range(chamber, now, now) | [
"def",
"today",
"(",
"self",
",",
"chamber",
")",
":",
"now",
"=",
"datetime",
".",
"date",
".",
"today",
"(",
")",
"return",
"self",
".",
"by_range",
"(",
"chamber",
",",
"now",
",",
"now",
")"
] | Return today's votes in a given chamber | [
"Return",
"today",
"s",
"votes",
"in",
"a",
"given",
"chamber"
] | train | https://github.com/eyeseast/propublica-congress/blob/03e519341063c5703080b4723112f1831816c77e/congress/votes.py#L44-L47 |
eyeseast/propublica-congress | congress/votes.py | VotesClient.by_type | def by_type(self, chamber, type, congress=CURRENT_CONGRESS):
"Return votes by type: missed, party, lone no, perfect"
check_chamber(chamber)
path = "{congress}/{chamber}/votes/{type}.json".format(
congress=congress, chamber=chamber, type=type)
return self.fetch(path) | python | def by_type(self, chamber, type, congress=CURRENT_CONGRESS):
"Return votes by type: missed, party, lone no, perfect"
check_chamber(chamber)
path = "{congress}/{chamber}/votes/{type}.json".format(
congress=congress, chamber=chamber, type=type)
return self.fetch(path) | [
"def",
"by_type",
"(",
"self",
",",
"chamber",
",",
"type",
",",
"congress",
"=",
"CURRENT_CONGRESS",
")",
":",
"check_chamber",
"(",
"chamber",
")",
"path",
"=",
"\"{congress}/{chamber}/votes/{type}.json\"",
".",
"format",
"(",
"congress",
"=",
"congress",
",",... | Return votes by type: missed, party, lone no, perfect | [
"Return",
"votes",
"by",
"type",
":",
"missed",
"party",
"lone",
"no",
"perfect"
] | train | https://github.com/eyeseast/propublica-congress/blob/03e519341063c5703080b4723112f1831816c77e/congress/votes.py#L62-L68 |
eyeseast/propublica-congress | congress/votes.py | VotesClient.nominations | def nominations(self, congress=CURRENT_CONGRESS):
"Return votes on nominations from a given Congress"
path = "{congress}/nominations.json".format(congress=congress)
return self.fetch(path) | python | def nominations(self, congress=CURRENT_CONGRESS):
"Return votes on nominations from a given Congress"
path = "{congress}/nominations.json".format(congress=congress)
return self.fetch(path) | [
"def",
"nominations",
"(",
"self",
",",
"congress",
"=",
"CURRENT_CONGRESS",
")",
":",
"path",
"=",
"\"{congress}/nominations.json\"",
".",
"format",
"(",
"congress",
"=",
"congress",
")",
"return",
"self",
".",
"fetch",
"(",
"path",
")"
] | Return votes on nominations from a given Congress | [
"Return",
"votes",
"on",
"nominations",
"from",
"a",
"given",
"Congress"
] | train | https://github.com/eyeseast/propublica-congress/blob/03e519341063c5703080b4723112f1831816c77e/congress/votes.py#L86-L89 |
eyeseast/propublica-congress | congress/client.py | Client.fetch | def fetch(self, path, parse=lambda r: r['results'][0]):
"""
Make an API request, with authentication.
This method can be used directly to fetch new endpoints
or customize parsing.
::
>>> from congress import Congress
>>> client = Congress()
... | python | def fetch(self, path, parse=lambda r: r['results'][0]):
"""
Make an API request, with authentication.
This method can be used directly to fetch new endpoints
or customize parsing.
::
>>> from congress import Congress
>>> client = Congress()
... | [
"def",
"fetch",
"(",
"self",
",",
"path",
",",
"parse",
"=",
"lambda",
"r",
":",
"r",
"[",
"'results'",
"]",
"[",
"0",
"]",
")",
":",
"url",
"=",
"self",
".",
"BASE_URI",
"+",
"path",
"headers",
"=",
"{",
"'X-API-Key'",
":",
"self",
".",
"apikey"... | Make an API request, with authentication.
This method can be used directly to fetch new endpoints
or customize parsing.
::
>>> from congress import Congress
>>> client = Congress()
>>> senate = client.fetch('115/senate/members.json')
>>> print(s... | [
"Make",
"an",
"API",
"request",
"with",
"authentication",
"."
] | train | https://github.com/eyeseast/propublica-congress/blob/03e519341063c5703080b4723112f1831816c77e/congress/client.py#L31-L70 |
eyeseast/propublica-congress | congress/utils.py | parse_date | def parse_date(s):
"""
Parse a date using dateutil.parser.parse if available,
falling back to datetime.datetime.strptime if not
"""
if isinstance(s, (datetime.datetime, datetime.date)):
return s
try:
from dateutil.parser import parse
except ImportError:
parse = lambda... | python | def parse_date(s):
"""
Parse a date using dateutil.parser.parse if available,
falling back to datetime.datetime.strptime if not
"""
if isinstance(s, (datetime.datetime, datetime.date)):
return s
try:
from dateutil.parser import parse
except ImportError:
parse = lambda... | [
"def",
"parse_date",
"(",
"s",
")",
":",
"if",
"isinstance",
"(",
"s",
",",
"(",
"datetime",
".",
"datetime",
",",
"datetime",
".",
"date",
")",
")",
":",
"return",
"s",
"try",
":",
"from",
"dateutil",
".",
"parser",
"import",
"parse",
"except",
"Imp... | Parse a date using dateutil.parser.parse if available,
falling back to datetime.datetime.strptime if not | [
"Parse",
"a",
"date",
"using",
"dateutil",
".",
"parser",
".",
"parse",
"if",
"available",
"falling",
"back",
"to",
"datetime",
".",
"datetime",
".",
"strptime",
"if",
"not"
] | train | https://github.com/eyeseast/propublica-congress/blob/03e519341063c5703080b4723112f1831816c77e/congress/utils.py#L40-L51 |
deep-compute/diskarray | diskarray/vararray.py | DiskVarArray.append | def append(self, v):
'''
>>> d = DiskVarArray('/tmp/test3', dtype='uint32')
>>> d.append([1, 2, 3, 4])
>>> d.__getitem__(0)
memmap([1, 2, 3, 4], dtype=uint32)
>>> d.append([5, 6, 7, 8])
>>> d.__getitem__(1)
memmap([5, 6, 7, 8], dtype=uint32)
>>> sh... | python | def append(self, v):
'''
>>> d = DiskVarArray('/tmp/test3', dtype='uint32')
>>> d.append([1, 2, 3, 4])
>>> d.__getitem__(0)
memmap([1, 2, 3, 4], dtype=uint32)
>>> d.append([5, 6, 7, 8])
>>> d.__getitem__(1)
memmap([5, 6, 7, 8], dtype=uint32)
>>> sh... | [
"def",
"append",
"(",
"self",
",",
"v",
")",
":",
"self",
".",
"index",
".",
"append",
"(",
"len",
"(",
"self",
".",
"data",
")",
")",
"self",
".",
"data",
".",
"extend",
"(",
"v",
")"
] | >>> d = DiskVarArray('/tmp/test3', dtype='uint32')
>>> d.append([1, 2, 3, 4])
>>> d.__getitem__(0)
memmap([1, 2, 3, 4], dtype=uint32)
>>> d.append([5, 6, 7, 8])
>>> d.__getitem__(1)
memmap([5, 6, 7, 8], dtype=uint32)
>>> shutil.rmtree('/tmp/test3', ignore_errors=T... | [
">>>",
"d",
"=",
"DiskVarArray",
"(",
"/",
"tmp",
"/",
"test3",
"dtype",
"=",
"uint32",
")",
">>>",
"d",
".",
"append",
"(",
"[",
"1",
"2",
"3",
"4",
"]",
")",
">>>",
"d",
".",
"__getitem__",
"(",
"0",
")",
"memmap",
"(",
"[",
"1",
"2",
"3",
... | train | https://github.com/deep-compute/diskarray/blob/baa05a37b9a45f0140cbb2f2af4559dafa2adea2/diskarray/vararray.py#L115-L127 |
deep-compute/diskarray | diskarray/vararray.py | DiskVarArray.destroy | def destroy(self):
'''
>>> import numpy as np
>>> d = DiskVarArray('/tmp/test4', dtype='uint32')
>>> d.append([1, 2, 3, 4])
>>> d.destroy # doctest:+ELLIPSIS
<bound method DiskVarArray.destroy of <diskarray.vararray.DiskVarArray object at 0x...>>
>>> shutil.rmtree... | python | def destroy(self):
'''
>>> import numpy as np
>>> d = DiskVarArray('/tmp/test4', dtype='uint32')
>>> d.append([1, 2, 3, 4])
>>> d.destroy # doctest:+ELLIPSIS
<bound method DiskVarArray.destroy of <diskarray.vararray.DiskVarArray object at 0x...>>
>>> shutil.rmtree... | [
"def",
"destroy",
"(",
"self",
")",
":",
"self",
".",
"data",
".",
"destroy",
"(",
")",
"self",
".",
"data",
"=",
"None",
"self",
".",
"index",
".",
"destroy",
"(",
")",
"self",
".",
"index",
"=",
"None"
] | >>> import numpy as np
>>> d = DiskVarArray('/tmp/test4', dtype='uint32')
>>> d.append([1, 2, 3, 4])
>>> d.destroy # doctest:+ELLIPSIS
<bound method DiskVarArray.destroy of <diskarray.vararray.DiskVarArray object at 0x...>>
>>> shutil.rmtree('/tmp/test4', ignore_errors=True) | [
">>>",
"import",
"numpy",
"as",
"np",
">>>",
"d",
"=",
"DiskVarArray",
"(",
"/",
"tmp",
"/",
"test4",
"dtype",
"=",
"uint32",
")",
">>>",
"d",
".",
"append",
"(",
"[",
"1",
"2",
"3",
"4",
"]",
")",
">>>",
"d",
".",
"destroy",
"#",
"doctest",
":... | train | https://github.com/deep-compute/diskarray/blob/baa05a37b9a45f0140cbb2f2af4559dafa2adea2/diskarray/vararray.py#L137-L151 |
deep-compute/diskarray | diskarray/diskarray.py | DiskArray.append | def append(self, v):
'''
>>> import numpy as np
>>> da = DiskArray('/tmp/test.array', shape=(0, 3), growby=3, dtype=np.float32)
>>> print(da[:])
[]
>>> data = np.array([[2,3,4], [1, 2, 3]])
>>> da.append(data[0])
>>> print(da[:])
[[2. 3. 4.]
[0. 0. 0.]
... | python | def append(self, v):
'''
>>> import numpy as np
>>> da = DiskArray('/tmp/test.array', shape=(0, 3), growby=3, dtype=np.float32)
>>> print(da[:])
[]
>>> data = np.array([[2,3,4], [1, 2, 3]])
>>> da.append(data[0])
>>> print(da[:])
[[2. 3. 4.]
[0. 0. 0.]
... | [
"def",
"append",
"(",
"self",
",",
"v",
")",
":",
"# FIXME: for now we only support",
"# append along axis 0 and only",
"# for 1d and 2d arrays",
"# FIXME: for now we only support",
"# appending one item at a time",
"nrows",
"=",
"self",
".",
"_shape",
"[",
"0",
"]",
"nrows... | >>> import numpy as np
>>> da = DiskArray('/tmp/test.array', shape=(0, 3), growby=3, dtype=np.float32)
>>> print(da[:])
[]
>>> data = np.array([[2,3,4], [1, 2, 3]])
>>> da.append(data[0])
>>> print(da[:])
[[2. 3. 4.]
[0. 0. 0.]
[0. 0. 0.]] | [
">>>",
"import",
"numpy",
"as",
"np",
">>>",
"da",
"=",
"DiskArray",
"(",
"/",
"tmp",
"/",
"test",
".",
"array",
"shape",
"=",
"(",
"0",
"3",
")",
"growby",
"=",
"3",
"dtype",
"=",
"np",
".",
"float32",
")",
">>>",
"print",
"(",
"da",
"[",
":",... | train | https://github.com/deep-compute/diskarray/blob/baa05a37b9a45f0140cbb2f2af4559dafa2adea2/diskarray/diskarray.py#L123-L157 |
deep-compute/diskarray | diskarray/diskarray.py | DiskArray.extend | def extend(self, v):
'''
>>> import numpy as np
>>> da = DiskArray('/tmp/test.array', shape=(0, 3), capacity=(10, 3), dtype=np.float32)
>>> print(da[:])
[[2. 3. 4.]
[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]]
... | python | def extend(self, v):
'''
>>> import numpy as np
>>> da = DiskArray('/tmp/test.array', shape=(0, 3), capacity=(10, 3), dtype=np.float32)
>>> print(da[:])
[[2. 3. 4.]
[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]]
... | [
"def",
"extend",
"(",
"self",
",",
"v",
")",
":",
"nrows",
"=",
"self",
".",
"_shape",
"[",
"0",
"]",
"nrows_capacity",
"=",
"self",
".",
"_capacity_shape",
"[",
"0",
"]",
"remaining_capacity",
"=",
"nrows_capacity",
"-",
"nrows",
"if",
"remaining_capacity... | >>> import numpy as np
>>> da = DiskArray('/tmp/test.array', shape=(0, 3), capacity=(10, 3), dtype=np.float32)
>>> print(da[:])
[[2. 3. 4.]
[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]]
>>> data = np.array([[2,3,4], [1, 2, ... | [
">>>",
"import",
"numpy",
"as",
"np",
">>>",
"da",
"=",
"DiskArray",
"(",
"/",
"tmp",
"/",
"test",
".",
"array",
"shape",
"=",
"(",
"0",
"3",
")",
"capacity",
"=",
"(",
"10",
"3",
")",
"dtype",
"=",
"np",
".",
"float32",
")",
">>>",
"print",
"(... | train | https://github.com/deep-compute/diskarray/blob/baa05a37b9a45f0140cbb2f2af4559dafa2adea2/diskarray/diskarray.py#L159-L200 |
sparklingpandas/sparklingpandas | sparklingpandas/groupby.py | GroupBy._prep_spark_sql_groupby | def _prep_spark_sql_groupby(self):
"""Used Spark SQL group approach"""
# Strip the index info
non_index_columns = filter(lambda x: x not in self._prdd._index_names,
self._prdd._column_names())
self._grouped_spark_sql = (self._prdd.to_spark_sql()
... | python | def _prep_spark_sql_groupby(self):
"""Used Spark SQL group approach"""
# Strip the index info
non_index_columns = filter(lambda x: x not in self._prdd._index_names,
self._prdd._column_names())
self._grouped_spark_sql = (self._prdd.to_spark_sql()
... | [
"def",
"_prep_spark_sql_groupby",
"(",
"self",
")",
":",
"# Strip the index info",
"non_index_columns",
"=",
"filter",
"(",
"lambda",
"x",
":",
"x",
"not",
"in",
"self",
".",
"_prdd",
".",
"_index_names",
",",
"self",
".",
"_prdd",
".",
"_column_names",
"(",
... | Used Spark SQL group approach | [
"Used",
"Spark",
"SQL",
"group",
"approach"
] | train | https://github.com/sparklingpandas/sparklingpandas/blob/7d549df4348c979042b683c355aa778fc6d3a768/sparklingpandas/groupby.py#L54-L63 |
sparklingpandas/sparklingpandas | sparklingpandas/groupby.py | GroupBy._prep_pandas_groupby | def _prep_pandas_groupby(self):
"""Prepare the old school pandas group by based approach."""
myargs = self._myargs
mykwargs = self._mykwargs
def extract_keys(groupedFrame):
for key, group in groupedFrame:
yield (key, group)
def group_and_extract(fram... | python | def _prep_pandas_groupby(self):
"""Prepare the old school pandas group by based approach."""
myargs = self._myargs
mykwargs = self._mykwargs
def extract_keys(groupedFrame):
for key, group in groupedFrame:
yield (key, group)
def group_and_extract(fram... | [
"def",
"_prep_pandas_groupby",
"(",
"self",
")",
":",
"myargs",
"=",
"self",
".",
"_myargs",
"mykwargs",
"=",
"self",
".",
"_mykwargs",
"def",
"extract_keys",
"(",
"groupedFrame",
")",
":",
"for",
"key",
",",
"group",
"in",
"groupedFrame",
":",
"yield",
"(... | Prepare the old school pandas group by based approach. | [
"Prepare",
"the",
"old",
"school",
"pandas",
"group",
"by",
"based",
"approach",
"."
] | train | https://github.com/sparklingpandas/sparklingpandas/blob/7d549df4348c979042b683c355aa778fc6d3a768/sparklingpandas/groupby.py#L65-L80 |
sparklingpandas/sparklingpandas | sparklingpandas/groupby.py | GroupBy._group | def _group(self, rdd):
"""Group together the values with the same key."""
return rdd.reduceByKey(lambda x, y: x.append(y)) | python | def _group(self, rdd):
"""Group together the values with the same key."""
return rdd.reduceByKey(lambda x, y: x.append(y)) | [
"def",
"_group",
"(",
"self",
",",
"rdd",
")",
":",
"return",
"rdd",
".",
"reduceByKey",
"(",
"lambda",
"x",
",",
"y",
":",
"x",
".",
"append",
"(",
"y",
")",
")"
] | Group together the values with the same key. | [
"Group",
"together",
"the",
"values",
"with",
"the",
"same",
"key",
"."
] | train | https://github.com/sparklingpandas/sparklingpandas/blob/7d549df4348c979042b683c355aa778fc6d3a768/sparklingpandas/groupby.py#L89-L91 |
sparklingpandas/sparklingpandas | sparklingpandas/groupby.py | GroupBy.groups | def groups(self):
"""Returns dict {group name -> group labels}."""
self._prep_pandas_groupby()
def extract_group_labels(frame):
return (frame[0], frame[1].index.values)
return self._mergedRDD.map(extract_group_labels).collectAsMap() | python | def groups(self):
"""Returns dict {group name -> group labels}."""
self._prep_pandas_groupby()
def extract_group_labels(frame):
return (frame[0], frame[1].index.values)
return self._mergedRDD.map(extract_group_labels).collectAsMap() | [
"def",
"groups",
"(",
"self",
")",
":",
"self",
".",
"_prep_pandas_groupby",
"(",
")",
"def",
"extract_group_labels",
"(",
"frame",
")",
":",
"return",
"(",
"frame",
"[",
"0",
"]",
",",
"frame",
"[",
"1",
"]",
".",
"index",
".",
"values",
")",
"retur... | Returns dict {group name -> group labels}. | [
"Returns",
"dict",
"{",
"group",
"name",
"-",
">",
"group",
"labels",
"}",
"."
] | train | https://github.com/sparklingpandas/sparklingpandas/blob/7d549df4348c979042b683c355aa778fc6d3a768/sparklingpandas/groupby.py#L119-L126 |
sparklingpandas/sparklingpandas | sparklingpandas/groupby.py | GroupBy.ngroups | def ngroups(self):
"""Number of groups."""
if self._can_use_new_school():
return self._grouped_spark_sql.count()
self._prep_pandas_groupby()
return self._mergedRDD.count() | python | def ngroups(self):
"""Number of groups."""
if self._can_use_new_school():
return self._grouped_spark_sql.count()
self._prep_pandas_groupby()
return self._mergedRDD.count() | [
"def",
"ngroups",
"(",
"self",
")",
":",
"if",
"self",
".",
"_can_use_new_school",
"(",
")",
":",
"return",
"self",
".",
"_grouped_spark_sql",
".",
"count",
"(",
")",
"self",
".",
"_prep_pandas_groupby",
"(",
")",
"return",
"self",
".",
"_mergedRDD",
".",
... | Number of groups. | [
"Number",
"of",
"groups",
"."
] | train | https://github.com/sparklingpandas/sparklingpandas/blob/7d549df4348c979042b683c355aa778fc6d3a768/sparklingpandas/groupby.py#L129-L134 |
sparklingpandas/sparklingpandas | sparklingpandas/groupby.py | GroupBy.indices | def indices(self):
"""Returns dict {group name -> group indices}."""
self._prep_pandas_groupby()
def extract_group_indices(frame):
return (frame[0], frame[1].index)
return self._mergedRDD.map(extract_group_indices).collectAsMap() | python | def indices(self):
"""Returns dict {group name -> group indices}."""
self._prep_pandas_groupby()
def extract_group_indices(frame):
return (frame[0], frame[1].index)
return self._mergedRDD.map(extract_group_indices).collectAsMap() | [
"def",
"indices",
"(",
"self",
")",
":",
"self",
".",
"_prep_pandas_groupby",
"(",
")",
"def",
"extract_group_indices",
"(",
"frame",
")",
":",
"return",
"(",
"frame",
"[",
"0",
"]",
",",
"frame",
"[",
"1",
"]",
".",
"index",
")",
"return",
"self",
"... | Returns dict {group name -> group indices}. | [
"Returns",
"dict",
"{",
"group",
"name",
"-",
">",
"group",
"indices",
"}",
"."
] | train | https://github.com/sparklingpandas/sparklingpandas/blob/7d549df4348c979042b683c355aa778fc6d3a768/sparklingpandas/groupby.py#L137-L144 |
sparklingpandas/sparklingpandas | sparklingpandas/groupby.py | GroupBy.median | def median(self):
"""Compute median of groups, excluding missing values.
For multiple groupings, the result index will be a MultiIndex.
"""
self._prep_pandas_groupby()
return DataFrame.fromDataFrameRDD(
self._regroup_mergedRDD().values().map(
lambda x... | python | def median(self):
"""Compute median of groups, excluding missing values.
For multiple groupings, the result index will be a MultiIndex.
"""
self._prep_pandas_groupby()
return DataFrame.fromDataFrameRDD(
self._regroup_mergedRDD().values().map(
lambda x... | [
"def",
"median",
"(",
"self",
")",
":",
"self",
".",
"_prep_pandas_groupby",
"(",
")",
"return",
"DataFrame",
".",
"fromDataFrameRDD",
"(",
"self",
".",
"_regroup_mergedRDD",
"(",
")",
".",
"values",
"(",
")",
".",
"map",
"(",
"lambda",
"x",
":",
"x",
... | Compute median of groups, excluding missing values.
For multiple groupings, the result index will be a MultiIndex. | [
"Compute",
"median",
"of",
"groups",
"excluding",
"missing",
"values",
"."
] | train | https://github.com/sparklingpandas/sparklingpandas/blob/7d549df4348c979042b683c355aa778fc6d3a768/sparklingpandas/groupby.py#L146-L154 |
sparklingpandas/sparklingpandas | sparklingpandas/groupby.py | GroupBy.mean | def mean(self):
"""Compute mean of groups, excluding missing values.
For multiple groupings, the result index will be a MultiIndex.
"""
if self._can_use_new_school():
self._prep_spark_sql_groupby()
import pyspark.sql.functions as func
return self._use... | python | def mean(self):
"""Compute mean of groups, excluding missing values.
For multiple groupings, the result index will be a MultiIndex.
"""
if self._can_use_new_school():
self._prep_spark_sql_groupby()
import pyspark.sql.functions as func
return self._use... | [
"def",
"mean",
"(",
"self",
")",
":",
"if",
"self",
".",
"_can_use_new_school",
"(",
")",
":",
"self",
".",
"_prep_spark_sql_groupby",
"(",
")",
"import",
"pyspark",
".",
"sql",
".",
"functions",
"as",
"func",
"return",
"self",
".",
"_use_aggregation",
"("... | Compute mean of groups, excluding missing values.
For multiple groupings, the result index will be a MultiIndex. | [
"Compute",
"mean",
"of",
"groups",
"excluding",
"missing",
"values",
"."
] | train | https://github.com/sparklingpandas/sparklingpandas/blob/7d549df4348c979042b683c355aa778fc6d3a768/sparklingpandas/groupby.py#L156-L168 |
sparklingpandas/sparklingpandas | sparklingpandas/groupby.py | GroupBy.var | def var(self, ddof=1):
"""Compute standard deviation of groups, excluding missing values.
For multiple groupings, the result index will be a MultiIndex.
"""
self._prep_pandas_groupby()
return DataFrame.fromDataFrameRDD(
self._regroup_mergedRDD().values().map(
... | python | def var(self, ddof=1):
"""Compute standard deviation of groups, excluding missing values.
For multiple groupings, the result index will be a MultiIndex.
"""
self._prep_pandas_groupby()
return DataFrame.fromDataFrameRDD(
self._regroup_mergedRDD().values().map(
... | [
"def",
"var",
"(",
"self",
",",
"ddof",
"=",
"1",
")",
":",
"self",
".",
"_prep_pandas_groupby",
"(",
")",
"return",
"DataFrame",
".",
"fromDataFrameRDD",
"(",
"self",
".",
"_regroup_mergedRDD",
"(",
")",
".",
"values",
"(",
")",
".",
"map",
"(",
"lamb... | Compute standard deviation of groups, excluding missing values.
For multiple groupings, the result index will be a MultiIndex. | [
"Compute",
"standard",
"deviation",
"of",
"groups",
"excluding",
"missing",
"values",
"."
] | train | https://github.com/sparklingpandas/sparklingpandas/blob/7d549df4348c979042b683c355aa778fc6d3a768/sparklingpandas/groupby.py#L170-L178 |
sparklingpandas/sparklingpandas | sparklingpandas/groupby.py | GroupBy.sum | def sum(self):
"""Compute the sum for each group."""
if self._can_use_new_school():
self._prep_spark_sql_groupby()
import pyspark.sql.functions as func
return self._use_aggregation(func.sum)
self._prep_pandas_groupby()
myargs = self._myargs
myk... | python | def sum(self):
"""Compute the sum for each group."""
if self._can_use_new_school():
self._prep_spark_sql_groupby()
import pyspark.sql.functions as func
return self._use_aggregation(func.sum)
self._prep_pandas_groupby()
myargs = self._myargs
myk... | [
"def",
"sum",
"(",
"self",
")",
":",
"if",
"self",
".",
"_can_use_new_school",
"(",
")",
":",
"self",
".",
"_prep_spark_sql_groupby",
"(",
")",
"import",
"pyspark",
".",
"sql",
".",
"functions",
"as",
"func",
"return",
"self",
".",
"_use_aggregation",
"(",... | Compute the sum for each group. | [
"Compute",
"the",
"sum",
"for",
"each",
"group",
"."
] | train | https://github.com/sparklingpandas/sparklingpandas/blob/7d549df4348c979042b683c355aa778fc6d3a768/sparklingpandas/groupby.py#L180-L203 |
sparklingpandas/sparklingpandas | sparklingpandas/groupby.py | GroupBy._create_exprs_using_func | def _create_exprs_using_func(self, f, columns):
"""Create aggregate expressions using the provided function
with the result coming back as the original column name."""
expressions = map(lambda c: f(c).alias(c),
self._columns)
return expressions | python | def _create_exprs_using_func(self, f, columns):
"""Create aggregate expressions using the provided function
with the result coming back as the original column name."""
expressions = map(lambda c: f(c).alias(c),
self._columns)
return expressions | [
"def",
"_create_exprs_using_func",
"(",
"self",
",",
"f",
",",
"columns",
")",
":",
"expressions",
"=",
"map",
"(",
"lambda",
"c",
":",
"f",
"(",
"c",
")",
".",
"alias",
"(",
"c",
")",
",",
"self",
".",
"_columns",
")",
"return",
"expressions"
] | Create aggregate expressions using the provided function
with the result coming back as the original column name. | [
"Create",
"aggregate",
"expressions",
"using",
"the",
"provided",
"function",
"with",
"the",
"result",
"coming",
"back",
"as",
"the",
"original",
"column",
"name",
"."
] | train | https://github.com/sparklingpandas/sparklingpandas/blob/7d549df4348c979042b683c355aa778fc6d3a768/sparklingpandas/groupby.py#L205-L210 |
sparklingpandas/sparklingpandas | sparklingpandas/groupby.py | GroupBy._use_aggregation | def _use_aggregation(self, agg, columns=None):
"""Compute the result using the aggregation function provided.
The aggregation name must also be provided so we can strip of the extra
name that Spark SQL adds."""
if not columns:
columns = self._columns
from pyspark.sql ... | python | def _use_aggregation(self, agg, columns=None):
"""Compute the result using the aggregation function provided.
The aggregation name must also be provided so we can strip of the extra
name that Spark SQL adds."""
if not columns:
columns = self._columns
from pyspark.sql ... | [
"def",
"_use_aggregation",
"(",
"self",
",",
"agg",
",",
"columns",
"=",
"None",
")",
":",
"if",
"not",
"columns",
":",
"columns",
"=",
"self",
".",
"_columns",
"from",
"pyspark",
".",
"sql",
"import",
"functions",
"as",
"F",
"aggs",
"=",
"map",
"(",
... | Compute the result using the aggregation function provided.
The aggregation name must also be provided so we can strip of the extra
name that Spark SQL adds. | [
"Compute",
"the",
"result",
"using",
"the",
"aggregation",
"function",
"provided",
".",
"The",
"aggregation",
"name",
"must",
"also",
"be",
"provided",
"so",
"we",
"can",
"strip",
"of",
"the",
"extra",
"name",
"that",
"Spark",
"SQL",
"adds",
"."
] | train | https://github.com/sparklingpandas/sparklingpandas/blob/7d549df4348c979042b683c355aa778fc6d3a768/sparklingpandas/groupby.py#L287-L297 |
sparklingpandas/sparklingpandas | sparklingpandas/groupby.py | GroupBy._regroup_mergedRDD | def _regroup_mergedRDD(self):
"""A common pattern is we want to call groupby again on the dataframes
so we can use the groupby functions.
"""
myargs = self._myargs
mykwargs = self._mykwargs
self._prep_pandas_groupby()
def regroup(df):
return df.groupb... | python | def _regroup_mergedRDD(self):
"""A common pattern is we want to call groupby again on the dataframes
so we can use the groupby functions.
"""
myargs = self._myargs
mykwargs = self._mykwargs
self._prep_pandas_groupby()
def regroup(df):
return df.groupb... | [
"def",
"_regroup_mergedRDD",
"(",
"self",
")",
":",
"myargs",
"=",
"self",
".",
"_myargs",
"mykwargs",
"=",
"self",
".",
"_mykwargs",
"self",
".",
"_prep_pandas_groupby",
"(",
")",
"def",
"regroup",
"(",
"df",
")",
":",
"return",
"df",
".",
"groupby",
"(... | A common pattern is we want to call groupby again on the dataframes
so we can use the groupby functions. | [
"A",
"common",
"pattern",
"is",
"we",
"want",
"to",
"call",
"groupby",
"again",
"on",
"the",
"dataframes",
"so",
"we",
"can",
"use",
"the",
"groupby",
"functions",
"."
] | train | https://github.com/sparklingpandas/sparklingpandas/blob/7d549df4348c979042b683c355aa778fc6d3a768/sparklingpandas/groupby.py#L353-L364 |
sparklingpandas/sparklingpandas | sparklingpandas/groupby.py | GroupBy.nth | def nth(self, n, *args, **kwargs):
"""Take the nth element of each grouby."""
# TODO: Stop collecting the entire frame for each key.
self._prep_pandas_groupby()
myargs = self._myargs
mykwargs = self._mykwargs
nthRDD = self._regroup_mergedRDD().mapValues(
lambd... | python | def nth(self, n, *args, **kwargs):
"""Take the nth element of each grouby."""
# TODO: Stop collecting the entire frame for each key.
self._prep_pandas_groupby()
myargs = self._myargs
mykwargs = self._mykwargs
nthRDD = self._regroup_mergedRDD().mapValues(
lambd... | [
"def",
"nth",
"(",
"self",
",",
"n",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# TODO: Stop collecting the entire frame for each key.",
"self",
".",
"_prep_pandas_groupby",
"(",
")",
"myargs",
"=",
"self",
".",
"_myargs",
"mykwargs",
"=",
"self",
... | Take the nth element of each grouby. | [
"Take",
"the",
"nth",
"element",
"of",
"each",
"grouby",
"."
] | train | https://github.com/sparklingpandas/sparklingpandas/blob/7d549df4348c979042b683c355aa778fc6d3a768/sparklingpandas/groupby.py#L366-L375 |
sparklingpandas/sparklingpandas | sparklingpandas/groupby.py | GroupBy.aggregate | def aggregate(self, f):
"""Apply the aggregation function.
Note: This implementation does note take advantage of partial
aggregation unless we have one of the special cases.
Currently the only special case is Series.kurtosis - and even
that doesn't properly do partial aggregation... | python | def aggregate(self, f):
"""Apply the aggregation function.
Note: This implementation does note take advantage of partial
aggregation unless we have one of the special cases.
Currently the only special case is Series.kurtosis - and even
that doesn't properly do partial aggregation... | [
"def",
"aggregate",
"(",
"self",
",",
"f",
")",
":",
"if",
"self",
".",
"_can_use_new_school",
"(",
")",
"and",
"f",
"==",
"pd",
".",
"Series",
".",
"kurtosis",
":",
"self",
".",
"_prep_spark_sql_groupby",
"(",
")",
"import",
"custom_functions",
"as",
"C... | Apply the aggregation function.
Note: This implementation does note take advantage of partial
aggregation unless we have one of the special cases.
Currently the only special case is Series.kurtosis - and even
that doesn't properly do partial aggregations, but we can improve
it to... | [
"Apply",
"the",
"aggregation",
"function",
".",
"Note",
":",
"This",
"implementation",
"does",
"note",
"take",
"advantage",
"of",
"partial",
"aggregation",
"unless",
"we",
"have",
"one",
"of",
"the",
"special",
"cases",
".",
"Currently",
"the",
"only",
"specia... | train | https://github.com/sparklingpandas/sparklingpandas/blob/7d549df4348c979042b683c355aa778fc6d3a768/sparklingpandas/groupby.py#L377-L393 |
sparklingpandas/sparklingpandas | sparklingpandas/groupby.py | GroupBy.apply | def apply(self, func, *args, **kwargs):
"""Apply the provided function and combine the results together in the
same way as apply from groupby in pandas.
This returns a DataFrame.
"""
self._prep_pandas_groupby()
def key_by_index(data):
"""Key each row by its ... | python | def apply(self, func, *args, **kwargs):
"""Apply the provided function and combine the results together in the
same way as apply from groupby in pandas.
This returns a DataFrame.
"""
self._prep_pandas_groupby()
def key_by_index(data):
"""Key each row by its ... | [
"def",
"apply",
"(",
"self",
",",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_prep_pandas_groupby",
"(",
")",
"def",
"key_by_index",
"(",
"data",
")",
":",
"\"\"\"Key each row by its index.\n \"\"\"",
"# TODO: Is there ... | Apply the provided function and combine the results together in the
same way as apply from groupby in pandas.
This returns a DataFrame. | [
"Apply",
"the",
"provided",
"function",
"and",
"combine",
"the",
"results",
"together",
"in",
"the",
"same",
"way",
"as",
"apply",
"from",
"groupby",
"in",
"pandas",
"."
] | train | https://github.com/sparklingpandas/sparklingpandas/blob/7d549df4348c979042b683c355aa778fc6d3a768/sparklingpandas/groupby.py#L398-L422 |
sparklingpandas/sparklingpandas | sparklingpandas/custom_functions.py | _create_function | def _create_function(name, doc=""):
""" Create a function for aggregator by name"""
def _(col):
spark_ctx = SparkContext._active_spark_context
java_ctx = (getattr(spark_ctx._jvm.com.sparklingpandas.functions,
name)
(col._java_ctx if isinstance(col,... | python | def _create_function(name, doc=""):
""" Create a function for aggregator by name"""
def _(col):
spark_ctx = SparkContext._active_spark_context
java_ctx = (getattr(spark_ctx._jvm.com.sparklingpandas.functions,
name)
(col._java_ctx if isinstance(col,... | [
"def",
"_create_function",
"(",
"name",
",",
"doc",
"=",
"\"\"",
")",
":",
"def",
"_",
"(",
"col",
")",
":",
"spark_ctx",
"=",
"SparkContext",
".",
"_active_spark_context",
"java_ctx",
"=",
"(",
"getattr",
"(",
"spark_ctx",
".",
"_jvm",
".",
"com",
".",
... | Create a function for aggregator by name | [
"Create",
"a",
"function",
"for",
"aggregator",
"by",
"name"
] | train | https://github.com/sparklingpandas/sparklingpandas/blob/7d549df4348c979042b683c355aa778fc6d3a768/sparklingpandas/custom_functions.py#L10-L20 |
sparklingpandas/sparklingpandas | sparklingpandas/pstatcounter.py | PStatCounter.merge | def merge(self, frame):
"""
Add another DataFrame to the PStatCounter.
"""
for column, values in frame.iteritems():
# Temporary hack, fix later
counter = self._counters.get(column)
for value in values:
if counter is not None:
... | python | def merge(self, frame):
"""
Add another DataFrame to the PStatCounter.
"""
for column, values in frame.iteritems():
# Temporary hack, fix later
counter = self._counters.get(column)
for value in values:
if counter is not None:
... | [
"def",
"merge",
"(",
"self",
",",
"frame",
")",
":",
"for",
"column",
",",
"values",
"in",
"frame",
".",
"iteritems",
"(",
")",
":",
"# Temporary hack, fix later",
"counter",
"=",
"self",
".",
"_counters",
".",
"get",
"(",
"column",
")",
"for",
"value",
... | Add another DataFrame to the PStatCounter. | [
"Add",
"another",
"DataFrame",
"to",
"the",
"PStatCounter",
"."
] | train | https://github.com/sparklingpandas/sparklingpandas/blob/7d549df4348c979042b683c355aa778fc6d3a768/sparklingpandas/pstatcounter.py#L58-L67 |
sparklingpandas/sparklingpandas | sparklingpandas/pstatcounter.py | PStatCounter.merge_pstats | def merge_pstats(self, other):
"""
Merge all of the stats counters of the other PStatCounter with our
counters.
"""
if not isinstance(other, PStatCounter):
raise Exception("Can only merge PStatcounters!")
for column, counter in self._counters.items():
... | python | def merge_pstats(self, other):
"""
Merge all of the stats counters of the other PStatCounter with our
counters.
"""
if not isinstance(other, PStatCounter):
raise Exception("Can only merge PStatcounters!")
for column, counter in self._counters.items():
... | [
"def",
"merge_pstats",
"(",
"self",
",",
"other",
")",
":",
"if",
"not",
"isinstance",
"(",
"other",
",",
"PStatCounter",
")",
":",
"raise",
"Exception",
"(",
"\"Can only merge PStatcounters!\"",
")",
"for",
"column",
",",
"counter",
"in",
"self",
".",
"_cou... | Merge all of the stats counters of the other PStatCounter with our
counters. | [
"Merge",
"all",
"of",
"the",
"stats",
"counters",
"of",
"the",
"other",
"PStatCounter",
"with",
"our",
"counters",
"."
] | train | https://github.com/sparklingpandas/sparklingpandas/blob/7d549df4348c979042b683c355aa778fc6d3a768/sparklingpandas/pstatcounter.py#L69-L81 |
sparklingpandas/sparklingpandas | sparklingpandas/pstatcounter.py | ColumnStatCounters.merge | def merge(self, frame):
"""
Add another DataFrame to the accumulated stats for each column.
Parameters
----------
frame: pandas DataFrame we will update our stats counter with.
"""
for column_name, _ in self._column_stats.items():
data_arr = frame[[col... | python | def merge(self, frame):
"""
Add another DataFrame to the accumulated stats for each column.
Parameters
----------
frame: pandas DataFrame we will update our stats counter with.
"""
for column_name, _ in self._column_stats.items():
data_arr = frame[[col... | [
"def",
"merge",
"(",
"self",
",",
"frame",
")",
":",
"for",
"column_name",
",",
"_",
"in",
"self",
".",
"_column_stats",
".",
"items",
"(",
")",
":",
"data_arr",
"=",
"frame",
"[",
"[",
"column_name",
"]",
"]",
".",
"values",
"count",
",",
"min_max_t... | Add another DataFrame to the accumulated stats for each column.
Parameters
----------
frame: pandas DataFrame we will update our stats counter with. | [
"Add",
"another",
"DataFrame",
"to",
"the",
"accumulated",
"stats",
"for",
"each",
"column",
".",
"Parameters",
"----------",
"frame",
":",
"pandas",
"DataFrame",
"we",
"will",
"update",
"our",
"stats",
"counter",
"with",
"."
] | train | https://github.com/sparklingpandas/sparklingpandas/blob/7d549df4348c979042b683c355aa778fc6d3a768/sparklingpandas/pstatcounter.py#L114-L132 |
sparklingpandas/sparklingpandas | sparklingpandas/pstatcounter.py | ColumnStatCounters.merge_stats | def merge_stats(self, other_col_counters):
"""
Merge statistics from a different column stats counter in to this one.
Parameters
----------
other_column_counters: Other col_stat_counter to marge in to this one.
"""
for column_name, _ in self._column_stats.items():... | python | def merge_stats(self, other_col_counters):
"""
Merge statistics from a different column stats counter in to this one.
Parameters
----------
other_column_counters: Other col_stat_counter to marge in to this one.
"""
for column_name, _ in self._column_stats.items():... | [
"def",
"merge_stats",
"(",
"self",
",",
"other_col_counters",
")",
":",
"for",
"column_name",
",",
"_",
"in",
"self",
".",
"_column_stats",
".",
"items",
"(",
")",
":",
"self",
".",
"_column_stats",
"[",
"column_name",
"]",
"=",
"self",
".",
"_column_stats... | Merge statistics from a different column stats counter in to this one.
Parameters
----------
other_column_counters: Other col_stat_counter to marge in to this one. | [
"Merge",
"statistics",
"from",
"a",
"different",
"column",
"stats",
"counter",
"in",
"to",
"this",
"one",
".",
"Parameters",
"----------",
"other_column_counters",
":",
"Other",
"col_stat_counter",
"to",
"marge",
"in",
"to",
"this",
"one",
"."
] | train | https://github.com/sparklingpandas/sparklingpandas/blob/7d549df4348c979042b683c355aa778fc6d3a768/sparklingpandas/pstatcounter.py#L134-L144 |
sparklingpandas/sparklingpandas | sparklingpandas/dataframe.py | _update_index_on_df | def _update_index_on_df(df, index_names):
"""Helper function to restore index information after collection. Doesn't
use self so we can serialize this."""
if index_names:
df = df.set_index(index_names)
# Remove names from unnamed indexes
index_names = _denormalize_index_names(index_na... | python | def _update_index_on_df(df, index_names):
"""Helper function to restore index information after collection. Doesn't
use self so we can serialize this."""
if index_names:
df = df.set_index(index_names)
# Remove names from unnamed indexes
index_names = _denormalize_index_names(index_na... | [
"def",
"_update_index_on_df",
"(",
"df",
",",
"index_names",
")",
":",
"if",
"index_names",
":",
"df",
"=",
"df",
".",
"set_index",
"(",
"index_names",
")",
"# Remove names from unnamed indexes",
"index_names",
"=",
"_denormalize_index_names",
"(",
"index_names",
")... | Helper function to restore index information after collection. Doesn't
use self so we can serialize this. | [
"Helper",
"function",
"to",
"restore",
"index",
"information",
"after",
"collection",
".",
"Doesn",
"t",
"use",
"self",
"so",
"we",
"can",
"serialize",
"this",
"."
] | train | https://github.com/sparklingpandas/sparklingpandas/blob/7d549df4348c979042b683c355aa778fc6d3a768/sparklingpandas/dataframe.py#L272-L280 |
sparklingpandas/sparklingpandas | sparklingpandas/dataframe.py | DataFrame._rdd | def _rdd(self):
"""Return an RDD of Panda DataFrame objects. This can be expensive
especially if we don't do a narrow transformation after and get it back
to Spark SQL land quickly."""
columns = self._schema_rdd.columns
index_names = self._index_names
def fromRecords(rec... | python | def _rdd(self):
"""Return an RDD of Panda DataFrame objects. This can be expensive
especially if we don't do a narrow transformation after and get it back
to Spark SQL land quickly."""
columns = self._schema_rdd.columns
index_names = self._index_names
def fromRecords(rec... | [
"def",
"_rdd",
"(",
"self",
")",
":",
"columns",
"=",
"self",
".",
"_schema_rdd",
".",
"columns",
"index_names",
"=",
"self",
".",
"_index_names",
"def",
"fromRecords",
"(",
"records",
")",
":",
"if",
"not",
"records",
":",
"return",
"[",
"]",
"else",
... | Return an RDD of Panda DataFrame objects. This can be expensive
especially if we don't do a narrow transformation after and get it back
to Spark SQL land quickly. | [
"Return",
"an",
"RDD",
"of",
"Panda",
"DataFrame",
"objects",
".",
"This",
"can",
"be",
"expensive",
"especially",
"if",
"we",
"don",
"t",
"do",
"a",
"narrow",
"transformation",
"after",
"and",
"get",
"it",
"back",
"to",
"Spark",
"SQL",
"land",
"quickly",
... | train | https://github.com/sparklingpandas/sparklingpandas/blob/7d549df4348c979042b683c355aa778fc6d3a768/sparklingpandas/dataframe.py#L43-L59 |
sparklingpandas/sparklingpandas | sparklingpandas/dataframe.py | DataFrame._column_names | def _column_names(self):
"""Return the column names"""
index_names = set(_normalize_index_names(self._index_names))
column_names = [col_name for col_name in self._schema_rdd.columns if
col_name not in index_names]
return column_names | python | def _column_names(self):
"""Return the column names"""
index_names = set(_normalize_index_names(self._index_names))
column_names = [col_name for col_name in self._schema_rdd.columns if
col_name not in index_names]
return column_names | [
"def",
"_column_names",
"(",
"self",
")",
":",
"index_names",
"=",
"set",
"(",
"_normalize_index_names",
"(",
"self",
".",
"_index_names",
")",
")",
"column_names",
"=",
"[",
"col_name",
"for",
"col_name",
"in",
"self",
".",
"_schema_rdd",
".",
"columns",
"i... | Return the column names | [
"Return",
"the",
"column",
"names"
] | train | https://github.com/sparklingpandas/sparklingpandas/blob/7d549df4348c979042b683c355aa778fc6d3a768/sparklingpandas/dataframe.py#L61-L66 |
sparklingpandas/sparklingpandas | sparklingpandas/dataframe.py | DataFrame._evil_apply_with_dataframes | def _evil_apply_with_dataframes(self, func, preserves_cols=False):
"""Convert the underlying SchmeaRDD to an RDD of DataFrames.
apply the provide function and convert the result back.
This is hella slow."""
source_rdd = self._rdd()
result_rdd = func(source_rdd)
# By defau... | python | def _evil_apply_with_dataframes(self, func, preserves_cols=False):
"""Convert the underlying SchmeaRDD to an RDD of DataFrames.
apply the provide function and convert the result back.
This is hella slow."""
source_rdd = self._rdd()
result_rdd = func(source_rdd)
# By defau... | [
"def",
"_evil_apply_with_dataframes",
"(",
"self",
",",
"func",
",",
"preserves_cols",
"=",
"False",
")",
":",
"source_rdd",
"=",
"self",
".",
"_rdd",
"(",
")",
"result_rdd",
"=",
"func",
"(",
"source_rdd",
")",
"# By default we don't know what the columns & indexes... | Convert the underlying SchmeaRDD to an RDD of DataFrames.
apply the provide function and convert the result back.
This is hella slow. | [
"Convert",
"the",
"underlying",
"SchmeaRDD",
"to",
"an",
"RDD",
"of",
"DataFrames",
".",
"apply",
"the",
"provide",
"function",
"and",
"convert",
"the",
"result",
"back",
".",
"This",
"is",
"hella",
"slow",
"."
] | train | https://github.com/sparklingpandas/sparklingpandas/blob/7d549df4348c979042b683c355aa778fc6d3a768/sparklingpandas/dataframe.py#L68-L83 |
sparklingpandas/sparklingpandas | sparklingpandas/dataframe.py | DataFrame._first_as_df | def _first_as_df(self):
"""Gets the first row as a Panda's DataFrame. Useful for functions like
dtypes & ftypes"""
columns = self._schema_rdd.columns
df = pd.DataFrame.from_records(
[self._schema_rdd.first()],
columns=self._schema_rdd.columns)
df = _update... | python | def _first_as_df(self):
"""Gets the first row as a Panda's DataFrame. Useful for functions like
dtypes & ftypes"""
columns = self._schema_rdd.columns
df = pd.DataFrame.from_records(
[self._schema_rdd.first()],
columns=self._schema_rdd.columns)
df = _update... | [
"def",
"_first_as_df",
"(",
"self",
")",
":",
"columns",
"=",
"self",
".",
"_schema_rdd",
".",
"columns",
"df",
"=",
"pd",
".",
"DataFrame",
".",
"from_records",
"(",
"[",
"self",
".",
"_schema_rdd",
".",
"first",
"(",
")",
"]",
",",
"columns",
"=",
... | Gets the first row as a Panda's DataFrame. Useful for functions like
dtypes & ftypes | [
"Gets",
"the",
"first",
"row",
"as",
"a",
"Panda",
"s",
"DataFrame",
".",
"Useful",
"for",
"functions",
"like",
"dtypes",
"&",
"ftypes"
] | train | https://github.com/sparklingpandas/sparklingpandas/blob/7d549df4348c979042b683c355aa778fc6d3a768/sparklingpandas/dataframe.py#L85-L93 |
sparklingpandas/sparklingpandas | sparklingpandas/dataframe.py | DataFrame.from_rdd_of_dataframes | def from_rdd_of_dataframes(self, rdd, column_idxs=None):
"""Take an RDD of Panda's DataFrames and return a Dataframe.
If the columns and indexes are already known (e.g. applyMap)
then supplying them with columnsIndexes will skip eveluating
the first partition to determine index info."""
... | python | def from_rdd_of_dataframes(self, rdd, column_idxs=None):
"""Take an RDD of Panda's DataFrames and return a Dataframe.
If the columns and indexes are already known (e.g. applyMap)
then supplying them with columnsIndexes will skip eveluating
the first partition to determine index info."""
... | [
"def",
"from_rdd_of_dataframes",
"(",
"self",
",",
"rdd",
",",
"column_idxs",
"=",
"None",
")",
":",
"def",
"frame_to_spark_sql",
"(",
"frame",
")",
":",
"\"\"\"Convert a Panda's DataFrame into Spark SQL Rows\"\"\"",
"return",
"[",
"r",
".",
"tolist",
"(",
")",
"f... | Take an RDD of Panda's DataFrames and return a Dataframe.
If the columns and indexes are already known (e.g. applyMap)
then supplying them with columnsIndexes will skip eveluating
the first partition to determine index info. | [
"Take",
"an",
"RDD",
"of",
"Panda",
"s",
"DataFrames",
"and",
"return",
"a",
"Dataframe",
".",
"If",
"the",
"columns",
"and",
"indexes",
"are",
"already",
"known",
"(",
"e",
".",
"g",
".",
"applyMap",
")",
"then",
"supplying",
"them",
"with",
"columnsInd... | train | https://github.com/sparklingpandas/sparklingpandas/blob/7d549df4348c979042b683c355aa778fc6d3a768/sparklingpandas/dataframe.py#L95-L136 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.