repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
python-diamond/Diamond
src/diamond/handler/sentry.py
SentryHandler.process
def process(self, metric): """ process a single metric @type metric: diamond.metric.Metric @param metric: metric to process @rtype None """ for rule in self.rules: rule.process(metric, self)
python
def process(self, metric): """ process a single metric @type metric: diamond.metric.Metric @param metric: metric to process @rtype None """ for rule in self.rules: rule.process(metric, self)
[ "def", "process", "(", "self", ",", "metric", ")", ":", "for", "rule", "in", "self", ".", "rules", ":", "rule", ".", "process", "(", "metric", ",", "self", ")" ]
process a single metric @type metric: diamond.metric.Metric @param metric: metric to process @rtype None
[ "process", "a", "single", "metric" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/sentry.py#L349-L357
train
python-diamond/Diamond
src/collectors/network/network.py
NetworkCollector.collect
def collect(self): """ Collect network interface stats. """ # Initialize results results = {} if os.access(self.PROC, os.R_OK): # Open File file = open(self.PROC) # Build Regular Expression greed = '' if str_t...
python
def collect(self): """ Collect network interface stats. """ # Initialize results results = {} if os.access(self.PROC, os.R_OK): # Open File file = open(self.PROC) # Build Regular Expression greed = '' if str_t...
[ "def", "collect", "(", "self", ")", ":", "# Initialize results", "results", "=", "{", "}", "if", "os", ".", "access", "(", "self", ".", "PROC", ",", "os", ".", "R_OK", ")", ":", "# Open File", "file", "=", "open", "(", "self", ".", "PROC", ")", "# ...
Collect network interface stats.
[ "Collect", "network", "interface", "stats", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/network/network.py#L51-L133
train
python-diamond/Diamond
src/collectors/conntrack/conntrack.py
ConnTrackCollector.get_default_config_help
def get_default_config_help(self): """ Return help text for collector configuration """ config_help = super(ConnTrackCollector, self).get_default_config_help() config_help.update({ "dir": "Directories with files of interest, comma seperated", "files":...
python
def get_default_config_help(self): """ Return help text for collector configuration """ config_help = super(ConnTrackCollector, self).get_default_config_help() config_help.update({ "dir": "Directories with files of interest, comma seperated", "files":...
[ "def", "get_default_config_help", "(", "self", ")", ":", "config_help", "=", "super", "(", "ConnTrackCollector", ",", "self", ")", ".", "get_default_config_help", "(", ")", "config_help", ".", "update", "(", "{", "\"dir\"", ":", "\"Directories with files of interest...
Return help text for collector configuration
[ "Return", "help", "text", "for", "collector", "configuration" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/conntrack/conntrack.py#L22-L31
train
python-diamond/Diamond
src/collectors/netapp/netapp.py
NetAppCollector._replace_and_publish
def _replace_and_publish(self, path, prettyname, value, device): """ Inputs a complete path for a metric and a value. Replace the metric name and publish. """ if value is None: return newpath = path # Change metric name before publish if needed. ...
python
def _replace_and_publish(self, path, prettyname, value, device): """ Inputs a complete path for a metric and a value. Replace the metric name and publish. """ if value is None: return newpath = path # Change metric name before publish if needed. ...
[ "def", "_replace_and_publish", "(", "self", ",", "path", ",", "prettyname", ",", "value", ",", "device", ")", ":", "if", "value", "is", "None", ":", "return", "newpath", "=", "path", "# Change metric name before publish if needed.", "newpath", "=", "\".\"", ".",...
Inputs a complete path for a metric and a value. Replace the metric name and publish.
[ "Inputs", "a", "complete", "path", "for", "a", "metric", "and", "a", "value", ".", "Replace", "the", "metric", "name", "and", "publish", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/netapp/netapp.py#L204-L215
train
python-diamond/Diamond
src/collectors/netapp/netapp.py
NetAppCollector._gen_delta_depend
def _gen_delta_depend(self, path, derivative, multiplier, prettyname, device): """ For some metrics we need to divide the delta for one metric with the delta of another. Publishes a metric if the convertion goes well. """ primary_delta = derivati...
python
def _gen_delta_depend(self, path, derivative, multiplier, prettyname, device): """ For some metrics we need to divide the delta for one metric with the delta of another. Publishes a metric if the convertion goes well. """ primary_delta = derivati...
[ "def", "_gen_delta_depend", "(", "self", ",", "path", ",", "derivative", ",", "multiplier", ",", "prettyname", ",", "device", ")", ":", "primary_delta", "=", "derivative", "[", "path", "]", "shortpath", "=", "\".\"", ".", "join", "(", "path", ".", "split",...
For some metrics we need to divide the delta for one metric with the delta of another. Publishes a metric if the convertion goes well.
[ "For", "some", "metrics", "we", "need", "to", "divide", "the", "delta", "for", "one", "metric", "with", "the", "delta", "of", "another", ".", "Publishes", "a", "metric", "if", "the", "convertion", "goes", "well", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/netapp/netapp.py#L217-L240
train
python-diamond/Diamond
src/collectors/netapp/netapp.py
NetAppCollector._gen_delta_per_sec
def _gen_delta_per_sec(self, path, value_delta, time_delta, multiplier, prettyname, device): """ Calulates the difference between to point, and scales is to per second. """ if time_delta < 0: return value = (value_delta / time_delta) * multi...
python
def _gen_delta_per_sec(self, path, value_delta, time_delta, multiplier, prettyname, device): """ Calulates the difference between to point, and scales is to per second. """ if time_delta < 0: return value = (value_delta / time_delta) * multi...
[ "def", "_gen_delta_per_sec", "(", "self", ",", "path", ",", "value_delta", ",", "time_delta", ",", "multiplier", ",", "prettyname", ",", "device", ")", ":", "if", "time_delta", "<", "0", ":", "return", "value", "=", "(", "value_delta", "/", "time_delta", "...
Calulates the difference between to point, and scales is to per second.
[ "Calulates", "the", "difference", "between", "to", "point", "and", "scales", "is", "to", "per", "second", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/netapp/netapp.py#L242-L253
train
python-diamond/Diamond
src/diamond/handler/datadog.py
DatadogHandler._send
def _send(self): """ Take metrics from queue and send it to Datadog API """ while len(self.queue) > 0: metric = self.queue.popleft() path = '%s.%s.%s' % ( metric.getPathPrefix(), metric.getCollectorPath(), metric.g...
python
def _send(self): """ Take metrics from queue and send it to Datadog API """ while len(self.queue) > 0: metric = self.queue.popleft() path = '%s.%s.%s' % ( metric.getPathPrefix(), metric.getCollectorPath(), metric.g...
[ "def", "_send", "(", "self", ")", ":", "while", "len", "(", "self", ".", "queue", ")", ">", "0", ":", "metric", "=", "self", ".", "queue", ".", "popleft", "(", ")", "path", "=", "'%s.%s.%s'", "%", "(", "metric", ".", "getPathPrefix", "(", ")", ",...
Take metrics from queue and send it to Datadog API
[ "Take", "metrics", "from", "queue", "and", "send", "it", "to", "Datadog", "API" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/datadog.py#L84-L106
train
python-diamond/Diamond
setup.py
get_version
def get_version(): """ Read the version.txt file to get the new version string Generate it if version.txt is not available. Generation is required for pip installs """ try: f = open('version.txt') except IOError: os.system("./version.sh > version.txt") f =...
python
def get_version(): """ Read the version.txt file to get the new version string Generate it if version.txt is not available. Generation is required for pip installs """ try: f = open('version.txt') except IOError: os.system("./version.sh > version.txt") f =...
[ "def", "get_version", "(", ")", ":", "try", ":", "f", "=", "open", "(", "'version.txt'", ")", "except", "IOError", ":", "os", ".", "system", "(", "\"./version.sh > version.txt\"", ")", "f", "=", "open", "(", "'version.txt'", ")", "version", "=", "''", "....
Read the version.txt file to get the new version string Generate it if version.txt is not available. Generation is required for pip installs
[ "Read", "the", "version", ".", "txt", "file", "to", "get", "the", "new", "version", "string", "Generate", "it", "if", "version", ".", "txt", "is", "not", "available", ".", "Generation", "is", "required", "for", "pip", "installs" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/setup.py#L98-L111
train
python-diamond/Diamond
setup.py
pkgPath
def pkgPath(root, path, rpath="/"): """ Package up a path recursively """ global data_files if not os.path.exists(path): return files = [] for spath in os.listdir(path): # Ignore test directories if spath == 'test': continue subpath = os.path.j...
python
def pkgPath(root, path, rpath="/"): """ Package up a path recursively """ global data_files if not os.path.exists(path): return files = [] for spath in os.listdir(path): # Ignore test directories if spath == 'test': continue subpath = os.path.j...
[ "def", "pkgPath", "(", "root", ",", "path", ",", "rpath", "=", "\"/\"", ")", ":", "global", "data_files", "if", "not", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "return", "files", "=", "[", "]", "for", "spath", "in", "os", ".", "li...
Package up a path recursively
[ "Package", "up", "a", "path", "recursively" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/setup.py#L114-L132
train
python-diamond/Diamond
src/diamond/handler/statsite.py
StatsiteHandler._send
def _send(self, data): """ Send data to statsite. Data that can not be sent will be queued. """ retry = self.RETRY # Attempt to send any data in the queue while retry > 0: # Check socket if not self.socket: # Log Error ...
python
def _send(self, data): """ Send data to statsite. Data that can not be sent will be queued. """ retry = self.RETRY # Attempt to send any data in the queue while retry > 0: # Check socket if not self.socket: # Log Error ...
[ "def", "_send", "(", "self", ",", "data", ")", ":", "retry", "=", "self", ".", "RETRY", "# Attempt to send any data in the queue", "while", "retry", ">", "0", ":", "# Check socket", "if", "not", "self", ".", "socket", ":", "# Log Error", "self", ".", "log", ...
Send data to statsite. Data that can not be sent will be queued.
[ "Send", "data", "to", "statsite", ".", "Data", "that", "can", "not", "be", "sent", "will", "be", "queued", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/statsite.py#L127-L159
train
python-diamond/Diamond
src/diamond/handler/statsite.py
StatsiteHandler._connect
def _connect(self): """ Connect to the statsite server """ # Create socket if self.udpport > 0: self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.port = self.udpport elif self.tcpport > 0: self.socket = socket.socket(s...
python
def _connect(self): """ Connect to the statsite server """ # Create socket if self.udpport > 0: self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.port = self.udpport elif self.tcpport > 0: self.socket = socket.socket(s...
[ "def", "_connect", "(", "self", ")", ":", "# Create socket", "if", "self", ".", "udpport", ">", "0", ":", "self", ".", "socket", "=", "socket", ".", "socket", "(", "socket", ".", "AF_INET", ",", "socket", ".", "SOCK_DGRAM", ")", "self", ".", "port", ...
Connect to the statsite server
[ "Connect", "to", "the", "statsite", "server" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/statsite.py#L161-L192
train
python-diamond/Diamond
src/diamond/utils/classes.py
load_include_path
def load_include_path(paths): """ Scan for and add paths to the include path """ for path in paths: # Verify the path is valid if not os.path.isdir(path): continue # Add path to the system path, to avoid name clashes # with mysql-connector for example ... ...
python
def load_include_path(paths): """ Scan for and add paths to the include path """ for path in paths: # Verify the path is valid if not os.path.isdir(path): continue # Add path to the system path, to avoid name clashes # with mysql-connector for example ... ...
[ "def", "load_include_path", "(", "paths", ")", ":", "for", "path", "in", "paths", ":", "# Verify the path is valid", "if", "not", "os", ".", "path", ".", "isdir", "(", "path", ")", ":", "continue", "# Add path to the system path, to avoid name clashes", "# with mysq...
Scan for and add paths to the include path
[ "Scan", "for", "and", "add", "paths", "to", "the", "include", "path" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/utils/classes.py#L19-L36
train
python-diamond/Diamond
src/diamond/utils/classes.py
load_dynamic_class
def load_dynamic_class(fqn, subclass): """ Dynamically load fqn class and verify it's a subclass of subclass """ if not isinstance(fqn, basestring): return fqn cls = load_class_from_name(fqn) if cls == subclass or not issubclass(cls, subclass): raise TypeError("%s is not a vali...
python
def load_dynamic_class(fqn, subclass): """ Dynamically load fqn class and verify it's a subclass of subclass """ if not isinstance(fqn, basestring): return fqn cls = load_class_from_name(fqn) if cls == subclass or not issubclass(cls, subclass): raise TypeError("%s is not a vali...
[ "def", "load_dynamic_class", "(", "fqn", ",", "subclass", ")", ":", "if", "not", "isinstance", "(", "fqn", ",", "basestring", ")", ":", "return", "fqn", "cls", "=", "load_class_from_name", "(", "fqn", ")", "if", "cls", "==", "subclass", "or", "not", "iss...
Dynamically load fqn class and verify it's a subclass of subclass
[ "Dynamically", "load", "fqn", "class", "and", "verify", "it", "s", "a", "subclass", "of", "subclass" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/utils/classes.py#L39-L51
train
python-diamond/Diamond
src/diamond/utils/classes.py
load_collectors_from_paths
def load_collectors_from_paths(paths): """ Scan for collectors to load from path """ # Initialize return value collectors = {} if paths is None: return if isinstance(paths, basestring): paths = paths.split(',') paths = map(str.strip, paths) load_include_path(pa...
python
def load_collectors_from_paths(paths): """ Scan for collectors to load from path """ # Initialize return value collectors = {} if paths is None: return if isinstance(paths, basestring): paths = paths.split(',') paths = map(str.strip, paths) load_include_path(pa...
[ "def", "load_collectors_from_paths", "(", "paths", ")", ":", "# Initialize return value", "collectors", "=", "{", "}", "if", "paths", "is", "None", ":", "return", "if", "isinstance", "(", "paths", ",", "basestring", ")", ":", "paths", "=", "paths", ".", "spl...
Scan for collectors to load from path
[ "Scan", "for", "collectors", "to", "load", "from", "path" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/utils/classes.py#L112-L181
train
python-diamond/Diamond
src/diamond/utils/classes.py
load_collectors_from_entry_point
def load_collectors_from_entry_point(path): """ Load collectors that were installed into an entry_point. """ collectors = {} for ep in pkg_resources.iter_entry_points(path): try: mod = ep.load() except Exception: logger.error('Failed to import entry_point: %s....
python
def load_collectors_from_entry_point(path): """ Load collectors that were installed into an entry_point. """ collectors = {} for ep in pkg_resources.iter_entry_points(path): try: mod = ep.load() except Exception: logger.error('Failed to import entry_point: %s....
[ "def", "load_collectors_from_entry_point", "(", "path", ")", ":", "collectors", "=", "{", "}", "for", "ep", "in", "pkg_resources", ".", "iter_entry_points", "(", "path", ")", ":", "try", ":", "mod", "=", "ep", ".", "load", "(", ")", "except", "Exception", ...
Load collectors that were installed into an entry_point.
[ "Load", "collectors", "that", "were", "installed", "into", "an", "entry_point", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/utils/classes.py#L184-L198
train
python-diamond/Diamond
src/diamond/utils/classes.py
get_collectors_from_module
def get_collectors_from_module(mod): """ Locate all of the collector classes within a given module """ for attrname in dir(mod): attr = getattr(mod, attrname) # Only attempt to load classes that are infact classes # are Collectors but are not the base Collector class if (...
python
def get_collectors_from_module(mod): """ Locate all of the collector classes within a given module """ for attrname in dir(mod): attr = getattr(mod, attrname) # Only attempt to load classes that are infact classes # are Collectors but are not the base Collector class if (...
[ "def", "get_collectors_from_module", "(", "mod", ")", ":", "for", "attrname", "in", "dir", "(", "mod", ")", ":", "attr", "=", "getattr", "(", "mod", ",", "attrname", ")", "# Only attempt to load classes that are infact classes", "# are Collectors but are not the base Co...
Locate all of the collector classes within a given module
[ "Locate", "all", "of", "the", "collector", "classes", "within", "a", "given", "module" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/utils/classes.py#L201-L226
train
python-diamond/Diamond
src/diamond/handler/mysql.py
MySQLHandler._send
def _send(self, data): """ Insert the data """ data = data.strip().split(' ') try: cursor = self.conn.cursor() cursor.execute("INSERT INTO %s (%s, %s, %s) VALUES(%%s, %%s, %%s)" % (self.table, self.col_metric, ...
python
def _send(self, data): """ Insert the data """ data = data.strip().split(' ') try: cursor = self.conn.cursor() cursor.execute("INSERT INTO %s (%s, %s, %s) VALUES(%%s, %%s, %%s)" % (self.table, self.col_metric, ...
[ "def", "_send", "(", "self", ",", "data", ")", ":", "data", "=", "data", ".", "strip", "(", ")", ".", "split", "(", "' '", ")", "try", ":", "cursor", "=", "self", ".", "conn", ".", "cursor", "(", ")", "cursor", ".", "execute", "(", "\"INSERT INTO...
Insert the data
[ "Insert", "the", "data" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/mysql.py#L73-L90
train
python-diamond/Diamond
src/diamond/handler/mysql.py
MySQLHandler._connect
def _connect(self): """ Connect to the MySQL server """ self._close() self.conn = MySQLdb.Connect(host=self.hostname, port=self.port, user=self.username, passwd=self.passwo...
python
def _connect(self): """ Connect to the MySQL server """ self._close() self.conn = MySQLdb.Connect(host=self.hostname, port=self.port, user=self.username, passwd=self.passwo...
[ "def", "_connect", "(", "self", ")", ":", "self", ".", "_close", "(", ")", "self", ".", "conn", "=", "MySQLdb", ".", "Connect", "(", "host", "=", "self", ".", "hostname", ",", "port", "=", "self", ".", "port", ",", "user", "=", "self", ".", "user...
Connect to the MySQL server
[ "Connect", "to", "the", "MySQL", "server" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/mysql.py#L92-L101
train
python-diamond/Diamond
src/collectors/nvidia_gpu/nvidia_gpu.py
NvidiaGPUCollector.collect
def collect(self): """ Collector GPU stats """ stats_config = self.config['stats'] if USE_PYTHON_BINDING: collect_metrics = self.collect_via_pynvml else: collect_metrics = self.collect_via_nvidia_smi collect_metrics(stats_config)
python
def collect(self): """ Collector GPU stats """ stats_config = self.config['stats'] if USE_PYTHON_BINDING: collect_metrics = self.collect_via_pynvml else: collect_metrics = self.collect_via_nvidia_smi collect_metrics(stats_config)
[ "def", "collect", "(", "self", ")", ":", "stats_config", "=", "self", ".", "config", "[", "'stats'", "]", "if", "USE_PYTHON_BINDING", ":", "collect_metrics", "=", "self", ".", "collect_via_pynvml", "else", ":", "collect_metrics", "=", "self", ".", "collect_via...
Collector GPU stats
[ "Collector", "GPU", "stats" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/nvidia_gpu/nvidia_gpu.py#L119-L129
train
python-diamond/Diamond
src/collectors/jcollectd/collectd_network.py
decode_network_values
def decode_network_values(ptype, plen, buf): """Decodes a list of DS values in collectd network format """ nvalues = short.unpack_from(buf, header.size)[0] off = header.size + short.size + nvalues valskip = double.size # Check whether our expected packet size is the reported one assert ((va...
python
def decode_network_values(ptype, plen, buf): """Decodes a list of DS values in collectd network format """ nvalues = short.unpack_from(buf, header.size)[0] off = header.size + short.size + nvalues valskip = double.size # Check whether our expected packet size is the reported one assert ((va...
[ "def", "decode_network_values", "(", "ptype", ",", "plen", ",", "buf", ")", ":", "nvalues", "=", "short", ".", "unpack_from", "(", "buf", ",", "header", ".", "size", ")", "[", "0", "]", "off", "=", "header", ".", "size", "+", "short", ".", "size", ...
Decodes a list of DS values in collectd network format
[ "Decodes", "a", "list", "of", "DS", "values", "in", "collectd", "network", "format" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/jcollectd/collectd_network.py#L83-L111
train
python-diamond/Diamond
src/collectors/jcollectd/collectd_network.py
decode_network_packet
def decode_network_packet(buf): """Decodes a network packet in collectd format. """ off = 0 blen = len(buf) while off < blen: ptype, plen = header.unpack_from(buf, off) if plen > blen - off: raise ValueError("Packet longer than amount of data in buffer") if pty...
python
def decode_network_packet(buf): """Decodes a network packet in collectd format. """ off = 0 blen = len(buf) while off < blen: ptype, plen = header.unpack_from(buf, off) if plen > blen - off: raise ValueError("Packet longer than amount of data in buffer") if pty...
[ "def", "decode_network_packet", "(", "buf", ")", ":", "off", "=", "0", "blen", "=", "len", "(", "buf", ")", "while", "off", "<", "blen", ":", "ptype", ",", "plen", "=", "header", ".", "unpack_from", "(", "buf", ",", "off", ")", "if", "plen", ">", ...
Decodes a network packet in collectd format.
[ "Decodes", "a", "network", "packet", "in", "collectd", "format", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/jcollectd/collectd_network.py#L143-L159
train
python-diamond/Diamond
src/collectors/jcollectd/collectd_network.py
Reader.receive
def receive(self, poll_interval): """Receives a single raw collect network packet. """ readable, writeable, errored = select.select(self._readlist, [], [], poll_interval) for s in readable: data, addr = s.recvfrom(self.BUFF...
python
def receive(self, poll_interval): """Receives a single raw collect network packet. """ readable, writeable, errored = select.select(self._readlist, [], [], poll_interval) for s in readable: data, addr = s.recvfrom(self.BUFF...
[ "def", "receive", "(", "self", ",", "poll_interval", ")", ":", "readable", ",", "writeable", ",", "errored", "=", "select", ".", "select", "(", "self", ".", "_readlist", ",", "[", "]", ",", "[", "]", ",", "poll_interval", ")", "for", "s", "in", "read...
Receives a single raw collect network packet.
[ "Receives", "a", "single", "raw", "collect", "network", "packet", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/jcollectd/collectd_network.py#L341-L351
train
python-diamond/Diamond
src/collectors/jcollectd/collectd_network.py
Reader.decode
def decode(self, poll_interval, buf=None): """Decodes a given buffer or the next received packet. """ if buf is None: buf = self.receive(poll_interval) if buf is None: return None return decode_network_packet(buf)
python
def decode(self, poll_interval, buf=None): """Decodes a given buffer or the next received packet. """ if buf is None: buf = self.receive(poll_interval) if buf is None: return None return decode_network_packet(buf)
[ "def", "decode", "(", "self", ",", "poll_interval", ",", "buf", "=", "None", ")", ":", "if", "buf", "is", "None", ":", "buf", "=", "self", ".", "receive", "(", "poll_interval", ")", "if", "buf", "is", "None", ":", "return", "None", "return", "decode_...
Decodes a given buffer or the next received packet.
[ "Decodes", "a", "given", "buffer", "or", "the", "next", "received", "packet", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/jcollectd/collectd_network.py#L353-L360
train
python-diamond/Diamond
src/collectors/jcollectd/collectd_network.py
Reader.interpret
def interpret(self, iterable=None, poll_interval=0.2): """Interprets a sequence """ if iterable is None: iterable = self.decode(poll_interval) if iterable is None: return None if isinstance(iterable, basestring): iterable = self.decode...
python
def interpret(self, iterable=None, poll_interval=0.2): """Interprets a sequence """ if iterable is None: iterable = self.decode(poll_interval) if iterable is None: return None if isinstance(iterable, basestring): iterable = self.decode...
[ "def", "interpret", "(", "self", ",", "iterable", "=", "None", ",", "poll_interval", "=", "0.2", ")", ":", "if", "iterable", "is", "None", ":", "iterable", "=", "self", ".", "decode", "(", "poll_interval", ")", "if", "iterable", "is", "None", ":", "ret...
Interprets a sequence
[ "Interprets", "a", "sequence" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/jcollectd/collectd_network.py#L362-L373
train
ncclient/ncclient
ncclient/manager.py
make_device_handler
def make_device_handler(device_params): """ Create a device handler object that provides device specific parameters and functions, which are called in various places throughout our code. If no device_params are defined or the "name" in the parameter dict is not known then a default handler will be ...
python
def make_device_handler(device_params): """ Create a device handler object that provides device specific parameters and functions, which are called in various places throughout our code. If no device_params are defined or the "name" in the parameter dict is not known then a default handler will be ...
[ "def", "make_device_handler", "(", "device_params", ")", ":", "if", "device_params", "is", "None", ":", "device_params", "=", "{", "}", "handler", "=", "device_params", ".", "get", "(", "'handler'", ",", "None", ")", "if", "handler", ":", "return", "handler"...
Create a device handler object that provides device specific parameters and functions, which are called in various places throughout our code. If no device_params are defined or the "name" in the parameter dict is not known then a default handler will be returned.
[ "Create", "a", "device", "handler", "object", "that", "provides", "device", "specific", "parameters", "and", "functions", "which", "are", "called", "in", "various", "places", "throughout", "our", "code", "." ]
2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a
https://github.com/ncclient/ncclient/blob/2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a/ncclient/manager.py#L63-L89
train
ncclient/ncclient
ncclient/manager.py
Manager.take_notification
def take_notification(self, block=True, timeout=None): """Attempt to retrieve one notification from the queue of received notifications. If block is True, the call will wait until a notification is received. If timeout is a number greater than 0, the call will wait that ...
python
def take_notification(self, block=True, timeout=None): """Attempt to retrieve one notification from the queue of received notifications. If block is True, the call will wait until a notification is received. If timeout is a number greater than 0, the call will wait that ...
[ "def", "take_notification", "(", "self", ",", "block", "=", "True", ",", "timeout", "=", "None", ")", ":", "return", "self", ".", "_session", ".", "take_notification", "(", "block", ",", "timeout", ")" ]
Attempt to retrieve one notification from the queue of received notifications. If block is True, the call will wait until a notification is received. If timeout is a number greater than 0, the call will wait that many seconds to receive a notification before timing out. ...
[ "Attempt", "to", "retrieve", "one", "notification", "from", "the", "queue", "of", "received", "notifications", "." ]
2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a
https://github.com/ncclient/ncclient/blob/2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a/ncclient/manager.py#L258-L274
train
ncclient/ncclient
ncclient/operations/third_party/hpcomware/rpc.py
DisplayCommand.request
def request(self, cmds): """ Single Execution element is permitted. cmds can be a list or single command """ if isinstance(cmds, list): cmd = '\n'.join(cmds) elif isinstance(cmds, str) or isinstance(cmds, unicode): cmd = cmds node = etree....
python
def request(self, cmds): """ Single Execution element is permitted. cmds can be a list or single command """ if isinstance(cmds, list): cmd = '\n'.join(cmds) elif isinstance(cmds, str) or isinstance(cmds, unicode): cmd = cmds node = etree....
[ "def", "request", "(", "self", ",", "cmds", ")", ":", "if", "isinstance", "(", "cmds", ",", "list", ")", ":", "cmd", "=", "'\\n'", ".", "join", "(", "cmds", ")", "elif", "isinstance", "(", "cmds", ",", "str", ")", "or", "isinstance", "(", "cmds", ...
Single Execution element is permitted. cmds can be a list or single command
[ "Single", "Execution", "element", "is", "permitted", ".", "cmds", "can", "be", "a", "list", "or", "single", "command" ]
2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a
https://github.com/ncclient/ncclient/blob/2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a/ncclient/operations/third_party/hpcomware/rpc.py#L7-L22
train
ncclient/ncclient
ncclient/xml_.py
validated_element
def validated_element(x, tags=None, attrs=None): """Checks if the root element of an XML document or Element meets the supplied criteria. *tags* if specified is either a single allowable tag name or sequence of allowable alternatives *attrs* if specified is a sequence of required attributes, each of which...
python
def validated_element(x, tags=None, attrs=None): """Checks if the root element of an XML document or Element meets the supplied criteria. *tags* if specified is either a single allowable tag name or sequence of allowable alternatives *attrs* if specified is a sequence of required attributes, each of which...
[ "def", "validated_element", "(", "x", ",", "tags", "=", "None", ",", "attrs", "=", "None", ")", ":", "ele", "=", "to_ele", "(", "x", ")", "if", "tags", ":", "if", "isinstance", "(", "tags", ",", "(", "str", ",", "bytes", ")", ")", ":", "tags", ...
Checks if the root element of an XML document or Element meets the supplied criteria. *tags* if specified is either a single allowable tag name or sequence of allowable alternatives *attrs* if specified is a sequence of required attributes, each of which may be a sequence of several allowable alternatives ...
[ "Checks", "if", "the", "root", "element", "of", "an", "XML", "document", "or", "Element", "meets", "the", "supplied", "criteria", "." ]
2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a
https://github.com/ncclient/ncclient/blob/2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a/ncclient/xml_.py#L125-L148
train
ncclient/ncclient
ncclient/xml_.py
NCElement.tostring
def tostring(self): """return a pretty-printed string output for rpc reply""" parser = etree.XMLParser(remove_blank_text=True) outputtree = etree.XML(etree.tostring(self.__doc), parser) return etree.tostring(outputtree, pretty_print=True)
python
def tostring(self): """return a pretty-printed string output for rpc reply""" parser = etree.XMLParser(remove_blank_text=True) outputtree = etree.XML(etree.tostring(self.__doc), parser) return etree.tostring(outputtree, pretty_print=True)
[ "def", "tostring", "(", "self", ")", ":", "parser", "=", "etree", ".", "XMLParser", "(", "remove_blank_text", "=", "True", ")", "outputtree", "=", "etree", ".", "XML", "(", "etree", ".", "tostring", "(", "self", ".", "__doc", ")", ",", "parser", ")", ...
return a pretty-printed string output for rpc reply
[ "return", "a", "pretty", "-", "printed", "string", "output", "for", "rpc", "reply" ]
2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a
https://github.com/ncclient/ncclient/blob/2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a/ncclient/xml_.py#L192-L196
train
ncclient/ncclient
ncclient/xml_.py
NCElement.remove_namespaces
def remove_namespaces(self, rpc_reply): """remove xmlns attributes from rpc reply""" self.__xslt=self.__transform_reply self.__parser = etree.XMLParser(remove_blank_text=True) self.__xslt_doc = etree.parse(io.BytesIO(self.__xslt), self.__parser) self.__transform = etree.XSLT(self...
python
def remove_namespaces(self, rpc_reply): """remove xmlns attributes from rpc reply""" self.__xslt=self.__transform_reply self.__parser = etree.XMLParser(remove_blank_text=True) self.__xslt_doc = etree.parse(io.BytesIO(self.__xslt), self.__parser) self.__transform = etree.XSLT(self...
[ "def", "remove_namespaces", "(", "self", ",", "rpc_reply", ")", ":", "self", ".", "__xslt", "=", "self", ".", "__transform_reply", "self", ".", "__parser", "=", "etree", ".", "XMLParser", "(", "remove_blank_text", "=", "True", ")", "self", ".", "__xslt_doc",...
remove xmlns attributes from rpc reply
[ "remove", "xmlns", "attributes", "from", "rpc", "reply" ]
2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a
https://github.com/ncclient/ncclient/blob/2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a/ncclient/xml_.py#L203-L210
train
ncclient/ncclient
ncclient/operations/retrieve.py
GetSchema.request
def request(self, identifier, version=None, format=None): """Retrieve a named schema, with optional revision and type. *identifier* name of the schema to be retrieved *version* version of schema to get *format* format of the schema to be retrieved, yang is the default :seeals...
python
def request(self, identifier, version=None, format=None): """Retrieve a named schema, with optional revision and type. *identifier* name of the schema to be retrieved *version* version of schema to get *format* format of the schema to be retrieved, yang is the default :seeals...
[ "def", "request", "(", "self", ",", "identifier", ",", "version", "=", "None", ",", "format", "=", "None", ")", ":", "node", "=", "etree", ".", "Element", "(", "qualify", "(", "\"get-schema\"", ",", "NETCONF_MONITORING_NS", ")", ")", "if", "identifier", ...
Retrieve a named schema, with optional revision and type. *identifier* name of the schema to be retrieved *version* version of schema to get *format* format of the schema to be retrieved, yang is the default :seealso: :ref:`filter_params`
[ "Retrieve", "a", "named", "schema", "with", "optional", "revision", "and", "type", "." ]
2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a
https://github.com/ncclient/ncclient/blob/2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a/ncclient/operations/retrieve.py#L175-L198
train
ncclient/ncclient
ncclient/devices/default.py
DefaultDeviceHandler.is_rpc_error_exempt
def is_rpc_error_exempt(self, error_text): """ Check whether an RPC error message is excempt, thus NOT causing an exception. On some devices the RPC operations may indicate an error response, even though the operation actually succeeded. This may be in cases where a warning would be ...
python
def is_rpc_error_exempt(self, error_text): """ Check whether an RPC error message is excempt, thus NOT causing an exception. On some devices the RPC operations may indicate an error response, even though the operation actually succeeded. This may be in cases where a warning would be ...
[ "def", "is_rpc_error_exempt", "(", "self", ",", "error_text", ")", ":", "if", "error_text", "is", "not", "None", ":", "error_text", "=", "error_text", ".", "lower", "(", ")", ".", "strip", "(", ")", "else", ":", "error_text", "=", "'no error given'", "# Co...
Check whether an RPC error message is excempt, thus NOT causing an exception. On some devices the RPC operations may indicate an error response, even though the operation actually succeeded. This may be in cases where a warning would be more appropriate. In that case, the client may be better a...
[ "Check", "whether", "an", "RPC", "error", "message", "is", "excempt", "thus", "NOT", "causing", "an", "exception", "." ]
2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a
https://github.com/ncclient/ncclient/blob/2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a/ncclient/devices/default.py#L146-L192
train
ncclient/ncclient
ncclient/devices/nexus.py
NexusDeviceHandler.get_ssh_subsystem_names
def get_ssh_subsystem_names(self): """ Return a list of possible SSH subsystem names. Different NXOS versions use different SSH subsystem names for netconf. Therefore, we return a list so that several can be tried, if necessary. The Nexus device handler also accepts ""...
python
def get_ssh_subsystem_names(self): """ Return a list of possible SSH subsystem names. Different NXOS versions use different SSH subsystem names for netconf. Therefore, we return a list so that several can be tried, if necessary. The Nexus device handler also accepts ""...
[ "def", "get_ssh_subsystem_names", "(", "self", ")", ":", "preferred_ssh_subsystem", "=", "self", ".", "device_params", ".", "get", "(", "\"ssh_subsystem_name\"", ")", "name_list", "=", "[", "\"netconf\"", ",", "\"xmlagent\"", "]", "if", "preferred_ssh_subsystem", ":...
Return a list of possible SSH subsystem names. Different NXOS versions use different SSH subsystem names for netconf. Therefore, we return a list so that several can be tried, if necessary. The Nexus device handler also accepts
[ "Return", "a", "list", "of", "possible", "SSH", "subsystem", "names", "." ]
2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a
https://github.com/ncclient/ncclient/blob/2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a/ncclient/devices/nexus.py#L79-L95
train
ncclient/ncclient
ncclient/transport/session.py
Session.add_listener
def add_listener(self, listener): """Register a listener that will be notified of incoming messages and errors. :type listener: :class:`SessionListener` """ self.logger.debug('installing listener %r', listener) if not isinstance(listener, SessionListener): ra...
python
def add_listener(self, listener): """Register a listener that will be notified of incoming messages and errors. :type listener: :class:`SessionListener` """ self.logger.debug('installing listener %r', listener) if not isinstance(listener, SessionListener): ra...
[ "def", "add_listener", "(", "self", ",", "listener", ")", ":", "self", ".", "logger", ".", "debug", "(", "'installing listener %r'", ",", "listener", ")", "if", "not", "isinstance", "(", "listener", ",", "SessionListener", ")", ":", "raise", "SessionError", ...
Register a listener that will be notified of incoming messages and errors. :type listener: :class:`SessionListener`
[ "Register", "a", "listener", "that", "will", "be", "notified", "of", "incoming", "messages", "and", "errors", "." ]
2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a
https://github.com/ncclient/ncclient/blob/2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a/ncclient/transport/session.py#L125-L135
train
ncclient/ncclient
ncclient/transport/session.py
Session.remove_listener
def remove_listener(self, listener): """Unregister some listener; ignore if the listener was never registered. :type listener: :class:`SessionListener` """ self.logger.debug('discarding listener %r', listener) with self._lock: self._listeners.discard(listener...
python
def remove_listener(self, listener): """Unregister some listener; ignore if the listener was never registered. :type listener: :class:`SessionListener` """ self.logger.debug('discarding listener %r', listener) with self._lock: self._listeners.discard(listener...
[ "def", "remove_listener", "(", "self", ",", "listener", ")", ":", "self", ".", "logger", ".", "debug", "(", "'discarding listener %r'", ",", "listener", ")", "with", "self", ".", "_lock", ":", "self", ".", "_listeners", ".", "discard", "(", "listener", ")"...
Unregister some listener; ignore if the listener was never registered. :type listener: :class:`SessionListener`
[ "Unregister", "some", "listener", ";", "ignore", "if", "the", "listener", "was", "never", "registered", "." ]
2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a
https://github.com/ncclient/ncclient/blob/2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a/ncclient/transport/session.py#L137-L145
train
ncclient/ncclient
ncclient/transport/session.py
Session.get_listener_instance
def get_listener_instance(self, cls): """If a listener of the specified type is registered, returns the instance. :type cls: :class:`SessionListener` """ with self._lock: for listener in self._listeners: if isinstance(listener, cls): ...
python
def get_listener_instance(self, cls): """If a listener of the specified type is registered, returns the instance. :type cls: :class:`SessionListener` """ with self._lock: for listener in self._listeners: if isinstance(listener, cls): ...
[ "def", "get_listener_instance", "(", "self", ",", "cls", ")", ":", "with", "self", ".", "_lock", ":", "for", "listener", "in", "self", ".", "_listeners", ":", "if", "isinstance", "(", "listener", ",", "cls", ")", ":", "return", "listener" ]
If a listener of the specified type is registered, returns the instance. :type cls: :class:`SessionListener`
[ "If", "a", "listener", "of", "the", "specified", "type", "is", "registered", "returns", "the", "instance", "." ]
2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a
https://github.com/ncclient/ncclient/blob/2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a/ncclient/transport/session.py#L147-L156
train
ncclient/ncclient
ncclient/operations/subscribe.py
CreateSubscription.request
def request(self, filter=None, stream_name=None, start_time=None, stop_time=None): """Creates a subscription for notifications from the server. *filter* specifies the subset of notifications to receive (by default all notificaitons are received) :seealso: :ref:`filter_params` ...
python
def request(self, filter=None, stream_name=None, start_time=None, stop_time=None): """Creates a subscription for notifications from the server. *filter* specifies the subset of notifications to receive (by default all notificaitons are received) :seealso: :ref:`filter_params` ...
[ "def", "request", "(", "self", ",", "filter", "=", "None", ",", "stream_name", "=", "None", ",", "start_time", "=", "None", ",", "stop_time", "=", "None", ")", ":", "node", "=", "new_ele_ns", "(", "\"create-subscription\"", ",", "NETCONF_NOTIFICATION_NS", ")...
Creates a subscription for notifications from the server. *filter* specifies the subset of notifications to receive (by default all notificaitons are received) :seealso: :ref:`filter_params` *stream_name* specifies the notification stream name. The default is None meaning all ...
[ "Creates", "a", "subscription", "for", "notifications", "from", "the", "server", "." ]
2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a
https://github.com/ncclient/ncclient/blob/2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a/ncclient/operations/subscribe.py#L27-L64
train
ncclient/ncclient
ncclient/operations/edit.py
DeleteConfig.request
def request(self, target): """Delete a configuration datastore. *target* specifies the name or URL of configuration datastore to delete :seealso: :ref:`srctarget_params`""" node = new_ele("delete-config") node.append(util.datastore_or_url("target", target, self._assert)) ...
python
def request(self, target): """Delete a configuration datastore. *target* specifies the name or URL of configuration datastore to delete :seealso: :ref:`srctarget_params`""" node = new_ele("delete-config") node.append(util.datastore_or_url("target", target, self._assert)) ...
[ "def", "request", "(", "self", ",", "target", ")", ":", "node", "=", "new_ele", "(", "\"delete-config\"", ")", "node", ".", "append", "(", "util", ".", "datastore_or_url", "(", "\"target\"", ",", "target", ",", "self", ".", "_assert", ")", ")", "return",...
Delete a configuration datastore. *target* specifies the name or URL of configuration datastore to delete :seealso: :ref:`srctarget_params`
[ "Delete", "a", "configuration", "datastore", "." ]
2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a
https://github.com/ncclient/ncclient/blob/2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a/ncclient/operations/edit.py#L73-L81
train
ncclient/ncclient
ncclient/operations/edit.py
CopyConfig.request
def request(self, source, target): """Create or replace an entire configuration datastore with the contents of another complete configuration datastore. *source* is the name of the configuration datastore to use as the source of the copy operation or `config` element containing the configuratio...
python
def request(self, source, target): """Create or replace an entire configuration datastore with the contents of another complete configuration datastore. *source* is the name of the configuration datastore to use as the source of the copy operation or `config` element containing the configuratio...
[ "def", "request", "(", "self", ",", "source", ",", "target", ")", ":", "node", "=", "new_ele", "(", "\"copy-config\"", ")", "node", ".", "append", "(", "util", ".", "datastore_or_url", "(", "\"target\"", ",", "target", ",", "self", ".", "_assert", ")", ...
Create or replace an entire configuration datastore with the contents of another complete configuration datastore. *source* is the name of the configuration datastore to use as the source of the copy operation or `config` element containing the configuration subtree to copy *target* is the nam...
[ "Create", "or", "replace", "an", "entire", "configuration", "datastore", "with", "the", "contents", "of", "another", "complete", "configuration", "datastore", "." ]
2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a
https://github.com/ncclient/ncclient/blob/2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a/ncclient/operations/edit.py#L87-L106
train
ncclient/ncclient
ncclient/operations/edit.py
Validate.request
def request(self, source="candidate"): """Validate the contents of the specified configuration. *source* is the name of the configuration datastore being validated or `config` element containing the configuration subtree to be validated :seealso: :ref:`srctarget_params`""" node = new_e...
python
def request(self, source="candidate"): """Validate the contents of the specified configuration. *source* is the name of the configuration datastore being validated or `config` element containing the configuration subtree to be validated :seealso: :ref:`srctarget_params`""" node = new_e...
[ "def", "request", "(", "self", ",", "source", "=", "\"candidate\"", ")", ":", "node", "=", "new_ele", "(", "\"validate\"", ")", "if", "type", "(", "source", ")", "is", "str", ":", "src", "=", "util", ".", "datastore_or_url", "(", "\"source\"", ",", "so...
Validate the contents of the specified configuration. *source* is the name of the configuration datastore being validated or `config` element containing the configuration subtree to be validated :seealso: :ref:`srctarget_params`
[ "Validate", "the", "contents", "of", "the", "specified", "configuration", "." ]
2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a
https://github.com/ncclient/ncclient/blob/2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a/ncclient/operations/edit.py#L114-L128
train
ncclient/ncclient
ncclient/operations/lock.py
Lock.request
def request(self, target="candidate"): """Allows the client to lock the configuration system of a device. *target* is the name of the configuration datastore to lock """ node = new_ele("lock") sub_ele(sub_ele(node, "target"), target) return self._request(node)
python
def request(self, target="candidate"): """Allows the client to lock the configuration system of a device. *target* is the name of the configuration datastore to lock """ node = new_ele("lock") sub_ele(sub_ele(node, "target"), target) return self._request(node)
[ "def", "request", "(", "self", ",", "target", "=", "\"candidate\"", ")", ":", "node", "=", "new_ele", "(", "\"lock\"", ")", "sub_ele", "(", "sub_ele", "(", "node", ",", "\"target\"", ")", ",", "target", ")", "return", "self", ".", "_request", "(", "nod...
Allows the client to lock the configuration system of a device. *target* is the name of the configuration datastore to lock
[ "Allows", "the", "client", "to", "lock", "the", "configuration", "system", "of", "a", "device", "." ]
2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a
https://github.com/ncclient/ncclient/blob/2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a/ncclient/operations/lock.py#L28-L35
train
ncclient/ncclient
ncclient/transport/ssh.py
SSHSession._parse10
def _parse10(self): """Messages are delimited by MSG_DELIM. The buffer could have grown by a maximum of BUF_SIZE bytes everytime this method is called. Retains state across method calls and if a chunk has been read it will not be considered again.""" self.logger.debug("parsing ...
python
def _parse10(self): """Messages are delimited by MSG_DELIM. The buffer could have grown by a maximum of BUF_SIZE bytes everytime this method is called. Retains state across method calls and if a chunk has been read it will not be considered again.""" self.logger.debug("parsing ...
[ "def", "_parse10", "(", "self", ")", ":", "self", ".", "logger", ".", "debug", "(", "\"parsing netconf v1.0\"", ")", "buf", "=", "self", ".", "_buffer", "buf", ".", "seek", "(", "self", ".", "_parsing_pos10", ")", "if", "MSG_DELIM", "in", "buf", ".", "...
Messages are delimited by MSG_DELIM. The buffer could have grown by a maximum of BUF_SIZE bytes everytime this method is called. Retains state across method calls and if a chunk has been read it will not be considered again.
[ "Messages", "are", "delimited", "by", "MSG_DELIM", ".", "The", "buffer", "could", "have", "grown", "by", "a", "maximum", "of", "BUF_SIZE", "bytes", "everytime", "this", "method", "is", "called", ".", "Retains", "state", "across", "method", "calls", "and", "i...
2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a
https://github.com/ncclient/ncclient/blob/2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a/ncclient/transport/ssh.py#L139-L170
train
ncclient/ncclient
ncclient/operations/util.py
one_of
def one_of(*args): "Verifies that only one of the arguments is not None" for i, arg in enumerate(args): if arg is not None: for argh in args[i+1:]: if argh is not None: raise OperationError("Too many parameters") else: return ...
python
def one_of(*args): "Verifies that only one of the arguments is not None" for i, arg in enumerate(args): if arg is not None: for argh in args[i+1:]: if argh is not None: raise OperationError("Too many parameters") else: return ...
[ "def", "one_of", "(", "*", "args", ")", ":", "for", "i", ",", "arg", "in", "enumerate", "(", "args", ")", ":", "if", "arg", "is", "not", "None", ":", "for", "argh", "in", "args", "[", "i", "+", "1", ":", "]", ":", "if", "argh", "is", "not", ...
Verifies that only one of the arguments is not None
[ "Verifies", "that", "only", "one", "of", "the", "arguments", "is", "not", "None" ]
2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a
https://github.com/ncclient/ncclient/blob/2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a/ncclient/operations/util.py#L21-L30
train
RJT1990/pyflux
pyflux/arma/arimax.py
ARIMAX._get_scale_and_shape
def _get_scale_and_shape(self, transformed_lvs): """ Obtains model scale, shape and skewness latent variables Parameters ---------- transformed_lvs : np.array Transformed latent variable vector Returns ---------- - Tuple of model scale, model shape, ...
python
def _get_scale_and_shape(self, transformed_lvs): """ Obtains model scale, shape and skewness latent variables Parameters ---------- transformed_lvs : np.array Transformed latent variable vector Returns ---------- - Tuple of model scale, model shape, ...
[ "def", "_get_scale_and_shape", "(", "self", ",", "transformed_lvs", ")", ":", "if", "self", ".", "scale", "is", "True", ":", "if", "self", ".", "shape", "is", "True", ":", "model_shape", "=", "transformed_lvs", "[", "-", "1", "]", "model_scale", "=", "tr...
Obtains model scale, shape and skewness latent variables Parameters ---------- transformed_lvs : np.array Transformed latent variable vector Returns ---------- - Tuple of model scale, model shape, model skewness
[ "Obtains", "model", "scale", "shape", "and", "skewness", "latent", "variables" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/arma/arimax.py#L152-L181
train
RJT1990/pyflux
pyflux/arma/arimax.py
ARIMAX._get_scale_and_shape_sim
def _get_scale_and_shape_sim(self, transformed_lvs): """ Obtains model scale, shape, skewness latent variables for a 2d array of simulations. Parameters ---------- transformed_lvs : np.array Transformed latent variable vector (2d - with draws of each variable) ...
python
def _get_scale_and_shape_sim(self, transformed_lvs): """ Obtains model scale, shape, skewness latent variables for a 2d array of simulations. Parameters ---------- transformed_lvs : np.array Transformed latent variable vector (2d - with draws of each variable) ...
[ "def", "_get_scale_and_shape_sim", "(", "self", ",", "transformed_lvs", ")", ":", "if", "self", ".", "scale", "is", "True", ":", "if", "self", ".", "shape", "is", "True", ":", "model_shape", "=", "self", ".", "latent_variables", ".", "z_list", "[", "-", ...
Obtains model scale, shape, skewness latent variables for a 2d array of simulations. Parameters ---------- transformed_lvs : np.array Transformed latent variable vector (2d - with draws of each variable) Returns ---------- - Tuple of np.arrays (each ...
[ "Obtains", "model", "scale", "shape", "skewness", "latent", "variables", "for", "a", "2d", "array", "of", "simulations", "." ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/arma/arimax.py#L183-L213
train
RJT1990/pyflux
pyflux/arma/arimax.py
ARIMAX._summarize_simulations
def _summarize_simulations(self, mean_values, sim_vector, date_index, h, past_values): """ Produces forecasted values to plot, along with prediction intervals This is a utility function that constructs the prediction intervals and other quantities used for plot_predict() in particular. ...
python
def _summarize_simulations(self, mean_values, sim_vector, date_index, h, past_values): """ Produces forecasted values to plot, along with prediction intervals This is a utility function that constructs the prediction intervals and other quantities used for plot_predict() in particular. ...
[ "def", "_summarize_simulations", "(", "self", ",", "mean_values", ",", "sim_vector", ",", "date_index", ",", "h", ",", "past_values", ")", ":", "error_bars", "=", "[", "]", "for", "pre", "in", "range", "(", "5", ",", "100", ",", "5", ")", ":", "error_b...
Produces forecasted values to plot, along with prediction intervals This is a utility function that constructs the prediction intervals and other quantities used for plot_predict() in particular. Parameters ---------- mean_values : np.ndarray Mean predictions for h...
[ "Produces", "forecasted", "values", "to", "plot", "along", "with", "prediction", "intervals" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/arma/arimax.py#L606-L639
train
RJT1990/pyflux
pyflux/arma/arimax.py
ARIMAX.normal_neg_loglik
def normal_neg_loglik(self, beta): """ Calculates the negative log-likelihood of the model for Normal family Parameters ---------- beta : np.ndarray Contains untransformed starting values for latent variables Returns ---------- The negative logliklih...
python
def normal_neg_loglik(self, beta): """ Calculates the negative log-likelihood of the model for Normal family Parameters ---------- beta : np.ndarray Contains untransformed starting values for latent variables Returns ---------- The negative logliklih...
[ "def", "normal_neg_loglik", "(", "self", ",", "beta", ")", ":", "mu", ",", "Y", "=", "self", ".", "_model", "(", "beta", ")", "return", "-", "np", ".", "sum", "(", "ss", ".", "norm", ".", "logpdf", "(", "Y", ",", "loc", "=", "mu", ",", "scale",...
Calculates the negative log-likelihood of the model for Normal family Parameters ---------- beta : np.ndarray Contains untransformed starting values for latent variables Returns ---------- The negative logliklihood of the model
[ "Calculates", "the", "negative", "log", "-", "likelihood", "of", "the", "model", "for", "Normal", "family" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/arma/arimax.py#L641-L654
train
RJT1990/pyflux
pyflux/arma/arimax.py
ARIMAX.normal_mb_neg_loglik
def normal_mb_neg_loglik(self, beta, mini_batch): """ Calculates the negative log-likelihood of the Normal model for a minibatch Parameters ---------- beta : np.ndarray Contains untransformed starting values for latent variables mini_batch : int Size of ...
python
def normal_mb_neg_loglik(self, beta, mini_batch): """ Calculates the negative log-likelihood of the Normal model for a minibatch Parameters ---------- beta : np.ndarray Contains untransformed starting values for latent variables mini_batch : int Size of ...
[ "def", "normal_mb_neg_loglik", "(", "self", ",", "beta", ",", "mini_batch", ")", ":", "mu", ",", "Y", "=", "self", ".", "_mb_model", "(", "beta", ",", "mini_batch", ")", "return", "-", "np", ".", "sum", "(", "ss", ".", "norm", ".", "logpdf", "(", "...
Calculates the negative log-likelihood of the Normal model for a minibatch Parameters ---------- beta : np.ndarray Contains untransformed starting values for latent variables mini_batch : int Size of each mini batch of data Returns ---------- ...
[ "Calculates", "the", "negative", "log", "-", "likelihood", "of", "the", "Normal", "model", "for", "a", "minibatch" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/arma/arimax.py#L656-L673
train
RJT1990/pyflux
pyflux/families/skewt.py
Skewt.draw_variable
def draw_variable(loc, scale, shape, skewness, nsims): """ Draws random variables from Skew t distribution Parameters ---------- loc : float location parameter for the distribution scale : float scale parameter for the distribution shape : float...
python
def draw_variable(loc, scale, shape, skewness, nsims): """ Draws random variables from Skew t distribution Parameters ---------- loc : float location parameter for the distribution scale : float scale parameter for the distribution shape : float...
[ "def", "draw_variable", "(", "loc", ",", "scale", ",", "shape", ",", "skewness", ",", "nsims", ")", ":", "return", "loc", "+", "scale", "*", "Skewt", ".", "rvs", "(", "shape", ",", "skewness", ",", "nsims", ")" ]
Draws random variables from Skew t distribution Parameters ---------- loc : float location parameter for the distribution scale : float scale parameter for the distribution shape : float tail thickness parameter for the distribution ...
[ "Draws", "random", "variables", "from", "Skew", "t", "distribution" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/skewt.py#L138-L162
train
RJT1990/pyflux
pyflux/families/skewt.py
Skewt.first_order_score
def first_order_score(y, mean, scale, shape, skewness): """ GAS Skew t Update term using gradient only - native Python function Parameters ---------- y : float datapoint for the time series mean : float location parameter for the Skew t distribution ...
python
def first_order_score(y, mean, scale, shape, skewness): """ GAS Skew t Update term using gradient only - native Python function Parameters ---------- y : float datapoint for the time series mean : float location parameter for the Skew t distribution ...
[ "def", "first_order_score", "(", "y", ",", "mean", ",", "scale", ",", "shape", ",", "skewness", ")", ":", "m1", "=", "(", "np", ".", "sqrt", "(", "shape", ")", "*", "sp", ".", "gamma", "(", "(", "shape", "-", "1.0", ")", "/", "2.0", ")", ")", ...
GAS Skew t Update term using gradient only - native Python function Parameters ---------- y : float datapoint for the time series mean : float location parameter for the Skew t distribution scale : float scale parameter for the Skew t distri...
[ "GAS", "Skew", "t", "Update", "term", "using", "gradient", "only", "-", "native", "Python", "function" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/skewt.py#L165-L194
train
RJT1990/pyflux
pyflux/families/skewt.py
Skewt.rvs
def rvs(df, gamma, n): """ Generates random variables from a Skew t distribution Parameters ---------- df : float degrees of freedom parameter gamma : float skewness parameter n : int or list Number of simulations to perform; if li...
python
def rvs(df, gamma, n): """ Generates random variables from a Skew t distribution Parameters ---------- df : float degrees of freedom parameter gamma : float skewness parameter n : int or list Number of simulations to perform; if li...
[ "def", "rvs", "(", "df", ",", "gamma", ",", "n", ")", ":", "if", "type", "(", "n", ")", "==", "list", ":", "u", "=", "np", ".", "random", ".", "uniform", "(", "size", "=", "n", "[", "0", "]", "*", "n", "[", "1", "]", ")", "result", "=", ...
Generates random variables from a Skew t distribution Parameters ---------- df : float degrees of freedom parameter gamma : float skewness parameter n : int or list Number of simulations to perform; if list input, produces array
[ "Generates", "random", "variables", "from", "a", "Skew", "t", "distribution" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/skewt.py#L197-L223
train
RJT1990/pyflux
pyflux/families/skewt.py
Skewt.logpdf
def logpdf(self, mu): """ Log PDF for Skew t prior Parameters ---------- mu : float Latent variable for which the prior is being formed over Returns ---------- - log(p(mu)) """ if self.transform is not None: mu = s...
python
def logpdf(self, mu): """ Log PDF for Skew t prior Parameters ---------- mu : float Latent variable for which the prior is being formed over Returns ---------- - log(p(mu)) """ if self.transform is not None: mu = s...
[ "def", "logpdf", "(", "self", ",", "mu", ")", ":", "if", "self", ".", "transform", "is", "not", "None", ":", "mu", "=", "self", ".", "transform", "(", "mu", ")", "return", "self", ".", "logpdf_internal_prior", "(", "mu", ",", "df", "=", "self", "."...
Log PDF for Skew t prior Parameters ---------- mu : float Latent variable for which the prior is being formed over Returns ---------- - log(p(mu))
[ "Log", "PDF", "for", "Skew", "t", "prior" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/skewt.py#L239-L254
train
RJT1990/pyflux
pyflux/families/skewt.py
Skewt.markov_blanket
def markov_blanket(y, mean, scale, shape, skewness): """ Markov blanket for each likelihood term Parameters ---------- y : np.ndarray univariate time series mean : np.ndarray array of location parameters for the Skew t distribution scale : float...
python
def markov_blanket(y, mean, scale, shape, skewness): """ Markov blanket for each likelihood term Parameters ---------- y : np.ndarray univariate time series mean : np.ndarray array of location parameters for the Skew t distribution scale : float...
[ "def", "markov_blanket", "(", "y", ",", "mean", ",", "scale", ",", "shape", ",", "skewness", ")", ":", "m1", "=", "(", "np", ".", "sqrt", "(", "shape", ")", "*", "sp", ".", "gamma", "(", "(", "shape", "-", "1.0", ")", "/", "2.0", ")", ")", "/...
Markov blanket for each likelihood term Parameters ---------- y : np.ndarray univariate time series mean : np.ndarray array of location parameters for the Skew t distribution scale : float scale parameter for the Skew t distribution ...
[ "Markov", "blanket", "for", "each", "likelihood", "term" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/skewt.py#L257-L283
train
RJT1990/pyflux
pyflux/families/skewt.py
Skewt.pdf_internal
def pdf_internal(x, df, loc=0.0, scale=1.0, gamma = 1.0): """ Raw PDF function for the Skew t distribution """ result = np.zeros(x.shape[0]) result[x<0] = 2.0/(gamma + 1.0/gamma)*stats.t.pdf(x=gamma*x[(x-loc) < 0], loc=loc[(x-loc) < 0]*gamma,df=df, scale=scale) result[x>=...
python
def pdf_internal(x, df, loc=0.0, scale=1.0, gamma = 1.0): """ Raw PDF function for the Skew t distribution """ result = np.zeros(x.shape[0]) result[x<0] = 2.0/(gamma + 1.0/gamma)*stats.t.pdf(x=gamma*x[(x-loc) < 0], loc=loc[(x-loc) < 0]*gamma,df=df, scale=scale) result[x>=...
[ "def", "pdf_internal", "(", "x", ",", "df", ",", "loc", "=", "0.0", ",", "scale", "=", "1.0", ",", "gamma", "=", "1.0", ")", ":", "result", "=", "np", ".", "zeros", "(", "x", ".", "shape", "[", "0", "]", ")", "result", "[", "x", "<", "0", "...
Raw PDF function for the Skew t distribution
[ "Raw", "PDF", "function", "for", "the", "Skew", "t", "distribution" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/skewt.py#L340-L347
train
RJT1990/pyflux
pyflux/families/skewt.py
Skewt.pdf
def pdf(self, mu): """ PDF for Skew t prior Parameters ---------- mu : float Latent variable for which the prior is being formed over Returns ---------- - p(mu) """ if self.transform is not None: mu = self.transfor...
python
def pdf(self, mu): """ PDF for Skew t prior Parameters ---------- mu : float Latent variable for which the prior is being formed over Returns ---------- - p(mu) """ if self.transform is not None: mu = self.transfor...
[ "def", "pdf", "(", "self", ",", "mu", ")", ":", "if", "self", ".", "transform", "is", "not", "None", ":", "mu", "=", "self", ".", "transform", "(", "mu", ")", "return", "self", ".", "pdf_internal", "(", "mu", ",", "df", "=", "self", ".", "df0", ...
PDF for Skew t prior Parameters ---------- mu : float Latent variable for which the prior is being formed over Returns ---------- - p(mu)
[ "PDF", "for", "Skew", "t", "prior" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/skewt.py#L349-L364
train
RJT1990/pyflux
pyflux/families/skewt.py
Skewt.cdf
def cdf(x, df, loc=0.0, scale=1.0, gamma = 1.0): """ CDF function for Skew t distribution """ result = np.zeros(x.shape[0]) result[x<0] = 2.0/(np.power(gamma,2) + 1.0)*ss.t.cdf(gamma*(x[x-loc < 0]-loc[x-loc < 0])/scale, df=df) result[x>=0] = 1.0/(np.power(gamma,2) + 1.0) ...
python
def cdf(x, df, loc=0.0, scale=1.0, gamma = 1.0): """ CDF function for Skew t distribution """ result = np.zeros(x.shape[0]) result[x<0] = 2.0/(np.power(gamma,2) + 1.0)*ss.t.cdf(gamma*(x[x-loc < 0]-loc[x-loc < 0])/scale, df=df) result[x>=0] = 1.0/(np.power(gamma,2) + 1.0) ...
[ "def", "cdf", "(", "x", ",", "df", ",", "loc", "=", "0.0", ",", "scale", "=", "1.0", ",", "gamma", "=", "1.0", ")", ":", "result", "=", "np", ".", "zeros", "(", "x", ".", "shape", "[", "0", "]", ")", "result", "[", "x", "<", "0", "]", "="...
CDF function for Skew t distribution
[ "CDF", "function", "for", "Skew", "t", "distribution" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/skewt.py#L434-L441
train
RJT1990/pyflux
pyflux/families/skewt.py
Skewt.ppf
def ppf(q, df, loc=0.0, scale=1.0, gamma = 1.0): """ PPF function for Skew t distribution """ result = np.zeros(q.shape[0]) probzero = Skewt.cdf(x=np.zeros(1),loc=np.zeros(1),df=df,gamma=gamma) result[q<probzero] = 1.0/gamma*ss.t.ppf(((np.power(gamma,2) + 1.0) * q[q<probz...
python
def ppf(q, df, loc=0.0, scale=1.0, gamma = 1.0): """ PPF function for Skew t distribution """ result = np.zeros(q.shape[0]) probzero = Skewt.cdf(x=np.zeros(1),loc=np.zeros(1),df=df,gamma=gamma) result[q<probzero] = 1.0/gamma*ss.t.ppf(((np.power(gamma,2) + 1.0) * q[q<probz...
[ "def", "ppf", "(", "q", ",", "df", ",", "loc", "=", "0.0", ",", "scale", "=", "1.0", ",", "gamma", "=", "1.0", ")", ":", "result", "=", "np", ".", "zeros", "(", "q", ".", "shape", "[", "0", "]", ")", "probzero", "=", "Skewt", ".", "cdf", "(...
PPF function for Skew t distribution
[ "PPF", "function", "for", "Skew", "t", "distribution" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/skewt.py#L444-L452
train
RJT1990/pyflux
pyflux/families/family.py
Family.transform_define
def transform_define(transform): """ This function links the user's choice of transformation with the associated numpy function """ if transform == 'tanh': return np.tanh elif transform == 'exp': return np.exp elif transform == 'logit': ...
python
def transform_define(transform): """ This function links the user's choice of transformation with the associated numpy function """ if transform == 'tanh': return np.tanh elif transform == 'exp': return np.exp elif transform == 'logit': ...
[ "def", "transform_define", "(", "transform", ")", ":", "if", "transform", "==", "'tanh'", ":", "return", "np", ".", "tanh", "elif", "transform", "==", "'exp'", ":", "return", "np", ".", "exp", "elif", "transform", "==", "'logit'", ":", "return", "Family", ...
This function links the user's choice of transformation with the associated numpy function
[ "This", "function", "links", "the", "user", "s", "choice", "of", "transformation", "with", "the", "associated", "numpy", "function" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/family.py#L26-L39
train
RJT1990/pyflux
pyflux/families/family.py
Family.itransform_define
def itransform_define(transform): """ This function links the user's choice of transformation with its inverse """ if transform == 'tanh': return np.arctanh elif transform == 'exp': return np.log elif transform == 'logit': return Family...
python
def itransform_define(transform): """ This function links the user's choice of transformation with its inverse """ if transform == 'tanh': return np.arctanh elif transform == 'exp': return np.log elif transform == 'logit': return Family...
[ "def", "itransform_define", "(", "transform", ")", ":", "if", "transform", "==", "'tanh'", ":", "return", "np", ".", "arctanh", "elif", "transform", "==", "'exp'", ":", "return", "np", ".", "log", "elif", "transform", "==", "'logit'", ":", "return", "Famil...
This function links the user's choice of transformation with its inverse
[ "This", "function", "links", "the", "user", "s", "choice", "of", "transformation", "with", "its", "inverse" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/family.py#L42-L55
train
RJT1990/pyflux
pyflux/gpnarx/gpnarx.py
GPNARX._L
def _L(self, parm): """ Creates cholesky decomposition of covariance matrix Parameters ---------- parm : np.array Contains transformed latent variables Returns ---------- The cholesky decomposition (L) of K """ return np.linalg.chol...
python
def _L(self, parm): """ Creates cholesky decomposition of covariance matrix Parameters ---------- parm : np.array Contains transformed latent variables Returns ---------- The cholesky decomposition (L) of K """ return np.linalg.chol...
[ "def", "_L", "(", "self", ",", "parm", ")", ":", "return", "np", ".", "linalg", ".", "cholesky", "(", "self", ".", "kernel", ".", "K", "(", "parm", ")", "+", "np", ".", "identity", "(", "self", ".", "X", "(", ")", ".", "shape", "[", "1", "]",...
Creates cholesky decomposition of covariance matrix Parameters ---------- parm : np.array Contains transformed latent variables Returns ---------- The cholesky decomposition (L) of K
[ "Creates", "cholesky", "decomposition", "of", "covariance", "matrix" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/gpnarx/gpnarx.py#L176-L189
train
RJT1990/pyflux
pyflux/gpnarx/gpnarx.py
GPNARX.plot_fit
def plot_fit(self, intervals=True, **kwargs): """ Plots the fit of the Gaussian process model to the data Parameters ---------- beta : np.array Contains untransformed starting values for latent variables intervals : Boolean Whether to plot uncert...
python
def plot_fit(self, intervals=True, **kwargs): """ Plots the fit of the Gaussian process model to the data Parameters ---------- beta : np.array Contains untransformed starting values for latent variables intervals : Boolean Whether to plot uncert...
[ "def", "plot_fit", "(", "self", ",", "intervals", "=", "True", ",", "*", "*", "kwargs", ")", ":", "import", "matplotlib", ".", "pyplot", "as", "plt", "import", "seaborn", "as", "sns", "figsize", "=", "kwargs", ".", "get", "(", "'figsize'", ",", "(", ...
Plots the fit of the Gaussian process model to the data Parameters ---------- beta : np.array Contains untransformed starting values for latent variables intervals : Boolean Whether to plot uncertainty intervals or not Returns --...
[ "Plots", "the", "fit", "of", "the", "Gaussian", "process", "model", "to", "the", "data" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/gpnarx/gpnarx.py#L260-L315
train
RJT1990/pyflux
pyflux/gas/gas.py
GAS._get_scale_and_shape
def _get_scale_and_shape(self,parm): """ Obtains appropriate model scale and shape latent variables Parameters ---------- parm : np.array Transformed latent variable vector Returns ---------- None (changes model attributes) """ if se...
python
def _get_scale_and_shape(self,parm): """ Obtains appropriate model scale and shape latent variables Parameters ---------- parm : np.array Transformed latent variable vector Returns ---------- None (changes model attributes) """ if se...
[ "def", "_get_scale_and_shape", "(", "self", ",", "parm", ")", ":", "if", "self", ".", "scale", "is", "True", ":", "if", "self", ".", "shape", "is", "True", ":", "model_shape", "=", "parm", "[", "-", "1", "]", "model_scale", "=", "parm", "[", "-", "...
Obtains appropriate model scale and shape latent variables Parameters ---------- parm : np.array Transformed latent variable vector Returns ---------- None (changes model attributes)
[ "Obtains", "appropriate", "model", "scale", "and", "shape", "latent", "variables" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/gas/gas.py#L127-L156
train
RJT1990/pyflux
pyflux/gas/gas.py
GAS.plot_sample
def plot_sample(self, nsims=10, plot_data=True, **kwargs): """ Plots draws from the posterior predictive density against the data Parameters ---------- nsims : int (default : 1000) How many draws from the posterior predictive distribution plot_data boolean ...
python
def plot_sample(self, nsims=10, plot_data=True, **kwargs): """ Plots draws from the posterior predictive density against the data Parameters ---------- nsims : int (default : 1000) How many draws from the posterior predictive distribution plot_data boolean ...
[ "def", "plot_sample", "(", "self", ",", "nsims", "=", "10", ",", "plot_data", "=", "True", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "latent_variables", ".", "estimation_method", "not", "in", "[", "'BBVI'", ",", "'M-H'", "]", ":", "raise", ...
Plots draws from the posterior predictive density against the data Parameters ---------- nsims : int (default : 1000) How many draws from the posterior predictive distribution plot_data boolean Whether to plot the data or not
[ "Plots", "draws", "from", "the", "posterior", "predictive", "density", "against", "the", "data" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/gas/gas.py#L939-L967
train
RJT1990/pyflux
pyflux/arma/arma.py
ARIMA._ar_matrix
def _ar_matrix(self): """ Creates the Autoregressive matrix for the model Returns ---------- X : np.ndarray Autoregressive Matrix """ X = np.ones(self.data_length-self.max_lag) if self.ar != 0: for i in range(0, self.ar): ...
python
def _ar_matrix(self): """ Creates the Autoregressive matrix for the model Returns ---------- X : np.ndarray Autoregressive Matrix """ X = np.ones(self.data_length-self.max_lag) if self.ar != 0: for i in range(0, self.ar): ...
[ "def", "_ar_matrix", "(", "self", ")", ":", "X", "=", "np", ".", "ones", "(", "self", ".", "data_length", "-", "self", ".", "max_lag", ")", "if", "self", ".", "ar", "!=", "0", ":", "for", "i", "in", "range", "(", "0", ",", "self", ".", "ar", ...
Creates the Autoregressive matrix for the model Returns ---------- X : np.ndarray Autoregressive Matrix
[ "Creates", "the", "Autoregressive", "matrix", "for", "the", "model" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/arma/arma.py#L109-L124
train
RJT1990/pyflux
pyflux/families/inverse_wishart.py
InverseWishart.logpdf
def logpdf(self, X): """ Log PDF for Inverse Wishart prior Parameters ---------- X : float Covariance matrix for which the prior is being formed over Returns ---------- - log(p(X)) """ return invwishart.logpdf(X, df=self.v, sc...
python
def logpdf(self, X): """ Log PDF for Inverse Wishart prior Parameters ---------- X : float Covariance matrix for which the prior is being formed over Returns ---------- - log(p(X)) """ return invwishart.logpdf(X, df=self.v, sc...
[ "def", "logpdf", "(", "self", ",", "X", ")", ":", "return", "invwishart", ".", "logpdf", "(", "X", ",", "df", "=", "self", ".", "v", ",", "scale", "=", "self", ".", "Psi", ")" ]
Log PDF for Inverse Wishart prior Parameters ---------- X : float Covariance matrix for which the prior is being formed over Returns ---------- - log(p(X))
[ "Log", "PDF", "for", "Inverse", "Wishart", "prior" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/inverse_wishart.py#L38-L51
train
RJT1990/pyflux
pyflux/families/inverse_wishart.py
InverseWishart.pdf
def pdf(self, X): """ PDF for Inverse Wishart prior Parameters ---------- x : float Covariance matrix for which the prior is being formed over Returns ---------- - p(x) """ return invwishart.pdf(X, df=self.v, sca...
python
def pdf(self, X): """ PDF for Inverse Wishart prior Parameters ---------- x : float Covariance matrix for which the prior is being formed over Returns ---------- - p(x) """ return invwishart.pdf(X, df=self.v, sca...
[ "def", "pdf", "(", "self", ",", "X", ")", ":", "return", "invwishart", ".", "pdf", "(", "X", ",", "df", "=", "self", ".", "v", ",", "scale", "=", "self", ".", "Psi", ")" ]
PDF for Inverse Wishart prior Parameters ---------- x : float Covariance matrix for which the prior is being formed over Returns ---------- - p(x)
[ "PDF", "for", "Inverse", "Wishart", "prior" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/inverse_wishart.py#L53-L66
train
RJT1990/pyflux
pyflux/ssm/nllt.py
NLLT.neg_loglik
def neg_loglik(self, beta): """ Creates negative loglikelihood of the model Parameters ---------- beta : np.array Contains untransformed starting values for latent variables Returns ---------- - Negative loglikelihood """ Z = np....
python
def neg_loglik(self, beta): """ Creates negative loglikelihood of the model Parameters ---------- beta : np.array Contains untransformed starting values for latent variables Returns ---------- - Negative loglikelihood """ Z = np....
[ "def", "neg_loglik", "(", "self", ",", "beta", ")", ":", "Z", "=", "np", ".", "zeros", "(", "2", ")", "Z", "[", "0", "]", "=", "1", "states", "=", "np", ".", "zeros", "(", "[", "self", ".", "state_no", ",", "self", ".", "data", ".", "shape", ...
Creates negative loglikelihood of the model Parameters ---------- beta : np.array Contains untransformed starting values for latent variables Returns ---------- - Negative loglikelihood
[ "Creates", "negative", "loglikelihood", "of", "the", "model" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/ssm/nllt.py#L117-L136
train
RJT1990/pyflux
pyflux/ssm/nllt.py
NLLT.state_likelihood_markov_blanket
def state_likelihood_markov_blanket(self, beta, alpha, col_no): """ Returns Markov blanket of the states given the variance latent variables Parameters ---------- beta : np.array Contains untransformed starting values for latent variables alpha : np.array ...
python
def state_likelihood_markov_blanket(self, beta, alpha, col_no): """ Returns Markov blanket of the states given the variance latent variables Parameters ---------- beta : np.array Contains untransformed starting values for latent variables alpha : np.array ...
[ "def", "state_likelihood_markov_blanket", "(", "self", ",", "beta", ",", "alpha", ",", "col_no", ")", ":", "_", ",", "_", ",", "_", ",", "Q", "=", "self", ".", "_ss_matrices", "(", "beta", ")", "blanket", "=", "np", ".", "append", "(", "0", ",", "s...
Returns Markov blanket of the states given the variance latent variables Parameters ---------- beta : np.array Contains untransformed starting values for latent variables alpha : np.array State matrix Returns ---------- State likelihood
[ "Returns", "Markov", "blanket", "of", "the", "states", "given", "the", "variance", "latent", "variables" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/ssm/nllt.py#L181-L199
train
RJT1990/pyflux
pyflux/ssm/nllt.py
NLLT.markov_blanket
def markov_blanket(self, beta, alpha): """ Creates total Markov blanket for states Parameters ---------- beta : np.array Contains untransformed starting values for latent variables alpha : np.array A vector of states Returns ---------- ...
python
def markov_blanket(self, beta, alpha): """ Creates total Markov blanket for states Parameters ---------- beta : np.array Contains untransformed starting values for latent variables alpha : np.array A vector of states Returns ---------- ...
[ "def", "markov_blanket", "(", "self", ",", "beta", ",", "alpha", ")", ":", "likelihood_blanket", "=", "self", ".", "likelihood_markov_blanket", "(", "beta", ")", "state_blanket", "=", "self", ".", "state_likelihood_markov_blanket", "(", "beta", ",", "alpha", ","...
Creates total Markov blanket for states Parameters ---------- beta : np.array Contains untransformed starting values for latent variables alpha : np.array A vector of states Returns ---------- Markov blanket for states
[ "Creates", "total", "Markov", "blanket", "for", "states" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/ssm/nllt.py#L221-L241
train
RJT1990/pyflux
pyflux/ssm/nllt.py
NLLT._general_approximating_model
def _general_approximating_model(self, beta, T, Z, R, Q, h_approx): """ Creates simplest kind of approximating Gaussian model Parameters ---------- beta : np.array Contains untransformed starting values for latent variables T, Z, R, Q : np.array State sp...
python
def _general_approximating_model(self, beta, T, Z, R, Q, h_approx): """ Creates simplest kind of approximating Gaussian model Parameters ---------- beta : np.array Contains untransformed starting values for latent variables T, Z, R, Q : np.array State sp...
[ "def", "_general_approximating_model", "(", "self", ",", "beta", ",", "T", ",", "Z", ",", "R", ",", "Q", ",", "h_approx", ")", ":", "H", "=", "np", ".", "ones", "(", "self", ".", "data_length", ")", "*", "h_approx", "mu", "=", "np", ".", "zeros", ...
Creates simplest kind of approximating Gaussian model Parameters ---------- beta : np.array Contains untransformed starting values for latent variables T, Z, R, Q : np.array State space matrices used in KFS algorithm h_approx : float Value t...
[ "Creates", "simplest", "kind", "of", "approximating", "Gaussian", "model" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/ssm/nllt.py#L403-L430
train
RJT1990/pyflux
pyflux/ssm/nllt.py
NLLT.fit
def fit(self, optimizer='RMSProp', iterations=1000, print_progress=True, start_diffuse=False, **kwargs): """ Fits the model Parameters ---------- optimizer : string Stochastic optimizer: either RMSProp or ADAM. iterations: int How many iterations to run ...
python
def fit(self, optimizer='RMSProp', iterations=1000, print_progress=True, start_diffuse=False, **kwargs): """ Fits the model Parameters ---------- optimizer : string Stochastic optimizer: either RMSProp or ADAM. iterations: int How many iterations to run ...
[ "def", "fit", "(", "self", ",", "optimizer", "=", "'RMSProp'", ",", "iterations", "=", "1000", ",", "print_progress", "=", "True", ",", "start_diffuse", "=", "False", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_bbvi_fit", "(", "optimizer"...
Fits the model Parameters ---------- optimizer : string Stochastic optimizer: either RMSProp or ADAM. iterations: int How many iterations to run print_progress : bool Whether tp print the ELBO progress or not start_diffuse :...
[ "Fits", "the", "model" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/ssm/nllt.py#L432-L455
train
RJT1990/pyflux
pyflux/var/var.py
create_design_matrix_2
def create_design_matrix_2(Z, data, Y_len, lag_no): """ For Python 2.7 - cythonized version only works for 3.5 """ row_count = 1 for lag in range(1, lag_no+1): for reg in range(Y_len): Z[row_count, :] = data[reg][(lag_no-lag):-lag] row_count += 1 return Z
python
def create_design_matrix_2(Z, data, Y_len, lag_no): """ For Python 2.7 - cythonized version only works for 3.5 """ row_count = 1 for lag in range(1, lag_no+1): for reg in range(Y_len): Z[row_count, :] = data[reg][(lag_no-lag):-lag] row_count += 1 return Z
[ "def", "create_design_matrix_2", "(", "Z", ",", "data", ",", "Y_len", ",", "lag_no", ")", ":", "row_count", "=", "1", "for", "lag", "in", "range", "(", "1", ",", "lag_no", "+", "1", ")", ":", "for", "reg", "in", "range", "(", "Y_len", ")", ":", "...
For Python 2.7 - cythonized version only works for 3.5
[ "For", "Python", "2", ".", "7", "-", "cythonized", "version", "only", "works", "for", "3", ".", "5" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/var/var.py#L18-L29
train
RJT1990/pyflux
pyflux/var/var.py
VAR._create_B
def _create_B(self,Y): """ Creates OLS coefficient matrix Parameters ---------- Y : np.array The dependent variables Y Returns ---------- The coefficient matrix B """ Z = self._create_Z(Y) return np.dot(np.dot(Y,np.t...
python
def _create_B(self,Y): """ Creates OLS coefficient matrix Parameters ---------- Y : np.array The dependent variables Y Returns ---------- The coefficient matrix B """ Z = self._create_Z(Y) return np.dot(np.dot(Y,np.t...
[ "def", "_create_B", "(", "self", ",", "Y", ")", ":", "Z", "=", "self", ".", "_create_Z", "(", "Y", ")", "return", "np", ".", "dot", "(", "np", ".", "dot", "(", "Y", ",", "np", ".", "transpose", "(", "Z", ")", ")", ",", "np", ".", "linalg", ...
Creates OLS coefficient matrix Parameters ---------- Y : np.array The dependent variables Y Returns ---------- The coefficient matrix B
[ "Creates", "OLS", "coefficient", "matrix" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/var/var.py#L97-L111
train
RJT1990/pyflux
pyflux/var/var.py
VAR._create_Z
def _create_Z(self,Y): """ Creates design matrix holding the lagged variables Parameters ---------- Y : np.array The dependent variables Y Returns ---------- The design matrix Z """ Z = np.ones(((self.ylen*self.lags +1),Y[0].shape[0]...
python
def _create_Z(self,Y): """ Creates design matrix holding the lagged variables Parameters ---------- Y : np.array The dependent variables Y Returns ---------- The design matrix Z """ Z = np.ones(((self.ylen*self.lags +1),Y[0].shape[0]...
[ "def", "_create_Z", "(", "self", ",", "Y", ")", ":", "Z", "=", "np", ".", "ones", "(", "(", "(", "self", ".", "ylen", "*", "self", ".", "lags", "+", "1", ")", ",", "Y", "[", "0", "]", ".", "shape", "[", "0", "]", ")", ")", "return", "self...
Creates design matrix holding the lagged variables Parameters ---------- Y : np.array The dependent variables Y Returns ---------- The design matrix Z
[ "Creates", "design", "matrix", "holding", "the", "lagged", "variables" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/var/var.py#L163-L177
train
RJT1990/pyflux
pyflux/var/var.py
VAR._forecast_mean
def _forecast_mean(self,h,t_params,Y,shock_type=None,shock_index=0,shock_value=None,shock_dir='positive',irf_intervals=False): """ Function allows for mean prediction; also allows shock specification for simulations or impulse response effects Parameters ---------- h : int H...
python
def _forecast_mean(self,h,t_params,Y,shock_type=None,shock_index=0,shock_value=None,shock_dir='positive',irf_intervals=False): """ Function allows for mean prediction; also allows shock specification for simulations or impulse response effects Parameters ---------- h : int H...
[ "def", "_forecast_mean", "(", "self", ",", "h", ",", "t_params", ",", "Y", ",", "shock_type", "=", "None", ",", "shock_index", "=", "0", ",", "shock_value", "=", "None", ",", "shock_dir", "=", "'positive'", ",", "irf_intervals", "=", "False", ")", ":", ...
Function allows for mean prediction; also allows shock specification for simulations or impulse response effects Parameters ---------- h : int How many steps ahead to forecast t_params : np.array Transformed latent variables vector Y : np.array ...
[ "Function", "allows", "for", "mean", "prediction", ";", "also", "allows", "shock", "specification", "for", "simulations", "or", "impulse", "response", "effects" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/var/var.py#L179-L237
train
RJT1990/pyflux
pyflux/var/var.py
VAR._shock_create
def _shock_create(self, h, shock_type, shock_index, shock_value, shock_dir, irf_intervals): """ Function creates shocks based on desired specification Parameters ---------- h : int How many steps ahead to forecast shock_type : None or str Type of shock; ...
python
def _shock_create(self, h, shock_type, shock_index, shock_value, shock_dir, irf_intervals): """ Function creates shocks based on desired specification Parameters ---------- h : int How many steps ahead to forecast shock_type : None or str Type of shock; ...
[ "def", "_shock_create", "(", "self", ",", "h", ",", "shock_type", ",", "shock_index", ",", "shock_value", ",", "shock_dir", ",", "irf_intervals", ")", ":", "if", "shock_type", "is", "None", ":", "random", "=", "[", "np", ".", "zeros", "(", "self", ".", ...
Function creates shocks based on desired specification Parameters ---------- h : int How many steps ahead to forecast shock_type : None or str Type of shock; options include None, 'Cov' (simulate from covariance matrix), 'IRF' (impulse response shock) s...
[ "Function", "creates", "shocks", "based", "on", "desired", "specification" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/var/var.py#L269-L336
train
RJT1990/pyflux
pyflux/var/var.py
VAR.estimator_cov
def estimator_cov(self,method): """ Creates covariance matrix for the estimators Parameters ---------- method : str Estimation method Returns ---------- A Covariance Matrix """ Y = np.array([reg[self.lags:] for reg i...
python
def estimator_cov(self,method): """ Creates covariance matrix for the estimators Parameters ---------- method : str Estimation method Returns ---------- A Covariance Matrix """ Y = np.array([reg[self.lags:] for reg i...
[ "def", "estimator_cov", "(", "self", ",", "method", ")", ":", "Y", "=", "np", ".", "array", "(", "[", "reg", "[", "self", ".", "lags", ":", "]", "for", "reg", "in", "self", ".", "data", "]", ")", "Z", "=", "self", ".", "_create_Z", "(", "Y", ...
Creates covariance matrix for the estimators Parameters ---------- method : str Estimation method Returns ---------- A Covariance Matrix
[ "Creates", "covariance", "matrix", "for", "the", "estimators" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/var/var.py#L388-L407
train
RJT1990/pyflux
pyflux/var/var.py
VAR.ols_covariance
def ols_covariance(self): """ Creates OLS estimate of the covariance matrix Returns ---------- The OLS estimate of the covariance matrix """ Y = np.array([reg[self.lags:reg.shape[0]] for reg in self.data]) return (1.0/(Y[0].shape[0]))*np.dot(sel...
python
def ols_covariance(self): """ Creates OLS estimate of the covariance matrix Returns ---------- The OLS estimate of the covariance matrix """ Y = np.array([reg[self.lags:reg.shape[0]] for reg in self.data]) return (1.0/(Y[0].shape[0]))*np.dot(sel...
[ "def", "ols_covariance", "(", "self", ")", ":", "Y", "=", "np", ".", "array", "(", "[", "reg", "[", "self", ".", "lags", ":", "reg", ".", "shape", "[", "0", "]", "]", "for", "reg", "in", "self", ".", "data", "]", ")", "return", "(", "1.0", "/...
Creates OLS estimate of the covariance matrix Returns ---------- The OLS estimate of the covariance matrix
[ "Creates", "OLS", "estimate", "of", "the", "covariance", "matrix" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/var/var.py#L435-L444
train
RJT1990/pyflux
pyflux/var/var.py
VAR.residuals
def residuals(self,Y): """ Creates the model residuals Parameters ---------- Y : np.array The dependent variables Y Returns ---------- The model residuals """ return (Y-np.dot(self._create_B(Y),self._create_Z(Y)))
python
def residuals(self,Y): """ Creates the model residuals Parameters ---------- Y : np.array The dependent variables Y Returns ---------- The model residuals """ return (Y-np.dot(self._create_B(Y),self._create_Z(Y)))
[ "def", "residuals", "(", "self", ",", "Y", ")", ":", "return", "(", "Y", "-", "np", ".", "dot", "(", "self", ".", "_create_B", "(", "Y", ")", ",", "self", ".", "_create_Z", "(", "Y", ")", ")", ")" ]
Creates the model residuals Parameters ---------- Y : np.array The dependent variables Y Returns ---------- The model residuals
[ "Creates", "the", "model", "residuals" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/var/var.py#L648-L661
train
RJT1990/pyflux
pyflux/var/var.py
VAR.construct_wishart
def construct_wishart(self,v,X): """ Constructs a Wishart prior for the covariance matrix """ self.adjust_prior(list(range(int((len(self.latent_variables.z_list)-self.ylen-(self.ylen**2-self.ylen)/2)), int(len(self.latent_variables.z_list)))), fam.InverseWishart(v,X))
python
def construct_wishart(self,v,X): """ Constructs a Wishart prior for the covariance matrix """ self.adjust_prior(list(range(int((len(self.latent_variables.z_list)-self.ylen-(self.ylen**2-self.ylen)/2)), int(len(self.latent_variables.z_list)))), fam.InverseWishart(v,X))
[ "def", "construct_wishart", "(", "self", ",", "v", ",", "X", ")", ":", "self", ".", "adjust_prior", "(", "list", "(", "range", "(", "int", "(", "(", "len", "(", "self", ".", "latent_variables", ".", "z_list", ")", "-", "self", ".", "ylen", "-", "("...
Constructs a Wishart prior for the covariance matrix
[ "Constructs", "a", "Wishart", "prior", "for", "the", "covariance", "matrix" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/var/var.py#L663-L668
train
RJT1990/pyflux
pyflux/ssm/llm.py
LLEV.simulation_smoother
def simulation_smoother(self,beta): """ Koopman's simulation smoother - simulates from states given model latent variables and observations Parameters ---------- beta : np.array Contains untransformed starting values for latent variables Returns ---...
python
def simulation_smoother(self,beta): """ Koopman's simulation smoother - simulates from states given model latent variables and observations Parameters ---------- beta : np.array Contains untransformed starting values for latent variables Returns ---...
[ "def", "simulation_smoother", "(", "self", ",", "beta", ")", ":", "T", ",", "Z", ",", "R", ",", "Q", ",", "H", "=", "self", ".", "_ss_matrices", "(", "beta", ")", "# Generate e_t+ and n_t+", "rnd_h", "=", "np", ".", "random", ".", "normal", "(", "0",...
Koopman's simulation smoother - simulates from states given model latent variables and observations Parameters ---------- beta : np.array Contains untransformed starting values for latent variables Returns ---------- - A simulated state evolution
[ "Koopman", "s", "simulation", "smoother", "-", "simulates", "from", "states", "given", "model", "latent", "variables", "and", "observations" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/ssm/llm.py#L496-L536
train
RJT1990/pyflux
pyflux/ssm/llm.py
LLEV.smoothed_state
def smoothed_state(self,data,beta): """ Creates the negative log marginal likelihood of the model Parameters ---------- data : np.array Data to be smoothed beta : np.array Contains untransformed starting values for latent variables Returns ...
python
def smoothed_state(self,data,beta): """ Creates the negative log marginal likelihood of the model Parameters ---------- data : np.array Data to be smoothed beta : np.array Contains untransformed starting values for latent variables Returns ...
[ "def", "smoothed_state", "(", "self", ",", "data", ",", "beta", ")", ":", "T", ",", "Z", ",", "R", ",", "Q", ",", "H", "=", "self", ".", "_ss_matrices", "(", "beta", ")", "alpha", ",", "V", "=", "univariate_KFS", "(", "data", ",", "Z", ",", "H"...
Creates the negative log marginal likelihood of the model Parameters ---------- data : np.array Data to be smoothed beta : np.array Contains untransformed starting values for latent variables Returns ---------- - Smoothed states
[ "Creates", "the", "negative", "log", "marginal", "likelihood", "of", "the", "model" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/ssm/llm.py#L538-L557
train
RJT1990/pyflux
pyflux/tsm.py
TSM._laplace_fit
def _laplace_fit(self,obj_type): """ Performs a Laplace approximation to the posterior Parameters ---------- obj_type : method Whether a likelihood or a posterior Returns ---------- None (plots posterior) """ # Get Mode and Inverse H...
python
def _laplace_fit(self,obj_type): """ Performs a Laplace approximation to the posterior Parameters ---------- obj_type : method Whether a likelihood or a posterior Returns ---------- None (plots posterior) """ # Get Mode and Inverse H...
[ "def", "_laplace_fit", "(", "self", ",", "obj_type", ")", ":", "# Get Mode and Inverse Hessian information", "y", "=", "self", ".", "fit", "(", "method", "=", "'PML'", ",", "printer", "=", "False", ")", "if", "y", ".", "ihessian", "is", "None", ":", "raise...
Performs a Laplace approximation to the posterior Parameters ---------- obj_type : method Whether a likelihood or a posterior Returns ---------- None (plots posterior)
[ "Performs", "a", "Laplace", "approximation", "to", "the", "posterior" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/tsm.py#L187-L221
train
RJT1990/pyflux
pyflux/tsm.py
TSM._optimize_fit
def _optimize_fit(self, obj_type=None, **kwargs): """ This function fits models using Maximum Likelihood or Penalized Maximum Likelihood """ preopt_search = kwargs.get('preopt_search', True) # If user supplied if obj_type == self.neg_loglik: method = 'MLE' e...
python
def _optimize_fit(self, obj_type=None, **kwargs): """ This function fits models using Maximum Likelihood or Penalized Maximum Likelihood """ preopt_search = kwargs.get('preopt_search', True) # If user supplied if obj_type == self.neg_loglik: method = 'MLE' e...
[ "def", "_optimize_fit", "(", "self", ",", "obj_type", "=", "None", ",", "*", "*", "kwargs", ")", ":", "preopt_search", "=", "kwargs", ".", "get", "(", "'preopt_search'", ",", "True", ")", "# If user supplied", "if", "obj_type", "==", "self", ".", "neg_logl...
This function fits models using Maximum Likelihood or Penalized Maximum Likelihood
[ "This", "function", "fits", "models", "using", "Maximum", "Likelihood", "or", "Penalized", "Maximum", "Likelihood" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/tsm.py#L347-L406
train
RJT1990/pyflux
pyflux/tsm.py
TSM.multivariate_neg_logposterior
def multivariate_neg_logposterior(self,beta): """ Returns negative log posterior, for a model with a covariance matrix Parameters ---------- beta : np.array Contains untransformed starting values for latent_variables Returns ---------- Negative log ...
python
def multivariate_neg_logposterior(self,beta): """ Returns negative log posterior, for a model with a covariance matrix Parameters ---------- beta : np.array Contains untransformed starting values for latent_variables Returns ---------- Negative log ...
[ "def", "multivariate_neg_logposterior", "(", "self", ",", "beta", ")", ":", "post", "=", "self", ".", "neg_loglik", "(", "beta", ")", "for", "k", "in", "range", "(", "0", ",", "self", ".", "z_no", ")", ":", "if", "self", ".", "latent_variables", ".", ...
Returns negative log posterior, for a model with a covariance matrix Parameters ---------- beta : np.array Contains untransformed starting values for latent_variables Returns ---------- Negative log posterior
[ "Returns", "negative", "log", "posterior", "for", "a", "model", "with", "a", "covariance", "matrix" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/tsm.py#L496-L516
train
RJT1990/pyflux
pyflux/tsm.py
TSM.shift_dates
def shift_dates(self,h): """ Auxiliary function for creating dates for forecasts Parameters ---------- h : int How many steps to forecast Returns ---------- A transformed date_index object """ date_index = copy.deepcopy(self.index) ...
python
def shift_dates(self,h): """ Auxiliary function for creating dates for forecasts Parameters ---------- h : int How many steps to forecast Returns ---------- A transformed date_index object """ date_index = copy.deepcopy(self.index) ...
[ "def", "shift_dates", "(", "self", ",", "h", ")", ":", "date_index", "=", "copy", ".", "deepcopy", "(", "self", ".", "index", ")", "date_index", "=", "date_index", "[", "self", ".", "max_lag", ":", "len", "(", "date_index", ")", "]", "if", "self", "....
Auxiliary function for creating dates for forecasts Parameters ---------- h : int How many steps to forecast Returns ---------- A transformed date_index object
[ "Auxiliary", "function", "for", "creating", "dates", "for", "forecasts" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/tsm.py#L518-L559
train
RJT1990/pyflux
pyflux/tsm.py
TSM.plot_z
def plot_z(self, indices=None,figsize=(15,5),**kwargs): """ Plots latent variables by calling latent parameters object Returns ---------- Pretty plot """ self.latent_variables.plot_z(indices=indices,figsize=figsize,**kwargs)
python
def plot_z(self, indices=None,figsize=(15,5),**kwargs): """ Plots latent variables by calling latent parameters object Returns ---------- Pretty plot """ self.latent_variables.plot_z(indices=indices,figsize=figsize,**kwargs)
[ "def", "plot_z", "(", "self", ",", "indices", "=", "None", ",", "figsize", "=", "(", "15", ",", "5", ")", ",", "*", "*", "kwargs", ")", ":", "self", ".", "latent_variables", ".", "plot_z", "(", "indices", "=", "indices", ",", "figsize", "=", "figsi...
Plots latent variables by calling latent parameters object Returns ---------- Pretty plot
[ "Plots", "latent", "variables", "by", "calling", "latent", "parameters", "object" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/tsm.py#L579-L586
train
RJT1990/pyflux
pyflux/ssm/ndynlin.py
NDynReg.evo_blanket
def evo_blanket(self, beta, alpha): """ Creates Markov blanket for the variance latent variables Parameters ---------- beta : np.array Contains untransformed starting values for latent variables alpha : np.array A vector of states Returns ...
python
def evo_blanket(self, beta, alpha): """ Creates Markov blanket for the variance latent variables Parameters ---------- beta : np.array Contains untransformed starting values for latent variables alpha : np.array A vector of states Returns ...
[ "def", "evo_blanket", "(", "self", ",", "beta", ",", "alpha", ")", ":", "# Markov blanket for each state", "evo_blanket", "=", "np", ".", "zeros", "(", "self", ".", "state_no", ")", "for", "i", "in", "range", "(", "evo_blanket", ".", "shape", "[", "0", "...
Creates Markov blanket for the variance latent variables Parameters ---------- beta : np.array Contains untransformed starting values for latent variables alpha : np.array A vector of states Returns ---------- Markov blanket for variance...
[ "Creates", "Markov", "blanket", "for", "the", "variance", "latent", "variables" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/ssm/ndynlin.py#L233-L258
train
RJT1990/pyflux
pyflux/ssm/ndynlin.py
NDynReg.log_p_blanket
def log_p_blanket(self, beta): """ Creates complete Markov blanket for latent variables Parameters ---------- beta : np.array Contains untransformed starting values for latent variables Returns ---------- Markov blanket for latent variables "...
python
def log_p_blanket(self, beta): """ Creates complete Markov blanket for latent variables Parameters ---------- beta : np.array Contains untransformed starting values for latent variables Returns ---------- Markov blanket for latent variables "...
[ "def", "log_p_blanket", "(", "self", ",", "beta", ")", ":", "states", "=", "np", ".", "zeros", "(", "[", "self", ".", "state_no", ",", "self", ".", "data", ".", "shape", "[", "0", "]", "]", ")", "for", "state_i", "in", "range", "(", "self", ".", ...
Creates complete Markov blanket for latent variables Parameters ---------- beta : np.array Contains untransformed starting values for latent variables Returns ---------- Markov blanket for latent variables
[ "Creates", "complete", "Markov", "blanket", "for", "latent", "variables" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/ssm/ndynlin.py#L260-L276
train
RJT1990/pyflux
pyflux/families/exponential.py
Exponential.logpdf
def logpdf(self, mu): """ Log PDF for Exponential prior Parameters ---------- mu : float Latent variable for which the prior is being formed over Returns ---------- - log(p(mu)) """ if self.transform is not None: m...
python
def logpdf(self, mu): """ Log PDF for Exponential prior Parameters ---------- mu : float Latent variable for which the prior is being formed over Returns ---------- - log(p(mu)) """ if self.transform is not None: m...
[ "def", "logpdf", "(", "self", ",", "mu", ")", ":", "if", "self", ".", "transform", "is", "not", "None", ":", "mu", "=", "self", ".", "transform", "(", "mu", ")", "return", "ss", ".", "expon", ".", "logpdf", "(", "mu", ",", "self", ".", "lmd0", ...
Log PDF for Exponential prior Parameters ---------- mu : float Latent variable for which the prior is being formed over Returns ---------- - log(p(mu))
[ "Log", "PDF", "for", "Exponential", "prior" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/exponential.py#L177-L192
train
RJT1990/pyflux
pyflux/families/exponential.py
Exponential.markov_blanket
def markov_blanket(y, mean, scale, shape, skewness): """ Markov blanket for the Exponential distribution Parameters ---------- y : np.ndarray univariate time series mean : np.ndarray array of location parameters for the Exponential distribution ...
python
def markov_blanket(y, mean, scale, shape, skewness): """ Markov blanket for the Exponential distribution Parameters ---------- y : np.ndarray univariate time series mean : np.ndarray array of location parameters for the Exponential distribution ...
[ "def", "markov_blanket", "(", "y", ",", "mean", ",", "scale", ",", "shape", ",", "skewness", ")", ":", "return", "ss", ".", "expon", ".", "logpdf", "(", "x", "=", "y", ",", "scale", "=", "1", "/", "mean", ")" ]
Markov blanket for the Exponential distribution Parameters ---------- y : np.ndarray univariate time series mean : np.ndarray array of location parameters for the Exponential distribution scale : float scale parameter for the Exponential dis...
[ "Markov", "blanket", "for", "the", "Exponential", "distribution" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/exponential.py#L195-L219
train
RJT1990/pyflux
pyflux/families/exponential.py
Exponential.pdf
def pdf(self, mu): """ PDF for Exponential prior Parameters ---------- mu : float Latent variable for which the prior is being formed over Returns ---------- - p(mu) """ if self.transform is not None: mu = self.tra...
python
def pdf(self, mu): """ PDF for Exponential prior Parameters ---------- mu : float Latent variable for which the prior is being formed over Returns ---------- - p(mu) """ if self.transform is not None: mu = self.tra...
[ "def", "pdf", "(", "self", ",", "mu", ")", ":", "if", "self", ".", "transform", "is", "not", "None", ":", "mu", "=", "self", ".", "transform", "(", "mu", ")", "return", "ss", ".", "expon", ".", "pdf", "(", "mu", ",", "self", ".", "lmd0", ")" ]
PDF for Exponential prior Parameters ---------- mu : float Latent variable for which the prior is being formed over Returns ---------- - p(mu)
[ "PDF", "for", "Exponential", "prior" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/exponential.py#L277-L292
train
RJT1990/pyflux
pyflux/inference/bbvi.py
BBVI.change_parameters
def change_parameters(self,params): """ Utility function for changing the approximate distribution parameters """ no_of_params = 0 for core_param in range(len(self.q)): for approx_param in range(self.q[core_param].param_no): self.q[core_param].vi_chang...
python
def change_parameters(self,params): """ Utility function for changing the approximate distribution parameters """ no_of_params = 0 for core_param in range(len(self.q)): for approx_param in range(self.q[core_param].param_no): self.q[core_param].vi_chang...
[ "def", "change_parameters", "(", "self", ",", "params", ")", ":", "no_of_params", "=", "0", "for", "core_param", "in", "range", "(", "len", "(", "self", ".", "q", ")", ")", ":", "for", "approx_param", "in", "range", "(", "self", ".", "q", "[", "core_...
Utility function for changing the approximate distribution parameters
[ "Utility", "function", "for", "changing", "the", "approximate", "distribution", "parameters" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/inference/bbvi.py#L54-L62
train
RJT1990/pyflux
pyflux/inference/bbvi.py
BBVI.current_parameters
def current_parameters(self): """ Obtains an array with the current parameters """ current = [] for core_param in range(len(self.q)): for approx_param in range(self.q[core_param].param_no): current.append(self.q[core_param].vi_return_param(approx_param...
python
def current_parameters(self): """ Obtains an array with the current parameters """ current = [] for core_param in range(len(self.q)): for approx_param in range(self.q[core_param].param_no): current.append(self.q[core_param].vi_return_param(approx_param...
[ "def", "current_parameters", "(", "self", ")", ":", "current", "=", "[", "]", "for", "core_param", "in", "range", "(", "len", "(", "self", ".", "q", ")", ")", ":", "for", "approx_param", "in", "range", "(", "self", ".", "q", "[", "core_param", "]", ...
Obtains an array with the current parameters
[ "Obtains", "an", "array", "with", "the", "current", "parameters" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/inference/bbvi.py#L71-L79
train
RJT1990/pyflux
pyflux/inference/bbvi.py
BBVI.cv_gradient
def cv_gradient(self,z): """ The control variate augmented Monte Carlo gradient estimate """ gradient = np.zeros(np.sum(self.approx_param_no)) z_t = z.T log_q = self.normal_log_q(z.T) log_p = self.log_p(z.T) grad_log_q = self.grad_log_q(z) gr...
python
def cv_gradient(self,z): """ The control variate augmented Monte Carlo gradient estimate """ gradient = np.zeros(np.sum(self.approx_param_no)) z_t = z.T log_q = self.normal_log_q(z.T) log_p = self.log_p(z.T) grad_log_q = self.grad_log_q(z) gr...
[ "def", "cv_gradient", "(", "self", ",", "z", ")", ":", "gradient", "=", "np", ".", "zeros", "(", "np", ".", "sum", "(", "self", ".", "approx_param_no", ")", ")", "z_t", "=", "z", ".", "T", "log_q", "=", "self", ".", "normal_log_q", "(", "z", ".",...
The control variate augmented Monte Carlo gradient estimate
[ "The", "control", "variate", "augmented", "Monte", "Carlo", "gradient", "estimate" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/inference/bbvi.py#L81-L96
train
RJT1990/pyflux
pyflux/inference/bbvi.py
BBVI.draw_variables
def draw_variables(self): """ Draw parameters from the approximating distributions """ z = self.q[0].draw_variable_local(self.sims) for i in range(1,len(self.q)): z = np.vstack((z,self.q[i].draw_variable_local(self.sims))) return z
python
def draw_variables(self): """ Draw parameters from the approximating distributions """ z = self.q[0].draw_variable_local(self.sims) for i in range(1,len(self.q)): z = np.vstack((z,self.q[i].draw_variable_local(self.sims))) return z
[ "def", "draw_variables", "(", "self", ")", ":", "z", "=", "self", ".", "q", "[", "0", "]", ".", "draw_variable_local", "(", "self", ".", "sims", ")", "for", "i", "in", "range", "(", "1", ",", "len", "(", "self", ".", "q", ")", ")", ":", "z", ...
Draw parameters from the approximating distributions
[ "Draw", "parameters", "from", "the", "approximating", "distributions" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/inference/bbvi.py#L129-L136
train
RJT1990/pyflux
pyflux/inference/bbvi.py
BBVI.grad_log_q
def grad_log_q(self,z): """ The gradients of the approximating distributions """ param_count = 0 grad = np.zeros((np.sum(self.approx_param_no),self.sims)) for core_param in range(len(self.q)): for approx_param in range(self.q[core_param].param_no): ...
python
def grad_log_q(self,z): """ The gradients of the approximating distributions """ param_count = 0 grad = np.zeros((np.sum(self.approx_param_no),self.sims)) for core_param in range(len(self.q)): for approx_param in range(self.q[core_param].param_no): ...
[ "def", "grad_log_q", "(", "self", ",", "z", ")", ":", "param_count", "=", "0", "grad", "=", "np", ".", "zeros", "(", "(", "np", ".", "sum", "(", "self", ".", "approx_param_no", ")", ",", "self", ".", "sims", ")", ")", "for", "core_param", "in", "...
The gradients of the approximating distributions
[ "The", "gradients", "of", "the", "approximating", "distributions" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/inference/bbvi.py#L155-L165
train
RJT1990/pyflux
pyflux/inference/bbvi.py
BBVIM.print_progress
def print_progress(self, i, current_params): """ Prints the current ELBO at every decile of total iterations """ for split in range(1,11): if i == (round(self.iterations/10*split)-1): post = -self.full_neg_posterior(current_params) approx = sel...
python
def print_progress(self, i, current_params): """ Prints the current ELBO at every decile of total iterations """ for split in range(1,11): if i == (round(self.iterations/10*split)-1): post = -self.full_neg_posterior(current_params) approx = sel...
[ "def", "print_progress", "(", "self", ",", "i", ",", "current_params", ")", ":", "for", "split", "in", "range", "(", "1", ",", "11", ")", ":", "if", "i", "==", "(", "round", "(", "self", ".", "iterations", "/", "10", "*", "split", ")", "-", "1", ...
Prints the current ELBO at every decile of total iterations
[ "Prints", "the", "current", "ELBO", "at", "every", "decile", "of", "total", "iterations" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/inference/bbvi.py#L441-L451
train
RJT1990/pyflux
pyflux/inference/bbvi.py
BBVIM.run
def run(self): """ The core BBVI routine - draws Monte Carlo gradients and uses a stochastic optimizer. """ # Initialization assumptions z = self.draw_normal_initial() gradient = self.cv_gradient_initial(z) gradient[np.isnan(gradient)] = 0 variance = np.p...
python
def run(self): """ The core BBVI routine - draws Monte Carlo gradients and uses a stochastic optimizer. """ # Initialization assumptions z = self.draw_normal_initial() gradient = self.cv_gradient_initial(z) gradient[np.isnan(gradient)] = 0 variance = np.p...
[ "def", "run", "(", "self", ")", ":", "# Initialization assumptions", "z", "=", "self", ".", "draw_normal_initial", "(", ")", "gradient", "=", "self", ".", "cv_gradient_initial", "(", "z", ")", "gradient", "[", "np", ".", "isnan", "(", "gradient", ")", "]",...
The core BBVI routine - draws Monte Carlo gradients and uses a stochastic optimizer.
[ "The", "core", "BBVI", "routine", "-", "draws", "Monte", "Carlo", "gradients", "and", "uses", "a", "stochastic", "optimizer", "." ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/inference/bbvi.py#L453-L502
train
RJT1990/pyflux
pyflux/garch/segarchm.py
logpdf
def logpdf(x, shape, loc=0.0, scale=1.0, skewness=1.0): """ Log PDF for the Skew-t distribution Parameters ---------- x : np.array random variables shape : float The degrees of freedom for the skew-t distribution loc : np.array The location parameter for the skew-t...
python
def logpdf(x, shape, loc=0.0, scale=1.0, skewness=1.0): """ Log PDF for the Skew-t distribution Parameters ---------- x : np.array random variables shape : float The degrees of freedom for the skew-t distribution loc : np.array The location parameter for the skew-t...
[ "def", "logpdf", "(", "x", ",", "shape", ",", "loc", "=", "0.0", ",", "scale", "=", "1.0", ",", "skewness", "=", "1.0", ")", ":", "m1", "=", "(", "np", ".", "sqrt", "(", "shape", ")", "*", "sp", ".", "gamma", "(", "(", "shape", "-", "1.0", ...
Log PDF for the Skew-t distribution Parameters ---------- x : np.array random variables shape : float The degrees of freedom for the skew-t distribution loc : np.array The location parameter for the skew-t distribution scale : float The scale of the distributi...
[ "Log", "PDF", "for", "the", "Skew", "-", "t", "distribution" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/garch/segarchm.py#L17-L44
train