Search is not available for this dataset
text
stringlengths
75
104k
def getSpaceUse(self): """Get disk space usage. @return: Dictionary of filesystem space utilization stats for filesystems. """ stats = {} try: out = subprocess.Popen([dfCmd, "-Pk"], stdout=subprocess.PIPE).communic...
def retrieveVals(self): """Retrieve values for graphs.""" stats = self._dbconn.getDatabaseStats() databases = stats.get('databases') totals = stats.get('totals') if self.hasGraph('pg_connections'): limit = self._dbconn.getParam('max_connections') ...
def connect(self, host, port): """Connects via a RS-485 to Ethernet adapter.""" sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect((host, port)) self._reader = sock.makefile(mode='rb') self._writer = sock.makefile(mode='wb')
def process(self, data_changed_callback): """Process data; returns when the reader signals EOF. Callback is notified when any data changes.""" # pylint: disable=too-many-locals,too-many-branches,too-many-statements while True: byte = self._reader.read(1) while Tr...
def send_key(self, key): """Sends a key.""" _LOGGER.info('Queueing key %s', key) frame = self._get_key_event_frame(key) # Queue it to send immediately following the reception # of a keep-alive packet in an attempt to avoid bus collisions. self._send_queue.put({'frame': f...
def states(self): """Returns a set containing the enabled states.""" state_list = [] for state in States: if state.value & self._states != 0: state_list.append(state) if (self._flashing_states & States.FILTER) != 0: state_list.append(States.FILTER...
def get_state(self, state): """Returns True if the specified state is enabled.""" # Check to see if we have a change request pending; if we do # return the value we expect it to change to. for data in list(self._send_queue.queue): desired_states = data['desired_states'] ...
def set_state(self, state, enable): """Set the state.""" is_enabled = self.get_state(state) if is_enabled == enable: return True key = None desired_states = [{'state': state, 'enabled': not is_enabled}] if state == States.FILTER_LOW_SPEED: if no...
def trace(function, *args, **k) : """Decorates a function by tracing the begining and end of the function execution, if doTrace global is True""" if doTrace : print ("> "+function.__name__, args, k) result = function(*args, **k) if doTrace : print ("< "+function.__name__, args, k, "->", result) return result
def geocode(self, location) : url = QtCore.QUrl("http://maps.googleapis.com/maps/api/geocode/xml") url.addQueryItem("address", location) url.addQueryItem("sensor", "false") """ url = QtCore.QUrl("http://maps.google.com/maps/geo/") url.addQueryItem("q", location) url.addQueryItem("output", "csv") url.add...
def correlate(params, corrmat): """ Force a correlation matrix on a set of statistically distributed objects. This function works on objects in-place. Parameters ---------- params : array An array of of uv objects. corrmat : 2d-array The correlation matrix to b...
def induce_correlations(data, corrmat): """ Induce a set of correlations on a column-wise dataset Parameters ---------- data : 2d-array An m-by-n array where m is the number of samples and n is the number of independent variables, each column of the array corresponding ...
def plotcorr(X, plotargs=None, full=True, labels=None): """ Plots a scatterplot matrix of subplots. Usage: plotcorr(X) plotcorr(..., plotargs=...) # e.g., 'r*', 'bo', etc. plotcorr(..., full=...) # e.g., True or False plotc...
def chol(A): """ Calculate the lower triangular matrix of the Cholesky decomposition of a symmetric, positive-definite matrix. """ A = np.array(A) assert A.shape[0] == A.shape[1], "Input matrix must be square" L = [[0.0] * len(A) for _ in range(len(A))] for i in range(len(A)): ...
def get(self, uri, params={}): '''A generic method to make GET requests to the OpenDNS Investigate API on the given URI. ''' return self._session.get(urljoin(Investigate.BASE_URL, uri), params=params, headers=self._auth_header, proxies=self.proxies )
def post(self, uri, params={}, data={}): '''A generic method to make POST requests to the OpenDNS Investigate API on the given URI. ''' return self._session.post( urljoin(Investigate.BASE_URL, uri), params=params, data=data, headers=self._auth_header, ...
def get_parse(self, uri, params={}): '''Convenience method to call get() on an arbitrary URI and parse the response into a JSON object. Raises an error on non-200 response status. ''' return self._request_parse(self.get, uri, params)
def post_parse(self, uri, params={}, data={}): '''Convenience method to call post() on an arbitrary URI and parse the response into a JSON object. Raises an error on non-200 response status. ''' return self._request_parse(self.post, uri, params, data)
def categorization(self, domains, labels=False): '''Get the domain status and categorization of a domain or list of domains. 'domains' can be either a single domain, or a list of domains. Setting 'labels' to True will give back categorizations in human-readable form. For more de...
def cooccurrences(self, domain): '''Get the cooccurrences of the given domain. For details, see https://investigate.umbrella.com/docs/api#co-occurrences ''' uri = self._uris["cooccurrences"].format(domain) return self.get_parse(uri)
def related(self, domain): '''Get the related domains of the given domain. For details, see https://investigate.umbrella.com/docs/api#relatedDomains ''' uri = self._uris["related"].format(domain) return self.get_parse(uri)
def security(self, domain): '''Get the Security Information for the given domain. For details, see https://investigate.umbrella.com/docs/api#securityInfo ''' uri = self._uris["security"].format(domain) return self.get_parse(uri)
def rr_history(self, query, query_type="A"): '''Get the RR (Resource Record) History of the given domain or IP. The default query type is for 'A' records, but the following query types are supported: A, NS, MX, TXT, CNAME For details, see https://investigate.umbrella.com/docs/a...
def domain_whois(self, domain): '''Gets whois information for a domain''' uri = self._uris["whois_domain"].format(domain) resp_json = self.get_parse(uri) return resp_json
def domain_whois_history(self, domain, limit=None): '''Gets whois history for a domain''' params = dict() if limit is not None: params['limit'] = limit uri = self._uris["whois_domain_history"].format(domain) resp_json = self.get_parse(uri, params) return res...
def ns_whois(self, nameservers, limit=DEFAULT_LIMIT, offset=DEFAULT_OFFSET, sort_field=DEFAULT_SORT): '''Gets the domains that have been registered with a nameserver or nameservers''' if not isinstance(nameservers, list): uri = self._uris["whois_ns"].format(nameservers) p...
def search(self, pattern, start=None, limit=None, include_category=None): '''Searches for domains that match a given pattern''' params = dict() if start is None: start = datetime.timedelta(days=30) if isinstance(start, datetime.timedelta): params['start'] = int...
def samples(self, anystring, limit=None, offset=None, sortby=None): '''Return an object representing the samples identified by the input domain, IP, or URL''' uri = self._uris['samples'].format(anystring) params = {'limit': limit, 'offset': offset, 'sortby': sortby} return self.get_par...
def sample(self, hash, limit=None, offset=None): '''Return an object representing the sample identified by the input hash, or an empty object if that sample is not found''' uri = self._uris['sample'].format(hash) params = {'limit': limit, 'offset': offset} return self.get_parse(uri, pa...
def as_for_ip(self, ip): '''Gets the AS information for a given IP address.''' if not Investigate.IP_PATTERN.match(ip): raise Investigate.IP_ERR uri = self._uris["as_for_ip"].format(ip) resp_json = self.get_parse(uri) return resp_json
def prefixes_for_asn(self, asn): '''Gets the AS information for a given ASN. Return the CIDR and geolocation associated with the AS.''' uri = self._uris["prefixes_for_asn"].format(asn) resp_json = self.get_parse(uri) return resp_json
def timeline(self, uri): '''Get the domain tagging timeline for a given uri. Could be a domain, ip, or url. For details, see https://docs.umbrella.com/investigate-api/docs/timeline ''' uri = self._uris["timeline"].format(uri) resp_json = self.get_parse(uri) retu...
def abs(x): """ Absolute value """ if isinstance(x, UncertainFunction): mcpts = np.abs(x._mcpts) return UncertainFunction(mcpts) else: return np.abs(x)
def acos(x): """ Inverse cosine """ if isinstance(x, UncertainFunction): mcpts = np.arccos(x._mcpts) return UncertainFunction(mcpts) else: return np.arccos(x)
def acosh(x): """ Inverse hyperbolic cosine """ if isinstance(x, UncertainFunction): mcpts = np.arccosh(x._mcpts) return UncertainFunction(mcpts) else: return np.arccosh(x)
def asin(x): """ Inverse sine """ if isinstance(x, UncertainFunction): mcpts = np.arcsin(x._mcpts) return UncertainFunction(mcpts) else: return np.arcsin(x)
def asinh(x): """ Inverse hyperbolic sine """ if isinstance(x, UncertainFunction): mcpts = np.arcsinh(x._mcpts) return UncertainFunction(mcpts) else: return np.arcsinh(x)
def atan(x): """ Inverse tangent """ if isinstance(x, UncertainFunction): mcpts = np.arctan(x._mcpts) return UncertainFunction(mcpts) else: return np.arctan(x)
def atanh(x): """ Inverse hyperbolic tangent """ if isinstance(x, UncertainFunction): mcpts = np.arctanh(x._mcpts) return UncertainFunction(mcpts) else: return np.arctanh(x)
def ceil(x): """ Ceiling function (round towards positive infinity) """ if isinstance(x, UncertainFunction): mcpts = np.ceil(x._mcpts) return UncertainFunction(mcpts) else: return np.ceil(x)
def cos(x): """ Cosine """ if isinstance(x, UncertainFunction): mcpts = np.cos(x._mcpts) return UncertainFunction(mcpts) else: return np.cos(x)
def cosh(x): """ Hyperbolic cosine """ if isinstance(x, UncertainFunction): mcpts = np.cosh(x._mcpts) return UncertainFunction(mcpts) else: return np.cosh(x)
def degrees(x): """ Convert radians to degrees """ if isinstance(x, UncertainFunction): mcpts = np.degrees(x._mcpts) return UncertainFunction(mcpts) else: return np.degrees(x)
def exp(x): """ Exponential function """ if isinstance(x, UncertainFunction): mcpts = np.exp(x._mcpts) return UncertainFunction(mcpts) else: return np.exp(x)
def expm1(x): """ Calculate exp(x) - 1 """ if isinstance(x, UncertainFunction): mcpts = np.expm1(x._mcpts) return UncertainFunction(mcpts) else: return np.expm1(x)
def fabs(x): """ Absolute value function """ if isinstance(x, UncertainFunction): mcpts = np.fabs(x._mcpts) return UncertainFunction(mcpts) else: return np.fabs(x)
def floor(x): """ Floor function (round towards negative infinity) """ if isinstance(x, UncertainFunction): mcpts = np.floor(x._mcpts) return UncertainFunction(mcpts) else: return np.floor(x)
def hypot(x, y): """ Calculate the hypotenuse given two "legs" of a right triangle """ if isinstance(x, UncertainFunction) or isinstance(x, UncertainFunction): ufx = to_uncertain_func(x) ufy = to_uncertain_func(y) mcpts = np.hypot(ufx._mcpts, ufy._mcpts) return UncertainF...
def log(x): """ Natural logarithm """ if isinstance(x, UncertainFunction): mcpts = np.log(x._mcpts) return UncertainFunction(mcpts) else: return np.log(x)
def log10(x): """ Base-10 logarithm """ if isinstance(x, UncertainFunction): mcpts = np.log10(x._mcpts) return UncertainFunction(mcpts) else: return np.log10(x)
def log1p(x): """ Natural logarithm of (1 + x) """ if isinstance(x, UncertainFunction): mcpts = np.log1p(x._mcpts) return UncertainFunction(mcpts) else: return np.log1p(x)
def radians(x): """ Convert degrees to radians """ if isinstance(x, UncertainFunction): mcpts = np.radians(x._mcpts) return UncertainFunction(mcpts) else: return np.radians(x)
def sin(x): """ Sine """ if isinstance(x, UncertainFunction): mcpts = np.sin(x._mcpts) return UncertainFunction(mcpts) else: return np.sin(x)
def sinh(x): """ Hyperbolic sine """ if isinstance(x, UncertainFunction): mcpts = np.sinh(x._mcpts) return UncertainFunction(mcpts) else: return np.sinh(x)
def sqrt(x): """ Square-root function """ if isinstance(x, UncertainFunction): mcpts = np.sqrt(x._mcpts) return UncertainFunction(mcpts) else: return np.sqrt(x)
def tan(x): """ Tangent """ if isinstance(x, UncertainFunction): mcpts = np.tan(x._mcpts) return UncertainFunction(mcpts) else: return np.tan(x)
def tanh(x): """ Hyperbolic tangent """ if isinstance(x, UncertainFunction): mcpts = np.tanh(x._mcpts) return UncertainFunction(mcpts) else: return np.tanh(x)
def trunc(x): """ Truncate the values to the integer value without rounding """ if isinstance(x, UncertainFunction): mcpts = np.trunc(x._mcpts) return UncertainFunction(mcpts) else: return np.trunc(x)
def lhd( dist=None, size=None, dims=1, form="randomized", iterations=100, showcorrelations=False, ): """ Create a Latin-Hypercube sample design based on distributions defined in the `scipy.stats` module Parameters ---------- dist: array_like frozen scipy.stat...
def to_uncertain_func(x): """ Transforms x into an UncertainFunction-compatible object, unless it is already an UncertainFunction (in which case x is returned unchanged). Raises an exception unless 'x' belongs to some specific classes of objects that are known not to depend on UncertainFunctio...
def Beta(alpha, beta, low=0, high=1, tag=None): """ A Beta random variate Parameters ---------- alpha : scalar The first shape parameter beta : scalar The second shape parameter Optional -------- low : scalar Lower bound of the distribution support (...
def BetaPrime(alpha, beta, tag=None): """ A BetaPrime random variate Parameters ---------- alpha : scalar The first shape parameter beta : scalar The second shape parameter """ assert ( alpha > 0 and beta > 0 ), 'BetaPrime "alpha" and "beta" paramete...
def Bradford(q, low=0, high=1, tag=None): """ A Bradford random variate Parameters ---------- q : scalar The shape parameter low : scalar The lower bound of the distribution (default=0) high : scalar The upper bound of the distribution (default=1) """ ass...
def Burr(c, k, tag=None): """ A Burr random variate Parameters ---------- c : scalar The first shape parameter k : scalar The second shape parameter """ assert c > 0 and k > 0, 'Burr "c" and "k" parameters must be greater than zero' return uv(ss.burr(c, k), ...
def ChiSquared(k, tag=None): """ A Chi-Squared random variate Parameters ---------- k : int The degrees of freedom of the distribution (must be greater than one) """ assert int(k) == k and k >= 1, 'Chi-Squared "k" must be an integer greater than 0' return uv(ss.chi2(k), tag=...
def Erlang(k, lamda, tag=None): """ An Erlang random variate. This distribution is the same as a Gamma(k, theta) distribution, but with the restriction that k must be a positive integer. This is provided for greater compatibility with other simulation tools, but provides no advantage over ...
def Exponential(lamda, tag=None): """ An Exponential random variate Parameters ---------- lamda : scalar The inverse scale (as shown on Wikipedia). (FYI: mu = 1/lamda.) """ assert lamda > 0, 'Exponential "lamda" must be greater than zero' return uv(ss.expon(scale=1.0 / lamda...
def ExtValueMax(mu, sigma, tag=None): """ An Extreme Value Maximum random variate. Parameters ---------- mu : scalar The location parameter sigma : scalar The scale parameter (must be greater than zero) """ assert sigma > 0, 'ExtremeValueMax "sigma" must be greater t...
def Fisher(d1, d2, tag=None): """ An F (fisher) random variate Parameters ---------- d1 : int Numerator degrees of freedom d2 : int Denominator degrees of freedom """ assert ( int(d1) == d1 and d1 >= 1 ), 'Fisher (F) "d1" must be an integer greater than 0...
def Gamma(k, theta, tag=None): """ A Gamma random variate Parameters ---------- k : scalar The shape parameter (must be positive and non-zero) theta : scalar The scale parameter (must be positive and non-zero) """ assert ( k > 0 and theta > 0 ), 'Gamma "k...
def LogNormal(mu, sigma, tag=None): """ A Log-Normal random variate Parameters ---------- mu : scalar The location parameter sigma : scalar The scale parameter (must be positive and non-zero) """ assert sigma > 0, 'Log-Normal "sigma" must be positive' return uv(s...
def Normal(mu, sigma, tag=None): """ A Normal (or Gaussian) random variate Parameters ---------- mu : scalar The mean value of the distribution sigma : scalar The standard deviation (must be positive and non-zero) """ assert sigma > 0, 'Normal "sigma" must be greater...
def Pareto(q, a, tag=None): """ A Pareto random variate (first kind) Parameters ---------- q : scalar The scale parameter a : scalar The shape parameter (the minimum possible value) """ assert q > 0 and a > 0, 'Pareto "q" and "a" must be positive scalars' p = Uni...
def Pareto2(q, b, tag=None): """ A Pareto random variate (second kind). This form always starts at the origin. Parameters ---------- q : scalar The scale parameter b : scalar The shape parameter """ assert q > 0 and b > 0, 'Pareto2 "q" and "b" must be positive sc...
def PERT(low, peak, high, g=4.0, tag=None): """ A PERT random variate Parameters ---------- low : scalar Lower bound of the distribution support peak : scalar The location of the distribution's peak (low <= peak <= high) high : scalar Upper bound of the distribut...
def StudentT(v, tag=None): """ A Student-T random variate Parameters ---------- v : int The degrees of freedom of the distribution (must be greater than one) """ assert int(v) == v and v >= 1, 'Student-T "v" must be an integer greater than 0' return uv(ss.t(v), tag=tag)
def Triangular(low, peak, high, tag=None): """ A triangular random variate Parameters ---------- low : scalar Lower bound of the distribution support peak : scalar The location of the triangle's peak (low <= peak <= high) high : scalar Upper bound of the distribu...
def Uniform(low, high, tag=None): """ A Uniform random variate Parameters ---------- low : scalar Lower bound of the distribution support. high : scalar Upper bound of the distribution support. """ assert low < high, 'Uniform "low" must be less than "high"' retur...
def Weibull(lamda, k, tag=None): """ A Weibull random variate Parameters ---------- lamda : scalar The scale parameter k : scalar The shape parameter """ assert ( lamda > 0 and k > 0 ), 'Weibull "lamda" and "k" parameters must be greater than zero' re...
def Bernoulli(p, tag=None): """ A Bernoulli random variate Parameters ---------- p : scalar The probability of success """ assert ( 0 < p < 1 ), 'Bernoulli probability "p" must be between zero and one, non-inclusive' return uv(ss.bernoulli(p), tag=tag)
def Binomial(n, p, tag=None): """ A Binomial random variate Parameters ---------- n : int The number of trials p : scalar The probability of success """ assert ( int(n) == n and n > 0 ), 'Binomial number of trials "n" must be an integer greater than zero'...
def Geometric(p, tag=None): """ A Geometric random variate Parameters ---------- p : scalar The probability of success """ assert ( 0 < p < 1 ), 'Geometric probability "p" must be between zero and one, non-inclusive' return uv(ss.geom(p), tag=tag)
def Hypergeometric(N, n, K, tag=None): """ A Hypergeometric random variate Parameters ---------- N : int The total population size n : int The number of individuals of interest in the population K : int The number of individuals that will be chosen from the popul...
def Poisson(lamda, tag=None): """ A Poisson random variate Parameters ---------- lamda : scalar The rate of an occurance within a specified interval of time or space. """ assert lamda > 0, 'Poisson "lamda" must be greater than zero.' return uv(ss.poisson(lamda), tag=tag)
def covariance_matrix(nums_with_uncert): """ Calculate the covariance matrix of uncertain variables, oriented by the order of the inputs Parameters ---------- nums_with_uncert : array-like A list of variables that have an associated uncertainty Returns ------- cov_m...
def correlation_matrix(nums_with_uncert): """ Calculate the correlation matrix of uncertain variables, oriented by the order of the inputs Parameters ---------- nums_with_uncert : array-like A list of variables that have an associated uncertainty Returns ------- cor...
def var(self): """ Variance value as a result of an uncertainty calculation """ mn = self.mean vr = np.mean((self._mcpts - mn) ** 2) return vr
def skew(self): r""" Skewness coefficient value as a result of an uncertainty calculation, defined as:: _____ m3 \/beta1 = ------ std**3 where m3 is the third central moment and std is the standard deviation ...
def kurt(self): """ Kurtosis coefficient value as a result of an uncertainty calculation, defined as:: m4 beta2 = ------ std**4 where m4 is the fourth central moment and std is the standard deviation """ ...
def stats(self): """ The first four standard moments of a distribution: mean, variance, and standardized skewness and kurtosis coefficients. """ mn = self.mean vr = self.var sk = self.skew kt = self.kurt return [mn, vr, sk, kt]
def percentile(self, val): """ Get the distribution value at a given percentile or set of percentiles. This follows the NIST method for calculating percentiles. Parameters ---------- val : scalar or array Either a single value or an array of values be...
def describe(self, name=None): """ Cleanly show what the four displayed distribution moments are: - Mean - Variance - Standardized Skewness Coefficient - Standardized Kurtosis Coefficient For a standard Normal distribution, these are [0, 1...
def plot(self, hist=False, show=False, **kwargs): """ Plot the distribution of the UncertainFunction. By default, the distribution is shown with a kernel density estimate (kde). Optional -------- hist : bool If true, a density histogram is displayed (...
def plot(self, hist=False, show=False, **kwargs): """ Plot the distribution of the UncertainVariable. Continuous distributions are plotted with a line plot and discrete distributions are plotted with discrete circles. Optional -------- hist : bool ...
def load_hat(self, path): # pylint: disable=no-self-use """Loads the hat from a picture at path. Args: path: The path to load from Returns: The hat data. """ hat = cv2.imread(path, cv2.IMREAD_UNCHANGED) if hat is None: raise ValueErr...
def find_faces(self, image, draw_box=False): """Uses a haarcascade to detect faces inside an image. Args: image: The image. draw_box: If True, the image will be marked with a rectangle. Return: The faces as returned by OpenCV's detectMultiScale method for ...
def find_resources(self, rsrc_type, sort=None, yield_pages=False, **kwargs): """Find instances of `rsrc_type` that match the filter in `**kwargs`""" return rsrc_type.find(self, sort=sort, yield_pages=yield_pages, **kwargs)
def changed(self, message=None, *args): """Marks the object as changed. If a `parent` attribute is set, the `changed()` method on the parent will be called, propagating the change notification up the chain. The message (if provided) will be debug logged. """ if message ...
def register(cls, origin_type): """Decorator for mutation tracker registration. The provided `origin_type` is mapped to the decorated class such that future calls to `convert()` will convert the object of `origin_type` to an instance of the decorated class. """ def decor...
def convert(cls, obj, parent): """Converts objects to registered tracked types This checks the type of the given object against the registered tracked types. When a match is found, the given object will be converted to the tracked type, its parent set to the provided parent, and returne...