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_documentation_string stringlengths 1 47.2k | 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)... | I will wait until all pending handlers cothreads have completed | 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).... | 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... | 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... | Process queued work until interrupt() is called | 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) | Set PVA global debug print level. This prints directly to stdout,
bypassing eg. sys.stdout.
:param lvl: logging.* level or logLevel* | 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... | P4P sequenced shutdown. Intended to be atexit. Idenpotent. | 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
""... | Create a server and block the calling thread until KeyboardInterrupt.
Shorthand for: ::
with Server(*args, **kws):
try;
time.sleep(99999999)
except KeyboardInterrupt:
pass | 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: ... | 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... | 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)... | Pack python value into Value
Accepts dict to explicitly initialize fields be name.
Any other type is assigned to the 'value' field. | 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... | Unpack a Value into an augmented python type (selected from the 'value' field) | 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 ... | 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. | 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 ... | :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... | 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... | Wrap numpy.ndarray as Value | 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) | Unwrap Value as NTNDArray | 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:
... | Wrap get/rpc handler to unwrap Value | 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... | Reasonably sensible default handling of put builder | 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... | 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. | 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:
... | 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. | 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... | 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
... | 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... | 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
... | 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... | 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.
:... | 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` ... | 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.
... | 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... | 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... | 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... | 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... | 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... | 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 ... | 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... | 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 ... | 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 ... | 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 ... | 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) | Begin closing subscription. | 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 | Close subscription. | 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()
... | Force close all Channels and cancel all Operations | 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: ... | 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... | 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... | 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 ... | 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... | 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
... | 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.
... | 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 ... | 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 ... | 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... | 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... | 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... | 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... | 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... | 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... | 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... | 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... | 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`.
... | 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) | Unpack a Value as some other python type | 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'... | 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` | 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... | 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` | 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... | 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'},
]) | 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... | Iterate an NTTable
:returns: An iterator yielding an OrderedDict for each column | 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=[
... | 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'),
]) | 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
... | 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 | 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):
... | Pack python value into Value | 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:
... | Unpack a Value into an augmented python type (selected from the 'value' field) | 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... | Store python value in Value | 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).... | 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... | 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... | Count the number of instances of each type/class
:returns: A dict() mapping type (as a string) to an integer number of references | 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... | Start a daemon thread which will periodically print GC stats
:param period: Update period in seconds
:param file: A writable file-like object | 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... | Collect stats and print results to file
:param file: A writable file-like object | 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: ... | 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... | 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... | 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 ... | 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 ... | 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 ... | 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() | Close subscription. | 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' ... | Takes a chamber and Congress,
OR state and district, returning a list of members | 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) | Same as BillsClient.by_member | 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}/... | See how often two members voted together in a given Congress.
Takes two member IDs, a chamber and a Congress number. | 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... | Takes a bioguide ID and a type:
(introduced|updated|cosponsored|withdrawn)
Returns recent bills | 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) | Shortcut for upcoming bills | 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/... | Return votes for a single month, defaulting to the current month. | 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 = "{... | Return votes cast in a chamber between two dates,
up to one month apart. | 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) | Return votes cast in a chamber on a single day | 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) | Return today's votes in a given chamber | 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) | Return votes by type: missed, party, lone no, perfect | 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) | Return votes on nominations from a given Congress | 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()
... | 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... | 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... | Parse a date using dateutil.parser.parse if available,
falling back to datetime.datetime.strptime if not | 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... | >>> 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... | 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... | >>> 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) | 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.]
... | >>> 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.]] | 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.]]
... | >>> 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, ... | 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()
... | Used Spark SQL group approach | 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... | Prepare the old school pandas group by based approach. | 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)) | Group together the values with the same key. | 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() | Returns dict {group name -> group labels}. | 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() | Number of groups. | 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() | Returns dict {group name -> group indices}. | 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... | Compute median of groups, excluding missing values.
For multiple groupings, the result index will be a MultiIndex. | 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... | Compute mean of groups, excluding missing values.
For multiple groupings, the result index will be a MultiIndex. | 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(
... | Compute standard deviation of groups, excluding missing values.
For multiple groupings, the result index will be a MultiIndex. | 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... | Compute the sum for each group. | 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 | Create aggregate expressions using the provided function
with the result coming back as the original column name. | 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 ... | 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. | 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... | A common pattern is we want to call groupby again on the dataframes
so we can use the groupby functions. | 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... | Take the nth element of each grouby. | 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... | 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... | 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 ... | Apply the provided function and combine the results together in the
same way as apply from groupby in pandas.
This returns a DataFrame. | 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,... | Create a function for aggregator by name | 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:
... | Add another DataFrame to the PStatCounter. | 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():
... | Merge all of the stats counters of the other PStatCounter with our
counters. | 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... | Add another DataFrame to the accumulated stats for each column.
Parameters
----------
frame: pandas DataFrame we will update our stats counter with. | 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():... | 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. | 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... | Helper function to restore index information after collection. Doesn't
use self so we can serialize this. | 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... | 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. | 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 | Return the column names | 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... | Convert the underlying SchmeaRDD to an RDD of DataFrames.
apply the provide function and convert the result back.
This is hella slow. | 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... | Gets the first row as a Panda's DataFrame. Useful for functions like
dtypes & ftypes | 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."""
... | 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. | 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.