repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
twisted/mantissa
xmantissa/webapp.py
PrivateApplication._getUsername
def _getUsername(self): """ Return a localpart@domain style string naming the owner of our store. @rtype: C{unicode} """ for (l, d) in getAccountNames(self.store): return l + u'@' + d
python
def _getUsername(self): """ Return a localpart@domain style string naming the owner of our store. @rtype: C{unicode} """ for (l, d) in getAccountNames(self.store): return l + u'@' + d
[ "def", "_getUsername", "(", "self", ")", ":", "for", "(", "l", ",", "d", ")", "in", "getAccountNames", "(", "self", ".", "store", ")", ":", "return", "l", "+", "u'@'", "+", "d" ]
Return a localpart@domain style string naming the owner of our store. @rtype: C{unicode}
[ "Return", "a", "localpart@domain", "style", "string", "naming", "the", "owner", "of", "our", "store", "." ]
train
https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/webapp.py#L523-L530
twisted/mantissa
xmantissa/webapp.py
PrivateApplication.linkToWithActiveTab
def linkToWithActiveTab(self, childItem, parentItem): """ Return a URL which will point to the web facet of C{childItem}, with the selected nav tab being the one that represents C{parentItem} """ return self.linkTo(parentItem.storeID) + '/' + self.toWebID(childItem)
python
def linkToWithActiveTab(self, childItem, parentItem): """ Return a URL which will point to the web facet of C{childItem}, with the selected nav tab being the one that represents C{parentItem} """ return self.linkTo(parentItem.storeID) + '/' + self.toWebID(childItem)
[ "def", "linkToWithActiveTab", "(", "self", ",", "childItem", ",", "parentItem", ")", ":", "return", "self", ".", "linkTo", "(", "parentItem", ".", "storeID", ")", "+", "'/'", "+", "self", ".", "toWebID", "(", "childItem", ")" ]
Return a URL which will point to the web facet of C{childItem}, with the selected nav tab being the one that represents C{parentItem}
[ "Return", "a", "URL", "which", "will", "point", "to", "the", "web", "facet", "of", "C", "{", "childItem", "}", "with", "the", "selected", "nav", "tab", "being", "the", "one", "that", "represents", "C", "{", "parentItem", "}" ]
train
https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/webapp.py#L552-L557
twisted/mantissa
xmantissa/webapp.py
PrivateApplication._preferredThemes
def _preferredThemes(self): """ Return a list of themes in the order of preference that this user has selected via L{PrivateApplication.preferredTheme}. """ themes = getInstalledThemes(self.store.parent) _reorderForPreference(themes, self.preferredTheme) return themes
python
def _preferredThemes(self): """ Return a list of themes in the order of preference that this user has selected via L{PrivateApplication.preferredTheme}. """ themes = getInstalledThemes(self.store.parent) _reorderForPreference(themes, self.preferredTheme) return themes
[ "def", "_preferredThemes", "(", "self", ")", ":", "themes", "=", "getInstalledThemes", "(", "self", ".", "store", ".", "parent", ")", "_reorderForPreference", "(", "themes", ",", "self", ".", "preferredTheme", ")", "return", "themes" ]
Return a list of themes in the order of preference that this user has selected via L{PrivateApplication.preferredTheme}.
[ "Return", "a", "list", "of", "themes", "in", "the", "order", "of", "preference", "that", "this", "user", "has", "selected", "via", "L", "{", "PrivateApplication", ".", "preferredTheme", "}", "." ]
train
https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/webapp.py#L577-L584
twisted/mantissa
xmantissa/webapp.py
PrivateApplication.getDocFactory
def getDocFactory(self, fragmentName, default=None): """ Retrieve a Nevow document factory for the given name. @param fragmentName: a short string that names a fragment template. @param default: value to be returned if the named template is not found. """ themes = self._preferredThemes() for t in themes: fact = t.getDocFactory(fragmentName, None) if fact is not None: return fact return default
python
def getDocFactory(self, fragmentName, default=None): """ Retrieve a Nevow document factory for the given name. @param fragmentName: a short string that names a fragment template. @param default: value to be returned if the named template is not found. """ themes = self._preferredThemes() for t in themes: fact = t.getDocFactory(fragmentName, None) if fact is not None: return fact return default
[ "def", "getDocFactory", "(", "self", ",", "fragmentName", ",", "default", "=", "None", ")", ":", "themes", "=", "self", ".", "_preferredThemes", "(", ")", "for", "t", "in", "themes", ":", "fact", "=", "t", ".", "getDocFactory", "(", "fragmentName", ",", ...
Retrieve a Nevow document factory for the given name. @param fragmentName: a short string that names a fragment template. @param default: value to be returned if the named template is not found.
[ "Retrieve", "a", "Nevow", "document", "factory", "for", "the", "given", "name", "." ]
train
https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/webapp.py#L588-L602
jwodder/doapi
doapi/domain.py
Domain.fetch
def fetch(self): """ Fetch & return a new `Domain` object representing the domain's current state :rtype: Domain :raises DOAPIError: if the API endpoint replies with an error (e.g., if the domain no longer exists) """ api = self.doapi_manager return api._domain(api.request(self.url)["domain"])
python
def fetch(self): """ Fetch & return a new `Domain` object representing the domain's current state :rtype: Domain :raises DOAPIError: if the API endpoint replies with an error (e.g., if the domain no longer exists) """ api = self.doapi_manager return api._domain(api.request(self.url)["domain"])
[ "def", "fetch", "(", "self", ")", ":", "api", "=", "self", ".", "doapi_manager", "return", "api", ".", "_domain", "(", "api", ".", "request", "(", "self", ".", "url", ")", "[", "\"domain\"", "]", ")" ]
Fetch & return a new `Domain` object representing the domain's current state :rtype: Domain :raises DOAPIError: if the API endpoint replies with an error (e.g., if the domain no longer exists)
[ "Fetch", "&", "return", "a", "new", "Domain", "object", "representing", "the", "domain", "s", "current", "state" ]
train
https://github.com/jwodder/doapi/blob/b1306de86a01d8ae7b9c1fe2699765bb82e4f310/doapi/domain.py#L40-L50
jwodder/doapi
doapi/domain.py
Domain._record
def _record(self, obj): """ Construct a `DomainRecord` object belonging to the domain's `doapi` object. ``obj`` may be a domain record ID, a dictionary of domain record fields, or another `DomainRecord` object (which will be shallow-copied). The resulting `DomainRecord` will only contain the information in ``obj``; no data will be sent to or from the API endpoint. :type obj: integer, `dict`, or `DomainRecord` :rtype: DomainRecord """ return DomainRecord(obj, domain=self, doapi_manager=self.doapi_manager)
python
def _record(self, obj): """ Construct a `DomainRecord` object belonging to the domain's `doapi` object. ``obj`` may be a domain record ID, a dictionary of domain record fields, or another `DomainRecord` object (which will be shallow-copied). The resulting `DomainRecord` will only contain the information in ``obj``; no data will be sent to or from the API endpoint. :type obj: integer, `dict`, or `DomainRecord` :rtype: DomainRecord """ return DomainRecord(obj, domain=self, doapi_manager=self.doapi_manager)
[ "def", "_record", "(", "self", ",", "obj", ")", ":", "return", "DomainRecord", "(", "obj", ",", "domain", "=", "self", ",", "doapi_manager", "=", "self", ".", "doapi_manager", ")" ]
Construct a `DomainRecord` object belonging to the domain's `doapi` object. ``obj`` may be a domain record ID, a dictionary of domain record fields, or another `DomainRecord` object (which will be shallow-copied). The resulting `DomainRecord` will only contain the information in ``obj``; no data will be sent to or from the API endpoint. :type obj: integer, `dict`, or `DomainRecord` :rtype: DomainRecord
[ "Construct", "a", "DomainRecord", "object", "belonging", "to", "the", "domain", "s", "doapi", "object", ".", "obj", "may", "be", "a", "domain", "record", "ID", "a", "dictionary", "of", "domain", "record", "fields", "or", "another", "DomainRecord", "object", ...
train
https://github.com/jwodder/doapi/blob/b1306de86a01d8ae7b9c1fe2699765bb82e4f310/doapi/domain.py#L61-L73
jwodder/doapi
doapi/domain.py
Domain.fetch_all_records
def fetch_all_records(self): r""" Returns a generator that yields all of the DNS records for the domain :rtype: generator of `DomainRecord`\ s :raises DOAPIError: if the API endpoint replies with an error """ api = self.doapi_manager return map(self._record, api.paginate(self.record_url, 'domain_records'))
python
def fetch_all_records(self): r""" Returns a generator that yields all of the DNS records for the domain :rtype: generator of `DomainRecord`\ s :raises DOAPIError: if the API endpoint replies with an error """ api = self.doapi_manager return map(self._record, api.paginate(self.record_url, 'domain_records'))
[ "def", "fetch_all_records", "(", "self", ")", ":", "api", "=", "self", ".", "doapi_manager", "return", "map", "(", "self", ".", "_record", ",", "api", ".", "paginate", "(", "self", ".", "record_url", ",", "'domain_records'", ")", ")" ]
r""" Returns a generator that yields all of the DNS records for the domain :rtype: generator of `DomainRecord`\ s :raises DOAPIError: if the API endpoint replies with an error
[ "r", "Returns", "a", "generator", "that", "yields", "all", "of", "the", "DNS", "records", "for", "the", "domain" ]
train
https://github.com/jwodder/doapi/blob/b1306de86a01d8ae7b9c1fe2699765bb82e4f310/doapi/domain.py#L92-L100
jwodder/doapi
doapi/domain.py
Domain.create_record
def create_record(self, type, name, data, priority=None, port=None, weight=None, **kwargs): # pylint: disable=redefined-builtin """ Add a new DNS record to the domain :param str type: the type of DNS record to add (``"A"``, ``"CNAME"``, etc.) :param str name: the name (hostname, alias, etc.) of the new record :param str data: the value of the new record :param int priority: the priority of the new record (SRV and MX records only) :param int port: the port that the service is accessible on (SRV records only) :param int weight: the weight of records with the same priority (SRV records only) :param kwargs: additional fields to include in the API request :return: the new domain record :rtype: DomainRecord :raises DOAPIError: if the API endpoint replies with an error """ api = self.doapi_manager data = { "type": type, "name": name, "data": data, "priority": priority, "port": port, "weight": weight, } data.update(kwargs) return self._record(api.request(self.record_url, method='POST', data=data)["domain_record"])
python
def create_record(self, type, name, data, priority=None, port=None, weight=None, **kwargs): # pylint: disable=redefined-builtin """ Add a new DNS record to the domain :param str type: the type of DNS record to add (``"A"``, ``"CNAME"``, etc.) :param str name: the name (hostname, alias, etc.) of the new record :param str data: the value of the new record :param int priority: the priority of the new record (SRV and MX records only) :param int port: the port that the service is accessible on (SRV records only) :param int weight: the weight of records with the same priority (SRV records only) :param kwargs: additional fields to include in the API request :return: the new domain record :rtype: DomainRecord :raises DOAPIError: if the API endpoint replies with an error """ api = self.doapi_manager data = { "type": type, "name": name, "data": data, "priority": priority, "port": port, "weight": weight, } data.update(kwargs) return self._record(api.request(self.record_url, method='POST', data=data)["domain_record"])
[ "def", "create_record", "(", "self", ",", "type", ",", "name", ",", "data", ",", "priority", "=", "None", ",", "port", "=", "None", ",", "weight", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# pylint: disable=redefined-builtin", "api", "=", "self", ...
Add a new DNS record to the domain :param str type: the type of DNS record to add (``"A"``, ``"CNAME"``, etc.) :param str name: the name (hostname, alias, etc.) of the new record :param str data: the value of the new record :param int priority: the priority of the new record (SRV and MX records only) :param int port: the port that the service is accessible on (SRV records only) :param int weight: the weight of records with the same priority (SRV records only) :param kwargs: additional fields to include in the API request :return: the new domain record :rtype: DomainRecord :raises DOAPIError: if the API endpoint replies with an error
[ "Add", "a", "new", "DNS", "record", "to", "the", "domain" ]
train
https://github.com/jwodder/doapi/blob/b1306de86a01d8ae7b9c1fe2699765bb82e4f310/doapi/domain.py#L102-L134
jwodder/doapi
doapi/domain.py
DomainRecord.fetch
def fetch(self): """ Fetch & return a new `DomainRecord` object representing the domain record's current state :rtype: DomainRecord :raises DOAPIError: if the API endpoint replies with an error (e.g., if the domain record no longer exists) """ return self.domain._record(self.doapi_manager.request(self.url)\ ["domain_record"])
python
def fetch(self): """ Fetch & return a new `DomainRecord` object representing the domain record's current state :rtype: DomainRecord :raises DOAPIError: if the API endpoint replies with an error (e.g., if the domain record no longer exists) """ return self.domain._record(self.doapi_manager.request(self.url)\ ["domain_record"])
[ "def", "fetch", "(", "self", ")", ":", "return", "self", ".", "domain", ".", "_record", "(", "self", ".", "doapi_manager", ".", "request", "(", "self", ".", "url", ")", "[", "\"domain_record\"", "]", ")" ]
Fetch & return a new `DomainRecord` object representing the domain record's current state :rtype: DomainRecord :raises DOAPIError: if the API endpoint replies with an error (e.g., if the domain record no longer exists)
[ "Fetch", "&", "return", "a", "new", "DomainRecord", "object", "representing", "the", "domain", "record", "s", "current", "state" ]
train
https://github.com/jwodder/doapi/blob/b1306de86a01d8ae7b9c1fe2699765bb82e4f310/doapi/domain.py#L184-L194
jwodder/doapi
doapi/domain.py
DomainRecord.update_record
def update_record(self, **attrs): # The `_record` is to avoid conflicts with MutableMapping.update. """ Update the record, modifying any number of its attributes (except ``id``). ``update_record`` takes the same keyword arguments as :meth:`Domain.create_record`; pass in only those attributes that you want to update. :return: an updated `DomainRecord` object :rtype: DomainRecord :raises DOAPIError: if the API endpoint replies with an error """ return self.domain._record(self.doapi_manager.request(self.url, method='PUT', data=attrs)\ ["domain_record"])
python
def update_record(self, **attrs): # The `_record` is to avoid conflicts with MutableMapping.update. """ Update the record, modifying any number of its attributes (except ``id``). ``update_record`` takes the same keyword arguments as :meth:`Domain.create_record`; pass in only those attributes that you want to update. :return: an updated `DomainRecord` object :rtype: DomainRecord :raises DOAPIError: if the API endpoint replies with an error """ return self.domain._record(self.doapi_manager.request(self.url, method='PUT', data=attrs)\ ["domain_record"])
[ "def", "update_record", "(", "self", ",", "*", "*", "attrs", ")", ":", "# The `_record` is to avoid conflicts with MutableMapping.update.", "return", "self", ".", "domain", ".", "_record", "(", "self", ".", "doapi_manager", ".", "request", "(", "self", ".", "url",...
Update the record, modifying any number of its attributes (except ``id``). ``update_record`` takes the same keyword arguments as :meth:`Domain.create_record`; pass in only those attributes that you want to update. :return: an updated `DomainRecord` object :rtype: DomainRecord :raises DOAPIError: if the API endpoint replies with an error
[ "Update", "the", "record", "modifying", "any", "number", "of", "its", "attributes", "(", "except", "id", ")", ".", "update_record", "takes", "the", "same", "keyword", "arguments", "as", ":", "meth", ":", "Domain", ".", "create_record", ";", "pass", "in", "...
train
https://github.com/jwodder/doapi/blob/b1306de86a01d8ae7b9c1fe2699765bb82e4f310/doapi/domain.py#L205-L220
KeplerGO/K2fov
K2fov/projection.py
Projection.isPositiveMap
def isPositiveMap(self): """Returns true if increasing ra increases pix in skyToPix() """ x0, y0 = self.skyToPix(self.ra0_deg, self.dec0_deg) x1, y1 = self.skyToPix(self.ra0_deg + 1/3600., self.dec0_deg) if x1 > x0: return True return False
python
def isPositiveMap(self): """Returns true if increasing ra increases pix in skyToPix() """ x0, y0 = self.skyToPix(self.ra0_deg, self.dec0_deg) x1, y1 = self.skyToPix(self.ra0_deg + 1/3600., self.dec0_deg) if x1 > x0: return True return False
[ "def", "isPositiveMap", "(", "self", ")", ":", "x0", ",", "y0", "=", "self", ".", "skyToPix", "(", "self", ".", "ra0_deg", ",", "self", ".", "dec0_deg", ")", "x1", ",", "y1", "=", "self", ".", "skyToPix", "(", "self", ".", "ra0_deg", "+", "1", "/...
Returns true if increasing ra increases pix in skyToPix()
[ "Returns", "true", "if", "increasing", "ra", "increases", "pix", "in", "skyToPix", "()" ]
train
https://github.com/KeplerGO/K2fov/blob/fb122b35687340e0357cba9e0dd47b3be0760693/K2fov/projection.py#L104-L112
KeplerGO/K2fov
K2fov/projection.py
Projection.plotGrid
def plotGrid(self, numLines=(5,5), lineWidth=1, colour="#777777"): """Plot NUMLINES[0] vertical gridlines and NUMLINES[1] horizontal gridlines, while keeping the initial axes bounds that were present upon its calling. Will not work for certain cases. """ x1, x2, y1, y2 = mp.axis() ra1, dec0 = self.pixToSky(x1, y1) ra0, dec1 = self.pixToSky(x2, y2) xNum, yNum = numLines self.raRange, self.decRange = self.getRaDecRanges(numLines) #import pdb; pdb.set_trace() #Guard against Ra of zero within the plot a1 = np.abs(ra1-ra0) a2 = np.abs( min(ra0, ra1) - (max(ra0, ra1) - 360)) if a2 < a1: #Then we straddle 360 degrees in RA if ra0 < ra1: ra1 -= 360 else: ra0 -= 360 #Draw lines of constant dec lwr = min(ra0, ra1) upr = max(ra0, ra1) stepX = round((upr-lwr) / float(xNum)) ra_deg = np.arange(lwr - 3*stepX, upr + 3.5*stepX, 1, dtype=np.float) for dec in self.decRange: self.plotLine(ra_deg, dec, '-', color = colour, linewidth = lineWidth) #Draw lines of const ra lwr = min(dec0, dec1) upr = max(dec0, dec1) stepY = round((upr-lwr) / float(yNum)) dec_deg = np.arange(dec0 - 3*stepY, dec1 + 3.5*stepY, 1, dtype=np.float) for ra in self.raRange: self.plotLine(ra, dec_deg, '-', color = colour, linewidth = lineWidth) mp.axis([x1, x2, y1, y2])
python
def plotGrid(self, numLines=(5,5), lineWidth=1, colour="#777777"): """Plot NUMLINES[0] vertical gridlines and NUMLINES[1] horizontal gridlines, while keeping the initial axes bounds that were present upon its calling. Will not work for certain cases. """ x1, x2, y1, y2 = mp.axis() ra1, dec0 = self.pixToSky(x1, y1) ra0, dec1 = self.pixToSky(x2, y2) xNum, yNum = numLines self.raRange, self.decRange = self.getRaDecRanges(numLines) #import pdb; pdb.set_trace() #Guard against Ra of zero within the plot a1 = np.abs(ra1-ra0) a2 = np.abs( min(ra0, ra1) - (max(ra0, ra1) - 360)) if a2 < a1: #Then we straddle 360 degrees in RA if ra0 < ra1: ra1 -= 360 else: ra0 -= 360 #Draw lines of constant dec lwr = min(ra0, ra1) upr = max(ra0, ra1) stepX = round((upr-lwr) / float(xNum)) ra_deg = np.arange(lwr - 3*stepX, upr + 3.5*stepX, 1, dtype=np.float) for dec in self.decRange: self.plotLine(ra_deg, dec, '-', color = colour, linewidth = lineWidth) #Draw lines of const ra lwr = min(dec0, dec1) upr = max(dec0, dec1) stepY = round((upr-lwr) / float(yNum)) dec_deg = np.arange(dec0 - 3*stepY, dec1 + 3.5*stepY, 1, dtype=np.float) for ra in self.raRange: self.plotLine(ra, dec_deg, '-', color = colour, linewidth = lineWidth) mp.axis([x1, x2, y1, y2])
[ "def", "plotGrid", "(", "self", ",", "numLines", "=", "(", "5", ",", "5", ")", ",", "lineWidth", "=", "1", ",", "colour", "=", "\"#777777\"", ")", ":", "x1", ",", "x2", ",", "y1", ",", "y2", "=", "mp", ".", "axis", "(", ")", "ra1", ",", "dec0...
Plot NUMLINES[0] vertical gridlines and NUMLINES[1] horizontal gridlines, while keeping the initial axes bounds that were present upon its calling. Will not work for certain cases.
[ "Plot", "NUMLINES", "[", "0", "]", "vertical", "gridlines", "and", "NUMLINES", "[", "1", "]", "horizontal", "gridlines", "while", "keeping", "the", "initial", "axes", "bounds", "that", "were", "present", "upon", "its", "calling", ".", "Will", "not", "work", ...
train
https://github.com/KeplerGO/K2fov/blob/fb122b35687340e0357cba9e0dd47b3be0760693/K2fov/projection.py#L130-L170
KeplerGO/K2fov
K2fov/projection.py
Projection.labelAxes
def labelAxes(self, numLines=(5,5)): """Put labels on axes Note: I should do better than this by picking round numbers as the places to put the labels. Note: If I ever do rotated projections, this simple approach will fail. """ x1, x2, y1, y2 = mp.axis() ra1, dec0 = self.pixToSky(x1, y1) raRange, decRange = self.getRaDecRanges(numLines) ax = mp.gca() x_ticks = self.skyToPix(raRange, dec0)[0] y_ticks = self.skyToPix(ra1, decRange)[1] ax.xaxis.set_ticks(x_ticks) ax.xaxis.set_ticklabels([str(int(i)) for i in raRange]) mp.xlabel("Right Ascension (deg)") ax.yaxis.set_ticks(y_ticks) ax.yaxis.set_ticklabels([str(int(i)) for i in decRange]) mp.ylabel("Declination (deg)")
python
def labelAxes(self, numLines=(5,5)): """Put labels on axes Note: I should do better than this by picking round numbers as the places to put the labels. Note: If I ever do rotated projections, this simple approach will fail. """ x1, x2, y1, y2 = mp.axis() ra1, dec0 = self.pixToSky(x1, y1) raRange, decRange = self.getRaDecRanges(numLines) ax = mp.gca() x_ticks = self.skyToPix(raRange, dec0)[0] y_ticks = self.skyToPix(ra1, decRange)[1] ax.xaxis.set_ticks(x_ticks) ax.xaxis.set_ticklabels([str(int(i)) for i in raRange]) mp.xlabel("Right Ascension (deg)") ax.yaxis.set_ticks(y_ticks) ax.yaxis.set_ticklabels([str(int(i)) for i in decRange]) mp.ylabel("Declination (deg)")
[ "def", "labelAxes", "(", "self", ",", "numLines", "=", "(", "5", ",", "5", ")", ")", ":", "x1", ",", "x2", ",", "y1", ",", "y2", "=", "mp", ".", "axis", "(", ")", "ra1", ",", "dec0", "=", "self", ".", "pixToSky", "(", "x1", ",", "y1", ")", ...
Put labels on axes Note: I should do better than this by picking round numbers as the places to put the labels. Note: If I ever do rotated projections, this simple approach will fail.
[ "Put", "labels", "on", "axes" ]
train
https://github.com/KeplerGO/K2fov/blob/fb122b35687340e0357cba9e0dd47b3be0760693/K2fov/projection.py#L174-L198
KeplerGO/K2fov
K2fov/projection.py
Projection.getRaDecRanges
def getRaDecRanges(self, numLines): """Pick suitable values for ra and dec ticks Used by plotGrid and labelAxes """ x1, x2, y1, y2 = mp.axis() ra0, dec0 = self.pixToSky(x1, y1) ra1, dec1 = self.pixToSky(x2, y2) #Deal with the case where ra range straddles 0. #Different code for case where ra increases left to right, or decreases. if self.isPositiveMap(): if ra1 < ra0: ra1 += 360 else: if ra0 < ra1: ra0 += 360 raMid = .5*(ra0+ra1) decMid = .5*(dec0+dec1) xNum, yNum = numLines stepX = round((ra1 - ra0) / xNum) stepY = round((dec1 - dec0) / yNum) rangeX = stepX * (xNum - 1) rangeY = stepY * (yNum - 1) raStart = np.round(raMid - rangeX/2.) decStart = np.round(decMid - rangeY/2.) raRange = np.arange(raStart, raStart + stepX*xNum, stepX) decRange = np.arange(decStart, decStart + stepY*yNum, stepY) raRange = np.fmod(raRange, 360.) return raRange, decRange
python
def getRaDecRanges(self, numLines): """Pick suitable values for ra and dec ticks Used by plotGrid and labelAxes """ x1, x2, y1, y2 = mp.axis() ra0, dec0 = self.pixToSky(x1, y1) ra1, dec1 = self.pixToSky(x2, y2) #Deal with the case where ra range straddles 0. #Different code for case where ra increases left to right, or decreases. if self.isPositiveMap(): if ra1 < ra0: ra1 += 360 else: if ra0 < ra1: ra0 += 360 raMid = .5*(ra0+ra1) decMid = .5*(dec0+dec1) xNum, yNum = numLines stepX = round((ra1 - ra0) / xNum) stepY = round((dec1 - dec0) / yNum) rangeX = stepX * (xNum - 1) rangeY = stepY * (yNum - 1) raStart = np.round(raMid - rangeX/2.) decStart = np.round(decMid - rangeY/2.) raRange = np.arange(raStart, raStart + stepX*xNum, stepX) decRange = np.arange(decStart, decStart + stepY*yNum, stepY) raRange = np.fmod(raRange, 360.) return raRange, decRange
[ "def", "getRaDecRanges", "(", "self", ",", "numLines", ")", ":", "x1", ",", "x2", ",", "y1", ",", "y2", "=", "mp", ".", "axis", "(", ")", "ra0", ",", "dec0", "=", "self", ".", "pixToSky", "(", "x1", ",", "y1", ")", "ra1", ",", "dec1", "=", "s...
Pick suitable values for ra and dec ticks Used by plotGrid and labelAxes
[ "Pick", "suitable", "values", "for", "ra", "and", "dec", "ticks" ]
train
https://github.com/KeplerGO/K2fov/blob/fb122b35687340e0357cba9e0dd47b3be0760693/K2fov/projection.py#L201-L238
xav-b/pyconsul
pyconsul/http.py
KVStorage.get
def get(self, key, **kwargs): ''' Fetch value at the given key kwargs can hold `recurse`, `wait` and `index` params ''' return self._get('/'.join([self._endpoint, key]), payload=kwargs)
python
def get(self, key, **kwargs): ''' Fetch value at the given key kwargs can hold `recurse`, `wait` and `index` params ''' return self._get('/'.join([self._endpoint, key]), payload=kwargs)
[ "def", "get", "(", "self", ",", "key", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_get", "(", "'/'", ".", "join", "(", "[", "self", ".", "_endpoint", ",", "key", "]", ")", ",", "payload", "=", "kwargs", ")" ]
Fetch value at the given key kwargs can hold `recurse`, `wait` and `index` params
[ "Fetch", "value", "at", "the", "given", "key", "kwargs", "can", "hold", "recurse", "wait", "and", "index", "params" ]
train
https://github.com/xav-b/pyconsul/blob/06ce3b921d01010c19643424486bea4b22196076/pyconsul/http.py#L27-L32
xav-b/pyconsul
pyconsul/http.py
KVStorage.set
def set(self, key, value, **kwargs): ''' Store a new value at the given key kwargs can hold `cas` and `flags` params ''' return requests.put( '{}/{}/kv/{}'.format( self.master, pyconsul.__consul_api_version__, key), data=value, params=kwargs )
python
def set(self, key, value, **kwargs): ''' Store a new value at the given key kwargs can hold `cas` and `flags` params ''' return requests.put( '{}/{}/kv/{}'.format( self.master, pyconsul.__consul_api_version__, key), data=value, params=kwargs )
[ "def", "set", "(", "self", ",", "key", ",", "value", ",", "*", "*", "kwargs", ")", ":", "return", "requests", ".", "put", "(", "'{}/{}/kv/{}'", ".", "format", "(", "self", ".", "master", ",", "pyconsul", ".", "__consul_api_version__", ",", "key", ")", ...
Store a new value at the given key kwargs can hold `cas` and `flags` params
[ "Store", "a", "new", "value", "at", "the", "given", "key", "kwargs", "can", "hold", "cas", "and", "flags", "params" ]
train
https://github.com/xav-b/pyconsul/blob/06ce3b921d01010c19643424486bea4b22196076/pyconsul/http.py#L35-L45
xav-b/pyconsul
pyconsul/http.py
Consul.health
def health(self, **kwargs): ''' Support `node`, `service`, `check`, `state` ''' if not len(kwargs): raise ValueError('no resource provided') for resource, name in kwargs.iteritems(): endpoint = 'health/{}/{}'.format(resource, name) return self._get(endpoint)
python
def health(self, **kwargs): ''' Support `node`, `service`, `check`, `state` ''' if not len(kwargs): raise ValueError('no resource provided') for resource, name in kwargs.iteritems(): endpoint = 'health/{}/{}'.format(resource, name) return self._get(endpoint)
[ "def", "health", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "not", "len", "(", "kwargs", ")", ":", "raise", "ValueError", "(", "'no resource provided'", ")", "for", "resource", ",", "name", "in", "kwargs", ".", "iteritems", "(", ")", ":", ...
Support `node`, `service`, `check`, `state`
[ "Support", "node", "service", "check", "state" ]
train
https://github.com/xav-b/pyconsul/blob/06ce3b921d01010c19643424486bea4b22196076/pyconsul/http.py#L124-L132
truemped/tornadotools
tornadotools/route.py
Route.routes
def routes(cls, application=None): """ Method for adding the routes to the `tornado.web.Application`. """ if application: for route in cls._routes: application.add_handlers(route['host'], route['spec']) else: return [route['spec'] for route in cls._routes]
python
def routes(cls, application=None): """ Method for adding the routes to the `tornado.web.Application`. """ if application: for route in cls._routes: application.add_handlers(route['host'], route['spec']) else: return [route['spec'] for route in cls._routes]
[ "def", "routes", "(", "cls", ",", "application", "=", "None", ")", ":", "if", "application", ":", "for", "route", "in", "cls", ".", "_routes", ":", "application", ".", "add_handlers", "(", "route", "[", "'host'", "]", ",", "route", "[", "'spec'", "]", ...
Method for adding the routes to the `tornado.web.Application`.
[ "Method", "for", "adding", "the", "routes", "to", "the", "tornado", ".", "web", ".", "Application", "." ]
train
https://github.com/truemped/tornadotools/blob/d22632b83810afc353fa886fbc9e265bee78653f/tornadotools/route.py#L88-L96
twisted/mantissa
xmantissa/_webidgen.py
webIDToStoreID
def webIDToStoreID(key, webid): """ Takes a webid (a 16-character str suitable for including in URLs) and a key (an int, a private key for decoding it) and produces a storeID. """ if len(webid) != 16: return None try: int(webid, 16) except TypeError: return None except ValueError: return None l = list(webid) for nybbleid in range(7, -1, -1): a, b = _swapat(key, nybbleid) _swap(l, b, a) i = int(''.join(l), 16) return i ^ key
python
def webIDToStoreID(key, webid): """ Takes a webid (a 16-character str suitable for including in URLs) and a key (an int, a private key for decoding it) and produces a storeID. """ if len(webid) != 16: return None try: int(webid, 16) except TypeError: return None except ValueError: return None l = list(webid) for nybbleid in range(7, -1, -1): a, b = _swapat(key, nybbleid) _swap(l, b, a) i = int(''.join(l), 16) return i ^ key
[ "def", "webIDToStoreID", "(", "key", ",", "webid", ")", ":", "if", "len", "(", "webid", ")", "!=", "16", ":", "return", "None", "try", ":", "int", "(", "webid", ",", "16", ")", "except", "TypeError", ":", "return", "None", "except", "ValueError", ":"...
Takes a webid (a 16-character str suitable for including in URLs) and a key (an int, a private key for decoding it) and produces a storeID.
[ "Takes", "a", "webid", "(", "a", "16", "-", "character", "str", "suitable", "for", "including", "in", "URLs", ")", "and", "a", "key", "(", "an", "int", "a", "private", "key", "for", "decoding", "it", ")", "and", "produces", "a", "storeID", "." ]
train
https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/_webidgen.py#L18-L36
twisted/mantissa
xmantissa/_webidgen.py
storeIDToWebID
def storeIDToWebID(key, storeid): """ Takes a key (int) and storeid (int) and produces a webid (a 16-character str suitable for including in URLs) """ i = key ^ storeid l = list('%0.16x' % (i,)) for nybbleid in range(0, 8): a, b = _swapat(key, nybbleid) _swap(l, a, b) return ''.join(l)
python
def storeIDToWebID(key, storeid): """ Takes a key (int) and storeid (int) and produces a webid (a 16-character str suitable for including in URLs) """ i = key ^ storeid l = list('%0.16x' % (i,)) for nybbleid in range(0, 8): a, b = _swapat(key, nybbleid) _swap(l, a, b) return ''.join(l)
[ "def", "storeIDToWebID", "(", "key", ",", "storeid", ")", ":", "i", "=", "key", "^", "storeid", "l", "=", "list", "(", "'%0.16x'", "%", "(", "i", ",", ")", ")", "for", "nybbleid", "in", "range", "(", "0", ",", "8", ")", ":", "a", ",", "b", "=...
Takes a key (int) and storeid (int) and produces a webid (a 16-character str suitable for including in URLs)
[ "Takes", "a", "key", "(", "int", ")", "and", "storeid", "(", "int", ")", "and", "produces", "a", "webid", "(", "a", "16", "-", "character", "str", "suitable", "for", "including", "in", "URLs", ")" ]
train
https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/_webidgen.py#L38-L48
p3trus/slave
slave/signal_recovery/sr7230.py
SR7230.start_asweep
def start_asweep(self, start=None, stop=None, step=None): """Starts a amplitude sweep. :param start: Sets the start frequency. :param stop: Sets the target frequency. :param step: Sets the frequency step. """ if start: self.amplitude_start = start if stop: self.amplitude_stop = stop if step: self.amplitude_step = step self._write(('SWEEP', Integer), 2)
python
def start_asweep(self, start=None, stop=None, step=None): """Starts a amplitude sweep. :param start: Sets the start frequency. :param stop: Sets the target frequency. :param step: Sets the frequency step. """ if start: self.amplitude_start = start if stop: self.amplitude_stop = stop if step: self.amplitude_step = step self._write(('SWEEP', Integer), 2)
[ "def", "start_asweep", "(", "self", ",", "start", "=", "None", ",", "stop", "=", "None", ",", "step", "=", "None", ")", ":", "if", "start", ":", "self", ".", "amplitude_start", "=", "start", "if", "stop", ":", "self", ".", "amplitude_stop", "=", "sto...
Starts a amplitude sweep. :param start: Sets the start frequency. :param stop: Sets the target frequency. :param step: Sets the frequency step.
[ "Starts", "a", "amplitude", "sweep", "." ]
train
https://github.com/p3trus/slave/blob/bdc74e73bd0f47b74a090c43aa2283c469cde3be/slave/signal_recovery/sr7230.py#L811-L825
p3trus/slave
slave/signal_recovery/sr7230.py
SR7230.start_fsweep
def start_fsweep(self, start=None, stop=None, step=None): """Starts a frequency sweep. :param start: Sets the start frequency. :param stop: Sets the target frequency. :param step: Sets the frequency step. """ if start: self.frequency_start = start if stop: self.frequency_stop = stop if step: self.frequency_step = step self._write(('SWEEP', Integer), 1)
python
def start_fsweep(self, start=None, stop=None, step=None): """Starts a frequency sweep. :param start: Sets the start frequency. :param stop: Sets the target frequency. :param step: Sets the frequency step. """ if start: self.frequency_start = start if stop: self.frequency_stop = stop if step: self.frequency_step = step self._write(('SWEEP', Integer), 1)
[ "def", "start_fsweep", "(", "self", ",", "start", "=", "None", ",", "stop", "=", "None", ",", "step", "=", "None", ")", ":", "if", "start", ":", "self", ".", "frequency_start", "=", "start", "if", "stop", ":", "self", ".", "frequency_stop", "=", "sto...
Starts a frequency sweep. :param start: Sets the start frequency. :param stop: Sets the target frequency. :param step: Sets the frequency step.
[ "Starts", "a", "frequency", "sweep", "." ]
train
https://github.com/p3trus/slave/blob/bdc74e73bd0f47b74a090c43aa2283c469cde3be/slave/signal_recovery/sr7230.py#L831-L845
p3trus/slave
slave/signal_recovery/sr7230.py
SR7230.take_data_triggered
def take_data_triggered(self, trigger, edge, stop): """Configures data acquisition to start on various trigger conditions. :param trigger: The trigger condition, either 'curve' or 'point'. ======= ======================================================= Value Description ======= ======================================================= 'curve' Each trigger signal starts a curve acquisition. 'point' A point is stored for each trigger signal. The max trigger frequency in this mode is 1 kHz. ======= ======================================================= :param edge: Defines wether a 'rising' or 'falling' edge is interpreted as a trigger signal. :param stop: The stop condition. Valid are 'buffer', 'halt', 'rising' and 'falling'. ========= ========================================================== Value Description ========= ========================================================== 'buffer' Data acquisition stops when the number of point specified in :attr:`~.Buffer.length` is acquired. 'halt' Data acquisition stops when the halt command is issued. 'trigger' Takes data for the period of a trigger event. If edge is 'rising' then teh acquisition starts on the rising edge of the trigger signal and stops on the falling edge and vice versa ========= ========================================================== """ param = { ('curve', 'rising', 'buffer'): 0, ('point', 'rising', 'buffer'): 1, ('curve', 'falling', 'buffer'): 2, ('point', 'falling', 'buffer'): 3, ('curve', 'rising', 'halt'): 4, ('point', 'rising', 'halt'): 5, ('curve', 'falling', 'halt'): 6, ('point', 'falling', 'halt'): 7, ('curve', 'rising', 'trigger'): 8, ('curve', 'falling', 'trigger'): 9, } self._write(('TDT', Integer), param[(trigger, edge, stop)])
python
def take_data_triggered(self, trigger, edge, stop): """Configures data acquisition to start on various trigger conditions. :param trigger: The trigger condition, either 'curve' or 'point'. ======= ======================================================= Value Description ======= ======================================================= 'curve' Each trigger signal starts a curve acquisition. 'point' A point is stored for each trigger signal. The max trigger frequency in this mode is 1 kHz. ======= ======================================================= :param edge: Defines wether a 'rising' or 'falling' edge is interpreted as a trigger signal. :param stop: The stop condition. Valid are 'buffer', 'halt', 'rising' and 'falling'. ========= ========================================================== Value Description ========= ========================================================== 'buffer' Data acquisition stops when the number of point specified in :attr:`~.Buffer.length` is acquired. 'halt' Data acquisition stops when the halt command is issued. 'trigger' Takes data for the period of a trigger event. If edge is 'rising' then teh acquisition starts on the rising edge of the trigger signal and stops on the falling edge and vice versa ========= ========================================================== """ param = { ('curve', 'rising', 'buffer'): 0, ('point', 'rising', 'buffer'): 1, ('curve', 'falling', 'buffer'): 2, ('point', 'falling', 'buffer'): 3, ('curve', 'rising', 'halt'): 4, ('point', 'rising', 'halt'): 5, ('curve', 'falling', 'halt'): 6, ('point', 'falling', 'halt'): 7, ('curve', 'rising', 'trigger'): 8, ('curve', 'falling', 'trigger'): 9, } self._write(('TDT', Integer), param[(trigger, edge, stop)])
[ "def", "take_data_triggered", "(", "self", ",", "trigger", ",", "edge", ",", "stop", ")", ":", "param", "=", "{", "(", "'curve'", ",", "'rising'", ",", "'buffer'", ")", ":", "0", ",", "(", "'point'", ",", "'rising'", ",", "'buffer'", ")", ":", "1", ...
Configures data acquisition to start on various trigger conditions. :param trigger: The trigger condition, either 'curve' or 'point'. ======= ======================================================= Value Description ======= ======================================================= 'curve' Each trigger signal starts a curve acquisition. 'point' A point is stored for each trigger signal. The max trigger frequency in this mode is 1 kHz. ======= ======================================================= :param edge: Defines wether a 'rising' or 'falling' edge is interpreted as a trigger signal. :param stop: The stop condition. Valid are 'buffer', 'halt', 'rising' and 'falling'. ========= ========================================================== Value Description ========= ========================================================== 'buffer' Data acquisition stops when the number of point specified in :attr:`~.Buffer.length` is acquired. 'halt' Data acquisition stops when the halt command is issued. 'trigger' Takes data for the period of a trigger event. If edge is 'rising' then teh acquisition starts on the rising edge of the trigger signal and stops on the falling edge and vice versa ========= ==========================================================
[ "Configures", "data", "acquisition", "to", "start", "on", "various", "trigger", "conditions", "." ]
train
https://github.com/p3trus/slave/blob/bdc74e73bd0f47b74a090c43aa2283c469cde3be/slave/signal_recovery/sr7230.py#L879-L922
twisted/mantissa
xmantissa/_recordattr.py
RecordAttribute._decompose
def _decompose(self, value): """ Decompose an instance of our record type into a dictionary mapping attribute names to values. @param value: an instance of self.recordType @return: L{dict} containing the keys declared on L{record}. """ data = {} for n, attr in zip(self.recordType.__names__, self.attrs): data[attr.attrname] = getattr(value, n) return data
python
def _decompose(self, value): """ Decompose an instance of our record type into a dictionary mapping attribute names to values. @param value: an instance of self.recordType @return: L{dict} containing the keys declared on L{record}. """ data = {} for n, attr in zip(self.recordType.__names__, self.attrs): data[attr.attrname] = getattr(value, n) return data
[ "def", "_decompose", "(", "self", ",", "value", ")", ":", "data", "=", "{", "}", "for", "n", ",", "attr", "in", "zip", "(", "self", ".", "recordType", ".", "__names__", ",", "self", ".", "attrs", ")", ":", "data", "[", "attr", ".", "attrname", "]...
Decompose an instance of our record type into a dictionary mapping attribute names to values. @param value: an instance of self.recordType @return: L{dict} containing the keys declared on L{record}.
[ "Decompose", "an", "instance", "of", "our", "record", "type", "into", "a", "dictionary", "mapping", "attribute", "names", "to", "values", "." ]
train
https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/_recordattr.py#L91-L103
twisted/mantissa
xmantissa/_recordattr.py
WithRecordAttributes.create
def create(cls, **kw): """ Create an instance of this class, first cleaning up the keyword arguments so they will fill in any required values. @return: an instance of C{cls} """ for k, v in kw.items(): attr = getattr(cls, k, None) if isinstance(attr, RecordAttribute): kw.pop(k) kw.update(attr._decompose(v)) return cls(**kw)
python
def create(cls, **kw): """ Create an instance of this class, first cleaning up the keyword arguments so they will fill in any required values. @return: an instance of C{cls} """ for k, v in kw.items(): attr = getattr(cls, k, None) if isinstance(attr, RecordAttribute): kw.pop(k) kw.update(attr._decompose(v)) return cls(**kw)
[ "def", "create", "(", "cls", ",", "*", "*", "kw", ")", ":", "for", "k", ",", "v", "in", "kw", ".", "items", "(", ")", ":", "attr", "=", "getattr", "(", "cls", ",", "k", ",", "None", ")", "if", "isinstance", "(", "attr", ",", "RecordAttribute", ...
Create an instance of this class, first cleaning up the keyword arguments so they will fill in any required values. @return: an instance of C{cls}
[ "Create", "an", "instance", "of", "this", "class", "first", "cleaning", "up", "the", "keyword", "arguments", "so", "they", "will", "fill", "in", "any", "required", "values", "." ]
train
https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/_recordattr.py#L167-L179
llazzaro/analyzerdam
analyzerdam/hbaseDAM.py
HBaseDAM.__rowResultToQuote
def __rowResultToQuote(self, row): ''' convert rowResult from Hbase to Quote''' keyValues = row.columns for field in QUOTE_FIELDS: key = "%s:%s" % (HBaseDAM.QUOTE, field) if 'time' != field and keyValues[key].value: keyValues[key].value = float(keyValues[key].value) return Quote(*[keyValues["%s:%s" % (HBaseDAM.QUOTE, field)].value for field in QUOTE_FIELDS])
python
def __rowResultToQuote(self, row): ''' convert rowResult from Hbase to Quote''' keyValues = row.columns for field in QUOTE_FIELDS: key = "%s:%s" % (HBaseDAM.QUOTE, field) if 'time' != field and keyValues[key].value: keyValues[key].value = float(keyValues[key].value) return Quote(*[keyValues["%s:%s" % (HBaseDAM.QUOTE, field)].value for field in QUOTE_FIELDS])
[ "def", "__rowResultToQuote", "(", "self", ",", "row", ")", ":", "keyValues", "=", "row", ".", "columns", "for", "field", "in", "QUOTE_FIELDS", ":", "key", "=", "\"%s:%s\"", "%", "(", "HBaseDAM", ".", "QUOTE", ",", "field", ")", "if", "'time'", "!=", "f...
convert rowResult from Hbase to Quote
[ "convert", "rowResult", "from", "Hbase", "to", "Quote" ]
train
https://github.com/llazzaro/analyzerdam/blob/c5bc7483dae23bd2e14bbf36147b7a43a0067bc0/analyzerdam/hbaseDAM.py#L24-L32
llazzaro/analyzerdam
analyzerdam/hbaseDAM.py
HBaseDAM.__rowResultToTick
def __rowResultToTick(self, row): ''' convert rowResult from Hbase to Tick''' keyValues = row.columns for field in TICK_FIELDS: key = "%s:%s" % (HBaseDAM.TICK, field) if 'time' != field and keyValues[key].value: keyValues[key].value = float(keyValues[key].value) return Tick(*[keyValues["%s:%s" % (HBaseDAM.TICK, field)].value for field in TICK_FIELDS])
python
def __rowResultToTick(self, row): ''' convert rowResult from Hbase to Tick''' keyValues = row.columns for field in TICK_FIELDS: key = "%s:%s" % (HBaseDAM.TICK, field) if 'time' != field and keyValues[key].value: keyValues[key].value = float(keyValues[key].value) return Tick(*[keyValues["%s:%s" % (HBaseDAM.TICK, field)].value for field in TICK_FIELDS])
[ "def", "__rowResultToTick", "(", "self", ",", "row", ")", ":", "keyValues", "=", "row", ".", "columns", "for", "field", "in", "TICK_FIELDS", ":", "key", "=", "\"%s:%s\"", "%", "(", "HBaseDAM", ".", "TICK", ",", "field", ")", "if", "'time'", "!=", "fiel...
convert rowResult from Hbase to Tick
[ "convert", "rowResult", "from", "Hbase", "to", "Tick" ]
train
https://github.com/llazzaro/analyzerdam/blob/c5bc7483dae23bd2e14bbf36147b7a43a0067bc0/analyzerdam/hbaseDAM.py#L34-L42
llazzaro/analyzerdam
analyzerdam/hbaseDAM.py
HBaseDAM.readQuotes
def readQuotes(self, start, end): ''' read quotes ''' rows = self.__hbase.scanTable(self.tableName(HBaseDAM.QUOTE), [HBaseDAM.QUOTE], start, end) return [self.__rowResultToQuote(row) for row in rows]
python
def readQuotes(self, start, end): ''' read quotes ''' rows = self.__hbase.scanTable(self.tableName(HBaseDAM.QUOTE), [HBaseDAM.QUOTE], start, end) return [self.__rowResultToQuote(row) for row in rows]
[ "def", "readQuotes", "(", "self", ",", "start", ",", "end", ")", ":", "rows", "=", "self", ".", "__hbase", ".", "scanTable", "(", "self", ".", "tableName", "(", "HBaseDAM", ".", "QUOTE", ")", ",", "[", "HBaseDAM", ".", "QUOTE", "]", ",", "start", "...
read quotes
[ "read", "quotes" ]
train
https://github.com/llazzaro/analyzerdam/blob/c5bc7483dae23bd2e14bbf36147b7a43a0067bc0/analyzerdam/hbaseDAM.py#L44-L48
llazzaro/analyzerdam
analyzerdam/hbaseDAM.py
HBaseDAM.writeQuotes
def writeQuotes(self, quotes): ''' write quotes ''' tName = self.tableName(HBaseDAM.QUOTE) if tName not in self.__hbase.getTableNames(): self.__hbase.createTable(tName, [ColumnDescriptor(name=HBaseDAM.QUOTE, maxVersions=5)]) for quote in quotes: self.__hbase.updateRow(self.tableName(HBaseDAM.QUOTE), quote.time, [Mutation(column = "%s:%s" % (HBaseDAM.QUOTE, field), value = getattr(quote, field) ) for field in QUOTE_FIELDS])
python
def writeQuotes(self, quotes): ''' write quotes ''' tName = self.tableName(HBaseDAM.QUOTE) if tName not in self.__hbase.getTableNames(): self.__hbase.createTable(tName, [ColumnDescriptor(name=HBaseDAM.QUOTE, maxVersions=5)]) for quote in quotes: self.__hbase.updateRow(self.tableName(HBaseDAM.QUOTE), quote.time, [Mutation(column = "%s:%s" % (HBaseDAM.QUOTE, field), value = getattr(quote, field) ) for field in QUOTE_FIELDS])
[ "def", "writeQuotes", "(", "self", ",", "quotes", ")", ":", "tName", "=", "self", ".", "tableName", "(", "HBaseDAM", ".", "QUOTE", ")", "if", "tName", "not", "in", "self", ".", "__hbase", ".", "getTableNames", "(", ")", ":", "self", ".", "__hbase", "...
write quotes
[ "write", "quotes" ]
train
https://github.com/llazzaro/analyzerdam/blob/c5bc7483dae23bd2e14bbf36147b7a43a0067bc0/analyzerdam/hbaseDAM.py#L50-L60
llazzaro/analyzerdam
analyzerdam/hbaseDAM.py
HBaseDAM.readTicks
def readTicks(self, start, end): ''' read ticks ''' rows = self.__hbase.scanTable(self.tableName(HBaseDAM.TICK), [HBaseDAM.TICK], start, end) return [self.__rowResultToTick(row) for row in rows]
python
def readTicks(self, start, end): ''' read ticks ''' rows = self.__hbase.scanTable(self.tableName(HBaseDAM.TICK), [HBaseDAM.TICK], start, end) return [self.__rowResultToTick(row) for row in rows]
[ "def", "readTicks", "(", "self", ",", "start", ",", "end", ")", ":", "rows", "=", "self", ".", "__hbase", ".", "scanTable", "(", "self", ".", "tableName", "(", "HBaseDAM", ".", "TICK", ")", ",", "[", "HBaseDAM", ".", "TICK", "]", ",", "start", ",",...
read ticks
[ "read", "ticks" ]
train
https://github.com/llazzaro/analyzerdam/blob/c5bc7483dae23bd2e14bbf36147b7a43a0067bc0/analyzerdam/hbaseDAM.py#L62-L65
llazzaro/analyzerdam
analyzerdam/hbaseDAM.py
HBaseDAM.writeTicks
def writeTicks(self, ticks): ''' read quotes ''' tName = self.tableName(HBaseDAM.TICK) if tName not in self.__hbase.getTableNames(): self.__hbase.createTable(tName, [ColumnDescriptor(name=HBaseDAM.TICK, maxVersions=5)]) for tick in ticks: self.__hbase.updateRow(self.tableName(HBaseDAM.TICK), tick.time, [Mutation(column = "%s:%s" % (HBaseDAM.TICK, field), value = getattr(tick, field) ) for field in TICK_FIELDS])
python
def writeTicks(self, ticks): ''' read quotes ''' tName = self.tableName(HBaseDAM.TICK) if tName not in self.__hbase.getTableNames(): self.__hbase.createTable(tName, [ColumnDescriptor(name=HBaseDAM.TICK, maxVersions=5)]) for tick in ticks: self.__hbase.updateRow(self.tableName(HBaseDAM.TICK), tick.time, [Mutation(column = "%s:%s" % (HBaseDAM.TICK, field), value = getattr(tick, field) ) for field in TICK_FIELDS])
[ "def", "writeTicks", "(", "self", ",", "ticks", ")", ":", "tName", "=", "self", ".", "tableName", "(", "HBaseDAM", ".", "TICK", ")", "if", "tName", "not", "in", "self", ".", "__hbase", ".", "getTableNames", "(", ")", ":", "self", ".", "__hbase", ".",...
read quotes
[ "read", "quotes" ]
train
https://github.com/llazzaro/analyzerdam/blob/c5bc7483dae23bd2e14bbf36147b7a43a0067bc0/analyzerdam/hbaseDAM.py#L67-L77
KeplerGO/K2fov
K2fov/c9.py
inMicrolensRegion_main
def inMicrolensRegion_main(args=None): """Exposes K2visible to the command line.""" import argparse parser = argparse.ArgumentParser( description="Check if a celestial coordinate is " "inside the K2C9 microlensing superstamp.") parser.add_argument('ra', nargs=1, type=float, help="Right Ascension in decimal degrees (J2000).") parser.add_argument('dec', nargs=1, type=float, help="Declination in decimal degrees (J2000).") args = parser.parse_args(args) if inMicrolensRegion(args.ra[0], args.dec[0]): print("Yes! The coordinate is inside the K2C9 superstamp.") else: print("Sorry, the coordinate is NOT inside the K2C9 superstamp.")
python
def inMicrolensRegion_main(args=None): """Exposes K2visible to the command line.""" import argparse parser = argparse.ArgumentParser( description="Check if a celestial coordinate is " "inside the K2C9 microlensing superstamp.") parser.add_argument('ra', nargs=1, type=float, help="Right Ascension in decimal degrees (J2000).") parser.add_argument('dec', nargs=1, type=float, help="Declination in decimal degrees (J2000).") args = parser.parse_args(args) if inMicrolensRegion(args.ra[0], args.dec[0]): print("Yes! The coordinate is inside the K2C9 superstamp.") else: print("Sorry, the coordinate is NOT inside the K2C9 superstamp.")
[ "def", "inMicrolensRegion_main", "(", "args", "=", "None", ")", ":", "import", "argparse", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "\"Check if a celestial coordinate is \"", "\"inside the K2C9 microlensing superstamp.\"", ")", "parser", ...
Exposes K2visible to the command line.
[ "Exposes", "K2visible", "to", "the", "command", "line", "." ]
train
https://github.com/KeplerGO/K2fov/blob/fb122b35687340e0357cba9e0dd47b3be0760693/K2fov/c9.py#L22-L36
KeplerGO/K2fov
K2fov/c9.py
inMicrolensRegion
def inMicrolensRegion(ra_deg, dec_deg, padding=0): """Returns `True` if the given sky oordinate falls on the K2C9 superstamp. Parameters ---------- ra_deg : float Right Ascension (J2000) in decimal degrees. dec_deg : float Declination (J2000) in decimal degrees. padding : float Target must be at least `padding` pixels away from the edge of the superstamp. (Note that CCD boundaries are not considered as edges in this case.) Returns ------- onMicrolensRegion : bool `True` if the given coordinate is within the K2C9 microlens superstamp. """ fov = getKeplerFov(9) try: ch, col, row = fov.getChannelColRow(ra_deg, dec_deg, allowIllegalReturnValues=False) return maskInMicrolensRegion(ch, col, row, padding=padding) except ValueError: return False
python
def inMicrolensRegion(ra_deg, dec_deg, padding=0): """Returns `True` if the given sky oordinate falls on the K2C9 superstamp. Parameters ---------- ra_deg : float Right Ascension (J2000) in decimal degrees. dec_deg : float Declination (J2000) in decimal degrees. padding : float Target must be at least `padding` pixels away from the edge of the superstamp. (Note that CCD boundaries are not considered as edges in this case.) Returns ------- onMicrolensRegion : bool `True` if the given coordinate is within the K2C9 microlens superstamp. """ fov = getKeplerFov(9) try: ch, col, row = fov.getChannelColRow(ra_deg, dec_deg, allowIllegalReturnValues=False) return maskInMicrolensRegion(ch, col, row, padding=padding) except ValueError: return False
[ "def", "inMicrolensRegion", "(", "ra_deg", ",", "dec_deg", ",", "padding", "=", "0", ")", ":", "fov", "=", "getKeplerFov", "(", "9", ")", "try", ":", "ch", ",", "col", ",", "row", "=", "fov", ".", "getChannelColRow", "(", "ra_deg", ",", "dec_deg", ",...
Returns `True` if the given sky oordinate falls on the K2C9 superstamp. Parameters ---------- ra_deg : float Right Ascension (J2000) in decimal degrees. dec_deg : float Declination (J2000) in decimal degrees. padding : float Target must be at least `padding` pixels away from the edge of the superstamp. (Note that CCD boundaries are not considered as edges in this case.) Returns ------- onMicrolensRegion : bool `True` if the given coordinate is within the K2C9 microlens superstamp.
[ "Returns", "True", "if", "the", "given", "sky", "oordinate", "falls", "on", "the", "K2C9", "superstamp", "." ]
train
https://github.com/KeplerGO/K2fov/blob/fb122b35687340e0357cba9e0dd47b3be0760693/K2fov/c9.py#L39-L66
KeplerGO/K2fov
K2fov/c9.py
pixelInMicrolensRegion
def pixelInMicrolensRegion(ch, col, row): """Returns `True` if the given pixel falls inside the K2C9 superstamp. The superstamp is used for microlensing experiment and is an almost contiguous area of 2.8e6 pixels. """ # First try the superstamp try: vertices_col = SUPERSTAMP["channels"][str(int(ch))]["vertices_col"] vertices_row = SUPERSTAMP["channels"][str(int(ch))]["vertices_row"] # The point is in one of 5 channels which constitute the superstamp # so check if it falls inside the polygon for this channel if isPointInsidePolygon(col, row, vertices_col, vertices_row): return True except KeyError: # Channel does not appear in file pass # Then try the late target masks for mask in LATE_TARGETS["masks"]: if mask["channel"] == ch: vertices_col = mask["vertices_col"] vertices_row = mask["vertices_row"] if isPointInsidePolygon(col, row, vertices_col, vertices_row): return True return False
python
def pixelInMicrolensRegion(ch, col, row): """Returns `True` if the given pixel falls inside the K2C9 superstamp. The superstamp is used for microlensing experiment and is an almost contiguous area of 2.8e6 pixels. """ # First try the superstamp try: vertices_col = SUPERSTAMP["channels"][str(int(ch))]["vertices_col"] vertices_row = SUPERSTAMP["channels"][str(int(ch))]["vertices_row"] # The point is in one of 5 channels which constitute the superstamp # so check if it falls inside the polygon for this channel if isPointInsidePolygon(col, row, vertices_col, vertices_row): return True except KeyError: # Channel does not appear in file pass # Then try the late target masks for mask in LATE_TARGETS["masks"]: if mask["channel"] == ch: vertices_col = mask["vertices_col"] vertices_row = mask["vertices_row"] if isPointInsidePolygon(col, row, vertices_col, vertices_row): return True return False
[ "def", "pixelInMicrolensRegion", "(", "ch", ",", "col", ",", "row", ")", ":", "# First try the superstamp", "try", ":", "vertices_col", "=", "SUPERSTAMP", "[", "\"channels\"", "]", "[", "str", "(", "int", "(", "ch", ")", ")", "]", "[", "\"vertices_col\"", ...
Returns `True` if the given pixel falls inside the K2C9 superstamp. The superstamp is used for microlensing experiment and is an almost contiguous area of 2.8e6 pixels.
[ "Returns", "True", "if", "the", "given", "pixel", "falls", "inside", "the", "K2C9", "superstamp", "." ]
train
https://github.com/KeplerGO/K2fov/blob/fb122b35687340e0357cba9e0dd47b3be0760693/K2fov/c9.py#L69-L94
KeplerGO/K2fov
K2fov/c9.py
maskInMicrolensRegion
def maskInMicrolensRegion(ch, col, row, padding=0): """Is a target in the K2C9 superstamp, including padding? This function is identical to pixelInMicrolensRegion, except it takes the extra `padding` argument. The coordinate must be within the K2C9 superstamp by at least `padding` number of pixels on either side of the coordinate. (Note that this function does not check whether something is close to the CCD boundaries, it only checks whether something is close to the edge of stamp.) """ if padding == 0: return pixelInMicrolensRegion(ch, col, row) combinations = [[col - padding, row], [col + padding, row], [col, row - padding], [col, row + padding]] for col, row in combinations: # Science pixels occupy columns 12 - 1111, rows 20 - 1043 if col < 12: col = 12 if col > 1111: col = 1111 if row < 20: row = 20 if row > 1043: row = 1043 if not pixelInMicrolensRegion(ch, col, row): return False return True
python
def maskInMicrolensRegion(ch, col, row, padding=0): """Is a target in the K2C9 superstamp, including padding? This function is identical to pixelInMicrolensRegion, except it takes the extra `padding` argument. The coordinate must be within the K2C9 superstamp by at least `padding` number of pixels on either side of the coordinate. (Note that this function does not check whether something is close to the CCD boundaries, it only checks whether something is close to the edge of stamp.) """ if padding == 0: return pixelInMicrolensRegion(ch, col, row) combinations = [[col - padding, row], [col + padding, row], [col, row - padding], [col, row + padding]] for col, row in combinations: # Science pixels occupy columns 12 - 1111, rows 20 - 1043 if col < 12: col = 12 if col > 1111: col = 1111 if row < 20: row = 20 if row > 1043: row = 1043 if not pixelInMicrolensRegion(ch, col, row): return False return True
[ "def", "maskInMicrolensRegion", "(", "ch", ",", "col", ",", "row", ",", "padding", "=", "0", ")", ":", "if", "padding", "==", "0", ":", "return", "pixelInMicrolensRegion", "(", "ch", ",", "col", ",", "row", ")", "combinations", "=", "[", "[", "col", ...
Is a target in the K2C9 superstamp, including padding? This function is identical to pixelInMicrolensRegion, except it takes the extra `padding` argument. The coordinate must be within the K2C9 superstamp by at least `padding` number of pixels on either side of the coordinate. (Note that this function does not check whether something is close to the CCD boundaries, it only checks whether something is close to the edge of stamp.)
[ "Is", "a", "target", "in", "the", "K2C9", "superstamp", "including", "padding?" ]
train
https://github.com/KeplerGO/K2fov/blob/fb122b35687340e0357cba9e0dd47b3be0760693/K2fov/c9.py#L97-L126
KeplerGO/K2fov
K2fov/c9.py
isPointInsidePolygon
def isPointInsidePolygon(x, y, vertices_x, vertices_y): """Check if a given point is inside a polygon. Parameters vertices_x[] and vertices_y[] define the polygon. The number of array elements is equal to number of vertices of the polygon. This function works for convex and concave polygons. Parameters ---------- vertices_x, vertices_y : lists or arrays of floats Vertices that define the polygon. x, y : float Coordinates of the point to check. Returns ------- inside : bool `True` if the point is inside the polygon. """ inside = False for i in range(len(vertices_x)): j = i - 1 if ((vertices_x[i] > x) != (vertices_x[j] > x)): if (y < (x - vertices_x[i]) * (vertices_y[i] - vertices_y[j]) / (vertices_x[i] - vertices_x[j]) + vertices_y[i]): inside = not inside return inside
python
def isPointInsidePolygon(x, y, vertices_x, vertices_y): """Check if a given point is inside a polygon. Parameters vertices_x[] and vertices_y[] define the polygon. The number of array elements is equal to number of vertices of the polygon. This function works for convex and concave polygons. Parameters ---------- vertices_x, vertices_y : lists or arrays of floats Vertices that define the polygon. x, y : float Coordinates of the point to check. Returns ------- inside : bool `True` if the point is inside the polygon. """ inside = False for i in range(len(vertices_x)): j = i - 1 if ((vertices_x[i] > x) != (vertices_x[j] > x)): if (y < (x - vertices_x[i]) * (vertices_y[i] - vertices_y[j]) / (vertices_x[i] - vertices_x[j]) + vertices_y[i]): inside = not inside return inside
[ "def", "isPointInsidePolygon", "(", "x", ",", "y", ",", "vertices_x", ",", "vertices_y", ")", ":", "inside", "=", "False", "for", "i", "in", "range", "(", "len", "(", "vertices_x", ")", ")", ":", "j", "=", "i", "-", "1", "if", "(", "(", "vertices_x...
Check if a given point is inside a polygon. Parameters vertices_x[] and vertices_y[] define the polygon. The number of array elements is equal to number of vertices of the polygon. This function works for convex and concave polygons. Parameters ---------- vertices_x, vertices_y : lists or arrays of floats Vertices that define the polygon. x, y : float Coordinates of the point to check. Returns ------- inside : bool `True` if the point is inside the polygon.
[ "Check", "if", "a", "given", "point", "is", "inside", "a", "polygon", "." ]
train
https://github.com/KeplerGO/K2fov/blob/fb122b35687340e0357cba9e0dd47b3be0760693/K2fov/c9.py#L128-L157
KeplerGO/K2fov
K2fov/c9.py
C9FootprintPlot.plot_outline
def plot_outline(self, annotate_late_targets=False, annotate_channels=False): """Plots the coverage of both the channels and the C9 superstamp.""" fov = getKeplerFov(9) # Plot the superstamp superstamp_patches = [] for ch in SUPERSTAMP["channels"]: v_col = SUPERSTAMP["channels"][ch]["vertices_col"] v_row = SUPERSTAMP["channels"][ch]["vertices_row"] radec = np.array([ fov.getRaDecForChannelColRow(int(ch), v_col[idx], v_row[idx]) for idx in range(len(v_col)) ]) patch = self.ax.fill(radec[:, 0], radec[:, 1], lw=0, facecolor="#27ae60", zorder=100) superstamp_patches.append(patch) # Plot the late target masks late_target_patches = [] for mask in LATE_TARGETS["masks"]: ch = mask["channel"] v_col = mask["vertices_col"] v_row = mask["vertices_row"] radec = np.array([ fov.getRaDecForChannelColRow(int(ch), v_col[idx], v_row[idx]) for idx in range(len(v_col)) ]) patch = self.ax.fill(radec[:, 0], radec[:, 1], lw=0, facecolor="#27ae60", zorder=201) late_target_patches.append(patch) if annotate_late_targets and 'context' not in mask["name"]: self.ax.text(np.mean(radec[:, 0]), np.mean(radec[:, 1]), ' ' + mask["name"], ha="left", va="center", zorder=950, fontsize=10, color="#c0392b", clip_on=True) # Plot all channel outlines channel_patches = [] corners = fov.getCoordsOfChannelCorners() for ch in np.arange(1, 85, dtype=int): if ch in fov.brokenChannels: continue # certain channel are no longer used idx = np.where(corners[::, 2] == ch) mdl = int(corners[idx, 0][0][0]) out = int(corners[idx, 1][0][0]) ra = corners[idx, 3][0] dec = corners[idx, 4][0] patch = self.ax.fill(np.concatenate((ra, ra[:1])), np.concatenate((dec, dec[:1])), lw=0, facecolor="#cccccc", zorder=50) channel_patches.append(patch) if annotate_channels: txt = "{}.{}\n#{}".format(mdl, out, ch) self.ax.text(np.mean(ra), np.mean(dec), txt, ha="center", va="center", zorder=900, fontsize=14, color="#000000", clip_on=True) return superstamp_patches, channel_patches
python
def plot_outline(self, annotate_late_targets=False, annotate_channels=False): """Plots the coverage of both the channels and the C9 superstamp.""" fov = getKeplerFov(9) # Plot the superstamp superstamp_patches = [] for ch in SUPERSTAMP["channels"]: v_col = SUPERSTAMP["channels"][ch]["vertices_col"] v_row = SUPERSTAMP["channels"][ch]["vertices_row"] radec = np.array([ fov.getRaDecForChannelColRow(int(ch), v_col[idx], v_row[idx]) for idx in range(len(v_col)) ]) patch = self.ax.fill(radec[:, 0], radec[:, 1], lw=0, facecolor="#27ae60", zorder=100) superstamp_patches.append(patch) # Plot the late target masks late_target_patches = [] for mask in LATE_TARGETS["masks"]: ch = mask["channel"] v_col = mask["vertices_col"] v_row = mask["vertices_row"] radec = np.array([ fov.getRaDecForChannelColRow(int(ch), v_col[idx], v_row[idx]) for idx in range(len(v_col)) ]) patch = self.ax.fill(radec[:, 0], radec[:, 1], lw=0, facecolor="#27ae60", zorder=201) late_target_patches.append(patch) if annotate_late_targets and 'context' not in mask["name"]: self.ax.text(np.mean(radec[:, 0]), np.mean(radec[:, 1]), ' ' + mask["name"], ha="left", va="center", zorder=950, fontsize=10, color="#c0392b", clip_on=True) # Plot all channel outlines channel_patches = [] corners = fov.getCoordsOfChannelCorners() for ch in np.arange(1, 85, dtype=int): if ch in fov.brokenChannels: continue # certain channel are no longer used idx = np.where(corners[::, 2] == ch) mdl = int(corners[idx, 0][0][0]) out = int(corners[idx, 1][0][0]) ra = corners[idx, 3][0] dec = corners[idx, 4][0] patch = self.ax.fill(np.concatenate((ra, ra[:1])), np.concatenate((dec, dec[:1])), lw=0, facecolor="#cccccc", zorder=50) channel_patches.append(patch) if annotate_channels: txt = "{}.{}\n#{}".format(mdl, out, ch) self.ax.text(np.mean(ra), np.mean(dec), txt, ha="center", va="center", zorder=900, fontsize=14, color="#000000", clip_on=True) return superstamp_patches, channel_patches
[ "def", "plot_outline", "(", "self", ",", "annotate_late_targets", "=", "False", ",", "annotate_channels", "=", "False", ")", ":", "fov", "=", "getKeplerFov", "(", "9", ")", "# Plot the superstamp", "superstamp_patches", "=", "[", "]", "for", "ch", "in", "SUPER...
Plots the coverage of both the channels and the C9 superstamp.
[ "Plots", "the", "coverage", "of", "both", "the", "channels", "and", "the", "C9", "superstamp", "." ]
train
https://github.com/KeplerGO/K2fov/blob/fb122b35687340e0357cba9e0dd47b3be0760693/K2fov/c9.py#L187-L247
p3trus/slave
slave/oxford/ips120.py
IPS120.set_field
def set_field(self, target, rate, wait_for_stability=True): """Sets the field to the specified value. :param field: The target field in Tesla. :param rate: The field rate in tesla per minute. :param wait_for_stability: If True, the function call blocks until the target field is reached. """ self.field.target = target self.field.sweep_rate = rate self.activity = 'to setpoint' while self.status['mode'] != 'at rest': time.sleep(1)
python
def set_field(self, target, rate, wait_for_stability=True): """Sets the field to the specified value. :param field: The target field in Tesla. :param rate: The field rate in tesla per minute. :param wait_for_stability: If True, the function call blocks until the target field is reached. """ self.field.target = target self.field.sweep_rate = rate self.activity = 'to setpoint' while self.status['mode'] != 'at rest': time.sleep(1)
[ "def", "set_field", "(", "self", ",", "target", ",", "rate", ",", "wait_for_stability", "=", "True", ")", ":", "self", ".", "field", ".", "target", "=", "target", "self", ".", "field", ".", "sweep_rate", "=", "rate", "self", ".", "activity", "=", "'to ...
Sets the field to the specified value. :param field: The target field in Tesla. :param rate: The field rate in tesla per minute. :param wait_for_stability: If True, the function call blocks until the target field is reached.
[ "Sets", "the", "field", "to", "the", "specified", "value", ".", ":", "param", "field", ":", "The", "target", "field", "in", "Tesla", ".", ":", "param", "rate", ":", "The", "field", "rate", "in", "tesla", "per", "minute", ".", ":", "param", "wait_for_st...
train
https://github.com/p3trus/slave/blob/bdc74e73bd0f47b74a090c43aa2283c469cde3be/slave/oxford/ips120.py#L162-L175
p3trus/slave
slave/oxford/ips120.py
IPS120.scan_field
def scan_field(self, measure, target, rate, delay=1): """Performs a field scan. Measures until the target field is reached. :param measure: A callable called repeatedly until stability at the target field is reached. :param field: The target field in Tesla. :param rate: The field rate in tesla per minute. :param delay: The time delay between each call to measure in seconds. :raises TypeError: if measure parameter is not callable. """ if not hasattr(measure, '__call__'): raise TypeError('measure parameter not callable.') self.activity = 'hold' self.field.target = target self.field.sweep_rate = rate self.activity = 'to setpoint' while self.status['mode'] != 'at rest': measure() time.sleep(delay)
python
def scan_field(self, measure, target, rate, delay=1): """Performs a field scan. Measures until the target field is reached. :param measure: A callable called repeatedly until stability at the target field is reached. :param field: The target field in Tesla. :param rate: The field rate in tesla per minute. :param delay: The time delay between each call to measure in seconds. :raises TypeError: if measure parameter is not callable. """ if not hasattr(measure, '__call__'): raise TypeError('measure parameter not callable.') self.activity = 'hold' self.field.target = target self.field.sweep_rate = rate self.activity = 'to setpoint' while self.status['mode'] != 'at rest': measure() time.sleep(delay)
[ "def", "scan_field", "(", "self", ",", "measure", ",", "target", ",", "rate", ",", "delay", "=", "1", ")", ":", "if", "not", "hasattr", "(", "measure", ",", "'__call__'", ")", ":", "raise", "TypeError", "(", "'measure parameter not callable.'", ")", "self"...
Performs a field scan. Measures until the target field is reached. :param measure: A callable called repeatedly until stability at the target field is reached. :param field: The target field in Tesla. :param rate: The field rate in tesla per minute. :param delay: The time delay between each call to measure in seconds. :raises TypeError: if measure parameter is not callable.
[ "Performs", "a", "field", "scan", "." ]
train
https://github.com/p3trus/slave/blob/bdc74e73bd0f47b74a090c43aa2283c469cde3be/slave/oxford/ips120.py#L177-L199
KeplerGO/K2fov
K2fov/plot.py
create_context_plot
def create_context_plot(ra, dec, name="Your object"): """Creates a K2FootprintPlot showing a given position in context with respect to the campaigns.""" plot = K2FootprintPlot() plot.plot_galactic() plot.plot_ecliptic() for c in range(0, 20): plot.plot_campaign_outline(c, facecolor="#666666") # for c in [11, 12, 13, 14, 15, 16]: # plot.plot_campaign_outline(c, facecolor="green") plot.ax.scatter(ra, dec, marker='x', s=250, lw=3, color="red", zorder=500) plot.ax.text(ra, dec - 2, name, ha="center", va="top", color="red", fontsize=20, fontweight='bold', zorder=501) return plot
python
def create_context_plot(ra, dec, name="Your object"): """Creates a K2FootprintPlot showing a given position in context with respect to the campaigns.""" plot = K2FootprintPlot() plot.plot_galactic() plot.plot_ecliptic() for c in range(0, 20): plot.plot_campaign_outline(c, facecolor="#666666") # for c in [11, 12, 13, 14, 15, 16]: # plot.plot_campaign_outline(c, facecolor="green") plot.ax.scatter(ra, dec, marker='x', s=250, lw=3, color="red", zorder=500) plot.ax.text(ra, dec - 2, name, ha="center", va="top", color="red", fontsize=20, fontweight='bold', zorder=501) return plot
[ "def", "create_context_plot", "(", "ra", ",", "dec", ",", "name", "=", "\"Your object\"", ")", ":", "plot", "=", "K2FootprintPlot", "(", ")", "plot", ".", "plot_galactic", "(", ")", "plot", ".", "plot_ecliptic", "(", ")", "for", "c", "in", "range", "(", ...
Creates a K2FootprintPlot showing a given position in context with respect to the campaigns.
[ "Creates", "a", "K2FootprintPlot", "showing", "a", "given", "position", "in", "context", "with", "respect", "to", "the", "campaigns", "." ]
train
https://github.com/KeplerGO/K2fov/blob/fb122b35687340e0357cba9e0dd47b3be0760693/K2fov/plot.py#L289-L303
KeplerGO/K2fov
K2fov/plot.py
create_context_plot_zoomed
def create_context_plot_zoomed(ra, dec, name="Your object", size=3): """Creates a K2FootprintPlot showing a given position in context with respect to the campaigns.""" plot = K2FootprintPlot(figsize=(8, 8)) for c in range(0, 20): plot.plot_campaign(c) plot.ax.scatter(ra, dec, marker='x', s=250, lw=3, color="red", zorder=500) plot.ax.text(ra, dec - 0.05*size, name, ha="center", va="top", color="red", fontsize=20, fontweight='bold', zorder=501) plot.ax.set_xlim([ra - size/2., ra + size/2.]) plot.ax.set_ylim([dec - size/2., dec + size/2.]) return plot
python
def create_context_plot_zoomed(ra, dec, name="Your object", size=3): """Creates a K2FootprintPlot showing a given position in context with respect to the campaigns.""" plot = K2FootprintPlot(figsize=(8, 8)) for c in range(0, 20): plot.plot_campaign(c) plot.ax.scatter(ra, dec, marker='x', s=250, lw=3, color="red", zorder=500) plot.ax.text(ra, dec - 0.05*size, name, ha="center", va="top", color="red", fontsize=20, fontweight='bold', zorder=501) plot.ax.set_xlim([ra - size/2., ra + size/2.]) plot.ax.set_ylim([dec - size/2., dec + size/2.]) return plot
[ "def", "create_context_plot_zoomed", "(", "ra", ",", "dec", ",", "name", "=", "\"Your object\"", ",", "size", "=", "3", ")", ":", "plot", "=", "K2FootprintPlot", "(", "figsize", "=", "(", "8", ",", "8", ")", ")", "for", "c", "in", "range", "(", "0", ...
Creates a K2FootprintPlot showing a given position in context with respect to the campaigns.
[ "Creates", "a", "K2FootprintPlot", "showing", "a", "given", "position", "in", "context", "with", "respect", "to", "the", "campaigns", "." ]
train
https://github.com/KeplerGO/K2fov/blob/fb122b35687340e0357cba9e0dd47b3be0760693/K2fov/plot.py#L306-L318
KeplerGO/K2fov
K2fov/plot.py
K2FootprintPlot.plot_campaign_outline
def plot_campaign_outline(self, campaign=0, facecolor="#666666", text=None): """Plot the outline of a campaign as a contiguous gray patch. Parameters ---------- campaign : int K2 Campaign number. facecolor : str Color of the patch. """ # The outline is composed of two filled rectangles, # defined by the first coordinate of the corner of four channels each fov = getKeplerFov(campaign) corners = fov.getCoordsOfChannelCorners() for rectangle in [[4, 75, 84, 11], [15, 56, 71, 32]]: ra_outline, dec_outline = [], [] for channel in rectangle: idx = np.where(corners[::, 2] == channel) ra_outline.append(corners[idx, 3][0][0]) dec_outline.append(corners[idx, 4][0][0]) ra = np.array(ra_outline + ra_outline[:1]) dec = np.array(dec_outline + dec_outline[:1]) if campaign == 1002: # Overlaps the meridian ra[ra > 180] -= 360 myfill = self.ax.fill(ra, dec, facecolor=facecolor, zorder=151, lw=0) # Print the campaign number on top of the outline if text is None: text = "{}".format(campaign) ra_center, dec_center, _ = fov.getBoresight() if campaign == 6: dec_center -= 2 elif campaign == 12: ra_center += 0.5 dec_center -= 1.7 elif campaign == 13: dec_center -= 1.5 elif campaign == 16: dec_center += 1.5 elif campaign == 18: dec_center -= 1.5 elif campaign == 19: dec_center += 1.7 elif campaign == 20: dec_center += 1.5 offsets = {5: (40, -20), 16: (-20, 40), 18: (-15, -50)} if campaign in [5]: pl.annotate(text, xy=(ra_center, dec_center), xycoords='data', ha='center', xytext=offsets[campaign], textcoords='offset points', size=18, zorder=0, color=facecolor, arrowprops=dict(arrowstyle="-", ec=facecolor, lw=2)) else: self.ax.text(ra_center, dec_center, text, fontsize=18, color="white", ha="center", va="center", zorder=155) return myfill
python
def plot_campaign_outline(self, campaign=0, facecolor="#666666", text=None): """Plot the outline of a campaign as a contiguous gray patch. Parameters ---------- campaign : int K2 Campaign number. facecolor : str Color of the patch. """ # The outline is composed of two filled rectangles, # defined by the first coordinate of the corner of four channels each fov = getKeplerFov(campaign) corners = fov.getCoordsOfChannelCorners() for rectangle in [[4, 75, 84, 11], [15, 56, 71, 32]]: ra_outline, dec_outline = [], [] for channel in rectangle: idx = np.where(corners[::, 2] == channel) ra_outline.append(corners[idx, 3][0][0]) dec_outline.append(corners[idx, 4][0][0]) ra = np.array(ra_outline + ra_outline[:1]) dec = np.array(dec_outline + dec_outline[:1]) if campaign == 1002: # Overlaps the meridian ra[ra > 180] -= 360 myfill = self.ax.fill(ra, dec, facecolor=facecolor, zorder=151, lw=0) # Print the campaign number on top of the outline if text is None: text = "{}".format(campaign) ra_center, dec_center, _ = fov.getBoresight() if campaign == 6: dec_center -= 2 elif campaign == 12: ra_center += 0.5 dec_center -= 1.7 elif campaign == 13: dec_center -= 1.5 elif campaign == 16: dec_center += 1.5 elif campaign == 18: dec_center -= 1.5 elif campaign == 19: dec_center += 1.7 elif campaign == 20: dec_center += 1.5 offsets = {5: (40, -20), 16: (-20, 40), 18: (-15, -50)} if campaign in [5]: pl.annotate(text, xy=(ra_center, dec_center), xycoords='data', ha='center', xytext=offsets[campaign], textcoords='offset points', size=18, zorder=0, color=facecolor, arrowprops=dict(arrowstyle="-", ec=facecolor, lw=2)) else: self.ax.text(ra_center, dec_center, text, fontsize=18, color="white", ha="center", va="center", zorder=155) return myfill
[ "def", "plot_campaign_outline", "(", "self", ",", "campaign", "=", "0", ",", "facecolor", "=", "\"#666666\"", ",", "text", "=", "None", ")", ":", "# The outline is composed of two filled rectangles,", "# defined by the first coordinate of the corner of four channels each", "f...
Plot the outline of a campaign as a contiguous gray patch. Parameters ---------- campaign : int K2 Campaign number. facecolor : str Color of the patch.
[ "Plot", "the", "outline", "of", "a", "campaign", "as", "a", "contiguous", "gray", "patch", "." ]
train
https://github.com/KeplerGO/K2fov/blob/fb122b35687340e0357cba9e0dd47b3be0760693/K2fov/plot.py#L67-L126
KeplerGO/K2fov
K2fov/plot.py
K2FootprintPlot.plot_campaign
def plot_campaign(self, campaign=0, annotate_channels=True, **kwargs): """Plot all the active channels of a campaign.""" fov = getKeplerFov(campaign) corners = fov.getCoordsOfChannelCorners() for ch in np.arange(1, 85, dtype=int): if ch in fov.brokenChannels: continue # certain channel are no longer used idx = np.where(corners[::, 2] == ch) mdl = int(corners[idx, 0][0][0]) out = int(corners[idx, 1][0][0]) ra = corners[idx, 3][0] if campaign == 1002: # Concept Engineering Test overlapped the meridian ra[ra < 180] += 360 dec = corners[idx, 4][0] self.ax.fill(np.concatenate((ra, ra[:1])), np.concatenate((dec, dec[:1])), **kwargs) if annotate_channels: txt = "K2C{0}\n{1}.{2}\n#{3}".format(campaign, mdl, out, ch) txt = "{1}.{2}\n#{3}".format(campaign, mdl, out, ch) self.ax.text(np.mean(ra), np.mean(dec), txt, ha="center", va="center", zorder=91, fontsize=10, color="#000000", clip_on=True)
python
def plot_campaign(self, campaign=0, annotate_channels=True, **kwargs): """Plot all the active channels of a campaign.""" fov = getKeplerFov(campaign) corners = fov.getCoordsOfChannelCorners() for ch in np.arange(1, 85, dtype=int): if ch in fov.brokenChannels: continue # certain channel are no longer used idx = np.where(corners[::, 2] == ch) mdl = int(corners[idx, 0][0][0]) out = int(corners[idx, 1][0][0]) ra = corners[idx, 3][0] if campaign == 1002: # Concept Engineering Test overlapped the meridian ra[ra < 180] += 360 dec = corners[idx, 4][0] self.ax.fill(np.concatenate((ra, ra[:1])), np.concatenate((dec, dec[:1])), **kwargs) if annotate_channels: txt = "K2C{0}\n{1}.{2}\n#{3}".format(campaign, mdl, out, ch) txt = "{1}.{2}\n#{3}".format(campaign, mdl, out, ch) self.ax.text(np.mean(ra), np.mean(dec), txt, ha="center", va="center", zorder=91, fontsize=10, color="#000000", clip_on=True)
[ "def", "plot_campaign", "(", "self", ",", "campaign", "=", "0", ",", "annotate_channels", "=", "True", ",", "*", "*", "kwargs", ")", ":", "fov", "=", "getKeplerFov", "(", "campaign", ")", "corners", "=", "fov", ".", "getCoordsOfChannelCorners", "(", ")", ...
Plot all the active channels of a campaign.
[ "Plot", "all", "the", "active", "channels", "of", "a", "campaign", "." ]
train
https://github.com/KeplerGO/K2fov/blob/fb122b35687340e0357cba9e0dd47b3be0760693/K2fov/plot.py#L128-L151
KeplerGO/K2fov
K2fov/plot.py
K2GalacticFootprintPlot.plot_campaign_outline
def plot_campaign_outline(self, campaign=0, facecolor="#666666", text=None, dashed=False): """Plot the outline of a campaign as a contiguous gray patch. Parameters ---------- campaign : int K2 Campaign number. facecolor : str Color of the patch. """ try: from astropy.coordinates import SkyCoord except ImportError: logger.error("You need to install AstroPy for this feature.") return None # The outline is composed of two filled rectangles, # defined by the first coordinate of the corner of four channels each fov = getKeplerFov(campaign) corners = fov.getCoordsOfChannelCorners() for rectangle in [[4, 75, 84, 11], [15, 56, 71, 32]]: ra_outline, dec_outline = [], [] for channel in rectangle: idx = np.where(corners[::, 2] == channel) ra_outline.append(corners[idx, 3][0][0]) dec_outline.append(corners[idx, 4][0][0]) crd = SkyCoord(ra_outline, dec_outline, unit='deg') l = crd.galactic.l.deg if campaign not in [4, 13, 1713]: l[l > 180] -= 360 l, b = list(l), list(crd.galactic.b.deg) if dashed: myfill = self.ax.fill(l + l[:1], b + b[:1], facecolor=facecolor, zorder=151, lw=2, ls='dashed', edgecolor='white') # myfill = self.ax.plot(l + l[:1], # b + b[:1], # zorder=200, lw=2, # ls='dotted', color='white') else: myfill = self.ax.fill(l + l[:1], b + b[:1], facecolor=facecolor, zorder=151, lw=0) # Print the campaign number on top of the outline ra, dec, roll = fov.getBoresight() gal = SkyCoord(ra, dec, unit='deg').galactic l, b = gal.l.deg, gal.b.deg if l > 180: l -= 360 if text is None: text = "{}".format(campaign) self.ax.text(l, b, text, fontsize=14, color="white", ha="center", va="center", zorder=255) return myfill
python
def plot_campaign_outline(self, campaign=0, facecolor="#666666", text=None, dashed=False): """Plot the outline of a campaign as a contiguous gray patch. Parameters ---------- campaign : int K2 Campaign number. facecolor : str Color of the patch. """ try: from astropy.coordinates import SkyCoord except ImportError: logger.error("You need to install AstroPy for this feature.") return None # The outline is composed of two filled rectangles, # defined by the first coordinate of the corner of four channels each fov = getKeplerFov(campaign) corners = fov.getCoordsOfChannelCorners() for rectangle in [[4, 75, 84, 11], [15, 56, 71, 32]]: ra_outline, dec_outline = [], [] for channel in rectangle: idx = np.where(corners[::, 2] == channel) ra_outline.append(corners[idx, 3][0][0]) dec_outline.append(corners[idx, 4][0][0]) crd = SkyCoord(ra_outline, dec_outline, unit='deg') l = crd.galactic.l.deg if campaign not in [4, 13, 1713]: l[l > 180] -= 360 l, b = list(l), list(crd.galactic.b.deg) if dashed: myfill = self.ax.fill(l + l[:1], b + b[:1], facecolor=facecolor, zorder=151, lw=2, ls='dashed', edgecolor='white') # myfill = self.ax.plot(l + l[:1], # b + b[:1], # zorder=200, lw=2, # ls='dotted', color='white') else: myfill = self.ax.fill(l + l[:1], b + b[:1], facecolor=facecolor, zorder=151, lw=0) # Print the campaign number on top of the outline ra, dec, roll = fov.getBoresight() gal = SkyCoord(ra, dec, unit='deg').galactic l, b = gal.l.deg, gal.b.deg if l > 180: l -= 360 if text is None: text = "{}".format(campaign) self.ax.text(l, b, text, fontsize=14, color="white", ha="center", va="center", zorder=255) return myfill
[ "def", "plot_campaign_outline", "(", "self", ",", "campaign", "=", "0", ",", "facecolor", "=", "\"#666666\"", ",", "text", "=", "None", ",", "dashed", "=", "False", ")", ":", "try", ":", "from", "astropy", ".", "coordinates", "import", "SkyCoord", "except"...
Plot the outline of a campaign as a contiguous gray patch. Parameters ---------- campaign : int K2 Campaign number. facecolor : str Color of the patch.
[ "Plot", "the", "outline", "of", "a", "campaign", "as", "a", "contiguous", "gray", "patch", "." ]
train
https://github.com/KeplerGO/K2fov/blob/fb122b35687340e0357cba9e0dd47b3be0760693/K2fov/plot.py#L227-L283
rande/python-simple-ioc
ioc/extra/tornado/router.py
AssetHelper.generate_static
def generate_static(self, path): """ This method generates a valid path to the public folder of the running project """ if not path: return "" if path[0] == '/': return "%s?v=%s" % (path, self.version) return "%s/%s?v=%s" % (self.static, path, self.version)
python
def generate_static(self, path): """ This method generates a valid path to the public folder of the running project """ if not path: return "" if path[0] == '/': return "%s?v=%s" % (path, self.version) return "%s/%s?v=%s" % (self.static, path, self.version)
[ "def", "generate_static", "(", "self", ",", "path", ")", ":", "if", "not", "path", ":", "return", "\"\"", "if", "path", "[", "0", "]", "==", "'/'", ":", "return", "\"%s?v=%s\"", "%", "(", "path", ",", "self", ".", "version", ")", "return", "\"%s/%s?v...
This method generates a valid path to the public folder of the running project
[ "This", "method", "generates", "a", "valid", "path", "to", "the", "public", "folder", "of", "the", "running", "project" ]
train
https://github.com/rande/python-simple-ioc/blob/36ddf667c1213a07a53cd4cdd708d02494e5190b/ioc/extra/tornado/router.py#L32-L42
72squared/redpipe
redpipe/keyspaces.py
_parse_values
def _parse_values(values, extra=None): """ Utility function to flatten out args. For internal use only. :param values: list, tuple, or str :param extra: list or None :return: list """ coerced = list(values) if coerced == values: values = coerced else: coerced = tuple(values) if coerced == values: values = list(values) else: values = [values] if extra: values.extend(extra) return values
python
def _parse_values(values, extra=None): """ Utility function to flatten out args. For internal use only. :param values: list, tuple, or str :param extra: list or None :return: list """ coerced = list(values) if coerced == values: values = coerced else: coerced = tuple(values) if coerced == values: values = list(values) else: values = [values] if extra: values.extend(extra) return values
[ "def", "_parse_values", "(", "values", ",", "extra", "=", "None", ")", ":", "coerced", "=", "list", "(", "values", ")", "if", "coerced", "==", "values", ":", "values", "=", "coerced", "else", ":", "coerced", "=", "tuple", "(", "values", ")", "if", "c...
Utility function to flatten out args. For internal use only. :param values: list, tuple, or str :param extra: list or None :return: list
[ "Utility", "function", "to", "flatten", "out", "args", "." ]
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L70-L93
72squared/redpipe
redpipe/keyspaces.py
Keyspace.redis_key
def redis_key(cls, key): """ Get the key we pass to redis. If no namespace is declared, it will use the class name. :param key: str the name of the redis key :return: str """ keyspace = cls.keyspace tpl = cls.keyspace_template key = "%s" % key if keyspace is None else tpl % (keyspace, key) return cls.keyparse.encode(key)
python
def redis_key(cls, key): """ Get the key we pass to redis. If no namespace is declared, it will use the class name. :param key: str the name of the redis key :return: str """ keyspace = cls.keyspace tpl = cls.keyspace_template key = "%s" % key if keyspace is None else tpl % (keyspace, key) return cls.keyparse.encode(key)
[ "def", "redis_key", "(", "cls", ",", "key", ")", ":", "keyspace", "=", "cls", ".", "keyspace", "tpl", "=", "cls", ".", "keyspace_template", "key", "=", "\"%s\"", "%", "key", "if", "keyspace", "is", "None", "else", "tpl", "%", "(", "keyspace", ",", "k...
Get the key we pass to redis. If no namespace is declared, it will use the class name. :param key: str the name of the redis key :return: str
[ "Get", "the", "key", "we", "pass", "to", "redis", ".", "If", "no", "namespace", "is", "declared", "it", "will", "use", "the", "class", "name", "." ]
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L121-L132
72squared/redpipe
redpipe/keyspaces.py
Keyspace.super_pipe
def super_pipe(self): """ Creates a mechanism for us to internally bind two different operations together in a shared pipeline on the class. This will temporarily set self._pipe to be this new pipeline, during this context and then when it leaves the context reset self._pipe to its original value. Example: def get_set(self, key, val) with self.super_pipe as pipe: res = self.get(key) self.set(key, val) return res This will have the effect of using only one network round trip if no pipeline was passed to the constructor. This method is still considered experimental and we are working out the details, so don't use it unless you feel confident you have a legitimate use-case for using this. """ orig_pipe = self._pipe def exit_handler(): self._pipe = orig_pipe self._pipe = autoexec(orig_pipe, name=self.connection, exit_handler=exit_handler) return self._pipe
python
def super_pipe(self): """ Creates a mechanism for us to internally bind two different operations together in a shared pipeline on the class. This will temporarily set self._pipe to be this new pipeline, during this context and then when it leaves the context reset self._pipe to its original value. Example: def get_set(self, key, val) with self.super_pipe as pipe: res = self.get(key) self.set(key, val) return res This will have the effect of using only one network round trip if no pipeline was passed to the constructor. This method is still considered experimental and we are working out the details, so don't use it unless you feel confident you have a legitimate use-case for using this. """ orig_pipe = self._pipe def exit_handler(): self._pipe = orig_pipe self._pipe = autoexec(orig_pipe, name=self.connection, exit_handler=exit_handler) return self._pipe
[ "def", "super_pipe", "(", "self", ")", ":", "orig_pipe", "=", "self", ".", "_pipe", "def", "exit_handler", "(", ")", ":", "self", ".", "_pipe", "=", "orig_pipe", "self", ".", "_pipe", "=", "autoexec", "(", "orig_pipe", ",", "name", "=", "self", ".", ...
Creates a mechanism for us to internally bind two different operations together in a shared pipeline on the class. This will temporarily set self._pipe to be this new pipeline, during this context and then when it leaves the context reset self._pipe to its original value. Example: def get_set(self, key, val) with self.super_pipe as pipe: res = self.get(key) self.set(key, val) return res This will have the effect of using only one network round trip if no pipeline was passed to the constructor. This method is still considered experimental and we are working out the details, so don't use it unless you feel confident you have a legitimate use-case for using this.
[ "Creates", "a", "mechanism", "for", "us", "to", "internally", "bind", "two", "different", "operations", "together", "in", "a", "shared", "pipeline", "on", "the", "class", ".", "This", "will", "temporarily", "set", "self", ".", "_pipe", "to", "be", "this", ...
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L144-L174
72squared/redpipe
redpipe/keyspaces.py
Keyspace.delete
def delete(self, *names): """ Remove the key from redis :param names: tuple of strings - The keys to remove from redis. :return: Future() """ names = [self.redis_key(n) for n in names] with self.pipe as pipe: return pipe.delete(*names)
python
def delete(self, *names): """ Remove the key from redis :param names: tuple of strings - The keys to remove from redis. :return: Future() """ names = [self.redis_key(n) for n in names] with self.pipe as pipe: return pipe.delete(*names)
[ "def", "delete", "(", "self", ",", "*", "names", ")", ":", "names", "=", "[", "self", ".", "redis_key", "(", "n", ")", "for", "n", "in", "names", "]", "with", "self", ".", "pipe", "as", "pipe", ":", "return", "pipe", ".", "delete", "(", "*", "n...
Remove the key from redis :param names: tuple of strings - The keys to remove from redis. :return: Future()
[ "Remove", "the", "key", "from", "redis" ]
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L176-L185
72squared/redpipe
redpipe/keyspaces.py
Keyspace.expire
def expire(self, name, time): """ Allow the key to expire after ``time`` seconds. :param name: str the name of the redis key :param time: time expressed in seconds. :return: Future() """ with self.pipe as pipe: return pipe.expire(self.redis_key(name), time)
python
def expire(self, name, time): """ Allow the key to expire after ``time`` seconds. :param name: str the name of the redis key :param time: time expressed in seconds. :return: Future() """ with self.pipe as pipe: return pipe.expire(self.redis_key(name), time)
[ "def", "expire", "(", "self", ",", "name", ",", "time", ")", ":", "with", "self", ".", "pipe", "as", "pipe", ":", "return", "pipe", ".", "expire", "(", "self", ".", "redis_key", "(", "name", ")", ",", "time", ")" ]
Allow the key to expire after ``time`` seconds. :param name: str the name of the redis key :param time: time expressed in seconds. :return: Future()
[ "Allow", "the", "key", "to", "expire", "after", "time", "seconds", "." ]
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L187-L196
72squared/redpipe
redpipe/keyspaces.py
Keyspace.exists
def exists(self, name): """ does the key exist in redis? :param name: str the name of the redis key :return: Future() """ with self.pipe as pipe: return pipe.exists(self.redis_key(name))
python
def exists(self, name): """ does the key exist in redis? :param name: str the name of the redis key :return: Future() """ with self.pipe as pipe: return pipe.exists(self.redis_key(name))
[ "def", "exists", "(", "self", ",", "name", ")", ":", "with", "self", ".", "pipe", "as", "pipe", ":", "return", "pipe", ".", "exists", "(", "self", ".", "redis_key", "(", "name", ")", ")" ]
does the key exist in redis? :param name: str the name of the redis key :return: Future()
[ "does", "the", "key", "exist", "in", "redis?" ]
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L198-L206
72squared/redpipe
redpipe/keyspaces.py
Keyspace.eval
def eval(self, script, numkeys, *keys_and_args): """ Run a lua script against the key. Doesn't support multi-key lua operations because we wouldn't be able to know what argument to namespace. Also, redis cluster doesn't really support multi-key operations. :param script: str A lua script targeting the current key. :param numkeys: number of keys passed to the script :param keys_and_args: list of keys and args passed to script :return: Future() """ with self.pipe as pipe: keys_and_args = [a if i >= numkeys else self.redis_key(a) for i, a in enumerate(keys_and_args)] return pipe.eval(script, numkeys, *keys_and_args)
python
def eval(self, script, numkeys, *keys_and_args): """ Run a lua script against the key. Doesn't support multi-key lua operations because we wouldn't be able to know what argument to namespace. Also, redis cluster doesn't really support multi-key operations. :param script: str A lua script targeting the current key. :param numkeys: number of keys passed to the script :param keys_and_args: list of keys and args passed to script :return: Future() """ with self.pipe as pipe: keys_and_args = [a if i >= numkeys else self.redis_key(a) for i, a in enumerate(keys_and_args)] return pipe.eval(script, numkeys, *keys_and_args)
[ "def", "eval", "(", "self", ",", "script", ",", "numkeys", ",", "*", "keys_and_args", ")", ":", "with", "self", ".", "pipe", "as", "pipe", ":", "keys_and_args", "=", "[", "a", "if", "i", ">=", "numkeys", "else", "self", ".", "redis_key", "(", "a", ...
Run a lua script against the key. Doesn't support multi-key lua operations because we wouldn't be able to know what argument to namespace. Also, redis cluster doesn't really support multi-key operations. :param script: str A lua script targeting the current key. :param numkeys: number of keys passed to the script :param keys_and_args: list of keys and args passed to script :return: Future()
[ "Run", "a", "lua", "script", "against", "the", "key", ".", "Doesn", "t", "support", "multi", "-", "key", "lua", "operations", "because", "we", "wouldn", "t", "be", "able", "to", "know", "what", "argument", "to", "namespace", ".", "Also", "redis", "cluste...
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L208-L223
72squared/redpipe
redpipe/keyspaces.py
Keyspace.dump
def dump(self, name): """ get a redis RDB-like serialization of the object. :param name: str the name of the redis key :return: Future() """ with self.pipe as pipe: return pipe.dump(self.redis_key(name))
python
def dump(self, name): """ get a redis RDB-like serialization of the object. :param name: str the name of the redis key :return: Future() """ with self.pipe as pipe: return pipe.dump(self.redis_key(name))
[ "def", "dump", "(", "self", ",", "name", ")", ":", "with", "self", ".", "pipe", "as", "pipe", ":", "return", "pipe", ".", "dump", "(", "self", ".", "redis_key", "(", "name", ")", ")" ]
get a redis RDB-like serialization of the object. :param name: str the name of the redis key :return: Future()
[ "get", "a", "redis", "RDB", "-", "like", "serialization", "of", "the", "object", "." ]
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L225-L233
72squared/redpipe
redpipe/keyspaces.py
Keyspace.restorenx
def restorenx(self, name, value, pttl=0): """ Restore serialized dump of a key back into redis :param name: str the name of the redis key :param value: redis RDB-like serialization :param pttl: milliseconds till key expires :return: Future() """ return self.eval(lua_restorenx, 1, name, pttl, value)
python
def restorenx(self, name, value, pttl=0): """ Restore serialized dump of a key back into redis :param name: str the name of the redis key :param value: redis RDB-like serialization :param pttl: milliseconds till key expires :return: Future() """ return self.eval(lua_restorenx, 1, name, pttl, value)
[ "def", "restorenx", "(", "self", ",", "name", ",", "value", ",", "pttl", "=", "0", ")", ":", "return", "self", ".", "eval", "(", "lua_restorenx", ",", "1", ",", "name", ",", "pttl", ",", "value", ")" ]
Restore serialized dump of a key back into redis :param name: str the name of the redis key :param value: redis RDB-like serialization :param pttl: milliseconds till key expires :return: Future()
[ "Restore", "serialized", "dump", "of", "a", "key", "back", "into", "redis" ]
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L235-L244
72squared/redpipe
redpipe/keyspaces.py
Keyspace.restore
def restore(self, name, value, pttl=0): """ Restore serialized dump of a key back into redis :param name: the name of the key :param value: the binary representation of the key. :param pttl: milliseconds till key expires :return: """ with self.pipe as pipe: res = pipe.restore(self.redis_key(name), ttl=pttl, value=value) f = Future() def cb(): f.set(self.valueparse.decode(res.result)) pipe.on_execute(cb) return f
python
def restore(self, name, value, pttl=0): """ Restore serialized dump of a key back into redis :param name: the name of the key :param value: the binary representation of the key. :param pttl: milliseconds till key expires :return: """ with self.pipe as pipe: res = pipe.restore(self.redis_key(name), ttl=pttl, value=value) f = Future() def cb(): f.set(self.valueparse.decode(res.result)) pipe.on_execute(cb) return f
[ "def", "restore", "(", "self", ",", "name", ",", "value", ",", "pttl", "=", "0", ")", ":", "with", "self", ".", "pipe", "as", "pipe", ":", "res", "=", "pipe", ".", "restore", "(", "self", ".", "redis_key", "(", "name", ")", ",", "ttl", "=", "pt...
Restore serialized dump of a key back into redis :param name: the name of the key :param value: the binary representation of the key. :param pttl: milliseconds till key expires :return:
[ "Restore", "serialized", "dump", "of", "a", "key", "back", "into", "redis" ]
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L246-L263
72squared/redpipe
redpipe/keyspaces.py
Keyspace.ttl
def ttl(self, name): """ get the number of seconds until the key's expiration :param name: str the name of the redis key :return: Future() """ with self.pipe as pipe: return pipe.ttl(self.redis_key(name))
python
def ttl(self, name): """ get the number of seconds until the key's expiration :param name: str the name of the redis key :return: Future() """ with self.pipe as pipe: return pipe.ttl(self.redis_key(name))
[ "def", "ttl", "(", "self", ",", "name", ")", ":", "with", "self", ".", "pipe", "as", "pipe", ":", "return", "pipe", ".", "ttl", "(", "self", ".", "redis_key", "(", "name", ")", ")" ]
get the number of seconds until the key's expiration :param name: str the name of the redis key :return: Future()
[ "get", "the", "number", "of", "seconds", "until", "the", "key", "s", "expiration" ]
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L265-L273
72squared/redpipe
redpipe/keyspaces.py
Keyspace.persist
def persist(self, name): """ clear any expiration TTL set on the object :param name: str the name of the redis key :return: Future() """ with self.pipe as pipe: return pipe.persist(self.redis_key(name))
python
def persist(self, name): """ clear any expiration TTL set on the object :param name: str the name of the redis key :return: Future() """ with self.pipe as pipe: return pipe.persist(self.redis_key(name))
[ "def", "persist", "(", "self", ",", "name", ")", ":", "with", "self", ".", "pipe", "as", "pipe", ":", "return", "pipe", ".", "persist", "(", "self", ".", "redis_key", "(", "name", ")", ")" ]
clear any expiration TTL set on the object :param name: str the name of the redis key :return: Future()
[ "clear", "any", "expiration", "TTL", "set", "on", "the", "object" ]
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L275-L283
72squared/redpipe
redpipe/keyspaces.py
Keyspace.pexpire
def pexpire(self, name, time): """ Set an expire flag on key ``name`` for ``time`` milliseconds. ``time`` can be represented by an integer or a Python timedelta object. :param name: str :param time: int or timedelta :return Future """ with self.pipe as pipe: return pipe.pexpire(self.redis_key(name), time)
python
def pexpire(self, name, time): """ Set an expire flag on key ``name`` for ``time`` milliseconds. ``time`` can be represented by an integer or a Python timedelta object. :param name: str :param time: int or timedelta :return Future """ with self.pipe as pipe: return pipe.pexpire(self.redis_key(name), time)
[ "def", "pexpire", "(", "self", ",", "name", ",", "time", ")", ":", "with", "self", ".", "pipe", "as", "pipe", ":", "return", "pipe", ".", "pexpire", "(", "self", ".", "redis_key", "(", "name", ")", ",", "time", ")" ]
Set an expire flag on key ``name`` for ``time`` milliseconds. ``time`` can be represented by an integer or a Python timedelta object. :param name: str :param time: int or timedelta :return Future
[ "Set", "an", "expire", "flag", "on", "key", "name", "for", "time", "milliseconds", ".", "time", "can", "be", "represented", "by", "an", "integer", "or", "a", "Python", "timedelta", "object", "." ]
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L285-L296
72squared/redpipe
redpipe/keyspaces.py
Keyspace.pexpireat
def pexpireat(self, name, when): """ Set an expire flag on key ``name``. ``when`` can be represented as an integer representing unix time in milliseconds (unix time * 1000) or a Python datetime object. """ with self.pipe as pipe: return pipe.pexpireat(self.redis_key(name), when)
python
def pexpireat(self, name, when): """ Set an expire flag on key ``name``. ``when`` can be represented as an integer representing unix time in milliseconds (unix time * 1000) or a Python datetime object. """ with self.pipe as pipe: return pipe.pexpireat(self.redis_key(name), when)
[ "def", "pexpireat", "(", "self", ",", "name", ",", "when", ")", ":", "with", "self", ".", "pipe", "as", "pipe", ":", "return", "pipe", ".", "pexpireat", "(", "self", ".", "redis_key", "(", "name", ")", ",", "when", ")" ]
Set an expire flag on key ``name``. ``when`` can be represented as an integer representing unix time in milliseconds (unix time * 1000) or a Python datetime object.
[ "Set", "an", "expire", "flag", "on", "key", "name", ".", "when", "can", "be", "represented", "as", "an", "integer", "representing", "unix", "time", "in", "milliseconds", "(", "unix", "time", "*", "1000", ")", "or", "a", "Python", "datetime", "object", "....
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L298-L305
72squared/redpipe
redpipe/keyspaces.py
Keyspace.pttl
def pttl(self, name): """ Returns the number of milliseconds until the key ``name`` will expire :param name: str the name of the redis key :return: """ with self.pipe as pipe: return pipe.pttl(self.redis_key(name))
python
def pttl(self, name): """ Returns the number of milliseconds until the key ``name`` will expire :param name: str the name of the redis key :return: """ with self.pipe as pipe: return pipe.pttl(self.redis_key(name))
[ "def", "pttl", "(", "self", ",", "name", ")", ":", "with", "self", ".", "pipe", "as", "pipe", ":", "return", "pipe", ".", "pttl", "(", "self", ".", "redis_key", "(", "name", ")", ")" ]
Returns the number of milliseconds until the key ``name`` will expire :param name: str the name of the redis key :return:
[ "Returns", "the", "number", "of", "milliseconds", "until", "the", "key", "name", "will", "expire" ]
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L307-L315
72squared/redpipe
redpipe/keyspaces.py
Keyspace.rename
def rename(self, src, dst): """ Rename key ``src`` to ``dst`` """ with self.pipe as pipe: return pipe.rename(self.redis_key(src), self.redis_key(dst))
python
def rename(self, src, dst): """ Rename key ``src`` to ``dst`` """ with self.pipe as pipe: return pipe.rename(self.redis_key(src), self.redis_key(dst))
[ "def", "rename", "(", "self", ",", "src", ",", "dst", ")", ":", "with", "self", ".", "pipe", "as", "pipe", ":", "return", "pipe", ".", "rename", "(", "self", ".", "redis_key", "(", "src", ")", ",", "self", ".", "redis_key", "(", "dst", ")", ")" ]
Rename key ``src`` to ``dst``
[ "Rename", "key", "src", "to", "dst" ]
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L317-L322
72squared/redpipe
redpipe/keyspaces.py
Keyspace.renamenx
def renamenx(self, src, dst): "Rename key ``src`` to ``dst`` if ``dst`` doesn't already exist" with self.pipe as pipe: return pipe.renamenx(self.redis_key(src), self.redis_key(dst))
python
def renamenx(self, src, dst): "Rename key ``src`` to ``dst`` if ``dst`` doesn't already exist" with self.pipe as pipe: return pipe.renamenx(self.redis_key(src), self.redis_key(dst))
[ "def", "renamenx", "(", "self", ",", "src", ",", "dst", ")", ":", "with", "self", ".", "pipe", "as", "pipe", ":", "return", "pipe", ".", "renamenx", "(", "self", ".", "redis_key", "(", "src", ")", ",", "self", ".", "redis_key", "(", "dst", ")", "...
Rename key ``src`` to ``dst`` if ``dst`` doesn't already exist
[ "Rename", "key", "src", "to", "dst", "if", "dst", "doesn", "t", "already", "exist" ]
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L324-L327
72squared/redpipe
redpipe/keyspaces.py
Keyspace.object
def object(self, infotype, key): """ get the key's info stats :param name: str the name of the redis key :param subcommand: REFCOUNT | ENCODING | IDLETIME :return: Future() """ with self.pipe as pipe: return pipe.object(infotype, self.redis_key(key))
python
def object(self, infotype, key): """ get the key's info stats :param name: str the name of the redis key :param subcommand: REFCOUNT | ENCODING | IDLETIME :return: Future() """ with self.pipe as pipe: return pipe.object(infotype, self.redis_key(key))
[ "def", "object", "(", "self", ",", "infotype", ",", "key", ")", ":", "with", "self", ".", "pipe", "as", "pipe", ":", "return", "pipe", ".", "object", "(", "infotype", ",", "self", ".", "redis_key", "(", "key", ")", ")" ]
get the key's info stats :param name: str the name of the redis key :param subcommand: REFCOUNT | ENCODING | IDLETIME :return: Future()
[ "get", "the", "key", "s", "info", "stats" ]
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L329-L338
72squared/redpipe
redpipe/keyspaces.py
Keyspace.scan
def scan(self, cursor=0, match=None, count=None): """ Incrementally return lists of key names. Also return a cursor indicating the scan position. ``match`` allows for filtering the keys by pattern ``count`` allows for hint the minimum number of returns """ f = Future() if self.keyspace is None: with self.pipe as pipe: res = pipe.scan(cursor=cursor, match=match, count=count) def cb(): f.set((res[0], [self.keyparse.decode(v) for v in res[1]])) pipe.on_execute(cb) return f if match is None: match = '*' match = "%s{%s}" % (self.keyspace, match) pattern = re.compile(r'^%s\{(.*)\}$' % self.keyspace) with self.pipe as pipe: res = pipe.scan(cursor=cursor, match=match, count=count) def cb(): keys = [] for k in res[1]: k = self.keyparse.decode(k) m = pattern.match(k) if m: keys.append(m.group(1)) f.set((res[0], keys)) pipe.on_execute(cb) return f
python
def scan(self, cursor=0, match=None, count=None): """ Incrementally return lists of key names. Also return a cursor indicating the scan position. ``match`` allows for filtering the keys by pattern ``count`` allows for hint the minimum number of returns """ f = Future() if self.keyspace is None: with self.pipe as pipe: res = pipe.scan(cursor=cursor, match=match, count=count) def cb(): f.set((res[0], [self.keyparse.decode(v) for v in res[1]])) pipe.on_execute(cb) return f if match is None: match = '*' match = "%s{%s}" % (self.keyspace, match) pattern = re.compile(r'^%s\{(.*)\}$' % self.keyspace) with self.pipe as pipe: res = pipe.scan(cursor=cursor, match=match, count=count) def cb(): keys = [] for k in res[1]: k = self.keyparse.decode(k) m = pattern.match(k) if m: keys.append(m.group(1)) f.set((res[0], keys)) pipe.on_execute(cb) return f
[ "def", "scan", "(", "self", ",", "cursor", "=", "0", ",", "match", "=", "None", ",", "count", "=", "None", ")", ":", "f", "=", "Future", "(", ")", "if", "self", ".", "keyspace", "is", "None", ":", "with", "self", ".", "pipe", "as", "pipe", ":",...
Incrementally return lists of key names. Also return a cursor indicating the scan position. ``match`` allows for filtering the keys by pattern ``count`` allows for hint the minimum number of returns
[ "Incrementally", "return", "lists", "of", "key", "names", ".", "Also", "return", "a", "cursor", "indicating", "the", "scan", "position", "." ]
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L349-L389
72squared/redpipe
redpipe/keyspaces.py
Keyspace.sort
def sort(self, name, start=None, num=None, by=None, get=None, desc=False, alpha=False, store=None, groups=False): """ Sort and return the list, set or sorted set at ``name``. ``start`` and ``num`` allow for paging through the sorted data ``by`` allows using an external key to weight and sort the items. Use an "*" to indicate where in the key the item value is located ``get`` allows for returning items from external keys rather than the sorted data itself. Use an "*" to indicate where int he key the item value is located ``desc`` allows for reversing the sort ``alpha`` allows for sorting lexicographically rather than numerically ``store`` allows for storing the result of the sort into the key ``store`` ``groups`` if set to True and if ``get`` contains at least two elements, sort will return a list of tuples, each containing the values fetched from the arguments to ``get``. """ with self.pipe as pipe: res = pipe.sort(self.redis_key(name), start=start, num=num, by=by, get=get, desc=desc, alpha=alpha, store=store, groups=groups) if store: return res f = Future() def cb(): decode = self.valueparse.decode f.set([decode(v) for v in res.result]) pipe.on_execute(cb) return f
python
def sort(self, name, start=None, num=None, by=None, get=None, desc=False, alpha=False, store=None, groups=False): """ Sort and return the list, set or sorted set at ``name``. ``start`` and ``num`` allow for paging through the sorted data ``by`` allows using an external key to weight and sort the items. Use an "*" to indicate where in the key the item value is located ``get`` allows for returning items from external keys rather than the sorted data itself. Use an "*" to indicate where int he key the item value is located ``desc`` allows for reversing the sort ``alpha`` allows for sorting lexicographically rather than numerically ``store`` allows for storing the result of the sort into the key ``store`` ``groups`` if set to True and if ``get`` contains at least two elements, sort will return a list of tuples, each containing the values fetched from the arguments to ``get``. """ with self.pipe as pipe: res = pipe.sort(self.redis_key(name), start=start, num=num, by=by, get=get, desc=desc, alpha=alpha, store=store, groups=groups) if store: return res f = Future() def cb(): decode = self.valueparse.decode f.set([decode(v) for v in res.result]) pipe.on_execute(cb) return f
[ "def", "sort", "(", "self", ",", "name", ",", "start", "=", "None", ",", "num", "=", "None", ",", "by", "=", "None", ",", "get", "=", "None", ",", "desc", "=", "False", ",", "alpha", "=", "False", ",", "store", "=", "None", ",", "groups", "=", ...
Sort and return the list, set or sorted set at ``name``. ``start`` and ``num`` allow for paging through the sorted data ``by`` allows using an external key to weight and sort the items. Use an "*" to indicate where in the key the item value is located ``get`` allows for returning items from external keys rather than the sorted data itself. Use an "*" to indicate where int he key the item value is located ``desc`` allows for reversing the sort ``alpha`` allows for sorting lexicographically rather than numerically ``store`` allows for storing the result of the sort into the key ``store`` ``groups`` if set to True and if ``get`` contains at least two elements, sort will return a list of tuples, each containing the values fetched from the arguments to ``get``.
[ "Sort", "and", "return", "the", "list", "set", "or", "sorted", "set", "at", "name", "." ]
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L409-L448
72squared/redpipe
redpipe/keyspaces.py
String.mget
def mget(self, keys, *args): """ Returns a list of values ordered identically to ``keys`` """ keys = [self.redis_key(k) for k in self._parse_values(keys, args)] with self.pipe as pipe: f = Future() res = pipe.mget(keys) def cb(): decode = self.valueparse.decode f.set([None if r is None else decode(r) for r in res.result]) pipe.on_execute(cb) return f
python
def mget(self, keys, *args): """ Returns a list of values ordered identically to ``keys`` """ keys = [self.redis_key(k) for k in self._parse_values(keys, args)] with self.pipe as pipe: f = Future() res = pipe.mget(keys) def cb(): decode = self.valueparse.decode f.set([None if r is None else decode(r) for r in res.result]) pipe.on_execute(cb) return f
[ "def", "mget", "(", "self", ",", "keys", ",", "*", "args", ")", ":", "keys", "=", "[", "self", ".", "redis_key", "(", "k", ")", "for", "k", "in", "self", ".", "_parse_values", "(", "keys", ",", "args", ")", "]", "with", "self", ".", "pipe", "as...
Returns a list of values ordered identically to ``keys``
[ "Returns", "a", "list", "of", "values", "ordered", "identically", "to", "keys" ]
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L478-L492
72squared/redpipe
redpipe/keyspaces.py
String.set
def set(self, name, value, ex=None, px=None, nx=False, xx=False): """ Set the value at key ``name`` to ``value`` ``ex`` sets an expire flag on key ``name`` for ``ex`` seconds. ``px`` sets an expire flag on key ``name`` for ``px`` milliseconds. ``nx`` if set to True, set the value at key ``name`` to ``value`` if it does not already exist. ``xx`` if set to True, set the value at key ``name`` to ``value`` if it already exists. :return: Future() """ with self.pipe as pipe: value = self.valueparse.encode(value) return pipe.set(self.redis_key(name), value, ex=ex, px=px, nx=nx, xx=xx)
python
def set(self, name, value, ex=None, px=None, nx=False, xx=False): """ Set the value at key ``name`` to ``value`` ``ex`` sets an expire flag on key ``name`` for ``ex`` seconds. ``px`` sets an expire flag on key ``name`` for ``px`` milliseconds. ``nx`` if set to True, set the value at key ``name`` to ``value`` if it does not already exist. ``xx`` if set to True, set the value at key ``name`` to ``value`` if it already exists. :return: Future() """ with self.pipe as pipe: value = self.valueparse.encode(value) return pipe.set(self.redis_key(name), value, ex=ex, px=px, nx=nx, xx=xx)
[ "def", "set", "(", "self", ",", "name", ",", "value", ",", "ex", "=", "None", ",", "px", "=", "None", ",", "nx", "=", "False", ",", "xx", "=", "False", ")", ":", "with", "self", ".", "pipe", "as", "pipe", ":", "value", "=", "self", ".", "valu...
Set the value at key ``name`` to ``value`` ``ex`` sets an expire flag on key ``name`` for ``ex`` seconds. ``px`` sets an expire flag on key ``name`` for ``px`` milliseconds. ``nx`` if set to True, set the value at key ``name`` to ``value`` if it does not already exist. ``xx`` if set to True, set the value at key ``name`` to ``value`` if it already exists. :return: Future()
[ "Set", "the", "value", "at", "key", "name", "to", "value" ]
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L494-L513
72squared/redpipe
redpipe/keyspaces.py
String.setnx
def setnx(self, name, value): """ Set the value as a string in the key only if the key doesn't exist. :param name: str the name of the redis key :param value: :return: Future() """ with self.pipe as pipe: return pipe.setnx(self.redis_key(name), self.valueparse.encode(value))
python
def setnx(self, name, value): """ Set the value as a string in the key only if the key doesn't exist. :param name: str the name of the redis key :param value: :return: Future() """ with self.pipe as pipe: return pipe.setnx(self.redis_key(name), self.valueparse.encode(value))
[ "def", "setnx", "(", "self", ",", "name", ",", "value", ")", ":", "with", "self", ".", "pipe", "as", "pipe", ":", "return", "pipe", ".", "setnx", "(", "self", ".", "redis_key", "(", "name", ")", ",", "self", ".", "valueparse", ".", "encode", "(", ...
Set the value as a string in the key only if the key doesn't exist. :param name: str the name of the redis key :param value: :return: Future()
[ "Set", "the", "value", "as", "a", "string", "in", "the", "key", "only", "if", "the", "key", "doesn", "t", "exist", "." ]
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L515-L525
72squared/redpipe
redpipe/keyspaces.py
String.setex
def setex(self, name, value, time): """ Set the value of key to ``value`` that expires in ``time`` seconds. ``time`` can be represented by an integer or a Python timedelta object. :param name: str the name of the redis key :param value: str :param time: secs :return: Future() """ with self.pipe as pipe: return pipe.setex(self.redis_key(name), value=self.valueparse.encode(value), time=time)
python
def setex(self, name, value, time): """ Set the value of key to ``value`` that expires in ``time`` seconds. ``time`` can be represented by an integer or a Python timedelta object. :param name: str the name of the redis key :param value: str :param time: secs :return: Future() """ with self.pipe as pipe: return pipe.setex(self.redis_key(name), value=self.valueparse.encode(value), time=time)
[ "def", "setex", "(", "self", ",", "name", ",", "value", ",", "time", ")", ":", "with", "self", ".", "pipe", "as", "pipe", ":", "return", "pipe", ".", "setex", "(", "self", ".", "redis_key", "(", "name", ")", ",", "value", "=", "self", ".", "value...
Set the value of key to ``value`` that expires in ``time`` seconds. ``time`` can be represented by an integer or a Python timedelta object. :param name: str the name of the redis key :param value: str :param time: secs :return: Future()
[ "Set", "the", "value", "of", "key", "to", "value", "that", "expires", "in", "time", "seconds", ".", "time", "can", "be", "represented", "by", "an", "integer", "or", "a", "Python", "timedelta", "object", "." ]
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L527-L541
72squared/redpipe
redpipe/keyspaces.py
String.psetex
def psetex(self, name, value, time_ms): """ Set the value of key ``name`` to ``value`` that expires in ``time_ms`` milliseconds. ``time_ms`` can be represented by an integer or a Python timedelta object """ with self.pipe as pipe: return pipe.psetex(self.redis_key(name), time_ms=time_ms, value=self.valueparse.encode(value=value))
python
def psetex(self, name, value, time_ms): """ Set the value of key ``name`` to ``value`` that expires in ``time_ms`` milliseconds. ``time_ms`` can be represented by an integer or a Python timedelta object """ with self.pipe as pipe: return pipe.psetex(self.redis_key(name), time_ms=time_ms, value=self.valueparse.encode(value=value))
[ "def", "psetex", "(", "self", ",", "name", ",", "value", ",", "time_ms", ")", ":", "with", "self", ".", "pipe", "as", "pipe", ":", "return", "pipe", ".", "psetex", "(", "self", ".", "redis_key", "(", "name", ")", ",", "time_ms", "=", "time_ms", ","...
Set the value of key ``name`` to ``value`` that expires in ``time_ms`` milliseconds. ``time_ms`` can be represented by an integer or a Python timedelta object
[ "Set", "the", "value", "of", "key", "name", "to", "value", "that", "expires", "in", "time_ms", "milliseconds", ".", "time_ms", "can", "be", "represented", "by", "an", "integer", "or", "a", "Python", "timedelta", "object" ]
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L543-L551
72squared/redpipe
redpipe/keyspaces.py
String.append
def append(self, name, value): """ Appends the string ``value`` to the value at ``key``. If ``key`` doesn't already exist, create it with a value of ``value``. Returns the new length of the value at ``key``. :param name: str the name of the redis key :param value: str :return: Future() """ with self.pipe as pipe: return pipe.append(self.redis_key(name), self.valueparse.encode(value))
python
def append(self, name, value): """ Appends the string ``value`` to the value at ``key``. If ``key`` doesn't already exist, create it with a value of ``value``. Returns the new length of the value at ``key``. :param name: str the name of the redis key :param value: str :return: Future() """ with self.pipe as pipe: return pipe.append(self.redis_key(name), self.valueparse.encode(value))
[ "def", "append", "(", "self", ",", "name", ",", "value", ")", ":", "with", "self", ".", "pipe", "as", "pipe", ":", "return", "pipe", ".", "append", "(", "self", ".", "redis_key", "(", "name", ")", ",", "self", ".", "valueparse", ".", "encode", "(",...
Appends the string ``value`` to the value at ``key``. If ``key`` doesn't already exist, create it with a value of ``value``. Returns the new length of the value at ``key``. :param name: str the name of the redis key :param value: str :return: Future()
[ "Appends", "the", "string", "value", "to", "the", "value", "at", "key", ".", "If", "key", "doesn", "t", "already", "exist", "create", "it", "with", "a", "value", "of", "value", ".", "Returns", "the", "new", "length", "of", "the", "value", "at", "key", ...
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L553-L565
72squared/redpipe
redpipe/keyspaces.py
String.strlen
def strlen(self, name): """ Return the number of bytes stored in the value of the key :param name: str the name of the redis key :return: Future() """ with self.pipe as pipe: return pipe.strlen(self.redis_key(name))
python
def strlen(self, name): """ Return the number of bytes stored in the value of the key :param name: str the name of the redis key :return: Future() """ with self.pipe as pipe: return pipe.strlen(self.redis_key(name))
[ "def", "strlen", "(", "self", ",", "name", ")", ":", "with", "self", ".", "pipe", "as", "pipe", ":", "return", "pipe", ".", "strlen", "(", "self", ".", "redis_key", "(", "name", ")", ")" ]
Return the number of bytes stored in the value of the key :param name: str the name of the redis key :return: Future()
[ "Return", "the", "number", "of", "bytes", "stored", "in", "the", "value", "of", "the", "key" ]
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L567-L575
72squared/redpipe
redpipe/keyspaces.py
String.substr
def substr(self, name, start, end=-1): """ Return a substring of the string at key ``name``. ``start`` and ``end`` are 0-based integers specifying the portion of the string to return. :param name: str the name of the redis key :param start: int :param end: int :return: Future() """ with self.pipe as pipe: f = Future() res = pipe.substr(self.redis_key(name), start=start, end=end) def cb(): f.set(self.valueparse.decode(res.result)) pipe.on_execute(cb) return f
python
def substr(self, name, start, end=-1): """ Return a substring of the string at key ``name``. ``start`` and ``end`` are 0-based integers specifying the portion of the string to return. :param name: str the name of the redis key :param start: int :param end: int :return: Future() """ with self.pipe as pipe: f = Future() res = pipe.substr(self.redis_key(name), start=start, end=end) def cb(): f.set(self.valueparse.decode(res.result)) pipe.on_execute(cb) return f
[ "def", "substr", "(", "self", ",", "name", ",", "start", ",", "end", "=", "-", "1", ")", ":", "with", "self", ".", "pipe", "as", "pipe", ":", "f", "=", "Future", "(", ")", "res", "=", "pipe", ".", "substr", "(", "self", ".", "redis_key", "(", ...
Return a substring of the string at key ``name``. ``start`` and ``end`` are 0-based integers specifying the portion of the string to return. :param name: str the name of the redis key :param start: int :param end: int :return: Future()
[ "Return", "a", "substring", "of", "the", "string", "at", "key", "name", ".", "start", "and", "end", "are", "0", "-", "based", "integers", "specifying", "the", "portion", "of", "the", "string", "to", "return", "." ]
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L577-L595
72squared/redpipe
redpipe/keyspaces.py
String.setrange
def setrange(self, name, offset, value): """ Overwrite bytes in the value of ``name`` starting at ``offset`` with ``value``. If ``offset`` plus the length of ``value`` exceeds the length of the original value, the new value will be larger than before. If ``offset`` exceeds the length of the original value, null bytes will be used to pad between the end of the previous value and the start of what's being injected. Returns the length of the new string. :param name: str the name of the redis key :param offset: int :param value: str :return: Future() """ with self.pipe as pipe: return pipe.setrange(self.redis_key(name), offset, value)
python
def setrange(self, name, offset, value): """ Overwrite bytes in the value of ``name`` starting at ``offset`` with ``value``. If ``offset`` plus the length of ``value`` exceeds the length of the original value, the new value will be larger than before. If ``offset`` exceeds the length of the original value, null bytes will be used to pad between the end of the previous value and the start of what's being injected. Returns the length of the new string. :param name: str the name of the redis key :param offset: int :param value: str :return: Future() """ with self.pipe as pipe: return pipe.setrange(self.redis_key(name), offset, value)
[ "def", "setrange", "(", "self", ",", "name", ",", "offset", ",", "value", ")", ":", "with", "self", ".", "pipe", "as", "pipe", ":", "return", "pipe", ".", "setrange", "(", "self", ".", "redis_key", "(", "name", ")", ",", "offset", ",", "value", ")"...
Overwrite bytes in the value of ``name`` starting at ``offset`` with ``value``. If ``offset`` plus the length of ``value`` exceeds the length of the original value, the new value will be larger than before. If ``offset`` exceeds the length of the original value, null bytes will be used to pad between the end of the previous value and the start of what's being injected. Returns the length of the new string. :param name: str the name of the redis key :param offset: int :param value: str :return: Future()
[ "Overwrite", "bytes", "in", "the", "value", "of", "name", "starting", "at", "offset", "with", "value", ".", "If", "offset", "plus", "the", "length", "of", "value", "exceeds", "the", "length", "of", "the", "original", "value", "the", "new", "value", "will",...
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L597-L614
72squared/redpipe
redpipe/keyspaces.py
String.setbit
def setbit(self, name, offset, value): """ Flag the ``offset`` in the key as ``value``. Returns a boolean indicating the previous value of ``offset``. :param name: str the name of the redis key :param offset: int :param value: :return: Future() """ with self.pipe as pipe: return pipe.setbit(self.redis_key(name), offset, value)
python
def setbit(self, name, offset, value): """ Flag the ``offset`` in the key as ``value``. Returns a boolean indicating the previous value of ``offset``. :param name: str the name of the redis key :param offset: int :param value: :return: Future() """ with self.pipe as pipe: return pipe.setbit(self.redis_key(name), offset, value)
[ "def", "setbit", "(", "self", ",", "name", ",", "offset", ",", "value", ")", ":", "with", "self", ".", "pipe", "as", "pipe", ":", "return", "pipe", ".", "setbit", "(", "self", ".", "redis_key", "(", "name", ")", ",", "offset", ",", "value", ")" ]
Flag the ``offset`` in the key as ``value``. Returns a boolean indicating the previous value of ``offset``. :param name: str the name of the redis key :param offset: int :param value: :return: Future()
[ "Flag", "the", "offset", "in", "the", "key", "as", "value", ".", "Returns", "a", "boolean", "indicating", "the", "previous", "value", "of", "offset", "." ]
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L616-L627
72squared/redpipe
redpipe/keyspaces.py
String.getbit
def getbit(self, name, offset): """ Returns a boolean indicating the value of ``offset`` in key :param name: str the name of the redis key :param offset: int :return: Future() """ with self.pipe as pipe: return pipe.getbit(self.redis_key(name), offset)
python
def getbit(self, name, offset): """ Returns a boolean indicating the value of ``offset`` in key :param name: str the name of the redis key :param offset: int :return: Future() """ with self.pipe as pipe: return pipe.getbit(self.redis_key(name), offset)
[ "def", "getbit", "(", "self", ",", "name", ",", "offset", ")", ":", "with", "self", ".", "pipe", "as", "pipe", ":", "return", "pipe", ".", "getbit", "(", "self", ".", "redis_key", "(", "name", ")", ",", "offset", ")" ]
Returns a boolean indicating the value of ``offset`` in key :param name: str the name of the redis key :param offset: int :return: Future()
[ "Returns", "a", "boolean", "indicating", "the", "value", "of", "offset", "in", "key" ]
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L629-L638
72squared/redpipe
redpipe/keyspaces.py
String.bitcount
def bitcount(self, name, start=None, end=None): """ Returns the count of set bits in the value of ``key``. Optional ``start`` and ``end`` paramaters indicate which bytes to consider :param name: str the name of the redis key :param start: int :param end: int :return: Future() """ with self.pipe as pipe: return pipe.bitcount(self.redis_key(name), start=start, end=end)
python
def bitcount(self, name, start=None, end=None): """ Returns the count of set bits in the value of ``key``. Optional ``start`` and ``end`` paramaters indicate which bytes to consider :param name: str the name of the redis key :param start: int :param end: int :return: Future() """ with self.pipe as pipe: return pipe.bitcount(self.redis_key(name), start=start, end=end)
[ "def", "bitcount", "(", "self", ",", "name", ",", "start", "=", "None", ",", "end", "=", "None", ")", ":", "with", "self", ".", "pipe", "as", "pipe", ":", "return", "pipe", ".", "bitcount", "(", "self", ".", "redis_key", "(", "name", ")", ",", "s...
Returns the count of set bits in the value of ``key``. Optional ``start`` and ``end`` paramaters indicate which bytes to consider :param name: str the name of the redis key :param start: int :param end: int :return: Future()
[ "Returns", "the", "count", "of", "set", "bits", "in", "the", "value", "of", "key", ".", "Optional", "start", "and", "end", "paramaters", "indicate", "which", "bytes", "to", "consider" ]
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L640-L651
72squared/redpipe
redpipe/keyspaces.py
String.incr
def incr(self, name, amount=1): """ increment the value for key by 1 :param name: str the name of the redis key :param amount: int :return: Future() """ with self.pipe as pipe: return pipe.incr(self.redis_key(name), amount=amount)
python
def incr(self, name, amount=1): """ increment the value for key by 1 :param name: str the name of the redis key :param amount: int :return: Future() """ with self.pipe as pipe: return pipe.incr(self.redis_key(name), amount=amount)
[ "def", "incr", "(", "self", ",", "name", ",", "amount", "=", "1", ")", ":", "with", "self", ".", "pipe", "as", "pipe", ":", "return", "pipe", ".", "incr", "(", "self", ".", "redis_key", "(", "name", ")", ",", "amount", "=", "amount", ")" ]
increment the value for key by 1 :param name: str the name of the redis key :param amount: int :return: Future()
[ "increment", "the", "value", "for", "key", "by", "1" ]
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L653-L662
72squared/redpipe
redpipe/keyspaces.py
String.incrby
def incrby(self, name, amount=1): """ increment the value for key by value: int :param name: str the name of the redis key :param amount: int :return: Future() """ with self.pipe as pipe: return pipe.incrby(self.redis_key(name), amount=amount)
python
def incrby(self, name, amount=1): """ increment the value for key by value: int :param name: str the name of the redis key :param amount: int :return: Future() """ with self.pipe as pipe: return pipe.incrby(self.redis_key(name), amount=amount)
[ "def", "incrby", "(", "self", ",", "name", ",", "amount", "=", "1", ")", ":", "with", "self", ".", "pipe", "as", "pipe", ":", "return", "pipe", ".", "incrby", "(", "self", ".", "redis_key", "(", "name", ")", ",", "amount", "=", "amount", ")" ]
increment the value for key by value: int :param name: str the name of the redis key :param amount: int :return: Future()
[ "increment", "the", "value", "for", "key", "by", "value", ":", "int" ]
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L664-L673
72squared/redpipe
redpipe/keyspaces.py
String.incrbyfloat
def incrbyfloat(self, name, amount=1.0): """ increment the value for key by value: float :param name: str the name of the redis key :param amount: int :return: Future() """ with self.pipe as pipe: return pipe.incrbyfloat(self.redis_key(name), amount=amount)
python
def incrbyfloat(self, name, amount=1.0): """ increment the value for key by value: float :param name: str the name of the redis key :param amount: int :return: Future() """ with self.pipe as pipe: return pipe.incrbyfloat(self.redis_key(name), amount=amount)
[ "def", "incrbyfloat", "(", "self", ",", "name", ",", "amount", "=", "1.0", ")", ":", "with", "self", ".", "pipe", "as", "pipe", ":", "return", "pipe", ".", "incrbyfloat", "(", "self", ".", "redis_key", "(", "name", ")", ",", "amount", "=", "amount", ...
increment the value for key by value: float :param name: str the name of the redis key :param amount: int :return: Future()
[ "increment", "the", "value", "for", "key", "by", "value", ":", "float" ]
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L675-L684
72squared/redpipe
redpipe/keyspaces.py
Set.sdiffstore
def sdiffstore(self, dest, *keys): """ Store the difference of sets specified by ``keys`` into a new set named ``dest``. Returns the number of keys in the new set. """ keys = [self.redis_key(k) for k in self._parse_values(keys)] with self.pipe as pipe: return pipe.sdiffstore(self.redis_key(dest), *keys)
python
def sdiffstore(self, dest, *keys): """ Store the difference of sets specified by ``keys`` into a new set named ``dest``. Returns the number of keys in the new set. """ keys = [self.redis_key(k) for k in self._parse_values(keys)] with self.pipe as pipe: return pipe.sdiffstore(self.redis_key(dest), *keys)
[ "def", "sdiffstore", "(", "self", ",", "dest", ",", "*", "keys", ")", ":", "keys", "=", "[", "self", ".", "redis_key", "(", "k", ")", "for", "k", "in", "self", ".", "_parse_values", "(", "keys", ")", "]", "with", "self", ".", "pipe", "as", "pipe"...
Store the difference of sets specified by ``keys`` into a new set named ``dest``. Returns the number of keys in the new set.
[ "Store", "the", "difference", "of", "sets", "specified", "by", "keys", "into", "a", "new", "set", "named", "dest", ".", "Returns", "the", "number", "of", "keys", "in", "the", "new", "set", "." ]
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L950-L958
72squared/redpipe
redpipe/keyspaces.py
Set.sunionstore
def sunionstore(self, dest, keys, *args): """ Store the union of sets specified by ``keys`` into a new set named ``dest``. Returns the number of members in the new set. """ keys = [self.redis_key(k) for k in self._parse_values(keys, args)] with self.pipe as pipe: return pipe.sunionstore(self.redis_key(dest), *keys)
python
def sunionstore(self, dest, keys, *args): """ Store the union of sets specified by ``keys`` into a new set named ``dest``. Returns the number of members in the new set. """ keys = [self.redis_key(k) for k in self._parse_values(keys, args)] with self.pipe as pipe: return pipe.sunionstore(self.redis_key(dest), *keys)
[ "def", "sunionstore", "(", "self", ",", "dest", ",", "keys", ",", "*", "args", ")", ":", "keys", "=", "[", "self", ".", "redis_key", "(", "k", ")", "for", "k", "in", "self", ".", "_parse_values", "(", "keys", ",", "args", ")", "]", "with", "self"...
Store the union of sets specified by ``keys`` into a new set named ``dest``. Returns the number of members in the new set.
[ "Store", "the", "union", "of", "sets", "specified", "by", "keys", "into", "a", "new", "set", "named", "dest", ".", "Returns", "the", "number", "of", "members", "in", "the", "new", "set", "." ]
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L1008-L1015
72squared/redpipe
redpipe/keyspaces.py
Set.sadd
def sadd(self, name, values, *args): """ Add the specified members to the Set. :param name: str the name of the redis key :param values: a list of values or a simple value. :return: Future() """ with self.pipe as pipe: values = [self.valueparse.encode(v) for v in self._parse_values(values, args)] return pipe.sadd(self.redis_key(name), *values)
python
def sadd(self, name, values, *args): """ Add the specified members to the Set. :param name: str the name of the redis key :param values: a list of values or a simple value. :return: Future() """ with self.pipe as pipe: values = [self.valueparse.encode(v) for v in self._parse_values(values, args)] return pipe.sadd(self.redis_key(name), *values)
[ "def", "sadd", "(", "self", ",", "name", ",", "values", ",", "*", "args", ")", ":", "with", "self", ".", "pipe", "as", "pipe", ":", "values", "=", "[", "self", ".", "valueparse", ".", "encode", "(", "v", ")", "for", "v", "in", "self", ".", "_pa...
Add the specified members to the Set. :param name: str the name of the redis key :param values: a list of values or a simple value. :return: Future()
[ "Add", "the", "specified", "members", "to", "the", "Set", "." ]
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L1017-L1028
72squared/redpipe
redpipe/keyspaces.py
Set.scard
def scard(self, name): """ How many items in the set? :param name: str the name of the redis key :return: Future() """ with self.pipe as pipe: return pipe.scard(self.redis_key(name))
python
def scard(self, name): """ How many items in the set? :param name: str the name of the redis key :return: Future() """ with self.pipe as pipe: return pipe.scard(self.redis_key(name))
[ "def", "scard", "(", "self", ",", "name", ")", ":", "with", "self", ".", "pipe", "as", "pipe", ":", "return", "pipe", ".", "scard", "(", "self", ".", "redis_key", "(", "name", ")", ")" ]
How many items in the set? :param name: str the name of the redis key :return: Future()
[ "How", "many", "items", "in", "the", "set?" ]
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L1077-L1085
72squared/redpipe
redpipe/keyspaces.py
Set.sismember
def sismember(self, name, value): """ Is the provided value is in the ``Set``? :param name: str the name of the redis key :param value: str :return: Future() """ with self.pipe as pipe: return pipe.sismember(self.redis_key(name), self.valueparse.encode(value))
python
def sismember(self, name, value): """ Is the provided value is in the ``Set``? :param name: str the name of the redis key :param value: str :return: Future() """ with self.pipe as pipe: return pipe.sismember(self.redis_key(name), self.valueparse.encode(value))
[ "def", "sismember", "(", "self", ",", "name", ",", "value", ")", ":", "with", "self", ".", "pipe", "as", "pipe", ":", "return", "pipe", ".", "sismember", "(", "self", ".", "redis_key", "(", "name", ")", ",", "self", ".", "valueparse", ".", "encode", ...
Is the provided value is in the ``Set``? :param name: str the name of the redis key :param value: str :return: Future()
[ "Is", "the", "provided", "value", "is", "in", "the", "Set", "?" ]
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L1087-L1097
72squared/redpipe
redpipe/keyspaces.py
Set.srandmember
def srandmember(self, name, number=None): """ Return a random member of the set. :param name: str the name of the redis key :return: Future() """ with self.pipe as pipe: f = Future() res = pipe.srandmember(self.redis_key(name), number=number) def cb(): if number is None: f.set(self.valueparse.decode(res.result)) else: f.set([self.valueparse.decode(v) for v in res.result]) pipe.on_execute(cb) return f
python
def srandmember(self, name, number=None): """ Return a random member of the set. :param name: str the name of the redis key :return: Future() """ with self.pipe as pipe: f = Future() res = pipe.srandmember(self.redis_key(name), number=number) def cb(): if number is None: f.set(self.valueparse.decode(res.result)) else: f.set([self.valueparse.decode(v) for v in res.result]) pipe.on_execute(cb) return f
[ "def", "srandmember", "(", "self", ",", "name", ",", "number", "=", "None", ")", ":", "with", "self", ".", "pipe", "as", "pipe", ":", "f", "=", "Future", "(", ")", "res", "=", "pipe", ".", "srandmember", "(", "self", ".", "redis_key", "(", "name", ...
Return a random member of the set. :param name: str the name of the redis key :return: Future()
[ "Return", "a", "random", "member", "of", "the", "set", "." ]
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L1099-L1117
72squared/redpipe
redpipe/keyspaces.py
Set.sscan
def sscan(self, name, cursor=0, match=None, count=None): """ Incrementally return lists of elements in a set. Also return a cursor indicating the scan position. ``match`` allows for filtering the keys by pattern ``count`` allows for hint the minimum number of returns :param name: str the name of the redis key :param cursor: int :param match: str :param count: int """ with self.pipe as pipe: f = Future() res = pipe.sscan(self.redis_key(name), cursor=cursor, match=match, count=count) def cb(): f.set((res[0], [self.valueparse.decode(v) for v in res[1]])) pipe.on_execute(cb) return f
python
def sscan(self, name, cursor=0, match=None, count=None): """ Incrementally return lists of elements in a set. Also return a cursor indicating the scan position. ``match`` allows for filtering the keys by pattern ``count`` allows for hint the minimum number of returns :param name: str the name of the redis key :param cursor: int :param match: str :param count: int """ with self.pipe as pipe: f = Future() res = pipe.sscan(self.redis_key(name), cursor=cursor, match=match, count=count) def cb(): f.set((res[0], [self.valueparse.decode(v) for v in res[1]])) pipe.on_execute(cb) return f
[ "def", "sscan", "(", "self", ",", "name", ",", "cursor", "=", "0", ",", "match", "=", "None", ",", "count", "=", "None", ")", ":", "with", "self", ".", "pipe", "as", "pipe", ":", "f", "=", "Future", "(", ")", "res", "=", "pipe", ".", "sscan", ...
Incrementally return lists of elements in a set. Also return a cursor indicating the scan position. ``match`` allows for filtering the keys by pattern ``count`` allows for hint the minimum number of returns :param name: str the name of the redis key :param cursor: int :param match: str :param count: int
[ "Incrementally", "return", "lists", "of", "elements", "in", "a", "set", ".", "Also", "return", "a", "cursor", "indicating", "the", "scan", "position", "." ]
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L1119-L1142
72squared/redpipe
redpipe/keyspaces.py
Set.sscan_iter
def sscan_iter(self, name, match=None, count=None): """ Make an iterator using the SSCAN command so that the client doesn't need to remember the cursor position. ``match`` allows for filtering the keys by pattern ``count`` allows for hint the minimum number of returns :param name: str the name of the redis key :param match: str :param count: int """ if self._pipe is not None: raise InvalidOperation('cannot pipeline scan operations') cursor = '0' while cursor != 0: cursor, data = self.sscan(name, cursor=cursor, match=match, count=count) for item in data: yield item
python
def sscan_iter(self, name, match=None, count=None): """ Make an iterator using the SSCAN command so that the client doesn't need to remember the cursor position. ``match`` allows for filtering the keys by pattern ``count`` allows for hint the minimum number of returns :param name: str the name of the redis key :param match: str :param count: int """ if self._pipe is not None: raise InvalidOperation('cannot pipeline scan operations') cursor = '0' while cursor != 0: cursor, data = self.sscan(name, cursor=cursor, match=match, count=count) for item in data: yield item
[ "def", "sscan_iter", "(", "self", ",", "name", ",", "match", "=", "None", ",", "count", "=", "None", ")", ":", "if", "self", ".", "_pipe", "is", "not", "None", ":", "raise", "InvalidOperation", "(", "'cannot pipeline scan operations'", ")", "cursor", "=", ...
Make an iterator using the SSCAN command so that the client doesn't need to remember the cursor position. ``match`` allows for filtering the keys by pattern ``count`` allows for hint the minimum number of returns :param name: str the name of the redis key :param match: str :param count: int
[ "Make", "an", "iterator", "using", "the", "SSCAN", "command", "so", "that", "the", "client", "doesn", "t", "need", "to", "remember", "the", "cursor", "position", "." ]
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L1144-L1165
72squared/redpipe
redpipe/keyspaces.py
List.blpop
def blpop(self, keys, timeout=0): """ LPOP a value off of the first non-empty list named in the ``keys`` list. If none of the lists in ``keys`` has a value to LPOP, then block for ``timeout`` seconds, or until a value gets pushed on to one of the lists. If timeout is 0, then block indefinitely. """ map = {self.redis_key(k): k for k in self._parse_values(keys)} keys = map.keys() with self.pipe as pipe: f = Future() res = pipe.blpop(keys, timeout=timeout) def cb(): if res.result: k = map[res.result[0]] v = self.valueparse.decode(res.result[1]) f.set((k, v)) else: f.set(res.result) pipe.on_execute(cb) return f
python
def blpop(self, keys, timeout=0): """ LPOP a value off of the first non-empty list named in the ``keys`` list. If none of the lists in ``keys`` has a value to LPOP, then block for ``timeout`` seconds, or until a value gets pushed on to one of the lists. If timeout is 0, then block indefinitely. """ map = {self.redis_key(k): k for k in self._parse_values(keys)} keys = map.keys() with self.pipe as pipe: f = Future() res = pipe.blpop(keys, timeout=timeout) def cb(): if res.result: k = map[res.result[0]] v = self.valueparse.decode(res.result[1]) f.set((k, v)) else: f.set(res.result) pipe.on_execute(cb) return f
[ "def", "blpop", "(", "self", ",", "keys", ",", "timeout", "=", "0", ")", ":", "map", "=", "{", "self", ".", "redis_key", "(", "k", ")", ":", "k", "for", "k", "in", "self", ".", "_parse_values", "(", "keys", ")", "}", "keys", "=", "map", ".", ...
LPOP a value off of the first non-empty list named in the ``keys`` list. If none of the lists in ``keys`` has a value to LPOP, then block for ``timeout`` seconds, or until a value gets pushed on to one of the lists. If timeout is 0, then block indefinitely.
[ "LPOP", "a", "value", "off", "of", "the", "first", "non", "-", "empty", "list", "named", "in", "the", "keys", "list", "." ]
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L1173-L1201
72squared/redpipe
redpipe/keyspaces.py
List.llen
def llen(self, name): """ Returns the length of the list. :param name: str the name of the redis key :return: Future() """ with self.pipe as pipe: return pipe.llen(self.redis_key(name))
python
def llen(self, name): """ Returns the length of the list. :param name: str the name of the redis key :return: Future() """ with self.pipe as pipe: return pipe.llen(self.redis_key(name))
[ "def", "llen", "(", "self", ",", "name", ")", ":", "with", "self", ".", "pipe", "as", "pipe", ":", "return", "pipe", ".", "llen", "(", "self", ".", "redis_key", "(", "name", ")", ")" ]
Returns the length of the list. :param name: str the name of the redis key :return: Future()
[ "Returns", "the", "length", "of", "the", "list", "." ]
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L1253-L1261
72squared/redpipe
redpipe/keyspaces.py
List.lrange
def lrange(self, name, start, stop): """ Returns a range of items. :param name: str the name of the redis key :param start: integer representing the start index of the range :param stop: integer representing the size of the list. :return: Future() """ with self.pipe as pipe: f = Future() res = pipe.lrange(self.redis_key(name), start, stop) def cb(): f.set([self.valueparse.decode(v) for v in res.result]) pipe.on_execute(cb) return f
python
def lrange(self, name, start, stop): """ Returns a range of items. :param name: str the name of the redis key :param start: integer representing the start index of the range :param stop: integer representing the size of the list. :return: Future() """ with self.pipe as pipe: f = Future() res = pipe.lrange(self.redis_key(name), start, stop) def cb(): f.set([self.valueparse.decode(v) for v in res.result]) pipe.on_execute(cb) return f
[ "def", "lrange", "(", "self", ",", "name", ",", "start", ",", "stop", ")", ":", "with", "self", ".", "pipe", "as", "pipe", ":", "f", "=", "Future", "(", ")", "res", "=", "pipe", ".", "lrange", "(", "self", ".", "redis_key", "(", "name", ")", ",...
Returns a range of items. :param name: str the name of the redis key :param start: integer representing the start index of the range :param stop: integer representing the size of the list. :return: Future()
[ "Returns", "a", "range", "of", "items", "." ]
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L1263-L1280
72squared/redpipe
redpipe/keyspaces.py
List.rpush
def rpush(self, name, *values): """ Push the value into the list from the *right* side :param name: str the name of the redis key :param values: a list of values or single value to push :return: Future() """ with self.pipe as pipe: v_encode = self.valueparse.encode values = [v_encode(v) for v in self._parse_values(values)] return pipe.rpush(self.redis_key(name), *values)
python
def rpush(self, name, *values): """ Push the value into the list from the *right* side :param name: str the name of the redis key :param values: a list of values or single value to push :return: Future() """ with self.pipe as pipe: v_encode = self.valueparse.encode values = [v_encode(v) for v in self._parse_values(values)] return pipe.rpush(self.redis_key(name), *values)
[ "def", "rpush", "(", "self", ",", "name", ",", "*", "values", ")", ":", "with", "self", ".", "pipe", "as", "pipe", ":", "v_encode", "=", "self", ".", "valueparse", ".", "encode", "values", "=", "[", "v_encode", "(", "v", ")", "for", "v", "in", "s...
Push the value into the list from the *right* side :param name: str the name of the redis key :param values: a list of values or single value to push :return: Future()
[ "Push", "the", "value", "into", "the", "list", "from", "the", "*", "right", "*", "side" ]
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L1295-L1306
72squared/redpipe
redpipe/keyspaces.py
List.lpop
def lpop(self, name): """ Pop the first object from the left. :param name: str the name of the redis key :return: Future() """ with self.pipe as pipe: f = Future() res = pipe.lpop(self.redis_key(name)) def cb(): f.set(self.valueparse.decode(res.result)) pipe.on_execute(cb) return f
python
def lpop(self, name): """ Pop the first object from the left. :param name: str the name of the redis key :return: Future() """ with self.pipe as pipe: f = Future() res = pipe.lpop(self.redis_key(name)) def cb(): f.set(self.valueparse.decode(res.result)) pipe.on_execute(cb) return f
[ "def", "lpop", "(", "self", ",", "name", ")", ":", "with", "self", ".", "pipe", "as", "pipe", ":", "f", "=", "Future", "(", ")", "res", "=", "pipe", ".", "lpop", "(", "self", ".", "redis_key", "(", "name", ")", ")", "def", "cb", "(", ")", ":"...
Pop the first object from the left. :param name: str the name of the redis key :return: Future()
[ "Pop", "the", "first", "object", "from", "the", "left", "." ]
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L1308-L1324
72squared/redpipe
redpipe/keyspaces.py
List.rpoplpush
def rpoplpush(self, src, dst): """ RPOP a value off of the ``src`` list and atomically LPUSH it on to the ``dst`` list. Returns the value. """ with self.pipe as pipe: f = Future() res = pipe.rpoplpush(self.redis_key(src), self.redis_key(dst)) def cb(): f.set(self.valueparse.decode(res.result)) pipe.on_execute(cb) return f
python
def rpoplpush(self, src, dst): """ RPOP a value off of the ``src`` list and atomically LPUSH it on to the ``dst`` list. Returns the value. """ with self.pipe as pipe: f = Future() res = pipe.rpoplpush(self.redis_key(src), self.redis_key(dst)) def cb(): f.set(self.valueparse.decode(res.result)) pipe.on_execute(cb) return f
[ "def", "rpoplpush", "(", "self", ",", "src", ",", "dst", ")", ":", "with", "self", ".", "pipe", "as", "pipe", ":", "f", "=", "Future", "(", ")", "res", "=", "pipe", ".", "rpoplpush", "(", "self", ".", "redis_key", "(", "src", ")", ",", "self", ...
RPOP a value off of the ``src`` list and atomically LPUSH it on to the ``dst`` list. Returns the value.
[ "RPOP", "a", "value", "off", "of", "the", "src", "list", "and", "atomically", "LPUSH", "it", "on", "to", "the", "dst", "list", ".", "Returns", "the", "value", "." ]
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L1343-L1356
72squared/redpipe
redpipe/keyspaces.py
List.lrem
def lrem(self, name, value, num=1): """ Remove first occurrence of value. Can't use redis-py interface. It's inconstistent between redis.Redis and redis.StrictRedis in terms of the kwargs. Better to use the underlying execute_command instead. :param name: str the name of the redis key :param num: :param value: :return: Future() """ with self.pipe as pipe: value = self.valueparse.encode(value) return pipe.execute_command('LREM', self.redis_key(name), num, value)
python
def lrem(self, name, value, num=1): """ Remove first occurrence of value. Can't use redis-py interface. It's inconstistent between redis.Redis and redis.StrictRedis in terms of the kwargs. Better to use the underlying execute_command instead. :param name: str the name of the redis key :param num: :param value: :return: Future() """ with self.pipe as pipe: value = self.valueparse.encode(value) return pipe.execute_command('LREM', self.redis_key(name), num, value)
[ "def", "lrem", "(", "self", ",", "name", ",", "value", ",", "num", "=", "1", ")", ":", "with", "self", ".", "pipe", "as", "pipe", ":", "value", "=", "self", ".", "valueparse", ".", "encode", "(", "value", ")", "return", "pipe", ".", "execute_comman...
Remove first occurrence of value. Can't use redis-py interface. It's inconstistent between redis.Redis and redis.StrictRedis in terms of the kwargs. Better to use the underlying execute_command instead. :param name: str the name of the redis key :param num: :param value: :return: Future()
[ "Remove", "first", "occurrence", "of", "value", "." ]
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L1358-L1374
72squared/redpipe
redpipe/keyspaces.py
List.ltrim
def ltrim(self, name, start, end): """ Trim the list from start to end. :param name: str the name of the redis key :param start: :param end: :return: Future() """ with self.pipe as pipe: return pipe.ltrim(self.redis_key(name), start, end)
python
def ltrim(self, name, start, end): """ Trim the list from start to end. :param name: str the name of the redis key :param start: :param end: :return: Future() """ with self.pipe as pipe: return pipe.ltrim(self.redis_key(name), start, end)
[ "def", "ltrim", "(", "self", ",", "name", ",", "start", ",", "end", ")", ":", "with", "self", ".", "pipe", "as", "pipe", ":", "return", "pipe", ".", "ltrim", "(", "self", ".", "redis_key", "(", "name", ")", ",", "start", ",", "end", ")" ]
Trim the list from start to end. :param name: str the name of the redis key :param start: :param end: :return: Future()
[ "Trim", "the", "list", "from", "start", "to", "end", "." ]
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L1376-L1386
72squared/redpipe
redpipe/keyspaces.py
List.lset
def lset(self, name, index, value): """ Set the value in the list at index *idx* :param name: str the name of the redis key :param value: :param index: :return: Future() """ with self.pipe as pipe: value = self.valueparse.encode(value) return pipe.lset(self.redis_key(name), index, value)
python
def lset(self, name, index, value): """ Set the value in the list at index *idx* :param name: str the name of the redis key :param value: :param index: :return: Future() """ with self.pipe as pipe: value = self.valueparse.encode(value) return pipe.lset(self.redis_key(name), index, value)
[ "def", "lset", "(", "self", ",", "name", ",", "index", ",", "value", ")", ":", "with", "self", ".", "pipe", "as", "pipe", ":", "value", "=", "self", ".", "valueparse", ".", "encode", "(", "value", ")", "return", "pipe", ".", "lset", "(", "self", ...
Set the value in the list at index *idx* :param name: str the name of the redis key :param value: :param index: :return: Future()
[ "Set", "the", "value", "in", "the", "list", "at", "index", "*", "idx", "*" ]
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L1406-L1417
72squared/redpipe
redpipe/keyspaces.py
SortedSet.zadd
def zadd(self, name, members, score=1, nx=False, xx=False, ch=False, incr=False): """ Add members in the set and assign them the score. :param name: str the name of the redis key :param members: a list of item or a single item :param score: the score the assign to the item(s) :param nx: :param xx: :param ch: :param incr: :return: Future() """ if nx: _args = ['NX'] elif xx: _args = ['XX'] else: _args = [] if ch: _args.append('CH') if incr: _args.append('INCR') if isinstance(members, dict): for member, score in members.items(): _args += [score, self.valueparse.encode(member)] else: _args += [score, self.valueparse.encode(members)] if nx and xx: raise InvalidOperation('cannot specify nx and xx at the same time') with self.pipe as pipe: return pipe.execute_command('ZADD', self.redis_key(name), *_args)
python
def zadd(self, name, members, score=1, nx=False, xx=False, ch=False, incr=False): """ Add members in the set and assign them the score. :param name: str the name of the redis key :param members: a list of item or a single item :param score: the score the assign to the item(s) :param nx: :param xx: :param ch: :param incr: :return: Future() """ if nx: _args = ['NX'] elif xx: _args = ['XX'] else: _args = [] if ch: _args.append('CH') if incr: _args.append('INCR') if isinstance(members, dict): for member, score in members.items(): _args += [score, self.valueparse.encode(member)] else: _args += [score, self.valueparse.encode(members)] if nx and xx: raise InvalidOperation('cannot specify nx and xx at the same time') with self.pipe as pipe: return pipe.execute_command('ZADD', self.redis_key(name), *_args)
[ "def", "zadd", "(", "self", ",", "name", ",", "members", ",", "score", "=", "1", ",", "nx", "=", "False", ",", "xx", "=", "False", ",", "ch", "=", "False", ",", "incr", "=", "False", ")", ":", "if", "nx", ":", "_args", "=", "[", "'NX'", "]", ...
Add members in the set and assign them the score. :param name: str the name of the redis key :param members: a list of item or a single item :param score: the score the assign to the item(s) :param nx: :param xx: :param ch: :param incr: :return: Future()
[ "Add", "members", "in", "the", "set", "and", "assign", "them", "the", "score", "." ]
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L1425-L1462
72squared/redpipe
redpipe/keyspaces.py
SortedSet.zincrby
def zincrby(self, name, value, amount=1): """ Increment the score of the item by `value` :param name: str the name of the redis key :param value: :param amount: :return: """ with self.pipe as pipe: return pipe.zincrby(self.redis_key(name), value=self.valueparse.encode(value), amount=amount)
python
def zincrby(self, name, value, amount=1): """ Increment the score of the item by `value` :param name: str the name of the redis key :param value: :param amount: :return: """ with self.pipe as pipe: return pipe.zincrby(self.redis_key(name), value=self.valueparse.encode(value), amount=amount)
[ "def", "zincrby", "(", "self", ",", "name", ",", "value", ",", "amount", "=", "1", ")", ":", "with", "self", ".", "pipe", "as", "pipe", ":", "return", "pipe", ".", "zincrby", "(", "self", ".", "redis_key", "(", "name", ")", ",", "value", "=", "se...
Increment the score of the item by `value` :param name: str the name of the redis key :param value: :param amount: :return:
[ "Increment", "the", "score", "of", "the", "item", "by", "value" ]
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L1478-L1490
72squared/redpipe
redpipe/keyspaces.py
SortedSet.zrevrank
def zrevrank(self, name, value): """ Returns the ranking in reverse order for the member :param name: str the name of the redis key :param member: str """ with self.pipe as pipe: return pipe.zrevrank(self.redis_key(name), self.valueparse.encode(value))
python
def zrevrank(self, name, value): """ Returns the ranking in reverse order for the member :param name: str the name of the redis key :param member: str """ with self.pipe as pipe: return pipe.zrevrank(self.redis_key(name), self.valueparse.encode(value))
[ "def", "zrevrank", "(", "self", ",", "name", ",", "value", ")", ":", "with", "self", ".", "pipe", "as", "pipe", ":", "return", "pipe", ".", "zrevrank", "(", "self", ".", "redis_key", "(", "name", ")", ",", "self", ".", "valueparse", ".", "encode", ...
Returns the ranking in reverse order for the member :param name: str the name of the redis key :param member: str
[ "Returns", "the", "ranking", "in", "reverse", "order", "for", "the", "member" ]
train
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L1492-L1501