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 |
|---|---|---|---|---|---|---|---|
milesrichardson/ParsePy | parse_rest/connection.py | ParseBatcher.batch | def batch(self, methods):
"""
Given a list of create, update or delete methods to call, call all
of them in a single batch operation.
"""
methods = list(methods) # methods can be iterator
if not methods:
#accepts also empty list (or generator) - it allows call... | python | def batch(self, methods):
"""
Given a list of create, update or delete methods to call, call all
of them in a single batch operation.
"""
methods = list(methods) # methods can be iterator
if not methods:
#accepts also empty list (or generator) - it allows call... | Given a list of create, update or delete methods to call, call all
of them in a single batch operation. | https://github.com/milesrichardson/ParsePy/blob/7c52d8a5dc63bb7c3b0b8c0c09d032b4bc7299ea/parse_rest/connection.py#L178-L201 |
milesrichardson/ParsePy | parse_rest/installation.py | Installation.update_channels | def update_channels(cls, installation_id, channels_to_add=set(),
channels_to_remove=set(), **kw):
"""
Allow an application to manually subscribe or unsubscribe an
installation to a certain push channel in a unified operation.
this is based on:
https://www... | python | def update_channels(cls, installation_id, channels_to_add=set(),
channels_to_remove=set(), **kw):
"""
Allow an application to manually subscribe or unsubscribe an
installation to a certain push channel in a unified operation.
this is based on:
https://www... | Allow an application to manually subscribe or unsubscribe an
installation to a certain push channel in a unified operation.
this is based on:
https://www.parse.com/docs/rest#installations-updating
installation_id: the installation id you'd like to add a channel to
channels_to_a... | https://github.com/milesrichardson/ParsePy/blob/7c52d8a5dc63bb7c3b0b8c0c09d032b4bc7299ea/parse_rest/installation.py#L30-L49 |
milesrichardson/ParsePy | parse_rest/query.py | Queryset._fetch | def _fetch(self, count=False):
if self._result_cache is not None:
return len(self._result_cache) if count else self._result_cache
"""
Return a list of objects matching query, or if count == True return
only the number of objects matching.
"""
options = dict(se... | python | def _fetch(self, count=False):
if self._result_cache is not None:
return len(self._result_cache) if count else self._result_cache
"""
Return a list of objects matching query, or if count == True return
only the number of objects matching.
"""
options = dict(se... | Return a list of objects matching query, or if count == True return
only the number of objects matching. | https://github.com/milesrichardson/ParsePy/blob/7c52d8a5dc63bb7c3b0b8c0c09d032b4bc7299ea/parse_rest/query.py#L111-L128 |
milesrichardson/ParsePy | parse_rest/datatypes.py | complex_type | def complex_type(name=None):
'''Decorator for registering complex types'''
def wrapped(cls):
ParseType.type_mapping[name or cls.__name__] = cls
return cls
return wrapped | python | def complex_type(name=None):
'''Decorator for registering complex types'''
def wrapped(cls):
ParseType.type_mapping[name or cls.__name__] = cls
return cls
return wrapped | Decorator for registering complex types | https://github.com/milesrichardson/ParsePy/blob/7c52d8a5dc63bb7c3b0b8c0c09d032b4bc7299ea/parse_rest/datatypes.py#L25-L30 |
milesrichardson/ParsePy | parse_rest/datatypes.py | Object.factory | def factory(cls, class_name):
"""find proper Object subclass matching class_name
system types like _User are mapped to types without underscore (parse_resr.user.User)
If user don't declare matching type, class is created on the fly
"""
class_name = str(class_name.lstrip('_'))
... | python | def factory(cls, class_name):
"""find proper Object subclass matching class_name
system types like _User are mapped to types without underscore (parse_resr.user.User)
If user don't declare matching type, class is created on the fly
"""
class_name = str(class_name.lstrip('_'))
... | find proper Object subclass matching class_name
system types like _User are mapped to types without underscore (parse_resr.user.User)
If user don't declare matching type, class is created on the fly | https://github.com/milesrichardson/ParsePy/blob/7c52d8a5dc63bb7c3b0b8c0c09d032b4bc7299ea/parse_rest/datatypes.py#L545-L558 |
milesrichardson/ParsePy | parse_rest/datatypes.py | Object.schema | def schema(cls):
"""Retrieves the class' schema."""
root = '/'.join([API_ROOT, 'schemas', cls.__name__])
schema = cls.GET(root)
return schema | python | def schema(cls):
"""Retrieves the class' schema."""
root = '/'.join([API_ROOT, 'schemas', cls.__name__])
schema = cls.GET(root)
return schema | Retrieves the class' schema. | https://github.com/milesrichardson/ParsePy/blob/7c52d8a5dc63bb7c3b0b8c0c09d032b4bc7299ea/parse_rest/datatypes.py#L568-L572 |
milesrichardson/ParsePy | parse_rest/datatypes.py | Object.schema_delete_field | def schema_delete_field(cls, key):
"""Deletes a field."""
root = '/'.join([API_ROOT, 'schemas', cls.__name__])
payload = {
'className': cls.__name__,
'fields': {
key: {
'__op': 'Delete'
}
}
}
... | python | def schema_delete_field(cls, key):
"""Deletes a field."""
root = '/'.join([API_ROOT, 'schemas', cls.__name__])
payload = {
'className': cls.__name__,
'fields': {
key: {
'__op': 'Delete'
}
}
}
... | Deletes a field. | https://github.com/milesrichardson/ParsePy/blob/7c52d8a5dc63bb7c3b0b8c0c09d032b4bc7299ea/parse_rest/datatypes.py#L575-L586 |
milesrichardson/ParsePy | parse_rest/datatypes.py | Object.increment | def increment(self, key, amount=1):
"""
Increment one value in the object. Note that this happens immediately:
it does not wait for save() to be called
"""
payload = {
key: {
'__op': 'Increment',
'amount': amount
}
... | python | def increment(self, key, amount=1):
"""
Increment one value in the object. Note that this happens immediately:
it does not wait for save() to be called
"""
payload = {
key: {
'__op': 'Increment',
'amount': amount
}
... | Increment one value in the object. Note that this happens immediately:
it does not wait for save() to be called | https://github.com/milesrichardson/ParsePy/blob/7c52d8a5dc63bb7c3b0b8c0c09d032b4bc7299ea/parse_rest/datatypes.py#L598-L610 |
milesrichardson/ParsePy | parse_rest/datatypes.py | Object.remove | def remove(self, key):
"""
Clear a column value in the object. Note that this happens immediately:
it does not wait for save() to be called.
"""
payload = {
key: {
'__op': 'Delete'
}
}
self.__class__.PUT(self._absolu... | python | def remove(self, key):
"""
Clear a column value in the object. Note that this happens immediately:
it does not wait for save() to be called.
"""
payload = {
key: {
'__op': 'Delete'
}
}
self.__class__.PUT(self._absolu... | Clear a column value in the object. Note that this happens immediately:
it does not wait for save() to be called. | https://github.com/milesrichardson/ParsePy/blob/7c52d8a5dc63bb7c3b0b8c0c09d032b4bc7299ea/parse_rest/datatypes.py#L612-L623 |
milesrichardson/ParsePy | parse_rest/user.py | login_required | def login_required(func):
'''decorator describing User methods that need to be logged in'''
def ret(obj, *args, **kw):
if not hasattr(obj, 'sessionToken'):
message = '%s requires a logged-in session' % func.__name__
raise ResourceRequestLoginRequired(message)
return func(... | python | def login_required(func):
'''decorator describing User methods that need to be logged in'''
def ret(obj, *args, **kw):
if not hasattr(obj, 'sessionToken'):
message = '%s requires a logged-in session' % func.__name__
raise ResourceRequestLoginRequired(message)
return func(... | decorator describing User methods that need to be logged in | https://github.com/milesrichardson/ParsePy/blob/7c52d8a5dc63bb7c3b0b8c0c09d032b4bc7299ea/parse_rest/user.py#L21-L28 |
milesrichardson/ParsePy | parse_rest/user.py | User.request_password_reset | def request_password_reset(email):
'''Trigger Parse\'s Password Process. Return True/False
indicate success/failure on the request'''
url = '/'.join([API_ROOT, 'requestPasswordReset'])
try:
User.POST(url, email=email)
return True
except ParseError:
... | python | def request_password_reset(email):
'''Trigger Parse\'s Password Process. Return True/False
indicate success/failure on the request'''
url = '/'.join([API_ROOT, 'requestPasswordReset'])
try:
User.POST(url, email=email)
return True
except ParseError:
... | Trigger Parse\'s Password Process. Return True/False
indicate success/failure on the request | https://github.com/milesrichardson/ParsePy/blob/7c52d8a5dc63bb7c3b0b8c0c09d032b4bc7299ea/parse_rest/user.py#L106-L115 |
clld/clldutils | src/clldutils/jsonlib.py | parse | def parse(d):
"""Convert iso formatted timestamps found as values in the dict d to datetime objects.
:return: A shallow copy of d with converted timestamps.
"""
res = {}
for k, v in iteritems(d):
if isinstance(v, string_types) and DATETIME_ISO_FORMAT.match(v):
v = dateutil.parse... | python | def parse(d):
"""Convert iso formatted timestamps found as values in the dict d to datetime objects.
:return: A shallow copy of d with converted timestamps.
"""
res = {}
for k, v in iteritems(d):
if isinstance(v, string_types) and DATETIME_ISO_FORMAT.match(v):
v = dateutil.parse... | Convert iso formatted timestamps found as values in the dict d to datetime objects.
:return: A shallow copy of d with converted timestamps. | https://github.com/clld/clldutils/blob/7b8587ef5b56a2fc6cafaff90bc5004355c2b13f/src/clldutils/jsonlib.py#L18-L28 |
clld/clldutils | src/clldutils/jsonlib.py | dump | def dump(obj, path, **kw):
"""Python 2 + 3 compatible version of json.dump.
:param obj: The object to be dumped.
:param path: The path of the JSON file to be written.
:param kw: Keyword parameters are passed to json.dump
"""
open_kw = {'mode': 'w'}
if PY3: # pragma: no cover
open_k... | python | def dump(obj, path, **kw):
"""Python 2 + 3 compatible version of json.dump.
:param obj: The object to be dumped.
:param path: The path of the JSON file to be written.
:param kw: Keyword parameters are passed to json.dump
"""
open_kw = {'mode': 'w'}
if PY3: # pragma: no cover
open_k... | Python 2 + 3 compatible version of json.dump.
:param obj: The object to be dumped.
:param path: The path of the JSON file to be written.
:param kw: Keyword parameters are passed to json.dump | https://github.com/clld/clldutils/blob/7b8587ef5b56a2fc6cafaff90bc5004355c2b13f/src/clldutils/jsonlib.py#L37-L53 |
clld/clldutils | src/clldutils/jsonlib.py | load | def load(path, **kw):
"""python 2 + 3 compatible version of json.load.
:param kw: Keyword parameters are passed to json.load
:return: The python object read from path.
"""
_kw = {}
if PY3: # pragma: no cover
_kw['encoding'] = 'utf-8'
with open(str(path), **_kw) as fp:
retur... | python | def load(path, **kw):
"""python 2 + 3 compatible version of json.load.
:param kw: Keyword parameters are passed to json.load
:return: The python object read from path.
"""
_kw = {}
if PY3: # pragma: no cover
_kw['encoding'] = 'utf-8'
with open(str(path), **_kw) as fp:
retur... | python 2 + 3 compatible version of json.load.
:param kw: Keyword parameters are passed to json.load
:return: The python object read from path. | https://github.com/clld/clldutils/blob/7b8587ef5b56a2fc6cafaff90bc5004355c2b13f/src/clldutils/jsonlib.py#L56-L66 |
clld/clldutils | src/clldutils/text.py | strip_brackets | def strip_brackets(text, brackets=None):
"""Strip brackets and what is inside brackets from text.
.. note::
If the text contains only one opening bracket, the rest of the text
will be ignored. This is a feature, not a bug, as we want to avoid that
this function raises errors too easily.... | python | def strip_brackets(text, brackets=None):
"""Strip brackets and what is inside brackets from text.
.. note::
If the text contains only one opening bracket, the rest of the text
will be ignored. This is a feature, not a bug, as we want to avoid that
this function raises errors too easily.... | Strip brackets and what is inside brackets from text.
.. note::
If the text contains only one opening bracket, the rest of the text
will be ignored. This is a feature, not a bug, as we want to avoid that
this function raises errors too easily. | https://github.com/clld/clldutils/blob/7b8587ef5b56a2fc6cafaff90bc5004355c2b13f/src/clldutils/text.py#L56-L68 |
clld/clldutils | src/clldutils/text.py | split_text_with_context | def split_text_with_context(text, separators=WHITESPACE, brackets=None):
"""Splits text at separators outside of brackets.
:param text:
:param separators: An iterable of single character tokens.
:param brackets:
:return: A `list` of non-empty chunks.
.. note:: This function leaves content in b... | python | def split_text_with_context(text, separators=WHITESPACE, brackets=None):
"""Splits text at separators outside of brackets.
:param text:
:param separators: An iterable of single character tokens.
:param brackets:
:return: A `list` of non-empty chunks.
.. note:: This function leaves content in b... | Splits text at separators outside of brackets.
:param text:
:param separators: An iterable of single character tokens.
:param brackets:
:return: A `list` of non-empty chunks.
.. note:: This function leaves content in brackets in the chunks. | https://github.com/clld/clldutils/blob/7b8587ef5b56a2fc6cafaff90bc5004355c2b13f/src/clldutils/text.py#L71-L89 |
clld/clldutils | src/clldutils/text.py | split_text | def split_text(text, separators=re.compile('\s'), brackets=None, strip=False):
"""Split text along the separators unless they appear within brackets.
:param separators: An iterable single characters or a compiled regex pattern.
:param brackets: `dict` mapping start tokens to end tokens of what is to be \
... | python | def split_text(text, separators=re.compile('\s'), brackets=None, strip=False):
"""Split text along the separators unless they appear within brackets.
:param separators: An iterable single characters or a compiled regex pattern.
:param brackets: `dict` mapping start tokens to end tokens of what is to be \
... | Split text along the separators unless they appear within brackets.
:param separators: An iterable single characters or a compiled regex pattern.
:param brackets: `dict` mapping start tokens to end tokens of what is to be \
recognized as brackets.
.. note:: This function will also strip content within... | https://github.com/clld/clldutils/blob/7b8587ef5b56a2fc6cafaff90bc5004355c2b13f/src/clldutils/text.py#L92-L107 |
clld/clldutils | src/clldutils/sfm.py | marker_split | def marker_split(block):
"""Yield marker, value pairs from a text block (i.e. a list of lines).
:param block: text block consisting of \n separated lines as it will be the case for \
files read using "rU" mode.
:return: generator of (marker, value) pairs.
"""
marker = None
value = []
f... | python | def marker_split(block):
"""Yield marker, value pairs from a text block (i.e. a list of lines).
:param block: text block consisting of \n separated lines as it will be the case for \
files read using "rU" mode.
:return: generator of (marker, value) pairs.
"""
marker = None
value = []
f... | Yield marker, value pairs from a text block (i.e. a list of lines).
:param block: text block consisting of \n separated lines as it will be the case for \
files read using "rU" mode.
:return: generator of (marker, value) pairs. | https://github.com/clld/clldutils/blob/7b8587ef5b56a2fc6cafaff90bc5004355c2b13f/src/clldutils/sfm.py#L30-L53 |
clld/clldutils | src/clldutils/sfm.py | Entry.get | def get(self, key, default=None):
"""Retrieve the first value for a marker or None."""
for k, v in self:
if k == key:
return v
return default | python | def get(self, key, default=None):
"""Retrieve the first value for a marker or None."""
for k, v in self:
if k == key:
return v
return default | Retrieve the first value for a marker or None. | https://github.com/clld/clldutils/blob/7b8587ef5b56a2fc6cafaff90bc5004355c2b13f/src/clldutils/sfm.py#L71-L76 |
clld/clldutils | src/clldutils/sfm.py | SFM.read | def read(self,
filename,
encoding='utf-8',
marker_map=None,
entry_impl=Entry,
entry_sep='\n\n',
entry_prefix=None,
keep_empty=False):
"""Extend the list by parsing new entries from a file.
:param filename:
... | python | def read(self,
filename,
encoding='utf-8',
marker_map=None,
entry_impl=Entry,
entry_sep='\n\n',
entry_prefix=None,
keep_empty=False):
"""Extend the list by parsing new entries from a file.
:param filename:
... | Extend the list by parsing new entries from a file.
:param filename:
:param encoding:
:param marker_map: A dict used to map marker names.
:param entry_impl: Subclass of Entry or None
:param entry_sep:
:param entry_prefix: | https://github.com/clld/clldutils/blob/7b8587ef5b56a2fc6cafaff90bc5004355c2b13f/src/clldutils/sfm.py#L117-L142 |
clld/clldutils | src/clldutils/sfm.py | SFM.write | def write(self, filename, encoding='utf-8'):
"""Write the list of entries to a file.
:param filename:
:param encoding:
:return:
"""
with io.open(str(filename), 'w', encoding=encoding) as fp:
for entry in self:
fp.write(entry.__unicode__())
... | python | def write(self, filename, encoding='utf-8'):
"""Write the list of entries to a file.
:param filename:
:param encoding:
:return:
"""
with io.open(str(filename), 'w', encoding=encoding) as fp:
for entry in self:
fp.write(entry.__unicode__())
... | Write the list of entries to a file.
:param filename:
:param encoding:
:return: | https://github.com/clld/clldutils/blob/7b8587ef5b56a2fc6cafaff90bc5004355c2b13f/src/clldutils/sfm.py#L148-L158 |
clld/clldutils | src/clldutils/clilib.py | confirm | def confirm(question, default=True):
"""Ask a yes/no question interactively.
:param question: The text of the question to ask.
:returns: True if the answer was "yes", False otherwise.
"""
valid = {"": default, "yes": True, "y": True, "no": False, "n": False}
while 1:
choice = input(ques... | python | def confirm(question, default=True):
"""Ask a yes/no question interactively.
:param question: The text of the question to ask.
:returns: True if the answer was "yes", False otherwise.
"""
valid = {"": default, "yes": True, "y": True, "no": False, "n": False}
while 1:
choice = input(ques... | Ask a yes/no question interactively.
:param question: The text of the question to ask.
:returns: True if the answer was "yes", False otherwise. | https://github.com/clld/clldutils/blob/7b8587ef5b56a2fc6cafaff90bc5004355c2b13f/src/clldutils/clilib.py#L113-L124 |
clld/clldutils | src/clldutils/inifile.py | INI.gettext | def gettext(self, section, option, whitespace_preserving_prefix='.'):
"""
While configparser supports multiline values, it does this at the expense of
stripping leading whitespace for each line in such a value. Sometimes we want
to preserve such whitespace, e.g. to be able to put markdow... | python | def gettext(self, section, option, whitespace_preserving_prefix='.'):
"""
While configparser supports multiline values, it does this at the expense of
stripping leading whitespace for each line in such a value. Sometimes we want
to preserve such whitespace, e.g. to be able to put markdow... | While configparser supports multiline values, it does this at the expense of
stripping leading whitespace for each line in such a value. Sometimes we want
to preserve such whitespace, e.g. to be able to put markdown with nested lists
into INI files. We support this be introducing a special prefi... | https://github.com/clld/clldutils/blob/7b8587ef5b56a2fc6cafaff90bc5004355c2b13f/src/clldutils/inifile.py#L44-L58 |
clld/clldutils | src/clldutils/misc.py | data_url | def data_url(content, mimetype=None):
"""
Returns content encoded as base64 Data URI.
:param content: bytes or str or Path
:param mimetype: mimetype for
:return: str object (consisting only of ASCII, though)
.. seealso:: https://en.wikipedia.org/wiki/Data_URI_scheme
"""
if isinstance(c... | python | def data_url(content, mimetype=None):
"""
Returns content encoded as base64 Data URI.
:param content: bytes or str or Path
:param mimetype: mimetype for
:return: str object (consisting only of ASCII, though)
.. seealso:: https://en.wikipedia.org/wiki/Data_URI_scheme
"""
if isinstance(c... | Returns content encoded as base64 Data URI.
:param content: bytes or str or Path
:param mimetype: mimetype for
:return: str object (consisting only of ASCII, though)
.. seealso:: https://en.wikipedia.org/wiki/Data_URI_scheme | https://github.com/clld/clldutils/blob/7b8587ef5b56a2fc6cafaff90bc5004355c2b13f/src/clldutils/misc.py#L24-L43 |
clld/clldutils | src/clldutils/misc.py | to_binary | def to_binary(s, encoding='utf8'):
"""Portable cast function.
In python 2 the ``str`` function which is used to coerce objects to bytes does not
accept an encoding argument, whereas python 3's ``bytes`` function requires one.
:param s: object to be converted to binary_type
:return: binary_type ins... | python | def to_binary(s, encoding='utf8'):
"""Portable cast function.
In python 2 the ``str`` function which is used to coerce objects to bytes does not
accept an encoding argument, whereas python 3's ``bytes`` function requires one.
:param s: object to be converted to binary_type
:return: binary_type ins... | Portable cast function.
In python 2 the ``str`` function which is used to coerce objects to bytes does not
accept an encoding argument, whereas python 3's ``bytes`` function requires one.
:param s: object to be converted to binary_type
:return: binary_type instance, representing s. | https://github.com/clld/clldutils/blob/7b8587ef5b56a2fc6cafaff90bc5004355c2b13f/src/clldutils/misc.py#L61-L72 |
clld/clldutils | src/clldutils/misc.py | dict_merged | def dict_merged(d, _filter=None, **kw):
"""Update dictionary d with the items passed as kw if the value passes _filter."""
def f(s):
if _filter:
return _filter(s)
return s is not None
d = d or {}
for k, v in iteritems(kw):
if f(v):
d[k] = v
return d | python | def dict_merged(d, _filter=None, **kw):
"""Update dictionary d with the items passed as kw if the value passes _filter."""
def f(s):
if _filter:
return _filter(s)
return s is not None
d = d or {}
for k, v in iteritems(kw):
if f(v):
d[k] = v
return d | Update dictionary d with the items passed as kw if the value passes _filter. | https://github.com/clld/clldutils/blob/7b8587ef5b56a2fc6cafaff90bc5004355c2b13f/src/clldutils/misc.py#L75-L85 |
clld/clldutils | src/clldutils/misc.py | xmlchars | def xmlchars(text):
"""Not all of UTF-8 is considered valid character data in XML ...
Thus, this function can be used to remove illegal characters from ``text``.
"""
invalid = list(range(0x9))
invalid.extend([0xb, 0xc])
invalid.extend(range(0xe, 0x20))
return re.sub('|'.join('\\x%0.2X' % i ... | python | def xmlchars(text):
"""Not all of UTF-8 is considered valid character data in XML ...
Thus, this function can be used to remove illegal characters from ``text``.
"""
invalid = list(range(0x9))
invalid.extend([0xb, 0xc])
invalid.extend(range(0xe, 0x20))
return re.sub('|'.join('\\x%0.2X' % i ... | Not all of UTF-8 is considered valid character data in XML ...
Thus, this function can be used to remove illegal characters from ``text``. | https://github.com/clld/clldutils/blob/7b8587ef5b56a2fc6cafaff90bc5004355c2b13f/src/clldutils/misc.py#L99-L107 |
clld/clldutils | src/clldutils/misc.py | slug | def slug(s, remove_whitespace=True, lowercase=True):
"""Condensed version of s, containing only lowercase alphanumeric characters."""
res = ''.join(c for c in unicodedata.normalize('NFD', s)
if unicodedata.category(c) != 'Mn')
if lowercase:
res = res.lower()
for c in string.pun... | python | def slug(s, remove_whitespace=True, lowercase=True):
"""Condensed version of s, containing only lowercase alphanumeric characters."""
res = ''.join(c for c in unicodedata.normalize('NFD', s)
if unicodedata.category(c) != 'Mn')
if lowercase:
res = res.lower()
for c in string.pun... | Condensed version of s, containing only lowercase alphanumeric characters. | https://github.com/clld/clldutils/blob/7b8587ef5b56a2fc6cafaff90bc5004355c2b13f/src/clldutils/misc.py#L139-L150 |
clld/clldutils | src/clldutils/misc.py | encoded | def encoded(string, encoding='utf-8'):
"""Cast string to binary_type.
:param string: six.binary_type or six.text_type
:param encoding: encoding which the object is forced to
:return: six.binary_type
"""
assert isinstance(string, string_types) or isinstance(string, binary_type)
if isinstance... | python | def encoded(string, encoding='utf-8'):
"""Cast string to binary_type.
:param string: six.binary_type or six.text_type
:param encoding: encoding which the object is forced to
:return: six.binary_type
"""
assert isinstance(string, string_types) or isinstance(string, binary_type)
if isinstance... | Cast string to binary_type.
:param string: six.binary_type or six.text_type
:param encoding: encoding which the object is forced to
:return: six.binary_type | https://github.com/clld/clldutils/blob/7b8587ef5b56a2fc6cafaff90bc5004355c2b13f/src/clldutils/misc.py#L153-L170 |
clld/clldutils | src/clldutils/path.py | readlines | def readlines(p,
encoding=None,
strip=False,
comment=None,
normalize=None,
linenumbers=False):
"""
Read a `list` of lines from a text file.
:param p: File path (or `list` or `tuple` of text)
:param encoding: Registered codec.
:pa... | python | def readlines(p,
encoding=None,
strip=False,
comment=None,
normalize=None,
linenumbers=False):
"""
Read a `list` of lines from a text file.
:param p: File path (or `list` or `tuple` of text)
:param encoding: Registered codec.
:pa... | Read a `list` of lines from a text file.
:param p: File path (or `list` or `tuple` of text)
:param encoding: Registered codec.
:param strip: If `True`, strip leading and trailing whitespace.
:param comment: String used as syntax to mark comment lines. When not `None`, \
commented lines will be stri... | https://github.com/clld/clldutils/blob/7b8587ef5b56a2fc6cafaff90bc5004355c2b13f/src/clldutils/path.py#L96-L129 |
clld/clldutils | src/clldutils/path.py | walk | def walk(p, mode='all', **kw):
"""Wrapper for `os.walk`, yielding `Path` objects.
:param p: root of the directory tree to walk.
:param mode: 'all|dirs|files', defaulting to 'all'.
:param kw: Keyword arguments are passed to `os.walk`.
:return: Generator for the requested Path objects.
"""
fo... | python | def walk(p, mode='all', **kw):
"""Wrapper for `os.walk`, yielding `Path` objects.
:param p: root of the directory tree to walk.
:param mode: 'all|dirs|files', defaulting to 'all'.
:param kw: Keyword arguments are passed to `os.walk`.
:return: Generator for the requested Path objects.
"""
fo... | Wrapper for `os.walk`, yielding `Path` objects.
:param p: root of the directory tree to walk.
:param mode: 'all|dirs|files', defaulting to 'all'.
:param kw: Keyword arguments are passed to `os.walk`.
:return: Generator for the requested Path objects. | https://github.com/clld/clldutils/blob/7b8587ef5b56a2fc6cafaff90bc5004355c2b13f/src/clldutils/path.py#L148-L162 |
clld/clldutils | src/clldutils/source.py | Source.bibtex | def bibtex(self):
"""Represent the source in BibTeX format.
:return: string encoding the source in BibTeX syntax.
"""
m = max(itertools.chain(map(len, self), [0]))
fields = (" %s = {%s}" % (k.ljust(m), self[k]) for k in self)
return "@%s{%s,\n%s\n}" % (
geta... | python | def bibtex(self):
"""Represent the source in BibTeX format.
:return: string encoding the source in BibTeX syntax.
"""
m = max(itertools.chain(map(len, self), [0]))
fields = (" %s = {%s}" % (k.ljust(m), self[k]) for k in self)
return "@%s{%s,\n%s\n}" % (
geta... | Represent the source in BibTeX format.
:return: string encoding the source in BibTeX syntax. | https://github.com/clld/clldutils/blob/7b8587ef5b56a2fc6cafaff90bc5004355c2b13f/src/clldutils/source.py#L109-L117 |
clld/clldutils | src/clldutils/source.py | Source.text | def text(self):
"""Linearize the bib source according to the rules of the unified style.
Book:
author. year. booktitle. (series, volume.) address: publisher.
Article:
author. year. title. journal volume(issue). pages.
Incollection:
author. year. title. In edito... | python | def text(self):
"""Linearize the bib source according to the rules of the unified style.
Book:
author. year. booktitle. (series, volume.) address: publisher.
Article:
author. year. title. journal volume(issue). pages.
Incollection:
author. year. title. In edito... | Linearize the bib source according to the rules of the unified style.
Book:
author. year. booktitle. (series, volume.) address: publisher.
Article:
author. year. title. journal volume(issue). pages.
Incollection:
author. year. title. In editor (ed.), booktitle, pages. ... | https://github.com/clld/clldutils/blob/7b8587ef5b56a2fc6cafaff90bc5004355c2b13f/src/clldutils/source.py#L131-L235 |
messagebird/python-rest-api | messagebird/client.py | Client.request | def request(self, path, method='GET', params=None, type=REST_TYPE):
"""Builds a request, gets a response and decodes it."""
response_text = self._get_http_client(type).request(path, method, params)
if not response_text:
return response_text
response_json = json.loads(respon... | python | def request(self, path, method='GET', params=None, type=REST_TYPE):
"""Builds a request, gets a response and decodes it."""
response_text = self._get_http_client(type).request(path, method, params)
if not response_text:
return response_text
response_json = json.loads(respon... | Builds a request, gets a response and decodes it. | https://github.com/messagebird/python-rest-api/blob/fb7864f178135f92d09af803bee93270e99f3963/messagebird/client.py#L52-L64 |
messagebird/python-rest-api | messagebird/client.py | Client.hlr_create | def hlr_create(self, msisdn, reference):
"""Perform a new HLR lookup."""
return HLR().load(self.request('hlr', 'POST', {'msisdn': msisdn, 'reference': reference})) | python | def hlr_create(self, msisdn, reference):
"""Perform a new HLR lookup."""
return HLR().load(self.request('hlr', 'POST', {'msisdn': msisdn, 'reference': reference})) | Perform a new HLR lookup. | https://github.com/messagebird/python-rest-api/blob/fb7864f178135f92d09af803bee93270e99f3963/messagebird/client.py#L92-L94 |
messagebird/python-rest-api | messagebird/client.py | Client.message_create | def message_create(self, originator, recipients, body, params=None):
"""Create a new message."""
if params is None: params = {}
if type(recipients) == list:
recipients = ','.join(recipients)
params.update({'originator': originator, 'body': body, 'recipients': recipients})
... | python | def message_create(self, originator, recipients, body, params=None):
"""Create a new message."""
if params is None: params = {}
if type(recipients) == list:
recipients = ','.join(recipients)
params.update({'originator': originator, 'body': body, 'recipients': recipients})
... | Create a new message. | https://github.com/messagebird/python-rest-api/blob/fb7864f178135f92d09af803bee93270e99f3963/messagebird/client.py#L100-L107 |
messagebird/python-rest-api | messagebird/client.py | Client.voice_message_create | def voice_message_create(self, recipients, body, params=None):
"""Create a new voice message."""
if params is None: params = {}
if type(recipients) == list:
recipients = ','.join(recipients)
params.update({'recipients': recipients, 'body': body})
return VoiceMessage(... | python | def voice_message_create(self, recipients, body, params=None):
"""Create a new voice message."""
if params is None: params = {}
if type(recipients) == list:
recipients = ','.join(recipients)
params.update({'recipients': recipients, 'body': body})
return VoiceMessage(... | Create a new voice message. | https://github.com/messagebird/python-rest-api/blob/fb7864f178135f92d09af803bee93270e99f3963/messagebird/client.py#L117-L124 |
messagebird/python-rest-api | messagebird/client.py | Client.lookup | def lookup(self, phonenumber, params=None):
"""Do a new lookup."""
if params is None: params = {}
return Lookup().load(self.request('lookup/' + str(phonenumber), 'GET', params)) | python | def lookup(self, phonenumber, params=None):
"""Do a new lookup."""
if params is None: params = {}
return Lookup().load(self.request('lookup/' + str(phonenumber), 'GET', params)) | Do a new lookup. | https://github.com/messagebird/python-rest-api/blob/fb7864f178135f92d09af803bee93270e99f3963/messagebird/client.py#L126-L129 |
messagebird/python-rest-api | messagebird/client.py | Client.lookup_hlr | def lookup_hlr(self, phonenumber, params=None):
"""Retrieve the information of a specific HLR lookup."""
if params is None: params = {}
return HLR().load(self.request('lookup/' + str(phonenumber) + '/hlr', 'GET', params)) | python | def lookup_hlr(self, phonenumber, params=None):
"""Retrieve the information of a specific HLR lookup."""
if params is None: params = {}
return HLR().load(self.request('lookup/' + str(phonenumber) + '/hlr', 'GET', params)) | Retrieve the information of a specific HLR lookup. | https://github.com/messagebird/python-rest-api/blob/fb7864f178135f92d09af803bee93270e99f3963/messagebird/client.py#L131-L134 |
messagebird/python-rest-api | messagebird/client.py | Client.lookup_hlr_create | def lookup_hlr_create(self, phonenumber, params=None):
"""Perform a new HLR lookup."""
if params is None: params = {}
return HLR().load(self.request('lookup/' + str(phonenumber) + '/hlr', 'POST', params)) | python | def lookup_hlr_create(self, phonenumber, params=None):
"""Perform a new HLR lookup."""
if params is None: params = {}
return HLR().load(self.request('lookup/' + str(phonenumber) + '/hlr', 'POST', params)) | Perform a new HLR lookup. | https://github.com/messagebird/python-rest-api/blob/fb7864f178135f92d09af803bee93270e99f3963/messagebird/client.py#L136-L139 |
messagebird/python-rest-api | messagebird/client.py | Client.verify_create | def verify_create(self, recipient, params=None):
"""Create a new verification."""
if params is None: params = {}
params.update({'recipient': recipient})
return Verify().load(self.request('verify', 'POST', params)) | python | def verify_create(self, recipient, params=None):
"""Create a new verification."""
if params is None: params = {}
params.update({'recipient': recipient})
return Verify().load(self.request('verify', 'POST', params)) | Create a new verification. | https://github.com/messagebird/python-rest-api/blob/fb7864f178135f92d09af803bee93270e99f3963/messagebird/client.py#L145-L149 |
messagebird/python-rest-api | messagebird/client.py | Client.verify_verify | def verify_verify(self, id, token):
"""Verify the token of a specific verification."""
return Verify().load(self.request('verify/' + str(id), params={'token': token})) | python | def verify_verify(self, id, token):
"""Verify the token of a specific verification."""
return Verify().load(self.request('verify/' + str(id), params={'token': token})) | Verify the token of a specific verification. | https://github.com/messagebird/python-rest-api/blob/fb7864f178135f92d09af803bee93270e99f3963/messagebird/client.py#L151-L153 |
messagebird/python-rest-api | messagebird/base_list.py | BaseList.items | def items(self, value):
"""Create typed objects from the dicts."""
items = []
for item in value:
items.append(self.itemType().load(item))
self._items = items | python | def items(self, value):
"""Create typed objects from the dicts."""
items = []
for item in value:
items.append(self.itemType().load(item))
self._items = items | Create typed objects from the dicts. | https://github.com/messagebird/python-rest-api/blob/fb7864f178135f92d09af803bee93270e99f3963/messagebird/base_list.py#L39-L45 |
messagebird/python-rest-api | messagebird/http_client.py | HttpClient.request | def request(self, path, method='GET', params=None):
"""Builds a request and gets a response."""
if params is None: params = {}
url = urljoin(self.endpoint, path)
headers = {
'Accept': 'application/json',
'Authorization': 'AccessKey ' + self.access_key,
... | python | def request(self, path, method='GET', params=None):
"""Builds a request and gets a response."""
if params is None: params = {}
url = urljoin(self.endpoint, path)
headers = {
'Accept': 'application/json',
'Authorization': 'AccessKey ' + self.access_key,
... | Builds a request and gets a response. | https://github.com/messagebird/python-rest-api/blob/fb7864f178135f92d09af803bee93270e99f3963/messagebird/http_client.py#L20-L50 |
sagemath/cysignals | setup.py | build.run | def run(self):
"""
Run ``./configure`` and Cython first.
"""
config_h = opj("src", "cysignals", "cysignals_config.h")
if not os.path.isfile(config_h):
import subprocess
subprocess.check_call(["make", "configure"])
subprocess.check_call(["sh", "... | python | def run(self):
"""
Run ``./configure`` and Cython first.
"""
config_h = opj("src", "cysignals", "cysignals_config.h")
if not os.path.isfile(config_h):
import subprocess
subprocess.check_call(["make", "configure"])
subprocess.check_call(["sh", "... | Run ``./configure`` and Cython first. | https://github.com/sagemath/cysignals/blob/a8a8ad789332996e7e094188d65884982e899a65/setup.py#L88-L103 |
sagemath/cysignals | src/scripts/cysignals-CSI-helper.py | cython_debug_files | def cython_debug_files():
"""
Cython extra debug information files
"""
# Search all subdirectories of sys.path directories for a
# "cython_debug" directory. Note that sys_path is a variable set by
# cysignals-CSI. It may differ from sys.path if GDB is run with a
# different Python interprete... | python | def cython_debug_files():
"""
Cython extra debug information files
"""
# Search all subdirectories of sys.path directories for a
# "cython_debug" directory. Note that sys_path is a variable set by
# cysignals-CSI. It may differ from sys.path if GDB is run with a
# different Python interprete... | Cython extra debug information files | https://github.com/sagemath/cysignals/blob/a8a8ad789332996e7e094188d65884982e899a65/src/scripts/cysignals-CSI-helper.py#L34-L46 |
BerkeleyAutomation/perception | perception/colorized_phoxi_sensor.py | ColorizedPhoXiSensor.start | def start(self):
"""Start the sensor.
"""
running = self._webcam.start()
if not running:
return running
running &= self._phoxi.start()
if not running:
self._webcam.stop()
return running | python | def start(self):
"""Start the sensor.
"""
running = self._webcam.start()
if not running:
return running
running &= self._phoxi.start()
if not running:
self._webcam.stop()
return running | Start the sensor. | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/colorized_phoxi_sensor.py#L81-L91 |
BerkeleyAutomation/perception | perception/colorized_phoxi_sensor.py | ColorizedPhoXiSensor.stop | def stop(self):
"""Stop the sensor.
"""
# Check that everything is running
if not self._running:
logging.warning('Colorized PhoXi not running. Aborting stop')
return False
self._webcam.stop()
self._phoxi.stop()
return True | python | def stop(self):
"""Stop the sensor.
"""
# Check that everything is running
if not self._running:
logging.warning('Colorized PhoXi not running. Aborting stop')
return False
self._webcam.stop()
self._phoxi.stop()
return True | Stop the sensor. | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/colorized_phoxi_sensor.py#L93-L104 |
BerkeleyAutomation/perception | perception/colorized_phoxi_sensor.py | ColorizedPhoXiSensor.frames | def frames(self):
"""Retrieve a new frame from the PhoXi and convert it to a ColorImage,
a DepthImage, and an IrImage.
Returns
-------
:obj:`tuple` of :obj:`ColorImage`, :obj:`DepthImage`, :obj:`IrImage`, :obj:`numpy.ndarray`
The ColorImage, DepthImage, and IrImage o... | python | def frames(self):
"""Retrieve a new frame from the PhoXi and convert it to a ColorImage,
a DepthImage, and an IrImage.
Returns
-------
:obj:`tuple` of :obj:`ColorImage`, :obj:`DepthImage`, :obj:`IrImage`, :obj:`numpy.ndarray`
The ColorImage, DepthImage, and IrImage o... | Retrieve a new frame from the PhoXi and convert it to a ColorImage,
a DepthImage, and an IrImage.
Returns
-------
:obj:`tuple` of :obj:`ColorImage`, :obj:`DepthImage`, :obj:`IrImage`, :obj:`numpy.ndarray`
The ColorImage, DepthImage, and IrImage of the current frame. | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/colorized_phoxi_sensor.py#L106-L120 |
BerkeleyAutomation/perception | perception/colorized_phoxi_sensor.py | ColorizedPhoXiSensor.median_depth_img | def median_depth_img(self, num_img=1, fill_depth=0.0):
"""Collect a series of depth images and return the median of the set.
Parameters
----------
num_img : int
The number of consecutive frames to process.
Returns
-------
DepthImage
The m... | python | def median_depth_img(self, num_img=1, fill_depth=0.0):
"""Collect a series of depth images and return the median of the set.
Parameters
----------
num_img : int
The number of consecutive frames to process.
Returns
-------
DepthImage
The m... | Collect a series of depth images and return the median of the set.
Parameters
----------
num_img : int
The number of consecutive frames to process.
Returns
-------
DepthImage
The median DepthImage collected from the frames. | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/colorized_phoxi_sensor.py#L122-L143 |
BerkeleyAutomation/perception | perception/colorized_phoxi_sensor.py | ColorizedPhoXiSensor._colorize | def _colorize(self, depth_im, color_im):
"""Colorize a depth image from the PhoXi using a color image from the webcam.
Parameters
----------
depth_im : DepthImage
The PhoXi depth image.
color_im : ColorImage
Corresponding color image.
Returns
... | python | def _colorize(self, depth_im, color_im):
"""Colorize a depth image from the PhoXi using a color image from the webcam.
Parameters
----------
depth_im : DepthImage
The PhoXi depth image.
color_im : ColorImage
Corresponding color image.
Returns
... | Colorize a depth image from the PhoXi using a color image from the webcam.
Parameters
----------
depth_im : DepthImage
The PhoXi depth image.
color_im : ColorImage
Corresponding color image.
Returns
-------
ColorImage
A colori... | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/colorized_phoxi_sensor.py#L145-L196 |
BerkeleyAutomation/perception | perception/rgbd_sensors.py | RgbdSensorFactory.sensor | def sensor(sensor_type, cfg):
""" Creates a camera sensor of the specified type.
Parameters
----------
sensor_type : :obj:`str`
the type of the sensor (real or virtual)
cfg : :obj:`YamlConfig`
dictionary of parameters for sensor initialization
"""... | python | def sensor(sensor_type, cfg):
""" Creates a camera sensor of the specified type.
Parameters
----------
sensor_type : :obj:`str`
the type of the sensor (real or virtual)
cfg : :obj:`YamlConfig`
dictionary of parameters for sensor initialization
"""... | Creates a camera sensor of the specified type.
Parameters
----------
sensor_type : :obj:`str`
the type of the sensor (real or virtual)
cfg : :obj:`YamlConfig`
dictionary of parameters for sensor initialization | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/rgbd_sensors.py#L11-L63 |
BerkeleyAutomation/perception | perception/feature_matcher.py | FeatureMatcher.get_point_index | def get_point_index(point, all_points, eps = 1e-4):
""" Get the index of a point in an array """
inds = np.where(np.linalg.norm(point - all_points, axis=1) < eps)
if inds[0].shape[0] == 0:
return -1
return inds[0][0] | python | def get_point_index(point, all_points, eps = 1e-4):
""" Get the index of a point in an array """
inds = np.where(np.linalg.norm(point - all_points, axis=1) < eps)
if inds[0].shape[0] == 0:
return -1
return inds[0][0] | Get the index of a point in an array | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/feature_matcher.py#L111-L116 |
BerkeleyAutomation/perception | perception/feature_matcher.py | RawDistanceFeatureMatcher.match | def match(self, source_obj_features, target_obj_features):
"""
Matches features between two graspable objects based on a full distance matrix.
Parameters
----------
source_obj_features : :obj:`BagOfFeatures`
bag of the source objects features
target_obj_featu... | python | def match(self, source_obj_features, target_obj_features):
"""
Matches features between two graspable objects based on a full distance matrix.
Parameters
----------
source_obj_features : :obj:`BagOfFeatures`
bag of the source objects features
target_obj_featu... | Matches features between two graspable objects based on a full distance matrix.
Parameters
----------
source_obj_features : :obj:`BagOfFeatures`
bag of the source objects features
target_obj_features : :obj:`BagOfFeatures`
bag of the target objects features
... | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/feature_matcher.py#L126-L173 |
BerkeleyAutomation/perception | perception/feature_matcher.py | PointToPlaneFeatureMatcher.match | def match(self, source_points, target_points, source_normals, target_normals):
"""
Matches points between two point-normal sets. Uses the closest ip to choose matches, with distance for thresholding only.
Parameters
----------
source_point_cloud : Nx3 :obj:`numpy.ndarray`
... | python | def match(self, source_points, target_points, source_normals, target_normals):
"""
Matches points between two point-normal sets. Uses the closest ip to choose matches, with distance for thresholding only.
Parameters
----------
source_point_cloud : Nx3 :obj:`numpy.ndarray`
... | Matches points between two point-normal sets. Uses the closest ip to choose matches, with distance for thresholding only.
Parameters
----------
source_point_cloud : Nx3 :obj:`numpy.ndarray`
source object points
target_point_cloud : Nx3 :obj:`numpy.ndarray`
target... | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/feature_matcher.py#L190-L231 |
BerkeleyAutomation/perception | perception/realsense_sensor.py | RealSenseSensor._config_pipe | def _config_pipe(self):
"""Configures the pipeline to stream color and depth.
"""
self._cfg.enable_device(self.id)
# configure the color stream
self._cfg.enable_stream(
rs.stream.color,
RealSenseSensor.COLOR_IM_WIDTH,
RealSenseSensor.COLOR_IM_... | python | def _config_pipe(self):
"""Configures the pipeline to stream color and depth.
"""
self._cfg.enable_device(self.id)
# configure the color stream
self._cfg.enable_stream(
rs.stream.color,
RealSenseSensor.COLOR_IM_WIDTH,
RealSenseSensor.COLOR_IM_... | Configures the pipeline to stream color and depth. | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/realsense_sensor.py#L79-L100 |
BerkeleyAutomation/perception | perception/realsense_sensor.py | RealSenseSensor._set_depth_scale | def _set_depth_scale(self):
"""Retrieve the scale of the depth sensor.
"""
sensor = self._profile.get_device().first_depth_sensor()
self._depth_scale = sensor.get_depth_scale() | python | def _set_depth_scale(self):
"""Retrieve the scale of the depth sensor.
"""
sensor = self._profile.get_device().first_depth_sensor()
self._depth_scale = sensor.get_depth_scale() | Retrieve the scale of the depth sensor. | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/realsense_sensor.py#L102-L106 |
BerkeleyAutomation/perception | perception/realsense_sensor.py | RealSenseSensor._set_intrinsics | def _set_intrinsics(self):
"""Read the intrinsics matrix from the stream.
"""
strm = self._profile.get_stream(rs.stream.color)
obj = strm.as_video_stream_profile().get_intrinsics()
self._intrinsics[0, 0] = obj.fx
self._intrinsics[1, 1] = obj.fy
self._intrinsics[0,... | python | def _set_intrinsics(self):
"""Read the intrinsics matrix from the stream.
"""
strm = self._profile.get_stream(rs.stream.color)
obj = strm.as_video_stream_profile().get_intrinsics()
self._intrinsics[0, 0] = obj.fx
self._intrinsics[1, 1] = obj.fy
self._intrinsics[0,... | Read the intrinsics matrix from the stream. | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/realsense_sensor.py#L108-L116 |
BerkeleyAutomation/perception | perception/realsense_sensor.py | RealSenseSensor.color_intrinsics | def color_intrinsics(self):
""":obj:`CameraIntrinsics` : The camera intrinsics for the RealSense color camera.
"""
return CameraIntrinsics(
self._frame,
self._intrinsics[0, 0],
self._intrinsics[1, 1],
self._intrinsics[0, 2],
self._intri... | python | def color_intrinsics(self):
""":obj:`CameraIntrinsics` : The camera intrinsics for the RealSense color camera.
"""
return CameraIntrinsics(
self._frame,
self._intrinsics[0, 0],
self._intrinsics[1, 1],
self._intrinsics[0, 2],
self._intri... | :obj:`CameraIntrinsics` : The camera intrinsics for the RealSense color camera. | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/realsense_sensor.py#L119-L130 |
BerkeleyAutomation/perception | perception/realsense_sensor.py | RealSenseSensor.start | def start(self):
"""Start the sensor.
"""
try:
self._depth_align = False
if self._registration_mode == RealSenseRegistrationMode.DEPTH_TO_COLOR:
self._depth_align = True
self._config_pipe()
self._profile = self._pipe.start(self._cf... | python | def start(self):
"""Start the sensor.
"""
try:
self._depth_align = False
if self._registration_mode == RealSenseRegistrationMode.DEPTH_TO_COLOR:
self._depth_align = True
self._config_pipe()
self._profile = self._pipe.start(self._cf... | Start the sensor. | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/realsense_sensor.py#L156-L177 |
BerkeleyAutomation/perception | perception/realsense_sensor.py | RealSenseSensor.stop | def stop(self):
"""Stop the sensor.
"""
# check that everything is running
if not self._running:
logging.warning('Realsense not running. Aborting stop.')
return False
self._pipe.stop()
self._running = False
return True | python | def stop(self):
"""Stop the sensor.
"""
# check that everything is running
if not self._running:
logging.warning('Realsense not running. Aborting stop.')
return False
self._pipe.stop()
self._running = False
return True | Stop the sensor. | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/realsense_sensor.py#L179-L189 |
BerkeleyAutomation/perception | perception/realsense_sensor.py | RealSenseSensor._read_color_and_depth_image | def _read_color_and_depth_image(self):
"""Read a color and depth image from the device.
"""
frames = self._pipe.wait_for_frames()
if self._depth_align:
frames = self._align.process(frames)
depth_frame = frames.get_depth_frame()
color_frame = frames.get_color_... | python | def _read_color_and_depth_image(self):
"""Read a color and depth image from the device.
"""
frames = self._pipe.wait_for_frames()
if self._depth_align:
frames = self._align.process(frames)
depth_frame = frames.get_depth_frame()
color_frame = frames.get_color_... | Read a color and depth image from the device. | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/realsense_sensor.py#L200-L229 |
BerkeleyAutomation/perception | perception/webcam_sensor.py | WebcamSensor.start | def start(self):
"""Start the sensor.
"""
self._cap = cv2.VideoCapture(self._device_id + cv2.CAP_V4L2)
if not self._cap.isOpened():
self._running = False
self._cap.release()
self._cap = None
return False
self._cap.set(cv2.CAP_PROP_... | python | def start(self):
"""Start the sensor.
"""
self._cap = cv2.VideoCapture(self._device_id + cv2.CAP_V4L2)
if not self._cap.isOpened():
self._running = False
self._cap.release()
self._cap = None
return False
self._cap.set(cv2.CAP_PROP_... | Start the sensor. | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/webcam_sensor.py#L69-L87 |
BerkeleyAutomation/perception | perception/webcam_sensor.py | WebcamSensor.stop | def stop(self):
"""Stop the sensor.
"""
# Check that everything is running
if not self._running:
logging.warning('Webcam not running. Aborting stop')
return False
if self._cap:
self._cap.release()
self._cap = None
self._run... | python | def stop(self):
"""Stop the sensor.
"""
# Check that everything is running
if not self._running:
logging.warning('Webcam not running. Aborting stop')
return False
if self._cap:
self._cap.release()
self._cap = None
self._run... | Stop the sensor. | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/webcam_sensor.py#L89-L102 |
BerkeleyAutomation/perception | perception/webcam_sensor.py | WebcamSensor.frames | def frames(self, most_recent=False):
"""Retrieve a new frame from the PhoXi and convert it to a ColorImage,
a DepthImage, and an IrImage.
Parameters
----------
most_recent: bool
If true, the OpenCV buffer is emptied for the webcam before reading the most recent frame... | python | def frames(self, most_recent=False):
"""Retrieve a new frame from the PhoXi and convert it to a ColorImage,
a DepthImage, and an IrImage.
Parameters
----------
most_recent: bool
If true, the OpenCV buffer is emptied for the webcam before reading the most recent frame... | Retrieve a new frame from the PhoXi and convert it to a ColorImage,
a DepthImage, and an IrImage.
Parameters
----------
most_recent: bool
If true, the OpenCV buffer is emptied for the webcam before reading the most recent frame.
Returns
-------
:obj:... | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/webcam_sensor.py#L104-L132 |
BerkeleyAutomation/perception | perception/ensenso_sensor.py | EnsensoSensor._set_format | def _set_format(self, msg):
""" Set the buffer formatting. """
num_points = msg.height * msg.width
self._format = '<' + num_points * 'ffff' | python | def _set_format(self, msg):
""" Set the buffer formatting. """
num_points = msg.height * msg.width
self._format = '<' + num_points * 'ffff' | Set the buffer formatting. | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/ensenso_sensor.py#L42-L45 |
BerkeleyAutomation/perception | perception/ensenso_sensor.py | EnsensoSensor._set_camera_properties | def _set_camera_properties(self, msg):
""" Set the camera intrinsics from an info msg. """
focal_x = msg.K[0]
focal_y = msg.K[4]
center_x = msg.K[2]
center_y = msg.K[5]
im_height = msg.height
im_width = msg.width
self._camera_intr = CameraIntrinsics(self._... | python | def _set_camera_properties(self, msg):
""" Set the camera intrinsics from an info msg. """
focal_x = msg.K[0]
focal_y = msg.K[4]
center_x = msg.K[2]
center_y = msg.K[5]
im_height = msg.height
im_width = msg.width
self._camera_intr = CameraIntrinsics(self._... | Set the camera intrinsics from an info msg. | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/ensenso_sensor.py#L47-L58 |
BerkeleyAutomation/perception | perception/ensenso_sensor.py | EnsensoSensor._depth_im_from_pointcloud | def _depth_im_from_pointcloud(self, msg):
""" Convert a pointcloud2 message to a depth image. """
# set format
if self._format is None:
self._set_format(msg)
# rescale camera intr in case binning is turned on
if msg.height != self._camera_intr.height:
res... | python | def _depth_im_from_pointcloud(self, msg):
""" Convert a pointcloud2 message to a depth image. """
# set format
if self._format is None:
self._set_format(msg)
# rescale camera intr in case binning is turned on
if msg.height != self._camera_intr.height:
res... | Convert a pointcloud2 message to a depth image. | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/ensenso_sensor.py#L60-L84 |
BerkeleyAutomation/perception | perception/ensenso_sensor.py | EnsensoSensor.start | def start(self):
""" Start the sensor """
# initialize subscribers
self._pointcloud_sub = rospy.Subscriber('/%s/depth/points' %(self.frame), PointCloud2, self._pointcloud_callback)
self._camera_info_sub = rospy.Subscriber('/%s/left/camera_info' %(self.frame), CameraInfo, self._camera_inf... | python | def start(self):
""" Start the sensor """
# initialize subscribers
self._pointcloud_sub = rospy.Subscriber('/%s/depth/points' %(self.frame), PointCloud2, self._pointcloud_callback)
self._camera_info_sub = rospy.Subscriber('/%s/left/camera_info' %(self.frame), CameraInfo, self._camera_inf... | Start the sensor | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/ensenso_sensor.py#L113-L122 |
BerkeleyAutomation/perception | perception/ensenso_sensor.py | EnsensoSensor.stop | def stop(self):
""" Stop the sensor """
# check that everything is running
if not self._running:
logging.warning('Ensenso not running. Aborting stop')
return False
# stop subs
self._pointcloud_sub.unregister()
self._camera_info_sub.unregister()
... | python | def stop(self):
""" Stop the sensor """
# check that everything is running
if not self._running:
logging.warning('Ensenso not running. Aborting stop')
return False
# stop subs
self._pointcloud_sub.unregister()
self._camera_info_sub.unregister()
... | Stop the sensor | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/ensenso_sensor.py#L124-L135 |
BerkeleyAutomation/perception | perception/ensenso_sensor.py | EnsensoSensor.frames | def frames(self):
"""Retrieve a new frame from the Ensenso and convert it to a ColorImage,
a DepthImage, and an IrImage.
Returns
-------
:obj:`tuple` of :obj:`ColorImage`, :obj:`DepthImage`, :obj:`IrImage`, :obj:`numpy.ndarray`
The ColorImage, DepthImage, and IrImage... | python | def frames(self):
"""Retrieve a new frame from the Ensenso and convert it to a ColorImage,
a DepthImage, and an IrImage.
Returns
-------
:obj:`tuple` of :obj:`ColorImage`, :obj:`DepthImage`, :obj:`IrImage`, :obj:`numpy.ndarray`
The ColorImage, DepthImage, and IrImage... | Retrieve a new frame from the Ensenso and convert it to a ColorImage,
a DepthImage, and an IrImage.
Returns
-------
:obj:`tuple` of :obj:`ColorImage`, :obj:`DepthImage`, :obj:`IrImage`, :obj:`numpy.ndarray`
The ColorImage, DepthImage, and IrImage of the current frame.
... | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/ensenso_sensor.py#L137-L161 |
BerkeleyAutomation/perception | perception/point_registration.py | IterativeRegistrationSolver.register | def register(self, source_point_cloud, target_point_cloud,
source_normal_cloud, target_normal_cloud, matcher,
num_iterations=1, compute_total_cost=True, match_centroids=False,
vis=False):
""" Iteratively register objects to one another.
Parameters
... | python | def register(self, source_point_cloud, target_point_cloud,
source_normal_cloud, target_normal_cloud, matcher,
num_iterations=1, compute_total_cost=True, match_centroids=False,
vis=False):
""" Iteratively register objects to one another.
Parameters
... | Iteratively register objects to one another.
Parameters
----------
source_point_cloud : :obj:`autolab_core.PointCloud`
source object points
target_point_cloud : :obj`autolab_core.PointCloud`
target object points
source_normal_cloud : :obj:`autolab_core.No... | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/point_registration.py#L32-L62 |
BerkeleyAutomation/perception | perception/point_registration.py | PointToPlaneICPSolver.register | def register(self, source_point_cloud, target_point_cloud,
source_normal_cloud, target_normal_cloud, matcher,
num_iterations=1, compute_total_cost=True, match_centroids=False,
vis=False):
"""
Iteratively register objects to one another using a modified ... | python | def register(self, source_point_cloud, target_point_cloud,
source_normal_cloud, target_normal_cloud, matcher,
num_iterations=1, compute_total_cost=True, match_centroids=False,
vis=False):
"""
Iteratively register objects to one another using a modified ... | Iteratively register objects to one another using a modified version of point to plane ICP.
The cost func is PointToPlane_COST + gamma * PointToPoint_COST.
Uses a `stochastic Gauss-Newton step` where on each iteration a smaller number of points is sampled.
Parameters
----------
... | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/point_registration.py#L85-L240 |
BerkeleyAutomation/perception | perception/camera_sensor.py | VirtualSensor.frames | def frames(self):
"""Retrieve the next frame from the image directory and convert it to a ColorImage,
a DepthImage, and an IrImage.
Parameters
----------
skip_registration : bool
If True, the registration step is skipped.
Returns
-------
:obj... | python | def frames(self):
"""Retrieve the next frame from the image directory and convert it to a ColorImage,
a DepthImage, and an IrImage.
Parameters
----------
skip_registration : bool
If True, the registration step is skipped.
Returns
-------
:obj... | Retrieve the next frame from the image directory and convert it to a ColorImage,
a DepthImage, and an IrImage.
Parameters
----------
skip_registration : bool
If True, the registration step is skipped.
Returns
-------
:obj:`tuple` of :obj:`ColorImage`... | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/camera_sensor.py#L190-L222 |
BerkeleyAutomation/perception | perception/camera_sensor.py | VirtualSensor.median_depth_img | def median_depth_img(self, num_img=1):
"""Collect a series of depth images and return the median of the set.
Parameters
----------
num_img : int
The number of consecutive frames to process.
Returns
-------
:obj:`DepthImage`
The median Dep... | python | def median_depth_img(self, num_img=1):
"""Collect a series of depth images and return the median of the set.
Parameters
----------
num_img : int
The number of consecutive frames to process.
Returns
-------
:obj:`DepthImage`
The median Dep... | Collect a series of depth images and return the median of the set.
Parameters
----------
num_img : int
The number of consecutive frames to process.
Returns
-------
:obj:`DepthImage`
The median DepthImage collected from the frames. | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/camera_sensor.py#L224-L243 |
BerkeleyAutomation/perception | perception/camera_sensor.py | TensorDatasetVirtualSensor.frames | def frames(self):
"""Retrieve the next frame from the tensor dataset and convert it to a ColorImage,
a DepthImage, and an IrImage.
Parameters
----------
skip_registration : bool
If True, the registration step is skipped.
Returns
-------
:obj:... | python | def frames(self):
"""Retrieve the next frame from the tensor dataset and convert it to a ColorImage,
a DepthImage, and an IrImage.
Parameters
----------
skip_registration : bool
If True, the registration step is skipped.
Returns
-------
:obj:... | Retrieve the next frame from the tensor dataset and convert it to a ColorImage,
a DepthImage, and an IrImage.
Parameters
----------
skip_registration : bool
If True, the registration step is skipped.
Returns
-------
:obj:`tuple` of :obj:`ColorImage`,... | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/camera_sensor.py#L275-L312 |
BerkeleyAutomation/perception | perception/primesense_sensor.py | PrimesenseSensor.color_intrinsics | def color_intrinsics(self):
""":obj:`CameraIntrinsics` : The camera intrinsics for the primesense color camera.
"""
return CameraIntrinsics(self._ir_frame, PrimesenseSensor.FOCAL_X, PrimesenseSensor.FOCAL_Y,
PrimesenseSensor.CENTER_X, PrimesenseSensor.CENTER_Y,
... | python | def color_intrinsics(self):
""":obj:`CameraIntrinsics` : The camera intrinsics for the primesense color camera.
"""
return CameraIntrinsics(self._ir_frame, PrimesenseSensor.FOCAL_X, PrimesenseSensor.FOCAL_Y,
PrimesenseSensor.CENTER_X, PrimesenseSensor.CENTER_Y,
... | :obj:`CameraIntrinsics` : The camera intrinsics for the primesense color camera. | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/primesense_sensor.py#L67-L73 |
BerkeleyAutomation/perception | perception/primesense_sensor.py | PrimesenseSensor.start | def start(self):
""" Start the sensor """
# open device
openni2.initialize(PrimesenseSensor.OPENNI2_PATH)
self._device = openni2.Device.open_any()
# open depth stream
self._depth_stream = self._device.create_depth_stream()
self._depth_stream.configure_mode(Primes... | python | def start(self):
""" Start the sensor """
# open device
openni2.initialize(PrimesenseSensor.OPENNI2_PATH)
self._device = openni2.Device.open_any()
# open depth stream
self._depth_stream = self._device.create_depth_stream()
self._depth_stream.configure_mode(Primes... | Start the sensor | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/primesense_sensor.py#L108-L140 |
BerkeleyAutomation/perception | perception/primesense_sensor.py | PrimesenseSensor.stop | def stop(self):
""" Stop the sensor """
# check that everything is running
if not self._running or self._device is None:
logging.warning('Primesense not running. Aborting stop')
return False
# stop streams
if self._depth_stream:
self._depth_st... | python | def stop(self):
""" Stop the sensor """
# check that everything is running
if not self._running or self._device is None:
logging.warning('Primesense not running. Aborting stop')
return False
# stop streams
if self._depth_stream:
self._depth_st... | Stop the sensor | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/primesense_sensor.py#L142-L158 |
BerkeleyAutomation/perception | perception/primesense_sensor.py | PrimesenseSensor._read_depth_image | def _read_depth_image(self):
""" Reads a depth image from the device """
# read raw uint16 buffer
im_arr = self._depth_stream.read_frame()
raw_buf = im_arr.get_buffer_as_uint16()
buf_array = np.array([raw_buf[i] for i in range(PrimesenseSensor.DEPTH_IM_WIDTH * PrimesenseSensor.DE... | python | def _read_depth_image(self):
""" Reads a depth image from the device """
# read raw uint16 buffer
im_arr = self._depth_stream.read_frame()
raw_buf = im_arr.get_buffer_as_uint16()
buf_array = np.array([raw_buf[i] for i in range(PrimesenseSensor.DEPTH_IM_WIDTH * PrimesenseSensor.DE... | Reads a depth image from the device | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/primesense_sensor.py#L160-L175 |
BerkeleyAutomation/perception | perception/primesense_sensor.py | PrimesenseSensor._read_color_image | def _read_color_image(self):
""" Reads a color image from the device """
# read raw buffer
im_arr = self._color_stream.read_frame()
raw_buf = im_arr.get_buffer_as_triplet()
r_array = np.array([raw_buf[i][0] for i in range(PrimesenseSensor.COLOR_IM_WIDTH * PrimesenseSensor.COLOR_I... | python | def _read_color_image(self):
""" Reads a color image from the device """
# read raw buffer
im_arr = self._color_stream.read_frame()
raw_buf = im_arr.get_buffer_as_triplet()
r_array = np.array([raw_buf[i][0] for i in range(PrimesenseSensor.COLOR_IM_WIDTH * PrimesenseSensor.COLOR_I... | Reads a color image from the device | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/primesense_sensor.py#L177-L198 |
BerkeleyAutomation/perception | perception/primesense_sensor.py | PrimesenseSensor.frames | def frames(self):
"""Retrieve a new frame from the Kinect and convert it to a ColorImage,
a DepthImage, and an IrImage.
Returns
-------
:obj:`tuple` of :obj:`ColorImage`, :obj:`DepthImage`, :obj:`IrImage`, :obj:`numpy.ndarray`
The ColorImage, DepthImage, and IrImage ... | python | def frames(self):
"""Retrieve a new frame from the Kinect and convert it to a ColorImage,
a DepthImage, and an IrImage.
Returns
-------
:obj:`tuple` of :obj:`ColorImage`, :obj:`DepthImage`, :obj:`IrImage`, :obj:`numpy.ndarray`
The ColorImage, DepthImage, and IrImage ... | Retrieve a new frame from the Kinect and convert it to a ColorImage,
a DepthImage, and an IrImage.
Returns
-------
:obj:`tuple` of :obj:`ColorImage`, :obj:`DepthImage`, :obj:`IrImage`, :obj:`numpy.ndarray`
The ColorImage, DepthImage, and IrImage of the current frame.
... | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/primesense_sensor.py#L200-L216 |
BerkeleyAutomation/perception | perception/primesense_sensor.py | PrimesenseSensor.min_depth_img | def min_depth_img(self, num_img=1):
"""Collect a series of depth images and return the min of the set.
Parameters
----------
num_img : int
The number of consecutive frames to process.
Returns
-------
:obj:`DepthImage`
The min DepthImage c... | python | def min_depth_img(self, num_img=1):
"""Collect a series of depth images and return the min of the set.
Parameters
----------
num_img : int
The number of consecutive frames to process.
Returns
-------
:obj:`DepthImage`
The min DepthImage c... | Collect a series of depth images and return the min of the set.
Parameters
----------
num_img : int
The number of consecutive frames to process.
Returns
-------
:obj:`DepthImage`
The min DepthImage collected from the frames. | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/primesense_sensor.py#L241-L260 |
BerkeleyAutomation/perception | perception/primesense_sensor.py | PrimesenseSensor_ROS._ros_read_images | def _ros_read_images(self, stream_buffer, number, staleness_limit = 10.):
""" Reads images from a stream buffer
Parameters
----------
stream_buffer : string
absolute path to the image buffer service
number : int
The number of frames to get. Must b... | python | def _ros_read_images(self, stream_buffer, number, staleness_limit = 10.):
""" Reads images from a stream buffer
Parameters
----------
stream_buffer : string
absolute path to the image buffer service
number : int
The number of frames to get. Must b... | Reads images from a stream buffer
Parameters
----------
stream_buffer : string
absolute path to the image buffer service
number : int
The number of frames to get. Must be less than the image buffer service's
current buffer size
stalene... | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/primesense_sensor.py#L312-L346 |
BerkeleyAutomation/perception | perception/primesense_sensor.py | PrimesenseSensor_ROS._read_depth_images | def _read_depth_images(self, num_images):
""" Reads depth images from the device """
depth_images = self._ros_read_images(self._depth_image_buffer, num_images, self.staleness_limit)
for i in range(0, num_images):
depth_images[i] = depth_images[i] * MM_TO_METERS # convert to meters
... | python | def _read_depth_images(self, num_images):
""" Reads depth images from the device """
depth_images = self._ros_read_images(self._depth_image_buffer, num_images, self.staleness_limit)
for i in range(0, num_images):
depth_images[i] = depth_images[i] * MM_TO_METERS # convert to meters
... | Reads depth images from the device | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/primesense_sensor.py#L360-L369 |
BerkeleyAutomation/perception | perception/primesense_sensor.py | PrimesenseSensor_ROS._read_color_images | def _read_color_images(self, num_images):
""" Reads color images from the device """
color_images = self._ros_read_images(self._color_image_buffer, num_images, self.staleness_limit)
for i in range(0, num_images):
if self._flip_images:
color_images[i] = np.flipud(color... | python | def _read_color_images(self, num_images):
""" Reads color images from the device """
color_images = self._ros_read_images(self._color_image_buffer, num_images, self.staleness_limit)
for i in range(0, num_images):
if self._flip_images:
color_images[i] = np.flipud(color... | Reads color images from the device | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/primesense_sensor.py#L370-L378 |
BerkeleyAutomation/perception | perception/primesense_sensor.py | PrimesenseSensor_ROS.median_depth_img | def median_depth_img(self, num_img=1, fill_depth=0.0):
"""Collect a series of depth images and return the median of the set.
Parameters
----------
num_img : int
The number of consecutive frames to process.
Returns
-------
:obj:`DepthImage`
... | python | def median_depth_img(self, num_img=1, fill_depth=0.0):
"""Collect a series of depth images and return the median of the set.
Parameters
----------
num_img : int
The number of consecutive frames to process.
Returns
-------
:obj:`DepthImage`
... | Collect a series of depth images and return the median of the set.
Parameters
----------
num_img : int
The number of consecutive frames to process.
Returns
-------
:obj:`DepthImage`
The median DepthImage collected from the frames. | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/primesense_sensor.py#L387-L404 |
BerkeleyAutomation/perception | perception/primesense_sensor.py | PrimesenseSensor_ROS.min_depth_img | def min_depth_img(self, num_img=1):
"""Collect a series of depth images and return the min of the set.
Parameters
----------
num_img : int
The number of consecutive frames to process.
Returns
-------
:obj:`DepthImage`
The min DepthImage c... | python | def min_depth_img(self, num_img=1):
"""Collect a series of depth images and return the min of the set.
Parameters
----------
num_img : int
The number of consecutive frames to process.
Returns
-------
:obj:`DepthImage`
The min DepthImage c... | Collect a series of depth images and return the min of the set.
Parameters
----------
num_img : int
The number of consecutive frames to process.
Returns
-------
:obj:`DepthImage`
The min DepthImage collected from the frames. | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/primesense_sensor.py#L406-L421 |
BerkeleyAutomation/perception | perception/object_render.py | ObjectRender.T_obj_camera | def T_obj_camera(self):
"""Returns the transformation from camera to object when the object is in the given stable pose.
Returns
-------
:obj:`autolab_core.RigidTransform`
The desired transform.
"""
if self.stable_pose is None:
T_obj_world = Rigid... | python | def T_obj_camera(self):
"""Returns the transformation from camera to object when the object is in the given stable pose.
Returns
-------
:obj:`autolab_core.RigidTransform`
The desired transform.
"""
if self.stable_pose is None:
T_obj_world = Rigid... | Returns the transformation from camera to object when the object is in the given stable pose.
Returns
-------
:obj:`autolab_core.RigidTransform`
The desired transform. | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/object_render.py#L56-L69 |
BerkeleyAutomation/perception | perception/object_render.py | QueryImageBundle.image | def image(self, render_mode):
"""Return an image generated with a particular render mode.
Parameters
----------
render_mode : :obj:`RenderMode`
The type of image we want.
Returns
-------
:obj:`Image`
The color, depth, or binary image if r... | python | def image(self, render_mode):
"""Return an image generated with a particular render mode.
Parameters
----------
render_mode : :obj:`RenderMode`
The type of image we want.
Returns
-------
:obj:`Image`
The color, depth, or binary image if r... | Return an image generated with a particular render mode.
Parameters
----------
render_mode : :obj:`RenderMode`
The type of image we want.
Returns
-------
:obj:`Image`
The color, depth, or binary image if render_mode is
COLOR, DEPTH, o... | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/object_render.py#L110-L131 |
BerkeleyAutomation/perception | perception/chessboard_registration.py | CameraChessboardRegistration.register | def register(sensor, config):
"""
Registers a camera to a chessboard.
Parameters
----------
sensor : :obj:`perception.RgbdSensor`
the sensor to register
config : :obj:`autolab_core.YamlConfig` or :obj:`dict`
configuration file for registration
... | python | def register(sensor, config):
"""
Registers a camera to a chessboard.
Parameters
----------
sensor : :obj:`perception.RgbdSensor`
the sensor to register
config : :obj:`autolab_core.YamlConfig` or :obj:`dict`
configuration file for registration
... | Registers a camera to a chessboard.
Parameters
----------
sensor : :obj:`perception.RgbdSensor`
the sensor to register
config : :obj:`autolab_core.YamlConfig` or :obj:`dict`
configuration file for registration
Returns
-------
:obj:`Chessb... | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/chessboard_registration.py#L35-L228 |
BerkeleyAutomation/perception | perception/features.py | BagOfFeatures.add | def add(self, feature):
""" Add a new feature to the bag.
Parameters
----------
feature : :obj:`Feature`
feature to add
"""
self.features_.append(feature)
self.num_features_ = len(self.features_) | python | def add(self, feature):
""" Add a new feature to the bag.
Parameters
----------
feature : :obj:`Feature`
feature to add
"""
self.features_.append(feature)
self.num_features_ = len(self.features_) | Add a new feature to the bag.
Parameters
----------
feature : :obj:`Feature`
feature to add | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/features.py#L109-L118 |
BerkeleyAutomation/perception | perception/features.py | BagOfFeatures.extend | def extend(self, features):
""" Add a list of features to the bag.
Parameters
----------
feature : :obj:`list` of :obj:`Feature`
features to add
"""
self.features_.extend(features)
self.num_features_ = len(self.features_) | python | def extend(self, features):
""" Add a list of features to the bag.
Parameters
----------
feature : :obj:`list` of :obj:`Feature`
features to add
"""
self.features_.extend(features)
self.num_features_ = len(self.features_) | Add a list of features to the bag.
Parameters
----------
feature : :obj:`list` of :obj:`Feature`
features to add | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/features.py#L120-L129 |
BerkeleyAutomation/perception | perception/features.py | BagOfFeatures.feature | def feature(self, index):
""" Returns a feature.
Parameters
----------
index : int
index of feature in list
Returns
-------
:obj:`Feature`
"""
if index < 0 or index >= self.num_features_:
raise ValueError('Index %d out of ... | python | def feature(self, index):
""" Returns a feature.
Parameters
----------
index : int
index of feature in list
Returns
-------
:obj:`Feature`
"""
if index < 0 or index >= self.num_features_:
raise ValueError('Index %d out of ... | Returns a feature.
Parameters
----------
index : int
index of feature in list
Returns
-------
:obj:`Feature` | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/features.py#L131-L145 |
BerkeleyAutomation/perception | perception/features.py | BagOfFeatures.feature_subset | def feature_subset(self, indices):
""" Returns some subset of the features.
Parameters
----------
indices : :obj:`list` of :obj:`int`
indices of the features in the list
Returns
-------
:obj:`list` of :obj:`Feature`
"""
if isi... | python | def feature_subset(self, indices):
""" Returns some subset of the features.
Parameters
----------
indices : :obj:`list` of :obj:`int`
indices of the features in the list
Returns
-------
:obj:`list` of :obj:`Feature`
"""
if isi... | Returns some subset of the features.
Parameters
----------
indices : :obj:`list` of :obj:`int`
indices of the features in the list
Returns
-------
:obj:`list` of :obj:`Feature` | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/features.py#L147-L163 |
BerkeleyAutomation/perception | perception/weight_sensor.py | WeightSensor.start | def start(self):
"""Start the sensor.
"""
if rospy.get_name() == '/unnamed':
raise ValueError('Weight sensor must be run inside a ros node!')
self._weight_subscriber = rospy.Subscriber('weight_sensor/weights', Float32MultiArray, self._weights_callback)
self._running =... | python | def start(self):
"""Start the sensor.
"""
if rospy.get_name() == '/unnamed':
raise ValueError('Weight sensor must be run inside a ros node!')
self._weight_subscriber = rospy.Subscriber('weight_sensor/weights', Float32MultiArray, self._weights_callback)
self._running =... | Start the sensor. | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/weight_sensor.py#L35-L41 |
BerkeleyAutomation/perception | perception/weight_sensor.py | WeightSensor.stop | def stop(self):
"""Stop the sensor.
"""
if not self._running:
return
self._weight_subscriber.unregister()
self._running = False | python | def stop(self):
"""Stop the sensor.
"""
if not self._running:
return
self._weight_subscriber.unregister()
self._running = False | Stop the sensor. | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/weight_sensor.py#L44-L50 |
BerkeleyAutomation/perception | perception/weight_sensor.py | WeightSensor.total_weight | def total_weight(self):
"""Read a weight from the sensor in grams.
Returns
-------
weight : float
The sensor weight in grams.
"""
weights = self._raw_weights()
if weights.shape[1] == 0:
return 0.0
elif weights.shape[1] < self._ntap... | python | def total_weight(self):
"""Read a weight from the sensor in grams.
Returns
-------
weight : float
The sensor weight in grams.
"""
weights = self._raw_weights()
if weights.shape[1] == 0:
return 0.0
elif weights.shape[1] < self._ntap... | Read a weight from the sensor in grams.
Returns
-------
weight : float
The sensor weight in grams. | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/weight_sensor.py#L53-L67 |
BerkeleyAutomation/perception | perception/weight_sensor.py | WeightSensor.individual_weights | def individual_weights(self):
"""Read individual weights from the load cells in grams.
Returns
-------
weight : float
The sensor weight in grams.
"""
weights = self._raw_weights()
if weights.shape[1] == 0:
return np.zeros(weights.shape[0])... | python | def individual_weights(self):
"""Read individual weights from the load cells in grams.
Returns
-------
weight : float
The sensor weight in grams.
"""
weights = self._raw_weights()
if weights.shape[1] == 0:
return np.zeros(weights.shape[0])... | Read individual weights from the load cells in grams.
Returns
-------
weight : float
The sensor weight in grams. | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/weight_sensor.py#L69-L83 |
BerkeleyAutomation/perception | perception/weight_sensor.py | WeightSensor._raw_weights | def _raw_weights(self):
"""Create a numpy array containing the raw sensor weights.
"""
if self._debug:
return np.array([[],[],[],[]])
if not self._running:
raise ValueError('Weight sensor is not running!')
if len(self._weight_buffers) == 0:
ti... | python | def _raw_weights(self):
"""Create a numpy array containing the raw sensor weights.
"""
if self._debug:
return np.array([[],[],[],[]])
if not self._running:
raise ValueError('Weight sensor is not running!')
if len(self._weight_buffers) == 0:
ti... | Create a numpy array containing the raw sensor weights. | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/weight_sensor.py#L92-L105 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.