code
string
signature
string
docstring
string
loss_without_docstring
float64
loss_with_docstring
float64
factor
float64
p = np.power(z, 1. / self.power) return p
def inverse(self, z)
Inverse of the power transform link function Parameters ---------- `z` : array-like Value of the transformed mean parameters at `p` Returns ------- `p` : array Mean parameters Notes ----- g^(-1)(z`) = `z`**(1/`power`)
9.658315
6.584755
1.466769
return self.power * np.power(p, self.power - 1)
def deriv(self, p)
Derivative of the power transform Parameters ---------- p : array-like Mean parameters Returns -------- g'(p) : array Derivative of power transform of `p` Notes ----- g'(`p`) = `power` * `p`**(`power` - 1)
6.642684
4.747916
1.399074
return self.power * (self.power - 1) * np.power(p, self.power - 2)
def deriv2(self, p)
Second derivative of the power transform Parameters ---------- p : array-like Mean parameters Returns -------- g''(p) : array Second derivative of the power transform of `p` Notes ----- g''(`p`) = `power` * (`power` - 1) ...
4.541001
3.011153
1.50806
return np.power(z, (1 - self.power)/self.power) / self.power
def inverse_deriv(self, z)
Derivative of the inverse of the power transform Parameters ---------- z : array-like `z` is usually the linear predictor for a GLM or GEE model. Returns ------- g^(-1)'(z) : array The value of the derivative of the inverse of the power transform...
7.495506
12.126756
0.618097
p = self._clean(p) return 1. / self.dbn.pdf(self.dbn.ppf(p))
def deriv(self, p)
Derivative of CDF link Parameters ---------- p : array-like mean parameters Returns ------- g'(p) : array The derivative of CDF transform at `p` Notes ----- g'(`p`) = 1./ `dbn`.pdf(`dbn`.ppf(`p`))
9.058982
3.891714
2.327762
from statsmodels.tools.numdiff import approx_fprime p = np.atleast_1d(p) # Note: special function for norm.ppf does not support complex return np.diag(approx_fprime(p, self.deriv, centered=True))
def deriv2(self, p)
Second derivative of the link function g''(p) implemented through numerical differentiation
7.519336
7.523905
0.999393
a = np.pi * (p - 0.5) d2 = 2 * np.pi**2 * np.sin(a) / np.cos(a)**3 return d2
def deriv2(self, p)
Second derivative of the Cauchy link function. Parameters ---------- p: array-like Probabilities Returns ------- g''(p) : array Value of the second derivative of Cauchy link function at `p`
4.148437
5.070708
0.818118
p = self._clean(p) return 1. / ((p - 1) * (np.log(1 - p)))
def deriv(self, p)
Derivative of C-Log-Log transform link function Parameters ---------- p : array-like Mean parameters Returns ------- g'(p) : array The derivative of the CLogLog transform link function Notes ----- g'(p) = - 1 / ((p-1)*log...
8.379749
5.548458
1.510284
p = self._clean(p) fl = np.log(1 - p) d2 = -1 / ((1 - p)**2 * fl) d2 *= 1 + 1 / fl return d2
def deriv2(self, p)
Second derivative of the C-Log-Log ink function Parameters ---------- p : array-like Mean parameters Returns ------- g''(p) : array The second derivative of the CLogLog link function
6.964714
8.762305
0.794849
''' Second derivative of the negative binomial link function. Parameters ---------- p : array-like Mean parameters Returns ------- g''(p) : array The second derivative of the negative binomial transform link function ...
def deriv2(self,p)
Second derivative of the negative binomial link function. Parameters ---------- p : array-like Mean parameters Returns ------- g''(p) : array The second derivative of the negative binomial transform link function Notes ...
5.38317
1.625932
3.310822
''' Derivative of the inverse of the negative binomial transform Parameters ----------- z : array-like Usually the linear predictor for a GLM or GEE model Returns ------- g^(-1)'(z) : array The value of the derivative of the inver...
def inverse_deriv(self, z)
Derivative of the inverse of the negative binomial transform Parameters ----------- z : array-like Usually the linear predictor for a GLM or GEE model Returns ------- g^(-1)'(z) : array The value of the derivative of the inverse of the negative ...
8.844493
2.214594
3.99373
try: return self._databases except AttributeError: self._databases = self.einfo().databases return self._databases
def databases(self)
list of databases available from eutils (per einfo query)
5.859485
3.113484
1.88197
if db is None: return EInfoResult(self._qs.einfo()).dblist return EInfoResult(self._qs.einfo({'db': db, 'version': '2.0'})).dbinfo
def einfo(self, db=None)
query the einfo endpoint :param db: string (optional) :rtype: EInfo or EInfoDB object If db is None, the reply is a list of databases, which is returned in an EInfo object (which has a databases() method). If db is not None, the reply is information about the specified ...
9.268534
5.758118
1.609646
esr = ESearchResult(self._qs.esearch({'db': db, 'term': term})) if esr.count > esr.retmax: logger.warning("NCBI found {esr.count} results, but we truncated the reply at {esr.retmax}" " results; see https://github.com/biocommons/eutils/issues/124/".format(esr=...
def esearch(self, db, term)
query the esearch endpoint
7.249032
7.576406
0.95679
db = db.lower() xml = self._qs.efetch({'db': db, 'id': str(id)}) doc = le.XML(xml) if db in ['gene']: return EntrezgeneSet(doc) if db in ['nuccore', 'nucest', 'protein']: # TODO: GBSet is misnamed; it should be GBSeq and get the GBSeq XML node as ...
def efetch(self, db, id)
query the efetch endpoint
6.313598
6.182163
1.02126
if eventObj.type not in (MOUSEMOTION, MOUSEBUTTONUP, MOUSEBUTTONDOWN) or not self._visible: # The button only cares bout mouse-related events (or no events, if it is invisible) return [] retVal = [] hasExited = False if not self.mouseOverButton and sel...
def handleEvent(self, eventObj)
All MOUSEMOTION, MOUSEBUTTONUP, MOUSEBUTTONDOWN event objects created by Pygame should be passed to this method. handleEvent() will detect if the event is relevant to this button and change its state. There are two ways that your code can respond to button-events. One is to inherit the ...
2.818779
2.534088
1.112344
if self._visible: if self.buttonDown: surfaceObj.blit(self.surfaceDown, self._rect) elif self.mouseOverButton: surfaceObj.blit(self.surfaceHighlight, self._rect) else: surfaceObj.blit(self.surfaceNormal, self._rect)
def draw(self, surfaceObj)
Blit the current button's appearance to the surface object.
2.931409
2.690086
1.089708
if self.customSurfaces: self.surfaceNormal = pygame.transform.smoothscale(self.origSurfaceNormal, self._rect.size) self.surfaceDown = pygame.transform.smoothscale(self.origSurfaceDown, self._rect.size) self.surfaceHighlight = pygame.transform.smoothscale(self...
def _update(self)
Redraw the button's Surface object. Call this method when the button has changed appearance.
1.657754
1.573103
1.053811
if downSurface is None: downSurface = normalSurface if highlightSurface is None: highlightSurface = normalSurface if type(normalSurface) == str: self.origSurfaceNormal = pygame.image.load(normalSurface) if type(downSurface) == str: ...
def setSurfaces(self, normalSurface, downSurface=None, highlightSurface=None)
Switch the button to a custom image type of button (rather than a text button). You can specify either a pygame.Surface object or a string of a filename to load for each of the three button appearance states.
1.898503
1.792674
1.059034
# TODO: change the links class attribute in the families to hold # meaningful information instead of a list of links instances such as # [<statsmodels.family.links.Log object at 0x9a4240c>, # <statsmodels.family.links.Power object at 0x9a423ec>, # <statsmodels.family.l...
def _setlink(self, link)
Helper method to set the link for a family. Raises a ValueError exception if the link is not available. Note that the error message might not be that informative because it tells you that the link should be in the base class for the link function. See glm.GLM for a list of appropriate...
5.77483
5.291931
1.091252
r return 1. / (self.link.deriv(mu)**2 * self.variance(mu))
def weights(self, mu)
r""" Weights for IRLS steps Parameters ---------- mu : array-like The transformed mean response variable in the exponential family Returns ------- w : array The weights for the IRLS steps
16.942329
19.526638
0.867652
r loglike = np.sum(freq_weights * (endog * np.log(mu) - mu - special.gammaln(endog + 1))) return scale * loglike
def loglike(self, endog, mu, freq_weights=1., scale=1.)
r""" The log-likelihood function in terms of the fitted mean response. Parameters ---------- endog : array-like Endogenous response variable mu : array-like Fitted mean response variable freq_weights : array-like 1d array of frequency ...
4.760228
5.547285
0.858119
return (endog - mu) / np.sqrt(self.variance(mu)) / scale
def resid_dev(self, endog, mu, scale=1.)
Gaussian deviance residuals Parameters ----------- endog : array-like Endogenous response variable mu : array-like Fitted mean response variable scale : float, optional An optional argument to divide the residuals by scale. The default ...
7.153401
12.23319
0.584754
return np.sum((freq_weights * (endog - mu)**2)) / scale
def deviance(self, endog, mu, freq_weights=1., scale=1.)
Gaussian deviance function Parameters ---------- endog : array-like Endogenous response variable mu : array-like Fitted mean response variable freq_weights : array-like 1d array of frequency weights. The default is 1. scale : float, op...
4.947443
8.734039
0.566455
if isinstance(self.link, L.Power) and self.link.power == 1: # This is just the loglikelihood for classical OLS nobs2 = endog.shape[0] / 2. SSR = np.sum((endog-self.fitted(mu))**2, axis=0) llf = -np.log(SSR) * nobs2 llf -= (1+np.log(np.pi/nobs2...
def loglike(self, endog, mu, freq_weights=1., scale=1.)
The log-likelihood in terms of the fitted mean response. Parameters ---------- endog : array-like Endogenous response variable mu : array-like Fitted mean response variable freq_weights : array-like 1d array of frequency weights. The default i...
5.202494
5.179352
1.004468
r endog_mu = self._clean(endog/mu) return 2*np.sum(freq_weights*((endog-mu)/mu-np.log(endog_mu)))
def deviance(self, endog, mu, freq_weights=1., scale=1.)
r""" Gamma deviance function Parameters ----------- endog : array-like Endogenous response variable mu : array-like Fitted mean response variable freq_weights : array-like 1d array of frequency weights. The default is 1. scale ...
8.755331
9.060802
0.966287
r endog_mu = self._clean(endog / mu) return np.sign(endog - mu) * np.sqrt(-2 * (-(endog - mu)/mu + np.log(endog_mu)))
def resid_dev(self, endog, mu, scale=1.)
r""" Gamma deviance residuals Parameters ----------- endog : array-like Endogenous response variable mu : array-like Fitted mean response variable scale : float, optional An optional argument to divide the residuals by scale. The defau...
10.004321
10.349361
0.966661
r return - 1./scale * np.sum((endog/mu + np.log(mu) + (scale - 1) * np.log(endog) + np.log(scale) + scale * special.gammaln(1./scale)) * freq_weights)
def loglike(self, endog, mu, freq_weights=1., scale=1.)
r""" The log-likelihood function in terms of the fitted mean response. Parameters ---------- endog : array-like Endogenous response variable mu : array-like Fitted mean response variable freq_weights : array-like 1d array of frequency ...
6.594404
7.321396
0.900703
''' Initialize the response variable. Parameters ---------- endog : array Endogenous response variable Returns -------- If `endog` is binary, returns `endog` If `endog` is a 2d array, then the input is assumed to be in the format ...
def initialize(self, endog, freq_weights)
Initialize the response variable. Parameters ---------- endog : array Endogenous response variable Returns -------- If `endog` is binary, returns `endog` If `endog` is a 2d array, then the input is assumed to be in the format (successes, fai...
5.626321
2.70179
2.082442
r''' Deviance function for either Bernoulli or Binomial data. Parameters ---------- endog : array-like Endogenous response variable (already transformed to a probability if appropriate). mu : array Fitted mean response variable ...
def deviance(self, endog, mu, freq_weights=1, scale=1., axis=None)
r''' Deviance function for either Bernoulli or Binomial data. Parameters ---------- endog : array-like Endogenous response variable (already transformed to a probability if appropriate). mu : array Fitted mean response variable freq_we...
3.055517
1.85659
1.645768
r mu = self.link._clean(mu) if np.shape(self.n) == () and self.n == 1: one = np.equal(endog, 1) return np.sign(endog-mu)*np.sqrt(-2 * np.log(one * mu + (1 - one) * (1 - mu)))...
def resid_dev(self, endog, mu, scale=1.)
r""" Binomial deviance residuals Parameters ----------- endog : array-like Endogenous response variable mu : array-like Fitted mean response variable scale : float, optional An optional argument to divide the residuals by scale. The de...
3.842623
3.888746
0.988139
r if np.shape(self.n) == () and self.n == 1: return scale * np.sum((endog * np.log(mu/(1 - mu) + 1e-200) + np.log(1 - mu)) * freq_weights) else: y = endog * self.n # convert back to successes return scale * np.sum((special....
def loglike(self, endog, mu, freq_weights=1, scale=1.)
r""" The log-likelihood function in terms of the fitted mean response. Parameters ---------- endog : array-like Endogenous response variable mu : array-like Fitted mean response variable freq_weights : array-like 1d array of frequency ...
3.163597
3.35636
0.942568
''' The Anscombe residuals Parameters ---------- endog : array-like Endogenous response variable mu : array-like Fitted mean response variable Returns ------- resid_anscombe : array The Anscombe residuals as de...
def resid_anscombe(self, endog, mu)
The Anscombe residuals Parameters ---------- endog : array-like Endogenous response variable mu : array-like Fitted mean response variable Returns ------- resid_anscombe : array The Anscombe residuals as defined below. ...
4.768886
1.787251
2.66828
for entry in self.entries: if entry.uuid == uuid: return entry raise EntryNotFoundError("Entry not found for uuid: %s" % uuid)
def find_by_uuid(self, uuid)
Find an entry by uuid. :raise: EntryNotFoundError
3.171579
2.819734
1.124779
for entry in self.entries: if entry.title == title: return entry raise EntryNotFoundError("Entry not found for title: %s" % title)
def find_by_title(self, title)
Find an entry by exact title. :raise: EntryNotFoundError
3.123904
2.868566
1.089012
entries = [] # Exact matches trump for entry in self.entries: if entry.title == title: entries.append(entry) if entries: return self._filter_entries(entries, ignore_groups) # Case insensitive matches next. title_lower = tit...
def fuzzy_search_by_title(self, title, ignore_groups=None)
Find an entry by by fuzzy match. This will check things such as: * case insensitive matching * typo checks * prefix matches If the ``ignore_groups`` argument is provided, then any matching entries in the ``ignore_groups`` list will not be returned. This ...
2.400787
2.589288
0.9272
configuration = config.Configuration() pegtree = pegnode.parse(self.filestring) for section_node in pegtree: if isinstance(section_node, pegnode.GlobalSection): configuration.globall = self.build_global(section_node) elif isinstance(section_node, ...
def build_configuration(self)
Parse the haproxy config file Raises: Exception: when there are unsupported section Returns: config.Configuration: haproxy config object
2.336828
2.315208
1.009338
config_block_lines = self.__build_config_block( global_node.config_block) return config.Global(config_block=config_block_lines)
def build_global(self, global_node)
parse `global` section, and return the config.Global Args: global_node (TreeNode): `global` section treenode Returns: config.Global: an object
5.619693
6.289046
0.893568
node_lists = [] for line_node in config_block_node: if isinstance(line_node, pegnode.ConfigLine): node_lists.append(self.__build_config(line_node)) elif isinstance(line_node, pegnode.OptionLine): node_lists.append(self.__build_option(line...
def __build_config_block(self, config_block_node)
parse `config_block` in each section Args: config_block_node (TreeNode): Description Returns: [line_node1, line_node2, ...]
1.940963
1.947779
0.996501
proxy_name = defaults_node.defaults_header.proxy_name.text config_block_lines = self.__build_config_block( defaults_node.config_block) return config.Defaults( name=proxy_name, config_block=config_block_lines)
def build_defaults(self, defaults_node)
parse `defaults` sections, and return a config.Defaults Args: defaults_node (TreeNode): Description Returns: config.Defaults: an object
5.697782
5.470243
1.041596
proxy_name = userlist_node.userlist_header.proxy_name.text config_block_lines = self.__build_config_block( userlist_node.config_block) return config.Userlist( name=proxy_name, config_block=config_block_lines)
def build_userlist(self, userlist_node)
parse `userlist` sections, and return a config.Userlist
4.858755
4.26385
1.139523
proxy_name = listen_node.listen_header.proxy_name.text service_address_node = listen_node.listen_header.service_address # parse the config block config_block_lines = self.__build_config_block( listen_node.config_block) # parse host and port host, po...
def build_listen(self, listen_node)
parse `listen` sections, and return a config.Listen Args: listen_node (TreeNode): Description Returns: config.Listen: an object
3.920623
3.78354
1.036231
proxy_name = frontend_node.frontend_header.proxy_name.text service_address_node = frontend_node.frontend_header.service_address # parse the config block config_block_lines = self.__build_config_block( frontend_node.config_block) # parse host and port ...
def build_frontend(self, frontend_node)
parse `frontend` sections, and return a config.Frontend Args: frontend_node (TreeNode): Description Raises: Exception: Description Returns: config.Frontend: an object
3.975589
3.847882
1.033189
proxy_name = backend_node.backend_header.proxy_name.text config_block_lines = self.__build_config_block( backend_node.config_block) return config.Backend(name=proxy_name, config_block=config_block_lines)
def build_backend(self, backend_node)
parse `backend` sections Args: backend_node (TreeNode): Description Returns: config.Backend: an object
5.399443
5.315832
1.015729
try: return self.template_class(self.engine.from_string(template_code)) except mako_exceptions.SyntaxException as exc: raise TemplateSyntaxError(exc.args)
def from_string(self, template_code)
Trying to compile and return the compiled template code. :raises: TemplateSyntaxError if there's a syntax error in the template. :param template_code: Textual template source. :return: Returns a compiled Mako template.
4.045626
4.280306
0.945172
try: return self.template_class(self.engine.get_template(template_name)) except mako_exceptions.TemplateLookupException as exc: raise TemplateDoesNotExist(exc.args) except mako_exceptions.CompileException as exc: raise TemplateSyntaxError(exc.args)
def get_template(self, template_name)
Trying to get a compiled template given a template name :param template_name: The template name. :raises: - TemplateDoesNotExist if no such template exists. - TemplateSyntaxError if we couldn't compile the template using Mako syntax. :return: Compiled Templa...
3.110271
2.769151
1.123186
if context is None: context = {} context['static'] = static context['url'] = self.get_reverse_url() if request is not None: # As Django doesn't have a global request object, # it's useful to put it in the context. context['reques...
def render(self, context=None, request=None)
Render the template with a given context. Here we're adding some context variables that are required for all templates in the system like the statix url and the CSRF tokens, etc. :param context: It must be a dict if provided :param request: It must be a django.http.HttpRequest if provid...
4.518238
4.558494
0.991169
if (hasattr(self, 'mle_settings') and self.mle_settings['optimizer'] in ['l1', 'l1_cvxopt_cp']): dot_fun = nan_dot else: dot_fun = np.dot if (cov_p is None and self.normalized_cov_params is None and not hasattr(self, 'cov_params_d...
def cov_params(self, r_matrix=None, column=None, scale=None, cov_p=None, other=None)
Returns the variance/covariance matrix. The variance/covariance matrix can be of a linear contrast of the estimates of params or all params multiplied by scale which will usually be an estimate of sigma^2. Scale is assumed to be a scalar. Parameters ---------- r_...
2.619558
2.59596
1.00909
bse = self.bse if self.use_t: dist = stats.t df_resid = getattr(self, 'df_resid_inference', self.df_resid) q = dist.ppf(1 - alpha / 2, df_resid) else: dist = stats.norm q = dist.ppf(1 - alpha / 2) if cols is None: ...
def conf_int(self, alpha=.05, cols=None, method='default')
Returns the confidence interval of the fitted parameters. Parameters ---------- alpha : float, optional The significance level for the confidence interval. ie., The default `alpha` = .05 returns a 95% confidence interval. cols : array-lik...
2.301911
2.359039
0.975783
seqids = self._xml_root.xpath('GBSeq_other-seqids/GBSeqid/text()') return {t: l.rstrip('|').split('|') for t, _, l in [si.partition('|') for si in seqids]}
def other_seqids(self)
returns a dictionary of sequence ids, like {'gi': ['319655736'], 'ref': ['NM_000551.3']}
10.742264
8.746676
1.228154
def MD5Hash(password): md5_password = md5.new(password) password_md5 = md5_password.hexdigest() return password_md5
Returns md5 hash of a string. @param password (string) - String to be hashed. @return (string) - Md5 hash of password.
null
null
null
def setVerbosity(self, verbose): if not (verbose == True or verbose == False): return False else: self.__verbose__ = verbose return True
Set verbosity of the SenseApi object. @param verbose (boolean) - True of False @return (boolean) - Boolean indicating whether setVerbosity succeeded
null
null
null
def setServer(self, server): if server == 'live': self.__server__ = server self.__server_url__ = 'api.sense-os.nl' self.setUseHTTPS() return True elif server == 'dev': self.__server__ = server self.__server_url__ =...
Set server to interact with. @param server (string) - 'live' for live server, 'dev' for test server, 'rc' for release candidate @return (boolean) - Boolean indicating whether setServer succeeded
null
null
null
def getAllSensors(self): j = 0 sensors = [] parameters = {'page':0, 'per_page':1000, 'owned':1} while True: parameters['page'] = j if self.SensorsGet(parameters): s = json.loads(self.getResponse())['sensors'] senso...
Retrieve all the user's own sensors by iterating over the SensorsGet function @return (list) - Array of sensors
null
null
null
def findSensor(self, sensors, sensor_name, device_type = None): if device_type == None: for sensor in sensors: if sensor['name'] == sensor_name: return sensor['id'] else: for sensor in sensors: if sensor['name...
Find a sensor in the provided list of sensors @param sensors (list) - List of sensors to search in @param sensor_name (string) - Name of sensor to find @param device_type (string) - Device type of sensor to find, can be None @return (string...
null
null
null
def AuthenticateSessionId(self, username, password): self.__setAuthenticationMethod__('authenticating_session_id') parameters = {'username':username, 'password':password} if self.__SenseApiCall__("/login.json", "POST", parameters = parameters): try: ...
Authenticate using a username and password. The SenseApi object will store the obtained session_id internally until a call to LogoutSessionId is performed. @param username (string) - CommonSense username @param password (string) - MD5Hash of CommonSense password ...
null
null
null
def LogoutSessionId(self): if self.__SenseApiCall__('/logout.json', 'POST'): self.__setAuthenticationMethod__('not_authenticated') return True else: self.__error__ = "api call unsuccessful" return False
Logout the current session_id from CommonSense @return (bool) - Boolean indicating whether LogoutSessionId was successful
null
null
null
def AuthenticateOauth (self, oauth_token_key, oauth_token_secret, oauth_consumer_key, oauth_consumer_secret): self.__oauth_consumer__ = oauth.OAuthConsumer(str(oauth_consumer_key), str(oauth_consumer_secret)) self.__oauth_token__ = oauth.OAuthToken(str(oauth_token_key), str(oauth_token_secre...
Authenticate using Oauth @param oauth_token_key (string) - A valid oauth token key obtained from CommonSense @param oauth_token_secret (string) - A valid oauth token secret obtained from CommonSense @param oauth_consumer_key (string) - A valid oauth consumer key obta...
null
null
null
def OauthGetAccessToken(self): self.__setAuthenticationMethod__('authenticating_oauth') # obtain access token oauth_request = oauth.OAuthRequest.from_consumer_and_token(self.__oauth_consumer__, \ token = self....
Use token_verifier to obtain an access token for the user. If this function returns True, the clients __oauth_token__ member contains the access token. @return (boolean) - Boolean indicating whether OauthGetRequestToken was successful
null
null
null
def OauthAuthorizeApplication(self, oauth_duration = 'hour'): if self.__session_id__ == '': self.__error__ = "not logged in" return False # automatically get authorization for the application parameters = {'oauth_token':self.__oauth_token__.key, 'tok_expir':s...
Authorize an application using oauth. If this function returns True, the obtained oauth token can be retrieved using getResponse and will be in url-parameters format. TODO: allow the option to ask the user himself for permission, instead of doing this automatically. Especially important for web application...
null
null
null
def SensorsGet(self, parameters = None, sensor_id = -1): url = '' if parameters is None and sensor_id <> -1: url = '/sensors/{0}.json'.format(sensor_id) else: url = '/sensors.json' if self.__SenseApiCall__(url, 'GET', parameters = parameters): ...
Retrieve sensors from CommonSense, according to parameters, or by sensor id. If successful, result can be obtained by a call to getResponse(), and should be a json string. @param parameters (dictionary) (optional) - Dictionary containing the parameters for the api-call. ...
null
null
null
def SensorsDelete(self, sensor_id): if self.__SenseApiCall__('/sensors/{0}.json'.format(sensor_id), 'DELETE'): return True else: self.__error__ = "api call unsuccessful" return False
Delete a sensor from CommonSense. @param sensor_id (int) - Sensor id of sensor to delete from CommonSense. @return (bool) - Boolean indicating whether SensorsDelete was successful.
null
null
null
def SensorsPost(self, parameters): if self.__SenseApiCall__('/sensors.json', 'POST', parameters = parameters): return True else: self.__error__ = "api call unsuccessful" return False
Create a sensor in CommonSense. If SensorsPost is successful, the sensor details, including its sensor_id, can be obtained by a call to getResponse(), and should be a json string. @param parameters (dictonary) - Dictionary containing the details of the sensor to be created. ...
null
null
null
def SensorsMetatagsGet(self, parameters, namespace = None): ns = "default" if namespace is None else namespace parameters['namespace'] = ns if self.__SenseApiCall__('/sensors/metatags.json', 'GET', parameters = parameters): return True else: self._...
Retrieve sensors with their metatags. @param namespace (string) - Namespace for which to retrieve the metatags. @param parameters (dictionary - Dictionary containing further parameters. @return (bool) - Boolean indicating whether SensorsMetatagsget was ...
null
null
null
def GroupSensorsMetatagsGet(self, group_id, parameters, namespace = None): ns = "default" if namespace is None else namespace parameters['namespace'] = ns if self.__SenseApiCall__('/groups/{0}/sensors/metatags.json'.format(group_id), 'GET', parameters = parameters): ret...
Retrieve sensors in a group with their metatags. @param group_id (int) - Group id for which to retrieve metatags. @param namespace (string) - Namespace for which to retrieve the metatags. @param parameters (dictionary) - Dictionary containing further parameters. ...
null
null
null
def SensorMetatagsGet(self, sensor_id, namespace = None): ns = "default" if namespace is None else namespace if self.__SenseApiCall__('/sensors/{0}/metatags.json'.format(sensor_id), 'GET', parameters = {'namespace': ns}): return True else: self.__error__ = ...
Retrieve the metatags of a sensor. @param sensor_id (int) - Id of the sensor to retrieve metatags from @param namespace (stirng) - Namespace for which to retrieve metatags. @return (bool) - Boolean indicating whether SensorMetatagsGet was successful
null
null
null
def SensorMetatagsPost(self, sensor_id, metatags, namespace = None): ns = "default" if namespace is None else namespace if self.__SenseApiCall__("/sensors/{0}/metatags.json?namespace={1}".format(sensor_id, ns), "POST", parameters = metatags): return True else: ...
Attach metatags to a sensor for a specific namespace @param sensor_id (int) - Id of the sensor to attach metatags to @param namespace (string) - Namespace for which to attach metatags @param metatags (dictionary) - Metatags to attach to the sensor ...
null
null
null
def GroupSensorsFind(self, group_id, parameters, filters, namespace = None): ns = "default" if namespace is None else namespace parameters['namespace'] = ns if self.__SenseApiCall__("/groups/{0}/sensors/find.json?{1}".format(group_id, urllib.urlencode(parameters, True)), "POST", par...
Find sensors in a group based on a number of filters on metatags @param group_id (int) - Id of the group in which to find sensors @param namespace (string) - Namespace to use in filtering on metatags @param parameters (dictionary) - Dictionary containing additional p...
null
null
null
def MetatagDistinctValuesGet(self, metatag_name, namespace = None): ns = "default" if namespace is None else namespace if self.__SenseApiCall__("/metatag_name/{0}/distinct_values.json", "GET", parameters = {'namespace': ns}): return True else: self.__error_...
Find the distinct value of a metatag name in a certain namespace @param metatag_name (string) - Name of the metatag for which to find the distinct values @param namespace (stirng) - Namespace in which to find the distinct values @return (bool) - Boolean...
null
null
null
def SensorsDataGet(self, sensorIds, parameters): if parameters is None: parameters = {} parameters["sensor_id[]"] = sensorIds if self.__SenseApiCall__('/sensors/data.json', 'GET', parameters = parameters): return True else: sel...
Retrieve sensor data for the specified sensors from CommonSense. If SensorsDataGet is successful, the result can be obtained by a call to getResponse(), and should be a json string. @param sensorIds (list) a list of sensor ids to retrieve the data for @param parameters (dictiona...
null
null
null
def SensorDataDelete(self, sensor_id, data_id): if self.__SenseApiCall__('/sensors/{0}/data/{1}.json'.format(sensor_id, data_id), 'DELETE'): return True else: self.__error_ = "api call unsuccessful" return False
Delete a sensor datum from a specific sensor in CommonSense. @param sensor_id (int) - Sensor id of the sensor to delete data from @param data_id (int) - Id of the data point to delete @return (bool) - Boolean indicating whether SensorDataDelete was succ...
null
null
null
def SensorsDataPost(self, parameters): if self.__SenseApiCall__('/sensors/data.json', 'POST', parameters = parameters): return True else: self.__error__ = "api call unsuccessful" return False
Post sensor data to multiple sensors in CommonSense simultaneously. @param parameters (dictionary) - Data to post to the sensors. @note - http://www.sense-os.nl/59?nodeId=59&selectedId=11887 @return (bool) - Boolean indicating whether Se...
null
null
null
def ServicesGet (self, sensor_id): if self.__SenseApiCall__('/sensors/{0}/services.json'.format(sensor_id), 'GET'): return True else: self.__error__ = "api call unsuccessful" return False
Retrieve services connected to a sensor in CommonSense. If ServicesGet is successful, the result can be obtained by a call to getResponse() and should be a json string. @sensor_id (int) - Sensor id of sensor to retrieve services from. @return (bool) - B...
null
null
null
def ServicesPost (self, sensor_id, parameters): if self.__SenseApiCall__('/sensors/{0}/services.json'.format(sensor_id), 'POST', parameters = parameters): return True else: self.__error__ = "api call unsuccessful" return False
Create a new service in CommonSense, attached to a specific sensor. If ServicesPost was successful, the service details, including its service_id, can be obtained from getResponse(), and should be a json string. @param sensor_id (int) - The sensor id of the sensor to connect the...
null
null
null
def ServicesDelete (self, sensor_id, service_id): if self.__SenseApiCall__('/sensors/{0}/services/{1}.json'.format(sensor_id, service_id), 'DELETE'): return True else: self.__error__ = "api call unsuccessful" return False
Delete a service from CommonSense. @param sensor_id (int) - Sensor id of the sensor the service is connected to. @param service_id (int) - Sensor id of the service to delete. @return (bool) - Boolean indicating whether ServicesDelete was successful.
null
null
null
def ServicesSetMetod (self, sensor_id, service_id, method, parameters): if self.__SenseApiCall__('/sensors/{0}/services/{1}/{2}.json'.format(sensor_id, service_id, method), 'POST', parameters = parameters): return True else: self.__error__ = "api call unsuccessful" ...
Set expression for the math service. @param sensor_id (int) - Sensor id of the sensor the service is connected to. @param service_id (int) - Service id of the service for which to set the expression. @param method (string) - The set method name. @param p...
null
null
null
def ServicesGetMetod (self, sensor_id, service_id, method): if self.__SenseApiCall__('/sensors/{0}/services/{1}/{2}.json'.format(sensor_id, service_id, method), 'GET'): return True else: self.__error__ = "api call unsuccessful" return False
Set expression for the math service. @param sensor_id (int) - Sensor id of the sensor the service is connected to. @param service_id (int) - Service id of the service for which to set the expression. @param method (string) - The get method name. ...
null
null
null
def ServicesSetUseDataTimestamp(self, sensor_id, service_id, parameters): if self.__SenseApiCall__('/sensors/{0}/services/{1}/SetUseDataTimestamp.json'.format(sensor_id, service_id), 'POST', parameters = parameters): return True else: self.__error__ = "api call unsu...
Indicate whether a math service should use the original timestamps of the incoming data, or let CommonSense timestamp the aggregated data. @param sensors_id (int) - Sensor id of the sensor the service is connected to. @param service_id (int) - Service id of the service for which ...
null
null
null
def CreateUser (self, parameters): print "Creating user" print parameters if self.__SenseApiCall__('/users.json', 'POST', parameters = parameters): return True else: self.__error__ = "api call unsuccessful" return False
Create a user This method creates a user and returns the user object and session @param parameters (dictionary) - Parameters according to which to create the user.
null
null
null
def UsersUpdate (self, user_id, parameters): if self.__SenseApiCall__('/users/{0}.json'.format(user_id), 'PUT', parameters): return True else: self.__error__ = "api call unsuccessful" return False
Update the current user. @param user_id (int) - id of the user to be updated @param parameters (dictionary) - user object to update the user with @return (bool) - Boolean indicating whether UserUpdate was successful.
null
null
null
def UsersChangePassword (self, current_password, new_password): if self.__SenseApiCall__('/change_password', "POST", {"current_password":current_password, "new_password":new_password}): return True else: self.__error__ = "api call unsuccessful" return F...
Change the password for the current user @param current_password (string) - md5 hash of the current password of the user @param new_password (string) - md5 hash of the new password of the user (make sure to doublecheck!) @return (bool) - Boolean indicat...
null
null
null
def UsersDelete (self, user_id): if self.__SenseApiCall__('/users/{user_id}.json'.format(user_id = user_id), 'DELETE'): return True else: self.__error__ = "api call unsuccessful" return False
Delete user. @return (bool) - Boolean indicating whether UsersDelete was successful.
null
null
null
def EventsNotificationsGet(self, event_notification_id = -1): if event_notification_id == -1: url = '/events/notifications.json' else: url = '/events/notifications/{0}.json'.format(event_notification_id) if self.__SenseApiCall__(url, 'GET'): ...
Retrieve either all notifications or the notifications attached to a specific event. If successful, result can be obtained by a call to getResponse(), and should be a json string. @param event_notification_id (int) (optional) - Id of the event-notification to retrieve details fro...
null
null
null
def EventsNotificationsDelete(self, event_notification_id): if self.__SenseApiCall__('/events/notifications/{0}.json'.format(event_notification_id), 'DELETE'): return True else: self.__error__ = "api call unsuccessful" return False
Delete an event-notification from CommonSense. @param event_notification_id (int) - Id of the event-notification to delete. @return (bool) - Boolean indicating whether EventsNotificationsDelete was successful.
null
null
null
def EventsNotificationsPost(self, parameters): if self.__SenseApiCall__('/events/notifications.json', 'POST', parameters = parameters): return True else: self.__error__ = "api call unsuccessful" return False
Create an event-notification in CommonSense. If EvensNotificationsPost was successful the result, including the event_notification_id can be obtained from getResponse(), and should be a json string. @param parameters (dictionary) - Parameters according to which to create the even...
null
null
null
def TriggersGet(self, trigger_id = -1): if trigger_id == -1: url = '/triggers.json' else: url = '/triggers/{0}.json'.format(trigger_id) if self.__SenseApiCall__(url, 'GET'): return True else: self.__error__ = "api call uns...
Retrieve either all triggers or the details of a specific trigger. If successful, result can be obtained by a call to getResponse(), and should be a json string. @param trigger_id (int) (optional) - Trigger id of the trigger to retrieve details from. @param (bool) ...
null
null
null
def TriggersDelete(self, trigger_id): if self.__SenseApiCall__('/triggers/{0}'.format(trigger_id), 'DELETE'): return True else: self.__error__ = "api call unsuccessful" return False
Delete a trigger from CommonSense. @param trigger_id (int) - Trigger id of the trigger to delete. @return (bool) - Boolean indicating whether TriggersDelete was successful.
null
null
null
def TriggersPost(self, parameters): if self.__SenseApiCall__('/triggers.json', 'POST', parameters = parameters): return True else: self.__error__ = "api call unsuccessful" return False
Create a trigger on CommonSense. If TriggersPost was successful the result, including the trigger_id, can be obtained from getResponse(). @param parameters (dictionary) - Parameters of the trigger to create. @note @return (...
null
null
null
def SensorsTriggersGet(self, sensor_id, trigger_id = -1): if trigger_id == -1: url = '/sensors/{0}/triggers.json'.format(sensor_id) else: url = '/sensors/{0}/triggers/{1}.json'.format(sensor_id, trigger_id) if self.__SenseApiCall__(url, 'GET'): ...
Obtain either all triggers connected to a sensor, or the details of a specific trigger connected to a sensor. If successful, result can be obtained from getResponse(), and should be a json string. @param sensor_id (int) - Sensor id of the sensor to retrieve triggers from. ...
null
null
null
def SensorsTriggersNotificationsGet(self, sensor_id, trigger_id): if self.__SenseApiCall__('/sensors/{0}/triggers/{1}/notifications.json'.format(sensor_id, trigger_id), 'GET'): return True else: self.__error__ = "api call unsuccessful" return False
Obtain all notifications connected to a sensor-trigger combination. If successful, the result can be obtained from getResponse(), and should be a json string. @param sensor_id (int) - Sensor id if the sensor-trigger combination. @param trigger_id (int) - Trigger id o...
null
null
null
def SensorsTriggersNotificationsDelete(self, sensor_id, trigger_id, notification_id): if self.__SenseApiCall__('/sensors/{0}/triggers/{1}/notifications/{2}.json'.format(sensor_id, trigger_id, notification_id), 'DELETE'): return True else: self.__error__ = "api call ...
Disconnect a notification from a sensor-trigger combination. @param sensor_id (int) - Sensor id if the sensor-trigger combination. @param trigger_id (int) - Trigger id of the sensor-trigger combination. @param notification_id (int) - Notification id of the notificati...
null
null
null
def SensorsTriggersNotificationsPost(self, sensor_id, trigger_id, parameters): if self.__SenseApiCall__('/sensors/{0}/triggers/{1}/notifications.json'.format(sensor_id, trigger_id), 'POST', parameters = parameters): return True else: self.__error__ = "api call unsuc...
Connect a notification to a sensor-trigger combination. @param sensor_id (int) - Sensor id if the sensor-trigger combination. @param trigger_id (int) - Trigger id of the sensor-trigger combination. @param parameters (dictionary) - Dictionary containing the notificati...
null
null
null
def NotificationsGet(self, notification_id = -1): if notification_id == -1: url = '/notifications.json' else: url = '/notifications/{0}.json'.format(notification_id) if self.__SenseApiCall__(url, 'GET'): return True else: ...
Obtain either all notifications from CommonSense, or the details of a specific notification. If successful, the result can be obtained from getResponse(), and should be a json string. @param notification_id (int) (optional) - Notification id of the notification to obtain details ...
null
null
null
def NotificationsDelete(self, notification_id): if self.__SenseApiCall__('/notifications/{0}.json'.format(notification_id), 'DELETE'): return True else: self.__error__ = "api call unsuccessful" return False
Delete a notification from CommonSense. @param notification_id (int) - Notification id of the notification to delete. @return (bool) - Boolean indicating whether NotificationsDelete was successful.
null
null
null
def NotificationsPost(self, parameters): if self.__SenseApiCall__('/notifications.json', 'POST', parameters = parameters): return True else: self.__error__ = "api call unsuccessful" return False
Create a notification on CommonSense. If successful the result, including the notification_id, can be obtained from getResponse(), and should be a json string. @param parameters (dictionary) - Dictionary containing the notification to create. @note - ...
null
null
null
def DeviceGet(self, device_id): if self.__SenseApiCall__('/devices/{0}'.format(device_id), 'GET'): return True else: self.__error__ = "api call unsuccessful" return False
Obtain details of a single device @param device_id (int) - Device for which to obtain details
null
null
null
def DeviceSensorsGet(self, device_id, parameters): if self.__SenseApiCall__('/devices/{0}/sensors.json'.format(device_id), 'GET', parameters = parameters): return True else: self.__error__ = "api call unsuccessful" return False
Obtain a list of all sensors attached to a device. @param device_id (int) - Device for which to retrieve sensors @param parameters (dict) - Search parameters @return (bool) - Boolean indicating whether DeviceSensorsGet was succesful.
null
null
null
def GroupsGet(self, parameters = None, group_id = -1): if parameters is None and group_id == -1: self.__error__ = "no arguments" return False url = '' if group_id is -1: url = '/groups.json' else: url = '/groups/{0}.json...
Retrieve groups from CommonSense, according to parameters, or by group id. If successful, result can be obtained by a call to getResponse(), and should be a json string. @param parameters (dictionary) (optional) - Dictionary containing the parameters for the api-call. ...
null
null
null
def GroupsDelete(self, group_id): if self.__SenseApiCall__('/groups/{0}.json'.format(group_id), 'DELETE'): return True else: self.__error__ = "api call unsuccessful" return False
Delete a group from CommonSense. @param group_id (int) - group id of group to delete from CommonSense. @return (bool) - Boolean indicating whether GroupsDelete was successful.
null
null
null
def GroupsPost(self, parameters): if self.__SenseApiCall__('/groups.json', 'POST', parameters = parameters): return True else: self.__error__ = "api call unsuccessful" return False
Create a group in CommonSense. If GroupsPost is successful, the group details, including its group_id, can be obtained by a call to getResponse(), and should be a json string. @param parameters (dictonary) - Dictionary containing the details of the group to be created. ...
null
null
null