Search is not available for this dataset
text
stringlengths
75
104k
def delete_tags(self, *payload): """ Delete a group of tags pass in up to 50 tags, or use *[tags] """ if len(payload) > 50: raise ze.TooManyItems("Only 50 tags or fewer may be deleted") modified_tags = " || ".join([tag for tag in payload]) # first, ge...
def delete_item(self, payload, last_modified=None): """ Delete Items from a Zotero library Accepts a single argument: a dict containing item data OR a list of dicts containing item data """ params = None if isinstance(payload, list): pa...
def _validate(self, conditions): """ Validate saved search conditions, raising an error if any contain invalid operators """ allowed_keys = set(self.searchkeys) operators_set = set(self.operators.keys()) for condition in conditions: if set(condition.keys()) != allowed_keys: ...
def _verify(self, payload): """ ensure that all files to be attached exist open()'s better than exists(), cos it avoids a race condition """ if not payload: # Check payload has nonzero length raise ze.ParamNotPassed for templt in payload: if os.pa...
def _create_prelim(self): """ Step 0: Register intent to upload files """ self._verify(self.payload) if "key" in self.payload[0] and self.payload[0]["key"]: if next((i for i in self.payload if "key" not in i), False): raise ze.UnsupportedParams( ...
def _get_auth(self, attachment, reg_key, md5=None): """ Step 1: get upload authorisation for a file """ mtypes = mimetypes.guess_type(attachment) digest = hashlib.md5() with open(attachment, "rb") as att: for chunk in iter(lambda: att.read(8192), b""): ...
def _upload_file(self, authdata, attachment, reg_key): """ Step 2: auth successful, and file not on server zotero.org/support/dev/server_api/file_upload#a_full_upload reg_key isn't used, but we need to pass it through to Step 3 """ upload_dict = authdata[ "pa...
def _register_upload(self, authdata, reg_key): """ Step 3: upload successful, so register it """ reg_headers = { "Content-Type": "application/x-www-form-urlencoded", "If-None-Match": "*", } reg_headers.update(self.zinstance.default_headers()) ...
def upload(self): """ File upload functionality Goes through upload steps 0 - 3 (private class methods), and returns a dict noting success, failure, or unchanged (returning the payload entries with that property as a list for each status) """ result = {"success":...
def which(program, win_allow_cross_arch=True): """Identify the location of an executable file.""" def is_exe(path): return os.path.isfile(path) and os.access(path, os.X_OK) def _get_path_list(): return os.environ['PATH'].split(os.pathsep) if os.name == 'nt': def find_exe(progra...
def split_multiline(value): """Split a multiline string into a list, excluding blank lines.""" return [element for element in (line.strip() for line in value.split('\n')) if element]
def split_elements(value): """Split a string with comma or space-separated elements into a list.""" items = [v.strip() for v in value.split(',')] if len(items) == 1: items = value.split() return items
def eval_environ(value): """Evaluate environment markers.""" def eval_environ_str(value): parts = value.split(';') if len(parts) < 2: return value expr = parts[1].lstrip() if not re.match("^((\\w+(\\.\\w+)?|'.*?'|\".*?\")\\s+" '(in|==|!=|not in...
def get_cfg_value(config, section, option): """Get configuration value.""" try: value = config[section][option] except KeyError: if (section, option) in MULTI_OPTIONS: return [] else: return '' if (section, option) in MULTI_OPTIONS: value = split_m...
def set_cfg_value(config, section, option, value): """Set configuration value.""" if isinstance(value, list): value = '\n'.join(value) config[section][option] = value
def cfg_to_args(config): """Compatibility helper to use setup.cfg in setup.py.""" kwargs = {} opts_to_args = { 'metadata': [ ('name', 'name'), ('author', 'author'), ('author-email', 'author_email'), ('maintainer', 'maintainer'), ('maintaine...
def run_3to2(args=None): """Convert Python files using lib3to2.""" args = BASE_ARGS_3TO2 if args is None else BASE_ARGS_3TO2 + args try: proc = subprocess.Popen(['3to2'] + args, stderr=subprocess.PIPE) except OSError: for path in glob.glob('*.egg'): if os.path.isdir(path) and...
def write_py2k_header(file_list): """Write Python 2 shebang and add encoding cookie if needed.""" if not isinstance(file_list, list): file_list = [file_list] python_re = re.compile(br"^(#!.*\bpython)(.*)([\r\n]+)$") coding_re = re.compile(br"coding[:=]\s*([-\w.]+)") new_line_re = re.compile...
def which(program): """Identify the location of an executable file.""" if os.path.split(program)[0]: program_path = find_exe(program) if program_path: return program_path else: for path in get_path_list(): program_path = find_exe(os.path.join(path, program)) ...
def correct(text: str, matches: [Match]) -> str: """Automatically apply suggestions to the text.""" ltext = list(text) matches = [match for match in matches if match.replacements] errors = [ltext[match.offset:match.offset + match.errorlength] for match in matches] correct_offset = 0 ...
def get_version(): """Get LanguageTool version.""" version = _get_attrib().get('version') if not version: match = re.search(r"LanguageTool-?.*?(\S+)$", get_directory()) if match: version = match.group(1) return version
def get_languages() -> set: """Get supported languages.""" try: languages = cache['languages'] except KeyError: languages = LanguageTool._get_languages() cache['languages'] = languages return languages
def get_directory(): """Get LanguageTool directory.""" try: language_check_dir = cache['language_check_dir'] except KeyError: def version_key(string): return [int(e) if e.isdigit() else e for e in re.split(r"(\d+)", string)] def get_lt_dir(base_dir): ...
def set_directory(path=None): """Set LanguageTool directory.""" old_path = get_directory() terminate_server() cache.clear() if path: cache['language_check_dir'] = path try: get_jar_info() except Error: cache['language_check_dir'] = old_path ...
def check(self, text: str, srctext=None) -> [Match]: """Match text against enabled rules.""" root = self._get_root(self._url, self._encode(text, srctext)) return [Match(e.attrib) for e in root if e.tag == 'error']
def _check_api(self, text: str, srctext=None) -> bytes: """Match text against enabled rules (result in XML format).""" root = self._get_root(self._url, self._encode(text, srctext)) return (b'<?xml version="1.0" encoding="UTF-8"?>\n' + ElementTree.tostring(root) + b"\n")
def correct(self, text: str, srctext=None) -> str: """Automatically apply suggestions to the text.""" return correct(text, self.check(text, srctext))
def parse_java_version(version_text): """Return Java version (major1, major2). >>> parse_java_version('''java version "1.6.0_65" ... Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609) ... Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)) ... ''') (1, 6) >>>...
def get_newest_possible_languagetool_version(): """Return newest compatible version. >>> version = get_newest_possible_languagetool_version() >>> version in [JAVA_6_COMPATIBLE_VERSION, ... JAVA_7_COMPATIBLE_VERSION, ... LATEST_VERSION] True """ java_path = find_...
def get_common_prefix(z): """Get common directory in a zip file if any.""" name_list = z.namelist() if name_list and all(n.startswith(name_list[0]) for n in name_list[1:]): return name_list[0] return None
def _process_events(self, events): """Process events from proactor.""" for f, callback, transferred, key, ov in events: try: self._logger.debug('Invoking event callback {}'.format(callback)) value = callback(transferred, key, ov) except OSError: ...
def asyncClose(fn): """Allow to run async code before application is closed.""" @functools.wraps(fn) def wrapper(*args, **kwargs): f = asyncio.ensure_future(fn(*args, **kwargs)) while not f.done(): QApplication.instance().processEvents() return wrapper
def asyncSlot(*args): """Make a Qt async slot run on asyncio loop.""" def outer_decorator(fn): @Slot(*args) @functools.wraps(fn) def wrapper(*args, **kwargs): asyncio.ensure_future(fn(*args, **kwargs)) return wrapper return outer_decorator
def with_logger(cls): """Class decorator to add a logger to a class.""" attr_name = '_logger' cls_name = cls.__qualname__ module = cls.__module__ if module is not None: cls_name = module + '.' + cls_name else: raise AssertionError setattr(cls, attr_name, logging.getLogger(cls...
def _process_event(self, key, mask): """Selector has delivered us an event.""" self._logger.debug('Processing event with key {} and mask {}'.format(key, mask)) fileobj, (reader, writer) = key.fileobj, key.data if mask & selectors.EVENT_READ and reader is not None: if reader._...
def addSources(self, *sources): """Add more ASN.1 MIB source repositories. MibCompiler.compile will invoke each of configured source objects in order of their addition asking each to fetch MIB module specified by name. Args: sources: reader object(s) Return...
def addSearchers(self, *searchers): """Add more transformed MIBs repositories. MibCompiler.compile will invoke each of configured searcher objects in order of their addition asking each if already transformed MIB module already exists and is more recent than specified. Args: ...
def addBorrowers(self, *borrowers): """Add more transformed MIBs repositories to borrow MIBs from. Whenever MibCompiler.compile encounters MIB module which neither of the *searchers* can find or fetched ASN.1 MIB module can not be parsed (due to syntax errors), these *borrowers* objects...
def compile(self, *mibnames, **options): """Transform requested and possibly referred MIBs. The *compile* method should be invoked when *MibCompiler* object is operational meaning at least *sources* are specified. Once called with a MIB module name, *compile* will: * fetch ASN...
def t_UPPERCASE_IDENTIFIER(self, t): r'[A-Z][-a-zA-z0-9]*' if t.value in self.forbidden_words: raise error.PySmiLexerError("%s is forbidden" % t.value, lineno=t.lineno) if t.value[-1] == '-': raise error.PySmiLexerError("Identifier should not end with '-': %s" % t.value,...
def t_LOWERCASE_IDENTIFIER(self, t): r'[0-9]*[a-z][-a-zA-z0-9]*' if t.value[-1] == '-': raise error.PySmiLexerError("Identifier should not end with '-': %s" % t.value, lineno=t.lineno) return t
def t_NUMBER(self, t): r'-?[0-9]+' t.value = int(t.value) neg = 0 if t.value < 0: neg = 1 val = abs(t.value) if val <= UNSIGNED32_MAX: if neg: t.type = 'NEGATIVENUMBER' elif val <= UNSIGNED64_MAX: if neg: ...
def t_BIN_STRING(self, t): r'\'[01]*\'[bB]' value = t.value[1:-2] while value and value[0] == '0' and len(value) % 8: value = value[1:] # XXX raise in strict mode # if len(value) % 8: # raise error.PySmiLexerError("Number of 0s and 1s have to divide by...
def t_HEX_STRING(self, t): r'\'[0-9a-fA-F]*\'[hH]' value = t.value[1:-2] while value and value[0] == '0' and len(value) % 2: value = value[1:] # XXX raise in strict mode # if len(value) % 2: # raise error.PySmiLexerError("Number of symbols have to be e...
def t_QUOTED_STRING(self, t): r'\"[^\"]*\"' t.lexer.lineno += len(re.findall(r'\r\n|\n|\r', t.value)) return t
def p_modules(self, p): """modules : modules module | module""" n = len(p) if n == 3: p[0] = p[1] + [p[2]] elif n == 2: p[0] = [p[1]]
def p_importPart(self, p): """importPart : imports | empty""" # libsmi: TODO: ``IMPORTS ;'' allowed? refer ASN.1! if p[1]: importDict = {} for imp in p[1]: # don't do just dict() because moduleNames may be repeated fromModule, symbol...
def p_imports(self, p): """imports : imports import | import""" n = len(p) if n == 3: p[0] = p[1] + [p[2]] elif n == 2: p[0] = [p[1]]
def p_importIdentifiers(self, p): """importIdentifiers : importIdentifiers ',' importIdentifier | importIdentifier""" n = len(p) if n == 4: p[0] = p[1] + [p[3]] elif n == 2: p[0] = [p[1]]
def p_declarations(self, p): """declarations : declarations declaration | declaration""" n = len(p) if n == 3: p[0] = p[1] + [p[2]] elif n == 2: p[0] = [p[1]]
def p_typeDeclarationRHS(self, p): """typeDeclarationRHS : Syntax | TEXTUAL_CONVENTION DisplayPart STATUS Status DESCRIPTION Text ReferPart SYNTAX Syntax | choiceClause""" if p[1]: if p[1] == 'TEXTUAL-CONVENTION': p[...
def p_sequenceItems(self, p): """sequenceItems : sequenceItems ',' sequenceItem | sequenceItem""" # libsmi: TODO: might this list be emtpy? n = len(p) if n == 4: p[0] = p[1] + [p[3]] elif n == 2: p[0] = [p[1]]
def p_Syntax(self, p): """Syntax : ObjectSyntax | BITS '{' NamedBits '}'""" # libsmi: TODO: standalone `BITS' ok? seen in RMON2-MIB # libsmi: -> no, it's only allowed in a SEQUENCE {...} n = len(p) if n == 2: p[0] = p[1] elif n == 5: ...
def p_NamedBits(self, p): """NamedBits : NamedBits ',' NamedBit | NamedBit""" n = len(p) if n == 4: p[0] = p[1] + [p[3]] elif n == 2: p[0] = [p[1]]
def p_objectIdentityClause(self, p): """objectIdentityClause : LOWERCASE_IDENTIFIER OBJECT_IDENTITY STATUS Status DESCRIPTION Text ReferPart COLON_COLON_EQUAL '{' objectIdentifier '}'""" p[0] = ('objectIdentityClause', p[1], # id # p[2], # OBJECT_IDENTITY p[4], # statu...
def p_objectTypeClause(self, p): """objectTypeClause : LOWERCASE_IDENTIFIER OBJECT_TYPE SYNTAX Syntax UnitsPart MaxOrPIBAccessPart STATUS Status descriptionClause ReferPart IndexPart MibIndex DefValPart COLON_COLON_EQUAL '{' ObjectName '}'""" p[0] = ('objectTypeClause', p[1], # id # p[...
def p_VarTypes(self, p): """VarTypes : VarTypes ',' VarType | VarType""" n = len(p) if n == 4: p[0] = ('VarTypes', p[1][1] + [p[3]]) elif n == 2: p[0] = ('VarTypes', [p[1]])
def p_moduleIdentityClause(self, p): """moduleIdentityClause : LOWERCASE_IDENTIFIER MODULE_IDENTITY SubjectCategoriesPart LAST_UPDATED ExtUTCTime ORGANIZATION Text CONTACT_INFO Text DESCRIPTION Text RevisionPart COLON_COLON_EQUAL '{' objectIdentifier '}'""" p[0] = ('moduleIdentityClause', p[1], # id ...
def p_ObjectSyntax(self, p): """ObjectSyntax : SimpleSyntax | conceptualTable | row | entryType | ApplicationSyntax | typeTag SimpleSyntax""" n = len(p) if n == 2: ...
def p_SimpleSyntax(self, p): """SimpleSyntax : INTEGER | INTEGER integerSubType | INTEGER enumSpec | INTEGER32 | INTEGER32 integerSubType | UPPERCASE_IDENTIFIER enumSpec ...
def p_valueofSimpleSyntax(self, p): """valueofSimpleSyntax : NUMBER | NEGATIVENUMBER | NUMBER64 | NEGATIVENUMBER64 | HEX_STRING | BIN_STRING ...
def p_sequenceSimpleSyntax(self, p): """sequenceSimpleSyntax : INTEGER anySubType | INTEGER32 anySubType | OCTET STRING anySubType | OBJECT IDENTIFIER anySubType""" n = len(p) if n == 3: p...
def p_ApplicationSyntax(self, p): """ApplicationSyntax : IPADDRESS anySubType | COUNTER32 | COUNTER32 integerSubType | GAUGE32 | GAUGE32 integerSubType | UNSIGNED32 ...
def p_sequenceApplicationSyntax(self, p): """sequenceApplicationSyntax : IPADDRESS anySubType | COUNTER32 anySubType | GAUGE32 anySubType | UNSIGNED32 anySubType | ...
def p_ranges(self, p): """ranges : ranges '|' range | range""" n = len(p) if n == 4: p[0] = p[1] + [p[3]] elif n == 2: p[0] = [p[1]]
def p_range(self, p): """range : value DOT_DOT value | value""" n = len(p) if n == 2: p[0] = (p[1],) elif n == 4: p[0] = (p[1], p[3])
def p_enumItems(self, p): """enumItems : enumItems ',' enumItem | enumItem""" n = len(p) if n == 4: p[0] = p[1] + [p[3]] elif n == 2: p[0] = [p[1]]
def p_IndexTypes(self, p): """IndexTypes : IndexTypes ',' IndexType | IndexType""" n = len(p) if n == 4: p[0] = p[1] + [p[3]] elif n == 2: p[0] = [p[1]]
def p_IndexType(self, p): """IndexType : IMPLIED Index | Index""" n = len(p) if n == 2: p[0] = (0, p[1]) elif n == 3: p[0] = (1, p[2])
def p_Value(self, p): """Value : valueofObjectSyntax | '{' BitsValue '}'""" n = len(p) if n == 2: p[0] = p[1] elif n == 4: p[0] = p[2]
def p_BitNames(self, p): """BitNames : BitNames ',' LOWERCASE_IDENTIFIER | LOWERCASE_IDENTIFIER""" n = len(p) if n == 4: p[0] = ('BitNames', p[1][1] + [p[3]]) elif n == 2: p[0] = ('BitNames', [p[1]])
def p_Revisions(self, p): """Revisions : Revisions Revision | Revision""" n = len(p) if n == 3: p[0] = ('Revisions', p[1][1] + [p[2]]) elif n == 2: p[0] = ('Revisions', [p[1]])
def p_Objects(self, p): """Objects : Objects ',' Object | Object""" n = len(p) if n == 4: p[0] = ('Objects', p[1][1] + [p[3]]) elif n == 2: p[0] = ('Objects', [p[1]])
def p_Notifications(self, p): """Notifications : Notifications ',' Notification | Notification""" n = len(p) if n == 4: p[0] = ('Notifications', p[1][1] + [p[3]]) elif n == 2: p[0] = ('Notifications', [p[1]])
def p_subidentifiers(self, p): """subidentifiers : subidentifiers subidentifier | subidentifier""" n = len(p) if n == 3: p[0] = p[1] + [p[2]] elif n == 2: p[0] = [p[1]]
def p_subidentifier(self, p): """subidentifier : fuzzy_lowercase_identifier | NUMBER | LOWERCASE_IDENTIFIER '(' NUMBER ')'""" n = len(p) if n == 2: p[0] = p[1] elif n == 5: # NOTE: we are not creating new symbol p[...
def p_subidentifiers_defval(self, p): """subidentifiers_defval : subidentifiers_defval subidentifier_defval | subidentifier_defval""" n = len(p) if n == 3: p[0] = ('subidentifiers_defval', p[1][1] + [p[2]]) elif n == 2: p[0] = ('su...
def p_subidentifier_defval(self, p): """subidentifier_defval : LOWERCASE_IDENTIFIER '(' NUMBER ')' | NUMBER""" n = len(p) if n == 2: p[0] = ('subidentifier_defval', p[1]) elif n == 5: p[0] = ('subidentifier_defval', p[1], p[3])
def p_objectGroupClause(self, p): """objectGroupClause : LOWERCASE_IDENTIFIER OBJECT_GROUP ObjectGroupObjectsPart STATUS Status DESCRIPTION Text ReferPart COLON_COLON_EQUAL '{' objectIdentifier '}'""" p[0] = ('objectGroupClause', p[1], # id p[3], # objects ...
def p_notificationGroupClause(self, p): """notificationGroupClause : LOWERCASE_IDENTIFIER NOTIFICATION_GROUP NotificationsPart STATUS Status DESCRIPTION Text ReferPart COLON_COLON_EQUAL '{' objectIdentifier '}'""" p[0] = ('notificationGroupClause', p[1], # id p[3], # no...
def p_moduleComplianceClause(self, p): """moduleComplianceClause : LOWERCASE_IDENTIFIER MODULE_COMPLIANCE STATUS Status DESCRIPTION Text ReferPart ComplianceModulePart COLON_COLON_EQUAL '{' objectIdentifier '}'""" p[0] = ('moduleComplianceClause', p[1], # id # p[2], # M...
def p_ComplianceModules(self, p): """ComplianceModules : ComplianceModules ComplianceModule | ComplianceModule""" n = len(p) if n == 3: p[0] = ('ComplianceModules', p[1][1] + [p[2]]) elif n == 2: p[0] = ('ComplianceModules', [p[1]])
def p_ComplianceModule(self, p): """ComplianceModule : MODULE ComplianceModuleName MandatoryPart CompliancePart""" objects = p[3] and p[3][1] or [] objects += p[4] and p[4][1] or [] p[0] = (p[2], # ModuleName objects)
def p_MandatoryGroups(self, p): """MandatoryGroups : MandatoryGroups ',' MandatoryGroup | MandatoryGroup""" n = len(p) if n == 4: p[0] = ('MandatoryGroups', p[1][1] + [p[3]]) elif n == 2: p[0] = ('MandatoryGroups', [p[1]])
def p_Compliances(self, p): """Compliances : Compliances Compliance | Compliance""" n = len(p) if n == 3: p[0] = p[1] and p[2] and ('Compliances', p[1][1] + [p[2]]) or p[1] elif n == 2: p[0] = p[1] and ('Compliances', [p[1]]) or None
def p_agentCapabilitiesClause(self, p): """agentCapabilitiesClause : LOWERCASE_IDENTIFIER AGENT_CAPABILITIES PRODUCT_RELEASE Text STATUS Status DESCRIPTION Text ReferPart ModulePart_Capabilities COLON_COLON_EQUAL '{' objectIdentifier '}'""" p[0] = ('agentCapabilitiesClause', p[1], # id ...
def p_Cells(self, p): """Cells : Cells ',' Cell | Cell""" n = len(p) if n == 4: p[0] = ('Cells', p[1][1] + [p[3]]) elif n == 2: p[0] = ('Cells', [p[1]])
def p_typeSMIv1(self, p): """typeSMIv1 : INTEGER | OCTET STRING | IPADDRESS | NETWORKADDRESS""" n = len(p) indextype = n == 3 and p[1] + ' ' + p[2] or p[1] p[0] = indextype
def p_enumItems(self, p): """enumItems : enumItems ',' enumItem | enumItem | enumItems enumItem | enumItems ','""" n = len(p) if n == 4: p[0] = p[1] + [p[3]] elif n == 2: p[0] = [p[1]] elif n =...
def p_notificationTypeClause(self, p): """notificationTypeClause : fuzzy_lowercase_identifier NOTIFICATION_TYPE NotificationObjectsPart STATUS Status DESCRIPTION Text ReferPart COLON_COLON_EQUAL '{' NotificationName '}'""" # some MIBs have uppercase and/or lowercase id p[0] = ('notificationTypeClause',...
def p_trapTypeClause(self, p): """trapTypeClause : fuzzy_lowercase_identifier TRAP_TYPE EnterprisePart VarPart DescrPart ReferPart COLON_COLON_EQUAL NUMBER""" # libsmi: TODO: range of number? p[0] = ('trapTypeClause', p[1], # fuzzy_lowercase_identifier # p[2], # TRAP_TYPE ...
def p_EnterprisePart(self, p): """EnterprisePart : ENTERPRISE objectIdentifier | ENTERPRISE '{' objectIdentifier '}'""" n = len(p) if n == 3: p[0] = p[2] elif n == 5: # common mistake case p[0] = p[3]
def p_CreationPart(self, p): """CreationPart : CREATION_REQUIRES '{' Cells '}' | CREATION_REQUIRES '{' '}' | empty""" n = len(p) if n == 5: p[0] = (p[1], p[3])
def AIC(N, rho, k): r"""Akaike Information Criterion :param rho: rho at order k :param N: sample size :param k: AR order. If k is the AR order and N the size of the sample, then Akaike criterion is .. math:: AIC(k) = \log(\rho_k) + 2\frac{k+1}{N} :: AIC(64, [0.5,0.3,0.2], [1,2,3...
def AICc(N, rho, k, norm=True): r"""corrected Akaike information criterion .. math:: AICc(k) = log(\rho_k) + 2 \frac{k+1}{N-k-2} :validation: double checked versus octave. """ from numpy import log, array p = k #todo check convention. agrees with octave res = log(rho) + 2. * (p+1) / (N-p...
def KIC(N, rho, k): r"""Kullback information criterion .. math:: KIC(k) = log(\rho_k) + 3 \frac{k+1}{N} :validation: double checked versus octave. """ from numpy import log, array res = log(rho) + 3. * (k+1.) /float(N) return res
def AKICc(N, rho, k): r"""approximate corrected Kullback information .. math:: AKICc(k) = log(rho_k) + \frac{p}{N*(N-k)} + (3-\frac{k+2}{N})*\frac{k+1}{N-k-2} """ from numpy import log, array p = k res = log(rho) + p/N/(N-p) + (3.-(p+2.)/N) * (p+1.) / (N-p-2.) return res
def FPE(N,rho, k=None): r"""Final prediction error criterion .. math:: FPE(k) = \frac{N + k + 1}{N - k - 1} \rho_k :validation: double checked versus octave. """ #k #todo check convention. agrees with octave fpe = rho * (N + k + 1.) / (N- k -1) return fpe
def MDL(N, rho, k): r"""Minimum Description Length .. math:: MDL(k) = N log \rho_k + p \log N :validation: results """ from numpy import log #p = arange(1, len(rho)+1) mdl = N* log(rho) + k * log(N) return mdl
def CAT(N, rho, k): r"""Criterion Autoregressive Transfer Function : .. math:: CAT(k) = \frac{1}{N} \sum_{i=1}^k \frac{1}{\rho_i} - \frac{\rho_i}{\rho_k} .. todo:: validation """ from numpy import zeros, arange cat = zeros(len(rho)) for p in arange(1, len(rho)+1): rho_p = float(N)...